Skip to content

Commit

Permalink
Issue #64: correct output files splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
gnrgomes committed Mar 15, 2024
1 parent a2b9c0d commit b7debaf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lisvap/utils/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b7debaf

Please sign in to comment.