Learn R Programming

climatol (version 3.1.2)

dd2m: Compute monthly data from daily series

Description

Daily series are aggregated into total, mean, maximum, or minimum monthly values, and saved to files for further processing.

Usage

dd2m(varcli, anyi, anyf, anyip=anyi, anyfp=anyf, ndec=1, suf=NA, valm=2,
namax=10, na.strings="NA", homog=FALSE, ini=NA)

Arguments

varcli

Acronym of the name of the studied climatic variable, as in the data file name.

anyi

Initial year of the data present in the file.

anyf

Final year of the data present in the file.

anyip

First year of the output period. (Defaults to anyi).

anyfp

Last year of the output period. (Defaults to anyf).

ndec

Number of decimal places to be saved in the output file.

suf

Optional suffix to be added (by a hyphen) to the acronym of the variable to form the name of the input data.

valm

Monthly value to compute:

1:

Sum,

2:

Mean,

3:

Maximum,

4:

Minimum.

namax

Maximum number of missing data in any month to compute its monthly value. (10 by default)

na.strings

Missing data code in the original daily data.

homog

If TRUE, monthly aggregation will be performed on daily series adjusted from a previous monthly homogenization.

ini

Initial date of the daily data, with format "YYYY-MM-DD". Its default NA value assume it to be the first day of the period of study.

Value

This function does not return any value.

Details

This function can be applied to either raw or homogenized daily data.

Raw data are read from files VAR_YEAR-YEAR.dat and VAR_YEAR-YEAR.est, and monthly data will be saved to files VAR-m_YEAR-YEAR.dat and VAR-m_YEAR-YEAR.est.

Homogenized data are read from VAR_YEAR-YEAR.rda. In this case monthly data will be saved to files named VAR-mh_YEAR-YEAR.dat and VAR-mh_YEAR-YEAR.est.

See Also

homogen, dahstat, dahgrid

Examples

Run this code
# NOT RUN {
#Set a temporal working directory and write input files:
wd <- tempdir()
wd0 <- setwd(wd)
data(Ttest)
write(dat,'Ttest_1981-2000.dat')
write.table(est.c,'Ttest_1981-2000.est',row.names=FALSE,col.names=FALSE)
rm(dat,est.c) #remove loaded data from memory space
#Now run the example:
dd2m('Ttest',1981,2000)
#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