climind.stats package

Submodules

climind.stats.paragraphs module

climind.stats.paragraphs.anomaly_and_rank(all_datasets: List[TimeSeriesAnnual], year: int, output_list=False) str[source]

Write a short paragraph, returned as a string, which gives the rank range and data value for the chosen year, as well as saying how many data sets and which datasets were used.

Parameters:
  • all_datasets (List[TimeSeriesAnnual]) – List of datasets to be used to derive the ranks and values

  • year (int) – Year for which the paragraph should be generated.

Return type:

str

climind.stats.paragraphs.anomaly_and_rank_plus_new_base(all_datasets: List[TimeSeriesAnnual], year: int) str[source]

Write a short paragraph, returned as a string, which gives the rank range and data value for the chosen year, as well as saying how many data sets and which datasets were used. Then it adds the anomalies relative to the 1961-1990 baseline, with information about the number of datasets.

Parameters:
  • all_datasets (List[TimeSeriesAnnual]) – List of datasets to be used to derive the ranks and values

  • year (int) – Year for which the paragraph should be generated.

Return type:

str

climind.stats.paragraphs.antarctic_ice_paragraph(all_datasets: List[TimeSeriesMonthly], year: int) str[source]

Generate a paragraph of some standard stats for the Antarctic sea ice: rank and value for max and min extents in the year (Feb and September).

Parameters:
  • all_datasets (List[TimeSeriesMonthly]) – List of datasets on which the assessment will be based

  • year (int) – Chosen year to focus on

Returns:

Paragraph of text

Return type:

str

climind.stats.paragraphs.arctic_ice_paragraph(all_datasets: List[TimeSeriesMonthly], year: int, output_list=False) str[source]

Generate a paragraph of some standard stats for the Arctic sea ice: rank and value for max and min extents in the year (March and September).

Parameters:
  • all_datasets (List[TimeSeriesMonthly]) – List of datasets on which the assessment will be based

  • year (int) – Chosen year to focus on

Returns:

Paragraph of text

Return type:

str

climind.stats.paragraphs.basic_anomaly_and_rank(all_datasets: List[TimeSeriesAnnual], year: int, output_list=False) str[source]
climind.stats.paragraphs.co2_paragraph(all_datasets: List[TimeSeriesAnnual], year: int, update=False, output_list: bool = False) str | list[source]

Generate a paragraph of some standard stats for greenhouse gases

Parameters:
  • all_datasets (List[TimeSeriesAnnual]) – List of datasets on which the assessment will be based

  • year (int) – Chosen year to focus on

  • update (bool) – If set to True treat this as an update

Returns:

Paragraph of text

Return type:

str

climind.stats.paragraphs.co2_paragraph_update(all_datasets: List[TimeSeriesAnnual], year: int) str[source]
climind.stats.paragraphs.compare_to_highest_anomaly_and_rank(all_datasets: List[TimeSeriesAnnual], year: int) str[source]
climind.stats.paragraphs.convert_to_percentages(ts, min_screen=90, max_screen=40)[source]
climind.stats.paragraphs.dataset_name_list(all_datasets: List[TimeSeriesMonthly | TimeSeriesAnnual], year: int = None) str[source]

Given a list of dataset, return a comma-and-and separated list of the names.

Parameters:
  • all_datasets (List[Union[TimeSeriesMonthly, TimeSeriesAnnual]]) – List of data sets whose names you want in a list

  • year (int) – If year is specified, the name list will specify to what month data are available if the year is incomplete.

Returns:

A list of the dataset names separated by commas and, where appropriate, ‘and’

Return type:

str

climind.stats.paragraphs.fancy_html_units(units: str) str[source]

Convert plain text units into html fancy units, which use subscripts and special characters to render.

Parameters:

units (str) – Units to be rendered into fancy units

Returns:

Units in fancy html form, or unchanged.

Return type:

str

climind.stats.paragraphs.get_last_month(in_str)[source]
climind.stats.paragraphs.glacier_paragraph(all_datasets: List[TimeSeriesMonthly | TimeSeriesAnnual], year: int, output_list=False) str[source]

Write the glacier paragraph :param all_datasets: list of data sets to be processed :type all_datasets: list[Union[TimeSeriesMonthly, TimeSeriesAnnual]] :param year: Year for which to do the evaluation :type year: int

Return type:

str

climind.stats.paragraphs.global_anomaly_and_rank(all_datasets: List[TimeSeriesAnnual], year: int, output_list: bool = False) str[source]
Parameters:
  • all_datasets

  • year

climind.stats.paragraphs.greenland_ice_sheet(all_datasets: List[TimeSeriesAnnual], year: int) str[source]
climind.stats.paragraphs.greenland_ice_sheet_monthly(all_datasets: List[TimeSeriesMonthly], year: int) str[source]
climind.stats.paragraphs.ice_sheet_monthly_sm_grace_version(all_datasets: List[TimeSeriesMonthly], year: int) str[source]

This is the method used by Shawn Marshall to deal with the GRACE approx mid-month values.

Parameters:
  • all_datasets (List[TimeSeriesMonthly]) – List of datasets to be processed.

  • year (int) – Year of focus

Return type:

str

climind.stats.paragraphs.long_term_trend_paragraph(all_datasets: List[TimeSeriesMonthly], year: int, output_list=False) str[source]
climind.stats.paragraphs.marine_heatwave_and_cold_spell_paragraph(all_datasets: List[TimeSeriesAnnual], year: int) str[source]
climind.stats.paragraphs.max_monthly_value(all_datasets: List[TimeSeriesMonthly], year: int) str[source]

Find the highest monthly data value within the chosen year and return a paragraph, as a string, which gives the value and rank for that month.

Parameters:
  • all_datasets (List[TimeSeriesMonthly]) – List of datasets to be used in the evaluation

  • year (int) – Year to be analysed

Returns:

Short paragraph of text

Return type:

str

climind.stats.paragraphs.nice_list(names)[source]
climind.stats.paragraphs.ordinal(n)
climind.stats.paragraphs.pre_industrial_estimate(all_datasets: List[TimeSeriesAnnual], _) str[source]

Write a short paragraph estimating the difference between the modern baseline and 1850 to 1900.

Parameters:

all_datasets (List[TimeSeriesAnnual]) – List of all the data sets to be analysed

Returns:

Returns a paragraph of text stating an estimate of the pre-industrial temperature from these data sets

Return type:

str

climind.stats.paragraphs.precip_paragraph(_, year) str[source]
climind.stats.paragraphs.rank_ranges(low: int, high: int) str[source]

Given an upper and lower limit on the rank, return a string which describes the range. e.g. ‘the 2nd’ or ‘between the 4th and 8th’.

Parameters:
  • low (int) – Lower of the two ranks.

  • high (int) – Higher of the two ranks.

Returns:

Short string which describes the range. e.g. ‘the 2nd’ or ‘between the 4th and 8th’ or similar.

Return type:

str

climind.stats.paragraphs.superlative(variable, highest=True)[source]
climind.stats.paragraphs.svg_background(all_datasets, year)[source]

climind.stats.utils module

climind.stats.utils.get_latitudes(resolution)[source]

Generate a “latitude” array running from -90 + half the resolution to 90 - half the resolution.

Parameters:

resolution (float) – Resolution of the grid

Return type:

ndarray

climind.stats.utils.get_n_years_from_n_months(n_months)[source]

For a given number of months, count the number of full years

Parameters:

n_months (int) – Number of months to convert to whole years

Returns:

Number of whole years

Return type:

int

climind.stats.utils.get_ranks(datasets, match_year)[source]
climind.stats.utils.get_values(datasets, match_year)[source]
climind.stats.utils.monthly_to_annual_array(monthly_means)[source]

Calculate 12-month averages from a monthly array of shape (n_months, 3). For use in the IPCC averaging method

Parameters:

monthly_means (ndarray(n_months, 3))

Returns:

Returns the annual averages

Return type:

ndarray(n_years, 3)

climind.stats.utils.record_margin_table_by_year(datasets, match_year: int, years_to_show: int = 50) str[source]
climind.stats.utils.record_margins(datasets: List[TimeSeriesMonthly | TimeSeriesAnnual], match_year: int, title: str, output_dir: Path)[source]
climind.stats.utils.rolling_average(input_array, window_length)[source]

Calculate a rolling average of specified window_length

Parameters:
  • input_array (ndarray) – input array for which rolling averages are to be calculated

  • window_length (int) – length of rolling average window

Return type:

ndarray

climind.stats.utils.run_the_numbers(datasets: List[TimeSeriesMonthly | TimeSeriesAnnual], match_year: int, title: str, output_dir: Path, ipcc_unc: bool = True)[source]

Given a list of datasets calculate various statistics relating to ranking and values

Parameters:
  • datasets (list) – List of data sets

  • match_year (int) – Year of interest. Stats will be calculated up to the year of interest, but note that rankings will include years after the year of interest if it is not the most recent year in the data sets

  • title (str) – name for the file

  • output_dir (Path)

Return type:

None

climind.stats.utils.table_by_year(datasets, match_year: int, years_to_show: int = 20) str[source]

Module contents