Skip to content

Commit

Permalink
add more tas (#544)
Browse files Browse the repository at this point in the history
<!-- Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [ ] This PR addresses an already opened issue (for bug fixes /
features)
    - This PR fixes #xyz
- [ ] (If applicable) Documentation has been added / updated (for bug
fixes / features).
- [ ] (If applicable) Tests have been added.
- [x] This PR does not seem to break the templates.
- [x] CHANGELOG.rst has been updated (with summary of main changes).
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added.

### What kind of change does this PR introduce?

* Add annual global tas timeseries for CMIP6's models CanESM5 r1i1p2f1
(ssp126, ssp245, ssp370, ssp585), MPI-ESM1-2-LR ssp370 (r2i1p1f1,
r3i1p1f1, r4i1p1f1, r5i1p1f1) (driving models of CRCM5)

### Does this PR introduce a breaking change?
no

### Other information:
for @mccrayc 

Done with this code:
```
import xscen as xs
import xclim as xc
import xarray as xr

ds_tas=xr.open_dataset('../../src/xscen/data/IPCC_annual_global_tas_old.nc')


#from PR270 de Pascal
def get_global_tas(source, exp, member):
    scats = xs.search_data_catalogs(
        '/catalogues/simulation.json',
        {'tas': 'MS'},
        other_search_criteria={'source': source, 'experiment': exp, 'member': member, 'processing_level': 'raw'},
        match_hist_and_fut=True
    )
    ds = xs.extract_dataset(scats.popitem()[1])['MS']
    day = ds.resample(time='YS').mean()
    dam = xs.spatial_mean(
        day,
        region='global',
        method='cos-lat',
        spatial_subset=False
    )
    dam['tas']= xc.units.convert_units_to(dam.tas, '°C')
    dam=dam.expand_dims('simulation').drop_vars('height').assign_coords(
        source=(("simulation",), [source]),
        data_source=(("simulation",),['From Amon with xscen'],),
        mip_era=(("simulation",), ['CMIP6']),
        experiment=(("simulation",), [exp]),
        member=(("simulation",), [member]),
    )
    return dam
new=[get_global_tas("MPI-ESM1-2-LR", 'ssp370', f'r{n}i1p1f1') for n in range(2,6)]
new1 =[get_global_tas('CanESM5',exp,'r1i1p2f1') for exp in ['ssp126','ssp245','ssp370','ssp585']]
#change from cftime to datetime
new2=[]
for ds in new1:
    ds['time']=ds.indexes['time'].to_datetimeindex()
    new2.append(ds)

out = xr.concat([ds_tas] + new + new2, "simulation")
out.attrs=ds_tas.attrs
out['tas'].attrs=ds_tas['tas'].attrs
display(ds_tas)
display(out)
xs.save_to_netcdf(out, '../../src/xscen/data/IPCC_annual_global_tas.nc')
```
  • Loading branch information
juliettelavoie authored Mar 3, 2025
2 parents 3ce2e83 + 5ec3000 commit b8266c3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ New features and enhancements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Include station-obs and forecasts in the derived schema for `build_path`. (:pull:`534`).
* Project catalog now allows `check_valid` and `drop_duplicates` keyword arguments. (:pull:`536`, :issue:`535`).
* Add annual global tas timeseries for CMIP6's models CanESM5 r1i1p2f1 (ssp126, ssp245, ssp370, ssp585), MPI-ESM1-2-LR ssp370 (r2i1p1f1, r3i1p1f1, r4i1p1f1, r5i1p1f1) (:pull:`544`).

Bug fixes
^^^^^^^^^
Expand Down
Binary file modified src/xscen/data/IPCC_annual_global_tas.nc
Binary file not shown.

0 comments on commit b8266c3

Please sign in to comment.