diff --git a/ADASMELIAE.py b/ADASMELIAE.py index 8d37f8e643b484fa2d45880add19e080920c265a..b028941a772b77421473f0facb5999e30c951c98 100755 --- a/ADASMELIAE.py +++ b/ADASMELIAE.py @@ -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"