Exemple #1
0
    def test_to_jsonable_dict(self):
        cfg = EnPTConfig()
        jsonable_dict = cfg.to_jsonable_dict()
        self.assertIsInstance(cfg.to_jsonable_dict(), dict)

        # test if dict is jsonable
        dumps(jsonable_dict)
Exemple #2
0
    def test_to_dict_validity(self):
        cfg = EnPTConfig()
        params = cfg.to_dict()
        self.assertIsInstance(cfg.to_jsonable_dict(), dict)

        # check validity
        EnPTValidator(allow_unknown=True,
                      schema=enpt_schema_config_output).validate(params)
Exemple #3
0
    def setUpClass(cls) -> None:
        config = EnPTConfig(**config_for_testing_dlr)

        # get lons / lats
        with TemporaryDirectory() as td, ZipFile(config.path_l1b_enmap_image,
                                                 "r") as zf:
            zf.extractall(td)
            cls.L1_obj = L1B_Reader(config=config).read_inputdata(
                root_dir_main=td, compute_snr=False)

        cls.data2transform_vnir_sensorgeo_3D = cls.L1_obj.vnir.data
        cls.data2transform_vnir_sensorgeo_2D = cls.L1_obj.vnir.data[:, :,
                                                                    0]  # a single VNIR band in sensor geometry
        cls.gA2transform_vnir_mapgeo = GeoArray(
            config.path_dem)  # a DEM in map geometry given by the user
        cls.data2transform_swir_sensorgeo_3D = cls.L1_obj.swir.data
        cls.data2transform_swir_sensorgeo_2D = cls.L1_obj.swir.data[:, :,
                                                                    -1]  # a single SWIR band in sensor geometry
        cls.gA2transform_swir_mapgeo = GeoArray(
            config.path_dem)  # a DEM in map geometry given by the user

        cls.VS_SGT = VNIR_SWIR_SensorGeometryTransformer(
            lons_vnir=cls.L1_obj.meta.vnir.lons,
            lats_vnir=cls.L1_obj.meta.vnir.lats,
            lons_swir=cls.L1_obj.meta.swir.lons,
            lats_swir=cls.L1_obj.meta.swir.lats,
            prj_vnir=32632,
            prj_swir=32632,
            res_vnir=(30, 30),
            res_swir=(30, 30),
            resamp_alg='nearest',
            # radius_of_influence=45
        )
Exemple #4
0
    def setUp(self):
        self.config = EnPTConfig(**config_for_testing)

        # don't drop bands - otherwise we can't run write-read-tests as the writer does not include the full bandlist
        self.config.drop_bad_bands = False

        self.pathList_testimages = [
            self.config.path_l1b_enmap_image,
            self.config.path_l1b_enmap_image_gapfill
        ]
        self.tmpdir = tempfile.mkdtemp(dir=self.config.working_dir)
        os.makedirs(self.config.output_dir, exist_ok=True)

        # unzip both test images in dummy format
        for l1b_file in self.pathList_testimages:
            with zipfile.ZipFile(l1b_file, "r") as zf:
                zf.extractall(self.tmpdir)

        self.testproducts = [
            os.path.join(
                self.tmpdir,
                os.path.basename(self.pathList_testimages[i]).split(".zip")[0])
            for i in range(len(self.pathList_testimages))
        ]

        self.RD = L1B_Reader(config=self.config)
Exemple #5
0
 def setUp(self):
     self.config = EnPTConfig(**config_for_testing_dlr)
     self.pathList_testimages = [
         self.config.path_l1b_enmap_image,
         self.config.path_l1b_enmap_image_gapfill
     ]
     self.tmpdir = tempfile.mkdtemp(dir=self.config.working_dir)
Exemple #6
0
 def setUp(self):
     """Set up the needed test data"""
     self.cfg = EnPTConfig(**config_for_testing)
     self.pathList_testimages = [
         self.cfg.path_l1b_enmap_image,
         self.cfg.path_l1b_enmap_image_gapfill
     ]
     self.RT = Radiometric_Transformer(config=self.cfg)
Exemple #7
0
    def setUpClass(cls) -> None:
        cls.config = EnPTConfig(**config_for_testing_dlr)

        cls.tmpdir = tempfile.mkdtemp(dir=cls.config.working_dir)

        # get an EnMAPL1Product_SensorGeo instance
        with ZipFile(cls.config.path_l1b_enmap_image, "r") as zf:
            zf.extractall(cls.tmpdir)
            cls.L1_obj = L1B_Reader(config=cls.config).read_inputdata(
                root_dir_main=cls.tmpdir,
                compute_snr=False)
    def setUp(self):
        self.config = EnPTConfig(**config_for_testing_dlr)

        # create a temporary directory
        # NOTE: This must exist during the whole runtime of Test_Spatial_Optimizer, otherwise
        #       Spatial_Optimizer.optimize_geolayer will fail to read some files.
        self.tmpdir = tempfile.mkdtemp(dir=self.config.working_dir)

        # get EnMAP L1 object in sensor geometry
        with ZipFile(self.config.path_l1b_enmap_image, "r") as zf:
            zf.extractall(self.tmpdir)
            self.L1_obj = L1B_Reader(config=self.config).read_inputdata(
                root_dir_main=self.tmpdir, compute_snr=False)
Exemple #9
0
    def setUp(self):
        self.config = EnPTConfig(**config_for_testing_dlr)

        # create a temporary directory
        # NOTE: This must exist during the whole runtime of Test_Orthorectifier, otherwise
        #       Orthorectifier.run_transformation will fail to read some files.
        self.tmpdir = tempfile.mkdtemp(dir=self.config.working_dir)

        # get lons / lats
        with ZipFile(self.config.path_l1b_enmap_image, "r") as zf:
            zf.extractall(self.tmpdir)
            self.L1_obj = L1B_Reader(config=self.config).read_inputdata(
                root_dir_main=self.tmpdir,
                compute_snr=False)
Exemple #10
0
    def setUp(self):
        config = EnPTConfig(**config_for_testing)

        # get lons / lats
        with TemporaryDirectory() as td, ZipFile(config.path_l1b_enmap_image,
                                                 "r") as zf:
            zf.extractall(td)
            L1_obj = L1B_Reader(config=config).read_inputdata(
                root_dir_main=os.path.join(
                    td,
                    os.path.splitext(
                        os.path.basename(config.path_l1b_enmap_image))[0]),
                compute_snr=False)

        R, C = L1_obj.vnir.data.shape[:2]
        self.lons_vnir = L1_obj.meta.vnir.interpolate_corners(
            *L1_obj.meta.vnir.lon_UL_UR_LL_LR, nx=C, ny=R)
        self.lats_vnir = L1_obj.meta.vnir.interpolate_corners(
            *L1_obj.meta.vnir.lat_UL_UR_LL_LR, nx=C, ny=R)

        self.gA2transform_sensorgeo = L1_obj.vnir.data[:, :,
                                                       50]  # a single VNIR band in sensor geometry
        self.gA2transform_mapgeo = GeoArray(
            config.path_dem)  # a DEM in map geometry given by the user
Exemple #11
0
def get_config(cli_args: argparse.Namespace):
    return EnPTConfig(**parsedArgs_to_user_opts(cli_args))
Exemple #12
0
 def test_invalid_filepath(self):
     with self.assertRaises(FileNotFoundError):
         EnPTConfig(path_l1b_enmap_image='/path/to/not/existing/image.tif')
Exemple #13
0
 def test_jsonconfig_file(self):
     cfg = os.path.join(path_options_default)
     cfg = EnPTConfig(json_config=cfg)
     self.assertIsInstance(cfg, EnPTConfig)
Exemple #14
0
 def test_jsonconfig_param_acceptance(self):
     cfg = EnPTConfig(json_config='{"general_opts": {"CPUs": 10}}')
     self.assertIsInstance(cfg, EnPTConfig)
     self.assertTrue(cfg.CPUs == 10)
Exemple #15
0
 def test_jsonconfig_str_schema_violation(self):
     cfg = '{"general_opts": {"CPUs": "badvalue"}}'
     with self.assertRaises(ValueError):
         EnPTConfig(json_config=cfg)
Exemple #16
0
 def test_jsonconfig_str_undecodable_val(self):
     cfg = '{"a": None /comment*/, "b":2}'
     with self.assertWarns(UserWarning), self.assertRaises(JSONDecodeError):
         EnPTConfig(json_config=cfg)
Exemple #17
0
 def test_jsonconfig_str_nojson(self):
     cfg = 'dict(a=1 /*comment*/, b=2)'
     with self.assertRaises(ValueError):
         EnPTConfig(json_config=cfg)
Exemple #18
0
 def test_jsonconfig_str_allfine(self):
     cfg = '{"a": 1 /*comment*/, "b":2}'
     cfg = EnPTConfig(json_config=cfg)
     self.assertIsInstance(cfg, EnPTConfig)
Exemple #19
0
 def test_plain_args(self):
     cfg = EnPTConfig(CPUs=10)
     self.assertIsInstance(cfg, EnPTConfig)
     self.assertTrue(cfg.CPUs == 10)