@@ -744,6 +744,93 @@ def test_resample_spatial(s2cube):
744
744
]
745
745
746
746
747
+ def test_resample_cube_spatial (s2cube ):
748
+ cube1 = s2cube .resample_spatial (resolution = [2.0 , 3.0 ], projection = 4578 )
749
+ cube2 = s2cube .resample_spatial (resolution = 10 , projection = 32631 )
750
+
751
+ cube12 = cube1 .resample_cube_spatial (target = cube2 )
752
+ assert get_download_graph (cube12 , drop_load_collection = True , drop_save_result = True ) == {
753
+ "resamplespatial1" : {
754
+ "process_id" : "resample_spatial" ,
755
+ "arguments" : {
756
+ "align" : "upper-left" ,
757
+ "data" : {"from_node" : "loadcollection1" },
758
+ "method" : "near" ,
759
+ "projection" : 4578 ,
760
+ "resolution" : [2.0 , 3.0 ],
761
+ },
762
+ },
763
+ "resamplespatial2" : {
764
+ "process_id" : "resample_spatial" ,
765
+ "arguments" : {
766
+ "align" : "upper-left" ,
767
+ "data" : {"from_node" : "loadcollection1" },
768
+ "method" : "near" ,
769
+ "projection" : 32631 ,
770
+ "resolution" : 10 ,
771
+ },
772
+ },
773
+ "resamplecubespatial1" : {
774
+ "arguments" : {
775
+ "data" : {"from_node" : "resamplespatial1" },
776
+ "method" : "near" ,
777
+ "target" : {"from_node" : "resamplespatial2" },
778
+ },
779
+ "process_id" : "resample_cube_spatial" ,
780
+ },
781
+ }
782
+ assert cube12 .metadata .spatial_dimensions == [
783
+ SpatialDimension (name = "x" , extent = None , crs = 32631 , step = 10 ),
784
+ SpatialDimension (name = "y" , extent = None , crs = 32631 , step = 10 ),
785
+ ]
786
+
787
+ cube21 = cube2 .resample_cube_spatial (target = cube1 )
788
+ assert get_download_graph (cube21 , drop_load_collection = True , drop_save_result = True ) == {
789
+ "resamplespatial1" : {
790
+ "process_id" : "resample_spatial" ,
791
+ "arguments" : {
792
+ "align" : "upper-left" ,
793
+ "data" : {"from_node" : "loadcollection1" },
794
+ "method" : "near" ,
795
+ "projection" : 32631 ,
796
+ "resolution" : 10 ,
797
+ },
798
+ },
799
+ "resamplespatial2" : {
800
+ "process_id" : "resample_spatial" ,
801
+ "arguments" : {
802
+ "align" : "upper-left" ,
803
+ "data" : {"from_node" : "loadcollection1" },
804
+ "method" : "near" ,
805
+ "projection" : 4578 ,
806
+ "resolution" : [2.0 , 3.0 ],
807
+ },
808
+ },
809
+ "resamplecubespatial1" : {
810
+ "arguments" : {
811
+ "data" : {"from_node" : "resamplespatial1" },
812
+ "method" : "near" ,
813
+ "target" : {"from_node" : "resamplespatial2" },
814
+ },
815
+ "process_id" : "resample_cube_spatial" ,
816
+ },
817
+ }
818
+ assert cube21 .metadata .spatial_dimensions == [
819
+ SpatialDimension (name = "x" , extent = None , crs = 4578 , step = 2.0 ),
820
+ SpatialDimension (name = "y" , extent = None , crs = 4578 , step = 3.0 ),
821
+ ]
822
+
823
+
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
829
+
830
+ cube12 = cube1 .resample_cube_spatial (target = cube2 )
831
+ assert cube12 .metadata is None
832
+
833
+
747
834
748
835
749
836
def test_merge (s2cube , api_version , test_data ):
0 commit comments