From 6013fb7166ce0145e3cce51d3bdf9f8def11e8b0 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Fri, 20 Dec 2024 11:30:52 -0700 Subject: [PATCH] Updates to NMSE notebook / functions Found a bug in reading the data -- we want to use (base_start_date, base_end_date) as the date range for the base_case data read, not (start_date, end_date). Also, for some reason I needed to .load() the data before calling .rolling() -- it's not clear to me why this was necessary but it avoided an Exception being raised from that function --- nblibrary/atm/Global_PSL_NMSE_compare_obs_lens.ipynb | 2 +- nblibrary/atm/averaging_utils.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nblibrary/atm/Global_PSL_NMSE_compare_obs_lens.ipynb b/nblibrary/atm/Global_PSL_NMSE_compare_obs_lens.ipynb index 7909c8d..dbd3252 100644 --- a/nblibrary/atm/Global_PSL_NMSE_compare_obs_lens.ipynb +++ b/nblibrary/atm/Global_PSL_NMSE_compare_obs_lens.ipynb @@ -204,7 +204,7 @@ " fix_time_dim(\n", " xr.open_mfdataset(f\"{base_file_path}/*PSL*.nc\", decode_times=False)\n", " )\n", - " .sel(time=slice(start_date, end_date))\n", + " .sel(time=slice(base_start_date, base_end_date))\n", " .assign_coords({\"lon\": lon, \"lat\": lat})\n", " .PSL\n", " / 100.0\n", diff --git a/nblibrary/atm/averaging_utils.py b/nblibrary/atm/averaging_utils.py index b98625b..96a44e9 100644 --- a/nblibrary/atm/averaging_utils.py +++ b/nblibrary/atm/averaging_utils.py @@ -36,7 +36,10 @@ def seasonal_climatology_weighted(dat): datw_am = dat * wgts_am ds_season = ( - datw.rolling(min_periods=3, center=True, time=3).sum().dropna("time", how="all") + datw.load() + .rolling(min_periods=3, center=True, time=3) + .sum() + .dropna("time", how="all") ) dat_djf = ds_season.where(ds_season.time.dt.month == 1, drop=True).mean("time") dat_mam = ds_season.where(ds_season.time.dt.month == 4, drop=True).mean("time")