You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importxarrayasxrds=xr.open_zarr(
"gs://weatherbench2/datasets/era5/1959-2023_01_10-full_37-1h-0p25deg-chunk-1.zarr",
chunks={},
)
ds=ds[
["u_component_of_wind", "v_component_of_wind", "temperature", "vertical_velocity"]
].rename(
{
"u_component_of_wind": "U",
"v_component_of_wind": "V",
"temperature": "T",
"vertical_velocity": "W",
}
)
zonal_means=ds.mean("longitude")
anomaly=ds-zonal_meansanomaly["uv"] =anomaly.U*anomaly.Vanomaly["vt"] =anomaly.V*anomaly.Tanomaly["uw"] =anomaly.U*anomaly.Wtemdiags=zonal_means.merge(anomaly[["uv", "vt", "uw"]].mean("longitude"))
# This is incredibly slow, takes a while for flox to construct the graph# daily = temdiags.resample(time="D").mean()# Option 2: rechunk to make it a blockwise problem# we should do this automaticallyfromxarray.groupersimportTimeResamplerdaily=temdiags.chunk(time=TimeResampler("D")).resample(time="D").mean()
daily.to_zarr(SOMEWHERE)
Activity
dcherian commentedon Sep 17, 2024
Rewritten to use the weatherbench2 dataset