Learn R Programming

climatol (version 4.4-0)

weekendaccum: Check for possible precipitation weekend accumulations.

Description

This function is intended to check for possible undeclared daily precipitation weekend accumulations, assigning an accumulation code if necessary to the false zeros.

Usage

weekendaccum(varcli,anyi,anyf,na.strings='NA',cumc=-1,wdsl=0.01,expl=TRUE)

Arguments

varcli

Short name of the climatic variable.

anyi

Initial year of the data.

anyf

Final year of the data.

na.strings

Character strings to be treated as missing data ['NA'].

cumc

Code of accumulated missing data [-1].

wdsl

Weekday significance level (in %) to detect 1 to 3 false consecutive zeros followed by an accumulation of precipitation. [0.01].

expl

Exploratory mode. TRUE by default, not modifying the original files. Set to FALSE to change false zeros to cumulative code cumc.

Details

This function is intended to be applied to DAILY PRECIPITATION only, whenever there is a suspicion that observations of precipitation on an accumulation rain gauge (as the Hellmann type) has been skipped on weekends (although the test is applied to any day of the week).

Parameter 'wdsl' can be set between 0.001 and 1, meaning significant levels between 0.00001 and 0.01. (Default value: 0.01, corresponding to a significant level of 0.0001.) Parameterized significant levels were derived from daily precipitations generated by a climate model. Default and suggested values are very low to avoid false positives.

The test is applied station by station and year by year. If 'expl=FALSE', when the difference between the frequency of zeros of any week day and the mean of 1, 2 or 3 preceding days is significant, those preceding days will be assigned the chosen cumulative code cumc (-1 by default) if and only if the precipitation of all those preceding days is zero and the tested week day recorded precipitation. In this way, ulterior application of the homogen function with the same cumulative code will distribute the accumulated precipitation into their corresponding days.

By default, 'expl=FALSE', so no modification will be applied to the data file, while the output will tell what would happen when setting 'expl=TRUE'. Maximum absolute differences between a week day and 1, 2 or 3 preceding days are saved in a *.Rdat binary file that can be loaded to examine these differences for every series and year.

See Also

homogen

Examples

Run this code
## Set a temporal working directory and write input files:
wd <- tempdir()
wd0 <- setwd(wd)

## Load example daily precipitation data:
data(climatol_data)
dat <- as.matrix(RR3st[,2:4])

## Set zero precipitation in some days and years of two of the three stations:
x <- seq(as.Date('1981-01-01'),as.Date('1995-12-31'),1)
year <- as.integer(strftime(x,'%Y'))
wkd  <- as.integer(strftime(x,'%w')) #weekday: 0(Sunday) to 6
dat[year%in%1986:1990 & wkd==6,1] <- 0
dat[year%in%1989:1992 & wkd%in%5:6,2] <- 0
write(dat,'Prec_1981-1995.dat') #write the input data file
## write stations input file:
write.table(SIstations,'Prec_1981-1995.est',row.names=FALSE,col.names=FALSE)

## Now run the function:
weekendaccum('Prec',1981,1995)

## Return to user's working directory:
setwd(wd0)

## Input and output files can be found in directory:
print(wd)

Run the code above in your browser using DataLab