Skip to content

Commit

Permalink
Merge pull request #268 from UW-Hydro/develop
Browse files Browse the repository at this point in the history
Fix minor bugs on dimension naming
  • Loading branch information
arbennett committed Nov 5, 2023
2 parents 8ac237d + 6db0c3c commit 259eece
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 10 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

What's New
==========

.. _whats-new.2.4.3:

v2.4.3
------
Bug fixes
~~~~~~~~~
- Fix a bug in the alignment of longitude values
- Fix a bug with using non-standard spatial dimension names

.. _whats-new.2.4.2:

v2.4.2
Expand Down
3 changes: 1 addition & 2 deletions metsim/disaggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def disaggregate(df_daily: pd.DataFrame, params: dict,
A dataframe with sub-daily timeseries.
"""
# adjust any longitude values to be within [-180, +180] range
lon_var = params['domain_vars']['lon']
params[lon_var] = math.remainder(params[lon_var], 360)
params['lon'] = math.remainder(params['lon'], 360)

stop = (df_daily.index[-1] + pd.Timedelta('1 days') -
pd.Timedelta("{} minutes".format(params['time_step'])))
Expand Down
11 changes: 6 additions & 5 deletions metsim/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ def read_netcdf(data_handle, domain=None, is_worker=False,
else:
ds = xr.open_dataset(data_handle)

# Needs to happen first to make sure variable names are correct
if var_dict is not None:
var_list = list(var_dict.keys())
ds = ds[var_list]
ds = ds.rename(var_dict)

if domain is not None:
ds = ds.sel({k: domain[k]
for k in list(domain.dims.keys())
Expand All @@ -289,11 +295,6 @@ def read_netcdf(data_handle, domain=None, is_worker=False,
ds['time'] = (ds.indexes['time'] -
pd.Timedelta(hours=11, minutes=59, seconds=59)).round('D')

if var_dict is not None:
var_list = list(var_dict.keys())
ds = ds[var_list]
ds = ds.rename(var_dict)

if start is not None or stop is not None:
ds = ds.sel(time=slice(start, stop))
dates = ds.indexes['time']
Expand Down

0 comments on commit 259eece

Please sign in to comment.