Commit 45420946 authored by Daniel Scheffler's avatar Daniel Scheffler Committed by Mathias Peters
Browse files

Bugfixes

algorithms.gms_object.GMS_object:
- set_pathes(): bugfix
- __getstate__(): now deletes self._masks after L2C
- revised log_for_fullArr_or_firstTile()
algorithms.L1C_P.AtmCorr:
- bugfix for not properly closing self.logger before logging into self.InObjs (fixes permission errors)
misc.path_generator:
- get_path_tempdir(): added hex-code for uniqueness
- updated __version__
Former-commit-id: d74b8bf8
Former-commit-id: ffb3ccac
parent 40c7cae3
......@@ -15,7 +15,7 @@ from . import config
from .processing.process_controller import process_controller
__version__ = '20170124.03'
__version__ = '20170124.04'
__author__ = 'Daniel Scheffler'
__all__ = ['algorithms',
'io',
......
......@@ -283,6 +283,8 @@ class AtmCorr(object):
logger_atmCorr.addHandler(fileHandler)
inObj.close_GMS_loggers()
self._logger = logger_atmCorr
return self._logger
......@@ -303,6 +305,8 @@ class AtmCorr(object):
self._logger.close()
self._logger = None
[inObj.close_GMS_loggers() for inObj in self.inObjs]
@property
def GSDs(self):
......@@ -712,6 +716,7 @@ class AtmCorr(object):
if self.results.data_ac is not None:
self.logger.info('Joining results of atmospheric correction to input GMS objects.')
del self.logger # otherwise logging in inObjs would open a second FileHandler to the same file (which is permitted)
for inObj in self.inObjs:
......
......@@ -128,8 +128,8 @@ class GMS_object(object):
self.path_cloud_class_obj = PG.get_path_cloud_class_obj(self.GMS_identifier,
get_all=True if CFG.job.bench_CLD_class else False)
if CFG.job.exec_mode=='Python':
self.path_InFilePreprocessor = os.path.join(self.ExtractedFolder, '%s%s_DN.bsq' \
%(self.entity_ID,('_'+self.subsystem if re.search("Terra", self.satellite, re.I) else '')))
self.path_InFilePreprocessor = os.path.join(self.ExtractedFolder, '%s%s_DN.bsq'
%(self.entity_ID, ('_%s'%self.subsystem if self.subsystem else '')))
else: # Flink
self.path_InFilePreprocessor = None # None: keeps all produced data in memory (numpy array attributes)
......@@ -166,9 +166,9 @@ class GMS_object(object):
# delete arrays if their in-mem size is to big to be pickled
# => (avoids MaybeEncodingError: Error sending result: '[<GeoMultiSens_dev.algorithms.L2C_P.L2C_object
# object at 0x7fc44f6399e8>]'. Reason: 'error("'i' format requires -2147483648 <= number <= 2147483647",)')
#if self.proc_level=='L2C' and CFG.job.exec_mode=='Flink':
# del self.arr, self.masks
if self.proc_level=='L2C' and CFG.job.exec_mode=='Flink':
if self.mask_nodata is not None and self.masks.bands>1 and self.mask_clouds is not None: # FIXME check by bandname
del self.masks
return self.__dict__
......@@ -1012,28 +1012,23 @@ class GMS_object(object):
for tb in HLP_F.get_image_tileborders(target_tileshape, target_tilesize, shape_fullArr=self.shape_fullArr)]
def log_for_fullArr_or_firstTile(self, log_msg, subset=None, logger=None):
def log_for_fullArr_or_firstTile(self, log_msg, subset=None):
"""Send a message to the logger only if full array or the first tile is currently processed.
This function can be called when processing any tile but log message will only be sent from first tile.
:param log_msg: the log message to be logged
:param subset: subset argument as sent to e.g. DN2TOARadRefTemp that indicates which tile is to be processed.
Not needed if self.arr_pos is not None.
:param logger: a GMS_logger object
"""
logger = logger if logger else self.logger
if subset is None and\
(self.arr_shape=='cube' or self.arr_pos is None or [self.arr_pos[0][0],self.arr_pos[1][0]]==[0,0]) or \
subset==['cube',None] or (subset and [subset[1][0][0], subset[1][1][0]]==[0,0]) or \
hasattr(self,'logAtThisTile') and getattr(self,'logAtThisTile'): # cube or 1st tile
logger.info(log_msg)
self.logger.info(log_msg)
else:
pass
logger.close()
self.logger.close()
self.logger = None
@staticmethod
def rescale_array(inArray, outScaleFactor, inScaleFactor=1):
......@@ -1765,7 +1760,9 @@ class GMS_object(object):
if sys.platform.startswith('linux'):
# delete temporary extraction folder
if os.path.isdir(self.ExtractedFolder): shutil.rmtree(self.ExtractedFolder)
if os.path.isdir(self.ExtractedFolder):
shutil.rmtree(self.ExtractedFolder)
if os.path.isdir(self.ExtractedFolder):
self.logger.warning('Could not delete temporary extraction folder: %s' % self.ExtractedFolder)
......
......@@ -95,10 +95,10 @@ class Job:
self.path_job_logs = absP('./logs/job_logs/')
# processor configuration: [run processor, write output, delete output if not needed anymore]
self.exec__L1AP = [1, 1, 1]
self.exec__L1BP = [1, 1, 1]
self.exec__L1CP = [1, 1, 1]
self.exec__L2AP = [1, 1, 1]
self.exec__L1AP = [1, 0, 1]
self.exec__L1BP = [1, 0, 1]
self.exec__L1CP = [1, 0, 1]
self.exec__L2AP = [1, 0, 1]
self.exec__L2BP = [1, 1, 0]
self.exec__L2CP = [1, 1, 0]
......
e4d215558b5d069528532f865b7b13c8062554a9
\ No newline at end of file
e469af5c741e5df3bd79b272f20da078e218c8ef
\ No newline at end of file
......@@ -6,6 +6,7 @@ import os
import re
import tempfile
import warnings
import uuid
from ..config import GMS_config as CFG
from .definition_dicts import get_GMS_sensorcode
......@@ -128,8 +129,9 @@ class path_generator(object):
path_archive = self.get_local_archive_path_baseN()
RootName = os.path.splitext(os.path.basename(path_archive))[0]
RootName = os.path.splitext(RootName)[0] if os.path.splitext(RootName)[1] else RootName
RootName += '__'+ uuid.uuid4().hex # add a hex code in order to get uniqueness
return os.path.join(CFG.job.path_tempdir, RootName, self.sensor, self.subsystem) \
if self.subsystem not in [None, ''] else os.path.join(CFG.job.path_tempdir, RootName, self.sensor)
if self.subsystem else os.path.join(CFG.job.path_tempdir, RootName, self.sensor)
def get_outPath_hdr(self,attrName2write):
# type: (str) -> str
......
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