replacemetdata {Maeswrap} | R Documentation |
Replace a weather variable
Description
Replaces one (or more) of the weather variables in the met.dat file.
Usage
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
## 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)
[Package Maeswrap version 1.7 Index]