Commit 495e3e21 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fix for completely failed scenes in case co-registration fails.

Fix for not continuing processing from L2B.
parent 25a6255f
......@@ -16,6 +16,7 @@ import numpy as np
from geopandas import GeoDataFrame
from shapely.geometry import box
import pytz
import traceback
from typing import Union, TYPE_CHECKING # noqa F401 # flake8 issue
from arosics import COREG, DESHIFTER
......@@ -546,6 +547,9 @@ class L1B_object(L1A_object):
self.logger.warning('Coregistration skipped according to user configuration.')
elif self.coreg_needed and self.spatRef_available:
self.coreg_info.update({'reference scene ID': self.spatRef_scene.scene_ID})
self.coreg_info.update({'reference entity ID': self.spatRef_scene.entity_ID})
geoArr_ref = GeoArray(self.spatRef_scene.filePath)
geoArr_shift = GeoArray(self.arr)
r_b4match, s_b4match = self.get_opt_bands4matching(target_cwlPos_nm=CFG.coreg_band_wavelength_for_matching)
......@@ -566,26 +570,36 @@ class L1B_object(L1A_object):
q=True
)
COREG_obj = COREG(geoArr_ref, geoArr_shift, **coreg_kwargs)
COREG_obj.calculate_spatial_shifts()
# initialize COREG object
try:
COREG_obj = COREG(geoArr_ref, geoArr_shift, **coreg_kwargs)
except Exception as e:
COREG_obj = None
self.logger.error('\nAn error occurred during coregistration. BE AWARE THAT THE SCENE %s '
'(ENTITY ID %s) HAS NOT BEEN COREGISTERED! Error message was: \n%s\n'
% (self.scene_ID, self.entity_ID, repr(e)))
self.logger.error(traceback.format_exc())
# TODO include that in the job summary
# calculate_spatial_shifts
if COREG_obj:
COREG_obj.calculate_spatial_shifts()
self.coreg_info.update(
COREG_obj.coreg_info) # no clipping to trueCornerLonLat until here -> only shift correction
self.coreg_info.update({'shift_reliability': COREG_obj.shift_reliability})
if COREG_obj.success:
self.coreg_info['success'] = True
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)
self.coreg_info.update(
COREG_obj.coreg_info) # no clipping to trueCornerLonLat until here -> only shift correction
self.coreg_info.update({'reference scene ID': self.spatRef_scene.scene_ID})
self.coreg_info.update({'reference entity ID': self.spatRef_scene.entity_ID})
self.coreg_info.update({'shift_reliability': COREG_obj.shift_reliability})
if COREG_obj.success:
self.coreg_info['success'] = True
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
[self.logger.error('ERROR during coregistration of scene %s (entity ID %s):\n%s'
% (self.scene_ID, self.entity_ID, err)) for err in COREG_obj.tracked_errors]
else:
# TODO add database entry with error hint
[self.logger.error('ERROR during coregistration of scene %s (entity ID %s):\n%s'
% (self.scene_ID, self.entity_ID, err)) for err in COREG_obj.tracked_errors]
else:
if self.coreg_needed:
......
......@@ -79,7 +79,7 @@ class ExceptionHandler(object):
self.GMS_objs = GMS_objs
if not GMS_objs:
raise ValueError('Unexpected argument for %s. Received %s.' % (self.GMS_mapper_name, GMS_objs))
return GMS_objs
# noinspection PyBroadException
try:
......
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