replacemetvar: Replace a weather variable

Description Usage Arguments Value Author(s) Examples

Description

Replaces one (or more) of the weather variables in the met.dat file.

Usage

1
2
3
4
5
replacemetdata(metdfr, oldmetfile = "met.dat", columns = NULL,
  newmetfile = "met.dat", khrs = NA, setdates = TRUE)

replacemetvar(replacevar, newvalues, oldmetfile = "met.dat",
  newmetfile = "metNEW.dat")

Arguments

metdfr

Dataframe with met data, to be pasted into a met.dat file.

oldmetfile

Default name of the met.dat file that will be modified.

columns

Optional character string : if the 'Columns' statement in the met.dat file is to be replaced.

newmetfile

Name of the new met.dat file.

khrs

Optional. Number of timesteps per day (by default, read from the met.dat file).

setdates

Logical. If TRUE, fixes the start and end date in the new met file.

replacevar

Character. Name(s) of the variable to be replaced.

newvalues

Vector of new values for the weather variable, has to be the same length as the number of records in the met.dat file.

Value

Returns nothing.

Author(s)

Remko Duursma

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 

#:::1.::: Replace precipitation with random number between 0 and 2.
# First find out how many records there are:
nrecords <- nrow(readmet("met.dat"))

# Make new rain
newrain <- runif(nrecords, 0, 2)

# And replace
replacemetvar("PPT",newrain,"met.dat", "newmet.dat")


#:::2.::: Replace multiple weather variables.
newtair <- runif(nrecords, 0, 35)

# Have to make a matrix of the variables to be replaced:
newmat <- matrix(cbind(newrain, newtair),ncol=2)

# And give a vector of variable names --in the same order as in the matrix!!--.
replacemetvar(c("PPT","TAIR"), newmat, "met.dat", "newmet.dat")



## End(Not run)

Maeswrap documentation built on May 2, 2019, 7:58 a.m.