diff --git a/ADASMELIAE.py b/ADASMELIAE.py index 8c347bc0fcd160932d4d250da37051fbbe4f9e5c..09e6db09e0b1186c2c354712bc53035f63fbb92e 100755 --- a/ADASMELIAE.py +++ b/ADASMELIAE.py @@ -169,14 +169,24 @@ if __name__ == "__main__": end_date if end_date <= model_end_date else model_end_date + timedelta(days=1) ) - 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"