This repo is a collection of Climate indices in MATLAB.
The functions takes a data structure with the variables as fields. The variables array can be of dimensions 1, 2 or 3.
The data struct is as follows.
data.tasmin % Daily minimum temperature
data.tasmax % Daily maximum temperature
data.pr % Daily precipitation accumulation
data.tas % Daily mean temperature
data.dates % Dates vector
A time vector of size MxN
is also necessary in the data struct, where M
is the number of timesteps and N
has at least a length of 3 (year, month, day). This can be created by the MATLAB
function datevec
.
Some functions needs other argument, such as the variable field. For example, tas
, pr
, tasmax
, tasmin
is needed for functions that calculate annual means, max and minium (i.e. annualmean
, annualmin
, annualmax
).
N.B. It is not necessary to have all variables (e.g. .tasmin
, .tasmax
, .pr
and .tas
) in the data struct if the called functions does not need it. However, the .dates
field is necessary.
The functions returns a struct.
indicator.data % Data array
indicator.dates % Date array
indicator.units % Unit
indicator.title % Title (for figure re-use)
indicator = annualmean(data, var::String)
Defn. Returns the annual mean values of variable 'var'.
indicator = annualmax(data, var::String)
Defn. Returns the annual maximum values of variable 'var'.
indicator = annualmin(data, var::String)
Defn. Returns the annual minimum values of variable 'var'.
indicator = annualsum(data, var::String)
Defn. Returns the annual summation of variable 'var'.
indicator = djfsum(data, var::String)
Defn. Returns the seasonal summation of variable 'var' over December, January and February.
indicator = jjasum(data, var::String)
Defn. Returns the seasonal summation of variable 'var' over June, July and August.
indicator = growseasonlength(data, code::Int)
Defn. Returns the length of the growing season. Needs variable 'tas' in data struct.
Code = 1 return the start date of the growing season (julian day)
Code = 2 return the end date of the growing season (julian day)
Code = 3 return the length of the growing season (days)
indicator = pr_growseason_mean(data)
Defn. Mean precipitation during the growing season. Needs variables 'pr' and 'tas' in data struct.
indicator = pr_growseason(data)
Defn. Precipitation total during the growing season. Needs variables 'pr' and 'tas' in data struct.
indicator = thresover(data, var, thres::Int/Float)
Defn. Returns the frequency of tasmax over a custom threshold 'thres'. Needs variables 'tasmax' data struct.
indicator = utm(data)
Defn. Returns the value of 'Unités thermiques maïs'.
indicator = grow_dd(data, thres::Float)
Defn. Returns the growing degree days, as defined by the cumulative temperature over the threshold 'thres'.
indicator = lastspringfrost(data, thres::Float)
Defn. Returns the julian day of the last spring frost with respect to threshold 'thres' (usually 0 Celsius).
indicator = cnfd(data)
Defn. Returns the length of the frost-free season. Hardcoded to lastspringfrost of 0 Celsius and firstfallfrost of -2 Celsius.
N.B. cnfd stands for 'consecutive no frost days'.
indicator = firstfallfrost(data, thres::Float)
Defn. Returns the julian day of the first spring frost with respect to threshold 'thres' (usually -2 Celsius)