Skip to content

Commit

Permalink
Updates to NMSE notebook / functions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mnlevy1981 committed Dec 20, 2024
1 parent fd1f66c commit 6013fb7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nblibrary/atm/Global_PSL_NMSE_compare_obs_lens.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion nblibrary/atm/averaging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 6013fb7

Please sign in to comment.