diff --git a/docs/whats-new.rst b/docs/whats-new.rst index d4e6882..6d4365d 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -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 diff --git a/metsim/disaggregate.py b/metsim/disaggregate.py index 7367079..9e71d51 100644 --- a/metsim/disaggregate.py +++ b/metsim/disaggregate.py @@ -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']))) diff --git a/metsim/io.py b/metsim/io.py index e57d85e..164335d 100644 --- a/metsim/io.py +++ b/metsim/io.py @@ -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()) @@ -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']