Normalisation API

Normalisation handling

Within netCDF-SCM, ‘normalisation’ refers to taking anomalies from some set of reference values. For example, subtracting a 21-year running mean from a pre-industrial control experiment from the results of a projection experiment.

netcdf_scm.normalisation.get_normaliser(key)[source]

Get the appropriate normaliser for a given key

Parameters

key (str) – Key which specifies the type of normaliser to get

Returns

Normaliser appropriate for key

Return type

netcdf_scm.normalisation.base.Normaliser

Raises

ValueErrorkey cannot be mapped to a known normaliser

Base API

Base class for normalisation operations

class netcdf_scm.normalisation.base.Normaliser[source]

Bases: abc.ABC

Base class for normalising operations

get_reference_values(indata, picontrol, picontrol_branching_time)[source]

Get reference values for an experiment from its equivalent piControl experiment

Parameters
  • indata (scmdata.ScmRun) – Experiment to calculate reference values for

  • picontrol (scmdata.ScmRun) – Pre-industrial control run data

  • picontrol_branching_time (datetime.datetime) – The branching time in the pre-industrial experiment. It is assumed that the first timepoint in input follows immediately from this branching time.

Returns

Reference values with the same index and columns as indata

Return type

pd.DataFrame

Raises
method_name

Name of the method used for normalisation

This string is included in the metadata of normalised data/files.

Type

str

normalise_against_picontrol(indata, picontrol, picontrol_branching_time)[source]

Normalise data against picontrol

Parameters
  • indata (scmdata.ScmRun) – Data to normalise

  • picontrol (scmdata.ScmRun) – Pre-industrial control run data

  • picontrol_branching_time (datetime.datetime) – The branching time in the pre-industrial experiment. It is assumed that the first timepoint in input follows immediately from this branching time.

Returns

Normalised data including metadata about the file which was used for normalisation and the normalisation method

Return type

scmdata.ScmRun

Raises

After branch time mean API

Module for the normaliser which calculates anomalies from a mean of a fixed number of years in the pre-industrial control run

class netcdf_scm.normalisation.after_branch_time_mean.AfterBranchTimeMean[source]

Bases: netcdf_scm.normalisation.base.Normaliser

Normaliser which calculates anomalies from a mean of a fixed number of years after the branch time in the pre-industrial control run

At present, only a 31-year mean after the branch time is implemented.

get_reference_values(indata, picontrol, picontrol_branching_time)

Get reference values for an experiment from its equivalent piControl experiment

Parameters
  • indata (scmdata.ScmRun) – Experiment to calculate reference values for

  • picontrol (scmdata.ScmRun) – Pre-industrial control run data

  • picontrol_branching_time (datetime.datetime) – The branching time in the pre-industrial experiment. It is assumed that the first timepoint in input follows immediately from this branching time.

Returns

Reference values with the same index and columns as indata

Return type

pd.DataFrame

Raises
method_name

Name of the method used for normalisation

This string is included in the metadata of normalised data/files.

Type

str

normalise_against_picontrol(indata, picontrol, picontrol_branching_time)

Normalise data against picontrol

Parameters
  • indata (scmdata.ScmRun) – Data to normalise

  • picontrol (scmdata.ScmRun) – Pre-industrial control run data

  • picontrol_branching_time (datetime.datetime) – The branching time in the pre-industrial experiment. It is assumed that the first timepoint in input follows immediately from this branching time.

Returns

Normalised data including metadata about the file which was used for normalisation and the normalisation method

Return type

scmdata.ScmRun

Raises

Running mean API

Module for the normaliser which calculates anomalies from a running mean in the pre-industrial control run

class netcdf_scm.normalisation.running_mean.NormaliserRunningMean(nyears=21)[source]

Bases: netcdf_scm.normalisation.base.Normaliser

Normaliser which calculates anomalies from a running mean in the pre-industrial control run

Each normalisation value is an n-year mean, centred on the equivalent point in the pre-industrial control simulation. If there is insufficient data to create a full n-year window at the edge of the simulation then a linear extrapolation of the running-mean is used to extend the normalisation values to cover the required full range.

get_reference_values(indata, picontrol, picontrol_branching_time)

Get reference values for an experiment from its equivalent piControl experiment

Parameters
  • indata (scmdata.ScmRun) – Experiment to calculate reference values for

  • picontrol (scmdata.ScmRun) – Pre-industrial control run data

  • picontrol_branching_time (datetime.datetime) – The branching time in the pre-industrial experiment. It is assumed that the first timepoint in input follows immediately from this branching time.

Returns

Reference values with the same index and columns as indata

Return type

pd.DataFrame

Raises
method_name

Name of the method used for normalisation

This string is included in the metadata of normalised data/files.

Type

str

normalise_against_picontrol(indata, picontrol, picontrol_branching_time)

Normalise data against picontrol

Parameters
  • indata (scmdata.ScmRun) – Data to normalise

  • picontrol (scmdata.ScmRun) – Pre-industrial control run data

  • picontrol_branching_time (datetime.datetime) – The branching time in the pre-industrial experiment. It is assumed that the first timepoint in input follows immediately from this branching time.

Returns

Normalised data including metadata about the file which was used for normalisation and the normalisation method

Return type

scmdata.ScmRun

Raises

Running mean de-drift API

Module for the normaliser which only removes drift in the pre-industrial control run (drift is calculated using a running-mean)

class netcdf_scm.normalisation.running_mean_dedrift.NormaliserRunningMeanDedrift(nyears=21)[source]

Bases: netcdf_scm.normalisation.running_mean.NormaliserRunningMean

Normaliser which calculates drift in the pre-industrial control using a running mean

Each normalisation value is the change in an n-year mean with respect to the running mean at the branch point. This means that the reference values are always zero in their first timestep. Each point is centred on the equivalent point in the pre-industrial control simulation.

If there is insufficient data to create a full n-year window at the edge of the simulation then a linear extrapolation of the running-mean is used to extend the normalisation values to cover the required full range.

get_reference_values(indata, picontrol, picontrol_branching_time)

Get reference values for an experiment from its equivalent piControl experiment

Parameters
  • indata (scmdata.ScmRun) – Experiment to calculate reference values for

  • picontrol (scmdata.ScmRun) – Pre-industrial control run data

  • picontrol_branching_time (datetime.datetime) – The branching time in the pre-industrial experiment. It is assumed that the first timepoint in input follows immediately from this branching time.

Returns

Reference values with the same index and columns as indata

Return type

pd.DataFrame

Raises
method_name

Name of the method used for normalisation

This string is included in the metadata of normalised data/files.

Type

str

normalise_against_picontrol(indata, picontrol, picontrol_branching_time)

Normalise data against picontrol

Parameters
  • indata (scmdata.ScmRun) – Data to normalise

  • picontrol (scmdata.ScmRun) – Pre-industrial control run data

  • picontrol_branching_time (datetime.datetime) – The branching time in the pre-industrial experiment. It is assumed that the first timepoint in input follows immediately from this branching time.

Returns

Normalised data including metadata about the file which was used for normalisation and the normalisation method

Return type

scmdata.ScmRun

Raises