Commit e1ade6ef authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Revised L1B_P.L1B_object.get_opt_bands4matching(). Global co-registration now...

Revised L1B_P.L1B_object.get_opt_bands4matching(). Global co-registration now works again. Added config parameter to disable auto-download of ECMWF data.

Former-commit-id: 44382727
parent cde8c9d4
......@@ -7,7 +7,6 @@ Detection of global/local geometric displacements.
import collections
import json
import os
import socket
import time
......@@ -28,6 +27,7 @@ from py_tools_ds.geo.projection import prj_equal, EPSG2WKT, WKT2EPSG
from py_tools_ds.geo.vector.topology import get_overlap_polygon
from ..config import GMS_config as CFG
from ..model.gms_object import GMS_object
from .L1A_P import L1A_object
from ..misc import database_tools as DB_T
from ..misc import helper_functions as HLP_F
......@@ -175,6 +175,7 @@ class Scene_finder(object):
def choose_ref_scene(self):
"""Choose reference scene with minimum cloud cover and maximum overlap."""
if self.possib_ref_scenes:
# First, collect some relavant reference scene metadata
......@@ -198,6 +199,7 @@ class Scene_finder(object):
return None
class ref_Scene:
def __init__(self, GDF_record):
self.scene_ID = int(GDF_record['sceneid'])
......@@ -440,23 +442,23 @@ class L1B_object(L1A_object):
:param target_cwlPos_nm: the desired wavelength used for matching
:param v: verbose mode
# get GMS_object for reference scene
path_gmsFile = PG.path_generator(scene_ID=self.spatRef_scene.scene_ID).get_path_gmsfile()
ref_obj = GMS_object().from_disk((path_gmsFile, ['cube', None]))
# get spectral characteristics
shift_cwl = [float(i) for i in self.meta_odict['wavelength']]
shift_fwhm = [float(i) for i in self.meta_odict['bandwidths']]
with open(PG.path_generator(scene_ID=self.spatRef_scene.scene_ID).get_path_gmsfile()) as inF:
ref_gmsDict = json.load(inF)
ref_cwl = [float(i) for i in ref_gmsDict['meta']['wavelength']]
ref_fwhm = [float(i) for i in ref_gmsDict['meta']['bandwidths']]
ref_cwl, shift_cwl = [[float(i) for i in GMS_obj.meta_odict['wavelength']] for GMS_obj in [ref_obj, self]]
ref_fwhm, shift_fwhm = [[float(i) for i in GMS_obj.meta_odict['bandwidths']] for GMS_obj in [ref_obj, self]]
# exclude cirrus/oxygen band of Landsat-8/Sentinel-2
shift_bbl, ref_bbl = [False] * len(shift_cwl), [False] * len(ref_cwl) # bad band lists
for dic, s_r in zip([self.__dict__, ref_gmsDict], ['shift', 'ref']):
dic['GMS_identifier']['logger'] = None # set a dummy value in order to avoid Exception
sensorcode = get_GMS_sensorcode(dic['GMS_identifier'])
if sensorcode in ['LDCM', 'S2A', 'S2B'] and '9' in dic['LayerBandsAssignment']:
locals()['%s_bbl' % s_r][dic['LayerBandsAssignment'].index('9')] = True
if sensorcode in ['S2A', 'S2B'] and '10' in dic['LayerBandsAssignment']:
locals()['%s_bbl' % s_r][dic['LayerBandsAssignment'].index('10')] = True
for GMS_obj, s_r, bbl in zip([self, ref_obj], ['shift', 'ref'], [shift_bbl, ref_bbl]):
GMS_obj.GMS_identifier['logger'] = None # set a dummy value in order to avoid Exception
sensorcode = get_GMS_sensorcode(GMS_obj.GMS_identifier)
if sensorcode in ['LDCM', 'S2A', 'S2B'] and '9' in GMS_obj.LayerBandsAssignment:
bbl[GMS_obj.LayerBandsAssignment.index('9')] = True
if sensorcode in ['S2A', 'S2B'] and '10' in GMS_obj.LayerBandsAssignment:
bbl[GMS_obj.LayerBandsAssignment.index('10')] = True
# cwl_overlap = (max(min(shift_cwl),min(ref_cwl)), min(max(shift_cwl),max(ref_cwl))) # -> (min wvl, max wvl)
# find matching band of reference image for each band of image to be shifted
......@@ -791,6 +791,7 @@ class AtmCorr(object):
script = False
# check if ECMWF data are available - if not, start the download
if CFG.job.auto_download_ecmwf:
# validate SNR
......@@ -152,6 +152,7 @@ class Job(object):
self.SZA_SAA_calculation_accurracy = 'coarse' # hardcoded
self.export_VZA_SZA_SAA_RAA_stats = True # hardcoded
self.export_L1C_obj_dumps = False # hardcoded
self.auto_download_ecmwf = False
# fixed attributes
# possible values: 'pending', 'running', 'canceled', 'failed', 'finished_with_warnings',
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