Validate API

Validation of RCMIP submissions

pyrcmip.validate.convert_units_to_rcmip_units(submission, protocol_variables)

Convert units to RCMIP units

Parameters
  • submission (scmdata.ScmRun) – Submission to convert

  • protocol_variables (pd.DataFrame) – Variables and units as defined by the RCMIP protocol

Returns

Submission with units converted to RCMIP units

Return type

scmdata.ScmRun

Raises

ProtocolConsistencyError – Units could not be converted to RCMIP units

pyrcmip.validate.validate_regions(regions_to_check, protocol_regions)

Validate regions against regions in the RCMIP protocol

Parameters
  • regions_to_check (list-like) – Regions to check

  • protocol_regions (list-like) – Regions in the RCMIP protocol

Raises

ProtocolConsistencyErrorregions_to_check contains regions not included in protocol_regions

pyrcmip.validate.validate_scenarios(scenarios_to_check, protocol_scenarios)

Validate scenarios against scenarios in the RCMIP protocol

Parameters
  • scenarios_to_check (list-like) – Scenarios to check

  • protocol_scenarios (list-like) – Scenarios in the RCMIP protocol

Raises

ProtocolConsistencyErrorscenarios_to_check contains scenarios not included in protocol_scenarios

pyrcmip.validate.validate_submission(submission, protocol=None)

Validate that an RCMIP submission complies with the required data format

Parameters
  • submission (scmdata.ScmRun) – Data to validate

  • protocol (str) – Data file containing the RCMIP protocol against which to validate the data. If None, the submission template will be loaded from pyrcmip/data/rcmip-data-submission-template-v4-0-0.xlsx.

Returns

Input data, converted to match RCMIP units

Return type

scmdata.ScmRun

Raises

ProtocolConsistencyError – The data is not consistent with the protocol

pyrcmip.validate.validate_submission_bundle(timeseries, model_reported, metadata, protocol=None)

Validate that an RCMIP submission bundle complies with the required formats

Parameters
  • timeseries (scmdata.ScmRun) – Timeseries to validate

  • model_reported (pd.DataFrame) – Model reported metrics

  • metadata (pd.DataFrame) – Model metadata

  • protocol (str) – Data file containing the RCMIP protocol against which to validate the timeseries. If None, the submission template will be loaded from pyrcmip/data/rcmip-data-submission-template-v4-0-0.xlsx.

Returns

Validated timeseries, model reported metrics and model metadata

Return type

(scmdata.ScmRun, pd.DataFrame, pd.DataFrame)

Raises
  • ProtocolConsistencyError – The submission bundle is not consistent with the RCMIP protocol

  • ValueError – A value for climate_model is found in timeseries or model_reported but isn’t found in the climate_model column of metadata.

pyrcmip.validate.validate_submission_model_meta(inp)

Validate a submission’s metadata

Parameters

inp (pd.DataFrame) – Metadata submission to validate

Returns

Validated metadata submission

Return type

pd.DataFrame

Raises

ProtocolConsistencyError – The columns of res are not as expected (i.e. {"climate_model", "climate_model_name", "climate_model_version", "climate_model_configuration_label", "climate_model_configuration_description", "project", "name_of_person", "literature_reference"}).

pyrcmip.validate.validate_submission_model_reported_metrics(inp)

Validate a submission of model reported metrics

Parameters

inp (pd.DataFrame) – Input to validate

Returns

Validated input

Return type

pd.DataFrame

Raises

ProtocolConsistencyError – The columns of res are not as expected (i.e. {"value", "ensemble_member", "RCMIP name", "unit", "climate_model"}), more than one climate model is included in res, the ensemble_member column is not integers, an unrecognised metric is provided or the provided unit is not compatible with RCMIP.

pyrcmip.validate.validate_variables(vars_to_check, protocol_variables)

Validate variables against variables in the RCMIP protocol

Parameters
  • vars_to_check (list-like) – Variables to check

  • protocol_variables (list-like) – Variables in the RCMIP protocol

Raises

ProtocolConsistencyErrorvars_to_check contains variables not included in protocol_variables