From 7d1707b4fce11ac5ea634b0bb265dccac0eac627 Mon Sep 17 00:00:00 2001 From: arbennett Date: Sun, 5 Nov 2023 16:00:05 -0700 Subject: [PATCH 1/2] Fix minor bugs on dimension naming --- metsim/disaggregate.py | 3 +-- metsim/io.py | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) 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'] From 6db0c3c603dbf829c361297335063c446f825625 Mon Sep 17 00:00:00 2001 From: arbennett Date: Sun, 5 Nov 2023 16:05:40 -0700 Subject: [PATCH 2/2] Add whatsnew --- docs/whats-new.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) 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