Skip to content

Commit

Permalink
Merge pull request #241 from UW-Hydro/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
arbennett committed Aug 21, 2020
2 parents 442c095 + 7aba05a commit 3550648
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 7 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ What's New

.. _whats-new.2.3.0:

v2.3.3
------

Bug fixes
~~~~~~~~~
- Fix a bug in use of alternate calendars due to xarray change

v2.3.2
------

Expand Down
6 changes: 1 addition & 5 deletions metsim/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,17 @@ def date_range(start=None, end=None, periods=None, freq='D', tz=None,
else:
# start and end are give
if (start is not None) and (end is not None) and (periods is None):

steps, units = decode_freq(freq)
start_num, end_num = date2num(
pd.to_datetime([start, end]).to_pydatetime(),
units, calendar=calendar)
# Todo divide by freq
periods = int((end_num - start_num) / steps) + 1

times = num2date(
np.linspace(start_num, end_num, periods,
endpoint=True,
dtype=np.float128), units, calendar)

index = pd.DatetimeIndex(xr.conventions.nctime_to_nptime(times))

index = xr.CFTimeIndex(times).to_datetimeindex()
return index

else:
Expand Down
3 changes: 2 additions & 1 deletion metsim/disaggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def disaggregate(df_daily: pd.DataFrame, params: dict,
stop = (df_daily.index[-1] + pd.Timedelta('1 days') -
pd.Timedelta("{} minutes".format(params['time_step'])))
dates_disagg = date_range(df_daily.index[0], stop,
freq='{}T'.format(params['time_step']))
freq='{}T'.format(params['time_step']),
calendar=params['calendar'])
df_disagg = pd.DataFrame(index=dates_disagg)
n_days = len(df_daily)
n_disagg = len(df_disagg)
Expand Down

0 comments on commit 3550648

Please sign in to comment.