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__":
filename = os.path.basename(file)
current_file_date_str = filename.split("_")[1].split(".")[0]
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:
tmp_file = "tmp" + file
os.rename(file, tmp_file)
# 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:
original_file = file
tmp_file = f"{tmp_dir}day_with_warning_status_0.nc"
run_command(
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(
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)
if mask_file_path is not None:
logging.info(f"Mask {file} with {os.path.basename(mask_file_path)}")
run_command(
command=f"cdo -P 6 -maskregion,{mask_file_path} {tmp_file} {file}",
)
else:
os.rename(tmp_file, file)
else:
os.rename(tmp_file, original_file)
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}")
with open("/dev/null", "w") as devnull:
# For warning status:
run_command(
......@@ -281,9 +281,9 @@ if __name__ == "__main__":
stdout=devnull,
)
# Should not generate grey files for more than one day after model end date
if current_file_date > model_end_date:
break
# Should not generate grey files for more than one day after model end date
if current_file_date > model_end_date:
break
# Generate mapfile
# 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