Skip to content

Commit

Permalink
add logic to define start and end points for situation where desired …
Browse files Browse the repository at this point in the history
…date range is contained by xarray dataset to crop_date_range
  • Loading branch information
wrongkindofdoctor committed Dec 8, 2024
1 parent edf6ad3 commit fe26e37
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,10 @@ def crop_date_range(self, case_date_range: util.DateRange, xr_ds, time_coord) ->
# dataset overlaps user-specified date range end
elif date_range_cf_start < ds_start <= date_range_cf_end <= ds_end:
new_xr_ds = xr_ds.sel({time_coord.name: slice(ds_start, date_range_cf_end)})
# dataset contains all of requested date range
elif date_range_cf_start>=ds_start and date_range_cf_end<=ds_end:
new_xr_ds = xr_ds.sel({time_coord.name: slice(date_range_cf_start, date_range_cf_end)})

return new_xr_ds

def check_group_daterange(self, df: pd.DataFrame, date_range: util.DateRange,
Expand Down

0 comments on commit fe26e37

Please sign in to comment.