Commit 0e3c9092 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'bugfix/fix_empty_bands_after_ortho' into 'master'

Bugfix/fix empty bands after ortho

See merge request !34
parents 18b2f9ad c809d163
Pipeline #5645 passed with stages
in 78 minutes and 46 seconds
......@@ -116,7 +116,8 @@ class L1B_Reader(object):
def _validate_enmap_l1b_rootdir(rootdir_l1b):
"""Check for valid EnMAP L1B root directory."""
if not os.path.isdir(rootdir_l1b):
raise NotADirectoryError(rootdir_l1b)
raise NotADirectoryError(rootdir_l1b, 'EnMAP images have to be provided either as zip-archives or as '
'a directory containing all extracted files.')
files = os.listdir(rootdir_l1b)
......
......@@ -93,7 +93,7 @@ config_for_testing_dlr = dict(
n_lines_to_append=50,
disable_progress_bars=True,
is_dummy_dataformat=False,
enable_ac=False,
enable_ac=True,
enable_ice_retrieval=False,
CPUs=32,
ortho_resampAlg='gauss',
......
......@@ -93,6 +93,12 @@ class AtmosphericCorrector(object):
enmap_l2a_vnir, enmap_l2a_swir, cwv_model, cwc_model, ice_model, toa_model, se, scem, srem = \
sicor_ac_enmap(enmap_l1b=enmap_ImageL1, options=options, logger=enmap_ImageL1.logger)
# validate results
for detectordata, detectorname in zip([enmap_l2a_vnir, enmap_l2a_swir], ['VNIR', 'SWIR']):
mean0, std0 = np.nanmean(detectordata[:, :, 0]), np.nanstd(detectordata[:, :, 0])
if np.isnan(mean0) or mean0 == 0 or std0 == 0:
enmap_ImageL1.logger.warning('The atmospheric correction returned empty %s bands!' % detectorname)
# join results
enmap_ImageL1.logger.info('Joining results of atmospheric correction.')
......
name: enmapbox
channels: &id1
- http://conda.anaconda.org/conda-forge
dependencies:
- python=3.*.*
- pip # avoids that conda uses the wrong pip
- qgis
- numpy
- scikit-learn
- matplotlib
- pip:
- scipy
- astropy
......@@ -37,9 +37,10 @@ from unittest import TestCase
from zipfile import ZipFile
import tempfile
import shutil
import numpy as np
from enpt.processors.orthorectification import Orthorectifier
from enpt.options.config import config_for_testing, EnPTConfig
from enpt.options.config import config_for_testing, config_for_testing_dlr, EnPTConfig
from enpt.io.reader import L1B_Reader
from enpt.model.images import EnMAPL2Product_MapGeo
......@@ -67,9 +68,49 @@ class Test_Orthorectifier(TestCase):
shutil.rmtree(self.tmpdir)
def test_run_transformation(self):
# FIXME td does not exist here anymore
OR = Orthorectifier(config=self.config)
L2_obj = OR.run_transformation(self.L1_obj)
self.assertIsInstance(L2_obj, EnMAPL2Product_MapGeo)
self.assertTrue(L2_obj.data.is_map_geo)
self.assertGreater(L2_obj.data.shape[0], self.L1_obj.vnir.data.shape[0])
self.assertNotEqual(L2_obj.data.shape[1], self.L1_obj.vnir.data.shape[1])
self.assertEqual(L2_obj.data.ndim, self.L1_obj.vnir.data.ndim)
self.assertTrue(np.isclose(np.mean(self.L1_obj.vnir.data[:, :, 0]),
np.mean(L2_obj.data[:, :, 0][L2_obj.data[:, :, 0] != L2_obj.data.nodata]),
rtol=0.01
))
class Test_Orthorectifier_DLR(TestCase):
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)
def tearDown(self):
shutil.rmtree(self.tmpdir)
def test_run_transformation(self):
OR = Orthorectifier(config=self.config)
L2_obj = OR.run_transformation(self.L1_obj)
self.assertIsInstance(L2_obj, EnMAPL2Product_MapGeo)
self.assertTrue(L2_obj.data.is_map_geo)
self.assertGreater(L2_obj.data.shape[0], self.L1_obj.vnir.data.shape[0])
self.assertNotEqual(L2_obj.data.shape[1], self.L1_obj.vnir.data.shape[1])
self.assertEqual(L2_obj.data.ndim, self.L1_obj.vnir.data.ndim)
self.assertTrue(np.isclose(np.mean(self.L1_obj.vnir.data[:, :, 0]),
np.mean(L2_obj.data[:, :, 0][L2_obj.data[:, :, 0] != L2_obj.data.nodata]),
rtol=0.01
))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment