Commit 3cb42d55 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed issue #68 (Cloud mask is not applied equally to all bands when filling...

Fixed issue #68 (Cloud mask is not applied equally to all bands when filling clouds with no data values).
parent b9128fb2
......@@ -684,8 +684,8 @@ class GMS_object(Dataset):
for log in paths_inLogs:
df = read_csv(log, sep='\n', delimiter=': ', header=None,
engine='python') # engine suppresses a pandas warning
allLogs_df = allLogs_df.append(
df) # FIXME this will log e.g. atm. corr 3 times for S2A -> use captured streams instead?
# FIXME this will log e.g. atm. corr 3 times for S2A -> use captured streams instead?
allLogs_df = allLogs_df.append(df)
allLogs_df = allLogs_df.sort_values(0)
......@@ -702,10 +702,6 @@ class GMS_object(Dataset):
self.logger.info('Merging the subsystems %s to a single GMS object...'
% ', '.join([GMS_obj.subsystem for GMS_obj in list_GMS_objs]))
# find the common extent. NOTE: boundsMap is expected in the order [xmin,xmax,ymin,ymax]
geoExtents = np.array([GMS_obj.arr.box.boundsMap for GMS_obj in list_GMS_objs])
common_extent = (min(geoExtents[:, 0]), max(geoExtents[:, 1]), min(geoExtents[:, 2]), max(geoExtents[:, 3]))
##################
# MERGE METADATA #
##################
......@@ -761,6 +757,10 @@ class GMS_object(Dataset):
# MERGE ARRAY DATA #
####################
# find the common extent. NOTE: boundsMap is expected in the order [xmin,xmax,ymin,ymax]
geoExtents = np.array([GMS_obj.arr.box.boundsMap for GMS_obj in list_GMS_objs])
common_extent = (min(geoExtents[:, 0]), max(geoExtents[:, 1]), min(geoExtents[:, 2]), max(geoExtents[:, 3]))
# overwrite array data with merged arrays, clipped to common_extent and reordered according to FullLayerBandsAss
for attrname in ['arr', 'ac_errors', 'dem', 'mask_nodata', 'mask_clouds', 'mask_clouds_confidence', 'masks']:
......@@ -860,6 +860,30 @@ class GMS_object(Dataset):
# self.mask_nodata and self.mask_clouds will already be set here -> so just recreate it from there
self.masks = None
# avoid unequal nodata edges between indiviual layers (resampling artifacts etc.) #
###################################################################################
# apply cloud mask to image data and all products derived from image data
# (only if image data represents BOA-Ref and cloud areas are not to be filled with TOA-Ref)
if re.search('BOA_Reflectance', self.MetaObj.PhysUnit, re.I) and not CFG.ac_fillnonclear_areas:
# get pixel values of areas that have not been atmospherically corrected (non-clear)
nonclear_labels = [lbl for lbl in ["Clear", "Snow", "Water", "Shadow", "Cirrus", "Cloud"]
if lbl not in CFG.ac_clear_area_labels]
cloud_mask_legend = DEF_D.get_mask_classdefinition('mask_clouds', self.satellite)
nonclear_pixVals = [cloud_mask_legend[lbl] for lbl in nonclear_labels]
# fill non-clear areas with no data values (for all bands)
for pixVal in nonclear_pixVals:
mask_nonclear = self.mask_clouds[:] == pixVal
self.arr[mask_nonclear] = DEF_D.get_outFillZeroSaturated(self.arr.dtype)[0]
if self.ac_errors:
self.ac_errors[mask_nonclear] = DEF_D.get_outFillZeroSaturated(self.ac_errors.dtype)[0]
# update no data mask
self.calc_mask_nodata(overwrite=True)
# recreate self.masks
self.build_combined_masks_array()
......@@ -867,6 +891,7 @@ class GMS_object(Dataset):
self.meta_odict.update({
'samples': self.arr.cols, 'lines': self.arr.rows, 'bands': self.arr.bands,
'map info': geotransform2mapinfo(self.arr.gt, self.arr.prj), 'coordinate system string': self.arr.prj, })
self.calc_corner_positions() # update corner coordinates
# set shape of full array
self.shape_fullArr = self.arr.shape
......
......@@ -171,10 +171,6 @@ def L2A_map(L1C_objs, block_size=None, return_tiles=True):
# merge multiple subsystems belonging to the same scene ID to a single GMS object
L2A_obj = L2A_P.L2A_object().from_sensor_subsystems(L2A_objs) if len(L2A_objs) > 1 else L2A_objs[0]
# update some attibutes
L2A_obj.calc_mask_nodata(overwrite=True) # update no data mask
L2A_obj.calc_corner_positions() # update corner coordinates
# write output
if CFG.exec_L2AP[1]:
L2A_obj.to_ENVI()
......
......@@ -453,7 +453,7 @@ testdata.append('MultipleDatasetsInOneJob')
summary_testResults, summary_errors, summary_failures, summary_skipped, jobstatus = [[] for _ in range(5)]
@unittest.SkipTest
# @unittest.SkipTest
class Test_in_normal_mode(unittest.TestCase):
def setUp(self):
# self.job_id = 26184107
......@@ -512,13 +512,16 @@ class Test_in_normal_mode(unittest.TestCase):
# self.job_id = 26187052 # GMS41: 1 Landsat, DB query returns no DEM
# self.job_id = 26187053 # GMS41: AC: The input 'list_GMS_objs' contains duplicates: ['', '']
# self.job_id = 26187750 # GEOMS: [AC]: RuntimeWarning: All-NaN slice encountered
self.job_id = 26187760 # GEOMS: [L2C]: ValueError: 'axis' entry is out of bounds
# self.job_id = 26187760 # GEOMS: [L2C]: ValueError: 'axis' entry is out of bounds
self.job_id = 26187804 # GEOMS: Spatial homogenization leaves resampling artifacs at the image edges.
self.PC = process_controller(self.job_id, **dict(is_test=False, parallelization_level='scenes', db_host=db_host,
delete_old_output=True, disable_exception_handler=True))
self.PC.config.spathomo_estimate_accuracy = True
self.PC.config.ac_estimate_accuracy = True # FIXME
self.PC.config.spechomo_estimate_accuracy = True # FIXME
self.PC.config.exec_L1CP = [1, 1, 0]
self.PC.config.exec_2ACP = [1, 1, 0]
def test(self):
self.PC.run_all_processors()
......
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