-
Notifications
You must be signed in to change notification settings - Fork 143
CMORizer for JRA-55 #3141
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
Merged
Merged
CMORizer for JRA-55 #3141
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bbf8d5f
first version
axel-lauer 370e516
first working version of jra-55 downloader
axel-lauer 3b88dec
fixed flake8 issues
axel-lauer 2e08769
snapshot 2023-03-23
axel-lauer 15a848d
first complete version
axel-lauer 6b7aa5b
fixed flake issues
axel-lauer eacb84c
added iris-grib to environment*.yml
axel-lauer e401a51
added iris-grib to setup.py
axel-lauer 67f6cf1
added variable ta to JRA-55 CMORizer
axel-lauer a6a8b45
Merge branch 'main' into cmorizer_jra-55
axel-lauer 2818967
fixed issues in downloader
axel-lauer f603f54
merged latest main branch
axel-lauer c85c45d
updated download path (changed by RDA)
axel-lauer 0fbd84a
Merge branch 'main' into cmorizer_jra-55
a039383
Update esmvaltool/cmorizers/data/formatters/datasets/jra_55.py
axel-lauer 8d33497
JRA-55 formatter: added support for start/end (year)
axel-lauer 332de23
JRA-55 formatter: simplified code for operator diff
axel-lauer 76fff77
JRA-55 formatter: switched from iris-grib to xarray
axel-lauer bb1a307
removed blank line(s)
axel-lauer 792537d
Merge branch 'main' into cmorizer_jra-55
axel-lauer dd28b2f
Merge branch 'main' into cmorizer_jra-55
rbeucher 10b92cd
Merge branch 'main' into cmorizer_jra-55
flicj191 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ dependencies: | |
| - cdo >=1.9.7 | ||
| - cdsapi | ||
| - cf-units | ||
| - cfgrib | ||
| - cftime | ||
| - cmocean | ||
| - cython | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ dependencies: | |
| - cdo >=1.9.7 | ||
| - cdsapi | ||
| - cf-units | ||
| - cfgrib | ||
| - cftime | ||
| - cmocean | ||
| - cython | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| --- | ||
| # Common global attributes for Cmorizer output | ||
| attributes: | ||
| dataset_id: JRA-55 | ||
| version: '1' | ||
| tier: 2 | ||
| modeling_realm: reanaly | ||
| project_id: OBS6 | ||
| source: 'https://rda.ucar.edu/datasets/ds628.1/' | ||
| reference: 'jra_55' | ||
| comment: | | ||
| '' | ||
|
|
||
| # Variables to cmorize | ||
| variables: | ||
| cli: | ||
| short_name: cli | ||
| mip: Amon | ||
| file: fcst_p125.229_ciwc.{year}01_{year}12.grb | ||
|
|
||
| clivi: | ||
| short_name: clivi | ||
| mip: Amon | ||
| file: fcst_column125.058_cice.{year}01_{year}12.grb | ||
|
|
||
| clw: | ||
| short_name: clw | ||
| mip: Amon | ||
| file: fcst_p125.228_clwc.{year}01_{year}12.grb | ||
|
|
||
| clwvi: | ||
| short_name: clwvi | ||
| mip: Amon | ||
| operator: sum | ||
| files: | ||
| - 'fcst_column125.058_cice.{year}01_{year}12.grb' | ||
| - 'fcst_column125.227_cw.{year}01_{year}12.grb' | ||
|
|
||
| clt: | ||
| short_name: clt | ||
| mip: Amon | ||
| file: fcst_surf125.071_tcdc.{year}01_{year}12.grb | ||
|
|
||
| prw: | ||
| short_name: prw | ||
| mip: Amon | ||
| file: fcst_column125.054_pwat.{year}01_{year}12.grb | ||
|
|
||
| rlus: | ||
| short_name: rlus | ||
| mip: Amon | ||
| typeOfLevel: surface | ||
| file: fcst_phy2m125.212_ulwrf.{year}01_{year}12.grb | ||
|
|
||
| rlut: | ||
| short_name: rlut | ||
| mip: Amon | ||
| typeOfLevel: nominalTop | ||
| file: fcst_phy2m125.212_ulwrf.{year}01_{year}12.grb | ||
|
|
||
| rlutcs: | ||
| short_name: rlutcs | ||
| mip: Amon | ||
| file: fcst_phy2m125.162_csulf.{year}01_{year}12.grb | ||
|
|
||
| rsus: | ||
| short_name: rsus | ||
| mip: Amon | ||
| typeOfLevel: surface | ||
| file: fcst_phy2m125.211_uswrf.{year}01_{year}12.grb | ||
|
|
||
| rsuscs: | ||
| short_name: rsuscs | ||
| mip: Amon | ||
| typeOfLevel: surface | ||
| file: fcst_phy2m125.160_csusf.{year}01_{year}12.grb | ||
|
|
||
| rsut: | ||
| short_name: rsut | ||
| mip: Amon | ||
| typeOfLevel: nominalTop | ||
| file: fcst_phy2m125.211_uswrf.{year}01_{year}12.grb | ||
|
|
||
| rsutcs: | ||
| short_name: rsutcs | ||
| mip: Amon | ||
| typeOfLevel: nominalTop | ||
| file: fcst_phy2m125.160_csusf.{year}01_{year}12.grb | ||
|
|
||
| ta: | ||
| short_name: ta | ||
| mip: Amon | ||
| file: anl_p125.011_tmp.{year}01_{year}12.grb | ||
|
|
||
| tas: | ||
| short_name: tas | ||
| mip: Amon | ||
| file: anl_surf125.011_tmp.{year}01_{year}12.grb | ||
|
|
||
| wap: | ||
| short_name: wap | ||
| mip: Amon | ||
| file: anl_p125.039_vvel.{year}01_{year}12.grb | ||
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
115 changes: 115 additions & 0 deletions
115
esmvaltool/cmorizers/data/downloaders/datasets/jra_55.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| """Script to download JRA-55 from RDA.""" | ||
| import logging | ||
| import os | ||
|
|
||
| from datetime import datetime | ||
|
|
||
| from dateutil import relativedelta | ||
|
|
||
| from esmvaltool.cmorizers.data.downloaders.wget import WGetDownloader | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def download_dataset(config, dataset, dataset_info, start_date, end_date, | ||
| overwrite): | ||
| """Download dataset. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| config : dict | ||
| ESMValTool's user configuration | ||
| dataset : str | ||
| Name of the dataset | ||
| dataset_info : dict | ||
| Dataset information from the datasets.yml file | ||
| start_date : datetime | ||
| Start of the interval to download | ||
| end_date : datetime | ||
| End of the interval to download | ||
| overwrite : bool | ||
| Overwrite already downloaded files | ||
| """ | ||
| downloader = WGetDownloader( | ||
| config=config, | ||
| dataset=dataset, | ||
| dataset_info=dataset_info, | ||
| overwrite=overwrite, | ||
| ) | ||
|
|
||
| os.makedirs(downloader.local_folder, exist_ok=True) | ||
|
|
||
| user = os.environ.get("rda-user") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Authentication methods may have changed on RDA, my login uses my orcid login, so this user, password wasn't working for me. But I commented out all the |
||
| if user is None: | ||
| user = str(input("RDA user name? ")) | ||
| if user == "": | ||
| errmsg = ("A RDA account is required to download JRA-55 data." | ||
| " Please visit https://rda.ucar.edu/login/register/" | ||
| " to create an account at the Research Data Archive" | ||
| " (RDA) if needed.") | ||
| logger.error(errmsg) | ||
| raise ValueError | ||
|
|
||
| passwd = os.environ.get("rda-passwd") | ||
| if passwd is None: | ||
| passwd = str(input("RDA password? ")) | ||
|
|
||
| if start_date is None: | ||
| start_date = datetime(1958, 1, 1) | ||
| if end_date is None: | ||
| end_date = datetime(2022, 12, 31) | ||
| loop_date = start_date | ||
|
|
||
| options = ["-O", "Authentication.log", "--save-cookies=auth.rda_ucar_edu", | ||
| f"--post-data=\"email={user}&passwd={passwd}&action=login\""] | ||
|
|
||
| # login to Research Data Archive (RDA) | ||
|
|
||
| downloader.login("https://rda.ucar.edu/cgi-bin/login", options) | ||
|
|
||
| # download files | ||
|
|
||
| url = "https://data.rda.ucar.edu/ds628.1" | ||
| download_options = ["--load-cookies=auth.rda_ucar_edu"] | ||
|
|
||
| # define variables to download | ||
|
|
||
| var = [["011_tmp", "anl_p125"], | ||
| ["011_tmp", "anl_surf125"], | ||
| ["039_vvel", "anl_p125"], | ||
| ["071_tcdc", "fcst_surf125"], | ||
| ["054_pwat", "fcst_column125"], | ||
| ["058_cice", "fcst_column125"], | ||
| ["160_csusf", "fcst_phy2m125"], | ||
| ["162_csulf", "fcst_phy2m125"], | ||
| ["211_uswrf", "fcst_phy2m125"], | ||
| ["212_ulwrf", "fcst_phy2m125"], | ||
| ["227_cw", "fcst_column125"], | ||
| ["228_clwc", "fcst_p125"], | ||
| ["229_ciwc", "fcst_p125"]] | ||
|
|
||
| # download data | ||
|
|
||
| while loop_date <= end_date: | ||
| year = loop_date.year | ||
|
|
||
| for item in var: | ||
| varname = item[0] | ||
| channel = item[1] | ||
| fname = f"{channel}.{varname}.{year}01_{year}12" | ||
| # download file | ||
| downloader.download_file(url + f"/{channel}/{year}/" + | ||
| fname, download_options) | ||
| # add file extension ".grb" | ||
| os.rename(downloader.local_folder + "/" + fname, | ||
| downloader.local_folder + "/" + fname + ".grb") | ||
|
|
||
| loop_date += relativedelta.relativedelta(years=1) | ||
|
|
||
| # clean up temporary files | ||
|
|
||
| if os.path.exists("Authentication.log"): | ||
| os.remove("Authentication.log") | ||
| if os.path.exists("auth.rda_ucar_edu"): | ||
| os.remove("auth.rda_ucar_edu") | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.