From b7debaf402057ed29e7355c3578155928603fc2b Mon Sep 17 00:00:00 2001 From: gnrgomes Date: Fri, 15 Mar 2024 17:45:50 +0100 Subject: [PATCH] Issue #64: correct output files splitting --- src/lisvap/utils/writers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lisvap/utils/writers.py b/src/lisvap/utils/writers.py index 998b3b5..d7e86c7 100644 --- a/src/lisvap/utils/writers.py +++ b/src/lisvap/utils/writers.py @@ -78,6 +78,9 @@ def get_output_parameters_monthly(start_date, timestep, time_frequency, timestep output_index = 0 elif current_date == last_date_last_month: filename_suffix = day_inside_last_month.strftime('%Y%m') + first_date_last_month = day_inside_last_month.replace(day=1) + datetime.timedelta(seconds=(2 * timestep_stride)) + num_steps_done_in_last_month = int((last_date_last_month - first_date_last_month).total_seconds() / timestep_stride) + 1 + output_index = num_steps_done_in_last_month elif current_output_index >= num_steps_done_in_current_month: output_index = num_steps_done_in_current_month - 1 return filename_suffix, output_index @@ -98,6 +101,9 @@ def get_output_parameters_yearly(start_date, timestep, time_frequency, timestep_ output_index = 0 elif current_date == last_date_last_year: filename_suffix = day_inside_last_year.strftime('%Y') + first_date_last_year = first_date_current_year.replace(year=current_date.year - 1) + num_steps_done_in_last_year = int((last_date_last_year - first_date_last_year).total_seconds() / timestep_stride) + 1 + output_index = num_steps_done_in_last_year - 1 elif current_output_index >= num_steps_done_in_current_year: output_index = num_steps_done_in_current_year - 1 return filename_suffix, output_index