Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more tas #544

Merged
merged 4 commits into from
Mar 3, 2025
Merged

add more tas #544

merged 4 commits into from
Mar 3, 2025

Conversation

juliettelavoie
Copy link
Contributor

@juliettelavoie juliettelavoie commented Mar 3, 2025

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.
  • This PR does not seem to break the templates.
  • CHANGELOG.rst has been updated (with summary of main changes).
    • 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')

@juliettelavoie juliettelavoie requested a review from aulemahal March 3, 2025 14:34
@mccrayc
Copy link
Collaborator

mccrayc commented Mar 3, 2025

Merci Juliette!

@juliettelavoie juliettelavoie merged commit b8266c3 into main Mar 3, 2025
16 checks passed
@juliettelavoie juliettelavoie deleted the add-tas branch March 3, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants