This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| timeseries_hist_datasets = [] | |
| timeseries_ssp126_datasets = [] | |
| timeseries_ssp245_datasets = [] | |
| timeseries_ssp370_datasets = [] | |
| timeseries_ssp585_datasets = [] | |
| for k,ds in data_timeseries.items(): | |
| # Separate experiments | |
| out = ds.convert_calendar('standard') | |
| out = out.sel(time=slice('1850', '2100'))# cut extended runs | |
| out = out.assign_coords(source_id=ds.source_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datatree import open_datatree | |
| timeseries.to_zarr('cmip_timeseries') # or netcdf, with any group structure | |
| roundtrip = open_datatree('cmip_timeseries', engine="zarr") | |
| print(roundtrip) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DataTree('None', parent=None) | |
| ├── DataTree('CESM2') | |
| │ ├── DataTree('historical') | |
| │ │ Dimensions: (vertex: 4, time: 1980, bnds: 2) | |
| │ │ Coordinates: | |
| │ │ * time (time) object 1850-01-15 12:59:59.999997 ... 2014-12-15 12:0... | |
| │ │ Dimensions without coordinates: vertex, bnds | |
| │ │ Data variables: | |
| │ │ lat float64 ... | |
| │ │ lat_bounds (vertex) float32 ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| anomaly = DataTree() | |
| for model_name, model in timeseries.children.items(): | |
| # model-specific base period as an xarray.Dataset | |
| base_period = model["historical"].ds.sel(time=slice('1950','1980')).mean('time') | |
| anomaly[model_name] = model - base_period # subtree - Dataset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import matplotlib.pyplot as plt | |
| from datatree import map_over_subtree | |
| fig, ax = plt.subplots() | |
| @map_over_subtree | |
| def plot_temp(ds, original_ds): | |
| if ds: | |
| label = f'{original_ds.attrs["source_id"]} - {original_ds.attrs["experiment_id"]}' | |
| ds['tos'].rolling(time=2*12).mean().plot(ax=ax, label=label) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.