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 CAMS cmorizer #3749

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -248,6 +248,8 @@ A list of the datasets for which a CMORizers is available is provided in the fol
+------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+
| CALIPSO-ICECLOUD | cli (AMon) | 3 | NCL |
+------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+
| CAMS | nbp (Lmon), fgco2 (Omon) | 3 | Python |
+------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+
| CDS-SATELLITE-ALBEDO | bdalb (Lmon), bhalb (Lmon) | 3 | Python |
+------------------------------+------------------------------------------------------------------------------------------------------+------+-----------------+
| CDS-SATELLITE-LAI-FAPAR | fapar (Lmon), lai (Lmon) | 3 | Python |
Expand Down
48 changes: 48 additions & 0 deletions esmvaltool/cmorizers/data/cmor_config/CAMS-EAC4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
# Common global attributes for Cmorizer output


# Input
filename: 'CAMS_EAC4_{variable}_{start_year}{end_year}.grib'
start_year: 2003
end_year: 2023
attributes:
dataset_id: CAMS-EAC4
version: 'v2024'
tier: 3
modeling_realm: reanaly
project_id: OBS6
source: "https://ads.atmosphere.copernicus.eu/datasets/cams-global-reanalysis-eac4-monthly?tab=overview"
reference: 'cams-eac4'
comment: ''

# Variables to cmorize
variables:
zg:
mip: Amon
varname: 'geopotential' # divide by g_0 = 9.80665 m/s-2
unit: 'm2 s-2' # to m
oh:
mip: Amon
varname: 'hydroxyl_radical'
unit: 'kg kg-1' # to mol mol-1
ch4:
mip: Amon
varname: 'methane_chemistry'
unit: 'kg kg-1' # to mol mol-1
co:
mip: Amon
varname: 'nitrogen_monoxide'
unit: 'kg kg-1' # to mol mol-1
o3:
mip: Amon
varname: 'ozone'
unit: 'kg kg-1' # to mol mol-1
hus:
mip: Amon
varname: 'specific humidity'
unit: 'kg kg-1' # 1
wap:
mip: Amon
varname: 'vertical velocity'
unit: 'Pa s-1'
40 changes: 40 additions & 0 deletions esmvaltool/cmorizers/data/cmor_config/CAMS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# Common global attributes for Cmorizer output


# Input
filename: 'cams73_v20r2_co2_flux_surface_mm_{year}{month}.nc'
start_year: 1979
end_year: 2020
attributes:
dataset_id: CAMS
version: 'v20r2' #'v20r1'
tier: 3
modeling_realm: reanaly
project_id: OBS6
source: "https://ads.atmosphere.copernicus.eu/cdsapp#!/dataset/cams-global-greenhouse-gas-inversion"
reference: 'cams'
comment: ''

# Variables to cmorize
variables:
nbp:
mip: Lmon
positive: down
varname: 'Posterior land surface upward mass flux of carbon for the whole grid box and the whole month without fossile'
fgco2:
mip: Omon
positive: down
varname: 'Posterior ocean surface upward mass flux of carbon for the whole grid box and the whole month without fossile'
areacella:
mip: fx
varname: area
areacello:
mip: Ofx
varname: area
sftlf:
mip: fx
varname: lsf
sftof:
mip: Ofx
varname: lsf
25 changes: 22 additions & 3 deletions esmvaltool/cmorizers/data/datasets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ datasets:
across Australia for each observed data variable. This accounts for spatial and temporal gaps in observations.
Where possible, the gridded analysis techniques provide useful estimates in data-sparse regions
such as central Australia.

Time coverage: Site-based data are used to provide gridded climate data at the monthly timescale for rainfall (1900+).
Reference: Evans, A., Jones, D.A., Smalley, R., and Lellyett, S. 2020. An enhanced gridded rainfall analysis scheme
for Australia. Bureau of Meteorology Research Report. No. 41.
Expand All @@ -33,11 +32,11 @@ datasets:
last_access: 2023-11-21
info: |
Data from NCI project requiring an NCI account and access to GADI

ANUClimate 2.0 consists of gridded daily and monthly climate variables across the terrestrial landmass of Australia
from at least 1970 to the present. Rainfall grids are generated from 1900 to the present. The underpinning spatial
models have been developed at the Fenner School of Environment and Society of the Australian National University.


APHRO-MA:
tier: 3
source: "http://aphrodite.st.hirosaki-u.ac.jp/download/"
Expand Down Expand Up @@ -110,6 +109,24 @@ datasets:
6) Follow download instructions in email from EarthData and put all
files in the same directory

CAMS:
tier: 3
source: https://ads.atmosphere.copernicus.eu/datasets/cams-global-greenhouse-gas-inversion?tab=overview
last_access: 2024-10-28
info: |
You will need to make an account with the CDS data store to download the data.
Then, select carbon dioxide, surface flux, surface air sample, monthly mean,
as well as the version and years you require to download.

CAMS-EAC4:
tier: 3
source: https://ads.atmosphere.copernicus.eu/datasets/cams-global-reanalysis-eac4-monthly?tab=overview
last_access: 2024-09-30
info: |
Requires ECMWF account for the Atmosphere Data Store.
Select your variables, as well as all pressure levels and download either
directly or using an API script.

CDS-SATELLITE-ALBEDO:
tier: 3
source: https://cds.climate.copernicus.eu/cdsapp#!/dataset/satellite-albedo?tab=form
Expand Down Expand Up @@ -888,7 +905,9 @@ datasets:

MERRA2:
tier: 3
source: https://goldsmr4.gesdisc.eosdis.nasa.gov/data/MERRA2_MONTHLY/ https://goldsmr5.gesdisc.eosdis.nasa.gov/data/MERRA2_MONTHLY/
source: |
https://goldsmr4.gesdisc.eosdis.nasa.gov/data/MERRA2_MONTHLY/
https://goldsmr5.gesdisc.eosdis.nasa.gov/data/MERRA2_MONTHLY/
last_access: 2022-09-13
info: |
Use automatic download. That will download monthly data but with
Expand Down
56 changes: 56 additions & 0 deletions esmvaltool/cmorizers/data/downloaders/datasets/cams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Script to download CAMS data from the Climate Data Store."""

import datetime

from dateutil import relativedelta

from esmvaltool.cmorizers.data.downloaders.cds import CDSDownloader
from esmvaltool.cmorizers.data.utilities import unpack_files_in_folder


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
"""
if start_date is None:
start_date = datetime.datetime(1979, 1, 1)
if end_date is None:
end_date = datetime.datetime(2020, 12, 1)
#end_date = datetime.datetime(2022, 12, 1)

downloader = CDSDownloader(
product_name='cams-global-greenhouse-gas-inversion',
request_dictionary={
'variable': 'carbon_dioxide',
'quantity': 'surface_flux',
'input_observations': 'surface',
'time_aggregation': 'monthly_mean',
'version': 'v20r2' #v22r2
},
config=config,
dataset=dataset,
dataset_info=dataset_info,
overwrite=overwrite,
)

loop_date = start_date
while loop_date <= end_date:
downloader.download(loop_date.year, loop_date.month, file_format='zip')
loop_date += relativedelta.relativedelta(months=1)

unpack_files_in_folder(downloader.local_folder)
68 changes: 68 additions & 0 deletions esmvaltool/cmorizers/data/downloaders/datasets/cams_eac4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""Script to download CAMS data from the Climate Data Store."""

import datetime

from esmvaltool.cmorizers.data.downloaders.cds import CDSDownloader


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
"""
if start_date is None:
start_date = datetime.datetime(2003, 1, 1)
if end_date is None:
end_date = datetime.datetime(2023, 12, 31)
# #end_date = datetime.datetime(2022, 12, 1)

variables = [
'geopotential', 'hydroxyl_radical', 'methane_chemistry', 'ozone',
'specific_humidity', 'vertical_velocity', 'nitrogen_monoxide'
]

for var in variables:

downloader = CDSDownloader(
product_name='cams-global-reanalysis-eac4-monthly',
request_dictionary={
'variable': [var],
'pressure_level': [
"1", "2", "3", "5", "7", "10", "20", "30", "50", "70",
"100", "150", "200", "250", "300", "400", "500", "600",
"700", "800", "850", "900", "925", "950", "1000"
],
"product_type": ["monthly_mean"],
"year": [
"2003", "2004", "2005", "2006", "2007", "2008", "2009",
"2010", "2011", "2012", "2013", "2014", "2015", "2016",
"2017", "2018", "2019", "2020", "2021", "2022", "2023"
],
"month": [
"01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
"11", "12"
],
"data_format":
'grib'
},
config=config,
dataset=dataset,
dataset_info=dataset_info,
overwrite=overwrite,
)

downloader.download_request(f"CAMS_EAC4_{var}_2003_2023.grib")
Loading