lars | R Documentation |
Read and write data from the LARS-WG stochastic weather generator file formats; also convert to a format for HELP
# read synthetic or observed *.st file read.lars(stfile, year.offset = 0) # write observed climate data (*.st and/or *.sr) write.lars(x, stfile, datfile, site, lat, lon, alt) # experimental functions (may not work great; or at all!) lars2help(infile, outfile, year.offset, site) write.lars.scenario(file, x1, x2, name = "anomaly")
stfile |
file name with ‘*.st’ extension; this is a
‘site file’ for LARS-WG which contains meta-data for the
climate data, and has the location of the the climate data file; for
|
datfile |
file name with either ‘*.sr’ or ‘*.dat’
extension; contains climate data, as described by |
file |
file name with a ‘*.sce’ extension; this is a ‘scenario’ file with absolute and relative changes of climate data |
infile |
input file |
outfile |
output file |
x |
|
x1 |
same as |
x2 |
same as |
year.offset |
offset of years between what is contained in the
data files and what is needed in R to produce a reasonable
‘ |
site |
same as ‘[SITE]’ in ‘st’ file; if missing,
this will try to read from |
name |
scenario name |
lat |
same as ‘LAT’ in ‘st’ file; if missing, this
will try to be read from |
lon |
same as ‘LON’ in ‘st’ file; if missing, this
will try to be read from |
alt |
same as ‘ALT’ in ‘st’ file; if missing, this
will try to be read from |
These functions interface with the LARS-WG files (Version 4.0), which is a stochastic weather generator by Mikhail Semenov.
The climate data files used with LARS-WG have two parts: (1)~a ‘site file’ with a ‘st’ extension, containing the meta-data; and (2)~a data file with a ‘*.sr’ or ‘*.dat’ extension, containing all the data. The variable names are translated according to the following table:
seas | LARS-WG |
year | ‘YEAR’ |
yday | ‘JDAY’ |
t_min | ‘MIN’ |
t_max | ‘MAX’ |
preicp | ‘RAIN’ |
solar | ‘RAD’ |
sun | ‘SUN’ |
pet | ‘PET’ |
To write climate data from R to a LARS-WG file, the data.frame
names need to match those in the seas-side of the table.
Data exported from write.lars
always has legal (according to
the Gregorian calendar) and increasing sequence of days (even if there
are gaps in x$date
). Missing data values are written as
-99
.
Synthetically generated data from LARS-WG use a 365-day calendar, and
may need to be converted to a Gregorian calendar, which can be done
using conv365toGregorian
.
lars2help
and write.lars.scenario
are experimental
functions to translate data between LARS and HELP (see
write.help
for more info).
Mike Toews
LARS-WG was can be downloaded for academic and research uses from
http://resources.rothamsted.ac.uk/mas-models/larswg
Semenov, M.A. and Barrow, E.M. 1997. Use of a stochastic weather generator in the development of climate change scenarios. Climate Change, 35 (4), 397–414, doi: 10.1023/A:1005342632279
write.help
, read.sdsm
,
summerland
example synthetic data,
conv365toGregorian
stfile <- system.file("extdata", "summerland.st", package="seas") print(stfile) summ <- read.lars(stfile, year.offset=1960) head(summ) str(summ) # plot temperature summ$t_mean <- rowMeans(summ[, c("t_min", "t_max")]) seas.temp.plot(summ) # plot solar radiation seas.var.plot(summ, "solar") # plot precipitation summ.ss <- seas.sum(summ) image(summ.ss) plot(seas.norm(summ.ss))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.