From 15c3590823f10665a7753397dcb4fbe1a9bdb134 Mon Sep 17 00:00:00 2001 From: Moritz Makowski Date: Sat, 6 Jan 2024 12:12:50 +0000 Subject: [PATCH] #83 Add option to save binary files --- config/config.template.json | 3 ++- src/retrieval/session/move_outputs.py | 13 +++++++++++++ src/types/config.py | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config/config.template.json b/config/config.template.json index 2d051b13..dd8297c6 100644 --- a/config/config.template.json +++ b/config/config.template.json @@ -35,7 +35,8 @@ "retrieval": { "general": { "max_process_count": 9, - "ifg_file_regex": "^$(SENSOR_ID)$(DATE).*\\.\\d+$" + "ifg_file_regex": "^$(SENSOR_ID)$(DATE).*\\.\\d+$", + "store_binary_spectra": false }, "ifg_file_permissions": { "fail_on_permission_error": true, diff --git a/src/retrieval/session/move_outputs.py b/src/retrieval/session/move_outputs.py index bee64693..fa90128d 100644 --- a/src/retrieval/session/move_outputs.py +++ b/src/retrieval/session/move_outputs.py @@ -90,6 +90,19 @@ def run( shutil.copytree(output_src_dir, output_dst) shutil.rmtree(output_src_dir) + # (OPTIONAL) STORE BINARY SPECTRA + + if config.retrieval.general.store_binary_spectra: + if session.retrieval_algorithm in ["proffast-2.2", "proffast-2.3"]: + shutil.copytree( + os.path.join( + session.ctn.data_output_path, "analysis", + f"{session.ctx.sensor_id}_SN{session.ctx.serial_number:03d}", + session.ctx.from_datetime.strftime("%y%m%d"), "cal" + ), + os.path.join(output_dst, "binary_spectra"), + ) + # STORE AUTOMATION LOGS shutil.copyfile( diff --git a/src/types/config.py b/src/types/config.py index 3f815d1e..67f52a11 100644 --- a/src/types/config.py +++ b/src/types/config.py @@ -137,6 +137,11 @@ class RetrievalGeneralConfig(pydantic.BaseModel): r"^$(SENSOR_ID)$(DATE).*\.nc$", ], ) + store_binary_spectra: bool = pydantic.Field( + ..., + description= + "Whether to store the binary spectra files. These are the files that are used by the retrieval algorithm. They are not needed for the output files, but can be useful for debugging.", + ) class RetrievalIfgFilePermissionsConfig(pydantic.BaseModel):