Skip to content

climateintelligence/HWStat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HWStat

This program computes several statistics of heatwaves.

A heatwave is defined as an uninterrupted period with extreme temperatures above a given (percentile-based) threshold. This percentile, which is calculated locally with a running window centered on each day of year, and the minimum duration (in days) required to define a heatwave are user-defined. The definition can be applied to maximum temperature (hot days), minimum temperature (hot nights), or both (hot days and nights).

The metrics are calculated (accumulated) over a specific time interval (month, season, year or a certain number of days defined by the user) and provided for the entire period. The output (spatial maps for each time interval of the considered period) includes the following parameters: the heatwave frequency (HWF, number of days with HW conditions), the longest spell (HWD, the longest HW event, in days), the heatwave amplitude (HWA, the largest daily temperature exceedance with respect to the considered percentile, in temperature units) and the heatwave magnitude (HWM, the cumulative exceedance over the considered time interval, i.e. an aggregated measure of HW frequency, duration and intensity based on the sum of daily temperature exceedances for all HW days, in temperature units).

The input temperature file must be in netcdf format and in hourly frequency.

This program saves the output in netcdf format for the above-mentioned indices and with the selected frequency (monthly, seasonal, annual,user-defined). The spatial domain and period are provided as in the input temperature data.

To pass the arguments to the program, you have to fill in a .ini located at

HWStat/parameters/params.ini

To run

python HWStat

To see the possible options, use the "-h" option to see the help:

python HWStat -h

It also allows you to run some of the modules in the Cython version to get the best performance. To do this, you have to compile the pyx file which belongs to cmodules folder via setup.py:

python setup.py build_ext --inplace

and the ".so" file must be generated. A ".so" file (library) for x86_64 and Linux is located in cmodules folder.

To activate the C modules, you have to add the "-C" option:

python HWStat -C

The HWCNT Xarray Accesor

This program also included a Xarray accesor (HWCNT) that is used by the main program to compute the indexes. So this accesor could be called independently of the main program importing the HWAccesor. For example, to compute the daily maximum temperature:

tmax = t2m.HWCNT.dailymax()

To transform to Celsius degrees

t2m = t2m.HWCNT.toCelsius()

or to compute the exceedance, the base period to compute the percentile, the window, the threshold percentile and the threshold of consecutive days defining a heatwave must be established. In this case we use the period 1950-1980 to compute the 90th percentile with a window of 30 days and at least 3 days of consecutive hot days/nights to define a heatwave:

t2m.HWCNT.setParameters(base_period = {"start":1950, "end":1980},
                             window= 30,
                             prec = 90)
t2m.HWCNT.threshold = 3

and then we get the exceedance

ex = t2m.HWCNT.exceedance()

About

Compute statistics of Heatwaves

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%