Commit 38e625ae authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Improved logging during L1B processor.

parent a059fdf3
......@@ -32,6 +32,7 @@ from .L1A_P import L1A_object
from ..misc import database_tools as DB_T
from ..misc import helper_functions as HLP_F
from ..misc import path_generator as PG
from ..misc.logging import GMS_logger
from ..misc.spatial_index_mediator import SpatialIndexMediator
from ..misc.definition_dicts import get_GMS_sensorcode, get_outFillZeroSaturated
......@@ -42,7 +43,7 @@ class Scene_finder(object):
"""Scene_finder class to query the postgreSQL database to find a suitable reference scene for co-registration."""
def __init__(self, src_boundsLonLat, src_AcqDate, src_prj, src_footprint_poly, sceneID_excluded=None,
min_overlap=20, min_cloudcov=0, max_cloudcov=20, plusminus_days=30, plusminus_years=10):
min_overlap=20, min_cloudcov=0, max_cloudcov=20, plusminus_days=30, plusminus_years=10, logger=None):
"""Initialize Scene_finder.
:param src_boundsLonLat:
......@@ -66,6 +67,7 @@ class Scene_finder(object):
self.max_cloudcov = max_cloudcov
self.plusminus_days = plusminus_days
self.plusminus_years = plusminus_years
self.logger = logger or GMS_logger('ReferenceSceneFinder')
# get temporal constraints
def add_years(dt, years): return dt.replace(dt.year + years) \
......@@ -146,31 +148,43 @@ class Scene_finder(object):
"""Filter reference scene with the same scene ID like the target scene."""
GDF = self.GDF_ref_scenes
if not GDF.empty:
self.logger.info('Excluding scene with the same ID like the target scene.')
self.GDF_ref_scenes = GDF.loc[GDF['sceneid'] != self.sceneID_excluded]
self.logger.info('%s scenes => %s scenes' % (len(GDF), len(self.GDF_ref_scenes)))
def _filter_by_overlap(self):
"""Filter all scenes with less spatial overlap than self.min_overlap."""
GDF = self.GDF_ref_scenes
if not GDF.empty:
self.logger.info('Excluding all scenes with less than %s percent spatial overlap.' % self.min_overlap)
self.GDF_ref_scenes = GDF.loc[GDF['overlap percentage'] >= self.min_overlap]
self.logger.info('%s scenes => %s scenes' % (len(GDF), len(self.GDF_ref_scenes)))
def _filter_by_proc_status(self):
"""Filter all scenes that have not been processed before according to proc. status (at least L1A is needed)."""
GDF = self.GDF_ref_scenes
if not GDF.empty:
self.logger.info('Exclude all scenes that have not been processed before according to processing status '
'(at least L1A is needed).')
self.GDF_ref_scenes = GDF[GDF['proc_level'].notnull()]
self.logger.info('%s scenes => %s scenes' % (len(GDF), len(self.GDF_ref_scenes)))
def _filter_by_dataset_existance(self):
"""Filter all scenes where no processed data can be found on fileserver."""
GDF = self.GDF_ref_scenes
if not GDF.empty:
self.logger.info('Excluding all scenes where no processed data have been found.')
self.GDF_ref_scenes = GDF[GDF['refDs_exists']]
self.logger.info('%s scenes => %s scenes' % (len(GDF), len(self.GDF_ref_scenes)))
def _filter_by_entity_ID_availability(self):
"""Filter all scenes where no proper entity ID can be found in the database (database errors)."""
GDF = self.GDF_ref_scenes
if not GDF.empty:
self.logger.info('Exclude all scenes where no proper entity ID can be found in the database '
'(database errors).')
self.GDF_ref_scenes = GDF[GDF['entityid'].notnull()]
self.logger.info('%s scenes => %s scenes' % (len(GDF), len(self.GDF_ref_scenes)))
def _filter_by_projection(self):
"""Filter all scenes that have a different projection than the target image."""
......@@ -180,7 +194,9 @@ class Scene_finder(object):
GDF['prj_equal'] = \
list(GDF['path_ref'].map(lambda path_ref: prj_equal(self.src_prj, GeoArray(path_ref).prj)))
self.logger.info('Exclude all scenes that have a different projection than the target image.')
self.GDF_ref_scenes = GDF[GDF['prj_equal']]
self.logger.info('%s scenes => %s scenes' % (len(GDF), len(self.GDF_ref_scenes)))
def choose_ref_scene(self):
"""Choose reference scene with minimum cloud cover and maximum overlap."""
......@@ -259,7 +275,8 @@ class L1B_object(L1A_object):
min_cloudcov=CFG.spatial_ref_min_cloudcov,
max_cloudcov=CFG.spatial_ref_max_cloudcov,
plusminus_days=CFG.spatial_ref_plusminus_days,
plusminus_years=CFG.spatial_ref_plusminus_years)
plusminus_years=CFG.spatial_ref_plusminus_years,
logger=self.logger)
# run spatial query
self.logger.info('Querying database in order to find a suitable reference scene for co-registration.')
......@@ -505,8 +522,10 @@ class L1B_object(L1A_object):
shift_band4match = 1
ref_band4match = 1
self.logger.info('Shift band for matching: %s (%snm)' % (shift_band4match, shift_cwl[shift_band4match - 1]))
self.logger.info('Reference band for matching: %s (%snm)' % (ref_band4match, ref_cwl[ref_band4match - 1]))
self.logger.info(
'Target band for matching: %s (%snm)' % (shift_band4match, shift_cwl[shift_band4match - 1]))
self.logger.info(
'Reference band for matching: %s (%snm)' % (ref_band4match, ref_cwl[ref_band4match - 1]))
return ref_band4match, shift_band4match
......@@ -554,6 +573,7 @@ class L1B_object(L1A_object):
self.logger.info("Calculated map shifts (X,Y): %s / %s"
% (COREG_obj.x_shift_map,
COREG_obj.y_shift_map)) # FIXME direkt in calculate_spatial_shifts loggen
self.logger.info("Reliability of calculated shift: %.1f percent" % COREG_obj.shift_reliability)
else:
# TODO add database entry with error hint
......
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