Metric Calculations API

Metric calculations used in RCMIP

class pyrcmip.metric_calculations.CalculatorAirborneFraction18501920

Bases: Calculator

Calculator of the airborne fraction from 1850 to 1920

classmethod calculate_metric(assessed_ranges, res_calc, norm_period, evaluation_period, unit)

Calculate metric

Parameters:
  • assessed_ranges (pyrcmip.assessed_ranges.AssessedRanges) – Assessed ranges instance

  • res_calc (scmdata.ScmRun) – Results from which the metric is to be derived

  • norm_period (list) – Years to use for normalising the data before calculating the metric

  • evaluation_period (list) – Years to use when evaluating the metric

  • unit (str) – Unit in which the metric should be returned

Returns:

Metric values with other relevant model metadata

Return type:

pd.DataFrame

Raises:
  • NoDataForMetricError – No data is available to calculate the given metric

  • DimensionalityError – The units of the data cannot be converted to the desired units or the units of the data are incompatible with the metric calculation

classmethod can_calculate_metric(metric)

Decide whether the input metric can be calculated or not

Parameters:

metric (str) – Metric to check

Returns:

If True, the metric can be calculated. Otherwise, it cannot.

Return type:

bool

class pyrcmip.metric_calculations.CalculatorAirborneFraction18501990

Bases: CalculatorAirborneFraction18501920

Calculator of the airborne fraction from 1850 to 1990

classmethod calculate_metric(assessed_ranges, res_calc, norm_period, evaluation_period, unit)

Calculate metric

Parameters:
  • assessed_ranges (pyrcmip.assessed_ranges.AssessedRanges) – Assessed ranges instance

  • res_calc (scmdata.ScmRun) – Results from which the metric is to be derived

  • norm_period (list) – Years to use for normalising the data before calculating the metric

  • evaluation_period (list) – Years to use when evaluating the metric

  • unit (str) – Unit in which the metric should be returned

Returns:

Metric values with other relevant model metadata

Return type:

pd.DataFrame

Raises:
  • NoDataForMetricError – No data is available to calculate the given metric

  • DimensionalityError – The units of the data cannot be converted to the desired units or the units of the data are incompatible with the metric calculation

classmethod can_calculate_metric(metric)

Decide whether the input metric can be calculated or not

Parameters:

metric (str) – Metric to check

Returns:

If True, the metric can be calculated. Otherwise, it cannot.

Return type:

bool

class pyrcmip.metric_calculations.CalculatorTCR

Bases: _CalculatorTCRTCREBase

Calculator of the transient climate response (TCR)

classmethod calculate_metric(assessed_ranges, res_calc, norm_period, evaluation_period, unit)

Calculate metric

Parameters:
  • assessed_ranges (pyrcmip.assessed_ranges.AssessedRanges) – Assessed ranges instance

  • res_calc (scmdata.ScmRun) – Results from which the metric is to be derived

  • norm_period (list) – Years to use for normalising the data before calculating the metric

  • evaluation_period (list) – Years to use when evaluating the metric

  • unit (str) – Unit in which the metric should be returned

Returns:

Metric values with other relevant model metadata

Return type:

pd.DataFrame

Raises:
  • NoDataForMetricError – No data is available to calculate the given metric

  • DimensionalityError – The units of the data cannot be converted to the desired units or the units of the data are incompatible with the metric calculation

classmethod can_calculate_metric(metric)

Decide whether the input metric can be calculated or not

Parameters:

metric (str) – Metric to check

Returns:

If True, the metric can be calculated. Otherwise, it cannot.

Return type:

bool

class pyrcmip.metric_calculations.CalculatorTCRE

Bases: _CalculatorTCRTCREBase

Calculator of the transient climate response to emissions (TCRE)

classmethod calculate_metric(assessed_ranges, res_calc, norm_period, evaluation_period, unit)

Calculate metric

Parameters:
  • assessed_ranges (pyrcmip.assessed_ranges.AssessedRanges) – Assessed ranges instance

  • res_calc (scmdata.ScmRun) – Results from which the metric is to be derived

  • norm_period (list) – Years to use for normalising the data before calculating the metric

  • evaluation_period (list) – Years to use when evaluating the metric

  • unit (str) – Unit in which the metric should be returned

Returns:

Metric values with other relevant model metadata

Return type:

pd.DataFrame

Raises:
  • NoDataForMetricError – No data is available to calculate the given metric

  • DimensionalityError – The units of the data cannot be converted to the desired units or the units of the data are incompatible with the metric calculation

classmethod can_calculate_metric(metric)

Decide whether the input metric can be calculated or not

Parameters:

metric (str) – Metric to check

Returns:

If True, the metric can be calculated. Otherwise, it cannot.

Return type:

bool

Base class for metric calculations

class pyrcmip.metric_calculations.base.Calculator

Bases: ABC

Base class for metric calculations

classmethod calculate_metric(assessed_ranges, res_calc, norm_period, evaluation_period, unit)

Calculate metric

Parameters:
  • assessed_ranges (pyrcmip.assessed_ranges.AssessedRanges) – Assessed ranges instance

  • res_calc (scmdata.ScmRun) – Results from which the metric is to be derived

  • norm_period (list) – Years to use for normalising the data before calculating the metric

  • evaluation_period (list) – Years to use when evaluating the metric

  • unit (str) – Unit in which the metric should be returned

Returns:

Metric values with other relevant model metadata

Return type:

pd.DataFrame

Raises:
  • NoDataForMetricError – No data is available to calculate the given metric

  • DimensionalityError – The units of the data cannot be converted to the desired units or the units of the data are incompatible with the metric calculation

classmethod can_calculate_metric(metric)

Decide whether the input metric can be calculated or not

Parameters:

metric (str) – Metric to check

Returns:

If True, the metric can be calculated. Otherwise, it cannot.

Return type:

bool