Description Usage Arguments Author(s) Examples
A function to read output.* files from SWAT200* runs.
1 | readSWAT(outfile_type)
|
outfile_type |
outfile_type ie. "sub","rch",etc. |
Daniel R. Fuka
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## The function is currently defined as
function(outfile){
if (outfile=="sub"){
varformat="x6,a4,1x,a8,1x,a4,a10,30a10"
dataformat="x6,i4,1x,i8,1x,i4,f10,30f10"
} else if (outfile=="rch"){
varformat="x6,a4,1x,a8,1x,a5,30a12"
dataformat="x6,i4,1x,i8,1x,i5,30f12"
} else { print ("You need to add your file type to this function if it is not output.sub or output.rch")}
print(varformat)
print(dataformat)
vfrformat = unlist(strsplit(as.character(varformat), ","))
dfrformat = unlist(strsplit(as.character(dataformat), ","))
outvars=read.fortran(paste("output.",outfile,sep=""),vfrformat,skip=8,nrows=1)
outdata=read.fortran(paste("output.",outfile,sep=""),dfrformat,skip=9,col.names=outvars)
return(outdata)
}
|
Loading required package: EcoHydRology
Loading required package: operators
Attaching package: 'operators'
The following objects are masked from 'package:base':
options, strrep
Loading required package: topmodel
Loading required package: DEoptim
Loading required package: parallel
DEoptim package
Differential Evolution algorithm in R
Authors: D. Ardia, K. Mullen, B. Peterson and J. Ulrich
Loading required package: XML
function (outfile)
{
if (outfile == "sub") {
varformat = "x6,a4,1x,a8,1x,a4,a10,30a10"
dataformat = "x6,i4,1x,i8,1x,i4,f10,30f10"
}
else if (outfile == "rch") {
varformat = "x6,a4,1x,a8,1x,a5,30a12"
dataformat = "x6,i4,1x,i8,1x,i5,30f12"
}
else {
print("You need to add your file type to this function if it is not output.sub or output.rch")
}
print(varformat)
print(dataformat)
vfrformat = unlist(strsplit(as.character(varformat), ","))
dfrformat = unlist(strsplit(as.character(dataformat), ","))
outvars = read.fortran(paste("output.", outfile, sep = ""),
vfrformat, skip = 8, nrows = 1)
outdata = read.fortran(paste("output.", outfile, sep = ""),
dfrformat, skip = 9, col.names = outvars)
return(outdata)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.