Commit 7feaa437 authored by Aurore Dupuis's avatar Aurore Dupuis
Browse files

Merge branch 'release-1.6' into 'develop'

Patch 1.6.5

See merge request remote_modules/let-it-snow!59
parents c09d5f11 5bcc1fe5
......@@ -56,34 +56,42 @@ def main(argv):
""" main script of snow extraction procedure"""
json_file = argv[1]
# Set logging level and format.
logging.basicConfig(stream=sys.stdout, level=logging.INFO, \
format='%(asctime)s - %(filename)s:%(lineno)s - %(levelname)s - %(message)s')
logging.info("Start run_snow_annual_map.py")
logging.info("Input args = {}".format(json_file))
logging.info("Load parameters")
# ----------------------------------------------------------------------------------------
# Set parameters
# ----------------------------------------------------------------------------------------
with open(json_file) as json_data_file:
params = json.load(json_data_file)
output_dir = params.get("path_out")
if not os.path.exists(output_dir):
logging.info("Create directory {} ...".format(output_dir))
os.makedirs(output_dir)
log = params.get("log", True)
stdout_file = op.join(output_dir, "stdout.log")
stderr_file = op.join(output_dir, "stderr.log")
if log:
sys.stdout = open(params.get("log_stdout", stdout_file), 'w')
sys.stderr = open(params.get("log_stderr", stderr_file), 'w')
# Set logging level and format.
mode = params.get("mode", "RUNTIME")
if mode == "DEBUG":
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, \
format='%(asctime)s - %(filename)s:%(lineno)s - %(levelname)s - %(message)s')
logging.debug("Debug is enabled")
else:
logging.basicConfig(stream=sys.stdout, level=logging.INFO, \
format='%(asctime)s - %(filename)s:%(lineno)s - %(levelname)s - %(message)s')
logging.info("Start run_snow_annual_map.py")
logging.info("Input args = {}".format(json_file))
tile_id = params.get("tile_id")
date_start = str_to_datetime(params.get("date_start"), "%d/%m/%Y")
date_stop = str_to_datetime(params.get("date_stop"), "%d/%m/%Y")
date_margin = timedelta(days=params.get("date_margin", 0))
logging.debug("Date margin: {}".format(date_margin))
output_dir = params.get("path_out")
if not os.path.exists(output_dir):
logging.info("Create directory {} ...".format(output_dir))
os.makedirs(output_dir)
processing_id = str(tile_id + "_" + datetime_to_str(date_start) + "_" + datetime_to_str(date_stop))
path_out = op.join(output_dir, processing_id)
......@@ -116,10 +124,6 @@ def main(argv):
densification_path_list = []
log = params.get("log", True)
if log:
sys.stdout = open(params.get("log_stdout", op.join(path_out, "stdout.log")), 'w')
sys.stderr = open(params.get("log_stderr", op.join(path_out, "stderr.log")), 'w')
# ----------------------------------------------------------------------------------------
# Search snow products
......@@ -214,6 +218,9 @@ def main(argv):
shutil.copy2(nobs_output_file, path_out)
shutil.copy2(smod_file, path_out)
shutil.copy2(sod_file, path_out)
if log:
shutil.copy2(stdout_file, path_out)
shutil.copy2(stderr_file, path_out)
os.remove(input_dates_file_path)
os.remove(output_dates_file_path)
......@@ -224,6 +231,9 @@ def main(argv):
os.remove(nobs_output_file)
os.remove(smod_file)
os.remove(sod_file)
if log:
os.remove(stdout_file)
os.remove(stderr_file)
logging.info("End run_snow_annual_map.py")
......
......@@ -20,4 +20,4 @@
# limitations under the License.
#
VERSION = "1.6.3"
VERSION = "1.6.5"
Supports Markdown
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