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

CMORizer for JRA-55 #3141

Merged
merged 22 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/sphinx/source/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ A list of the datasets for which a CMORizers is available is provided in the fol
+------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+
| JRA-25 | clt, hus, prw, rlut, rlutcs, rsut, rsutcs (Amon) | 2 | Python |
+------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+
| JRA-55 | cli, clivi, clw, clwvi, clt, prw, rlus, rlut, rlutcs, rsus, rsuscs, rsut, rsutcs, ta, tas, wap (Amon)| 2 | Python |
+------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+
| Kadow2020 | tasa (Amon) | 2 | Python |
+------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+
| LAI3g | lai (Lmon) | 3 | Python |
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
- gdal
- iris >=3.6.0
- iris-esmf-regrid >=0.7.0
- iris-grib
- jinja2
- joblib
- lime
Expand Down
1 change: 1 addition & 0 deletions environment_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
- gdal
- iris >=3.6.0
- iris-esmf-regrid >=0.7.0
- iris-grib
- jinja2
- joblib
- lime
Expand Down
103 changes: 103 additions & 0 deletions esmvaltool/cmorizers/data/cmor_config/JRA-55.yml
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:
alistairsellar marked this conversation as resolved.
Show resolved Hide resolved
cli:
short_name: cli
mip: Amon
file: fcst_p125.229_ciwc.*.grb

clivi:
short_name: clivi
mip: Amon
file: fcst_column125.058_cice.*.grb

clw:
short_name: clw
mip: Amon
file: fcst_p125.228_clwc.*.grb

clwvi:
short_name: clwvi
mip: Amon
operator: sum
files:
- 'fcst_column125.058_cice.*.grb'
- 'fcst_column125.227_cw.*.grb'

clt:
short_name: clt
mip: Amon
file: fcst_surf125.071_tcdc.*.grb

prw:
short_name: prw
mip: Amon
file: fcst_column125.054_pwat.*.grb

rlus:
short_name: rlus
mip: Amon
start_element: 0
file: fcst_phy2m125.212_ulwrf.*.grb

rlut:
short_name: rlut
mip: Amon
start_element: 1
file: fcst_phy2m125.212_ulwrf.*.grb

rlutcs:
short_name: rlutcs
mip: Amon
file: fcst_phy2m125.162_csulf.*.grb

rsus:
short_name: rsus
mip: Amon
start_element: 0
file: fcst_phy2m125.211_uswrf.*.grb

rsuscs:
short_name: rsuscs
mip: Amon
start_element: 0
file: fcst_phy2m125.160_csusf.*.grb

rsut:
short_name: rsut
mip: Amon
start_element: 1
file: fcst_phy2m125.211_uswrf.*.grb

rsutcs:
short_name: rsutcs
mip: Amon
start_element: 1
file: fcst_phy2m125.160_csusf.*.grb

ta:
short_name: ta
mip: Amon
file: anl_p125.011_tmp.*.grb

tas:
short_name: tas
mip: Amon
file: anl_surf125.011_tmp.*.grb

wap:
short_name: wap
mip: Amon
file: anl_p125.039_vvel.*.grb
9 changes: 9 additions & 0 deletions esmvaltool/cmorizers/data/datasets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,15 @@ datasets:
mon/atmos/rsut/rsut_Amon_reanalysis_JRA-25_197901-201312.nc
mon/atmos/rsutcs/rsutcs_Amon_reanalysis_JRA-25_197901-201312.nc

JRA-55:
tier: 2
source: https://rda.ucar.edu/datasets/ds628.1/
last_access: 2023-03-22
info: |
Create an account on the research data archive (RDA) in order to be able
to download the data (1.25 degree, pressure levels). See
https://rda.ucar.edu/login/register/ for more details.

Kadow2020:
tier: 2
source: http://users.met.fu-berlin.de/~ChristopherKadow/
Expand Down
115 changes: 115 additions & 0 deletions esmvaltool/cmorizers/data/downloaders/datasets/jra_55.py
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")
Copy link
Contributor

Choose a reason for hiding this comment

The 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 downloader.login() (lines 43-56, 64-69) stuff and was able to download fine on Gadi supercomputer.

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://rda.ucar.edu/data/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")
14 changes: 14 additions & 0 deletions esmvaltool/cmorizers/data/downloaders/wget.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ def download_file(self, server_path, wget_options):
logger.debug(command)
subprocess.check_output(command)

def login(self, server_path, wget_options):
"""Login.

Parameters
----------
server_path: str
Path to remote file
wget_options: list(str)
Extra options for wget
"""
command = ['wget'] + wget_options + [server_path]
logger.debug(command)
subprocess.check_output(command)

@property
def overwrite_options(self):
"""Get overwrite options as configured in downloader."""
Expand Down
Loading