climakitae.tools package#

Submodules#

climakitae.tools.derived_variables module#

Functions for deriving frequently used variables

climakitae.tools.derived_variables.compute_dewpointtemp(temperature, rel_hum)#

Calculate dew point temperature

Args:

temperature (xr.DataArray): Temperature in Kelvin rel_hum (xr.DataArray): Relative humidity (0-100 scale)

Returns

dew_point (xr.DataArray): Dew point (K)

climakitae.tools.derived_variables.compute_hdd_cdd(t2, hdd_threshold, cdd_threshold)#

Compute heating degree days (HDD) and cooling degree days (CDD)

Parameters:
  • t2 (DataArray) – Air temperature at 2m gridded data

  • hdd_threshold (int, optional) – Standard temperature in Fahrenheit.

  • cdd_threshold (int, optional) – Standard temperature in Fahrenheit.

Returns:

tuple of DataArray – (hdd, cdd)

climakitae.tools.derived_variables.compute_hdh_cdh(t2, hdh_threshold, cdh_threshold)#

Compute heating degree hours (HDH) and cooling degree hours (CDH)

Parameters:
  • t2 (DataArray) – Air temperature at 2m gridded data

  • hdh_threshold (int, optional) – Standard temperature in Fahrenheit.

  • cdh_threshold (int, optional) – Standard temperature in Fahrenheit.

Returns:

tuple of DataArray – (hdh, cdh)

climakitae.tools.derived_variables.compute_relative_humidity(pressure, temperature, mixing_ratio, name='rh_derived')#

Compute relative humidity. Variable attributes need to be assigned outside of this function because the metpy function removes them

Args:

pressure (xr.DataArray): Pressure in hPa temperature (xr.DataArray): Temperature in Celsius mixing_ratio (xr.DataArray): Dimensionless mass mixing ratio in g/kg name (str, optional): Name to assign to output DataArray

Returns:

rel_hum (xr.DataArray): Relative humidity

Source: https://www.weather.gov/media/epz/wxcalc/mixingRatio.pdf

climakitae.tools.derived_variables.compute_specific_humidity(tdps, pressure, name='q2_derived')#

Compute specific humidity.

Args:

tdps (xr.DataArray): Dew-point temperature, in K pressure (xr.DataArray): Air pressure, in Pascals name (str, optional): Name to assign to output DataArray

Returns:

spec_hum (xr.DataArray): Specific humidity

climakitae.tools.derived_variables.compute_wind_dir(u10, v10, name='wind_direction_derived')#

Compute wind direction at 10 meters

Args:

u10 (xr.DataArray): Zonal velocity at 10 meters height in m/s v10 (xr.DataArray): Meridional velocity at 10 meters height in m/s name (str, optional): Name to assign to output DataArray

Returns:
wind_dir (xr.DataArray): Wind direction, in [0, 360] degrees,

with 0/360 defined as north, by meteorological convention

Notes:

source: https://sites.google.com/view/raybellwaves/cheat-sheets/xarray

climakitae.tools.derived_variables.compute_wind_mag(u10, v10, name='wind_speed_derived')#

Compute wind magnitude at 10 meters

Args:

u10 (xr.DataArray): Zonal velocity at 10 meters height in m/s v10 (xr.DataArray): Meridonal velocity at 10 meters height in m/s name (str, optional): Name to assign to output DataArray

Returns:

wind_mag (xr.DataArray): Wind magnitude

climakitae.tools.indices module#

Functions for deriving indices

climakitae.tools.indices.effective_temp(T)#

Compute effective temperature Effective Temp = (1/2)*(yesterday’s effective temp) + (1/2)*(today’s actual temp) To make sense of the expansion, today’s ET is consist of a portion of the actual temperature of each day up to today–half of today’s temp, 1/4 of yesterday’s temp, 1/8 of the day before yesterday’s temp etc, thus it’s “an exponentially smoothed temperature” as stated in the glossary of the reference. This derivation only considers 4 days of temperature data in the computation of EFT: today, yesterday, the day before yesterday, and two days before yesterday. Thus, the first 3 timesteps of the EFT will be NaN.

Parameters:

T (DataArray) – Daily air temperature in any units

Returns:

eft (DataArray) – Effective temperature

References

https://www.nationalgas.com/document/132516/download

climakitae.tools.indices.fosberg_fire_index(t2_F, rh_percent, windspeed_mph)#

Compute the Fosberg Fire Weather Index. Use hourly weather as inputs. Ensure that the input variables are in the correct units (see below).

Parameters:
  • t2_F (DataArray) – Air temperature in units of Fahrenheit

  • rh_percent (DataArray) – Relative humidity in units of 0-100 (percent)

  • windspeed_mph (DataArray) – Windspeed in units of miles per hour

Returns:

FFWI (DataArray) – Fosberg Fire Weather Index computed for each grid cell

References

https://a.atmos.washington.edu/wrfrt/descript/definitions/fosbergindex.html sharppy/SHARPpy https://www.spc.noaa.gov/exper/firecomp/INFO/fosbinfo.html

climakitae.tools.indices.noaa_heat_index(T, RH)#

Compute the NOAA Heat Index. See references for more information on the derivation on this index.

Parameters:
  • T (DataArray) – Temperature in deg F

  • RH (DataArray) – Relative Humidity in percentage (0-100)

Returns:

HI (DataArray) – Heat index per timestep

References

NOAA: https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml NCAR NCL documentation: https://www.ncl.ucar.edu/Document/Functions/Heat_stress/heat_index_nws.shtml

Module contents#