@@ -744,6 +744,26 @@ def test_resample_spatial(s2cube):
744
744
]
745
745
746
746
747
+ def test_resample_spatial_no_metadata (s2cube_without_metadata ):
748
+ cube = s2cube_without_metadata .resample_spatial (resolution = (3 , 5 ), projection = 4578 )
749
+ assert get_download_graph (cube , drop_load_collection = True , drop_save_result = True ) == {
750
+ "resamplespatial1" : {
751
+ "process_id" : "resample_spatial" ,
752
+ "arguments" : {
753
+ "data" : {"from_node" : "loadcollection1" },
754
+ "resolution" : [3 , 5 ],
755
+ "projection" : 4578 ,
756
+ "method" : "near" ,
757
+ "align" : "upper-left" ,
758
+ },
759
+ }
760
+ }
761
+ assert cube .metadata .spatial_dimensions == [
762
+ SpatialDimension (name = "x" , extent = [None , None ], crs = 4578 , step = 3.0 ),
763
+ SpatialDimension (name = "y" , extent = [None , None ], crs = 4578 , step = 5.0 ),
764
+ ]
765
+
766
+
747
767
def test_resample_cube_spatial (s2cube ):
748
768
cube1 = s2cube .resample_spatial (resolution = [2.0 , 3.0 ], projection = 4578 )
749
769
cube2 = s2cube .resample_spatial (resolution = 10 , projection = 32631 )
@@ -821,16 +841,27 @@ def test_resample_cube_spatial(s2cube):
821
841
]
822
842
823
843
824
- def test_resample_cube_spatial_no_metadata (s2cube_without_metadata ):
825
- cube1 = s2cube_without_metadata .resample_spatial (resolution = [2.0 , 3.0 ], projection = 4578 )
826
- cube2 = s2cube_without_metadata .resample_spatial (resolution = 10 , projection = 32631 )
827
- assert cube1 .metadata is None
828
- assert cube2 .metadata is None
844
+ def test_resample_cube_spatial_no_source_metadata (s2cube , s2cube_without_metadata ):
845
+ cube = s2cube_without_metadata
846
+ target = s2cube .resample_spatial (resolution = 10 , projection = 32631 )
847
+ assert cube .metadata is None
848
+ assert target .metadata is not None
849
+
850
+ result = cube .resample_cube_spatial (target = target )
851
+ assert result .metadata .spatial_dimensions == [
852
+ SpatialDimension (name = "x" , extent = None , crs = 32631 , step = 10 ),
853
+ SpatialDimension (name = "y" , extent = None , crs = 32631 , step = 10 ),
854
+ ]
829
855
830
- cube12 = cube1 .resample_cube_spatial (target = cube2 )
831
- assert cube12 .metadata is None
832
856
857
+ def test_resample_cube_spatial_no_target_metadata (s2cube , s2cube_without_metadata ):
858
+ cube = s2cube .resample_spatial (resolution = 10 , projection = 32631 )
859
+ target = s2cube_without_metadata
860
+ assert cube .metadata is not None
861
+ assert target .metadata is None
833
862
863
+ result = cube .resample_cube_spatial (target = target )
864
+ assert result .metadata is None
834
865
835
866
836
867
def test_merge (s2cube , api_version , test_data ):
0 commit comments