def test_intersect_dimensions(self): """ Tests simple data cube intersection, i.e. if all data from a second datacube is properly intersected with the data of to the original data cube. """ dc_1 = EODataCube(filepaths=self.gt_filepaths, smart_filename_class=SgrtFilename, dimensions=['time', 'pol']) dc_2 = EODataCube(filepaths=self.gt_filepaths, smart_filename_class=SgrtFilename, dimensions=['time', 'orbit_direction']) dc_intersected = dc_1.intersect(dc_2) assert len(dc_intersected) == len(self.gt_filepaths) assert 'pol' not in dc_intersected.dimensions assert 'orbit_direction' not in dc_intersected.dimensions assert 'time' in dc_intersected.dimensions
def test_intersect_empty(self): """ Tests data cube intersection on the temporal dimension, i.e. if all data from a second datacube is properly intersected with the data of to the original data cube according to matching timestamps. The result should be empty due to non-overlapping timestamps. """ # empty data cube when an intersection is applied dc_1 = EODataCube(filepaths=self.gt_filepaths, smart_filename_class=SgrtFilename, dimensions=['time', 'pol']) dc_2 = EODataCube(filepaths=self.gt_filepaths, smart_filename_class=SgrtFilename, dimensions=['time', 'orbit_direction']) dc_1.inventory = dc_1.inventory[dc_1['time'] == self.timestamps[0]] dc_2.inventory = dc_2.inventory[dc_2['time'] == self.timestamps[1]] dc_intersected = dc_1.intersect(dc_2, on_dimension='time') assert len(dc_intersected) == 0
def test_intersect_align_dimension_shrink(self): """ Tests matching of entries with two different methods, which should yield the same result: data cube intersection and data cube alignment on the temporal dimension. """ dc_1 = EODataCube(filepaths=self.gt_filepaths, smart_filename_class=SgrtFilename, dimensions=['time']) dc_2 = dc_1.clone() dc_2.inventory = dc_2.inventory[dc_2['time'] != self.timestamps[0]] dc_2.inventory = dc_2.inventory[dc_2['time'] != self.timestamps[2]] dc_aligned = dc_1.align_dimension(dc_2, name='time', inplace=False) dc_intersected = dc_1.intersect(dc_2, on_dimension='time', inplace=False) assert sorted(list(dc_aligned['time'])) == sorted( list(dc_intersected['time']))