コード例 #1
0
ファイル: datasets.py プロジェクト: HatemMn/infrastructure
 def __init__(self, **kwargs):
     super().__init__(dataset_id='S2CESBIO38', **kwargs)
     self.bandregisterfinder = filefinders.BandRegisterFinder(
         self.dataset_metadata, self.in_path)
     self.filefinder = filefinders.FileFinderBySubStrings(self.in_path)
     self.bandloader = loaders.MultiFileBandLoader(self.dataset_metadata,
                                                   imread=self._band_imread)
     self.maskloader = loaders.ImageLoader(self.dataset_metadata,
                                           imread=tif.imread)
     self.normaliser = normalisers.Landsat8Normaliser(self.dataset_metadata)
     self.encoder = encoders.MapByValueEncoder(self.dataset_metadata)
     self.descriptorloader = loaders.SimpleSpectralDescriptorsLoader(
         self.dataset_metadata)
     self.descriptors = self.descriptorloader(
         band_ids=self.selected_band_ids)
     self.resizer = resizers.BandsMaskResizer(self.dataset_metadata,
                                              to_array=True,
                                              strict=False)
     self.splitter = splitters.SlidingWindowSplitter(
         self.patch_size,
         self.stride,
         filters=[
             filters.FilterByMaskClass(threshold=self.nodata_threshold,
                                       target_index=0)
         ])
     self.outputmetadatawriter = writers.LandsatMetadataWriter(
         self.dataset_metadata, sun_elevation=False)
     self.outputorganiser = misc.BySceneAndPatchOrganiser()
     self.datasaver = savers.ImageMaskDescriptorNumpySaver(overwrite=True)
     self.metadatasaver = savers.MetadataJsonSaver(overwrite=True)
     self.sensat_username = None
     self.sensat_passwd = None
     self.download_scenes()
コード例 #2
0
def test_FilterByMaskClass():

    bands = None
    mask0 = np.concatenate((np.ones((10, 10, 1)), np.zeros((10, 10, 1))),
                           axis=2)
    mask1 = np.concatenate((np.zeros((10, 10, 1)), np.ones((10, 10, 1))),
                           axis=2)

    mask2 = copy.copy(mask0)
    mask2[2, 4, :] = [0, 1]
    mask3 = copy.copy(mask1)
    mask3[5, 3, :] = [1, 0]
    mask4 = np.concatenate((mask0, mask1), axis=1)
    mask5 = np.concatenate((mask0, mask0, mask1), axis=1)
    mask6 = np.concatenate((mask1, mask0, mask1), axis=1)
    mask7 = np.zeros((10, 10, 4))

    filter0 = filters.FilterByMaskClass(target_index=0)
    filter1 = filters.FilterByMaskClass(target_index=1)
    filter2 = filters.FilterByMaskClass(target_index=0, threshold=0.5)
    filter3 = filters.FilterByMaskClass()
    assert not filter0(bands, mask0)
    assert filter0(bands, mask1)
    assert not filter0(bands, mask2)
    assert not filter0(bands, mask3)
    assert not filter0(bands, mask4)

    assert filter1(bands, mask0)
    assert not filter1(bands, mask1)
    assert not filter1(bands, mask2)
    assert not filter1(bands, mask3)
    assert not filter1(bands, mask4)

    assert not filter2(bands, mask0)
    assert filter2(bands, mask1)
    assert not filter2(bands, mask2)
    assert filter2(bands, mask3)
    assert filter2(bands, mask4)
    assert not filter2(bands, mask5)
    assert filter2(bands, mask6)

    assert filter3(bands, mask0)
    assert filter3(bands, mask1)
    assert not filter3(bands, mask7)
コード例 #3
0
ファイル: datasets.py プロジェクト: ESA-PhiLab/eo4ai
    def __init__(self, **kwargs):
        super().__init__(dataset_id='S2IRIS513', **kwargs)

        self.filefinder = filefinders.FileFinderBySubStrings(self.in_path)
        self.bandloader = loaders.SingleFileBandLoader(
                                                    self.dataset_metadata,
                                                    imread=np.load
                                                    )
        self.maskloader = loaders.ImageLoader(
                                            self.dataset_metadata,
                                            imread=np.load
                                            )

        self.descriptorloader = loaders.SimpleSpectralDescriptorsLoader(
                                                        self.dataset_metadata
                                                        )
        self.descriptors = self.descriptorloader(
                                                band_ids=self.selected_band_ids
                                                )

        self.resizer = resizers.BandsMaskResizer(
                                                self.dataset_metadata,
                                                to_array=True,
                                                strict=False
                                                )

        self.splitter = splitters.SlidingWindowSplitter(
                                        self.patch_size,
                                        self.stride,
                                        filters=[filters.FilterByMaskClass(
                                            threshold=self.nodata_threshold,
                                            target_index=0
                                            )]
                                        )

        self.outputmetadatawriter = writers.LandsatMetadataWriter(
                                                        self.dataset_metadata,
                                                        sun_elevation=False
                                                        )
        self.outputorganiser = misc.BySceneAndPatchOrganiser()
        self.datasaver = savers.ImageMaskDescriptorNumpySaver(overwrite=True)
        self.metadatasaver = savers.MetadataJsonSaver(overwrite=True)