Skip to content

Commit 259eece

Browse files
authored
Merge pull request #268 from UW-Hydro/develop
Fix minor bugs on dimension naming
2 parents 8ac237d + 6db0c3c commit 259eece

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

docs/whats-new.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
What's New
44
==========
5+
6+
.. _whats-new.2.4.3:
7+
8+
v2.4.3
9+
------
10+
Bug fixes
11+
~~~~~~~~~
12+
- Fix a bug in the alignment of longitude values
13+
- Fix a bug with using non-standard spatial dimension names
14+
515
.. _whats-new.2.4.2:
616

717
v2.4.2

metsim/disaggregate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ def disaggregate(df_daily: pd.DataFrame, params: dict,
6464
A dataframe with sub-daily timeseries.
6565
"""
6666
# adjust any longitude values to be within [-180, +180] range
67-
lon_var = params['domain_vars']['lon']
68-
params[lon_var] = math.remainder(params[lon_var], 360)
67+
params['lon'] = math.remainder(params['lon'], 360)
6968

7069
stop = (df_daily.index[-1] + pd.Timedelta('1 days') -
7170
pd.Timedelta("{} minutes".format(params['time_step'])))

metsim/io.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ def read_netcdf(data_handle, domain=None, is_worker=False,
270270
else:
271271
ds = xr.open_dataset(data_handle)
272272

273+
# Needs to happen first to make sure variable names are correct
274+
if var_dict is not None:
275+
var_list = list(var_dict.keys())
276+
ds = ds[var_list]
277+
ds = ds.rename(var_dict)
278+
273279
if domain is not None:
274280
ds = ds.sel({k: domain[k]
275281
for k in list(domain.dims.keys())
@@ -289,11 +295,6 @@ def read_netcdf(data_handle, domain=None, is_worker=False,
289295
ds['time'] = (ds.indexes['time'] -
290296
pd.Timedelta(hours=11, minutes=59, seconds=59)).round('D')
291297

292-
if var_dict is not None:
293-
var_list = list(var_dict.keys())
294-
ds = ds[var_list]
295-
ds = ds.rename(var_dict)
296-
297298
if start is not None or stop is not None:
298299
ds = ds.sel(time=slice(start, stop))
299300
dates = ds.indexes['time']

0 commit comments

Comments
 (0)