Skip to content
Merged
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
1 change: 1 addition & 0 deletions changelog/540.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed fire diagnostic CMIP7 data selection and recipe writing.
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,14 @@ class ClimateDriversForFire(ESMValToolDiagnostic):
"branded_variable": (
"cVeg_tavg-u-hxy-lnd",
"treeFrac_tavg-u-hxy-u",
"vegFrac_tavg-u-hxy-u",
),
"experiment_id": "historical",
"frequency": "mon",
"region": "glb",
"realm": "land",
}
),
FacetFilter(
{
"branded_variable": "vegFrac_tavg-u-hxy-u",
"experiment_id": "historical",
"frequency": "mon",
"region": "glb",
"realm": "land",
}
),
),
group_by=("source_id", "variant_label", "grid_label"),
constraints=(
Expand All @@ -125,16 +117,16 @@ class ClimateDriversForFire(ESMValToolDiagnostic):
),
AddSupplementaryDataset.from_defaults("sftlf", SourceDatasetType.CMIP7),
RequireFacets(
"variable_id",
"branded_variable",
(
"cVeg",
"hurs",
"pr",
"tas",
"tasmax",
"sftlf",
"treeFrac",
"vegFrac",
"cVeg_tavg-u-hxy-lnd",
"hurs_tavg-h2m-hxy-u",
"pr_tavg-u-hxy-u",
"sftlf_ti-u-hxy-u",
"tas_tavg-h2m-hxy-u",
"tas_tmaxavg-h2m-hxy-u",
"treeFrac_tavg-u-hxy-u",
"vegFrac_tavg-u-hxy-u",
),
),
),
Expand Down Expand Up @@ -234,27 +226,27 @@ def update_recipe(
"""Update the recipe."""
cmip_source = get_cmip_source_type(input_files)
recipe_variables = dataframe_to_recipe(input_files[cmip_source])
recipe.pop("datasets")
for diagnostic in recipe["diagnostics"].values():
for variable_group, variable in diagnostic.get("variables", {}).items():
cmip6_short_name = variable.get("short_name", variable_group)
if cmip_source == SourceDatasetType.CMIP7 and cmip6_short_name == "tasmax":
short_name = "tas"
else:
short_name = cmip6_short_name
variable["short_name"] = short_name
variable["start_year"] = 2013
variable["end_year"] = 2014
datasets = recipe_variables[short_name]["additional_datasets"]
for dataset in datasets:
dataset.pop("timerange", None)
if cmip_source == SourceDatasetType.CMIP7 and short_name == "tas":
# Separate the two "tas" datasets into "tas" and "tasmax".
if cmip6_short_name == "tasmax":
datasets = [d for d in datasets if d["branding_suffix"] == "tmaxavg-h2m-hxy-u"]
else:
datasets = [d for d in datasets if d["branding_suffix"] == "tavg-h2m-hxy-u"]

if cmip_source == SourceDatasetType.CMIP7:
# CMIP7: use per-variable additional_datasets to preserve correct branding_suffix
recipe["datasets"] = []
for diagnostic in recipe["diagnostics"].values():
for var_name, variable in diagnostic.get("variables", {}).items():
short_name = variable.get("short_name", var_name)
if short_name in recipe_variables:
datasets = recipe_variables[short_name]["additional_datasets"]
for ds in datasets:
ds.pop("mip", None)
ds.pop("timerange", None)
ds["start_year"] = 2013
ds["end_year"] = 2014
variable["additional_datasets"] = datasets
else:
dataset = recipe_variables["cVeg"]["additional_datasets"][0]
dataset.pop("mip")
dataset.pop("timerange")
dataset["start_year"] = 2013
dataset["end_year"] = 2014
recipe["datasets"] = [dataset]
variable["additional_datasets"] = datasets

recipe["diagnostics"]["fire_evaluation"]["scripts"]["fire_evaluation"]["remove_confire_files"] = True
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ documentation:
- kelley_douglas
maintainer:
- lenhardt_julien
datasets:
- project: CMIP6
activity: CMIP
dataset: ACCESS-ESM1-5
ensemble: r1i1p1f1
institute: CSIRO
exp: historical
grid: gn
start_year: 2013
end_year: 2014
preprocessors:
preproc:
regrid:
Expand All @@ -44,24 +34,108 @@ diagnostics:
pr:
mip: Amon
preprocessor: preproc
short_name: pr
start_year: 2013
end_year: 2014
additional_datasets:
- project: CMIP6
activity: CMIP
dataset: ACCESS-ESM1-5
ensemble: r1i1p1f1
institute: CSIRO
exp: historical
grid: gn
mip: Amon
tasmax:
mip: Amon
preprocessor: preproc
short_name: tasmax
start_year: 2013
end_year: 2014
additional_datasets:
- project: CMIP6
activity: CMIP
dataset: ACCESS-ESM1-5
ensemble: r1i1p1f1
institute: CSIRO
exp: historical
grid: gn
mip: Amon
treeFrac:
mip: Lmon
preprocessor: preproc_fraction
short_name: treeFrac
start_year: 2013
end_year: 2014
additional_datasets:
- project: CMIP6
activity: CMIP
dataset: ACCESS-ESM1-5
ensemble: r1i1p1f1
institute: CSIRO
exp: historical
grid: gn
mip: Lmon
vegFrac:
mip: Emon
preprocessor: preproc_fraction
short_name: vegFrac
start_year: 2013
end_year: 2014
additional_datasets:
- project: CMIP6
activity: CMIP
dataset: ACCESS-ESM1-5
ensemble: r1i1p1f1
institute: CSIRO
exp: historical
grid: gn
mip: Emon
cVeg:
mip: Lmon
preprocessor: preproc
short_name: cVeg
start_year: 2013
end_year: 2014
additional_datasets:
- project: CMIP6
activity: CMIP
dataset: ACCESS-ESM1-5
ensemble: r1i1p1f1
institute: CSIRO
exp: historical
grid: gn
mip: Lmon
tas:
mip: Amon
preprocessor: preproc
short_name: tas
start_year: 2013
end_year: 2014
additional_datasets:
- project: CMIP6
activity: CMIP
dataset: ACCESS-ESM1-5
ensemble: r1i1p1f1
institute: CSIRO
exp: historical
grid: gn
mip: Amon
hurs:
mip: Amon
preprocessor: preproc
short_name: hurs
start_year: 2013
end_year: 2014
additional_datasets:
- project: CMIP6
activity: CMIP
dataset: ACCESS-ESM1-5
ensemble: r1i1p1f1
institute: CSIRO
exp: historical
grid: gn
mip: Amon
scripts:
fire_evaluation:
script: fire/fire_diagnostic.py
Expand Down