@@ -411,7 +411,6 @@ def get_data(self, index, metadata=False):
411411 if temp_dir :
412412 temp_dir .cleanup ()
413413 x_imgs = np .array (x_imgs )
414-
415414 if (
416415 SENTINEL_2 in self .platforms or LANDSAT_8 in self .platforms
417416 ) and self .cloud_sort :
@@ -420,7 +419,6 @@ def get_data(self, index, metadata=False):
420419 x_imgs = filters .order_tensor_on_cloud_mask (
421420 x_imgs , max_images = self .timesteps , sat_platform = sat_platform
422421 )
423-
424422 if not self .train :
425423 if metadata :
426424 return x_imgs , x_meta
@@ -927,6 +925,27 @@ def process_data(self):
927925 raise NotImplementedError
928926
929927
928+ """
929+
930+ read data
931+ (several option)
932+ but return alwasys this shape
933+
934+
935+ process data
936+ a lot of options but shuold always be able to do:
937+
938+ upsampling (optional)
939+ augmentaiton (Optional)
940+ padding (Optional)
941+ nan_sorter (Optional)
942+ cloud sorter (Optional)
943+
944+ return data
945+
946+ """
947+
948+
930949class Data (Protocol ):
931950 x_tensor : np .array
932951 y_tensor : np .array
@@ -971,8 +990,31 @@ def padd(self, padding: int = 0, padding_mode="same"):
971990 mode = padding_mode ,
972991 )
973992
974- def cloud_sort (self ):
975- ...
993+ def nan_value_sorter (self ):
994+ # TODO: Working only when timesteps is the first dimension. Solve to general case
995+ # to integrate batch.
996+ # That is why the loop on batch.
997+ ordered_tensor = []
998+ for batch_images in self .x_tensor :
999+ # Choose and order timesteps by level of nan_value density.
1000+ # Expects X -> (Timesteps, num_bands, width, height)
1001+ x_imgs = filters .order_tensor_on_masks (
1002+ batch_images , self .x_nan_value , max_images = self .x_tensor .timesteps
1003+ )
1004+ ordered_tensor .append (x_imgs )
1005+ self .x_tensor = ordered_tensor
1006+
1007+ def cloud_sorter (self ):
1008+ # TODO: Working only after data is read, so it is expecting shape:
1009+ # NOT working probably.
1010+ if (
1011+ SENTINEL_2 in self .platforms or LANDSAT_8 in self .platforms
1012+ ) and self .cloud_sort :
1013+ # Now we only use one platform.
1014+ sat_platform = [f for f in self .platforms ][0 ]
1015+ self .x_tensor = filters .order_tensor_on_cloud_mask (
1016+ self .x_tensor , max_images = self .timesteps , sat_platform = sat_platform
1017+ )
9761018
9771019 def normalize (self , normalization : float = None ):
9781020 if normalization is not None :
@@ -1011,6 +1053,9 @@ def __init__(self, x_shape: XShape1D, y_shape: YShape1D):
10111053 self .x_shape = x_shape
10121054 self .y_shape = y_shape
10131055
1056+ def padding (self ):
1057+ pass
1058+
10141059
10151060class LearningMode :
10161061 def __init__ ():
0 commit comments