示例#1
0
    def test_align_dimension_shrink(self):
        """
        Tests alignment of a data cube with another data cube along the temporal dimension. Since the second
        data cube contains less data, the original data cube will also contain less data, i.e. the same timestamps as
        in the other data cube.
        """

        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_1.align_dimension(dc_2, name='time', inplace=True)
        assert sorted(list(set(
            dc_1['time']))) == [self.timestamps[1], self.timestamps[3]]
示例#2
0
    def test_align_dimension_grow(self):
        """
        Tests alignment of a data cube with another data cube along the temporal dimension. Since the second
        data cube contains more data, the original data cube will also contain more data, i.e. the same timestamps as
        in the other data cube by duplicating the entries.
        """

        dc_1 = EODataCube(filepaths=self.gt_filepaths,
                          smart_filename_class=SgrtFilename,
                          dimensions=['time'])
        dc_2 = dc_1.clone()
        timestamps = list(dc_1['time'])
        subset_idxs = [
            timestamps.index(self.timestamps[0]),
            timestamps.index(self.timestamps[1]),
            timestamps.index(self.timestamps[2]),
            timestamps.index(self.timestamps[3])
        ]
        dc_1.inventory = dc_1.inventory.iloc[subset_idxs]

        dc_1.align_dimension(dc_2, name='time', inplace=True)
        assert (dc_1['time'] == dc_2['time']).all()
示例#3
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']))