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

Better global tas database and warming level methods #270

Merged
merged 21 commits into from
Dec 11, 2023
Merged

Conversation

aulemahal
Copy link
Collaborator

@aulemahal aulemahal commented Oct 6, 2023

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
  • (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.
  • HISTORY.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?

Addition of:

CMIP6_CMCC-ESM2_ssp245_r1i1p1f1
CMIP6_CMCC-ESM2_ssp370_r1i1p1f1
CMIP6_CMCC-ESM2_ssp585_r1i1p1f1
CMIP6_EC-Earth3-CC_ssp245_r1i1p1f1
CMIP6_EC-Earth3-CC_ssp585_r1i1p1f1
CMIP6_KACE-1-0-G_ssp245_r1i1p1f1
CMIP6_KACE-1-0-G_ssp370_r1i1p1f1
CMIP6_KACE-1-0-G_ssp585_r1i1p1f1
CMIP6_TaiESM1_ssp245_r1i1p1f1
CMIP6_TaiESM1_ssp370_r1i1p1f1

to xscen/data/IPCC_annual_global_tas.csv.

  • Change from CSV to netCDF
  • Accept DataArrays, DataFrames in get_warming_level, output as those or list.
  • Multiple models and multiple warming levels in subset_warming_level.

Does this PR introduce a breaking change?

Yes, if get_warming_level is called with a sequence of models, the output is now a list of the same length. The dictionary can be retrieved by passing output='selected'. I found it way more useful this way!

Other information:

The new global tas were computed with the following code:

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.tas.resample(time='YS').mean()
    dam = xs.spatial_mean(
        day,
        region='global',
        method='cos-lat',
        spatial_subset=False
    )
    tas = xc.units.convert_units_to(dam, '°C')
    return tas.rename(time='year').assign_coords(year=tas.time.dt.year.values)

See issue #268 for discussion of small differences between this and the official IPCC-provided data.

@juliettelavoie
Copy link
Contributor

do we want to add the source to the original data in the csv ?
Technically, it is here: https://github.com/Ouranosinc/xscen/blob/b3c79cd02f01c9f791d082459464b0842b5f4f6c/xscen/extract.py#L861C2-L861C2
(not exactly the github page with the data, but the paper links to the repo)

but maybe it needs to be in the csv also? (while we are here anyway)

@aulemahal
Copy link
Collaborator Author

Good idea!

@github-actions github-actions bot added the CI Modifications to autiomation utilities label Oct 6, 2023
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added the docs label Oct 9, 2023
@aulemahal
Copy link
Collaborator Author

Last commits are a rewrite of get_warming_level and subset_warming_level so they're easier to use with arrays.

See changes of the warming level notebook for most explanations. And edit on the root comment.

@aulemahal aulemahal changed the title Better global tas database Better global tas database and warming level methods Oct 9, 2023
@aulemahal
Copy link
Collaborator Author

@sarahclaude Should I use this PR to add the global tas average for non-r1i1p1f1 models ? Will you need that ?

@sarahclaude
Copy link
Collaborator

I might need it in the future but we are not dealing with warming levels yets, so not on short-term.

@aulemahal
Copy link
Collaborator Author

PR prête pour la revue.

J'ai laissé faire les membres non-r1i1p1f1 pour le moment. Les modèles ajoutés sont essentiellement ceux qui manquaient de ESPO-G6.

Copy link
Contributor

@RondeauG RondeauG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good!

xscen/catalog.py Show resolved Hide resolved
HISTORY.rst Outdated Show resolved Hide resolved
xscen/extract.py Outdated Show resolved Hide resolved
xscen/extract.py Outdated Show resolved Hide resolved
xscen/extract.py Outdated Show resolved Hide resolved
xscen/extract.py Outdated Show resolved Hide resolved
xscen/extract.py Outdated Show resolved Hide resolved
xscen/extract.py Outdated Show resolved Hide resolved
tests/test_extract.py Outdated Show resolved Hide resolved
tests/test_extract.py Outdated Show resolved Hide resolved
@RondeauG
Copy link
Contributor

There's output to potentially remove, but other than that, this looks good to go!

Copy link
Contributor

@juliettelavoie juliettelavoie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

xscen/extract.py Outdated
output: {'selected', 'requested'}
When `realization` is a sequence.
If "requested", the function returns a list of the same length as `realization`.
If "selected", the function returns a dict, keys are the models selected in the database.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with a breaking change, returning only a list and removing the output arg.

Warming level dataset.
xr.Dataset or None
Warming level dataset, or None if `ds` can't be subsetted for the requested warming level.
The dataset will have a new dimension `warminglevel` with `wl_dim` as coordinates.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of keeping the fake time axis ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I don't understand the question, but as get_warming_level does not perform any statistical computation, there's a N year window for each warming level. The only way to have a multidimensional dataset with time and wl_dim, is to have some sort of time axis that is not the actual horizon (which is different for each warming level and simulation).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my mistake. I forgot that the mean wasn't calculated on the window in that function.

@Zeitsperre
Copy link
Contributor

Docs are failing because a file only in this branch isn't present in main. Let me know if you want me to bypass protections to push to main!

@aulemahal aulemahal merged commit 1a5fed7 into main Dec 11, 2023
17 of 18 checks passed
@aulemahal aulemahal deleted the upd-globaltas branch December 11, 2023 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Modifications to autiomation utilities docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing simulations in IPCC_annual_global_tas.csv
5 participants