Skip to content
Snippets Groups Projects
Commit 7723227c authored by Lene Wasskog's avatar Lene Wasskog
Browse files

fix: Filename bug

parent 4e6b2f44
No related branches found
No related tags found
No related merge requests found
Pipeline #4025 passed
...@@ -233,33 +233,33 @@ if __name__ == "__main__": ...@@ -233,33 +233,33 @@ if __name__ == "__main__":
filename = os.path.basename(file) filename = os.path.basename(file)
current_file_date_str = filename.split("_")[1].split(".")[0] current_file_date_str = filename.split("_")[1].split(".")[0]
current_file_date = datetime.strptime(current_file_date_str, "%Y-%m-%d").date() current_file_date = datetime.strptime(current_file_date_str, "%Y-%m-%d").date()
with open("/dev/null", "w") as devnull:
warning_status_lcc = (
f"{tmp_dir}result_WARNING_STATUS_{current_file_date_str}_lcc.tif"
)
result_lcc = f"{tmp_dir}result_{current_file_date_str}_lcc.tif"
warning_status = (
f"{result_tif_dir}result_WARNING_STATUS_{current_file_date_str}.tif"
)
result = f"{result_tif_dir}result_{current_file_date_str}.tif"
logging.debug(f"Calculate result for {current_file_date_str}") # Ensure warning status 0 for all points on first day after model end date, mask if mask file is given
if current_file_date > model_end_date:
# Ensure warning status 0 for all points on first day after model end date, mask if mask file is given original_file = file
if current_file_date > model_end_date: tmp_file = f"{tmp_dir}day_with_warning_status_0.nc"
tmp_file = "tmp" + file run_command(
os.rename(file, tmp_file) command=f'cdo -s -aexpr,"WARNING_STATUS = 0" {original_file} {tmp_file}',
)
if mask_file_path is not None:
logging.info(f"Mask {tmp_file} with {os.path.basename(mask_file_path)}")
run_command( run_command(
command=f'cdo -s -aexpr,"WARNING_STATUS = 0" {tmp_file} {file}', command=f"cdo -P 6 -maskregion,{mask_file_path} {tmp_file} {original_file}",
) )
os.rename(file, tmp_file) else:
if mask_file_path is not None: os.rename(tmp_file, original_file)
logging.info(f"Mask {file} with {os.path.basename(mask_file_path)}")
run_command( warning_status_lcc = (
command=f"cdo -P 6 -maskregion,{mask_file_path} {tmp_file} {file}", f"{tmp_dir}result_WARNING_STATUS_{current_file_date_str}_lcc.tif"
) )
else: result_lcc = f"{tmp_dir}result_{current_file_date_str}_lcc.tif"
os.rename(tmp_file, file) warning_status = (
f"{result_tif_dir}result_WARNING_STATUS_{current_file_date_str}.tif"
)
result = f"{result_tif_dir}result_{current_file_date_str}.tif"
logging.debug(f"Calculate result for {current_file_date_str}")
with open("/dev/null", "w") as devnull:
# For warning status: # For warning status:
run_command( run_command(
...@@ -281,9 +281,9 @@ if __name__ == "__main__": ...@@ -281,9 +281,9 @@ if __name__ == "__main__":
stdout=devnull, stdout=devnull,
) )
# Should not generate grey files for more than one day after model end date # Should not generate grey files for more than one day after model end date
if current_file_date > model_end_date: if current_file_date > model_end_date:
break break
# Generate mapfile # Generate mapfile
# Building data sets for language specific legends # Building data sets for language specific legends
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment