lars                  package:seas                  R Documentation

_R_e_a_d _a_n_d _w_r_i_t_e _d_a_t_a _f_r_o_m _L_A_R_S-_W_G _f_i_l_e _f_o_r_m_a_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Read and write data from the LARS-WG stochastic weather generator
     file formats; also convert to a format for HELP

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

  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
          'write.lars', if this variable is 'NA' or 'FALSE', this file
          will not be written (however, 'datfile' must be defined)

 datfile: file name with either '*.sr' or '*.dat' extension; contains
          climate data, as described by 'stfile'; this does not need to
          be set if 'stfile' is defined, as this datum is found in the
          'st' file

    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: 'data.frame' of climate data

      x1: same as 'x'

      x2: same as 'x'

year.offset: offset of years between what is contained in the data
          files and what is needed in R to produce a reasonable
          ''Date''; this is required, for example, if synthetic data
          are produced that start from an arbitrary year '1' but
          represent climate from the year '2000'

    site: same as '[SITE]' in 'st' file; if missing, this will try to
          read from 'attr(x$name)'; this is the same as a 'region' for
          HELP

    name: scenario name

     lat: same as 'LAT' in 'st' file; if missing, this will try to be
          read from 'attr(x$latitude)'

     lon: same as 'LON' in 'st' file; if missing, this will try to be
          read from 'attr(x$longitude)'

     alt: same as 'ALT' in 'st' file; if missing, this will try to be
          read from 'attr(x$elevation)'

_D_e_t_a_i_l_s:

     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).

_A_u_t_h_o_r(_s):

     M.W. Toews

_R_e_f_e_r_e_n_c_e_s:

     LARS-WG was can be downloaded for academic and research uses from 
      <URL: http://www.rothamsted.bbsrc.ac.uk/mas-models/larswg.php>

     Semenov, M.A. and Barrow, E.M. (1997) "Use of a stochastic weather
     generator in the development of climate change scenarios".
     _Climate Change_: *35*, 397-414. doi: 10.1023/A:1005342632279

_S_e_e _A_l_s_o:

     'write.help', 'read.sdsm', 'summerland' example synthetic data,
     'conv365toGregorian'

_E_x_a_m_p_l_e_s:

     stfile <- system.file("data/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")])
     plot.seas.temp(summ)

     # plot solar radiation
     plot.seas.var(summ,"solar")

     # plot precipitation
     summ.ss <- seas.sum(summ)
     image(summ.ss)
     plot(seas.norm(summ.ss))

