Fabian Wachsmann
Scientific programmer in the joint research project DICAD at DKRZ Developer of Climate Data Operators (CDO)
state of affairs and examples
Make data easy to analyze
CMOR
Convention (1 and 2) about climate data accepted in Coupled Model Inter-comparison Project
Collection of operators to process climate data
Climate Model Output Rewrite to ensure correct conversion
'cdo cmor'
Motivation
Definitions
MIP-
table
cdo cmor,cmip6_mip_tables_325/CMIP6_Amon.json example_interface.nc
cdo cmor,cmip6_mip_tables_325/CMIP6_Amon.json,cn=tas example_interface.nc
A CMOR-variable is the unique combination of the cmor_name and the corresponding MIP-table which includes the cmor_name
A Controlled Vocabulary (CV) is a special MIP-table and defines and restricts the required global attribute set for the output file
Data request (dreq)
MIP-tables and CV
CMOR
CDO
CMOR2
CMOR3
Use the CDO installation which uses the CMOR Version suitable to create the data standard of your project
Instructions
Recommendations
Recent challenges
Progress
#connect to mistral
ssh -X <usernr>@mistral.dkrz.de
#create workdir
mkdir cdocmor_handson
cd cdocmor_handson
#copy examples directory
cdoDir=/work/bm0021/cdo_incl_cmor/
cp -r ${cdoDir}examples ./
cd examples
#link cdo cmor installation
alias cdo=${cdoDir}cdo_handson_cmor3
Preparation
#**General usage:
#cdo cmor,MIP-table[,keyvaluelist] infile
#**The keyvaluelist is of format
#key=value[,value]
#**Some keywords only allow exactly one value.
#**Others allow a comma separated list (CSL) of values.
#**If the input file is of netCDF format and contains all required meta data,
#**it can be sufficient to call:
#cdo cmor,MIP-table infile
#**example:
cdo cmor,cmip6_mip_tables_325/CMIP6_Amon.json example_interface.nc
#**Parameter one MUST be the MIP table
#**It can be specified with a relative or absoulte path
Usage
#example:
cdo cmor,cmip6_mip_tables_325/CMIP6_Amon.json example_interface.nc
Usage
The outfile is generated by CMOR and must not be specified.
Name and path of the outfile are generated according to templates defined by the corresponding project:
Filename | Filepath | |
---|---|---|
CMOR2 |
|
|
CMOR3 |
|
<variable_id>_<table_id>_
<source_id>_<experiment_id>_
<variant_label>_<grid_label>
<variable_id>_<table_id>_
<model_id>_<experiment_id>_
<member>
<activity_id>/<product>/<institute_id>/
<model_id>/<experiment_id>/<frequency>/
<realm>/<variable_id>/<member>
<mip_er>/<activity_id>/<institution_id>/<source_id>/
<experiment_id>/<variant_label>/<table_id>/
<variable_id>/<grid_label>/<version>
#example:
cdo cmor,cmip6_mip_tables_325/CMIP6_Amon.json example_interface.nc
First steps
#example:
#select tas from infile
cdo cmor,cmip6_mip_tables_325/CMIP6_Amon.json,cn=tas example_interface.nc
#select tas and uas from infile
cdo cmor,cmip6_mip_tables_325/CMIP6_Amon.json,cn=tas,uas example_interface.nc
Keyword cmor_name selects a subset of variables to be processed
#example:
cdo cmor,cmip6_mip_tables_325/CMIP6_Amon.json example_interface.nc
First steps
~/cdo-git/src/cdo cmor,Amon example_interface.nc
cdo cmor: (2.2.) Start to find a MIP table file.
cdo cmor: Is 'Amon' a valid 'MIP table' file?
Empty file: 'Amon'.
cdo cmor: Try to build a path with additional configuration attributes:
'mip_table_dir' and 'project_id'
in order to use 'Amon' as MIP-table.
cdo cmor: (2.2.) MIP table file 'cmip6_mip_tables_328//CMIP6_Amon.json' exists.
cdo cmor: Function 'attribute check, compare and set':
Be aware of differences between infile and user specification.
Attribute 'time_units' in input file: 'days since 1850-1-16 12:00:00' does not agree with user specification 'days since 1850-1-1 00:00:00'.
Cmor library is called with 'days since 1850-1-1 00:00:00'.
cdo cmor: Function 'all axes registration':
You have not requested a particular variable via 'cmor_name'.
There are several in infile and all will be processed.
Notice that attributes specified in the cmdline will be used for all infile variables.
cdo cmor: Vertical axis is either default and scalar or not available.
cdo cmor: Vertical axis is either default and scalar or not available.
cdo cmor: File stored in: './/CMIP6/CMIP/MPI-M/MPI-ESM-1-2-HR/historical/r1i1p1f1/Amon/uas/gn/v20180116/uas_Amon_MPI-ESM-1-2-HR_historical_r1i1p1f1_gn_185001-185012.nc' with cmor!
cdo cmor: File stored in: './/CMIP6/CMIP/MPI-M/MPI-ESM-1-2-HR/historical/r1i1p1f1/Amon/tas/gn/v20180116/tas_Amon_MPI-ESM-1-2-HR_historical_r1i1p1f1_gn_185001-185012.nc' with cmor!
cdo cmor: Processed 1769472 values from 8 variables over 12 timesteps ( 1.06s 1044MB )
#The usual CDO options are valid for this operator as well:
#cdo cmor can be called in silent (-s) or verbose (-v) mode.
#The verbose mode is recommended if the processing is unclear:
cdo -v cmor,cmip6_mip_tables_325/CMIP6_Amon.json example_interface.nc
cdo -s cmor,cmip6_mip_tables_325/CMIP6_Amon.json example_interface.nc
#In many cases, operator chaining can be helpful:
cdo -cmor,cmip6_mip_tables_325/CMIP6_Amon.json -addc,10 example_interface.nc
First steps
Configuration and data streams
Infile
CDO
CMOR
Outfile
replace
append
variables (attributes)
coordinates (attributes)
global
(attributes)
mapping
table
grid info
file
info
table
MIP-
table
CV
predefinitons
user setting
data stream
cdo
cmor
mapping
table
grid info
file
info
table
MIP-
table
infile
md
data
new file
md
data
old file
md
data
command
replace
append
line
metadata stream
data stream
info table and global attributes
Infile
CDO
CMOR
Outfile
replace
append
global
(attributes)
info
table
global
(attributes)
Info table format conventions are:
info_table.txt
#control keywords:
mip_table_dir="cmip6_mip_tables/"
#required global attributes:activity_id="CMIP"
experiment="AMIP"
experiment_id="amip"
forcing_index="1"
grid="All grid attributes are set for the native grid and based on information from attribute source."
grid_label="gn"
initialization_index="1"
institution="Max Planck Institute for Meteorology, Hamburg 20146, Germany"
institution_id="MPI-M"
license="CMIP6 model data produced by REQUIRED is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file) and. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law."
mip_era="CMIP6"
nominal_resolution="100 km"
physics_index="1"
realization_index="1"
source="MPIESM1.2-HR (2017): \naerosol: none, prescribed MACv2-SP\natmos: ECHAM6.3 (spectral T127; 384 x 192 longitude/latitude; 95 levels; top level 0.01 hPa)\natmosChem: none\nland: JSBACH3.2\nlandIce: none/prescribed\nocean: MPIOM1.63 (tripolar TP04, approximately 0.4deg; 900 x 450 longitude/latitude; 40 levels; top grid cell 0-12 m)\nocnBgchem: HAMOCC\nseaIce: unnamed (thermodynamic (Semtner zero-layer) dynamic (Hibler 79) sea ice model)"
source_id="MPIESM-1-2-HR"
source_type="AGCM"
sub_experiment="none"
sub_experiment_id="none"
parent_activity_id="no parent"
parent_experiment_id="no parent"
calendar="proleptic_gregorian"
required_time_units="days since REQUIRED"
info
table
Info tables
global
(attributes)
A tool to create an info table is provided at
info
table
Infile
CDO
CMOR
Outfile
replace
append
variables (attributes)
predefinitons
user setting
data stream
variable mapping
mapping
table
Infile
variables (attributes)
mapping_
table.txt
¶meter cmor_name=tasmax code=201 units="K" cell_methods="m" project_mip_table=Amon /
¶meter cmor_name=tasmax code=201 units="K" cell_methods="m" project_mip_table=day /
¶meter cmor_name=tasmin code=202 units="K" cell_methods="m" project_mip_table=day /
¶meter cmor_name=tasmin code=202 units="K" cell_methods="m" project_mip_table=Amon /
¶meter cmor_name=rsds units="W m-2" cell_methods="m" positive="d" /
¶meter cmor_name=rlds units="W m-2" cell_methods="m" positive="d" /
A Mapping table
Each line should contain
mapping
table
Infile
variables (attributes)
mapping
table
If the source variable of a target cmor variable in infile features wrong or no variable attributes at all, its attributes can be provided and overwritten via the command line or via a mapping table.
Variable attributes specifications can be combined. The priority order is:
The mapping table can include mapping for all target variables. If a mapping table is provided, cmor names and the MIP-table specified in the command line are used to find a matching mapping table line. Subsequently, a corresponding mapping table line provides the infile variable selector.
Infile
variables (attributes)
Keyword | Short name | Value format | Default |
---|---|---|---|
project_mip_table | pmt | MT name substring | |
name | n | Word | |
code | c | Three digits integer. GRIB code. | |
units | u | String. Must be readable by udunits. | |
cell_methods | cm | Character (see below) | m |
positive | p | u=upward, d=downward | |
variable_comment | vc | String |
Five valid time cell methods can be specified. It is used to choose the correct time axis.
mapping
table
A tool to create an mappping table is provided at
Infile
CDO
CMOR
Outfile
replace
append
coordinates (attributes)
coordinates and grid info file
grid info
file
coordinates (attributes)
grid info
file
"latitude": {
"standard_name": "latitude",
"units": "degrees_north",
"axis": "Y",
"long_name": "latitude",
"climatology": "",
"formula": "",
"must_have_bounds": "yes",
"out_name": "lat",
"positive": "",
"requested": "",
"requested_bounds": "",
"stored_direction": "increasing",
"tolerance": "",
"type": "double",
"valid_max": "90.0",
"valid_min": "-90.0",
"value": "",
"z_bounds_factors": "",
"z_factors": "",
"bounds_values": ""
}
"tas": {
"frequency": "mon",
"modeling_realm": "atmos",
"standard_name": "air_temperature",
"units": "K",
"cell_methods": "area: time: mean",
"cell_measures": "area: areacella",
"long_name": "Near-Surface Air Temperature",
"comment": "near-surface (usually, 2 meter) air temperature",
"dimensions": "longitude latitude time height2m",
"out_name": "tas",
"type": "real",
"positive": "",
"valid_min": "",
"valid_max": "",
"ok_min_mean_abs": "",
"ok_max_mean_abs": ""
}
coordinates (attributes)
grid info
file
grid_
info.nc
ncdump -h example_gridinfo_CCLM4-8-17.nc
netcdf example_gridinfo_CCLM4-8-17 {
dimensions:
rlon = 424 ;
rlat = 412 ;
vertices = 4 ;
time = UNLIMITED ; // (1 currently)
bnds = 2 ;
variables:
double lon(rlat, rlon) ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
lon:_CoordinateAxisType = "Lon" ;
lon:bounds = "lon_bnds" ;
double lon_bnds(rlat, rlon, vertices) ;
double lat(rlat, rlon) ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
lat:_CoordinateAxisType = "Lat" ;
lat:bounds = "lat_bnds" ;
double lat_bnds(rlat, rlon, vertices) ;
double rlon(rlon) ;
rlon:standard_name = "grid_longitude" ;
rlon:long_name = "longitude in rotated pole grid" ;
rlon:units = "degrees" ;
rlon:axis = "X" ;
double rlat(rlat) ;
rlat:standard_name = "grid_latitude" ;
rlat:long_name = "latitude in rotated pole grid" ;
rlat:units = "degrees" ;
rlat:axis = "Y" ;
int rotated_pole ;
rotated_pole:grid_north_pole_latitude = 39.25 ;
rotated_pole:grid_north_pole_longitude = -162. ;
rotated_pole:grid_mapping_name = "rotated_latitude_longitude" ;
double height ;
height:standard_name = "height" ;
height:long_name = "height" ;
height:units = "m" ;
height:positive = "up" ;
height:axis = "Z" ;
double time(time) ;
time:standard_name = "time" ;
time:long_name = "time" ;
time:bounds = "time_bnds" ;
time:units = "days since 1949-12-01 00:00:00" ;
time:calendar = "365_day" ;
time:axis = "T" ;
double time_bnds(time, bnds) ;
float tas(time, rlat, rlon) ;
tas:standard_name = "air_temperature" ;
tas:long_name = "Near-Surface Air Temperature" ;
tas:units = "K" ;
tas:grid_mapping = "rotated_pole" ;
tas:coordinates = "height lat lon" ;
tas:_FillValue = 1.e+20f ;
tas:missing_value = 1.e+20f ;
tas:cell_methods = "time: mean" ;
}
Infile
CDO
CMOR
Outfile
replace
append
predefinitons
user setting
data stream
output control
1851
1852
1850
CMOR
1850_post
1851_post
1852_post
tas_
185001_185012.nc
tas_
185001_185112.nc
tas_
185001_185212.nc
model simulation year |
Postprocessing skript |
CMIP6 compliant example variable |
Workflow
Function | Name | Short name | Necessary information (M: mandatory, R: If required, D: Default, W: Works without) | Format and description. CV: Value must be in Controlled Vocabulary. CV restricted: Format of value is restricted by Controlled Vocabulary | Default |
---|---|---|---|---|---|
CMOR variable selector in mapping table | project_mip_table | pmt | W | Substring of the MIP-table name | |
Coordinate keyword | calendar | D | Word, 5 options. | standard' | |
Coordinate keyword | climatology_interval | R | Two integers: “%d,%d“ | ||
Coordinate keyword | leap_year | R | |||
Coordinate keyword | leap_month | R | |||
Coordinate keyword | req_time_units | M | "$units since $year-$month-$day $hours:$minutes:$seconds" | ||
Coordinate keyword | time_bounds | D | Either „c“ for create or „i“ for infile | i | |
Filename keyword | grid_info | gi | W | Filename. Grid of a netCDF file must fit to infile variable dimensions | |
Filename keyword | grid_info_dir | W | Filepath | ||
Filename keyword | info | i | D | CSV of filenames. | ".cdocmorinfo" in the current working directory |
Filename keyword | mapping_table | mt | W | Filename | |
Filename keyword | mapping_table_dir | W | Filepath | ||
Filename keyword | mip_table_dir | W | Filepath | ||
Mapping keyword | cell_methods | cm | D | Character, 5 options | m |
Mapping keyword | character_axis | ca | R | Cmor axis label | |
Mapping keyword | positive | p | R | d for downward, u for upward or blank for undirected | |
Mapping keyword | units | u | M | String, must be readable by udunits | |
Mapping keyword | variable_comment | vc | W | String | |
Mapping keyword | z_axis | za | R | Cmor axis label | |
Output control keyword | drs | d | D | y' for building a DRS and 'n' for not building a DRS | y |
Output control keyword | drs_root | dr | D | Filepath to where DRS will be built | ./ |
Output control keyword | last_chunk | lc | W | CSV of filenames | |
Output control keyword | max_size | ms | D | Unit: Gb | 2 |
Output control keyword | output_mode | om | D | r for replace or a for append | a |
Variable selector keyword | cmor_name | cn | M | CSV. Value must be in MIP-table. | |
Variable selector keyword | code | c | W | Three digits Intege. GRIB-cod. | |
Variable selector keyword | name | n | W | Word |
By Fabian Wachsmann
Explore the advantages of CDO, CMOR and cdo cmor. Learn the basic application of the operator.
Scientific programmer in the joint research project DICAD at DKRZ Developer of Climate Data Operators (CDO)