# Load HYPEtools Package
library(HYPEtools)
# Get Path to HYPEtools Model Example Files
model_path <- system.file("demo_model", package = "HYPEtools")
# List HYPE Model Example Files
list.files(model_path)
#> [1] "AquiferData_Example.txt" "ClassData.txt"
#> [3] "FloodData_Example.txt" "ForcKey.txt"
#> [5] "GeoClass.txt" "GeoData.txt"
#> [7] "Pobs.txt" "PointSourceData.txt"
#> [9] "Qobs.txt" "Tobs.txt"
#> [11] "Xobs.txt" "description.txt"
#> [13] "filedir.txt" "gis"
#> [15] "info.txt" "optpar.txt"
#> [17] "par.txt" "pmsf.txt"
#> [19] "results"
More information on the different types of HYPE model files can be found on the HYPE Wiki: http://hype.smhi.net/wiki/doku.php?id=start:hype_file_reference
# Import Files
gd <- ReadGeoData(file.path(model_path, "GeoData.txt"))
gc <- ReadGeoClass(file.path(model_path, "GeoClass.txt"))
#> 14 data columns in imported file.
# Some Import Checks
summary(gd)
#>
#> Columns, except 'SLC_n', 'SCR_n', and 'DHSLC_n':
#>
#> column name class | column name class | column name
#> 1 SUBID integer | 4 AREA numeric | 13 SLOPE_MEAN
#> 2 MAINDOWN integer | 5 PARREG integer | 14 ICATCH
#> 3 LAKEDATAID integer | 6 RIVLEN numeric | 15 LAKE_DEPTH
#> class
#> numeric
#> numeric
#> numeric
#>
#> mean median minimum maximum
#> Sub-basin area (km2): 13.8 11.1 0.0721 62.6
#> Unit river length (km/km2): 0.518 0.246 0.000807 3.63
#> ilake drainage area fraction (-): 0.301 0.3 0.3 0.319
#>
#> Number of sub-basins: 25
#> ID(s) of outlets in 'maindown': 3606
#> Number of SLC classes: 6
#> Number of SCR classes: 0
#> Number of DHSLC classes: 0
#> SLC columns: c(7:12)
str(gc)
#> 'data.frame': 6 obs. of 14 variables:
#> $ slc : int 1 2 3 4 5 6
#> $ landuse : int 1 1 3 2 2 3
#> $ soil : int 1 1 1 1 2 2
#> $ cropid1 : int 0 0 0 0 0 0
#> $ cropid2 : int 0 0 0 0 0 0
#> $ rotation : int 0 0 0 0 0 0
#> $ vegtype : int 1 1 1 1 1 1
#> $ special : int 1 2 0 0 0 0
#> $ tiledepth : int 0 0 0 0 0 0
#> $ streamdepth: num 0 0 0.6 1 1 0.75
#> $ nsoils : int 1 1 3 3 3 3
#> $ depth1 : num 10 10 0.25 0.25 0.25 0.25
#> $ depth2 : num NA NA 0.5 0.75 0.75 0.5
#> $ depth3 : num NA NA 0.75 1.5 1.5 1
#> - attr(*, "comment")= chr [1:3] "!Landuses: 1=Water; 2=Coniferous forest; 3=Agricultural land\t\t\t\t\t\t\t\t\t\t\t\t\t" "!Soils: 1=Fine soil; 2=Coarse soil\t\t\t\t\t\t\t\t\t\t\t\t\t" "!Combination\tLanduse\tSoil\tCropid-main\tCropid-2nd\tRotation\tVegetationstyp\tSpecial-class\tTile-depth\tDrai"| __truncated__
class(gd)
#> [1] "HypeGeoData" "data.frame"
# Import Discharge Observations
qobs <- ReadObs(file.path(model_path, "Qobs.txt"))
str(qobs)
#> 'data.frame': 365 obs. of 2 variables:
#> $ DATE : POSIXct, format: "2001-01-01" "2001-01-02" ...
#> $ X3587: num 5.09 5 5 5 5.01 ...
#> - attr(*, "obsid")= int 3587
#> - attr(*, "timestep")= chr "day"
#> - attr(*, "variable")= chr "rout"
# Get SUBIDs with observations from attribute
obsid(qobs)
#> [1] 3587
# Import Parameter File
par <- ReadPar(file.path(model_path, "par.txt"))
str(par)
#> List of 57
#> $ !! : chr "Parameter Values"
#> $ !! : num(0)
#> $ !! : chr "General"
#> $ cevpam : num 0.25
#> $ cevpph : num 67.5
#> $ damp : num 0.5
#> $ epotdist : num 3
#> $ gldepi : num 3.6
#> $ grata : num 0.6
#> $ gratk : num 0.283
#> $ gratp : num 2
#> $ lp : num 0.95
#> $ qmean : num 200
#> $ rcgrw : num 0
#> $ rivvel : num 1
#> $ rrcs3 : num 2e-04
#> $ sdnsnew : num 0.09
#> $ sdnsmax : num 0.5
#> $ sdnsrate : num 0.015
#> $ sdnsradd : num 0.026
#> $ tcalt : num 0.6
#> $ ttpi : num 3
#> $ pcelevth : num 500
#> $ pcelevadd: num 0.04
#> $ pcelevmax: num 0.04
#> $ !! : num(0)
#> $ !! : chr "Landuses 1=Water 2=Coniferous forest 3=Agricultural land"
#> $ cevp : num [1:3] 0.175 0.22 0.215
#> $ cmlt : num [1:3] 2.8 1.9 3.5
#> $ frost : num [1:3] 2 2 2
#> $ srrcs : num [1:3] 0.4 0.2 0.3
#> $ ttmp : num [1:3] 0.2 0.3 0.2
#> $ !! : num(0)
#> $ !! : chr "Soils 1=Fine soil 2=Coarse soil"
#> $ mperc1 : num [1:2] 20 25
#> $ mperc2 : num [1:2] 20 25
#> $ rrcs1 : num [1:2] 0.6 0.1
#> $ rrcs2 : num [1:2] 0.04 0.03
#> $ sfrost : num [1:2] 1 1
#> $ srrate : num [1:2] 0.05 0.025
#> $ trrcs : num [1:2] 0.3 0.15
#> $ wcep1 : num [1:2] 0.01 0.07
#> $ wcep2 : num [1:2] 0.01 0.0595
#> $ wcep3 : num [1:2] 0.01 0.049
#> $ wcfc1 : num [1:2] 0.15 0.15
#> $ wcfc2 : num [1:2] 0.15 0.15
#> $ wcfc3 : num [1:2] 0.15 0.15
#> $ wcwp1 : num [1:2] 0.15 0.05
#> $ wcwp2 : num [1:2] 0.15 0.05
#> $ wcwp3 : num [1:2] 0.15 0.05
#> $ !! : num(0)
#> $ !! : chr "PARREG 1"
#> $ preccorr : num -0.24
#> $ cevpcorr : num -0.29
#> $ tempcorr : num -0.4
#> $ ratcorr : num -0.813
#> $ rrcscorr : num -0.79