Commit 6b2d1f1c authored by bsilva's avatar bsilva

include ac water in atmospheric_correction and config

parent 411a8b91
Pipeline #9618 failed with stage
in 6 minutes and 33 seconds
......@@ -61,6 +61,23 @@ __author__ = 'Daniel Scheffler'
path_enptlib = os.path.dirname(pkgutil.get_loader("enpt").path)
path_options_default = os.path.join(path_enptlib, 'options', 'options_default.json')
config_for_testing_water = dict(
path_l1b_enmap_image=os.path.abspath(
os.path.join(path_enptlib, '..', 'tests', 'data', 'EnMAP_Level_1B', 'ENMAP01-____L1B-DT000400126_20170218T110115Z_002_V000204_20200206T182719Z__rows700-730.zip')),
# path_l1b_enmap_image_gapfill=os.path.abspath(
# os.path.join(path_enptlib, '..', 'tests', 'data', 'EnMAP_Level_1B', 'ENMAP01-____L1B-DT000400126_20170218T110115Z_002_V000204_20200206T182719Z__rows700-730.zip')),
path_dem=os.path.abspath(
os.path.join(path_enptlib, '..', 'tests', 'data', 'ENMAP01-____L1B-DT000400126_20170218T110115Z_002_V000204_20200206T182719Z__DEM_ASTER.bsq')),
log_level='DEBUG',
output_dir=os.path.join(path_enptlib, '..', 'tests', 'data', 'test_outputs'),
n_lines_to_append=0,
disable_progress_bars=True,
is_dummy_dataformat=False,
enable_ac=True,
mode_ac='water',
enable_ice_retrieval=False,
CPUs=16
)
config_for_testing = dict(
path_l1b_enmap_image=os.path.abspath(
......
......@@ -120,13 +120,41 @@ class AtmosphericCorrector(object):
# FIXME use cwv_model, cwc_model, toa_model also for EnPT?
elif self.cfg.mode_ac == 'water':
# call water AC of AWI here -> apply it to water surfaces ONLY
if 2 not in enmap_ImageL1.vnir.mask_landwater[:]:
raise RuntimeError("The atmospheric correction mode is set to 'water' but the input image does not "
"contain any water surfaces according to the land/water image mask.")
raise NotImplementedError("The atmospheric correction mode 'water' is not yet implemented. "
"You may use 'land' instead.")
# raise NotImplementedError("The atmospheric correction mode 'water' is not yet implemented. "
# "You may use 'land' instead.")
from acwater.level1_enmap import run_polymer_enmap
# load data as polymer object
l2 = run_polymer_enmap(enmap_l1b=enmap_ImageL1)
enmap_l2a_vnir = l2.Rw
enmap_l2a_swir = np.full(enmap_ImageL1.swir.data.shape, np.NaN, dtype=np.float)
# 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 for water.')
for in_detector, out_detector in zip([enmap_ImageL1.vnir, enmap_ImageL1.swir],
[enmap_l2a_vnir, enmap_l2a_swir]):
# in_detector.data = (out_detector * self.cfg.scale_factor_boa_ref).astype(np.int16)
in_detector.detector_meta.unit = '0-%d' % self.cfg.scale_factor_boa_ref
in_detector.detector_meta.unitcode = 'BOARef'
# TODO, join bands prior polymer run?
# detectors are joined at : EnPT/enpt/processors/orthorectification/orthorectification.py:109
else: # self.cfg.mode_ac == 'combined'
# call SICOR for land and AWI water AC for land surfaces here
......
......@@ -39,14 +39,14 @@ from unittest import TestCase, main
import shutil
from enpt.execution.controller import EnPT_Controller
from enpt.options.config import config_for_testing, config_for_testing_dlr
from enpt.options.config import config_for_testing, config_for_testing_dlr, config_for_testing_water
__author__ = 'Daniel Scheffler'
class Test_EnPT_Controller(TestCase):
def setUp(self):
self.CTR = EnPT_Controller(**config_for_testing)
self.CTR = EnPT_Controller(**config_for_testing_water)
def tearDown(self):
# NOTE: ignore_errors deletes the folder, regardless of whether it contains read-only files
......@@ -56,16 +56,16 @@ class Test_EnPT_Controller(TestCase):
self.CTR.run_all_processors()
class Test_EnPT_Controller_DLR_testdata(TestCase):
def setUp(self):
self.CTR = EnPT_Controller(**config_for_testing_dlr)
def tearDown(self):
# NOTE: ignore_errors deletes the folder, regardless of whether it contains read-only files
shutil.rmtree(self.CTR.cfg.output_dir, ignore_errors=True)
def test_run_all_processors(self):
self.CTR.run_all_processors()
# class Test_EnPT_Controller_DLR_testdata(TestCase):
# def setUp(self):
# self.CTR = EnPT_Controller(**config_for_testing_dlr)
#
# def tearDown(self):
# # NOTE: ignore_errors deletes the folder, regardless of whether it contains read-only files
# shutil.rmtree(self.CTR.cfg.output_dir, ignore_errors=True)
#
# def test_run_all_processors(self):
# self.CTR.run_all_processors()
if __name__ == '__main__':
......
Markdown is supported
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