RClimMAWGEN (version 1.1)

climdex.data.frame: ClimDex Data Frame

Description

Create input object for clim,ete index analyis from RMAWGEN output.

Usage

climdex.data.frame(data, station, realization_TN, realization_TX, realization_PREC, start_date = "1981-01-01", end_date = "2010-12-31", climate_index = "climdex.gsl", frequency = c("yearly", "monthly", "daily"), freq = c("default", "monthly", "annual"), date.series = seq(as.PCICt(start_date, cal = "gregorian"), as.PCICt(end_date, cal = "gregorian"), by  = "days"), base.range = c(1990, 2002), n = 5, prefix = NULL, ...)

Arguments

data
data.frame containing realizations of weather variables, e.g. the one retured as output by ComprehensiveTemperatureGenerator
station
names of weather stations where to apply climate indices
realization_TN
realizations of daily minimum temperature (observed and simulated) time series on which climate index are calculated
realization_TX
realizations of daily maximum temperature (observed and simulated) time series on which climate index are calculated
realization_PREC
realizations of daily precipitation (observed and simulated) time series on which climate index are calculated. It is NULL if missing.
start_date
start date yyyy-mm-dd of weather time series
end_date
start date yyyy-mm-dd of weather time series
climate_index
climate indices to be calculated. The names must correspond to the name of the respective function contained in the climdex.pcic R package
yearly
logical voalue. If TRUE (Default) the index is calculeted yearly per each year, otherwise the index is calculated monthly, i.e. per each month
base.range
prefix
name for time series on which climate indices are calculated.
date.series
see climdexInput.raw. If missing, it is automatically calculated from start_date and end_date
frequency
string value. Default is c("yearly","monthly","daily"). Set one of these, if the climate indices are referred to each year, month or day respectively.
freq
string value. Default is c("default","monthly", "annual"). It has the same role of "frequency" and is used in several cilmdex.pcic indices. If it is omitted (Default) the frequency is obtaind by frequency argument. See climdex.tn90p,climdex.tx90p .
...
further arguments

Value

a climdex.data.frame object (see the variable climdex in the examples.)

References

http://www.climdex.org

See Also

as.climdex.data.frame,climdexInput.raw,climdex.tn90p,climdex.tx90p

Examples

Run this code
rm(list=ls())
library(RClimMAWGEN)
#  generated and observed daily temperature data for the considering period
#  (1981-2010)(RMAWGEN output data structure)
data (generation_p1)


#collected generated (realizations) and observed data (realizations$Tx_mes, realizations$Tn_mes)

realizations <- generation_p1$output

realizations$Tx_mes <- generation_p1$input$Tx_mes

realizations$Tn_mes <- generation_p1$input$Tn_mes

# realization scanarios used for 'climdex.data.frame'
realizations_TN <- c("Tn_mes","Tn_gen00002","Tn_gen00003","Tn_gen00004")
realizations_TX <- c("Tx_mes","Tx_gen00002","Tx_gen00003","Tx_gen00004")

stations <- names(realizations$Tn_mes)

start_date = "1981-01-01"
end_date = "2010-12-31"

# The indices \link{climdex.tn90p},\link{climdex.tx90p} are considered in this example
climate_indices = c("climdex.tn90p","climdex.tx90p")

frequency =  "monthly"

date.series = seq(as.PCICt(start_date, cal = "gregorian"),
 as.PCICt(end_date, cal = "gregorian"), by = "days")

base.range = c(1990, 2002)
n = 5
prefix = NULL


climdex <- climdex.data.frame(data=realizations, station=stations,
 realization_TN=realizations_TN,realization_TX=realizations_TX,realization_PREC=NULL,
 start_date= start_date, end_date = end_date ,climate_index = climate_indices,
 frequency = frequency,date.series = date.series,base.range = base.range,
 n = n, prefix = prefix)

str(climdex)

## Function 'climdex.data.frame' can be also used with annual frequency
## The following lines are now commented because the elapsed time is too long!!
## Please uncomment to run the following lines to run the function.
# climdex_annual <- climdex.data.frame(data=realizations, station=stations,
# realization_TN=realizations_TN,realization_TX=realizations_TX,realization_PREC=NULL,
# start_date= start_date, end_date = end_date ,climate_index = climate_indices,
# frequency = "yearly",date.series = date.series,base.range = base.range,
# n = n, prefix = prefix)
#
# str(climdex_annual)


# Wilcoxon test between observed and generated climate indices

 observed <- "T0129__Tn_mes__climdex.tx90p"
 generated <- c("T0129__Tn_gen00002__climdex.tx90p","T0129__Tn_gen00003__climdex.tx90p")
 wxt <- wilcox.test(x=climdex,observed=observed,generated=generated)
 wxt
#  Kolgomorov-Smirinov test between observed and generated climate indices

kst <- ks.test.climdex.data.frame(data=climdex,observed=observed,generated=generated)
kst

accepted(wxt)
accepted(kst)

Run the code above in your browser using DataLab