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

feat: Ensure model is not run after model period end

parent 11217d46
No related branches found
No related tags found
No related merge requests found
......@@ -165,14 +165,24 @@ if __name__ == "__main__":
start_date = model_start_date
end_date = today + timedelta(days=2)
if start_date > end_date:
logging.error("Model period not started. Quit.")
sys.exit()
logging.info(
f"Model start date {model_start_date}. Model end date {model_end_date}."
)
logging.info(
f"Start running model {model_id} for start date {start_date} and end date {end_date}"
f"Attempt to run model {model_id} for start date {start_date} and end date {end_date} (today + 2 days)"
)
# Ensure that model is not run after model run period (include 2 extra days at the end to replace forecast with reanalysed)
if model_end_date + timedelta(days=2) < end_date:
logging.error(f"{end_date} is after model period end (+ 2 days) {model_end_date + timedelta(days=2)}. Quit.")
sys.exit()
# Ensure that model is not run before model run period
if today < start_date:
logging.error("Model period not started. Quit.")
sys.exit()
weather_data_file = weather_data_dir + today.strftime(weather_data_filename_pattern)
max_temp_in_period_file = f"{tmp_dir}{year}_max_temp_for_period.nc"
unmasked_result_file = f"{tmp_dir}{year}_unmasked_result.nc"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment