climdex.data.frame: ClimDex Data Frame

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/climdex.data.frame.R

Description

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

Usage

1
2
3
4
5
6
7
8
9
  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

see climdexInput.raw

n

see climdexInput.raw

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.)

Author(s)

Emanuele Cordano, Annalisa Di Piazzaa

References

http://www.climdex.org

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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)

Example output

Loading required package: climdex.pcic
Loading required package: PCICt
Loading required package: RMAWGEN
Loading required package: chron
Loading required package: date
Loading required package: vars
Loading required package: MASS
Loading required package: strucchange
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: sandwich
Loading required package: urca
Loading required package: lmtest
List of 16
 $ T0129__Tn_mes__climdex.tn90p     : num [1:360] 0 0 22.6 50 0 ...
 $ T0129__Tn_mes__climdex.tx90p     : num [1:360] 6.45 0 6.45 30 3.23 ...
 $ T0129__Tn_gen00002__climdex.tn90p: num [1:360] 29.03 0 9.68 6.67 6.45 ...
 $ T0129__Tn_gen00002__climdex.tx90p: num [1:360] 22.6 21.4 0 10 22.6 ...
 $ T0129__Tn_gen00003__climdex.tn90p: num [1:360] 12.9 50 32.26 0 6.45 ...
 $ T0129__Tn_gen00003__climdex.tx90p: num [1:360] 0 25 25.8 23.3 0 ...
 $ T0129__Tn_gen00004__climdex.tn90p: num [1:360] 16.13 3.57 32.26 13.33 6.45 ...
 $ T0129__Tn_gen00004__climdex.tx90p: num [1:360] 6.45 0 22.58 0 16.13 ...
 $ T0139__Tn_mes__climdex.tn90p     : num [1:360] 0 0 25.81 53.33 6.45 ...
 $ T0139__Tn_mes__climdex.tx90p     : num [1:360] 0 0 3.23 30 6.45 ...
 $ T0139__Tn_gen00002__climdex.tn90p: num [1:360] 38.71 0 0 10 9.68 ...
 $ T0139__Tn_gen00002__climdex.tx90p: num [1:360] 25.81 28.57 0 3.33 32.26 ...
 $ T0139__Tn_gen00003__climdex.tn90p: num [1:360] 9.68 50 25.81 6.67 3.23 ...
 $ T0139__Tn_gen00003__climdex.tx90p: num [1:360] 0 21.43 32.26 20 3.23 ...
 $ T0139__Tn_gen00004__climdex.tn90p: num [1:360] 16.13 3.57 29.03 3.33 6.45 ...
 $ T0139__Tn_gen00004__climdex.tx90p: num [1:360] 9.68 3.57 29.03 0 9.68 ...
 - attr(*, "row.names")= int [1:360] 1 2 3 4 5 6 7 8 9 10 ...
 - attr(*, "class")= chr "climdex.data.frame"
$T0129__Tn_mes__climdex.tx90p_vs_T0129__Tn_gen00002__climdex.tx90p

	Wilcoxon rank sum test with continuity correction

data:  x[, observed] and x[, it]
W = 61843, p-value = 0.2848
alternative hypothesis: true location shift is not equal to 0


$T0129__Tn_mes__climdex.tx90p_vs_T0129__Tn_gen00003__climdex.tx90p

	Wilcoxon rank sum test with continuity correction

data:  x[, observed] and x[, it]
W = 58171, p-value = 0.01676
alternative hypothesis: true location shift is not equal to 0


Warning messages:
1: In ks.test(x = data[, observed], y = data[, it], ...) :
  p-value will be approximate in the presence of ties
2: In ks.test(x = data[, observed], y = data[, it], ...) :
  p-value will be approximate in the presence of ties
$T0129__Tn_mes__climdex.tx90p_vs_T0129__Tn_gen00002__climdex.tx90p

	Two-sample Kolmogorov-Smirnov test

data:  data[, observed] and data[, it]
D = 0.086111, p-value = 0.1385
alternative hypothesis: two-sided


$T0129__Tn_mes__climdex.tx90p_vs_T0129__Tn_gen00003__climdex.tx90p

	Two-sample Kolmogorov-Smirnov test

data:  data[, observed] and data[, it]
D = 0.13056, p-value = 0.004327
alternative hypothesis: two-sided


[1] "T0129__Tn_mes__climdex.tx90p_vs_T0129__Tn_gen00002__climdex.tx90p"
[1] "T0129__Tn_mes__climdex.tx90p_vs_T0129__Tn_gen00002__climdex.tx90p"

RClimMAWGEN documentation built on May 2, 2019, 3:38 p.m.