climate_ref_esmvaltool.recipe
#
as_facets(group)
#
Convert a group from the datasets dataframe to ESMValTool facets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
DataFrame
|
A group of datasets representing a single instance_id. |
required |
Returns:
| Type | Description |
|---|---|
A :obj:`dict` containing facet-value pairs.
|
|
Source code in packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/recipe.py
as_isodate(timestamp)
#
Format a timestamp as an ISO 8601 datetime.
For example, '2014-12-16 12:00:00' will be formatted as '20141216T120000'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
Timestamp
|
The timestamp to format. |
required |
Source code in packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/recipe.py
as_timerange(group)
#
Format the timeranges from a dataframe as an ESMValTool timerange.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
DataFrame
|
The dataframe describing a single dataset. |
required |
Returns:
| Type | Description |
|---|---|
A timerange.
|
|
Source code in packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/recipe.py
dataframe_to_recipe(files, group_by=('instance_id',), equalize_timerange=False)
#
Convert the datasets dataframe to a recipe "variables" section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
DataFrame
|
The pandas dataframe describing the input files. |
required |
group_by
|
tuple[str, ...]
|
The columns to group the input files by. |
('instance_id',)
|
equalize_timerange
|
bool
|
If True, use the timerange that is covered by all datasets. |
False
|
Returns:
| Type | Description |
|---|---|
A "variables" section that can be used in an ESMValTool recipe.
|
|
Source code in packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/recipe.py
fix_annual_statistics_keep_year(recipe)
#
Add keep_group_coordinates: true to every annual_statistics step.
ESMValCore changed annual_statistics to remove the year
coordinate by default (keep_group_coordinates=False). Several
ESMValTool diagnostic scripts still rely on the coordinate being
present, so we patch the recipe to preserve it.
Remove this workaround once ESMValCore restores the old default or the affected diagnostic scripts are updated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe
|
Recipe
|
The recipe to update in place. |
required |
Source code in packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/recipe.py
get_child_and_parent_dataset(df, parent_experiment, child_duration_in_years, parent_offset_in_years, parent_duration_in_years)
#
Retrieve the child and parent dataset in recipe format from a dataframe.
Source code in packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/recipe.py
load_recipe(recipe)
#
Load a recipe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe
|
str
|
The name of an ESMValTool recipe. |
required |
Returns:
| Type | Description |
|---|---|
The loaded recipe.
|
|
Source code in packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/recipe.py
prepare_climate_data(datasets, climate_data_dir)
#
Symlink the input files from the Pandas dataframe into a directory tree.
This ensures that ESMValTool can find the data and only uses the requested data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
DataFrame
|
The pandas dataframe describing the input datasets. |
required |
climate_data_dir
|
Path
|
The directory where ESMValTool should look for input data. |
required |
Source code in packages/climate-ref-esmvaltool/src/climate_ref_esmvaltool/recipe.py
rewrite_mip_for_cmip7(recipe)
#
Rewrite CMIP6 MIP table names to CMIP7 realm names in a recipe.
Base ESMValTool recipes have CMIP6 MIP table names (e.g. Amon,
Lmon) hardcoded in the diagnostics/variables section. When the recipe
uses CMIP7 data, these must be rewritten to CMIP7 realm names
(e.g. atmos, land).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe
|
Recipe
|
The recipe to update in place. |
required |