hotspell.heatwaves module

class hotspell.heatwaves.HeatWaves(events, metrics)

Bases: object

Class designed for storing heat wave events.

It is the holder for the output of get_heatwaves.

Parameters:
  • events (DataFrame) – It contains the dates of detected heat wave events, as well as their basic characteristics (duration and temperature statistics).

  • metrics (DataFrame) – It contains the summary of heat waves per year via standard metrics. Years with no heat waves are distinguished from years with missing data.

Notes

Column names of metrics correspond to:

hwnHeat wave number

The annual total sum of heat wave events

hwfHeat wave day frequency

The annual total sum of heat wave days

hwdHeat wave duration

The length of the longest heat wave per year

hwdmHeat wave duration (mean)

The average length of heat waves per year

hwmHeat wave magnitude

The average magnitude of all events (anomaly against seasonal mean)

hwmaHeat wave magnitude (absolute value)

The average magnitude of all events

hwaHeat wave amplitude

The hottest day of hottest event per year (anomaly against seasonal mean)

hwaaHeat wave amplitude (absolute value)

The hottest day of hottest event per year

hotspell.heatwaves.get_heatwaves(filename, hw_index, ref_years=('1961-01-01', '1990-12-31'), summer_months=(6, 7, 8), max_missing_days_pct=10, export=True, metrics=True)

Detect heat wave events from weather station data.

Parameters:
  • filename (str or path object) – The path of the csv file that contains the weather data. It requires specific columns to be included in the csv file in a specific order.

  • hw_index (HeatWaveIndex) – An HeatWaveIndex object created using the index function.

  • ref_years (tuple of str, default ("1961-01-01", "1990-12-31")) – The first and the last year of the reference period. It should be set using the “YYYY-MM-DD” format.

  • summer_months (tuple of int or None, default (6, 7, 8)) – A tuple with all months of the summer period. For the southern hemisphere it should be set as (12, 1, 2) or similar variants.

  • max_missing_days_pct (int, default 10) – The percentage of maximum missing days for a year to be considered valid and be included in the metrics. If a summer period has been defined the percentage corresponds only to this period.

  • export (bool, default True) – If True, output is exported as csv files in the same folder as the input data.

  • metrics (bool, default True) – If True, annual metrics are computed and are exported if export=True.

Return type:

HeatWaves object