Learn R Programming

climatol (version 4.4-0)

rclimdex2climatol: Convert RClimDEX/RClimPACT daily data files to climatol input format

Description

This function can be useful to prepare the climatol input files when the user have their daily data in RClimDEX/RClimPACT format.

Usage

rclimdex2climatol(stfile, kvar, stcol=1:5, sep='', anyi=NA, anyf=NA, mis=-99.9,
mindat=365, header=TRUE)

Arguments

stfile

Name of the file containing the list of data file names (or station codes), station coordinates and names.

kvar

RClimDex variable to extract: 1 (RR), 2 (TX), 3 (TN).

stcol

Columns in stfile holding file names (or station codes), longitudes, latitudes, elevations and station names. (Defaults to 1:5.)

sep

Field separator in stfile and data files (space or tab by default).

anyi

First year to study. (Defaults to the first year of available data.)

anyf

Last year to study. (Defaults to the last year of available data.)

mis

Missing data code. (Defaults to -99.9.)

mindat

Minimum required number of data per station. (Defaults to 365 daily data.)

header

Do files have a header line? TRUE by default).

Details

Users of the RClimDEX or RClimPACT/RClimPACT2 programs can convert their daily data files to the climatol format.

If the first column of stfile contains station codes, file names must be those codes with a .txt extension. If the first column contains file names, the codes will be taken by removing the extension of the file names.

All files referred to in stfile will be read, and the selected variable (precipitation, maximum or minimum temperature) will be stored in a unique *.dat file, with its companion *.est station file. Therefore, if you want to convert all three variables, you must run this function three times, with kvar equal to 1, 2 and 3.

Coordinates must be given in degrees with decimals, using the minus sign for sourthern latitudes and western longitudes.

See Also

homogen, climatol2rclimdex

Examples

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

## Prepare a few files in RClimDex/RClimPACT format:
data(climatol_data)
df=data.frame(File=c('p064.txt','p084.txt','p082.txt'),Lat=SIstations$Y,
  Lon=SIstations$X,Elev=SIstations$Z,name=SIstations$Name)
write.table(df,'stations.txt',sep='\t',row.names=FALSE)
write.table(p064.df,'p064.txt',sep='\t',row.names=FALSE,quote=FALSE)
write.table(p084.df,'p084.txt',sep='\t',row.names=FALSE,quote=FALSE)
write.table(p082.df,'p082.txt',sep='\t',row.names=FALSE,quote=FALSE)

## Now run the example:
rclimdex2climatol('stations.txt',3)

## 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