Learn R Programming

seas (version 0.3-3)

lars: Write and read data from LARS-WG

Description

Write and read data from the LARS-WG stochastic weather generator; also convert to a format for HELP

Usage

write.lars(file = "", dat, var, start, end)
# write observed climate data (*.sr)
write.lars(file = "", dat, var, start, end)

# read synthetic (*.dat) or observed data (*.sr) read.lars(file, head=c("year","yday","t_max","t_min","precip","solar"), year.offset=0)

# experimental functions (may not work great; or at all!) lars2help(infile, outfile, year.offset, region) write.lars.scenario(file, dat1, dat2, name="anomaly")

Arguments

file
name of file; use extension *.sr for writing observed weather, and read.lars can read either *.sr observed files or *.dat synthetically generated files; file="",
infile
input file
outfile
output file
dat
data.frame of climate data
dat1
same as dat
dat2
same as dat
var
variables for each column (e.g., c("MAX","MIN","RAIN","RAD")); if missing, will try and use t_min, t_max, precip, and solar within names(dat)
start
either an integer starting year (assumed to be 1 of January), or a Date object of the exact date
end
either an integer ending year (assumed to be 31 of December), or a Date object of the exact date
head
names from file to be used for dat
year.offset
offset of years between file and what is needed in Rusing Date
region
region name for HELP file
name
name of scenario

synopsis

write.lars(file = "", dat, var, start, end) read.lars(file,head=c("year","yday","t_max","t_min","precip","solar"), year.offset=0) lars2help(infile,outfile, year.offset, region) write.lars.scenario(file, dat1, dat2, name="anomaly")

Details

These functions interface with the LARS-WG files. The variable headers are not located within the *.sr or *.dat files, so they need to be explicitly defined using the var parameter. These should be the same found in the station file, with *.st extension, which is used exclusively be LARS-WG. However, the YEAR and JDAY variables do not need to be defined, since they are assumed to be in the first and second columns, respectively, and are automatically converted to and from the RDate object. Data exported from write.lars always has legal (according to the Gregorian calendar) and increasing sequence of days between start and end (even if there are gaps in dat). Missing data values are written as -99., as specified in the LARS-WG manual, Version 4.0.

lars2help and write.lars.scenario are experimental functions to translate data between LARS and HELP (see write.help for more info).

References

LARS-WG was developed by M.A. Semenov, and can be downloaded for academic and research interests from http://www.rothamsted.bbsrc.ac.uk/mas-models/larswg.php

See Also

write.help, read.sdsm