How to make the provenance record
def get_provenance_record(attributes, ancestor_files):
"""Create a provenance record describing the diagnostic data and plot."""
caption = ("Average {long_name} between {start_year} and {end_year} "
"according to {dataset}.".format(**attributes))
record = {
'caption': caption,
'statistics': ['mean'],
'domains': ['global'],
'plot_types': ['zonal'],
'authors': [
'unmaintained'
],
'references': [
'NICEST-2',
],
'ancestors': ancestor_files,
}
return record
in the main(cfg)
datasets = select_metadata(input_data, short_name='psl', activity='CMIP')
for dataset in datasets:
basename = 'cbf_' + Path(dataset['filename']).stem
provenance_record = get_provenance_record(
dataset, ancestor_files=[dataset['filename']])
save_data(basename, provenance_record, cfg, cbf)
or replace ESMValTool's save_data
explicitly with:
from esmvaltool.diag_scripts.shared import ProvenanceLogger
...
with ProvenanceLogger(cfg) as provenance_logger:
provenance_logger.log(filename, provenance_record)