write_input_swat2012_pcp: Write out precipitation SWAT 2012 meteorology input file

Description Usage Arguments Examples

Description

Write out precipitation SWAT 2012 meteorology input file

Usage

1
2
3
write_input_swat2012_pcp(file, data, stations, station_names,
  col_time_name = "time_posix", col_station_name = "station_name",
  col_lon = "lon", col_lat = "lat", col_elev = "elev")

Arguments

file

string: directory + file name of output file

data

data.frame: precipitation [mm]; contains a column with time stamp and >=1 columns with data; time column needs to be of type POSIXct

stations

data.frame : contains station information in four columns: station name, lon coordinate, lat coordinate, and elevation

station_names

character-array: contains names of the stations to write out; have to be equal to column names of data

col_time_name

character, optional: name of the time stamp column in 'data', default = 'time_posix'

col_station_name

character, optional: name of the station names column in 'stations', default = 'station_name'

col_lon

character, optional: name of the longitude column in 'stations', default = 'lon'

col_lat

character, optional: name of the latitude column in 'stations', default = 'lat'

col_elev

character, optional: name of the elevation column in 'stations', default = 'elev'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# see example in README

explanation of the following command:
  - make time column:
      format(data[[time_name]],"%Y%m%d")
  - format the individual values of the data column:
      formatC(as.matrix(my_data[station_names]), format='f', width=8, digits=3, flag='0')
     We need 'as.matrix' because my_data is a data frame. formatC cannot be applied to a 2d data frame.
  - append all formatted data values in one row:
      apply(formatC(...), 1, paste0, collapse = '')

neumannd/eurocordex2swatTools documentation built on May 14, 2019, 2:17 p.m.