Commit 1460d9b2 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Bugfix within AC

algorithms.L1C_P.AtmCorr:
- options: bugfix for not excluding specific bands from AC output
- _join_results_to_inObjs():
    - bugfix for stacking data_ac bands in the wrong order
    - NaN values withon data_ac are now set to outFill value

- updated __version__


Former-commit-id: 577c72b9
parent 1366a70f
...@@ -15,7 +15,7 @@ from . import config ...@@ -15,7 +15,7 @@ from . import config
from .processing.process_controller import process_controller from .processing.process_controller import process_controller
__version__ = '20170209.01' __version__ = '20170215.01'
__author__ = 'Daniel Scheffler' __author__ = 'Daniel Scheffler'
__all__ = ['algorithms', __all__ = ['algorithms',
'io', 'io',
......
...@@ -489,7 +489,7 @@ class AtmCorr(object): ...@@ -489,7 +489,7 @@ class AtmCorr(object):
return self._options return self._options
else: else:
self._options = self.inObjs[0].ac_options self._options = self.inObjs[0].ac_options
self._options["AC"]['bands'] = list(self.data.keys()) self._options["AC"]['bands'] = [b for b in self.data.keys() if b in self._options["AC"]['bands']]
self._options["report"]["reporting"] = self.reporting self._options["report"]["reporting"] = self.reporting
return self._options return self._options
...@@ -786,7 +786,7 @@ class AtmCorr(object): ...@@ -786,7 +786,7 @@ class AtmCorr(object):
for inObj in self.inObjs: for inObj in self.inObjs:
#assert isinstance(inObj.arr, (GeoArray, np.ndarray)), print(type(inObj.arr)) #assert isinstance(inObj.arr, (GeoArray, np.ndarray)), print(type(inObj.arr))
nodata = self.results.nodata[inObj.arr.xgsd] # 2D mask with True outside of image coverage nodata = self.results.nodata[inObj.arr.xgsd] # 2D mask with True outside of image coverage
ac_bandNs = [bandN for bandN in self.ac_input['options']['AC']['bands'] if bandN in inObj.arr.bandnames] ac_bandNs = [bandN for bandN in inObj.arr.bandnames if bandN in self.results.data_ac.keys()]
out_LBA = [bN.split('B0')[1] if bN.startswith('B0') else bN.split('B')[1] for bN in ac_bandNs] out_LBA = [bN.split('B0')[1] if bN.startswith('B0') else bN.split('B')[1] for bN in ac_bandNs]
# update metadata # update metadata
...@@ -797,15 +797,18 @@ class AtmCorr(object): ...@@ -797,15 +797,18 @@ class AtmCorr(object):
inObj.MetaObj.filter_layerdependent_metadata() inObj.MetaObj.filter_layerdependent_metadata()
inObj.meta_odict = inObj.MetaObj.to_odict() inObj.meta_odict = inObj.MetaObj.to_odict()
# join SURFACE REFLECTANCE as 3D int16 array, scaled to scale factor from config # join SURFACE REFLECTANCE as 3D int16 array, scaled to scale factor from config
surf_refl = np.dstack((self.results.data_ac[bandN] for bandN in ac_bandNs)) surf_refl = np.dstack((self.results.data_ac[bandN] for bandN in ac_bandNs))
surf_refl *= CFG.usecase.scale_factor_BOARef # scale using scale factor (output is float16) surf_refl *= CFG.usecase.scale_factor_BOARef # scale using scale factor (output is float16)
surf_refl[nodata] = get_outFillZeroSaturated(inObj.arr.dtype)[0] # FIXME AC output nodata values = 0 -> new nodata areas but mask not updated surf_refl[nodata] = get_outFillZeroSaturated(inObj.arr.dtype)[0] # FIXME AC output nodata values = 0 -> new nodata areas but mask not updated
if self.results.bad_data_value is np.nan:
surf_refl[np.isnan(surf_refl)] = get_outFillZeroSaturated(inObj.arr.dtype)[0]
else:
surf_refl[surf_refl==self.results.bad_data_value] = get_outFillZeroSaturated(inObj.arr.dtype)[0]
# overwrite LayerBandsAssignment and use inObj.arr setter to generate a GeoArray # overwrite LayerBandsAssignment and use inObj.arr setter to generate a GeoArray
inObj.LayerBandsAssignment = out_LBA inObj.LayerBandsAssignment = out_LBA
inObj.arr = surf_refl.astype(inObj.arr.dtype) # -> int16 inObj.arr = surf_refl.astype(inObj.arr.dtype) # -> int16 (also converts NaNs to 0 if needed
# join ERRORS ARRAY as 3D int8 or int16 BOA reflectance array, scaled to scale factor from config # join ERRORS ARRAY as 3D int8 or int16 BOA reflectance array, scaled to scale factor from config
if self.results.data_errors is not None: if self.results.data_errors is not None:
......
...@@ -1762,7 +1762,7 @@ def get_LayerBandsAssignment(GMS_identifier, nBands=None, ignore_usecase=False, ...@@ -1762,7 +1762,7 @@ def get_LayerBandsAssignment(GMS_identifier, nBands=None, ignore_usecase=False,
if CFG.usecase.conversion_type_optical=='BOA_Ref': if CFG.usecase.conversion_type_optical=='BOA_Ref':
path_ac_options = get_path_ac_options(GMS_identifier) path_ac_options = get_path_ac_options(GMS_identifier)
if os.path.exists(path_ac_options): if os.path.exists(path_ac_options):
ac_bandNs = get_ac_options(path_ac_options)['AC']['bands'] ac_bandNs = get_ac_options(path_ac_options)['AC']['bands'] # FIXME this does not work for L7
ac_out_LBA = [bN.split('B0')[1] if bN.startswith('B0') else bN.split('B')[1] for bN in ac_bandNs] ac_out_LBA = [bN.split('B0')[1] if bN.startswith('B0') else bN.split('B')[1] for bN in ac_bandNs]
LayerBandsAssignment = [i for i in LayerBandsAssignment if i in ac_out_LBA] LayerBandsAssignment = [i for i in LayerBandsAssignment if i in ac_out_LBA]
else: else:
......
...@@ -591,7 +591,7 @@ class GMS_object(object): ...@@ -591,7 +591,7 @@ class GMS_object(object):
if path_ac_options and os.path.exists(path_ac_options): if path_ac_options and os.path.exists(path_ac_options):
opt_dict = get_ac_options(path_ac_options) opt_dict = get_ac_options(path_ac_options)
# update some file paths according to # update some file paths depending on the current environment
opt_dict['DEM']['fn'] = CFG.job.path_dem_proc_srtm_90m opt_dict['DEM']['fn'] = CFG.job.path_dem_proc_srtm_90m
opt_dict['ECMWF']['path_db'] = CFG.job.path_ECMWF_db opt_dict['ECMWF']['path_db'] = CFG.job.path_ECMWF_db
for key in opt_dict['RTFO']: for key in opt_dict['RTFO']:
......
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