calc_index: Function to calculate climate indices

View source: R/calc_indices_main.R

calc_indexR Documentation

Function to calculate climate indices

Description

The function calculated climate indices for different temporal aggregations for gridded and station data. It also works for seasonal forecast ensembles (grid and station). As input a climindvis object (output of make_object is needed.

Usage

calc_index(climindvis, index, aggt, ...)

Arguments

climindvis

Object of type climindvis as returned by make_object

index

Name of index to be calculated, e.g. "dd","tnn","spi". (for a complete list of indices see see section "indices" below).

aggt

Aggregation type for temporal aggregation:

  • "annual": annual aggregation

  • "seasonal": seasonal aggregation ("MAM","JJA","SON","DJF"), define subset as character array using parameter selagg, e.g. selagg=("DJF","MAM") for selecting seasons DJF and MAM only.

  • "monthly": Monthly aggregation. For subset of months, define subset as integer array using parameter selagg, e.g. c(1:3) for monthly aggregation of Jan,Feb and March

  • "other": aggregation over all months defined as integer array in aggmons, e.g. c(1:4) aggregates over Jan-Apri.

  • "dates": Aggregation of user defined dates defined in start_days and end_days. start_days and end days are arrays of format date or character(yyyy-mm-dd). If start and end dates are the same for all years they can also be specified as "0000-mm-dd", e.g. "0000-01-01".

  • "xdays": Aggregations over time slices of xday days, e.g. for xday=7, weekly aggregation. If the parameters start and/or end are provided, time slices are only calculated between the two dates. If you want weekly aggregations you thus have to set the starting date to a Monday. This aggregation is not implemented for seasonal forecast data and if small xdays are chosen (e.g. 7 or 10) we recommend to use it only for short time periods. Please note that at the moment the autoplot functions do not work with this aggregation type.

...

for index specific arguments see links in section "indices" below.

Value

The function returns an S3 object of class climindvis_index with the following entries:

  • index Array of index values of dimension: spatial dimensions x (ensemble members) x aggregations x years

  • index_info List with information about the indices (name (@iname), @aggt, names of aggregations (@aggnames), @years, index format (@iformat), index dimensions (@idims)) used for plotting functions.

  • lon Array of longitudes

  • lat Array of latitudes

  • index_trend Array of dimension spatial dimension(s) x (ensemble) x aggregation x 4. The dimensions of the last dimension are 1: fit of trend estimate, 2: lower confidence interval, 3: upper confidence interval and 4:fit of loess-curve.

  • trend_info Array of dimension spatial dimension(s) x (ensemble) x aggregation x 6. The dimensions of the last dimension are the 1:start year, 2: end year, 3. p-value, 4. relative trend, 5. absolute trend and 6. the method used to calculate the trend. Methods are numeric and correspond to (1) Least Squares Fit, (2) Logistic Regression and (3) MannKendall.

Details

Note that indices are only calculated if all days of an aggregation period are available in the time series . If e.g. the dataset only contains data for Jan-May and aggt="seasonal" is chosen, the index will only be calculated for the season MAM. If the aggregation period spans years, the index will not be calculated for the last year.

Indices

The following indexs can be calculated with the ClimIndVis package. For index specific arguments and examples, see links.

Threshold Indices:

  • dd Dry days (Prec < 1mm). For arguments and default values see index_arguments.dd

  • fd Frost days (Tmin<0C). For arguments and default values see index_arguments.fd

  • th_tmin Days with minimum temperature below a user defined threshold (Tmin < threshold). For arguments and default values see index_arguments.th_tmin

  • th_tmax Days with maximum temperature above a user defined threshold (Tmax > threshold). For arguments and default values see index_arguments.th_tmax

  • th_topt Days with average temperature within a user defined temperature range (threshold <= Tavg <= threshold2). For arguments and default values see index_arguments.th_topt

  • th Threshold function for days below/above a user defined threshold (Variable >/>=/</<= threshold). For arguments and default values see index_arguments.th

  • th_range Threshold function for days within a user defined range (threshold >/>=/</<= variable >/>=/</<= threshold2). For arguments and default values see index_arguments.th_range

Minimum-Maximum Indices:

  • tnn Minimum value of daily minimum temperature. For arguments and default values see index_arguments.tnn

  • tnx Maximum value of daily minimum temperature. For arguments and default values see index_arguments.tnx

  • txn Minimum value of daily maximum temperature. For arguments and default values see index_arguments.txn

  • txx Maximum value of daily maximum temperature. For arguments and default values see index_arguments.txx

  • varmin Minimum value of user defined variable. For arguments and default values see index_arguments.varmin

  • varmax Maximum value of user defined variable. For arguments and default values see index_arguments.varmin

  • rx Maximum rx-day precipitation. index_arguments.rx

  • minmax_xdays Maximum/minimum rx-day value of variable. For arguments and default values see index_arguments.minmax_xdays

Spell-Duration Indices:

  • cwd Consecutive wet days. For arguments and default values see index_arguments.cwd

  • cdd Consecutive dry days. For arguments and default values see index_arguments.cdd

  • cxd Consecutive days of variable above/below a threshold. For arguments and default values see index_arguments.cxd

  • csdi Cold spell duration index. Count of days with at least 6 consecutive days when TN < 10th percentile. For arguments and default values see index_arguments.csdi

  • wsdi Warm spell duration index. Count of days with at least 6 consecutive days when TX > 90th percentile. For arguments and default values see index_arguments.wsdi

Quantile Indices:

  • tn10p Percentage of days when TN < 10th percentile. For arguments and default values see index_arguments.tn10p

  • tn90p Percentage of days when TN > 90th percentile.For arguments and default values see index_arguments.tn90p

  • tx10p Percentage of days when TX < 10th percentile.For arguments and default values see index_arguments.tx10p

  • tx90p Percentage of days when TX > 90th percentile.For arguments and default values see index_arguments.tx90p

  • qth Number of days above/below thershold. (works for precip and temperature data). For arguments and default values see index_arguments.qth

  • rXptot Total precipitation when RR > Xp, e.g. (r95ptot). For arguments and default values see index_arguments.rXptot

  • qval Percentile value for each aggregation period and year. For arguments and default values see index_arguments.qval

  • qrange Percentile range for each aggregation period and year. For arguments and default values see index_arguments.qrange

further Indices:

  • mean For arguments and default values see index_arguments.mean

  • sum For arguments and default values see index_arguments.sum

  • spi Standard precipitation index. Argument aggt needs to be set to monthly for this index. For more arguments and default values see index_arguments.spi

  • spi_forecast Argument aggt needs to be set to monthly for this index. For more arguments and default values see index_arguments.spi_forecast

  • sdii Simple precipitation intensity index. Ratio of total rainfall to the number of days when precipitation is higher than a dry day threshold. For arguments and default values see index_arguments.sdii

  • prcptot Total precipitation in wet days. For arguments and default values see index_arguments.prcptot

  • rainy_season_start Start of the rainy season. Argument aggt needs to be set to dates and start_days and end_days additionally provided for this index. For more arguments and default values see index_arguments.rainy_season_start #'

  • rainy_season_end End of the rainy season. Argument aggt needs to be set to dates and start_days and end_days additionally provided for this index. For more arguments and default values see index_arguments.rainy_season_end #'

  • rainy_season_dur Duration of the rainy season. Argument aggt needs to be set to dates and day_start and day_end additionally provided for this index. For more arguments and default values see index_arguments.rainy_season_dur

See Also

calculate_index.climindvis


Climandes/ClimIndVis documentation built on June 9, 2025, 7:09 p.m.