diff --git a/.Rbuildignore b/.Rbuildignore index eb5115b..19084a7 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,7 +1,10 @@ -.gitattributes -.gitignore -.RData -.Rhistory +^\.gitattributes$ +^\.gitignore$ +^\.RData$ +^\.Rhistory$ +^Makefile$ +^\.travis\.yml$ + extdata/.*[.]csv$ extdata/.*[.]kml$ extdata/.*[.]md$ diff --git a/.gitignore b/.gitignore index 743353f..4a04b18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ -/20*/ /.RData /.Rhistory /*.tar.gz /*.zip + +/src-i386 +/src-x64 + Thumbs.db diff --git a/DESCRIPTION b/DESCRIPTION index 45b8516..fbcf7b3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,26 +1,44 @@ Package: wrv -Type: Package -Version: 1.0.3 -Date: 2016-8-12 Title: Wood River Valley Groundwater-Flow Model -Author: Jason C. Fisher -Maintainer: Jason C. Fisher -Depends: R (>= 3.2.0), sp, rgdal, raster -Imports: methods, rgeos, igraph, dplyr -Suggests: RCurl, knitr, xtable, sfsmisc, animation, viridis, colorspace -SystemRequirements: PEST (>= 13.0, optional) +Version: 1.1.0 +Authors@R: person("Jason", "Fisher", email="jfisher@usgs.gov", role=c("aut", "cre")) Description: A processing program for the groundwater-flow model of the Wood - River Valley aquifer system, south-central Idaho. Included in the package is - MODFLOW-USG version 1.2, a U.S. Geological Survey groundwater-flow model. + River Valley aquifer system, south-central Idaho. Included in the package is + MODFLOW-USG version 1.3, a U.S. Geological Survey groundwater-flow model. +Depends: + R (>= 3.2.0) +Imports: + dplyr, + grDevices, + graphics, + inlmisc, + methods, + sp, + stats, + raster, + rgdal, + rgeos +Suggests: + animation, + dataRetrieval, + git2r, + knitr, + leaflet, + sfsmisc, + viridis, + xtable +SystemRequirements: PEST (>= 13.0, optional) License: CC0 Copyright: This software is in the public domain because it contains materials - that originally came from the United States Geological Survey (USGS), an - agency of the United States Department of Interior. For more information, see - the official USGS copyright policy at - http://www.usgs.gov/visual-id/credit_usgs.html#copyright + that originally came from the United States Geological Survey (USGS), an + agency of the United States Department of Interior. For more information, + see the official USGS copyright policy at + https://www2.usgs.gov/visual-id/credit_usgs.html URL: https://github.com/USGS-R/wrv BugReports: https://github.com/USGS-R/wrv/issues -ByteCompile: yes -LazyData: yes +Encoding: UTF-8 +ByteCompile: true +LazyData: true LazyDataCompression: xz VignetteBuilder: knitr +RoxygenNote: 5.0.1 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7051572 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +# prepare the package for release + +PKGNAME := $(shell sed -n "s/Package: *\([^ ]*\)/\1/p" DESCRIPTION) +PKGVERS := $(shell sed -n "s/Version: *\([^ ]*\)/\1/p" DESCRIPTION) +PKGSRC := $(shell basename `pwd`) +APPXC := sir20165080_AppendixC + +all: docs install check clean + +docs: + R -q -e 'devtools::document()';\ + R -q -e 'devtools::clean_dll()';\ + +build: + cd ..;\ + R CMD build --no-build-vignettes $(PKGSRC);\ + +install: build + cd ..;\ + R CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz;\ + +check: + cd ..;\ + R CMD check --no-build-vignettes --as-cran $(PKGNAME)_$(PKGVERS).tar.gz;\ + +rd2tex: + cd ..;\ + R CMD Rd2pdf --no-clean --no-preview --force $(PKGSRC);\ + cp -f .Rd2pdf*/Rd2.tex $(PKGSRC)/inst/misc;\ + $(RM) $(PKGSRC).pdf;\ + $(RM) -r .Rd2pdf*;\ + +vignettes: rd2tex + R -q -e 'devtools::build_vignettes()';\ + R -q -e 'tools::compactPDF(paths='\''inst/doc'\'', gs_quality='\''ebook'\'')';\ + +datasets: + cd ..;\ + R -q -e 'knitr::purl(input='\''$(PKGSRC)/vignettes/$(APPXC).Rnw'\'')';\ + Rscript $(APPXC).R + mkdir -p $(PKGSRC)/data;\ + cp -i data/*.rda $(PKGSRC)/data;\ + $(RM) $(APPXC).R;\ + $(RM) -r data;\ + +clean: + cd ..;\ + $(RM) -r $(PKGNAME).Rcheck/;\ + +.PHONY: all docs build install check rd2tex vignettes datasets clean diff --git a/NAMESPACE b/NAMESPACE index a982103..64a5c14 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,44 +1,9 @@ - -importFrom("grDevices", "axisTicks", "col2rgb", "dev.cur", "dev.new", "dev.off", - "dev.size", "extendrange", "grey", "png", "rainbow", "xy.coords") -importFrom("graphics", "abline", "arrows", "axTicks", "axis", "axis.Date", - "box", "grconvertX", "grconvertY", "layout", "matplot", "mtext", - "par", "plot.new", "plot.window", "polygon", "rect", "segments", - "strheight", "strwidth", "symbols", "title") -importFrom("methods", "as", "slot", "slot<-") -importFrom("stats", "approxfun", "dist", "integrate", "median", "na.omit", "sd") -importFrom("utils", "read.csv", "untar", "unzip", "write.csv", "write.table") - -import("sp", "rgdal", "raster") - -importFrom("rgeos", "append.poly", "gArea", "gBuffer", "gCentroid", - "gDifference", "gDistance", "gIntersection", "gIntersects", - "gIsValid", "gUnaryUnion", "gUnion") -importFrom("igraph", "clusters") -importFrom("dplyr", "arrange", "bind_rows", "filter", "group_by_", "left_join", - "mutate", "summarise_") - -export("AddBubbles", - "AddColorKey", - "AddInsetMap", - "AddScaleBar", - "BumpDisconnectCells", - "BumpRiverStage", - "DownloadFile", - "ExportRasterStack", - "ExtractAlongTransect", - "GetDaysInMonth", - "GetSeasonalMult", - "GetWellConfig", - "PlotCrossSection", - "PlotGraph", - "PlotMap", - "ReadModflowBinary", - "ReplaceInTemplate", - "RmSmallCellChunks", - "RunWaterBalance", - "SetPolygons", - "SummariseBudget", - "ToScientific", - "UpdateWaterBudget", - "WriteModflowInput") +# Generated by roxygen2: do not edit by hand + +export(GetSeasonalMult) +export(GetWellConfig) +export(RunWaterBalance) +export(UpdateWaterBudget) +export(WriteModflowInput) +import(raster) +import(sp) diff --git a/NEWS b/NEWS deleted file mode 100644 index 7c49835..0000000 --- a/NEWS +++ /dev/null @@ -1,330 +0,0 @@ -Changes in Version 1.0.3 - - o ... - - o Change file name from sir2016_5080_usgsdatarelease.xml to sir2016-5080_usgsdatarelease.xml, a Water Node request. - -Changes in Version 1.0.2 - - o Fix NOTES associated with running R CMD check. - - o Add published Scientific Investigations Report 2016-5080 to ./inst/doc folder. - -Changes in Version 1.0.1 - - o Place vignette source, R-code, and PDF (optimized for viewing) files in the ./inst/doc folder. - -Changes in Version 1.0.0 - - o Respond to Model Archive data release review comments. - - o Add report number to documentation. - -Changes in Version 0.8.1 - - o Move remote repository location from https://github.com/jfisher-usgs/wrv to https://github.com/USGS-R/wrv - - o Add BSD license for the .ReduceAmp function. - -Changes in Version 0.8.0 - - o Reorganize model archive to comply with new open data requirements. - - o Remove suggested git2r R-package, version control is no longer used when constructing the model archive. - - o Add USGS software disclaimer to the package startup message. - - o Fix bug that prevented package compilation on R version 3.3.0. - - o Address editorial review comments in package vignettes. - -Changes in Version 0.7.2 - - o Change LaTeX bibliography engine from natbib to biblatex. - -Changes in Version 0.7.1 - - o Fix bug with scientific-notation format of axis-tickmark labels in the PlotGraph function. - - o Calculate the relative composite sensitivity in the sensitivity dataset. - -Changes in Version 0.7.0 - - o Vignettes ready for editorial review. - - o Update PEST sensitivity dataset with results from final model calibration run. - -Changes in Version 0.6.4 - - o All colleague review comments pertaining to package vignettes have been addressed. - - o Fix bug in PlotMap function that was introduced with sp version 1.2-2. - Function sp::gridlines now returns the correct ID attribute order for labels "EW" and "NS". - - o Change default value for auto.flow.reduce argument in the WriteModflowInput function to FALSE. - -Changes in Version 0.6.3 - - o For sampling purposes the BumpRiverStage function requires a random number generator (RNG). - The RNG state is now set using the set.seed function and results are reproducible. - - o Add make.intervals argument to the PlotMap function. - -Changes in Version 0.6.2 - - o Add auto.flow.reduce argument to the WriteModflowInput function, its default is TRUE. - The MODFLOW-USG option "AUTOFLOWREDUCE" is now set for all model formulations, not just the "convertible" formulation. - Pumping rates that have been automatically reduced will be written to a model output file ("*.afr"). - - o Shorten a few of the long function names in order to tidy the manual vignette. - - o Add PEST sensitivity dataset, this will be updated after final calibration. - Plotting routines for this dataset were added to the miscellaneous vignette. - - o Fix minor bug with PlotCrossSection function that may have prevented improper cell coloring. - -Changes in Version 0.6.1 - - o Use more robust estimate of riverbed conductance. - - o Change number of time steps per stress period to 4, previously was 1. - - o Change format for package version numbering from #.#-# to #.#.# - -Changes in Version 0.6-0 - - o Fix bug in steady-state calculation using the ss.interval argument in the UpdateWaterBudget function. - -Changes in Version 0.5-6 - - o Add iwelcb argument to the UpdateWaterBudget function. - - o Require R version greater than or equal to 3.2, was previously 3.1. - - o Change UpdateWaterBudget function to write well configuration data to the "qa-well-config.csv" file. - - o Rename exported CSV files from "wrv-summary-*.csv" to "qa-*.csv", where the "qa" stands for quality assurance. - - o Add ss.interval argument to the UpdateWaterBudget function. - Specifying this interval overrides the default time period representing steady-state boundary conditions. - -Changes in Version 0.5-5 - - o River cells in lower model layers have been removed. - Cell geometries were changed to compensate for river stage elevations located beneath the bottom of a river cell. - -Changes in Version 0.5-3 - - o The criterion for selecting lower-layer river cells has changed from riverbed bottom to river stage. - -Changes in Version 0.5-2 - - o Consolidate ./inst/templates and ./inst/references folder files in ./inst/misc folder, and add README file. - - o Remove links to external package functions in manual. - This prevents broken links in manual vignette. - - o Add Rd2.tex file to facilitate building of vignette manual, see Rd2pdf command. - - o Add model.area field to "wrv-summary-incidental.csv"; see RunWaterBalanceModel function. - -Changes in Version 0.5-0 - - o Change UpdateWaterBudget-function argument to allow toggling of output units in summary tables. - - o Change file format for "wrv-summary-pumping.csv". - - o Rename vignettes to reflect report appendices. - - o Add suggested number of axis intervals as new arguments in the PlotGraph function. - - o Add ToLatexScientific function to format scientific notation as m x 10^n. - - o Add subreach.recharge dataset, used to calculate stream-aquifer flow-exchange ratios. - - o Revised GetWellConfig function to be more general; although, it's still hard-coded for three model layers. - - o Changed MODFLOW solver options NONLINMETH and IACL to 1 and 0 (were previously 2 and 2), respectively. - These new solver options coincide with the current PEST run. - - o Fixed minor bug in ReadModflowBinaryFile function that was causing it to get stuck in a continuous loop when a variable description was not recognized. - -Changes in Version 0.4-6 - - o Change October streamflows in the "Big Wood, Wood River Ranch to Stanton Crossing" reach to non-dry-bed conditions. - -Changes in Version 0.4-5 - - o Add dry-bed conditions to the "Big Wood, Wood River Ranch to Stanton Crossing" reach. - - o Add new vignette titled "Parameter Estimation of the Groundwater Flow Model". - - o The viridis and git2r R-packages are now suggested to improve plot colors and add version control to the model archive, respectively. - -Changes in Version 0.4-4 - - o Update tributary underflow datasets to account for the raw-data measurement resolution and the addition of a new tributary boundary at Oregon Gulch. - - o Add AddInsetMap function to draw an inset map in the current graphics device. - - o The animation R-package is now suggested and used to create animations showing the depth-to-water over time. - -Changes in Version 0.4-3 - - o The Hailey precipitation data was found to be much less than what is shown in the design document. - All precipitation data was recalculated from raw data and validated with the design document. - - o Add new vignette titled "Natural Groundwater Recharge". - - o Renamed vignette files. - -Changes in Version 0.4-2 - - o Fix error associated with the units of soil percolation rate; units changed from meters per day to meters per month. - - o Fix minor bug in the SetPolygons function that may have interfered with polygon intersections. - -Changes in Version 0.4-1 - - o Add new vignette titled "Incidental Recharge and Groundwater Pumping Demand". - - o Annual flow rate in the "BWR Upper" tributary canyon was changed from 145 acre-feet to 602 acre-feet. - - o Add PlotCrossSection, AddColorKey, and AddScaleBar functions. - - o Fix transient stream stage on Big Wood River between Hailey and Stanton Crossing streamgages. - - o Reference data filenames were changed back to "EFF.csv", "TRIB.csv", and "SEEP.csv". - -Changes in Version 0.4-0 - - o New package vignette "wrv-process" that begins to document the instructions for processing the calibrated model. - - o Reference data filenames were changed from "EFF.csv", "TRIB.csv", "SEEP.csv" to "EFF.ref", "TRIB.ref", "SEEP.ref", respectively. - - o Batch filenames were changed from "Run.bat", "Update.bat" to "RunModflow.bat", "UpdateBudget.bat", respectively. - - o Output from "wrv-model" vignette adheres to the recommended USGS model archive structure. - - o Add "README.md" to the "./inst/extdata/" folder; the files and folders were reorganized under this folder. - - o MODFLOW-USG (version 1.2) source code is included in the package source. - A MODFLOW-USG executable is included with the precompiled binary versions of the package. - -Changes in Version 0.3-0 - - o Add content to post-processing analysis of transient model simulation in the wrv-model vignette. - - o Improve performance for reading MODFLOW binary flow data in the ReadModflowBinaryFile function. - - o Add SummariseBudget function to summarize cell-by-cell flow for model boundary components. - - o The sfsmisc R-package is now suggested to improve figure axes labels. - -Changes in Version 0.2-7 - - o Write volumetric budget for every stress period, was previously only written for the last stress period. - - o The dplyr R-package is now required. - - o Change from using base::merge and stats::aggregate functions to dplyr equivalents. - Use of dplyr::left_join function will fix bug with base::merge auto-arranging row order. - - o Remove perianal dry-bed conditions for the "Big Wood, Wood River Ranch to Stanton Crossing" river reach. - -Changes in Version 0.2-6 - - o Normalize the Big Wood River gage-height using median rather than mean. - This prevents stream-stage elevations from being lower than streambed elevations. - -Changes in Version 0.2-5 - - o Change calculation for missing gage-height data at the USGS 13140800 streamgage. - -Changes in Version 0.2-4 - - o Modeling transient stage conditions in the Big Wood River. - - o Change option for reading hydraulic parameters in the model. - The model now expects Specific Storage rather than the Storage Coefficient. - - o Tidy help documentation. - -Changes in Version 0.2-3 - - o Improve computational efficiency of RunWaterBalanceModel function. - - o The UpdateWaterBudget function call in Update.bat now passes the default local directory. - -Changes in Version 0.2-2 - - o Account for recharge from miscellaneous seepage sites (Bypass Canal and Bellevue WWTP Ponds). - - o Add support for writing raster stack to disk as a KLM file. - - o Update numerous raw data files. - -Changes in Version 0.2-1 - - o Account for episodic dry periods in the stream reaches located between Glendale and Wood River Ranch. - Requires passing river data as a data.frame-class object to the WriteModflowInputFiles function. - - o Update SetPolygons function to handle point and line artifacts. - - o Tidy code for UpdateWaterBudget function and add output that is more descriptive. - - o Update numerous raw data files. - - o Revise area calculation in summary table for recharge on non-irrigated lands. - -Changes in Version 0.2-0 - - o Add UpdateWaterBudget function; only used during parameter estimation. - - o Add model options for (1) steady-state or transient conditions, (2) confined or convertible conditions, and (3) verbose output. - - o All areal recharge and specified flows in the major tributary canyons are placed in the MODFLOW Well Package. - The MODFLOW Recharge Package and MODFLOW Flow and Head Boundary Package are no longer in use. - - o Update numerous raw data files. - - o Fix bug with calculation of recharge on non-irrigated lands. - - o Revise calculation of river stage and river bottom elevations. - -Changes in Version 0.1-5 - - o Remove dependence on png package. - - o Components of recharge and pumping added to model. - - o The FindConnectedCells function was replaced by a new BumpDisconnectedCells function. - Model cells producing vertical disconnects between adjacent cells are no longer removed. - - o Many changes and additions to raw data files and package datasets. - - o Revise method for calculating groundwater inflow in the tributary canyons. - The GetSesonalMultiplier function was added to assist with the temporal distribution of flow in the tributary canyons. - - o The DownloadFile function attempts to re-download a file if the previous attempt fails. - -Changes in Version 0.1-4 - - o Add an additional hydrogeologic zone that is composed entirely of the alluvium unit under confined conditions. - The horizontal hydraulic conductivity for all hydrogeologic zones has been changed to better reflect values given by Bartolino and Adkins (2012, pg. 25-26). - - o New package vignette that documents the construction of package datasets. - - o There is no longer the need to specify the number of bytes when reading MODFLOW binary files in the ReadModflowBinaryFile function. - -Changes in Version 0.1-3 - - o Add ReadModflowListFile function to read and parse volumetric budget information from the MODFLOW listing file. - - o Simulate stream-aquifer flow exchange in the Big Wood River and Silver Creek. - - o Add SetPolygons function to determine the intersection or difference between two multi-polygon objects. - -Changes in Version 0.1-2 - - o First public release coinciding with Modeling Technical Advisory Committee meeting Dec. 2013. diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..7af6933 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,351 @@ +# wrv 1.1.0 + +- Add suggested package **leaflet**, allows the creation of interactive maps using the 'Leaflet' JavaScript library and the **htmlwidgets** package. + +- Update MODFLOW-USG version from 1.2 to 1.3, see [release notes](http://water.usgs.gov/ogw/mfusg/release.txt) for details. + +- Change NEWS file to markdown format. + +- Remove **RCurl** from suggested packages. + +- Recreate package datasets using Appendix C code, no significant changes were identified. + +- Pass datasets as arguments in the `UpdateWaterBudget` and `RunWaterBudget` functions; + these datasets were previously called from within the function. + +- Add code block identifiers in vignettes. + +# wrv 1.0.3 + +- Remove `DownloadFile` function and edit Appendix C to reflect this change. + +- Add Makefile for automating package-development tasks. + +- Change to in-source documentation using **roxygen2** package. + +- Change file name from sir2016_5080_usgsdatarelease.xml to sir2016-5080_usgsdatarelease.xml, a Water Node request. + +# wrv 1.0.2 + +- Fix NOTES associated with running `R CMD check`. + +- Add published Scientific Investigations Report 2016-5080 to ./inst/doc folder. + +# wrv 1.0.1 + +- Place vignette source, R-code, and PDF (optimized for viewing) files in the ./inst/doc folder. + +# wrv 1.0.0 + +- Respond to Model Archive data release review comments. + +- Add report number to documentation. + +# wrv 0.8.1 + +- Move remote repository location from https://github.com/jfisher-usgs/wrv to https://github.com/USGS-R/wrv + +- Add BSD license for the `.ReduceAmp` function. + +# wrv 0.8.0 + +- Reorganize model archive to comply with new open data requirements. + +- Remove suggested **git2r** R-package, version control is no longer used when constructing the model archive. + +- Add USGS software disclaimer to the package startup message. + +- Fix bug that prevented package compilation on R version 3.3.0. + +- Address editorial review comments in package vignettes. + +# wrv 0.7.2 + +- Change LaTeX bibliography engine from natbib to biblatex. + +# wrv 0.7.1 + +- Fix bug with scientific-notation format of axis-tickmark labels in the PlotGraph function. + +- Calculate the relative composite sensitivity in the sensitivity dataset. + +# wrv 0.7.0 + +- Vignettes ready for editorial review. + +- Update PEST sensitivity dataset with results from final model calibration run. + +# wrv 0.6.4 + +- All colleague review comments pertaining to package vignettes have been addressed. + +- Fix bug in PlotMap function that was introduced with **sp** version 1.2-2. + Function `sp::gridlines` now returns the correct ID attribute order for labels "EW" and "NS". + +- Change default value for `auto.flow.reduce` argument in the `WriteModflowInput` function to `FALSE`. + +# wrv 0.6.3 + +- For sampling purposes the `BumpRiverStage` function requires a random number generator (RNG). + The RNG state is now set using the set.seed function and results are reproducible. + +- Add make.intervals argument to the PlotMap function. + +# wrv 0.6.2 + +- Add auto.flow.reduce argument to the WriteModflowInput function, its default is `TRUE`. + The MODFLOW-USG option "AUTOFLOWREDUCE" is now set for all model formulations, not just the "convertible" formulation. + Pumping rates that have been automatically reduced will be written to a model output file ("*.afr"). + +- Shorten a few of the long function names in order to tidy the manual vignette. + +- Add PEST sensitivity dataset, this will be updated after final calibration. + Plotting routines for this dataset were added to the miscellaneous vignette. + +- Fix minor bug with PlotCrossSection function that may have prevented improper cell coloring. + +# wrv 0.6.1 + +- Use more robust estimate of riverbed conductance. + +- Change number of time steps per stress period to 4, previously was 1. + +- Change format for package version numbering from #.#-# to #.#.# + +# wrv 0.6-0 + +- Fix bug in steady-state calculation using the `ss.interval` argument in the `UpdateWaterBudget` function. + +# wrv 0.5-6 + +- Add `iwelcb` argument to the `UpdateWaterBudget` function. + +- Require R version greater than or equal to 3.2, was previously 3.1. + +- Change `UpdateWaterBudget` function to write well configuration data to the "qa-well-config.csv" file. + +- Rename exported CSV files from "wrv-summary-*.csv" to "qa-*.csv", where the "qa" stands for quality assurance. + +- Add `ss.interval` argument to the `UpdateWaterBudget` function. + Specifying this interval overrides the default time period representing steady-state boundary conditions. + +# wrv 0.5-5 + +- River cells in lower model layers have been removed. + Cell geometries were changed to compensate for river stage elevations located beneath the bottom of a river cell. + +# wrv 0.5-3 + +- The criterion for selecting lower-layer river cells has changed from riverbed bottom to river stage. + +# wrv 0.5-2 + +- Consolidate ./inst/templates and ./inst/references folder files in ./inst/misc folder, and add README file. + +- Remove links to external package functions in manual. + This prevents broken links in manual vignette. + +- Add Rd2.tex file to facilitate building of vignette manual, see `Rd2pdf` command. + +- Add model.area field to "wrv-summary-incidental.csv"; see `RunWaterBalanceModel` function. + +# wrv 0.5-0 + +- Change `UpdateWaterBudget` function argument to allow toggling of output units in summary tables. + +- Change file format for "wrv-summary-pumping.csv". + +- Rename vignettes to reflect report appendices. + +- Add suggested number of axis intervals as new arguments in the `PlotGraph` function. + +- Add `ToLatexScientific` function to format scientific notation as m x 10^n. + +- Add `subreach.recharge` dataset, used to calculate stream-aquifer flow-exchange ratios. + +- Revise `GetWellConfig` function to be more general; although, it's still hard-coded for three model layers. + +- Changed MODFLOW solver options NONLINMETH and IACL to 1 and 0 (were previously 2 and 2), respectively. + These new solver options coincide with the current PEST run. + +- Fixed minor bug in `ReadModflowBinaryFile` function that was causing it to get stuck in a continuous loop when a variable description was not recognized. + +# wrv 0.4-6 + +- Change October streamflows in the "Big Wood, Wood River Ranch to Stanton Crossing" reach to non-dry-bed conditions. + +# wrv 0.4-5 + +- Add dry-bed conditions to the "Big Wood, Wood River Ranch to Stanton Crossing" reach. + +- Add new vignette titled "Parameter Estimation of the Groundwater Flow Model". + +- The **viridis** and **git2r** R-packages are now suggested to improve plot colors and add version control to the model archive, respectively. + +# wrv 0.4-4 + +- Update tributary underflow datasets to account for the raw-data measurement resolution and the addition of a new tributary boundary at Oregon Gulch. + +- Add `AddInsetMap` function to draw an inset map in the current graphics device. + +- The R package **animation** is now suggested and used to create animations showing the depth-to-water over time. + +# wrv 0.4-3 + +- The Hailey precipitation data was found to be much less than what is shown in the design document. + All precipitation data was recalculated from raw data and validated with the design document. + +- Add new vignette titled "Natural Groundwater Recharge". + +- Renamed vignette files. + +# wrv 0.4-2 + +- Fix error associated with the units of soil percolation rate; units changed from meters per day to meters per month. + +- Fix minor bug in the `SetPolygons` function that may have interfered with polygon intersections. + +# wrv 0.4-1 + +- Add new vignette titled "Incidental Recharge and Groundwater Pumping Demand". + +- Annual flow rate in the "BWR Upper" tributary canyon was changed from 145 acre-feet to 602 acre-feet. + +- Add `PlotCrossSection`, `AddColorKey`, and `AddScaleBar` functions. + +- Fix transient stream stage on Big Wood River between Hailey and Stanton Crossing streamgages. + +- Reference data filenames were changed back to "EFF.csv", "TRIB.csv", and "SEEP.csv". + +# wrv 0.4-0 + +- New package vignette "wrv-process" that begins to document the instructions for processing the calibrated model. + +- Reference data filenames were changed from "EFF.csv", "TRIB.csv", "SEEP.csv" to "EFF.ref", "TRIB.ref", "SEEP.ref", respectively. + +- Batch filenames were changed from "Run.bat", "Update.bat" to "RunModflow.bat", "UpdateBudget.bat", respectively. + +- Output from "wrv-model" vignette adheres to the recommended USGS model archive structure. + +- Add "README.md" to the "./inst/extdata/" folder; the files and folders were reorganized under this folder. + +- MODFLOW-USG (version 1.2) source code is included in the package source. + A MODFLOW-USG executable is included with the precompiled binary versions of the package. + +# wrv 0.3-0 + +- Add content to post-processing analysis of transient model simulation in the wrv-model vignette. + +- Improve performance for reading MODFLOW binary flow data in the ReadModflowBinaryFile function. + +- Add SummariseBudget function to summarize cell-by-cell flow for model boundary components. + +- R-package **sfsmisc** is now suggested to improve figure axes labels. + +# wrv 0.2-7 + +- Write volumetric budget for every stress period, was previously only written for the last stress period. + +- R-package **dplyr** is now required. + +- Change from using `base::merge` and `stats::aggregate` functions to **dplyr** equivalents. + Use of `dplyr::left_join` function will fix bug with `base::merge` auto-arranging row order. + +- Remove perianal dry-bed conditions for the "Big Wood, Wood River Ranch to Stanton Crossing" river reach. + +# wrv 0.2-6 + +- Normalize the Big Wood River gage-height using median rather than mean. + This prevents stream-stage elevations from being lower than streambed elevations. + +# wrv 0.2-5 + +- Change calculation for missing gage-height data at the USGS 13140800 streamgage. + +# wrv 0.2-4 + +- Modeling transient stage conditions in the Big Wood River. + +- Change option for reading hydraulic parameters in the model. + The model now expects Specific Storage rather than the Storage Coefficient. + +- Tidy help documentation. + +# wrv 0.2-3 + +- Improve computational efficiency of `RunWaterBalanceModel` function. + +- The `UpdateWaterBudget` function call in Update.bat now passes the default local directory. + +# wrv 0.2-2 + +- Account for recharge from miscellaneous seepage sites (Bypass Canal and Bellevue WWTP Ponds). + +- Add support for writing raster stack to disk as a KLM file. + +- Update numerous raw data files. + +# wrv 0.2-1 + +- Account for episodic dry periods in the stream reaches located between Glendale and Wood River Ranch. + Requires passing river data as a `data.frame-class` object to the `WriteModflowInputFiles` function. + +- Update `SetPolygons` function to handle point and line artifacts. + +- Tidy code for `UpdateWaterBudget` function and add output that is more descriptive. + +- Update numerous raw data files. + +- Revise area calculation in summary table for recharge on non-irrigated lands. + +# wrv 0.2-0 + +- Add `UpdateWaterBudget` function; only used during parameter estimation. + +- Add model options for (1) steady-state or transient conditions, (2) confined or convertible conditions, and (3) verbose output. + +- All areal recharge and specified flows in the major tributary canyons are placed in the MODFLOW Well Package. + The MODFLOW Recharge Package and MODFLOW Flow and Head Boundary Package are no longer in use. + +- Update numerous raw data files. + +- Fix bug with calculation of recharge on non-irrigated lands. + +- Revise calculation of river stage and river bottom elevations. + +# wrv 0.1-5 + +- Remove dependence on **png** package. + +- Components of recharge and pumping added to model. + +- The `FindConnectedCells` function was replaced by a new `BumpDisconnectedCells` function. + Model cells producing vertical disconnects between adjacent cells are no longer removed. + +- Many changes and additions to raw data files and package datasets. + +- Revise method for calculating groundwater inflow in the tributary canyons. + The `GetSesonalMultiplier` function was added to assist with the temporal distribution of flow in the tributary canyons. + +- The `DownloadFile` function attempts to re-download a file if the previous attempt fails. + +# wrv 0.1-4 + +- Add an additional hydrogeologic zone that is composed entirely of the alluvium unit under confined conditions. + The horizontal hydraulic conductivity for all hydrogeologic zones has been changed to better reflect values given by Bartolino and Adkins (2012, pg. 25-26). + +- New package vignette that documents the construction of package datasets. + +- There is no longer the need to specify the number of bytes when reading MODFLOW binary files in the `ReadModflowBinaryFile` function. + +# wrv 0.1-3 + +- Add `ReadModflowListFile` function to read and parse volumetric budget information from the MODFLOW listing file. + +- Simulate stream-aquifer flow exchange in the Big Wood River and Silver Creek. + +- Add `SetPolygons` function to determine the intersection or difference between two multi-polygon objects. + +# wrv 0.1-2 + +- First public release coinciding with Modeling Technical Advisory Committee meeting Dec. 2013. diff --git a/R/AddBubbles.R b/R/AddBubbles.R deleted file mode 100644 index b82214f..0000000 --- a/R/AddBubbles.R +++ /dev/null @@ -1,172 +0,0 @@ -AddBubbles <- function(x, y=NULL, z, zlim=NULL, inches=c(0, 0.2), - scaling=c("perceptual", "mathematical"), - bg.pos="red", bg.neg="blue", fg=NA, lwd=0.25, - cex=0.7, format=NULL, draw.legend=TRUE, - loc=c("bottomleft", "topleft", "topright", "bottomright"), - inset=0.02, breaks=NULL, break.labels=NULL, - quantile.breaks=FALSE, make.intervals=FALSE, - title=NULL, subtitle=NULL, - add=TRUE) { - - xy <- xy.coords(x, y, - xlab=deparse(substitute(x)), - ylab=deparse(substitute(y))) - x <- xy$x - y <- xy$y - - if (is.numeric(zlim)) { - if (is.na(zlim[1])) zlim[1] <- min(z, na.rm=TRUE) - if (is.na(zlim[2])) zlim[2] <- max(z, na.rm=TRUE) - z[z < zlim[1] | z > zlim[2]] <- NA - } - is <- !is.na(z) - x <- x[is] - y <- y[is] - z <- z[is] - - if (is.null(breaks)) breaks <- pretty(z, n=6) - - if (quantile.breaks) { - breaks <- quantile(z, probs=seq(0, 1, 0.25)) - if (is.null(break.labels)) { - val <- formatC(breaks, format=format, big.mark=",") - lab <- c("minimum", "25th quartile", "median", - "75th quartile", "maximum") - break.labels <- sprintf("%s (%s)", val, lab) - } - } else if (make.intervals) { - interval <- findInterval(z, breaks, rightmost.closed=TRUE) - s <- formatC(breaks, format=NULL, big.mark=",") - ss <- sprintf("[%s, %s)", head(s, -1), tail(s, -1)) - if (any(interval == 0)) ss[1] <- sprintf("(-Inf, %s)", s[1]) - n <- length(breaks) - if (any(interval == n)) { - if (any(z == max(breaks))) - ss[length(ss)] <- sub(")$", "]", ss[length(ss)]) - else - ss[length(ss)] <- sprintf("[%s, Inf)", s[length(s) - 1L]) - } - if (is.null(break.labels)) break.labels <- ss - idxs <- findInterval(z, breaks, all.inside=TRUE) - breaks <- (head(breaks, -1) + tail(breaks, -1)) / 2 - z <- breaks[idxs] - } - - if (is.null(break.labels)) - break.labels <- formatC(breaks, format=format, big.mark=",") - - if (!add) plot(NA, type="n", xlim=extendrange(x), ylim=extendrange(y), - xlab="x", ylab="y") - - if (is.na(inches[1])) inches[1] <- 0 - if (is.na(inches[2])) inches[2] <- 0.2 - min.r <- diff(grconvertX(c(0, inches[1]), from="inches", to="user")) - max.r <- diff(grconvertX(c(0, inches[2]), from="inches", to="user")) - min.r - - scaling <- match.arg(scaling) - if (scaling == "mathematical") - Scale <- function(v, max.v, max.r) {return(sqrt(v / max.v) * max.r)} - else - Scale <- function(v, max.v, max.r) {return(((v / max.v)^0.57) * max.r)} - r <- Scale(abs(z), max(abs(c(z, breaks))), max.r) + min.r - - cols <- rep("#02080D", length(z)) - if (is.function(bg.neg)) - cols[z < 0] <- .Map2Color(abs(z[z < 0]), bg.neg) - else - cols[z < 0] <- bg.neg - if (is.function(bg.pos)) - cols[z > 0] <- .Map2Color(z[z > 0], bg.pos) - else - cols[z > 0] <- bg.pos - - idxs <- order(r, decreasing=TRUE) - fg.cols <- if (is.null(fg)) cols[idxs] else fg - symbols(x[idxs], y[idxs], circles=r[idxs], bg=cols[idxs], fg=fg.cols, - inches=FALSE, add=TRUE, lwd=lwd) - - if (draw.legend) { - ipad <- strwidth("0", cex=cex) # arbitrary choice for inner padding - - lab.width <- max(strwidth(break.labels, cex=cex)) - - usr <- par("usr") - padx <- inset * diff(usr[1:2]) - pady <- inset * diff(usr[3:4]) - - r <- Scale(abs(breaks), max(abs(c(z, breaks))), max.r) + min.r - - gap <- max(c(median(r), strheight("O", cex=cex) * 1.5)) - - s <- vapply(seq_along(r), function(i) sum(r[1:i]), 0) - s <- ipad + gap + 2 * s - r + (seq_along(r) - 1L) * gap - - dx <- ipad + max(r) * 2 + ipad + lab.width + ipad - dy <- max(s) + r[length(r)] + ipad * 2 - - if (!is.null(title)) { - title.width <- strwidth(title, cex=cex, font=2) + ipad * 2 - if (dx < title.width) dx <- title.width - title.height <- strheight(title, cex=cex, font=2) - dy <- dy + title.height + ipad - } - - if (!is.null(subtitle)) { - subtitle.width <- strwidth(subtitle, cex=cex) + ipad * 2 - if (dx < subtitle.width) dx <- subtitle.width - subtitle.height <- strheight(subtitle, cex=cex) * 1.5 - dy <- dy + subtitle.height - } - - loc <- match.arg(loc) - if (loc == "bottomleft") { - loc <- c(usr[1] + padx, usr[3] + pady) - } else if (loc == "topleft") { - loc <- c(usr[1] + padx, usr[4] - pady - dy) - } else if (loc == "topright") { - loc <- c(usr[2] - padx - dx, usr[4] - pady - dy) - } else if (loc == "bottomright") { - loc <- c(usr[2] - padx - dx, usr[3] + pady) - } - - rect(loc[1], loc[2], loc[1] + dx, loc[2] + dy, - col="#FFFFFFE7", border="black", lwd=0.5) - - x <- rep(loc[1] + ipad + max(r), length(r)) - y <- loc[2] + s - - cols <- rep("#02080D", length(breaks)) - if (is.function(bg.neg)) - cols[breaks < 0] <- .Map2Color(abs(breaks[breaks < 0]), bg.neg) - else - cols[breaks < 0] <- bg.neg - if (is.function(bg.pos)) - cols[breaks > 0] <- .Map2Color(breaks[breaks > 0], bg.pos) - else - cols[breaks > 0] <- bg.pos - fg.cols <- if (is.null(fg)) cols else fg - symbols(x, y, circles=r, bg=cols, fg=fg.cols, inches=FALSE, add=TRUE, - lwd=lwd) - - text(loc[1] + ipad + max(r) * 2 + ipad, y, break.labels, - adj=c(0, 0.5), cex=cex) - - if (!is.null(title)) - text(loc[1] + dx / 2, loc[2] + dy - ipad, title, - adj=c(0.5, 1), cex=cex, font=2) - - if (!is.null(subtitle)) - text(loc[1] + dx / 2, loc[2] + dy - subtitle.height - title.height - ipad, - subtitle, adj=c(0.5, 0), cex=cex) - } - - invisible(NULL) -} - -## - -.Map2Color <- function(x, Pal, xlim=NULL, n=100L){ - if (length(x) == 0) return(NULL) - if (is.null(xlim)) xlim <- range(x) - Pal(n)[findInterval(x, seq(xlim[1], xlim[2], length.out=n), all.inside=TRUE)] -} diff --git a/R/AddColorKey.R b/R/AddColorKey.R deleted file mode 100644 index 4931f54..0000000 --- a/R/AddColorKey.R +++ /dev/null @@ -1,68 +0,0 @@ -AddColorKey <- function(mai, is.categorical, breaks, col, at=NULL, - labels=TRUE, scientific=FALSE, explanation=NULL, - padx=0.2) { - - if (!missing(mai)) { - mai[2] <- mai[2] + padx - mai[4] <- mai[4] + padx - op <- par(mai=mai) - on.exit(par(op)) - } - - if (is.categorical) { - n <- max(c(if (missing(col)) 0 else length(col), length(labels))) - at <- seq_len(n) - if (length(n) == 0) - stop("categorical data requires colors and (or) labels") - breaks <- c(0.5, seq_len(n) + 0.5) - } else if (missing(breaks)) { - stop("missing breaks argument for continous data") - } - - if (missing(col)) col <- rainbow(length(breaks) - 1L, start=0.0, end=0.8) - - if (is.null(at)) at <- breaks - - cex <- 0.7 - lwd <- 0.5 - - xlim <- range(breaks) - plot(NA, type="n", xlim=xlim, ylim=c(0, 1), xaxs="i", yaxs="i", bty="n", - xaxt="n", yaxt="n", xlab="", ylab="") - - if (is.categorical) { - bw <- 2 / 6 - pin <- par("pin") - repeat { - if (bw < pin[1] || bw == 0.1) break - bw <- bw - 0.1 - } - dx <- (diff(xlim) / pin[1]) * bw / 2 - x <- seq_along(col) - rect(xleft=x - dx, ybottom=0, xright=x + dx, ytop=1, col=col, border=NA) - } else { - rect(xleft=head(breaks, -1), ybottom=0, xright=tail(breaks, -1), ytop=1, - col=col, border=col, lwd=lwd) - if (length(at) >= length(breaks) - 1L) { - abline(v=breaks, lwd=lwd) - } else { - segments(x0=at, y0=0, y1=0.25, lwd=lwd) - segments(x0=at, y0=1, y1=0.75, lwd=lwd) - } - box(lwd=lwd) - } - - if (is.logical(labels) && labels) { - labels <- if (is.null(at)) axTicks(1) else at - if (scientific) - labels <- ToScientific(labels, lab.type="plotmath") - else - labels <- formatC(labels, big.mark=",") - } - - axis(1, at=at, labels=labels, lwd=-1, lwd.ticks=-1, cex.axis=cex, padj=0, - mgp=c(3, 0, 0)) - - if (!is.null(explanation)) - mtext(explanation, side=3, line=0.6, padj=1, adj=0, cex=cex) -} diff --git a/R/AddInsetMap.R b/R/AddInsetMap.R deleted file mode 100644 index 1dca0ea..0000000 --- a/R/AddInsetMap.R +++ /dev/null @@ -1,72 +0,0 @@ -AddInsetMap <- function(p, col=c("#D8D8D8", "#BFA76F"), - main.label=list(label=NA, adj=NULL), - sub.label=list(label=NA, adj=NULL), - loc=c("bottomleft", "topleft", "topright", "bottomright"), - inset=0.02, width=NULL) { - - op <- par(no.readonly=TRUE) - on.exit(par(op)) - - loc <- match.arg(loc) - - if (!inherits(p, c("SpatialPolygons", "SpatialPolygonsDataFrame"))) - stop("polygon 'p' is the incorrect class") - - usr <- par("usr") - crds <- cbind(c(usr[1:2], usr[2:1], usr[1]), - c(rep(usr[3], 2), rep(usr[4], 2), usr[3])) - b <- SpatialPolygons(list(Polygons(list(Polygon(crds)), "bbox")), - proj4string=crs(p)) - - if (length(gIntersection(p, b)) == 0) - stop("user coordinates of the plotting region do not intersect polygon") - - ext <- extent(gUnion(p, b)) - - if (is.null(width)) { - dx <- 0.2 * diff(usr[1:2]) - } else { - dx <- width * (diff(usr[1:2]) / par("pin")[1]) - } - dy <- dx * (diff(ext[3:4]) / diff(ext[1:2])) - - padx <- inset * diff(usr[1:2]) - pady <- inset * diff(usr[3:4]) - - if (loc == "bottomleft") { - loc <- c(usr[1] + padx, usr[3] + pady) - } else if (loc == "topleft") { - loc <- c(usr[1] + padx, usr[4] - pady - dy) - } else if (loc == "topright") { - loc <- c(usr[2] - padx - dx, usr[4] - pady - dy) - } else if (loc == "bottomright") { - loc <- c(usr[2] - padx - dx, usr[3] + pady) - } - - rect(loc[1], loc[2], loc[1] + dx, loc[2] + dy, col="#FFFFFFE7", border=NA) - - plt <- c(grconvertX(c(loc[1], loc[1] + dx), "user", "nfc"), - grconvertY(c(loc[2], loc[2] + dy), "user", "nfc")) - par(plt=plt, bg="#FFFFFFCC", new=TRUE) - - xlim <- range(ext[1:2]) - ylim <- range(ext[3:4]) - plot.window(xlim=xlim, ylim=ylim) - - plot(p, col=col[1], border=NA, lwd=0.25, add=TRUE) - plot(b, col=col[2], border="#090909", lwd=0.25, add=TRUE) - plot(p, col=NA, border="#090909", lwd=0.25, add=TRUE) - - if (!is.na(main.label[[1]])) { - x <- coordinates(gUnaryUnion(p))[1, ] - text(x[1], x[2], cex=0.7, main.label[[1]], adj=main.label$adj, font=2) - } - if (!is.na(sub.label[[1]])) { - x <- coordinates(gUnaryUnion(b))[1, ] - text(x[1], x[2], cex=0.6, sub.label[[1]], adj=sub.label$adj) - } - - box(lwd=0.5) - - invisible(NULL) -} diff --git a/R/AddScaleBar.R b/R/AddScaleBar.R deleted file mode 100644 index 2a2b009..0000000 --- a/R/AddScaleBar.R +++ /dev/null @@ -1,60 +0,0 @@ -AddScaleBar <- function(asp=1, unit=NULL, is.lonlat=FALSE, - loc=c("bottomleft", "topleft", "topright", "bottomright"), - offset=c(0, 0), lab.vert.exag=NULL) { - loc <- match.arg(loc) - usr <- par("usr") - pin <- par("pin") - - if (is.lonlat) { - y <- (usr[3] + usr[4]) / 2 - xaxp <- par("xaxp") - dx1 <- diff(xaxp[1:2]) / xaxp[3] - dm1 <- spDistsN1(cbind(0, y), c(dx1, y), longlat=TRUE) - dm2 <- diff(pretty(c(0, dm1), 1)[1:2]) - d <- (dx1 * dm2) / dm1 - label <- paste(format(dm2), "km") - } else { - d <- diff(pretty(usr[1:2]))[1] - label <- format(d, big.mark=",") - if (!is.null(unit)) label <- paste(label, unit) - } - - padx <- 0.05 * (usr[2] - usr[1]) - pady <- 0.05 * (usr[2] - usr[1]) / asp - if (loc == "bottomleft") { - loc <- c(usr[1] + padx, usr[3] + pady) - } else if (loc == "topleft") { - loc <- c(usr[1] + padx, usr[4] - pady) - } else if (loc == "topright") { - loc <- c(usr[2] - padx - d, usr[4] - pady) - } else if (loc == "bottomright") { - loc <- c(usr[2] - padx - d, usr[3] + pady) - } - loc[1] <- loc[1] + offset[1] * (diff(usr[1:2]) / pin[1]) - loc[2] <- loc[2] + offset[2] * (diff(usr[3:4]) / pin[2]) - - divs <- 1L - for (i in 5:3) { - if (d %% i == 0) { - divs <- i - break - } - } - xat <- seq(loc[1], loc[1] + d, length.out=(divs + 1L)) - tcl <- (diff(usr[1:2]) * 0.01) / asp - - lines(rbind(c(loc[1], loc[2]), c(loc[1] + d, loc[2])), lwd=0.5) - for (i in xat) lines(rbind(c(i, loc[2]), c(i, loc[2] + tcl)), lwd=0.5) - text(loc[1], loc[2] + tcl, "0", adj=c(0.5, -0.5), cex=0.7) - text(loc[1] + d, loc[2] + tcl, label, adj=c(0.3, -0.5), cex=0.7) - - if (is.logical(lab.vert.exag)) { - add.label <- lab.vert.exag - } else { - add.label <- if (asp > 20) TRUE else FALSE - } - if (add.label) { - txt <- sprintf("VERTICAL EXAGGERATION x%s", asp) - text(loc[1] + d / 2, loc[2], txt, cex=0.7, pos=1) - } -} diff --git a/R/BumpDisconnectCells.R b/R/BumpDisconnectCells.R deleted file mode 100644 index 79fc51c..0000000 --- a/R/BumpDisconnectCells.R +++ /dev/null @@ -1,39 +0,0 @@ -BumpDisconnectCells <- function(rs, min.overlap=2, bump.by=0.1, max.itr=1e+04) { - r <- rs[[2]] - - cell <- which(!is.na(r[])) - rows <- rowFromCell(r, cell) - cols <- colFromCell(r, cell) - - d <- cbind(cell, c1=NA, c2=NA, c3=NA, c4=NA) - d[, "c1"] <- cellFromRowCol(r, rows + 1L, cols) - d[, "c2"] <- cellFromRowCol(r, rows, cols - 1L) - d[, "c3"] <- cellFromRowCol(r, rows - 1L, cols) - d[, "c4"] <- cellFromRowCol(r, rows, cols + 1L) - - itr <- 0L - while(TRUE) { - - FUN <- function(i) { - x <- rep(NA, nrow(d)) - is <- !is.na(d[, i]) - x[is] <- r[d[is, "cell"]] >= rs[[1]][d[is, i]] - min.overlap - return(x) - } - m <- cbind(FUN("c1"), FUN("c2"), FUN("c3"), FUN("c4")) - is.disconnected <- apply(m, 1, any, na.rm=TRUE) - if (all(!is.disconnected)) break - - cells.to.bump <- d[is.disconnected, "cell"] - r[cells.to.bump] <- r[cells.to.bump] - bump.by - - itr <- itr + 1L - if (itr > max.itr) { - warning("maximum iterations reached") - break - } - - d <- d[is.disconnected, , drop=FALSE] - } - return(r - rs[[2]]) -} diff --git a/R/BumpRiverStage.R b/R/BumpRiverStage.R deleted file mode 100644 index 4030348..0000000 --- a/R/BumpRiverStage.R +++ /dev/null @@ -1,133 +0,0 @@ -BumpRiverStage <- function(r, outlets, min.drop=1e-06) { - - r.save <- r - r.out <- rasterize(outlets, r) - - riv.cells <- which(!is.na(r[])) - out.cells <- which(!is.na(r.out[])) - - adj.cells <- adjacent(raster(r), cells=out.cells, pairs=FALSE) - out.cells <- riv.cells[riv.cells %in% adj.cells] - - adj <- unique(adjacent(r, riv.cells, sorted=TRUE)) - adj <- cbind(adj, is=as.integer(adj[, "to"] %in% riv.cells)) - adj <- adj[adj[, "is"] == 1L, c("from", "to")] - - # Move up the river system finding all possible source (stuck) cells off the - # main paths. - - FUN <- function(path) { - i <- 1L - repeat { - cells <- adj[adj[, "from"] == path[i], "to"] - cells <- cells[!cells %in% visited.cells & !cells %in% out.cells] - if (length(cells) == 0) { - stuck.cells <<- c(stuck.cells, tail(path, 1)) - return(NULL) - } - i <- i + 1L - if (length(cells) == 1) { - path[i] <- cells - visited.cells <<- c(visited.cells, cells) - } else { - visited.cells <<- c(visited.cells, cells) - return(cells) - } - } - } - - source.cells <- list() - for (i in seq_along(out.cells)) { - breaks <- out.cells[i] - stuck.cells <- breaks - visited.cells <- breaks - repeat { - if (is.null(breaks)) break - breaks <- unique(unlist(lapply(breaks, FUN))) - } - stuck.cells <- stuck.cells[!stuck.cells %in% out.cells] - if (length(stuck.cells) > 0) - source.cells[[i]] <- stuck.cells - } - - sink.cells <- out.cells[!vapply(source.cells, is.null, FALSE)] - source.cells <- unlist(source.cells) - - # Find paths by finding the shortest path through the river maze. - # Lee algorithm, http://en.wikipedia.org/wiki/Lee_algorithm - - CalcWaveExpansion <- function(cells) { - visited.cells <- NULL - i <- 0L - dist <- rep(NA, length(riv.cells)) - dist[which(riv.cells %in% cells)] <- i - repeat { - visited.cells <- c(visited.cells, cells) - adj.cells <- adj[adj[, "from"] %in% cells, "to"] - adj.cells <- adj.cells[!adj.cells %in% source.cells & - !adj.cells %in% visited.cells] - if (length(adj.cells) > 0) { - cells <- adj.cells - i <- i + 1L - dist[which(riv.cells %in% cells)] <- i - } else { - break - } - } - return(dist) - } - dists <- CalcWaveExpansion(sink.cells) - - BacktracePath <- function(cell) { - path <- NULL - repeat { - path <- c(path, cell) - adj.cells <- adj[adj[, "from"] == cell, "to"] - adj.cells <- adj.cells[!adj.cells %in% source.cells & - !adj.cells %in% path] - cell <- adj.cells[.WhichMin(dists[riv.cells %in% adj.cells])] - if (cell %in% sink.cells) break - } - return(path) - } - paths <- lapply(source.cells, BacktracePath) - - # Drop stage along each path - - DropStageAlongPath <- function(path) { - repeat { - difs <- diff(r[path]) - i <- match(TRUE, difs > 0) - if (is.na(i)) - break - cell <- path[i + 1L] - r[cell] <<- r[cell] - difs[i] - min.drop - } - invisible(difs) - } - lapply(paths, DropStageAlongPath) - - # Set stage for river cells not on any of the paths - - SetNonPathCells <- function(cell) { - adj.cells <- adj[adj[, "from"] %in% cell, "to"] - adj.cells <- adj.cells[!adj.cells %in% source.cells] - ave.top <- mean(r[adj.cells]) - if (ave.top < r[cell]) r[cell] <<- ave.top - dif <- r[cell] - ave.top - invisible(dif) - } - lapply(source.cells, SetNonPathCells) - - return(r - r.save) -} - - -.WhichMin <- function(x) { - y <- seq_along(x)[x == min(x)] - if (length(y) > 1L) { - set.seed(42) - y <- sample(y, 1L) - } - return(y) -} diff --git a/R/DownloadFile.R b/R/DownloadFile.R deleted file mode 100644 index cb532b1..0000000 --- a/R/DownloadFile.R +++ /dev/null @@ -1,94 +0,0 @@ -DownloadFile <- function(url, dest.dir=tempdir(), mode=NULL, extract=TRUE, - max.attempts=10L, wait.time=30) { - - if (!requireNamespace("RCurl", quietly=TRUE)) - stop("package 'RCurl' is not available") - - cainfo <- system.file("CurlSSL", "cacert.pem", package="RCurl") - curl.options <- list(cainfo=cainfo, followlocation=TRUE, header=TRUE, - nobody=TRUE, ftp.use.epsv=TRUE, useragent="R", - timeout=100, ftp.response.timeout=100) - - i <- 1L - repeat { - handle <- RCurl::getCurlHandle() - invisible(try(RCurl::getURL(url, .opts=curl.options, curl=handle), - silent=TRUE)) - info <- RCurl::getCurlInfo(handle) - if (info$response.code %in% c(200L, 350L)) { - break - } else { - if (i > max.attempts) - stop("exceeded the maximum number of attempts to download a file") - i <- i + 1L - Sys.sleep(wait.time) - } - } - - eff.url <- info$effective.url - pos <- regexpr("\\.([[:alnum:]]+)$", eff.url) - ext <- ifelse(pos > -1L, paste0(".", substring(eff.url, pos + 1L)), "") - - # Mode is only an issue for Windows OS - if (is.null(mode)) { - if (is.null(info$content.type)) { # assume mode when missing conent type - txt.ext <- paste0(".", c("txt", "csv", "tsv", "htm", "html", "xml", - "asc", "lst", "log", "json")) - mode <- if (ext %in% txt.ext) "w" else "wb" # TODO(jcf): find better way - } else { - mode <- if (grepl("^text/", info$content.type)) "w" else "wb" - } - } - - temp.file <- file.path(dest.dir, basename(eff.url)) - - curl.options <- list(cainfo=cainfo, followlocation=TRUE) - - i <- 1L - repeat { - con <- RCurl::CFILE(temp.file, mode=mode) - status <- try(RCurl::curlPerform(url=eff.url, writedata=con@ref, - .opts=curl.options), silent=TRUE) - RCurl::close(con) - if (status == 0L) { - break - } else { - if (i > max.attempts) - stop(paste("exceeded max number of attempts:", status)) - i <- i + 1L - Sys.sleep(wait.time) - } - } - - if (extract && ext %in% c(".zip", ".gz", ".bz2", ".xz")) { - if (ext == ".zip") { - extracted.files <- unzip(temp.file, exdir=dest.dir) - } else { - idx <- which(c(".gz", ".bz2", ".xz") == ext) - compressed <- c("gzip", "bzip2", "xz")[idx] - untar(temp.file, exdir=dest.dir, compressed=compressed) - extracted.files <- untar(temp.file, list=TRUE, compressed=compressed) - } - unlink(temp.file) - temp.file <- extracted.files - } - - invisible(temp.file) -} - - -.GetCommonDir <- function(paths) { - if (length(paths) < 2) - return() - paths <- normalizePath(paths, "/") - chunks <- strsplit(paths, "/") - i <- 1L - repeat { - chunk <- sapply(chunks, function(x) x[i]) - if (!all(chunk %in% chunk[1])) - break - i <- i + 1L - } - path <- paste(chunks[[1]][seq_len(i - 1L)], collapse="/") - return(path) -} diff --git a/R/ExportRasterStack.R b/R/ExportRasterStack.R deleted file mode 100644 index 7e9430d..0000000 --- a/R/ExportRasterStack.R +++ /dev/null @@ -1,46 +0,0 @@ -ExportRasterStack <- function(rs, path, zip="", - col=rainbow(250, start=0.0, end=0.8)) { - - dir.create(path, showWarnings=FALSE, recursive=TRUE) - - dir.create(path.csv <- file.path(path, "csv"), showWarnings=FALSE) - dir.create(path.png <- file.path(path, "png"), showWarnings=FALSE) - dir.create(path.tif <- file.path(path, "tif"), showWarnings=FALSE) - dir.create(path.rda <- file.path(path, "rda"), showWarnings=FALSE) - dir.create(path.kml <- file.path(path, "kml"), showWarnings=FALSE) - - n <- 0L - for (i in names(rs)) { - n <- n + 1L - fig.num <- formatC(n, width=2, format="d", flag="0") - - f <- file.path(path.csv, paste(fig.num, "_", i, ".csv", sep="")) - m <- matrix(data=rs[[i]][], nrow=nrow(rs), ncol=ncol(rs), byrow=TRUE) - write.table(m, file=f, quote=FALSE, sep=",", na="", row.names=FALSE, - col.names=FALSE, qmethod="double") - - f <- file.path(path.png, paste(fig.num, "_", i, ".png", sep="")) - png(filename=f, width=7, height=7, units="in", pointsize=12, res=1200, - antialias="cleartype") - plot(rs[[i]], maxpixels=length(rs[[i]]), col=col, main=names(rs[[i]]), - asp=1) - dev.off() - - f <- file.path(path.tif, paste(fig.num, "_", i, ".tif", sep="")) - writeRaster(rs[[i]], filename=f, format="GTiff", overwrite=TRUE, - NAflag=-999) - } - - base.name <- "raster" - - f <- file.path(path.rda, "rasters.rda") - save(rs, file=f) - - f <- file.path(path.kml, "rasters.kml") - crs <- "+proj=longlat +datum=WGS84" - rs <- projectRaster(rs, crs=crs, method="ngb", alignOnly=FALSE) - KML(rs, f, col=col, maxpixels=ncell(rs) * 2, blur=5, zip=zip, - overwrite=TRUE) - - invisible() -} diff --git a/R/ExtractAlongTransect.R b/R/ExtractAlongTransect.R deleted file mode 100644 index b0d9cf7..0000000 --- a/R/ExtractAlongTransect.R +++ /dev/null @@ -1,94 +0,0 @@ -ExtractAlongTransect <- function(transect, r) { - - if (!inherits(transect, c("SpatialPoints", "SpatialLines"))) - stop("incorrect class for 'transect' argument") - if (!inherits(r, c("RasterLayer", "RasterStack", "RasterBrick"))) - stop("incorrect class for 'r' argument") - - if (inherits(transect, "SpatialLines")) - transect <- as(transect, "SpatialPoints") - - crs <- CRS(proj4string(r)) - - v <- coordinates(spTransform(transect, crs)) - if (length(v) < 2) stop("number of vertices in transect is < 2") - - r.xmin <- xmin(r) - r.xmax <- xmax(r) - r.ymin <- ymin(r) - r.ymax <- ymax(r) - - rx <- seq(r.xmin, r.xmax, by=xres(r)) - ry <- seq(r.ymin, r.ymax, by=yres(r)) - - dist.along.transect <- as.matrix(dist(v)) - segs <- list() - v.d <- 0 - - for (i in seq_len(nrow(v) - 1L)) { - - v.x <- v[i:(i + 1L), 1] - v.y <- v[i:(i + 1L), 2] - - m <- (v.y[2] - v.y[1]) / (v.x[2] - v.x[1]) - rx.x <- rx[rx > min(v.x) & rx < max(v.x)] - ry.y <- ry[ry > min(v.y) & ry < max(v.y)] - rx.y <- m * (rx.x - v.x[1]) + v.y[1] - ry.x <- (ry.y - v.y[1]) / m + v.x[1] - - x <- c(v.x[1], rx.x, ry.x, v.x[2]) - y <- c(v.y[1], rx.y, ry.y, v.y[2]) - - d <- as.matrix(dist(cbind(x, y), diag=TRUE))[, 1] - idxs <- order(d) - x <- x[idxs] - y <- y[idxs] - d <- d[idxs] - idxs <- which(x >= r.xmin & x <= r.xmax & y >= r.ymin & y <= r.ymax) - x <- x[idxs] - y <- y[idxs] - d <- d[idxs] + sum(v.d) - n <- length(d) - mid.x <- vapply(seq_len(n - 1L), function(j) mean(c(x[j], x[j + 1L])), 0) - mid.y <- vapply(seq_len(n - 1L), function(j) mean(c(y[j], y[j + 1L])), 0) - - x <- c(x[1], rep(x[2:(n - 1L)], each=2), x[n]) - y <- c(y[1], rep(y[2:(n - 1L)], each=2), y[n]) - d <- c(d[1], rep(d[2:(n - 1L)], each=2), d[n]) - - n <- length(x) - seg <- cbind(x, y, dist=d, matrix(NA, nrow=n, ncol=nlayers(r), - dimnames=list(NULL, names(r)))) - colnames(seg) <- make.names(colnames(seg), unique=TRUE) - - for (j in seq_len(nlayers(r))) { - z <- extract(r[[j]], SpatialPoints(cbind(mid.x, mid.y))) - seg[, j + 3L] <- rep(z, each=2) - } - rownames(seg) <- NULL - - idxs <- NULL - for (j in seq_len(n)) { - is.last <- j == n - if (is.last || all(is.na(seg[j, ]))) { - if (is.null(idxs)) next - if (is.last) idxs <- c(idxs, j) - nsegs <- length(segs) - if (nsegs == 0 || max(segs[[nsegs]][, "dist"]) != min(d[idxs])) - segs[[nsegs + 1L]] <- seg[idxs, ] - else - segs[[nsegs]] <- rbind(segs[[nsegs]], seg[idxs, ]) - idxs <- NULL - } else { - idxs <- c(idxs, j) - } - } - v.d <- c(v.d, dist.along.transect[i, i + 1L]) - } - - FUN <- function(s) { - SpatialPointsDataFrame(s[, 1:2], data.frame(s[, -(1:2)], row.names=NULL), - proj4string=crs, match.ID=FALSE) - } - return(lapply(segs, FUN)) -} diff --git a/R/GetDaysInMonth.R b/R/GetDaysInMonth.R deleted file mode 100644 index b79bf89..0000000 --- a/R/GetDaysInMonth.R +++ /dev/null @@ -1,10 +0,0 @@ -GetDaysInMonth <- function(x) { - d <- as.Date(paste0(x, "28"), format="%Y%m%d") - m <- format(d, format="%m") - for (i in seq_along(d)) { - while (format(d[i], format="%m") == m[i]) { - d[i] <- d[i] + 1L - } - } - return(as.integer(format(d - 1L, format="%d"))) -} diff --git a/R/GetSeasonalMult.R b/R/GetSeasonalMult.R index 81893ea..c5b01ed 100644 --- a/R/GetSeasonalMult.R +++ b/R/GetSeasonalMult.R @@ -1,4 +1,52 @@ -GetSeasonalMult <- function(x, reduction, d.in.mv.ave, tr.stress.periods) { +#' Get Seasonal Multiplier +#' +#' This function determines the seasonal fraction of the long-term mean value. +#' +#' @param x data.frame. +#' Time series data (observations) with components of class Date and numeric. +#' @param reduction numeric. +#' Signal amplitude reduction, a dimensionless quantity. +#' Its magnitude should be greater than or equal to 1; +#' where a value of 1 indicates no reduction in the signal amplitude. +#' @param d.in.mv.ave numeric. +#' Number of days in the moving average subset. +#' @param fixed.dates Date. +#' Vector of equally spaced dates, these are the fixed locations where the moving average is calculated. +#' The final date is neglected. +#' +#' @details A simple moving average is first calculated at dates specified in \code{fixed.dates} +#' using past observational data in \code{x} +#' (such as the previous 9-months of stage data recorded at a streamgage). +#' The seasonal average of the moving average is then passed through a signal amplitude reduction algorithm. +#' The reduced values are then divided by the mean of the seasonal reduced data to give +#' the seasonal fraction of the mean (also known as the seasonal scaling index). +#' +#' @return Returns an object of class data.frame with the following variables: +#' \describe{ +#' \item{\code{names(x)[1]}}{start date for each season in \code{fixed.dates}.} +#' \item{multiplier}{seasonal scaling index} +#' } +#' +#' @author J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center +#' +#' A.H. Wylie and J. Sukow, Idaho Department of Water Resources +#' +#' @keywords manip +#' +#' @export +#' +#' @examples +#' obs <- dataRetrieval::readNWISdata(sites = "13139510", parameterCd = "00060", +#' startDate = "1992-01-01", endDate = "2011-01-01") +#' obs <- obs[, c("dateTime", "X_00060_00003")] +#' obs[, 1] <- as.Date(obs[, 1]) +#' +#' fixed.dates <- seq(as.Date("1995-01-01"), as.Date("2011-01-01"), "1 month") +#' d <- GetSeasonalMult(obs, 2, 273.932, fixed.dates) +#' str(d) +#' + +GetSeasonalMult <- function(x, reduction, d.in.mv.ave, fixed.dates) { if (!is.data.frame(x) || !inherits(x[, 1], "Date") || !is.numeric(x[, 2])) stop("Problem with 'x' argument") @@ -6,19 +54,19 @@ GetSeasonalMult <- function(x, reduction, d.in.mv.ave, tr.stress.periods) { stop("Problem with 'reduction' argument") if (!is.numeric(d.in.mv.ave) || d.in.mv.ave <= 0) stop("Problem with 'd.in.mv.ave' argument") - if (!inherits(tr.stress.periods, "Date")) - stop("Problem with 'tr.stress.periods' argument") + if (!inherits(fixed.dates, "Date")) + stop("Problem with 'fixed.dates' argument") - f <- approxfun(x[, 1], x[, 2]) - d <- data.frame(YearMonth=head(tr.stress.periods, -1)) + f <- stats::approxfun(x[, 1], x[, 2]) + d <- data.frame(utils::head(fixed.dates, -1)) FUN <- function(i) { - vol <- integrate(f, i - d.in.mv.ave, i, subdivisions=1000L, rel.tol=0.001) + vol <- stats::integrate(f, i - d.in.mv.ave, i, subdivisions=1000L, rel.tol=0.001) return(vol$value / d.in.mv.ave) } - d[, 2] <- vapply(d[, 1], FUN, 0) # moving average + d[, 2] <- vapply(d[, 1], FUN, 0) # moving average at fixed dates d <- .GetQtrlyMean(d) # seasonal mean d[, 2] <- .ReduceAmp(d[, 2], reduction) # amplitude reduction - d$multiplier <- d[, 2] / mean(d[, 2]) # seasonal multiplier + d$multiplier <- d[, 2] / mean(d[, 2]) # seasonal-scaling index d <- d[, c(1, 3)] colnames(d) <- c(colnames(x)[1], "multiplier") rownames(d) <- NULL @@ -31,7 +79,7 @@ GetSeasonalMult <- function(x, reduction, d.in.mv.ave, tr.stress.periods) { if (!is.data.frame(x) || !inherits(x[, 1], "Date") || !is.numeric(x[, 2])) stop("Problem with 'x' argument") d <- data.frame(yr=strftime(x[, 1], "%Y"), qu=quarters(x[, 1]), val=x[, 2]) - d <- aggregate(val ~ yr + qu, d, FUN=mean, na.rm=TRUE) + d <- stats::aggregate(val ~ yr + qu, d, FUN=mean, na.rm=TRUE) d$qu <- as.character(d$qu) d$qu[d$qu == "Q1"] <- "01-01" d$qu[d$qu == "Q2"] <- "04-01" diff --git a/R/GetWellConfig.R b/R/GetWellConfig.R index bbe5283..7d10252 100644 --- a/R/GetWellConfig.R +++ b/R/GetWellConfig.R @@ -1,7 +1,60 @@ +#' Get Well Completion and Pumping Rate in Model Space +#' +#' This function determines well completions and pumping rates in model space. +#' The pumping rate is specified for each model cell intersecting a well's open interval(s) +#' and calculated by multiplying the estimated pumping demand by the cell's transmissivity fraction. +#' The transmissivity fraction is calculated by dividing the cell's aquifer transmissivity by +#' the sum of all transmissivity values for cells belonging to the same well. +#' The transmissivity fraction calculation assumes saturated conditions in the model cell. +#' +#' @param rs.model RasterStack. +#' Composed of raster layers describing the model grid and hydraulic conductivity distribution: +#' \code{lay1.top}, \code{lay1.bot}, \code{lay2.bot}, \code{lay3.bot}, +#' \code{lay1.hk}, \code{lay2.hk}, and \code{lay3.hk}. +#' @param wells SpatialPointsDataFrame. +#' Average pumping rate for each well during various times. +#' @param well.col character. +#' Column name of the well identifier field. +#' @param rate.col character. +#' Vector of column names for the pumping rate fields. +#' @param lay2.hk.tol numeric. +#' Hydraulic conductivity tolerance for model cells in layer 2. +#' Used to prevent pumping in the aquitard layer of the aquifer system. +#' Pumping is prohibited in model layer 2 cells with hydraulic conductivity values less than +#' \code{lay2.hk.tol} and a well opening isolated to layer 2; +#' for these cases, pumping is allocated to the adjacent layer 1 cell. +#' +#' @return Returns an object of class data.frame with the following components: +#' \describe{ +#' \item{\dots}{unique identifier assigned to a well, its name is specified by \code{well.col}.} +#' \item{lay,row,col}{layer, row, and column number of a model cell, respectively.} +#' \item{hk}{hydraulic conductivity of the model cell, in meters per day.} +#' \item{thk}{vertical length of the well opening (open borehole or screen) in the model cell, in meters. +#' A value of zero indicates that the well opening is unknown or below the modeled bedrock surface.} +#' \item{frac}{transmissivity fraction for a model cell, +#' where transmissivity is defined as \code{hk} multiplied by \code{thk}.} +#' \item{\dots}{pumping rate allocated to the model cell for each time period +#' specified by \code{rate.col}, in cubic meters per day. +#' The pumping rate is calculated by multiplying the pumping demand for a well +#' (specified in \code{wells}) by \code{frac}.} +#' } +#' +#' @author J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center +#' +#' A.H. Wylie, Idaho Department of Water Resources +#' +#' @keywords manip +#' +#' @export +#' +#' @examples +#' \dontrun{# see Appendix D. Uncalibrated Groundwater-Flow Model} +#' + GetWellConfig <- function(rs.model, wells, well.col, rate.col=NULL, lay2.hk.tol=1e-02) { - wells@data$cell <- over(wells, as(rs.model, "SpatialGrid")) + wells@data$cell <- sp::over(wells, methods::as(rs.model, "SpatialGrid")) is.in.model <- as.logical(!is.na(rs.model[["lay1.top"]])[wells@data$cell]) wells <- wells[is.in.model, , drop=FALSE] @@ -63,7 +116,7 @@ GetWellConfig <- function(rs.model, wells, well.col, rate.col=NULL, names(dd) <- well.col dd$lay <- unlist(apply(d[, c("is.lay1", "is.lay2", "is.lay3")], 1L, which)) - dd <- left_join(dd, d[, c(well.col, "cell", "row", "col")], by=well.col) + dd <- dplyr::left_join(dd, d[, c(well.col, "cell", "row", "col")], by=well.col) for (i in 1:3) { is <- dd$lay == i dd$hk[is] <- rs.model[[paste0("lay", i, ".hk")]][dd$cell[is]] @@ -84,7 +137,7 @@ GetWellConfig <- function(rs.model, wells, well.col, rate.col=NULL, } if (!is.null(rate.col)) { - dd <- left_join(dd, d[, c(well.col, rate.col), drop=FALSE], by=well.col) + dd <- dplyr::left_join(dd, d[, c(well.col, rate.col), drop=FALSE], by=well.col) dd[, rate.col] <- dd[, rate.col] * dd$frac } diff --git a/R/PlotCrossSection.R b/R/PlotCrossSection.R deleted file mode 100644 index 457b66b..0000000 --- a/R/PlotCrossSection.R +++ /dev/null @@ -1,246 +0,0 @@ -PlotCrossSection <- function(transect, rs, geo.lays=names(rs), val.lays=NULL, - wt.lay=NULL, asp=1, ylim=NULL, - max.dev.dim=c(43, 56), n=NULL, breaks=NULL, - pal=NULL, col=NULL, ylab=NULL, unit=NULL, - id=c("A", "A'"), labels=NULL, explanation=NULL, - features=NULL, max.feature.dist=Inf, draw.key=TRUE, - draw.sep=TRUE, is.categorical=FALSE, - contour.lines=NULL, bg.col="#E1E1E1", - wt.col="#FFFFFFD8") { - - if (!inherits(transect, "SpatialLines")) - stop("incorrect class for 'transect' argument") - if (!inherits(rs, c("RasterStack", "RasterBrick"))) - stop("incorrect class for 'rs' argument") - if (!all(c(geo.lays, val.lays) %in% names(rs))) - stop("layer names not found in raster stack") - if (length(val.lays) >= length(geo.lays)) - stop("number of value layers is greater than the number of geometry layers") - - transect <- spTransform(transect, crs(rs)) - rs <- crop(rs, extent(as.vector(t(bbox(transect)))), snap="out") - layer.names <- unique(c(geo.lays, val.lays, wt.lay)) - eat <- ExtractAlongTransect(transect, subset(rs, layer.names)) - - cell.values <- NULL - cell.polys <- list() - for (i in seq_along(val.lays)) { - for (j in seq_along(eat)) { - seg <- as.matrix(eat[[j]]@data) - for (k in seq(1, nrow(seg) - 1L, by=2)) { - v <- as.numeric(seg[k, val.lays[i]]) - p <- rbind(seg[c(k, k + 1L), c("dist", geo.lays[i])], - seg[c(k + 1L, k), c("dist", geo.lays[i + 1L])], - seg[k, c("dist", geo.lays[i]), drop=FALSE]) - if (anyNA(p)) next - cell.values <- c(cell.values, v) - cell.polys <- c(cell.polys, Polygon(p)) - } - } - } - - at <- NULL - if (!is.null(cell.values)) { - if (!is.function(pal)) { - if (requireNamespace("colorspace", quietly=TRUE)) { - pal <- function(n) { - colorspace::rainbow_hcl(n, start=0.0, end=(360 * (n - 1) / n) * 0.8) - } - } else { - pal <- function(n) rainbow(n, start=0.0, end=0.8) - } - } - if (is.categorical) { - unique.vals <- sort(unique(cell.values)) - at <- seq_along(unique.vals) - if (!is.character(col)) col <- pal(length(at)) - cell.cols <- col[match(cell.values, unique.vals)] - } else { - if (!is.numeric(n)) n <- 200L - if (!is.numeric(breaks)) { - at <- pretty(cell.values, n=8) - breaks <- seq(min(at), max(at), length.out=n) - } - intervals <- findInterval(cell.values, breaks, all.inside=TRUE) - if (!is.character(col)) col <- pal(length(breaks) - 1L) - cell.cols <- col[intervals] - } - cols <- unique(cell.cols) - - FUN <- function(i) { - p <- Polygons(cell.polys[which(cell.cols == cols[i])], i) - p <- gUnaryUnion(SpatialPolygons(list(p), i)) - p <- slot(p, "polygons")[[1]] - p@ID <- cols[i] - return(p) - } - p <- lapply(seq_along(cols), FUN) - cell.polys.merged <- SpatialPolygons(p, seq_along(cols)) - } - - x <- unlist(lapply(eat, function(i) i@data$dist)) - xlim <- range(x, na.rm=TRUE) - xat <- pretty(xlim) - - y <- unlist(lapply(eat, function(i) unlist(i@data[, geo.lays]))) - if (is.numeric(ylim)) { - yat <- pretty(ylim) - } else { - yat <- pretty(range(y, na.rm=TRUE)) - ylim <- range(yat, na.rm=TRUE) - } - - inches.in.pica <- 1 / 6 - mar2 <- c(1, 4.6, 4, 2) - if (draw.key) { - y1 <- 1 - mar1 <- c(2, mar2[2], 1, mar2[4]) - } else { - y1 <- 0 - mar1 <- c(0, 0, 0, 0) - } - if (dev.cur() > 1) { - dev.dim <- dev.size() / inches.in.pica - w <- dev.dim[1] - h1 <- y1 + mar1[1] + mar1[3] - h2 <- dev.dim[2] - h1 - h <- h1 + h2 - } else { - w <- max.dev.dim[1] - repeat { - y2 <- (w - mar2[2] - mar2[4]) * (diff(ylim) / diff(xlim)) * asp - h2 <- y2 + mar2[1] + mar2[3] - h1 <- y1 + mar1[1] + mar1[3] - h <- h1 + h2 - if (h > max.dev.dim[2]) w <- w - 0.01 else break - } - wi <- w * inches.in.pica - hi <- h * inches.in.pica - dev.new(width=wi, height=hi) - } - - if (draw.key) { - layout(matrix(c(2, 1), nrow=2, ncol=1), heights=c(h2, h1) / h) - if (!is.null(labels$at)) at <- labels$at - labs <- if (is.null(labels$labels)) TRUE else labels$labels - AddColorKey(mai=mar1 * inches.in.pica, is.categorical=is.categorical, - breaks=breaks, col=col, at=at, labels=labs, - explanation=explanation) - } else { - layout(matrix(1, nrow=1, ncol=1)) - } - - par(mai=mar2 * inches.in.pica, mgp=c(3, 0.6, 0)) - - plot(NA, type="n", xlim=xlim, ylim=ylim, xaxs="i", yaxs="i", bty="n", - xaxt="n", yaxt="n", xlab="", ylab="", asp=asp) - - lwd <- 0.5 - cex <- 0.7 - tcl <- -7.2 / par("cra")[2] - usr <- par("usr") - - if (is.character(bg.col)) { - FUN <- function(i) { - m <- cbind(x=i@data[[1]], y=i@data[[2]]) - m <- rbind(m, cbind(rev(range(m[, "x"], na.rm=TRUE)), usr[3]), - m[1, , drop=FALSE]) - return(Polygon(m)) - } - bg.poly <- SpatialPolygons(list(Polygons(lapply(eat, FUN), "bg")), 1L) - plot(bg.poly, col=bg.col, border=NA, lwd=0.1, add=TRUE) - } - - plot(cell.polys.merged, col=cols, border=cols, lwd=0.1, add=TRUE) - - if (!is.null(wt.lay) && wt.lay[1] %in% names(rs)) { - for (s in eat) - lines(s@data[["dist"]], s@data[, wt.lay[1]], lwd=lwd, col=wt.col) - } - - lays <- if (draw.sep) geo.lays else c(head(geo.lays, 1), tail(geo.lays, 1)) - for (s in eat) - matplot(s@data[["dist"]], s@data[, lays], xaxt="n", yaxt="n", - type="l", lty=1, lwd=lwd, col="#1F1F1F", add=TRUE) - - if (is.list(contour.lines)) { - e <- extent(cell.polys.merged) - nc <- 200 - dx <- diff(e[1:2]) / nc - nr <- as.integer(diff(e[3:4]) / (dx / asp)) - r <- raster(e, nrows=nr, ncols=nc) - FUN <- function(i) Polygons(list(cell.polys[[i]]), as.character(i)) - p <- lapply(seq_along(cell.polys), FUN) - p <- SpatialPolygons(p, seq_along(cell.polys)) - r <- rasterize(p, r) - r[] <- cell.values[r[]] - - color <- as.character(contour.lines[["col"]]) - drawl <- as.logical(contour.lines[["drawlabels"]]) - metho <- as.character(contour.lines[["method"]]) - color <- ifelse(length(color) == 1 && !is.na(color), color, "#1F1F1F") - drawl <- ifelse(length(drawl) == 1 && !is.na(drawl), drawl, TRUE) - metho <- ifelse(length(metho) == 1 && !is.na(metho), metho, "flattest") - contour.breaks <- if (length(breaks) > 20) pretty(breaks, 20L) else breaks - ncontours <- length(contour.breaks) - raster::contour(r, maxpixels=length(r), levels=contour.breaks, - labels=formatC(contour.breaks, big.mark=","), xlim=xlim, - ylim=ylim, labcex=0.5, drawlabels=drawl, method=metho, - axes=FALSE, col=color, lwd=lwd, add=TRUE) - } - - ylabs <- format(yat, big.mark=",") - - axis(4, at=yat, labels=FALSE, lwd=0, lwd.ticks=lwd, tcl=tcl) - axis(2, at=yat, labels=ylabs, lwd=0, lwd.ticks=lwd, tcl=tcl, - cex.axis=cex, las=1) - - if (!is.null(ylab)) { - line.in.inches <- (par("mai") / par("mar"))[2] - max.sw <- max(strwidth(ylabs, units="inches")) * cex - mar.line <- max.sw / line.in.inches + sum(par("mgp")[2:3]) + par("mgp")[2] - title(ylab=ylab, cex.lab=cex, line=mar.line) - } - - abline(v=xlim, col="black", lwd=lwd) - abline(h=usr[3], col="black", lwd=lwd) - - if (!is.null(unit)) mtext(unit, at=usr[1], cex=cex, line=0.2, adj=1) - - if (is.character(id)) { - if (length(id) == 1) id <- c(id, paste0(id, "'")) - mtext(id[1], at=usr[1], cex=cex, line=1, adj=0.5, font=4) - mtext(id[2], at=usr[2], cex=cex, line=1, adj=0.5, font=4) - } - - par(xpd=TRUE) - y <- unlist(lapply(eat, function(i) i@data[[geo.lays[1]]])) - GetGeoTop <- approxfun(x, y) - pady <- diff(usr[3:4]) * 0.02 - d <- as.matrix(dist(coordinates(as(transect, "SpatialPoints"))))[, 1] - dist.to.bend <- head(d[-1], -1) - for (d in dist.to.bend) { - y <- GetGeoTop(d) - lines(c(d, d), c(ylim[1], y + pady), lwd=0.3, col="#999999") - text(d, y + pady, "BEND", adj=c(-0.1, 0.5), col="#999999", cex=0.6, srt=90) - } - if (!is.null(features)) { - tran.pts <- do.call("rbind", eat) - for (i in seq_len(length(features))) { - pnt <- spTransform(features, crs(rs))[i, ] - dist.to.transect <- gDistance(pnt, tran.pts, byid=TRUE) - idx <- which.min(dist.to.transect) - if (dist.to.transect[idx] > max.feature.dist) next - d <- x[idx] - y <- GetGeoTop(d) - lines(c(d, d), c(y, y + pady), lwd=0.3) - label <- format(pnt@data[1, 1]) - text(d, y + pady, label, adj=c(-0.1, 0.5), cex=cex, srt=90) - } - } - par(xpd=FALSE) - - AddScaleBar(asp, unit, loc="bottomright", offset=c(-0.3, 0)) - - invisible(list(din=par("din"), usr=usr, heights=c(h2, h1) / h)) -} diff --git a/R/PlotGraph.R b/R/PlotGraph.R deleted file mode 100644 index a46a908..0000000 --- a/R/PlotGraph.R +++ /dev/null @@ -1,240 +0,0 @@ -PlotGraph <- function(x, y, xlab, ylab, asp=NA, xlim=NULL, ylim=NULL, - xn=5L, yn=5L, ylog=FALSE, type="s", lty=1, lwd=1, - pch=NULL, col=NULL, bg=NA, fill=NULL, pt.cex=1, - seq.date.by="year", scientific=NA, - conversion.factor=NULL, boxwex=0.8, - center.date.labels=FALSE, bg.polygon=NULL) { - - scientific <- as.logical(scientific) - scientific <- rep(scientific, length.out=3) - - if (inherits(x, c("data.frame", "matrix"))) { - if (inherits(x, "tbl_df")) x <- as.data.frame(x) - if (missing(y)) y <- x[, -1, drop=FALSE] - x <- x[, 1] - } - y <- as.matrix(y) - - if (inherits(x, "Date")) { - if (!inherits(xlim, "Date")) xlim <- range(x) - xat <- seq(xlim[1], xlim[2], seq.date.by) - - } else if (inherits(x, c("character", "factor"))) { - x <- seq_along(x) - xat <- x - xlim <- extendrange(x) - - } else { - if (is.numeric(xlim)) { - xat <- pretty(xlim, n=xn) - } else { - xat <- pretty(range(x, na.rm=TRUE), n=xn) - xlim <- range(xat) - } - } - if (is.numeric(ylim)) { - if (ylog) - yat <- axisTicks(log10(ylim), TRUE, nint=yn) - else - yat <- pretty(ylim, n=yn) - } else { - if (ylog) - yat <- axisTicks(log10(range(y)), TRUE, nint=yn) - else - yat <- pretty(range(y, na.rm=TRUE), n=yn) - ylim <- range(yat) - } - - n <- ncol(y) - if (!is.character(col) && !is.logical(col)) - col <- if (is.function(col)) col(n) else rainbow(n, start=0.0, end=0.8) - lty <- rep_len(lty, length.out=n) - lwd <- rep_len(lwd, length.out=n) - - mar <- c(2.3, 4.1, 0.5, 4.1) - if (is.null(conversion.factor)) mar[4] <- 2.1 - mgp <- c(3.2, 0.2, 0) # cumulative axis margin line: title, labels, and line - op <- par(mar=mar, mgp=mgp) - line.in.inches <- (par("mai") / par("mar"))[2] - - plot.new() - plot.window(xlim=xlim, ylim=ylim, asp=asp, xaxt="n", yaxt="n", - xaxs="i", yaxs="i", log=ifelse(ylog, "y", "")) - - cex <- 0.7 - tcl <- 7.2 / par("cra")[2] - is.decreasing <- diff(par("usr")[1:2]) < 0 - - if (is.list(bg.polygon)) { - bg.col <- if (is.null(bg.polygon$col)) NA else bg.polygon$col - polygon(bg.polygon$x, col=bg.col, border=NA) - } - - abline(v=xat, col="lightgrey", lwd=0.5) - abline(h=yat, col="lightgrey", lwd=0.5) - - if (type %in% c("l", "s") & is.character(fill)) { - for (i in seq_len(ncol(y))) { - if (is.na(fill[i])) next - xx <- as.numeric(x) - yy <- as.numeric(y[, i]) - grp <- .GetSegmentGroup(yy) - for (j in unique(na.omit(grp))) { - idxs <- which(grp %in% j) - xxx <- xx[idxs] - yyy <- yy[idxs] - if (type == "s") { - xxx <- sort(c(xxx, tail(xxx, -1)), decreasing=is.decreasing) - yyy <- head(rep(yyy, each=2), -1) - max.idx <- max(idxs) - if (max.idx < length(xx)) { - xxx <- c(xxx, xx[max.idx + 1L]) - yyy <- c(yyy, tail(yyy, 1)) - } - } - xxx <- c(xxx, tail(xxx, 1), xxx[1]) - ylim <- sort(par("usr")[3:4]) - ymin <- if (ylim[1] < 0 & ylim[2] > 0) 0 else ylim[which.min(abs(ylim))] - yyy <- c(yyy, rep(ymin, 2)) - polygon(xxx, yyy, col=fill[i], border=NA) - } - } - } - - if (inherits(x, "Date")) { - if (center.date.labels) { - - if (tail(xat, 1) < xlim[2]) - at <- xat + diff(c(xat, xlim[2])) / 2 - else - at <- head(xat, -1) + diff(xat) / 2 - - axis.Date(1, at=xat, tcl=tcl, labels=FALSE, lwd=-1, lwd.ticks=0.5) - axis.Date(1, at=at, tcl=0, cex.axis=cex, lwd=-1) - } else { - axis.Date(1, at=xat, tcl=tcl, cex.axis=cex, lwd=-1, lwd.ticks=0.5) - } - axis.Date(3, at=xat, tcl=tcl, labels=FALSE, lwd=-1, lwd.ticks=0.5) - } else { - if (is.na(scientific[1])) { - xlabels <- formatC(xat, big.mark=",") - } else if (scientific[1]) { - digits <- format.info(as.numeric(xat))[2] - while (TRUE) { - xlabels <- ToScientific(xat, digits=digits, lab.type="plotmath") - if (!any(duplicated(unlist(lapply(xlabels, eval)))) | digits > 2) break - digits <- digits + 1L - } - } else { - s <- format(xat, big.mark=",", scientific=FALSE) - xlabels <- sub("^\\s+", "", s) - } - axis(1, at=xat, labels=xlabels, tcl=tcl, las=1, cex.axis=cex, lwd=-1, - lwd.ticks=0.5) - axis(3, at=xat, tcl=tcl, lwd=-1, lwd.ticks=0.5, labels=FALSE) - } - if (is.na(scientific[2])) { - ylabels <- formatC(yat, big.mark=",") - } else if (scientific[2]) { - digits <- format.info(as.numeric(yat))[2] - while (TRUE) { - ylabels <- ToScientific(yat, digits=digits, lab.type="plotmath") - if (!any(duplicated(unlist(lapply(ylabels, eval)))) | digits > 2) break - digits <- digits + 1L - } - } else { - s <- format(yat, big.mark=",", scientific=FALSE) - ylabels <- sub("^\\s+", "", s) - } - axis(2, at=yat, labels=ylabels, tcl=tcl, las=1, cex.axis=cex, lwd=-1, - lwd.ticks=0.5) - if (!missing(xlab)) { - mar.line <- sum(par("mgp")[2:3]) + par("mgp")[2] + cex - title(xlab=xlab, cex.lab=cex, line=mar.line) - } - if (!missing(ylab)) { - max.sw <- max(strwidth(ylabels, units="inches")) * cex - mar.line <- max.sw / line.in.inches + sum(par("mgp")[2:3]) + par("mgp")[2] - title(ylab=ylab[1], cex.lab=cex, line=mar.line) - } - - if (is.null(conversion.factor)) { - axis(4, at=yat, tcl=tcl, lwd=-1, lwd.ticks=0.5, labels=FALSE) - } else { - - if (ylog) - yat <- axisTicks(log10(range(yat * conversion.factor)), TRUE, nint=yn) - else - yat <- pretty(yat * conversion.factor, n=yn) - - if (is.na(scientific[3])) { - ylabels <- formatC(yat, big.mark=",") - } else if (scientific[3]) { - digits <- format.info(as.numeric(yat))[2] - while (TRUE) { - ylabels <- ToScientific(yat, digits=digits, lab.type="plotmath") - if (!any(duplicated(unlist(lapply(ylabels, eval)))) | digits > 2) break - digits <- digits + 1L - } - } else { - s <- format(yat, big.mark=",", scientific=FALSE) - ylabels <- sub("^\\s+", "", s) - } - axis(4, at=(yat / conversion.factor), labels=ylabels, tcl=tcl, las=1, - cex.axis=cex, lwd=-1, lwd.ticks=0.5) - if (!missing(ylab) && length(ylab) > 1) { - max.sw <- max(strwidth(ylabels, units="inches")) * cex - mar.line <- max.sw / line.in.inches + sum(par("mgp")[2:3]) - mtext(ylab[2], side=4, cex=cex, line=mar.line) - } - } - - box(lwd=0.5) - - x <- as.numeric(x) - is.x <- x >= as.numeric(xlim[1]) & x <= as.numeric(xlim[2]) - x <- x[is.x] - y <- y[is.x, , drop=FALSE] - y[y < ylim[1] & y > ylim[2]] <- NA - - if (type == "box") { - boxplot(y, xaxt="n", yaxt="n", range=0, varwidth=TRUE, boxwex=boxwex, - col=col, border="#333333", add=TRUE, at=x) - } else { - if (type == "s") { - for (i in seq_len(ncol(y))) { - xx <- as.numeric(x) - yy <- as.numeric(y[, i]) - grp <- .GetSegmentGroup(yy) - for (j in unique(na.omit(grp))) { - idxs <- which(grp %in% j) - xxx <- sort(c(xx[idxs], tail(xx[idxs], -1)), decreasing=is.decreasing) - yyy <- head(rep(yy[idxs], each=2), -1) - max.idx <- max(idxs) - if (max.idx < length(xx)) { - xxx <- c(xxx, xx[max.idx + 1L]) - yyy <- c(yyy, tail(yyy, 1)) - } - lines(xxx, yyy, lty=lty[i], lwd=lwd[i], col=col[i]) - } - } - } else { - matplot(x, y, xaxt="n", yaxt="n", type=type, lty=lty, lwd=lwd, pch=pch, - col=col, bg=bg, cex=pt.cex, add=TRUE, verbose=FALSE) - } - } - - invisible(NULL) -} - - -.GetSegmentGroup <- function (y) { - grp <- as.integer(!is.na(y)) - mult <- 1L - for (i in seq_along(grp)[-1]) { - if (grp[i - 1L] > 0L & grp[i] == 0L) mult <- mult + 1L - grp[i] <- grp[i] * mult - } - grp[grp == 0L] <- NA - return(grp) -} diff --git a/R/PlotMap.R b/R/PlotMap.R deleted file mode 100644 index 13dd43e..0000000 --- a/R/PlotMap.R +++ /dev/null @@ -1,468 +0,0 @@ -PlotMap <- function(r, layer=1, att=NULL, n, breaks, xlim=NULL, ylim=NULL, - zlim=NULL, asp=1, extend.xy=FALSE, extend.z=FALSE, - reg.axs=TRUE, trim.r=TRUE, dms.tick=FALSE, bg.lines=FALSE, - bg.image=NULL, bg.image.alpha=1, pal=NULL, col=NULL, - max.dev.dim=c(43, 56), labels=NULL, scale.loc="bottomleft", - arrow.loc=NULL, explanation=NULL, credit=proj4string(r), - shade=NULL, contour.lines=NULL, rivers=NULL, lakes=NULL, - roads=NULL, draw.key=NULL, draw.raster=TRUE, useRaster) { - - if (!is.null(bg.image) && !inherits(bg.image, "RasterLayer")) - stop("background image is the incorrect class") - - if (missing(useRaster)) { - useRaster <- getOption("preferRaster") - if (!is.logical(useRaster)) useRaster <- FALSE - } - - if (inherits(r, "CRS")) { - is.lim <- is.numeric(xlim) && length(xlim) == 2 && all(!is.na(xlim)) && - is.numeric(ylim) && length(ylim) == 2 && all(!is.na(ylim)) - if (!is.lim && is.null(bg.image)) - stop("spatial limits must be specified") - e <- raster::extent(if (is.lim) c(xlim, ylim) else bg.image) - r <- raster(e, crs=r) - r[] <- NA - } - - if (inherits(r, "SpatialGridDataFrame")) - r <- raster(r, layer=layer) - if (!inherits(r, "RasterLayer")) - stop("raster layer is the incorrect class") - - if (raster::is.factor(r)) { - att.tbl <- raster::levels(r)[[1]] - ids <- att.tbl[, "ID"] - att <- ifelse(is.null(att), ifelse(ncol(att.tbl) > 1, 2, 1), att) - r.levels <- att.tbl[, att] - rr <- r - rr[] <- NA - new.ids <- seq(along=ids) - new.att.tbl <- as.data.frame(list(ID=new.ids, att=r.levels)) - suppressWarnings(levels(rr) <- list(new.att.tbl)) - for (i in new.ids) { - rr[r == ids[i]] <- i - } - r <- rr - } - - if (is.null(xlim)) - xlim <- c(NA, NA) - if (is.null(ylim)) - ylim <- c(NA, NA) - if (is.null(zlim)) - zlim <- c(NA, NA) - - e <- as.vector(extent(r)) - if (!is.na(xlim[1])) - e[1] <- xlim[1] - if (!is.na(xlim[2])) - e[2] <- xlim[2] - if (!is.na(ylim[1])) - e[3] <- ylim[1] - if (!is.na(ylim[2])) - e[4] <- ylim[2] - r <- crop(r, extent(e)) - - if (trim.r && !all(is.na(r[]))) - r <- trim(r) - - xran <- bbox(r)[1, ] - yran <- bbox(r)[2, ] - - if (extend.xy) { - default.xlim <- range(pretty(xran)) - default.ylim <- range(pretty(yran)) - } else { - if (reg.axs) { - buf <- diff(xran) * 0.04 - default.xlim <- c(xran[1] - buf, xran[2] + buf) - default.ylim <- c(yran[1] - (buf * asp), yran[2] + (buf * asp)) - } else { - default.xlim <- range(xran) - default.ylim <- range(yran) - } - } - - if (is.na(xlim[1])) - xlim[1] <- default.xlim[1] - if (is.na(xlim[2])) - xlim[2] <- default.xlim[2] - if (is.na(ylim[1])) - ylim[1] <- default.ylim[1] - if (is.na(ylim[2])) - ylim[2] <- default.ylim[2] - - zran <- range(r[], finite=TRUE) - if (anyNA(zran)) { - n <- 0 - } else { - default.zlim <- range(if (extend.z) pretty(zran) else zran) - if (raster::is.factor(r)) { - at1 <- raster::levels(r)[[1]][, "ID"] - breaks <- c(0.5, at1 + 0.5) - zlim <- range(breaks) - } else { - if (all(is.na(zlim))) { - if (missing(breaks)) { - if (missing(n)) - zlim <- if (extend.z) range(pretty(zran)) else zran - } else { - zlim <- range(breaks) - } - } else { - if (is.na(zlim[1])) - zlim[1] <- default.zlim[1] - if (is.na(zlim[2])) - zlim[2] <- default.zlim[2] - } - if (missing(breaks)) { - if (missing(n) || n > 200L) { - breaks <- seq(zlim[1], zlim[2], length.out=200L) - at1 <- if (extend.z) pretty(zran) else pretty(zlim) - } else { - if (all(is.na(zlim))) { - breaks <- pretty(zran, n=n) - zlim <- if (extend.z) range(breaks) else zran - } else { - breaks <- pretty(zlim, n=n) - } - at1 <- breaks - } - } else { - at1 <- breaks - } - } - n <- length(breaks) - 1L - } - - if (!is.logical(draw.key)) draw.key <- if (n == 0) FALSE else TRUE - - if (dms.tick) { - al <- list() - al[[1]] <- Lines(list(Line(rbind(c(xlim[1], ylim[1]), - c(xlim[2], ylim[1])))), ID="al1") - al[[2]] <- Lines(list(Line(rbind(c(xlim[1], ylim[1]), - c(xlim[1], ylim[2])))), ID="al2") - al[[3]] <- Lines(list(Line(rbind(c(xlim[1], ylim[2]), - c(xlim[2], ylim[2])))), ID="al3") - al[[4]] <- Lines(list(Line(rbind(c(xlim[2], ylim[1]), - c(xlim[2], ylim[2])))), ID="al4") - sl <- SpatialLines(al, proj4string=r@crs) - sl.dd <- spTransform(sl, CRS("+proj=longlat +datum=WGS84")) - e.dd <- pretty(range(bbox(sl.dd)[1, ])) - n.dd <- pretty(range(bbox(sl.dd)[2, ])) - grd.dd <- gridlines(sl.dd, easts=e.dd, norths=n.dd, ndiscr=1000) - - pts.dd <- gIntersection(sl.dd, grd.dd, byid=TRUE) - ids <- row.names(pts.dd) - - row.names(pts.dd) <- make.names(ids, unique=TRUE) - pts <- spTransform(pts.dd, r@crs) - - at2 <- list() - at2[[1]] <- as.vector(coordinates(pts[ids == "al1 NS", ])[, 1]) - at2[[2]] <- as.vector(coordinates(pts[ids == "al2 EW", ])[, 2]) - at2[[3]] <- as.vector(coordinates(pts[ids == "al3 NS", ])[, 1]) - at2[[4]] <- as.vector(coordinates(pts[ids == "al4 EW", ])[, 2]) - - xlabs <- .FormatDMS(dd2dms(coordinates(pts.dd[ids == "al3 NS", ])[, 1], - NS=FALSE)) - ylabs <- .FormatDMS(dd2dms(coordinates(pts.dd[ids == "al2 EW", ])[, 2], - NS=TRUE)) - } else { - at2 <- list() - at2[[1]] <- pretty(xlim) - at2[[2]] <- pretty(ylim) - at2[[3]] <- at2[[1]] - at2[[4]] <- at2[[2]] - xlabs <- prettyNum(at2[[1]]) - ylabs <- prettyNum(at2[[2]]) - if (extend.xy) - ylabs[length(ylabs)] <- "" - } - - inches.in.pica <- 1 / 6 - - mar2 <- c(1, 3, 2, 2) - if (is.character(credit)) mar2[1] <- 2 - if (draw.key) { - y1 <- 1 - mar1 <- c(2, 3, 1, 2) - } else { - y1 <- 0 - mar1 <- c(0, 0, 0, 0) - } - - if (dev.cur() > 1) { - dev.dim <- dev.size() / inches.in.pica - w <- dev.dim[1] - h1 <- y1 + mar1[1] + mar1[3] - h2 <- dev.dim[2] - h1 - h <- h1 + h2 - } else { - w <- max.dev.dim[1] - repeat { - y2 <- (w - mar2[2] - mar2[4]) * (diff(ylim) / diff(xlim)) * asp - h2 <- y2 + mar2[1] + mar2[3] - h1 <- y1 + mar1[1] + mar1[3] - h <- h1 + h2 - if (h > max.dev.dim[2]) - w <- w - 0.01 - else - break - } - wi <- w * inches.in.pica - hi <- h * inches.in.pica - dev.new(width=wi, height=hi) - } - - if (draw.key) - layout(matrix(c(2, 1), nrow=2, ncol=1), heights=c(h2, h1) / h) - else - layout(matrix(1, nrow=1, ncol=1)) - - lwd <- 0.5 # line weight - cex <- 0.7 # magnification of text relative to the default - tcl <- 7.2 / par("cra")[2] # length of ticks, fraction of text height - - if (is.character(col)) { - if (length(col) != n) stop("number of specified colors is incorrect") - cols <- col - } else { - if (is.function(pal)) { - cols <- pal(n) - } else { - if (requireNamespace("colorspace", quietly=TRUE)) - cols <- colorspace::rainbow_hcl(n, start=0.0, end=(360 * (n - 1) / n) * 0.8) - else - cols <- rainbow(n, start=0.0, end=0.8) - } - } - if (!all(.AreColors(cols))) - stop("colors are not valid") - - # Plot color key - - if (draw.key & n > 0) { - is.categorical <- raster::is.factor(r) - at <- if (is.null(labels$at)) at1 else labels$at - if (is.null(labels$labels)) - labels <- if (is.categorical) raster::levels(r)[[1]][, "att"] else TRUE - else - labels <- labels$labels - AddColorKey(mai=mar1 * inches.in.pica, is.categorical=raster::is.factor(r), - breaks=breaks, col=cols, at=at, labels=labels, - explanation=explanation) - } else if (draw.key) { - op <- par(mar=c(0, 0, 0, 0)) - plot.new() - par(op) - } - - # Plot map - - par(mai=mar2 * inches.in.pica) - plot(NA, type="n", xlim=xlim, ylim=ylim, xaxs="i", yaxs="i", bty="n", - xaxt="n", yaxt="n", xlab="", ylab="", asp=asp) - - if (bg.lines) { - usr <- par()$usr - rect(xleft=usr[1], ybottom=usr[3], xright=usr[2], ytop=usr[4], - col="#E7E7E7", border=NA) - if (dms.tick) { - plot(spTransform(grd.dd, r@crs), lwd=lwd, col="#FFFFFF", add=TRUE) - } else { - abline(v=at2[[1]], lwd=lwd, col="#FFFFFF") - abline(h=at2[[2]], lwd=lwd, col="#FFFFFF") - abline(v=.LocateMidTicks(1), lwd=(lwd / 2), col="#FFFFFF59") - abline(h=.LocateMidTicks(2), lwd=(lwd / 2), col="#FFFFFF59") - } - } - - if (!is.null(bg.image)) { - bg.image <- crop(bg.image, extent(e), snap="out") - if (!is.null(bg.image)) - raster::image(bg.image, maxpixels=length(bg.image), useRaster=TRUE, - col=grey(0:255 / 255, alpha=bg.image.alpha), add=TRUE) - } - - if (draw.raster & n > 0) { - raster::image(r, maxpixels=length(r), useRaster=useRaster, zlim=zlim, - col=cols, add=TRUE, breaks=breaks) - if (is.list(shade)) { - zfact <- as.numeric(shade[["z.factor"]]) - angle <- as.numeric(shade[["angle"]]) - direc <- as.numeric(shade[["direction"]]) - alpha <- as.numeric(shade[["alpha"]]) - zfact <- ifelse(length(zfact) == 1 && !is.na(zfact), zfact, 1) - angle <- ifelse(length(angle) == 1 && !is.na(angle), angle, 45) - direc <- ifelse(length(direc) == 1 && !is.na(direc), direc, 0) - alpha <- ifelse(length(alpha) == 1 && !is.na(alpha), alpha, 1) - rr <- r * zfact - hs <- hillShade(slope=terrain(rr), aspect=terrain(rr, opt="aspect"), - angle=angle, direction=direc) - raster::image(hs, maxpixels=length(hs), useRaster=TRUE, - col=grey(0:255 / 255, alpha=alpha), add=TRUE) - } - } - - if (is.list(rivers)) { - river <- spTransform(rivers[["x"]], r@crs) - river <- crop(river, extent(e)) - if (!is.null(rivers)) { - color <- as.character(rivers[["col"]]) - width <- as.numeric(rivers[["lwd"]]) - color <- ifelse(length(color) == 1 && .AreColors(color), color, "#3399CC") - width <- ifelse(length(width) == 1 && !is.na(width), width, 0.5) - plot(river, col=color, lwd=width, add=TRUE) - } - } - - if (is.list(lakes)) { - lakes <- spTransform(lakes[["x"]], r@crs) - lakes <- crop(lakes, extent(e)) - if (!is.null(lakes)) { - color <- as.character(lakes[["col"]]) - bordr <- as.character(lakes[["border"]]) - width <- as.numeric(lakes[["lwd"]]) - color <- ifelse(length(color) == 1 && .AreColors(color), color, "#CCFFFF") - bordr <- ifelse(length(bordr) == 1 && .AreColors(bordr), bordr, "#3399CC") - width <- ifelse(length(width) == 1 && !is.na(width), width, 0.5) - plot(lakes, col=color, border=bordr, lwd=width, add=TRUE) - } - } - - if (is.list(roads)) { - road <- spTransform(roads[["x"]], r@crs) - road <- crop(road, extent(e)) - if (!is.null(roads)) { - color <- as.character(roads[["col"]]) - width <- as.numeric(roads[["lwd"]]) - color <- ifelse(length(color) == 1 && .AreColors(color), color, "#666666") - width <- ifelse(length(width) == 1 && !is.na(width), width, 0.25) - plot(road, col=color, lwd=width, add=TRUE) - } - } - - if (is.list(contour.lines)) { - color <- as.character(contour.lines[["col"]]) - drawl <- as.logical(contour.lines[["drawlabels"]]) - metho <- as.character(contour.lines[["method"]]) - color <- ifelse(length(color) == 1 && !is.na(color), color, "#1F1F1F") - drawl <- ifelse(length(drawl) == 1 && !is.na(drawl), drawl, TRUE) - metho <- ifelse(length(metho) == 1 && !is.na(metho), metho, "flattest") - contour.breaks <- if (n + 1L > 20L) pretty(zlim, 20L) else breaks - ncontours <- length(contour.breaks) - raster::contour(r, maxpixels=length(r), levels=contour.breaks, - labels=formatC(contour.breaks, big.mark=","), xlim=xlim, - ylim=ylim, zlim=zlim, labcex=0.5, drawlabels=drawl, - method=metho, axes=FALSE, col=color, lwd=lwd, add=TRUE) - } - - axis(1, at=at2[[1]], labels=FALSE, lwd=-1, lwd.ticks=lwd, tcl=tcl, - cex.axis=cex) - if (dms.tick) - axis(2, at=at2[[2]], labels=ylabs, lwd=-1, lwd.ticks=lwd, hadj=0, tcl=tcl, - cex.axis=cex, las=1) - else - axis(2, at=at2[[2]], labels=ylabs, lwd=-1, lwd.ticks=lwd, padj=2, tcl=tcl, - cex.axis=cex) - axis(3, at=at2[[3]], labels=xlabs, lwd=-1, lwd.ticks=lwd, padj=2, tcl=tcl, - cex.axis=cex) - axis(4, at=at2[[4]], labels=FALSE, lwd=-1, lwd.ticks=lwd, tcl=tcl, - cex.axis=cex) - box(lwd=lwd) - - if (is.character(credit)) - mtext(credit, side=1, line=-0.5, padj=1, adj=0, cex=0.6, col="#C0C0C0") - - if (!is.null(scale.loc)) { - txt <- strsplit(proj4string(r), " ")[[1]] - unit <- sub("^\\+units=", "", grep("^\\+units=", txt, value=TRUE)) - lonlat <- "+proj=longlat" %in% txt - AddScaleBar(asp, unit, lonlat, scale.loc) - } - - if (!is.null(arrow.loc)) - .AddNorthArrow(arrow.loc, r@crs, cex) - - invisible(list(din=par("din"), usr=par("usr"), heights=c(h2, h1) / h)) -} - - -.LocateMidTicks <- function(side) { - ran <- if (side %in% c(1, 3)) par("usr")[1:2] else par("usr")[3:4] - at <- axTicks(side) - inc <- diff(range(at)) / (length(at) - 1) - at.mid <- seq(min(at) - inc, max(at) + inc, by=inc / 2) - at.mid <- at.mid[!at.mid %in% at & at.mid > ran[1] & at.mid < ran[2]] - return(at.mid) -} - - -.AddNorthArrow <- function(loc, crs, cex) { - usr <- par("usr") - - x.mid <- (usr[2] + usr[1]) / 2 - y.mid <- (usr[4] + usr[3]) / 2 - - crs.dd <- CRS("+proj=longlat +datum=WGS84") - - d <- 0.05 * (usr[4] - usr[3]) - - xy <- rbind(c(x.mid, y.mid), c(x.mid, y.mid + d)) - sp.dd <- spTransform(SpatialPoints(xy, proj4string=crs), crs.dd) - dd <- sp.dd@coords - - d.dd <- sqrt((dd[2, 1] - dd[1, 1])^2 + (dd[2, 2] - dd[1, 2])^2) - dd <- rbind(dd[1, ], c(dd[1, 1], dd[1, 2] + d.dd)) - sp.xy <- spTransform(SpatialPoints(dd, proj4string=crs.dd), crs) - xy <- sp.xy@coords - - padx <- 0.1 * (usr[2] - usr[1]) - pady <- 0.1 * (usr[4] - usr[3]) - if (loc %in% c("bottomleft", "topleft")) - x0 <- usr[1] + padx - else - x0 <- usr[2] - padx - if (loc %in% c("bottomleft", "bottomright")) - y0 <- usr[3] + pady - else - y0 <- usr[4] - pady - x1 <- xy[2, 1] + x0 - xy[1, 1] - y1 <- xy[2, 2] + y0 - xy[1, 2] - - a <- atan((y1 - y0) / (x1 - x0)) * (180 / pi) - if (a > 45 && a <= 135) { - pos <- 3 - } else if (a > 135 && a <= 225) { - pos <- 2 - } else if (a > 225 && a <= 315) { - pos <- 1 - } else { - pos <- 4 - } - - arrows(x0, y0, x1, y1, length=0.1) - text(x1, y1, labels="N", pos=pos, cex=cex) -} - - -.FormatDMS <- function(dms) { - d <- dms@deg - m <- dms@min - s <- dms@sec - s.round <- round(s, digits=3) - sep <- ifelse(dms@NS, "\n", "") - txt <- paste0(d, "\u00B0") - txt <- paste0(txt, ifelse(m != 0 | s.round != 0, paste0(sep, m, "'"), "")) - txt <- paste0(txt, ifelse(s.round != 0, paste0(sep, s.round, "\""), "")) - return(txt) -} - - -.AreColors <- function(x) { - sapply(x, function(i) tryCatch(is.matrix(col2rgb(i)), - error=function(e) FALSE)) -} diff --git a/R/ReadModflowBinary.R b/R/ReadModflowBinary.R deleted file mode 100644 index dc017a9..0000000 --- a/R/ReadModflowBinary.R +++ /dev/null @@ -1,175 +0,0 @@ -ReadModflowBinary <- function(f, data.type=c("array", "flow"), - rm.totim.0=FALSE) { - if (!file.exists(f)) - stop("binary file can not be found") - - data.type <- match.arg(data.type) - - ans <- try(.ReadBinary(f, data.type, nbytes=4L), silent=TRUE) - if (inherits(ans, "try-error")) - ans <- .ReadBinary(f, data.type, nbytes=8L) - - if (rm.totim.0) - ans <- ans[vapply(ans, function(i) i$totim, 0) != 0] - - return(ans) -} - - -.Read3dArray <- function(con, nrow, ncol, nlay, nbytes) { - FUN <- function(i) { - v <- readBin(con, "numeric", n=nrow * ncol, size=nbytes) - return(matrix(v, nrow=nrow, ncol=ncol, byrow=TRUE)) - } - return(lapply(seq_len(nlay), FUN)) -} - - -.TidyDescription <- function(desc) { - return(tolower(gsub("(^ +)|( +$)", "", desc))) -} - - -.ReadBinary <- function(f, data.type, nbytes) { - con <- file(f, open="rb", encoding="bytes") - on.exit(close(con, type="rb")) - - ## kstp: time step number - ## kper: stress period number - ## pertim: time in current stress period - ## totim: total elapsed time - ## desc: variable name - ## ncol: number of columns in the model grid - ## nrow: number of rows in the model grid - ## nlay: number of layers in the model grid - ## ilay: single layer number - ## itype: data storage type - ## delt: length of time step - ## nval: number of values for each cell - ## ctmp: description of additional values - ## nlist: number of cells for which values will be stored - - if (data.type == "array") - valid.desc <- c("head", "drawdown", "subsidence", "compaction", - "critical head", "head in hgu", "ndsys compaction", - "z displacement", "d critical head", "layer compaction", - "dsys compaction", "nd critical head", "system compaction", - "preconsol stress", "change in pcstrs", "effective stress", - "change in eff-st", "void ratio", "thickness", - "center elevation", "geostatic stress", "change in g-strs") - else - valid.desc <- c("storage", "constant head", "flow right face", - "flow front face", "flow lower face", "wells", "drains", - "river leakage") - lst <- list() - repeat { - kstp <- readBin(con, "integer", n=1L, size=4L) - if (length(kstp) == 0) break - kper <- readBin(con, "integer", n=1L, size=4L) - - if (data.type == "array") { - pertim <- readBin(con, "numeric", n=1L, size=nbytes) - totim <- readBin(con, "numeric", n=1L, size=nbytes) - desc <- readBin(readBin(con, "raw", n=16L, size=1L), "character", n=1L) - desc <- .TidyDescription(desc) - if (!desc %in% valid.desc) break - ncol <- readBin(con, "integer", n=1L, size=4L) - nrow <- readBin(con, "integer", n=1L, size=4L) - ilay <- readBin(con, "integer", n=1L, size=4L) - v <- readBin(con, "numeric", n=nrow * ncol, size=nbytes) - d <- matrix(v, nrow=nrow, ncol=ncol, byrow=TRUE) - lst[[length(lst) + 1L]] <- list(d=d, kstp=kstp, kper=kper, desc=desc, - ilay=ilay, pertim=pertim, totim=totim) - - } else { - desc <- readBin(readBin(con, "raw", n=16L, size=1L), "character", n=1L) - desc <- .TidyDescription(desc) - if (!desc %in% valid.desc) break - ncol <- readBin(con, "integer", n=1L, size=4L) - nrow <- readBin(con, "integer", n=1L, size=4L) - nlay <- readBin(con, "integer", n=1L, size=4L) - if (nlay > 0) { - d <- .Read3dArray(con, nrow, ncol, nlay, nbytes) - } else { - nlay <- abs(nlay) - itype <- readBin(con, "integer", n=1L, size=4L) - delt <- readBin(con, "numeric", n=1L, size=nbytes) - pertim <- readBin(con, "numeric", n=1L, size=nbytes) - totim <- readBin(con, "numeric", n=1L, size=nbytes) - - if (itype == 5L) - nval <- readBin(con, "integer", n=1L, size=4L) - else - nval <- 1L - if (nval > 100L) - stop("more than one-hundred varaiables for each cell") - if (nval > 1L) { - ctmp <- readBin(readBin(con, "raw", n=16L, size=1L), "character", - n=nval - 1L) - ctmp <- .TidyDescription(ctmp) - } else { - ctmp <- NULL - } - if (itype %in% c(2L, 5L)) { - nlist <- readBin(con, "integer", n=1L, size=4L) - if (nlist > (nrow * ncol * nlay)) - stop("large number of cells for which values will be stored") - } - if (itype %in% c(0L, 1L)) { - nvalues <- ncol * nrow * nlay - d <- .Read3dArray(con, nrow, ncol, nlay, nbytes) - for (i in seq_along(d)) { - lst[[length(lst) + 1L]] <- list(d=d[[i]], kstp=kstp, kper=kper, - desc=desc, ilay=i, delt=delt, - pertim=pertim, totim=totim) - } - } else if (itype %in% c(2L, 5L)) { - if (nlist > 0L) { - d <- matrix(0, nrow=nlist, ncol=4L + nval) - colnames(d) <- make.names(c("icell", "layer", "row", "column", - desc, ctmp), unique=TRUE) - for (i in seq_len(nlist)) { - d[i, 1] <- readBin(con, "integer", n=1L, size=4L) - d[i, 4L + seq_len(nval)] <- readBin(con, "numeric", n=nval, - size=nbytes) - } - nrc <- nrow * ncol - d[, "layer"] <- as.integer((d[, "icell"] - 1L) / nrc + 1L) - d[, "row"] <- as.integer(((d[, "icell"] - (d[, "layer"] - 1L) * - nrc) - 1L) / ncol + 1L) - d[, "column"] <- as.integer(d[, "icell"] - (d[, "layer"] - 1L) * - nrc - (d[, "row"] - 1L) * ncol) - lst[[length(lst) + 1L]] <- list(d=d, kstp=kstp, kper=kper, - desc=desc, delt=delt, - pertim=pertim, totim=totim) - } - } else if (itype == 3L) { - layers <- readBin(con, "integer", n=nrow * ncol, size=4L) - values <- readBin(con, "numeric", n=nrow * ncol, size=nbytes) - for (i in sort(unique(layers))) { - v <- values[layers == i] - d <- matrix(v, nrow=nrow, ncol=ncol, byrow=TRUE) - lst[[length(lst) + 1L]] <- list(d=d, kstp=kstp, kper=kper, - desc=desc, ilay=i, delt=delt, - pertim=pertim, totim=totim) - } - } else if (itype == 4L) { - v <- readBin(con, "numeric", n=nrow * ncol, size=nbytes) - d <- matrix(v, nrow=nrow, ncol=ncol, byrow=TRUE) - lst[[length(lst) + 1L]] <- list(d=d, kstp=kstp, kper=kper, desc=desc, - ilay=1L, delt=delt, pertim=pertim, - totim=totim) - d[, ] <- 0 - for (i in seq_len(nlay)[-1]) { - lst[[length(lst) + 1L]] <- list(d=d, kstp=kstp, kper=kper, - desc=desc, ilay=i, delt=delt, - pertim=pertim, totim=totim) - } - } else { - stop("data storage type is not recognized") - } - } - } - } - return(lst) -} diff --git a/R/ReplaceInTemplate.R b/R/ReplaceInTemplate.R deleted file mode 100644 index 419c8a6..0000000 --- a/R/ReplaceInTemplate.R +++ /dev/null @@ -1,34 +0,0 @@ -ReplaceInTemplate <- function(text, replacement) { - -# This function was derived from the sensitivity::template.replace function, -# accessed on Feb 6, 2015 (http://cran.r-project.org/web/packages/sensitivity/) - - if (missing(replacement)) replacement <- list() - - for (i in seq_along(text)) { - - for (j in names(replacement)) { - pattern <- sub("KEY", j, "\\$\\(KEY\\)", perl=TRUE) - text[i] <- gsub(pattern, paste(replacement[[j]]), text[i], perl=TRUE) - } - - repeat { - reg <- regexpr("@\\{.+?\\}", text[i], perl=TRUE) - if (reg == -1) break - - match.first <- as.integer(reg) - match.last <- match.first + attr(reg, "match.length") - 1L - match.text <- substr(text[i], match.first + 2L, match.last - 1L) - - val.match.text <- eval(parse(text=match.text)) - - line.begin <- substr(text[i], 1, match.first - 1L) - line.middle <- paste(val.match.text) - line.end <- substr(text[i], match.last + 1L, nchar(text[i])) - text[i] <- paste0(line.begin, line.middle, line.end) - } - - } - - return(text) -} diff --git a/R/RmSmallCellChunks.R b/R/RmSmallCellChunks.R deleted file mode 100644 index d409254..0000000 --- a/R/RmSmallCellChunks.R +++ /dev/null @@ -1,27 +0,0 @@ -RmSmallCellChunks <- function(r) { - - ext <- extent(r) - new.ext <- extent(c(ext@xmin - res(r)[1], ext@xmax + res(r)[1], - ext@ymin - res(r)[2], ext@ymax + res(r)[2])) - new.r <- extend(r, new.ext) - - r.values <- new.r[] - r.clump <- clump(new.r, directions=4) - chunk.numbers <- r.clump[] - chunks <- unique(na.omit(chunk.numbers)) - FUN <- function(i) sum(chunk.numbers == i, na.rm=TRUE) - chunk.sizes <- vapply(chunks, FUN, 0) - - biggest.chunk <- chunks[which(chunk.sizes == max(chunk.sizes))] - n <- length(biggest.chunk) - if (n > 1L) - warning(paste("There are", n, "raster chunks with largest area.")) - - chunk.numbers[!is.na(chunk.numbers) & !chunk.numbers %in% biggest.chunk] <- NA - r.values[is.na(chunk.numbers)] <- NA - new.r[] <- r.values - - r <- crop(new.r, ext) - - return(r) -} diff --git a/R/RunWaterBalance.R b/R/RunWaterBalance.R index dc1927c..9b3a5f8 100644 --- a/R/RunWaterBalance.R +++ b/R/RunWaterBalance.R @@ -1,7 +1,186 @@ -RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, - ss.stress.periods=NULL, verbose=FALSE) { - - yr.mo <- format(head(tr.stress.periods, -1), "%Y%m") +#' Run Water Balance +#' +#' This function estimates natural and incidental groundwater recharge at the water table, +#' and pumping demand at production wells. +#' A water-balance approach is used to calculate these volumetric flow rate estimates, +#' where positive values are flow into the aqufer system (groundwater recharge), +#' and negative values are flow out of the system (groundwater discharge). +#' +#' @param r.grid RasterLayer. +#' Gridded numeric values where NA indicates an \sQuote{inactive} cell in +#' the top model layer. +#' @param tr.stress.periods Date. +#' Vector of start and end dates for each stress period in the simulation. +#' @param ss.stress.periods Date. +#' Vector of start and end dates for stress periods used to create steady-state conditions. +#' @param canal.seep data.frame. +#' See \code{\link{canal.seep}} dataset for details. +#' @param comb.sw.irr data.frame. +#' See \code{\link{comb.sw.irr}} dataset for details. +#' @param div.gw data.frame. +#' See \code{\link{div.gw}} dataset for details. +#' @param div.sw data.frame. +#' See \code{\link{div.sw}} dataset for details. +#' @param div.ww data.frame. +#' See \code{\link{div.gw}} dataset for details. +#' @param efficiency data.frame. +#' See \code{\link{efficiency}} dataset for details. +#' @param entity.components list. +#' See \code{\link{entity.components}} dataset for details. +#' @param et RasterStack. +#' See \code{\link{et}} dataset for details. +#' @param irr.entities SpatialPolygonsDataFrame. +#' See \code{\link{irr.entities}} dataset for details. +#' @param land.surface RasterLayer. +#' See \code{\link{land.surface}} dataset for details. +#' @param pod.gw data.frame. +#' See \code{\link{pod.gw}} dataset for details. +#' @param priority.cuts data.frame. +#' See \code{\link{priority.cuts}} dataset for details. +#' @param r.canals RasterLayer. +#' See \code{\link{r.canals}} dataset for details. +#' @param rs.entities RasterStack. +#' See \code{\link{rs.entities}} dataset for details. +#' @param rs.rech.non.irr RasterStack. +#' See \code{\link{rs.rech.non.irr}} dataset for details. +#' @param verbose logical. +#' Indicates whether to return summary tables: +#' \code{natural.rech}, \code{inciden.rech}, and \code{pumping.rech}. +# See \sQuote{Value} section for table formats. +#' +#' @return Returns an object of class list with the following components: +#' +#' (1) Water-table flow data (combines natural and incidental groundwater recharge) +#' are stored in \code{areal.rech}, +#' an object of RasterStack class with raster layers for each model stress period; +#' cell values are specified as volumetric flow rates in cubic meters per day. +#' +#' (2) Production well pumping data are stored in \code{pod.rech}, +#' an object of \code{data.frame} class with the following components: +#' \describe{ +#' \item{WMISNumber}{unique number assigned to a water right point of diversion.} +#' \item{ss,199501,\dots,201012}{volumetric flow rate, specified for each stress period, +#' in cubic meters per day.} +#' } +#' +#' (3) Natural groundwater recharge data are stored in \code{natural.rech}, +#' an object of data.frame class with the following components: +#' \describe{ +#' \item{YearMonth}{calendar year and month YYYYMM.} +#' \item{Area}{land-surface area of non-irrigated lands, in square meters.} +#' \item{ET}{evapotranspiration on non-irrigated lands, in cubic meters per month.} +#' \item{Rech}{volumetric flow rate, in cubic meters per month.} +#' } +#' +#' (4) Incidental groundwater recharge data are stored in \code{inciden.rech}, +#' an object of data.frame class with the following components: +#' \describe{ +#' \item{EntityName}{name of the irrigation entity.} +#' \item{YearMonth}{calendar year and month YYYYMM.} +#' \item{SWDiv}{surface-water diversions, in cubic meters per month.} +#' \item{SeepFrac}{canal seepage as a fraction of diversions, a dimensionless quantity.} +#' \item{CanalSeep}{canal seepage, in cubic meters per month.} +#' \item{SWDel}{surface-water delivered to field headgates, in cubic meters per month.} +#' \item{area.sw}{area irrigated by only surface water, in square meters.} +#' \item{et.sw}{evapotranspiration on lands irrigated by only surface water, +#' in cubic meters per month.} +#' \item{precip.sw}{precipitation on lands irrigated by only surface water, +#' in cubic meters per month.} +#' \item{cir.sw}{crop irrigation requirement on lands irrigated by only surface water, +#' in cubic meters per month.} +#' \item{area.mix}{area irrigated by both surface and groundwater, in square meters.} +#' \item{et.mix}{evapotranspiration on lands irrigated by both surface and groundwater, +#' in cubic meters per month.} +#' \item{precip.mix}{precipitation on lands irrigated by both surface and groundwater, +#' in cubic meters per month.} +#' \item{cir.mix}{crop irrigation requirement on lands irrigated by both surface and groundwater, +#' in cubic meters per month.} +#' \item{area.gw}{area irrigated by only groundwater, in square meters.} +#' \item{et.gw}{evapotranspiration on lands irrigated by only groundwater, +#' in cubic meters per month.} +#' \item{precip.gw}{precipitation on lands irrigated by only groundwater, +#' in cubic meters per month.} +#' \item{cir.gw}{crop irrigation requirement on lands irrigated by only groundwater, +#' in cubic meters per month.} +#' \item{Eff}{irrigation efficiency, a dimensionless quantity.} +#' \item{GWDiv}{recorded groundwater diversions, in cubic meters per month.} +#' \item{WWDiv}{inflow to municipal wastewater treatment plants, in cubic meters per month.} +#' \item{hg.sw}{surface-water delivered to field headgates on lands irrigated by only surface water, +#' in cubic meters per month.} +#' \item{hg.mix}{surface-water delivered to field headgates on lands irrigation by both surface and groundwater, +#' in cubic meters per month.} +#' \item{rech.sw}{incidental groundwater recharge beneath lands irrigated by only surface water, +#' in cubic meters per month.} +#' \item{gw.dem.mix}{groundwater demand on lands irrigated by both surface and groundwater, +#' in cubic meters per month.} +#' \item{gw.div.est}{calculated groundwater diversions, in cubic meters per month.} +#' \item{rech.mix}{incidental groundwater recharge beneath lands irrigated by both surface and groundwater, +#' in cubic meters per month.} +#' \item{gw.only}{groundwater demand on lands irrigated by only groundwater in entities with +#' lands also irrigated by both surface and groundwater, in cubic meters per month.} +#' \item{rech.muni}{incidental groundwater recharge beneath entities with +#' lands irrigated by only groundwater and lands irrigated by both surface and groundwater, +#' in cubic meters per month.} +#' \item{gw.dem.gw}{groundwater demand on lands irrigated by only groundwater in +#' entities without surface-water irrigation, in cubic meters per month.} +#' \item{rech.gw}{incidental groundwater recharge beneath lands irrigated by only groundwater, +#' in cubic meters per month.} +#' \item{area.model}{area of the irrigation entity that is located in the model domain, +#' in square meters.} +#' } +#' Volumetric flow rates are calculated for their respective area in +#' the irrigation entity---not just that part overlying the model area. +#' Flow rate values are given this way in order to facilitate with quality assurance of +#' the water-budget calculation. +#' To calculate a simulated volumetric-flow rate: divide the flow rate by the affected area, +#' and then multiply this value by the area of the irrigation entity that is located in +#' the model domain (\code{area.model}). +#' +#' (5) Well pumping data are also stored in \code{pumping.rech} (see \code{pod.rech} component), +#' an object of data.frame class with the following components: +#' \describe{ +#' \item{WMISNumber}{unique number assigned to a water right point of diversion.} +#' \item{YearMonth}{calendar year and month YYYYMM.} +#' \item{Pumping}{volumetric rate of pumping, in cubic meters per month.} +#' } +#' +#' @author J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center +#' +#' J. Sukow and M. McVay, Idaho Department of Water Resources +#' +#' @seealso \code{\link{UpdateWaterBudget}} +#' +#' @keywords manip +#' +#' @import sp +#' @import raster +#' +#' @export +#' +#' @examples +#' \dontrun{# see Appendix A. Package Introduction} +#' + +RunWaterBalance <- function(r.grid, tr.stress.periods, + ss.stress.periods=NULL, + canal.seep=wrv::canal.seep, + comb.sw.irr=wrv::comb.sw.irr, + div.gw=wrv::div.gw, + div.sw=wrv::div.sw, + div.ww=wrv::div.ww, + efficiency=wrv::efficiency, + entity.components=wrv::entity.components, + et=wrv::et, + irr.entities=wrv::irr.entities, + land.surface=wrv::land.surface, + pod.gw=wrv::pod.gw, + priority.cuts=wrv::priority.cuts, + r.canals=wrv::r.canals, + rs.entities=wrv::rs.entities, + rs.rech.non.irr=wrv::rs.rech.non.irr, + verbose=FALSE) { + + yr.mo <- format(utils::head(tr.stress.periods, -1), "%Y%m") yr.mo.irr <- yr.mo[months(tr.stress.periods, abbreviate=TRUE) %in% c("Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")] yr.mo.non.irr <- yr.mo[!yr.mo %in% yr.mo.irr] @@ -13,8 +192,9 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, ## 3a. surface-water diversion FUN <- function(i) { - d <- wrv::div.sw[wrv::div.sw$YearMonth == i, , drop=FALSE] - d <- summarise_(group_by_(d, "EntityName"), SWDiv="sum(SWDiv, na.rm=TRUE)") + d <- div.sw[div.sw$YearMonth == i, , drop=FALSE] + d <- dplyr::summarise_(dplyr::group_by_(d, "EntityName"), + SWDiv="sum(SWDiv, na.rm=TRUE)") return(d) } sw.div.by.entity <- lapply(yr.mo, FUN) @@ -22,27 +202,29 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, ## 3b. gw diversions; water measurement information system (wmis) - wmis.no <- sort(unique(wrv::pod.gw$WMISNumber)) + wmis.no <- sort(unique(pod.gw$WMISNumber)) wmis.no.by.entity <- as.data.frame(list(WMISNumber=wmis.no)) - idxs <- match(wmis.no, wrv::pod.gw$WMISNumber) - wmis.no.by.entity$EntityName <- wrv::pod.gw$EntityName[idxs] + idxs <- match(wmis.no, pod.gw$WMISNumber) + wmis.no.by.entity$EntityName <- pod.gw$EntityName[idxs] div.gw$id <- paste0(div.gw$WMISNumber, div.gw$YearMonth) - div.gw.agg <- summarise_(group_by_(div.gw, "id"), - GWDiv="sum(GWDiv, na.rm=TRUE)") + div.gw.agg <- dplyr::summarise_(dplyr::group_by_(div.gw, "id"), + GWDiv="sum(GWDiv, na.rm=TRUE)") d <- as.data.frame(list(WMISNumber=rep(wmis.no, each=length(yr.mo)), YearMonth=rep(yr.mo, times=length(wmis.no)), GWDiv=0)) idxs <- match(paste0(d$WMISNumber, d$YearMonth), div.gw.agg$id) - d$GWDiv[!is.na(idxs)] <- div.gw.agg$GWDiv[na.omit(idxs)] + d$GWDiv[!is.na(idxs)] <- div.gw.agg$GWDiv[stats::na.omit(idxs)] gw.div.by.wmis.no <- d FUN <- function(i) { is.neg <- gw.div.by.wmis.no$GWDiv < 0 & gw.div.by.wmis.no$YearMonth == i d <- gw.div.by.wmis.no[is.neg, ] - d <- summarise_(group_by_(d, "WMISNumber"), GWDiv="sum(GWDiv, na.rm=TRUE)") - d <- left_join(d, wmis.no.by.entity, by="WMISNumber") - d <- summarise_(group_by_(d, "EntityName"), GWDiv="sum(GWDiv, na.rm=TRUE)") + d <- dplyr::summarise_(dplyr::group_by_(d, "WMISNumber"), + GWDiv="sum(GWDiv, na.rm=TRUE)") + d <- dplyr::left_join(d, wmis.no.by.entity, by="WMISNumber") + d <- dplyr::summarise_(dplyr::group_by_(d, "EntityName"), + GWDiv="sum(GWDiv, na.rm=TRUE)") return(d) } gw.div.by.entity <- lapply(yr.mo, FUN) @@ -51,8 +233,9 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, ## 3c. wastewater treament plant discharge FUN <- function(i) { - d <- wrv::div.ww[wrv::div.ww$YearMonth == i, ] - d <- summarise_(group_by_(d, "EntityName"), WWDiv="sum(WWDiv, na.rm=TRUE)") + d <- div.ww[div.ww$YearMonth == i, ] + d <- dplyr::summarise_(dplyr::group_by_(d, "EntityName"), + WWDiv="sum(WWDiv, na.rm=TRUE)") return(d) } ww.div.by.entity <- lapply(yr.mo, FUN) @@ -61,13 +244,13 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, ## 3d. calculate estimates for recharge and groundwater FUN <- function(i) { - irr <- wrv::irr.entities@data + irr <- irr.entities@data d <- data.frame(EntityName=levels(irr$EntityName)) - d <- suppressWarnings(left_join(d, sw.div.by.entity[[i]], by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, sw.div.by.entity[[i]], by="EntityName")) d$SWDiv[is.na(d$SWDiv)] <- 0 - d <- suppressWarnings(left_join(d, seep, by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, canal.seep, by="EntityName")) d$CanalSeep <- d$SWDiv * d$SeepFrac d$CanalSeep[is.na(d$CanalSeep)] <- 0 d$SWDel <- d$SWDiv - d$CanalSeep @@ -78,30 +261,30 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, cols <- c("EntityName", "area", "et.vol", "precip.vol", "cir.vol") - comp <- wrv::entity.components[[i]]@data + comp <- entity.components[[i]]@data comp <- comp[comp$Source == "SW Only", cols] names(comp) <- c("EntityName", "area.sw", "et.sw", "precip.sw", "cir.sw") - d <- suppressWarnings(left_join(d, comp, by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, comp, by="EntityName")) d$cir.sw[is.na(d$cir.sw)] <- 0 - comp <- wrv::entity.components[[i]]@data + comp <- entity.components[[i]]@data comp <- comp[comp$Source == "Mixed", cols] names(comp) <- c("EntityName", "area.mix", "et.mix", "precip.mix", "cir.mix") - d <- suppressWarnings(left_join(d, comp, by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, comp, by="EntityName")) d$cir.mix[is.na(d$cir.mix)] <- 0 - comp <- wrv::entity.components[[i]]@data + comp <- entity.components[[i]]@data comp <- comp[comp$Source == "GW Only", cols] names(comp) <- c("EntityName", "area.gw", "et.gw", "precip.gw", "cir.gw") - d <- suppressWarnings(left_join(d, comp, by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, comp, by="EntityName")) d$cir.gw[is.na(d$cir.gw)] <- 0 - eff <- eff[, c("EntityName", "Eff")] - d <- suppressWarnings(left_join(d, eff, by="EntityName")) - d <- suppressWarnings(left_join(d, gw.div.by.entity[[i]], by="EntityName")) + efficiency <- efficiency[, c("EntityName", "Eff")] + d <- suppressWarnings(dplyr::left_join(d, efficiency, by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, gw.div.by.entity[[i]], by="EntityName")) d$GWDiv[is.na(d$GWDiv)] <- 0 - d <- suppressWarnings(left_join(d, ww.div.by.entity[[i]], by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, ww.div.by.entity[[i]], by="EntityName")) d$WWDiv[is.na(d$WWDiv)] <- 0 cols <- c("hg.sw", "hg.mix", "rech.sw", "gw.dem.mix", "gw.div.est", "rech.mix", "gw.only", "rech.muni", "gw.dem.gw", "rech.gw") @@ -173,15 +356,15 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, cols <- names(div.by.entity[[1]]) FUN <- function(i) { - d <- data.frame(EntityName=levels(wrv::irr.entities@data$EntityName)) + d <- data.frame(EntityName=levels(irr.entities@data$EntityName)) - d <- suppressWarnings(left_join(d, sw.div.by.entity[[i]], by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, sw.div.by.entity[[i]], by="EntityName")) d$SWDiv[is.na(d$SWDiv)] <- 0 - d <- suppressWarnings(left_join(d, gw.div.by.entity[[i]], by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, gw.div.by.entity[[i]], by="EntityName")) d$GWDiv[is.na(d$GWDiv)] <- 0 - d <- suppressWarnings(left_join(d, ww.div.by.entity[[i]], by="EntityName")) + d <- suppressWarnings(dplyr::left_join(d, ww.div.by.entity[[i]], by="EntityName")) d$WWDiv[is.na(d$WWDiv)] <- 0 d$rech.gw <- d$SWDiv - d$GWDiv + d$WWDiv @@ -196,10 +379,10 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, ## if (verbose) { - cell.area <- xres(wrv::land.surface) * yres(wrv::land.surface) + cell.area <- xres(land.surface) * yres(land.surface) cols <- names(div.by.entity[[1]]) - d <- bind_rows(lapply(div.by.entity, function(i) i[, cols])) + d <- dplyr::bind_rows(lapply(div.by.entity, function(i) i[, cols])) year.month <- rep(names(div.by.entity), times=vapply(div.by.entity, nrow, 0L)) d <- cbind(YearMonth=year.month, d) @@ -207,7 +390,7 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, d <- d[order(d$EntityName), c(2, 1, 3:ncol(d))] cell.count <- rep(NA, nrow(d)) for (i in yr.mo) { - r <- mask(crop(wrv::rs.entities[[i]], r.grid), r.grid) + r <- mask(crop(rs.entities[[i]], r.grid), r.grid) rat <- levels(r)[[1]] rat$COUNT <- freq(r, useNA="no")[, "count"] is <- d$YearMonth == i @@ -219,8 +402,8 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, d <- data.frame(YearMonth=yr.mo, Area=NA, ET=NA, Rech=NA) row.names(d) <- yr.mo for (i in yr.mo) { - r.rech <- crop(wrv::rs.rech.non.irr[[i]], r.grid) - r.et <- crop(wrv::et[[i]], r.grid) * cell.area # convert from length to vol. + r.rech <- crop(rs.rech.non.irr[[i]], r.grid) + r.et <- crop(et[[i]], r.grid) * cell.area # convert from length to vol. cells <- which(!is.na(r.grid[]) & !is.na(r.rech[])) d[i, "Area"] <- length(cells) * cell.area d[i, "ET"] <- sum(r.et[cells]) @@ -238,8 +421,8 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, FUN <- function(i) { d <- div.by.entity[[i]][, c("EntityName", "CanalSeep")] d <- d[d$CanalSeep != 0, ] - r <- wrv::r.canals - rat <- left_join(levels(r)[[1]], d, by="EntityName") + r <- r.canals + rat <- dplyr::left_join(levels(r)[[1]], d, by="EntityName") rat$CanalSeep <- rat$CanalSeep / rat$COUNT levels(r) <- rat[, c("ID", "CanalSeep")] r <- subs(r, levels(r)[[1]], subsWithNA=FALSE) @@ -249,10 +432,10 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, names(rs.rech.canals) <- yr.mo FUN <- function(i) { - r <- wrv::rs.entities[[i]] + r <- rs.entities[[i]] cols <- c("rech.mix", "rech.sw", "rech.muni", "rech.gw") - d <- left_join(levels(r)[[1]], div.by.entity[[i]][, c("EntityName", cols)], - by="EntityName") + d <- dplyr::left_join(levels(r)[[1]], div.by.entity[[i]][, c("EntityName", cols)], + by="EntityName") d$rech <- rowSums(d[, cols], na.rm=TRUE) / d$COUNT levels(r) <- d[, c("ID", "rech")] r <- subs(r, levels(r)[[1]], subsWithNA=FALSE) @@ -264,8 +447,8 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, ## FUN <- function(i) { - r <- sum(rs.rech.canals[[i]], rs.rech.irr[[i]], wrv::rs.rech.non.irr[[i]], - na.rm=TRUE) * (1 / GetDaysInMonth(i)) # m^3/month to m^3/day + r <- sum(rs.rech.canals[[i]], rs.rech.irr[[i]], rs.rech.non.irr[[i]], + na.rm=TRUE) * (1 / inlmisc::GetDaysInMonth(i)) # m^3/month to m^3/day return(r) } areal.rech <- crop(stack(lapply(yr.mo, FUN), quick=TRUE), r.grid) @@ -276,24 +459,24 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, sc.sources <- c("BUHLER DRAIN", "UNNAMED DRAIN", "UNNAMED STREAM", "CAIN CREEK", "LOVING CREEK", "SILVER CREEK") - is.sc.src <- wrv::comb.sw.irr$Source %in% sc.sources + is.sc.src <- comb.sw.irr$Source %in% sc.sources FUN <- function(i) { - d <- wrv::comb.sw.irr + d <- comb.sw.irr d$sw.rate <- 0 - priority.cut <- wrv::priority.cuts[wrv::priority.cuts$YearMonth == i, + priority.cut <- priority.cuts[priority.cuts$YearMonth == i, "Pdate_BWR"] is.lt <- !is.sc.src & (!is.na(priority.cut) & d$Pdate < priority.cut) d$sw.rate[is.lt] <- d$MaxDivRate[is.lt] - priority.cut <- wrv::priority.cuts[wrv::priority.cuts$YearMonth == i, + priority.cut <- priority.cuts[priority.cuts$YearMonth == i, "Pdate_SC"] is.lt <- is.sc.src & (!is.na(priority.cut) & d$Pdate < priority.cut) d$sw.rate[is.lt] <- d$MaxDivRate[is.lt] - d <- summarise_(group_by_(d, "WaterRight"), - MaxDivRate="sum(MaxDivRate, na.rm=TRUE)", - sw.rate="sum(sw.rate, na.rm=TRUE)") + d <- dplyr::summarise_(dplyr::group_by_(d, "WaterRight"), + MaxDivRate="sum(MaxDivRate, na.rm=TRUE)", + sw.rate="sum(sw.rate, na.rm=TRUE)") d$sw.curt <- 1 - d$sw.rate / d$MaxDivRate - d <- suppressWarnings(left_join(wrv::pod.gw, d, by="WaterRight")) + d <- suppressWarnings(dplyr::left_join(pod.gw, d, by="WaterRight")) d$gw.rate <- d$IrrRate is.na.sw.curt <- is.na(d$sw.curt) d$gw.rate[!is.na.sw.curt] <- d$IrrRate[!is.na.sw.curt] * @@ -301,15 +484,15 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, is.est <- !d$WMISNumber %in% div.gw[div.gw$YearMonth == i, "WMISNumber"] d <- d[is.est, ] - d.agg <- summarise_(group_by_(d, "EntityName"), - gw.rate="sum(gw.rate, na.rm=TRUE)") + d.agg <- dplyr::summarise_(dplyr::group_by_(d, "EntityName"), + gw.rate="sum(gw.rate, na.rm=TRUE)") d$fraction <- d$gw.rate / d.agg$gw.rate[match(d$EntityName, d.agg$EntityName)] d$gw.div <- 0 div <- div.by.entity[[i]][, c("EntityName", "gw.div.est")] idxs <- match(d$EntityName, div$EntityName) d$gw.div[!is.na(idxs)] <- d$fraction[!is.na(idxs)] * - div$gw.div.est[na.omit(idxs)] + div$gw.div.est[stats::na.omit(idxs)] return(d) } rech.by.pod <- lapply(yr.mo.irr, FUN) @@ -319,8 +502,8 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, rec <- gw.div.by.wmis.no[gw.div.by.wmis.no$YearMonth == i, c("WMISNumber", "GWDiv")] est <- rech.by.pod[[i]][, c("WMISNumber", "gw.div")] - est <- summarise_(group_by_(est, "WMISNumber"), - gw.div="sum(gw.div, na.rm=TRUE)") + est <- dplyr::summarise_(dplyr::group_by_(est, "WMISNumber"), + gw.div="sum(gw.div, na.rm=TRUE)") d <- merge(rec, est, all=TRUE, by="WMISNumber") d[[i]] <- rowSums(d[, c("GWDiv", "gw.div")], na.rm=TRUE) d <- d[, c("WMISNumber", i)] @@ -355,13 +538,13 @@ RunWaterBalance <- function(tr.stress.periods, r.grid, eff, seep, ## - FUN <- function(i) {pod.rech[[i]] * (1 / GetDaysInMonth(i))} # m3/mo to m3/d + FUN <- function(i) {pod.rech[[i]] * (1 / inlmisc::GetDaysInMonth(i))} # m3/mo to m3/d pod.rech[, -1] <- data.frame(lapply(names(pod.rech)[-1], FUN)) ## if (is.ss) { - ss.yr.mo <- format(head(ss.stress.periods, -1), "%Y%m") + ss.yr.mo <- format(utils::head(ss.stress.periods, -1), "%Y%m") r <- calc(subset(areal.rech, ss.yr.mo), fun=mean) names(r) <- "ss" areal.rech <- stack(areal.rech, r, quick=TRUE) diff --git a/R/SetPolygons.R b/R/SetPolygons.R deleted file mode 100644 index e49f347..0000000 --- a/R/SetPolygons.R +++ /dev/null @@ -1,64 +0,0 @@ -SetPolygons <- function(x, y, cmd=c("gIntersection", "gDifference"), - buffer.width=NA) { - - cmd <- match.arg(cmd) - - if (!inherits(x, c("SpatialPolygons", "SpatialPolygonsDataFrame"))) - stop("argument 'x' is the wrong class") - if (!inherits(y, c("SpatialPolygons", "SpatialPolygonsDataFrame", "Extent"))) - stop("argument 'y' is the wrong class") - - if (inherits(y, "Extent")) { - crds <- cbind(c(y[1:2], y[2:1], y[1]), c(rep(y[3], 2), rep(y[4], 2), y[3])) - y <- SpatialPolygons(list(Polygons(list(Polygon(crds)), "bbox")), - proj4string=crs(x)) - } - - if (inherits(x, "SpatialPolygonsDataFrame")) { - d <- x@data - rownames(d) <- sapply(slot(x, "polygons"), function(i) slot(i, "ID")) - } else { - d <- NULL - } - - x <- as(x, "SpatialPolygons") - y <- as(y, "SpatialPolygons") - y <- y[which(apply(gIntersects(y, x, byid=TRUE), 2, any)), ] - - are.intersecting <- gIntersects(x, y, byid=TRUE) - - FUN <- function (i) { - if (any(are.intersecting[, i])) { - y.intersect <- y[are.intersecting[, i]] - if (is.numeric(buffer.width)) - y.intersect <- gBuffer(y.intersect, width=buffer.width) - - x.geo <- do.call(cmd, list(x[i], gUnaryUnion(y.intersect), byid=TRUE)) - if (inherits(x.geo, "SpatialCollections")) - x.geo <- gUnaryUnion(x.geo@polyobj) - - is.valid <- suppressWarnings(gIsValid(x.geo, byid=TRUE)) - if (length(is.valid) == 0) return(NULL) - if (!is.valid) { - x.geo <- gBuffer(x.geo, width=0) - ans <- gIsValid(x.geo, byid=TRUE, reason=TRUE) - if (ans != "Valid Geometry") stop(paste("non-valid polygons:", ans)) - } - - p <- x.geo@polygons[[1]] - slot(p, "ID") <- slot(x[i]@polygons[[1]], "ID") - } else { - p <- if (cmd == "gIntersection") NULL else x[i]@polygons[[1]] - } - return(p) - } - z <- lapply(seq_along(x), FUN) - - is.retained <- !vapply(z, is.null, TRUE) - z <- SpatialPolygons(z[is.retained], proj4string=crs(x)) - if (inherits(d, "data.frame")) { - d <- d[is.retained, , drop=FALSE] - z <- SpatialPolygonsDataFrame(z, d, match.ID=TRUE) - } - return(z) -} diff --git a/R/SummariseBudget.R b/R/SummariseBudget.R deleted file mode 100644 index 58a3d2e..0000000 --- a/R/SummariseBudget.R +++ /dev/null @@ -1,60 +0,0 @@ -SummariseBudget <- function(budget, - desc=c("wells", "drains", "river leakage")) { - - if (!inherits(budget, "list")) { - budget <- budget[1] - if (is.character(budget) & file.access(budget) == 0) - budget <- ReadModflowBinary(budget, "flow") - else - stop("problem with 'budget' argument") - } - desc <- match.arg(desc, several.ok=TRUE) - - budget.desc <- as.factor(vapply(budget, function(i) i$desc, "")) - is.desc.not.included <- !desc %in% levels(budget.desc) - if (any(is.desc.not.included )) - warning(paste("missing flow variable(s) in budget file:", - paste(desc[is.desc.not.included], collapse=", "))) - budget <- budget[budget.desc %in% desc] - if (length(budget) == 0) - stop("flow variable(s) can not be found in the budget file") - - descs <- vapply(budget, function(i) make.names(i$desc), "") - - .Summarise <- function(b, desc) { - FUN <- function(j) { - d <- data.frame(desc=j$desc, kper=j$kper, kstp=j$kstp, id=NA, - flow=j$d[, make.names(j$desc)], delt=j$delt, - pertim=j$pertim, totim=j$totim, stringsAsFactors=FALSE) - if ("id" %in% colnames(j$d)) d$id <- as.integer(j$d[, "id"]) - return(d) - } - d <- bind_rows(lapply(desc, - function(i) bind_rows(lapply(b[desc == i], FUN)))) - d$desc <- as.factor(d$desc) - d <- summarise_(group_by_(d, "desc", "kper", "kstp", "id"), - delt="delt[1]", pertim="pertim[1]", totim="totim[1]", - count="length(flow)", - flow.sum="sum(flow)", - flow.mean="mean(flow)", - flow.median="stats::median(flow)", - flow.sd="sd(flow)") - return(d) - } - - b <- budget - for (i in seq_along(b)) { - b[[i]]$d[b[[i]]$d[, descs[i]] < 0, descs[i]] <- 0 - } - d <- mutate(.Summarise(b, desc), flow.dir="in") - - b <- budget - for (i in seq_along(b)) { - b[[i]]$d[b[[i]]$d[, descs[i]] > 0, descs[i]] <- 0 - } - d <- bind_rows(d, mutate(.Summarise(b, desc), flow.dir="out")) - - d$flow.dir <- as.factor(d$flow.dir) - - return(d) -} diff --git a/R/ToScientific.R b/R/ToScientific.R deleted file mode 100644 index 62ebd6e..0000000 --- a/R/ToScientific.R +++ /dev/null @@ -1,26 +0,0 @@ -ToScientific <- function(x, digits=format.info(as.numeric(x))[2], - lab.type=c("latex", "plotmath")) { - - lab.type <- match.arg(lab.type) - x[is.zero <- x == 0] <- NA - idxs <- which(is.finite(x)) - - m <- rep(NA, length(x)) - n <- m - n[idxs] <- floor(log(abs(x[idxs]), 10)) - m[idxs] <- sprintf("%0.*f", digits, x[idxs] / 10^n[idxs]) - if (lab.type == "latex") { - s <- rep(NA, length(x)) - s[idxs] <- sprintf("$%s \\times 10^{%d}$", m[idxs], n[idxs]) - s[is.zero] <- "0" - } else { - FUN <- function(i) { - if (i %in% which(is.zero)) return(quote(0)) - if (is.na(x[i])) return("") - return(substitute(paste(M, " x ", 10^N), list(M=m[i], N=n[i]))) - } - s <- lapply(seq_along(x), FUN) - s <- do.call("expression", s) - } - return(s) -} diff --git a/R/UpdateWaterBudget.R b/R/UpdateWaterBudget.R index d330cb9..6fd128c 100644 --- a/R/UpdateWaterBudget.R +++ b/R/UpdateWaterBudget.R @@ -1,6 +1,165 @@ +#' Update Water Budget +#' +#' This function determines the specified-flow boundary conditions for the groundwater-flow model. +#' These boundary conditions include: +#' (1) natural and incidental groundwater recharge at the water table, +#' (2) groundwater pumping at production wells, and +#' (3) groundwater underflow in the major tributary valleys. +#' Specified-flow values are saved to disk by rewriting the +#' \href{http://water.usgs.gov/ogw/modflow/}{MODFLOW} Well Package file (\file{.wel}). +#' Note that this function is executed after each iteration of \href{http://www.pesthomepage.org/}{PEST}. +# It may also be run in an interactive \R session to initialize model parameter files. +#' +#' @param dir.run character. +#' Path name of the directory to read/write model files. +#' @param id character. +#' Short identifier (file name) for model files. +#' @param qa.tables character. +#' Indicates if quality assurance tables are written to disk; +#' by default "none" of these tables are written. +#' Values of "si" and "english" indicate that table values are written in +#' metric and English units, respectively. +#' @param ss.interval Date or character. +#' Vector of length 2 specifying the start and end dates for the period used to +#' represent steady-state boundary conditions. +#' That is, recharge values for stress periods coinciding with this time period are +#' averaged and used as steady-state boundary conditions. +#' The required date format is YYYY-MM-DD. +#' This argument overrides the \code{ss.stress.periods} object in the \file{model.rda} file, +#' see \sQuote{Details} section for additional information. +#' @param iwelcb integer. +#' A flag and unit number. +#' If equal to zero, the default, cell-by-cell flow terms resulting from +#' conditions in the MODFLOW Well Package will not be written to disk. +#' A value of 0 is appropriate for model calibration, +#' where MODFLOW run times are kept as short as possible. +#' If greater than zero, the cell-by-cell flow terms are written to disk. +#' See the MODFLOW Name File (\file{*.nam}) for the unit number associated with +#' the budget file (\file{*.bud}). +#' The default value is 50 (value specified in the \code{\link{WriteModflowInput}} function) +#' if \R is being used interactively and 0 otherwise. +#' @param canal.seep data.frame. +#' See \code{\link{canal.seep}} dataset for details. +#' @param efficiency data.frame. +#' See \code{\link{efficiency}} dataset for details. +#' @param gage.disch data.frame. +#' See \code{\link{gage.disch}} dataset for details. +#' @param pod.wells SpatialPointsDataFrame. +#' See \code{\link{pod.wells}} dataset for details. +#' @param tributaries SpatialPolygonsDataFrame. +#' See \code{\link{tributaries}} dataset for details. +#' @param ... +#' Arguments to be passed to \code{\link{RunWaterBalance}}, such as evapotranspiration \code{et}. +#' +#' @details Files read during execution, and located within the \code{dir.run} directory, +#' inlcude the MODFLOW hydraulic conductivity reference files \file{hk1.ref}, +#' \file{hk2.ref}, and \file{hk3.ref} corresponding to model layers 1, 2, and 3, respectively. +#' Hydraulic conductivity values are read from a two-dimensional array in +#' matrix format with \sQuote{white-space} delimited fields. +#' And a binary data file \file{model.rda} containing the following serialized \R objects: +#' \code{rs}, \code{misc}, \code{trib}, \code{tr.stress.periods}, and \code{ss.stress.periods}. +#' +#' \code{rs} is an object of RasterStack class with raster layers \dQuote{lay1.top}, +#' \dQuote{lay1.bot}, \dQuote{lay2.bot}, and \dQuote{lay3.bot}. +#' These raster layers describe the geometry of the model grid; that is, +#' the upper and lower elevation of model layer 1, and the bottom elevations of model layers 2 and 3. +#' Missing cell values (equal to NA) indicate inactive model cells lying outside of the model domain. +#' +#' \code{misc} is a data.frame object with miscellaneous seepage, +#' such as from the \sQuote{Bellevue Waste Water Treatment Plant ponds} and the \sQuote{Bypass Canal}. +#' This object is comprised of the following components: +#' \bold{lay}, \bold{row}, \bold{col} are integer values specifying a +#' model cell's layer, row, and column index, respectively; and +#' \bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of +#' elevation during each stress period, respectively, +#' in meters above the North American Vertical Datum of 1988. +#' +#' \code{trib} is a data.frame object with default values for the +#' long-term mean underflows in each of the tributary basins. +#' The object is comprised of the following components: +#' \bold{Name} is a unique identifier for the tributary basin; +#' \bold{lay}, \bold{row}, \bold{col} are \code{integer} values of a +#' model cell's layer, row, and column index, respectively; and +#' \bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of +#' underflow during each stress period, respectively, in cubic meters per day. +#' +#' \code{tr.stress.periods} is a vector of Date values giving the start and end dates for +#' stress periods in the model simulation period (1995--2010). +#' +#' \code{ss.stress.periods} is a vector of Date values giving the start and end dates for +#' stress periods used to define steady-state conditions. +#' +#' \code{reduction} is a numeric default value for the signal amplitude reduction algorithm, +#' a dimensionless quantity. +#' +#' \code{d.in.mv.ave} is a numeric default value for the number of days in the +#' moving average subset. +#' +#' @return Returns an object of difftime class, the runtime for this function. +#' Used for the side-effect of files written to disk. +#' +#' A MODFLOW Well Package file \file{.wel} is always written to disk; whereas, +#' parameter estimation files \file{seep.csv}, \file{eff.csv}, and \file{trib.csv}, and +#' a script file \file{UpdateBudget.bat}, are only written if they do not already exist. +#' The script file may be used to automate the execution of this function from a +#' file manager (such as, Windows Explorer). +#' +#' The \file{seep.csv} file stores as tabular data the canal seepage fraction for +#' each of the irrigation entities. +#' Its character and numeric data fields are delimited by commas (a comma-separated-value [CSV] file). +#' The first line is reserved for field names \dQuote{EntityName} and \dQuote{SeepFrac}. +#' +#' The \file{eff.csv} file stores as tabular data the irrigation efficiency for +#' each of the irrigation entities. +#' Its character and numeric data fields are delimited by commas. +#' The first line is reserved for field names \dQuote{EntityName} and \dQuote{Eff}. +#' +#' The \file{trib.csv} file stores as tabular data the underflow boundary conditions for +#' each tributary basin. +#' Its character and numeric data fields are delimited by commas. +#' The first line is reserved for field names \dQuote{Name} and \dQuote{Value}. +#' Data records include a long-term mean flow multiplier for +#' each of the tributary basins (name is the unique identifier for the tributary), +#' a record for the amplitude reduction (\code{reduction}), and +#' a record for the number of days in the moving average (\code{d.in.mv.ave}). +#' +#' If the \code{qa.tables} argument is specified as either \dQuote{si} or \dQuote{english}, +#' quality assurance tables are written to disk as CSV files (\file{qa-*.csv}). +#' Volumetric flow rate data within these tables is described in the +#' \sQuote{Value} section of the \code{\link{RunWaterBalance}} function; +#' see returned list components \code{natural.rech}, \code{inciden.rech}, and \code{pumping.rech}. +#' The well configuration data are described in the \sQuote{Value} section of the +#' \code{\link{GetWellConfig}} function. +#' +#' @author J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center +#' +#' @seealso \code{\link{RunWaterBalance}}, \code{\link{GetSeasonalMult}} +#' +#' @keywords utilities +#' +#' @import sp +#' @import raster +#' +#' @export +#' +#' @examples +#' \dontrun{ +#' dir.run <- file.path(getwd(), "model/model1") +#' UpdateWaterBudget(dir.run, "wrv_mfusg", qa.tables = "si", +#' ss.interval = c("1998-01-01", "2011-01-01")) +#' } +#' + UpdateWaterBudget <- function(dir.run, id, qa.tables=c("none", "si", "english"), - ss.interval=NULL, iwelcb=0L) { + ss.interval=NULL, + iwelcb=ifelse(interactive(), 50L, 0L), + canal.seep=wrv::canal.seep, + efficiency=wrv::efficiency, + gage.disch=wrv::gage.disch, + pod.wells=wrv::pod.wells, + tributaries=wrv::tributaries, + ...) { # Initialize runtime @@ -9,7 +168,7 @@ UpdateWaterBudget <- function(dir.run, id, # Configure export of quality assurance tables qa.tables <- match.arg(qa.tables) - qa.write <- qa.tables != "none" + verbose <- qa.tables != "none" m2.to.acre <- 0.000247105 m3.to.af <- 0.000810713194 m.to.ft <- 3.28084 @@ -29,47 +188,47 @@ UpdateWaterBudget <- function(dir.run, id, f <- file.path(dir.run, "seep.csv") if (!file.exists(f)) - write.csv(wrv::canal.seep, file=f, quote=FALSE, row.names=FALSE) - seep <- read.csv(f) + utils::write.csv(canal.seep, file=f, quote=FALSE, row.names=FALSE) + canal.seep <- utils::read.csv(f) # Read irrigation efficiency from calibration file f <- file.path(dir.run, "eff.csv") if (!file.exists(f)) - write.csv(wrv::efficiency, file=f, quote=FALSE, row.names=FALSE) - eff <- read.csv(f) + utils::write.csv(efficiency, file=f, quote=FALSE, row.names=FALSE) + efficiency <- utils::read.csv(f) # Read tributary underflow control parameters from calibration file f <- file.path(dir.run, "trib.csv") if (!file.exists(f)) { - d <- data.frame(Name=wrv::tributaries$Name, Value=1) + d <- data.frame(Name=tributaries$Name, Value=1) d <- rbind(d, data.frame(Name=c("reduction", "d.in.mv.ave"), Value=c(reduction, d.in.mv.ave))) - write.csv(d, file=f, quote=FALSE, row.names=FALSE) + utils::write.csv(d, file=f, quote=FALSE, row.names=FALSE) } - d <- read.csv(f) + d <- utils::read.csv(f) reduction <- d$Value[d$Name == "reduction"] d.in.mv.ave <- d$Value[d$Name == "d.in.mv.ave"] - scale.factors <- head(d$Value, -2) - names(scale.factors) <- head(d$Name, -2) + scale.factors <- utils::head(d$Value, -2) + names(scale.factors) <- utils::head(d$Name, -2) # Process specified flows in tributary canyons - mult <- GetSeasonalMult(wrv::gage.disch[, c("Date", "13139510")], reduction, + mult <- GetSeasonalMult(gage.disch[, c("Date", "13139510")], reduction, d.in.mv.ave, tr.stress.periods) - mult <- data.frame(Date=head(tr.stress.periods, -1), + mult <- data.frame(Date=utils::head(tr.stress.periods, -1), multiplier=rep(mult$multiplier, each=3)) # seasonal to monthly - ave.flows <- wrv::tributaries$Flow - names(ave.flows) <- wrv::tributaries$Name + ave.flows <- tributaries$Flow + names(ave.flows) <- tributaries$Name scale.factors <- scale.factors[match(names(scale.factors), names(ave.flows))] ave.flows <- ave.flows * scale.factors d <- t(vapply(ave.flows, function(i) mult$multiplier * i, rep(0, nrow(mult)))) colnames(d) <- format(mult$Date, format="%Y%m") - ss.yr.mo <- format(head(ss.stress.periods, -1), "%Y%m") + ss.yr.mo <- format(utils::head(ss.stress.periods, -1), "%Y%m") d <- cbind(d, ss=apply(d[, ss.yr.mo], 1, mean)) trib[, colnames(d)] <- d[match(trib$Name, row.names(d)), ] trib[, colnames(d)] <- trib[, colnames(d)] / trib$count @@ -87,21 +246,21 @@ UpdateWaterBudget <- function(dir.run, id, # Process areal recharge and pumping demand - l <- RunWaterBalance(tr.stress.periods, rs[["lay1.bot"]], eff, seep, + l <- RunWaterBalance(rs[["lay1.bot"]], tr.stress.periods, ss.stress.periods=ss.stress.periods, - verbose=qa.write) + canal.seep=canal.seep, efficiency=efficiency, + verbose=verbose, ...) cells <- which(!is.na(l[["areal.rech"]][[1]][])) rc <- rowColFromCell(l[["areal.rech"]], cells) rech <- cbind(lay = 1, row = rc[, 1], col = rc[, 2], l[["areal.rech"]][cells]) - wells <- wrv::pod.wells[match(l[["pod.rech"]]$WMISNumber, - wrv::pod.wells@data$WMISNumber), ] + wells <- pod.wells[match(l[["pod.rech"]]$WMISNumber, pod.wells@data$WMISNumber), ] wells@data <- dplyr::left_join(wells@data, l[["pod.rech"]], by="WMISNumber") well <- GetWellConfig(rs, wells, "WMISNumber", names(l[["pod.rech"]][-1])) well.config <- well[, 1:7] # Combine recharge components into a single data frame - yr.mo <- c("ss", format(head(tr.stress.periods, -1), "%Y%m")) + yr.mo <- c("ss", format(utils::head(tr.stress.periods, -1), "%Y%m")) cols <- c("lay", "row", "col", yr.mo) rech <- as.matrix(cbind(rech[, cols], id=1)) @@ -138,8 +297,8 @@ UpdateWaterBudget <- function(dir.run, id, if (nrow(mm) == 0) next ds.5 <- paste(nrow(mm), 0, " # ITMP,NP STRESS PERIOD", i) cat(ds.5, file=f, sep="\n", append=TRUE) - write.table(mm, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(mm, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) } # Write batch file to run UpdateWaterBudget function @@ -147,7 +306,7 @@ UpdateWaterBudget <- function(dir.run, id, f <- file.path(dir.run, "UpdateBudget.bat") if (!file.exists(f)) { cmd <- shQuote(paste0(file.path(R.home(component="bin"), "Rscript"))) - cmd <- paste(cmd, "--vanilla --default-packages=utils,stats,wrv -e") + cmd <- paste(cmd, "--vanilla --default-packages=utils,stats,raster,wrv -e") cmd <- paste(cmd, shQuote(paste0("UpdateWaterBudget(", shQuote("."), ", ", shQuote(id), ")"))) cat(cmd, file=f, sep="\n") @@ -156,7 +315,7 @@ UpdateWaterBudget <- function(dir.run, id, # Write recharge quality assurance tables - if (qa.write) { + if (verbose) { d <- l[["inciden.rech"]] misc.cols <- c("EntityName", "YearMonth", "SeepFrac", "Eff") area.cols <- c("area.sw", "area.mix", "area.gw", "area.model") @@ -172,7 +331,7 @@ UpdateWaterBudget <- function(dir.run, id, names(d)[m3] <- paste0(names(d)[m3], "_m3") } f <- file.path(dir.run, "qa-incidental.csv") - write.csv(d, file=f, quote=FALSE, row.names=FALSE) + utils::write.csv(d, file=f, quote=FALSE, row.names=FALSE) d <- l[["natural.rech"]] cols <- match(c("Area", "ET", "Rech"), names(d)) @@ -185,7 +344,7 @@ UpdateWaterBudget <- function(dir.run, id, names(d)[cols] <- c("Area_m2", "ET_m3", "Rech_m3") } f <- file.path(dir.run, "qa-natural.csv") - write.csv(d, file=f, quote=FALSE, row.names=FALSE) + utils::write.csv(d, file=f, quote=FALSE, row.names=FALSE) d <- l[["pumping.rech"]] if (qa.tables == "english") { @@ -195,7 +354,7 @@ UpdateWaterBudget <- function(dir.run, id, names(d)[3] <- paste0(names(d)[3], "_m3") } f <- file.path(dir.run, "qa-pumping.csv") - write.csv(d, file=f, quote=FALSE, row.names=FALSE) + utils::write.csv(d, file=f, quote=FALSE, row.names=FALSE) d <- well.config if (qa.tables == "english") { @@ -208,7 +367,7 @@ UpdateWaterBudget <- function(dir.run, id, names(d)[6] <- paste0(names(d)[6], "_m") } f <- file.path(dir.run, "qa-well-config.csv") - write.csv(d, file=f, quote=FALSE, row.names=FALSE) + utils::write.csv(d, file=f, quote=FALSE, row.names=FALSE) } # Return runtime diff --git a/R/WriteModflowInput.R b/R/WriteModflowInput.R index cfd1409..e2b6562 100644 --- a/R/WriteModflowInput.R +++ b/R/WriteModflowInput.R @@ -1,3 +1,141 @@ +#' Write MODFLOW Input Files +#' +#' This function generates and writes input files for a MODFLOW simulation of +#' groundwater flow in the Wood River Valley (WRV) aquifer system. +#' +#' @param rs.model RasterStack. +#' Collection of RasterLayer objects with the same extent and resolution, +#' see \sQuote{Details} for required raster layers. +#' @param rech data.frame. +#' Areal recharge rate, in cubic meters per day. +#' Variables describe the model cell location (\code{lay}, \code{row}, \code{col}) and +#' volumetric rate during each stress period +#' (\code{ss}, \code{199501}, \code{199502}, \dots, \code{201012}). +#' @param well data.frame. +#' Well pumping at point locations in cubic meters per day. +#' Variables describe the model cell location and volumetric rate during each stress period. +#' @param trib data.frame. +#' Incoming flows from the major tributary canyons. +#' Variables describe the model cell location and volumetric rate during each stress period. +#' @param misc data.frame. +#' Direct recharge from miscellaneous seepage sites in cubic meters per day. +#' Variables describe the model cell location and volumetric rate during each stress period. +#' @param river data.frame. +#' River conditions. +#' Variables describe the model cell location, river conductance +#' (\code{cond}) in square meters per day, river bottom elevation (\code{bottom}) in +#' meters above the North American Vertical Datum of 1988 (NAVD 88), and +#' a numeric river reach identifier (\code{id}). +#' @param drain data.frame. +#' Drain conditions for groundwater outlet boundaries. +#' Variables describe the model cell location, drain threshold elevation +#' (\code{elev}) in meters above the NAVD 88, drain conductance (\code{cond}) in +#' square meters per day, and a numeric identifier (\code{id}) indicating the +#' drains general location. +#' @param id character. +#' Short identifier for the model run. +#' @param dir.run character. +#' Path name of the directory to write model input files. +#' @param is.convertible logical. +#' If true, indicates model layers are \sQuote{convertible}, with +#' transmissivity computed using upstream water-table depth. +#' Otherwise, model layers are \sQuote{confined} and transmissivity is constant over time. +#' @param ss.perlen integer or difftime. +#' Length of the steady-state stress period in days. +#' @param tr.stress.periods Date. +#' Vector of start times for each stress period in the transient simulation. +#' If missing, only steady-state conditions are simulated. +#' @param ntime.steps integer. +#' Number of uniform time steps in a stress period. +#' @param mv.flag numeric. +#' Missing value flag for output reference data files. +#' @param auto.flow.reduce logical. +#' If true, a simulated well will adjust pumping according to +#' supply under bottom-hole conditions. +#' Pumping rates that have been automatically reduced will be written to a +#' model output file (\file{.afr}). +#' @param verbose logical. +#' If true, additional information is written to the +#' listing file (\file{.lst}) and budget file (\file{.bud}) +#' +#' @details Groundwater flow in the WRV aquifer system is simulated using the +#' \href{http://water.usgs.gov/ogw/mfusg/}{MODFLOW-USG} groundwater-flow model. +#' This numerical model was chosen for its ability to solve +#' complex unconfined groundwater flow simulations. +#' The solver implemented in MODFLOW-USG incorporates the Newton-Raphson formulation for +#' improving solution convergence and avoiding problems with the drying and +#' rewetting of cells (Niswonger and others, 2011). +#' A structured finite-difference grid is implemented in the model to +#' (1) simplify discretization, +#' (2) keep formats and structures for the MODFLOW-USG packages identical to those of +#' \href{http://water.usgs.gov/nrp/gwsoftware/modflow2005/Guide/index.html}{MODFLOW-2005}, and +#' (3) allow any MODFLOW post-processor to be used to analyze the results of the MODFLOW-USG simulation +#' (such as \href{http://water.usgs.gov/nrp/gwsoftware/modelviewer/ModelViewer.html}{Model Viewer}). +#' +#' Model input files are written to \code{dir.run} and include the following MODFLOW Package files: +#' Name (\file{.nam}), Basic (\file{.ba6}), Discretization (\file{.dis}), +#' Layer-Property Flow (\file{.lpf}), Drain (\file{.drn}), River (\file{.riv}), +#' Well (\file{.wel}), Sparse Matrix Solver (\file{.sms}), and Output Control (\file{.oc}). +#' See the users guide (\cite{Description of Model Input and Output}) included with the MODFLOW-USG +#' software for details on input file formats and structures. +#' +#' Data within the \code{rech}, \code{well}, \code{trib}, and \code{misc} arguments are +#' combined in the MODFLOW Well Package and identifiable with added \code{id} values of +#' 1, 2, 3, and 4, respectively. +#' +#' The Layer-Property Flow file includes options for the calculation of vertical flow in +#' partially dewatered cells. +#' For the WRV model, where there is no indication that perched conditions exist, +#' CONSTANTCV and NOVFC options are used to create the most stable solution +#' (Panday and others, 2013, p. 15-16). +#' Options for the Sparse Matrix Solver were set for unconfined simulations by +#' implementing an upstream-weighting scheme with Newton-Raphson linearization, +#' Delta-Bar-Delta under-relaxation, and the \eqn{\chi}MD solver of Ibaraki (2005). +#' +#' The raster stack \code{rs.model} includes the following layers: +#' \describe{ +#' \item{lay1.top}{elevation at the top of model layer 1 (land surface), +#' in meters above the NAVD 88.} +#' \item{lay1.bot}{elevation at the bottom of model layer 1, in meters above the NAVD 88.} +#' \item{lay2.bot}{elevation at the bottom of model layer 2.} +#' \item{lay3.bot}{elevation at the bottom of model layer 3.} +#' \item{lay1.strt}{initial (starting) hydraulic head in model layer 1, +#' in meters above the NAVD 88.} +#' \item{lay2.strt}{initial hydraulic head in model layer 2.} +#' \item{lay3.strt}{initial hydraulic head in model layer 3.} +#' \item{lay1.zones}{hydrogeologic zones in model layer 1 where values +#' equal to 1 is unconfined alluvium, equal to 2 is basalt, +#' equal to 3 is clay, and equal to 4 is confined alluvium.} +#' \item{lay2.zones}{hydrogeologic zones in model layer 2.} +#' \item{lay3.zones}{hydrogeologic zones in model layer 3.} +#' \item{lay1.hk}{horizontal hydraulic conductivity in model layer 1, in meters per day.} +#' \item{lay2.hk}{horizontal hydraulic conductivity in model layer 2.} +#' \item{lay3.hk}{horizontal hydraulic conductivity in model layer 3.} +#' } +#' +#' @return Used for the side-effect of files written to disk. +#' +#' @author J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center +#' +#' @references Ibaraki, M., 2005, \eqn{\chi}MD User's guide-An efficient sparse matrix solver library, version 1.30: +#' Columbus, Ohio State University School of Earth Sciences. +#' +#' Niswonger, R.G., Panday, Sorab, and Ibaraki, Motomu, 2011, MODFLOW-NWT, A Newton formulation for MODFLOW-2005: +#' U.S. Geological Survey Techniques and Methods 6-A37, 44 p., available at \url{http://pubs.usgs.gov/tm/tm6a37/}. +#' +#' Panday, Sorab, Langevin, C.D., Niswonger, R.G., Ibaraki, Motomu, and Hughes, J.D., 2013, MODFLOW-USG version 1: +#' An unstructured grid version of MODFLOW for simulating groundwater flow and tightly coupled processes using a +#' control volume finite-difference formulation: U.S. Geological Survey Techniques and Methods, book 6, chap. A45, +#' 66 p., available at \url{http://pubs.usgs.gov/tm/06/a45/}. +#' +#' @keywords IO +#' +#' @export +#' +#' @examples +#' \dontrun{# see Appendix D. Uncalibrated Groundwater-Flow Model} +#' + WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, id, dir.run, is.convertible=FALSE, ss.perlen=0L, tr.stress.periods=NULL, ntime.steps=4L, @@ -21,7 +159,7 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, perlen <- c(perlen, as.integer(diff(tr.stress.periods))) nstp <- c(nstp, rep(as.integer(ntime.steps), length(tr.stress.periods) - 1L)) ss.tr <- c(ss.tr, rep("TR", length(perlen) - 1L)) - yr.mo <- c(yr.mo, format(head(tr.stress.periods, -1), "%Y%m")) + yr.mo <- c(yr.mo, format(utils::head(tr.stress.periods, -1), "%Y%m")) } # Unique unit numbers for output files @@ -54,8 +192,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, r <- !is.na(rs.model[[paste0("lay", i, ".bot")]]) r[] <- as.integer(r[]) m <- format(raster::as.matrix(r), justify="right", width=2) - write.table(m, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(m, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) } hnoflo <- 9999 @@ -67,8 +205,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, cat(ds.4, file=f, sep="\n", append=TRUE) m <- raster::as.matrix(rs.model[[paste0("lay", i, ".strt")]]) m[is.na(m)] <- hnoflo - write.table(m, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(m, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) } # Discretization file (DIS) @@ -98,21 +236,21 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, m <- raster::as.matrix(rs.model[["lay1.top"]]) m[is.na(m)] <- 0.0 - write.table(m, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(m, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) for (i in 1:3) { ds.6 <- paste("INTERNAL 1 (FREE)", iprn, " # BOTM layer", i) cat(ds.6, file=f, sep="\n", append=TRUE) m <- raster::as.matrix(rs.model[[paste0("lay", i, ".bot")]]) m[is.na(m)] <- 0.0 - write.table(m, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(m, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) } ds.7 <- data.frame(perlen=perlen, nstp=nstp, tsmult=1, ss.tr=ss.tr) - write.table(ds.7, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(ds.7, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) # Layer-Property Flow file (LPF) @@ -157,8 +295,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, cat(ds.13 <- 0, file=f, sep="\n", append=TRUE) r <- rs.model[[paste0("lay", i, ".hk")]] r[is.na(r)] <- mv.flag - write.table(raster::as.matrix(r), file=file.path(dir.run, f.ref), - quote=FALSE, row.names=FALSE, col.names=FALSE) + utils::write.table(raster::as.matrix(r), file=file.path(dir.run, f.ref), + quote=FALSE, row.names=FALSE, col.names=FALSE) if (!is.transient) next f.ref <- paste0("ss", i, ".ref") @@ -166,8 +304,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, cat(fmt, file=f, sep="\n", append=TRUE) r <- deratify(rs.model[[z]], ifelse(is.convertible, "ss", "sc")) r[is.na(r)] <- mv.flag - write.table(raster::as.matrix(r), file=file.path(dir.run, f.ref), - quote=FALSE, row.names=FALSE, col.names=FALSE) + utils::write.table(raster::as.matrix(r), file=file.path(dir.run, f.ref), + quote=FALSE, row.names=FALSE, col.names=FALSE) if (!is.convertible) next f.ref <- paste0("sy", i, ".ref") @@ -175,8 +313,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, cat(fmt, file=f, sep="\n", append=TRUE) r <- deratify(rs.model[[z]], "sy") r[is.na(r)] <- mv.flag - write.table(raster::as.matrix(r), file=file.path(dir.run, f.ref), - quote=FALSE, row.names=FALSE, col.names=FALSE) + utils::write.table(raster::as.matrix(r), file=file.path(dir.run, f.ref), + quote=FALSE, row.names=FALSE, col.names=FALSE) } # Drain file (DRN) @@ -197,8 +335,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, cat(ds.2, file=f, sep="\n", append=TRUE) ds.5 <- paste(nrow(d), 0, " # ITMP,NP") cat(ds.5, file=f, sep="\n", append=TRUE) - write.table(d, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(d, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) if (is.transient) { ds.5 <- paste(-1, 0, " # ITMP,NP") for (i in 2:length(perlen)) { @@ -226,8 +364,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, ds.5 <- paste(n, 0L, " # ITMP,NP STRESS PERIOD", i) cat(ds.5, file=f, sep="\n", append=TRUE) d <- river[, c("lay", "row", "col", i, "cond", "bottom", "id")] - write.table(d, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(d, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) } # Well file (WEL) @@ -259,8 +397,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, if (nrow(mm) == 0) next ds.5 <- paste(nrow(mm), 0, " # ITMP,NP STRESS PERIOD", i) cat(ds.5, file=f, sep="\n", append=TRUE) - write.table(mm, file=f, append=TRUE, quote=FALSE, row.names=FALSE, - col.names=FALSE) + utils::write.table(mm, file=f, append=TRUE, quote=FALSE, row.names=FALSE, + col.names=FALSE) } # Sparse Matrix Solver file (SMS) @@ -319,8 +457,8 @@ WriteModflowInput <- function(rs.model, rech, well, trib, misc, river, drain, nam <- rbind(nam, data.frame(ftype="DATA", nunit=nunit.txt, fname=paste0(id, ".afr"))) f <- file.path(dir.run, paste0(id, ".nam")) - write.table(nam, file=f, append=FALSE, quote=FALSE, sep=" ", - row.names=FALSE, col.names=FALSE) + utils::write.table(nam, file=f, append=FALSE, quote=FALSE, sep=" ", + row.names=FALSE, col.names=FALSE) invisible(NULL) } diff --git a/R/data.R b/R/data.R new file mode 100644 index 0000000..49eac7d --- /dev/null +++ b/R/data.R @@ -0,0 +1,1830 @@ +#' Extent of Alluvium Unit +#' +#' Estimated extent of alluvium unit in the Wood River Valley aquifer system. +#' +#' @format An object of SpatialPolygonsDataFrame class containing 1 Polygons. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Extent defined by Bartollino and Adkins (2012, Plate 1). +#' +#' @references Bartolino, J.R., and Adkins, C.B., 2012, +#' Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: +#' U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., +#' available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(alluvium.extent, col = "#BFA76F") +#' str(alluvium.extent) +#' +"alluvium.extent" + +#' Thickness of the Quaternary Sediment +#' +#' Estimated thickness of the Quaternary sediment in the Wood River Valley aquifer system. +#' +#' @format An object of RasterLayer class. +#' Each cell on the surface grid represents a depth measured from land surface in meters. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' The spatial grid is composed of 565 rows and 429 columns, +#' and has cell sizes that are constant at 100 meters by 100 meters. +#' +#' @source Revised version of Plate 1 in Bartolino and Adkins (2012). +#' +#' @references Bartolino, J.R., and Adkins, C.B., 2012, +#' Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: +#' U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., +#' available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +#' +#' @keywords datasets +#' +#' @examples +#' col <- rainbow(255, start = 0.0, end = 0.8) +#' raster::image(alluvium.thickness, col = col, asp = 1, axes = FALSE, +#' xlab = "", ylab = "") +#' summary(alluvium.thickness) +#' +"alluvium.thickness" + +#' Extent of Basalt Unit +#' +#' Estimated extent of the basalt unit underlying the alluvial Wood River Valley aquifer system. +#' +#' @format An object of SpatialPolygonsDataFrame class containing 1 Polygons. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Extent defined by Bartollino and Adkins (2012, Plate 1). +#' +#' @references Bartolino, J.R., and Adkins, C.B., 2012, +#' Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: +#' U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., +#' available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(basalt.extent, col = "#BEAED4", border = NA) +#' sp::plot(alluvium.extent, add = TRUE) +#' str(basalt.extent) +#' +"basalt.extent" + +#' Bellevue Waste Water Treatment Plant Ponds +#' +#' Location of the Bellevue Waste Water Treatment Plant ponds. +#' +#' @format An object of SpatialPolygonsDataFrame class containing 1 Polygons. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on December 11, 2014 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(bellevue.wwtp.ponds) +#' +"bellevue.wwtp.ponds" + +#' Bypass Canal +#' +#' Location of the Bypass Canal in the Wood River Valley. +#' +#' @format An object of SpatialLines class containing 4 Lines. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on January 15, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(bypass.canal) +#' +"bypass.canal" + +#' Canal Seepage +#' +#' Canal seepage as a fraction of diversions for irrigation entities in the Wood River Valley. +#' +#' @format An object of class data.frame with 19 records and the following variables: +#' \describe{ +#' \item{EntityName}{name of the irrigation entity served by the canal system.} +#' \item{SeepFrac}{estimated canal seepage as a fraction of diversions.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on November 4, 2015 +#' +#' @seealso \code{\link{canals}} +#' +#' @keywords datasets +#' +#' @examples +#' str(canal.seep) +#' +#' d <- canal.seep[order(canal.seep$SeepFrac, decreasing=TRUE), ] +#' par(mar = c(4.1, 8.1, 0.1, 0.6)) +#' barplot(d$SeepFrac, names.arg = d$EntityName, horiz = TRUE, cex.names = 0.7, +#' cex.axis = 0.7, cex.lab = 0.7, las = 1, xlab = "Seepage fraction") +#' +#' graphics.off() +#' +"canal.seep" + +#' Canal Systems +#' +#' Canal systems in the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialLinesDataFrame class containing +#' 113 Lines and a data.frame with the following variable: +#' \describe{ +#' \item{EntityName}{name of the irrigation entity served by the canal system.} +#' \item{Name}{local canal name} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on November 29, 2014 +#' +#' @seealso \code{\link{r.canals}}, \code{\link{canal.seep}} +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(canals, col = "#3399CC") +#' str(canals@data) +#' +"canals" + +#' Cities and Towns +#' +#' Cities and towns in the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialPointsDataFrame class containing 11 points. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources +#' (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +#' accessed on April 15, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' str(cities) +#' +#' col <- "#333333" +#' sp::plot(cities, pch = 15, cex = 0.8, col = col) +#' text(cities, labels = cities@data$FEATURE_NA, col = col, cex = 0.5, pos = 1, offset = 0.4) +#' +"cities" + +#' Extent of Clay Unit +#' +#' Estimated extent of the clay confining unit (aquitard) separating the +#' unconfined aquifer from the underlying confined aquifer in the +#' Wood River Valley aquifer system. +#' +#' @format An object of SpatialPolygonsDataFrame class containing 2 Polygons. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Extent defined by Moreland (1977, fig. 3 in USGS Open-File report). +#' Moreland (1977) shows an outlier by Picabo that is assumed to +#' indicate confined conditions in the basalt and not the lake sediments. +#' +#' @references Moreland, J.A., 1977, Ground water-surface water relations in the Silver Creek area, +#' Blaine County, Idaho: Boise, Idaho Department of Water Resources, Water Information Bulletin 44, +#' 42 p., 5 plates in pocket, accessed January 31, 2012. +#' Also published as U.S. Geological Survey Open-File report 77-456, 66 p., +#' available at \url{http://pubs.er.usgs.gov/pubs/ofr/ofr77456}. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(clay.extent, col = "#FDC086", border = NA) +#' sp::plot(alluvium.extent, add = TRUE) +#' str(clay.extent) +#' +"clay.extent" + +#' Combined Surface-Water Irrigation Diversions +#' +#' Supplemental groundwater rights and associated surface-water rights. +#' +#' @format An object of class data.frame with 1,213 records and the following variables: +#' \describe{ +#' \item{WaterRight}{name of the supplemental groundwater right.} +#' \item{CombWaterRight}{name of the surface-water right that shares a +#' combined limit with the groundwater right.} +#' \item{Source}{river or stream source name for the surface-water right.} +#' \item{WaterUse}{authorized beneficial use for the surface-water right.} +#' \item{MaxDivRate}{authorized maximum diversion rate for the surface-water right, +#' in cubic meters per day.} +#' \item{Pdate}{priority date of the surface-water right.} +#' } +#' +#' @source Idaho Department of Water Resources (IDWR), accessed on April 25, 2014; +#' derived from combined limit comments in IDWR water rights database. +#' +#' @keywords datasets +#' +#' @examples +#' str(comb.sw.irr) +#' +"comb.sw.irr" + +#' Groundwater Diversions +#' +#' Groundwater diversions recorded by Water District 37 or municipal water providers. +#' Groundwater is diverted from the aquifer by means of either pumping wells or +#' flowing-artesian wells. +#' +#' @format An object of class data.frame with 7,292 records and the following variables: +#' \describe{ +#' \item{YearMonth}{year and month during which diversions were recorded, +#' with a required date format of YYYYMM.} +#' \item{Diversion}{name of the well} +#' \item{Reach}{name of the river subreach into which the well water is discharged; +#' only applicable to exchange wells.} +#' \item{BigReach}{name of the river reach into which the well water is discharged; +#' only applicable to exchange wells.} +#' \item{EntityName}{name of the irrigation entity which the well supplies water.} +#' \item{WMISNumber}{well number in the Idaho Department of Water Resources (IDWR) +#' Water Measurement Information System.} +#' \item{GWDiv}{volume of water diverted during the month, in cubic meters.} +#' } +#' +#' @source Idaho Department of Water Resources (IDWR), accessed on December 11, 2014; +#' compiled data records from Water District 37 and 37M, City of Ketchum, +#' Sun Valley Water and Sewer District, City of Hailey, and City of Bellevue. +#' +#' @keywords datasets +#' +#' @examples +#' str(div.gw) +#' +"div.gw" + +#' Diversions, Returns, and Exchange Wells +#' +#' Location of streamflow diversions, irrigation canal or pond returns, and +#' exchange well returns. +#' +#' @format An object of SpatialPointsDataFrame class containing 117 points with the +#' following variables: +#' \describe{ +#' \item{Name}{local name for the diversion/return site.} +#' \item{Type}{data type, either \dQuote{Diversion}, \dQuote{Return}, or +#' \dQuote{Exchange well inflow}.} +#' \item{LocSource}{data source} +#' \item{Big}{corresponding river reach} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on June 5, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(div.ret.exch) +#' str(div.ret.exch@data) +#' +"div.ret.exch" + +#' Surface-Water Diversions +#' +#' Surface-water diversions recorded by Water District 37 or municipal water providers. +#' +#' @format An object of class data.frame with 15,550 records and the following variables: +#' \describe{ +#' \item{YearMonth}{year and month during which diversions were recorded, +#' with a required date format of YYYYMM.} +#' \item{Diversion}{name of the surface-water diversion.} +#' \item{Reach}{river subreach from which the water is diverted.} +#' \item{BigReach}{river reach from which the water is diverted.} +#' \item{EntityName}{name of the irrigation entity which the diversion supplies water.} +#' \item{SWDiv}{volume of water diverted during the month, in cubic meters.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on December 11, 2014; +#' compiled data records from Water District 37 and 37M, City of Hailey, +#' City of Bellevue, City of Ketchum, and Sun Valley Water and Sewer District. +#' +#' @keywords datasets +#' +#' @examples +#' str(div.sw) +#' +"div.sw" + +#' Wastewater Treatment Plant Diversions +#' +#' Discharge from wastewater treatment plants. +#' +#' @format An object of class data.frame with 1,182 records and the following variables: +#' \describe{ +#' \item{YearMonth}{year and month during which diversions were recorded, +#' with a required date format of YYYYMM.} +#' \item{Return}{name of the wastewater treatment plant.} +#' \item{Reach}{name of the river subreach to which treated effluent is discharged; +#' only applicable to wastewater treatment plants that discharge to the river.} +#' \item{BigReach}{name of the river reach to which treated effluent is discharged; +#' only applicable to wastewater treatment plants that discharge to the river.} +#' \item{EntityName}{name of the irrigation entity served by the wastewater treatment plant.} +#' \item{WWDiv}{volume of wastewater discharged during the month, in cubic meters.} +#' } +#' +#' @source Idaho Department of Water Resources and U.S. Geological Survey, +#' accessed on August 11, 2014; compiled data records from the +#' U.S. Environmental Protection Agency for plants that discharge to the river, +#' and from records of the Idaho Department of Environmental Quality for +#' plants that discharge to land application. +#' +#' @keywords datasets +#' +#' @examples +#' str(div.ww) +#' +"div.ww" + +#' Drain Boundaries at Stanton Crossing and Silver Creek +#' +#' Polygons used to define the locations of drain boundaries in the model domain. +#' The polygons clip the line segments along the aquifer boundary (see \code{\link{alluvium.extent}}), +#' and model cells intersecting these clipped-line segments are defined as boundary cells. +#' +#' @format An object of SpatialPolygonsDataFrame class containing a set of 2 Polygons and +#' a data.frame with the following variable: +#' \describe{ +#' \item{Name}{identifier for the polygon.} +#' \item{cond}{drain conductance in square meters per day.} +#' \item{elev}{drain threshold elevation in meters above the +#' North American Vertical Datum of 1988 (NAVD 88).} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source U.S. Geological Survey, accessed on March 27, 2015; +#' a Keyhole Markup Language (\href{http://en.wikipedia.org/wiki/Kml}{KML}) file created in +#' \href{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in +#' areas of known drains. +#' +#' @keywords datasets +#' +#' @examples +#' str(drains) +#' +#' sp::plot(drains, border = "red") +#' sp::plot(alluvium.extent, add = TRUE) +#' +"drains" + +#' Dry River Bed and Stream Fed Creek Conditions +#' +#' A summary of dry river bed and stream fed conditions in the Wood River Valley, Idaho. +#' Stream reaches on the Big Wood River between Glendale and Wood River Ranch are episodically dry; +#' these dry periods are specified for calendar months when water diversions to the +#' Bypass Canal begins before the 16th of the month and ends after the 15th of the month. +#' +#' @format An object of data.frame class with 12 records and the following variables: +#' \describe{ +#' \item{Reach}{stream reach name} +#' \item{199501,\dots,201012}{logical values indicating whether the stream reach exhibits +#' dry-bed conditions during a stress period.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on January 6, 2016; +#' compiled from Water District 37 records. +#' +#' @keywords datasets +#' +#' @examples +#' str(drybed) +#' +"drybed" + +#' Irrigation Efficiency +#' +#' The irrigation efficiency of irrigation entities in the Wood River Valley, Idaho. +#' +#' @format An object of data.frame class with 88 records and the following variables: +#' \describe{ +#' \item{EntityName}{name of the irrigation entity which the irrigation efficiency is applied.} +#' \item{Eff}{estimated irrigation efficiency, the ratio of the amount of +#' water consumed by the crop to the amount of water supplied through irrigation.} +#' \item{Comment}{brief comment on irrigation conditions.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on July 9, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' str(efficiency) +#' +"efficiency" + +#' Irrigation Entity Components +#' +#' Irrigation entities and their components in the Wood River Valley and surrounding areas. +#' An irrigation entity is defined as an area served by a group of surface-water and/or +#' groundwater diversion(s). +#' +#' @format An object of list class with components of SpatialPolygonsDataFrame-class. +#' There are a total of 192 components, one for each month in the 1995--2010 time period. +#' Linked data.frame objects have the following variables: +#' \describe{ +#' \item{EntitySrce}{concatenation of the \code{EntityName} and \code{Source} character strings.} +#' \item{mean.et}{mean evapotranspiration (ET) on irrigated and semi-irrigated lands in meters.} +#' \item{area}{area of irrigated and semi-irrigated lands in square meters.} +#' \item{PrecipZone}{name of the precipitation zone; +#' see \code{\link{precip.zones}} dataset for details.} +#' \item{et.vol}{volume of ET on irrigated and semi-irrigated lands in cubic meters.} +#' \item{precip.vol}{volume of precipitation on irrigated and semi-irrigated lands in cubic meters.} +#' \item{cir.vol}{volume of crop irrigation requirement in cubic meters (ET minus precipitation).} +#' \item{EntityName}{name of the irrigation entity.} +#' \item{Source}{water source, either \dQuote{Mixed} for a mixture of surface water and groundwater, +#' \dQuote{SW Only} for surface water only, or \dQuote{GW Only} for groundwater only.} +#' } +#' +#' @source Calculated from the \code{\link{irr.entities}}, \code{\link{wetlands}}, +#' \code{\link{public.parcels}}, \code{\link{irr.lands.year}}, \code{\link{et}}, and +#' \code{\link{precipitation}} datasets; +#' see the \file{package-datasets} vignette for the \R code used in this calculation. +#' +#' @keywords datasets +#' +#' @examples +#' names(entity.components) +#' sp::plot(entity.components[["199506"]]) +#' print(entity.components[["199506"]]) +#' +"entity.components" + +#' Evapotranspiration +#' +#' Evapotranspiration (ET) in the Wood River Valley and surrounding areas. +#' Defined as the amount of water lost to the atmosphere via direct evaporation, +#' transpiration by vegetation, or sublimation from snow covered areas. +#' +#' @format An object of RasterStack class containing 192 RasterLayer objects, +#' one layer for each month in the 1995-2010 time period. +#' Each cell on a layers surface grid represents the monthly depth of ET in meters. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on November 17, 2014 +#' +#' @seealso \code{\link{et.method}} +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(et[["199505"]]) +#' print(et) +#' +"et" + +#' Method Used to Calculate Evapotranspiration +#' +#' Methods used to estimate monthly distributions of evapotranspiration (ET) rate. +#' +#' @format An object of data.frame class with 122 records with the following variables: +#' \describe{ +#' \item{YearMonth}{year and month during which the method was applied, +#' with a required date format of YYYYMM.} +#' \item{ETMethod}{Identifier that indicates the method used to estimate ET values. +#' Identifiers include either +#' \dQuote{Allen-Robison}, the Allen and Robison method (Allen and Robison, 2007); +#' \dQuote{METRIC}, the Mapping Evapotranspiration at high Resolution and with +#' Internalized Calibration (METRIC) model (Allen and others, 2010a); +#' \dQuote{NDVI}, the Normalized Difference Vegetation Index (NDVI) method +#' (Allen and others, 2010b); +#' \dQuote{Interpolation}, interpolation from known ET data; or +#' \dQuote{METRIC-NDVI}, a combination of METRIC and NDVI methods.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on April 27, 2015 +#' +#' @references Allen, R., and Robison, C.W., 2007, Evapotranspiration and +#' consumptive water requirements for Idaho, University of Idaho, Kimberly, Idaho. +#' +#' Allen, R., Tasumi, M., Trezza, R., and Kjaersgaard, J., 2010a, +#' METRIC mapping evapotranspiration at high resolution applications manual for +#' Landsat satellite imagery version 2.07, University of Idaho, Kimberly, ID. +#' +#' Allen, R., Robison, C.W., Garcia, M., Trezza, R., Tasumi, M., and Kjaersgaard, J., 2010b, +#' ETrF vs NDVI relationships for southern Idaho for rapid estimation of evapotranspiration, +#' University of Idaho, Kimberly, ID. +#' +#' ET Idaho: \url{http://data.kimberly.uidaho.edu/ETIdaho/} +#' +#' @keywords datasets +#' +#' @examples +#' str(et.method) +#' +"et.method" + +#' Daily Mean Discharge at Streamgages +#' +#' The daily mean discharge at streamgages in the Big Wood River Valley, Idaho. +#' Discharge records bracket the 1992-2014 time period and are based on +#' records with quality assurance code of approved (\sQuote{A}). +#' +#' @format An object of data.frame class with 8,315 records and the following variables: +#' \describe{ +#' \item{Date}{date during which discharge was averaged.} +#' \item{13135500}{daily mean discharge in cubic meters per day, recorded at the USGS +#' \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} +#' Big Wood River near Ketchum streamgage.} +#' \item{13139510}{daily mean discharge in cubic meters per day, recorded at the USGS +#' \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} +#' Big Wood River at Hailey streamgage.} +#' \item{13140800}{daily mean discharge in cubic meters per day, recorded at the USGS +#' \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} +#' Big Wood River at Stanton Crossing near Bellevue streamgage.} +#' } +#' +#' @source National Water Information System (\href{http://waterdata.usgs.gov/nwis}{NWIS}), +#' accessed on January 8, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' str(gage.disch) +#' +#' col <- c("red", "blue", "green") +#' ylab <- paste("Discharge in cubic", c("meters per day", "acre-foot per year")) +#' inlmisc::PlotGraph(gage.disch, ylab = ylab, col = col, lty = 1:3, +#' conversion.factor = 0.29611) +#' leg <- sprintf("USGS \%s", names(gage.disch)[-1]) +#' legend("topright", leg, col = col, lty = 1:3, inset = 0.02, cex = 0.7, +#' box.lty = 1, bg = "#FFFFFFE7") +#' +#' graphics.off() +#' +"gage.disch" + +#' Daily Mean Gage Height at Streamgages +#' +#' The daily mean gage height at streamgages in the Big Wood River Valley, Idaho. +#' Gage height records bracket the 1987-2014 and are based on records with +#' quality assurance codes of working (\sQuote{W}), in review (\sQuote{R}), and +#' approved (\sQuote{A}). +#' +#' @format An object of data.frame class with 9,980 records and the following variables: +#' \describe{ +#' \item{Date}{date during which gage height was averaged.} +#' \item{13135500}{daily mean gage height in meters, recorded at the USGS +#' \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} +#' Big Wood River near Ketchum streamgage.} +#' \item{13139510}{daily mean gage height in meters, recorded at the USGS +#' \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} +#' Big Wood River at Hailey streamgage.} +#' \item{13140800}{daily mean gage height in meters, recorded at the USGS +#' \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} +#' Big Wood River at Stanton Crossing near Bellevue streamgages.} +#' } +#' +#' @source Data queried from the National Water Information System +#' (\href{http://waterdata.usgs.gov/nwis}{NWIS}) database on December 15, 2014, +#' by Ross Dickinson (USGS). +#' Records recorded on May 26-28, 1991 and March 15-22, 1995 were reassigned +#' quality assurance codes of \sQuote{I} because of assumed ice build-up. +#' Missing data at the Big Wood River near Ketchum gage was estimated using a +#' linear regression model based on recorded gage-height data at the Big Wood River at +#' Hailey and Near Ketchum streamgages. +#' Missing data at the Stanton Crossing near Bellevue gage was replaced with +#' average gage-height values recorded at this gage. +#' +#' @keywords datasets +#' +#' @examples +#' str(gage.height) +#' +#' col <- c("red", "blue", "green") +#' ylab <- paste("Gage height in", c("meters", "feet")) +#' inlmisc::PlotGraph(gage.height, ylab = ylab, col = col, lty = 1:3, +#' conversion.factor = 3.28084) +#' leg <- sprintf("USGS \%s", names(gage.height)[-1]) +#' legend("topright", leg, col = col, lty = 1:3, inset = 0.02, cex = 0.7, +#' box.lty = 1, bg = "#FFFFFFE7") +#' +#' graphics.off() +#' +"gage.height" + +#' Land Surface Hill Shading +#' +#' Hill shading of the Wood River Valley and surrounding area. +#' +#' @format An object of \code{RasterLayer} class. +#' Each cell on the surface grid represents the hill shade. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' The spatial grid is composed of 3,108 rows and 2,360 columns, +#' and has cell sizes that are constant at 20 meters by 20 meters. +#' +#' @source Calculated from the slope and aspect of the \code{\link{land.surface}} dataset +#' using the \code{terrain} and \code{hillShade} functions; +#' see the appendix C. Package Dataset Creation for the \R code used in this calculation. +#' +#' @keywords datasets +#' +#' @examples +#' raster::image(hill.shading, length(hill.shading), col = grey(0:255 / 255), asp = 1, +#' axes = FALSE, xlab = "", ylab = "") +#' +"hill.shading" + +#' U.S. State of Idaho +#' +#' Boundary of Idaho, a state in the northwestern region of the United States. +#' +#' @format An object of SpatialPolygons class containing 1 Polygons. +#' Cartographic boundary at 5m (1:5,000,000) resolution. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source U.S. Department of Commerce, U.S. Census Bureau, +#' Geography Division/Cartographic Products Branch. +#' A simplified representation of the State of Idaho from the 2014 Census Bureau's +#' MAF/\href{http://www.census.gov/geo/maps-data/data/tiger.html}{TIGER} geographic database. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(idaho, col = "#EAE2CF", border = "#BFA76F", lwd = 0.5) +#' print(idaho) +#' +"idaho" + +#' Irrigation Entities +#' +#' Delineation of areas served by a group of surface-water and (or) groundwater diversions. +#' +#' @format An object of SpatialPolygonsDataFrame class containing 235 Polygons and +#' a data.frame with the following variables: +#' \describe{ +#' \item{EntityName}{name of the irrigation entity served by a group of diversions.} +#' \item{Source}{water source, either \dQuote{Mixed} for a mixture of surface water and groundwater, +#' \dQuote{SW Only} for surface-water only, or \dQuote{GW Only} for groundwater only.} +#' \item{EntitySrce}{concatenation of the \code{EntityName} and \code{Source} character strings.} +#' \item{PrecipZone}{name of the precipitation zone. +#' See \code{\link{precip.zones}} dataset for details.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources (IDWR), accessed on December 11, 2014; +#' derived from IDWR water rights database, Blaine County tax lot data, +#' and IDWR irrigated land classification files. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(irr.entities) +#' print(irr.entities) +#' +"irr.entities" + +#' Irrigated Lands +#' +#' Classification of irrigated lands in the Wood River Valley and surrounding areas; +#' available for years 1996, 2000, 2002, 2006, 2008, 2009, and 2010. +#' +#' @format An object of list class with 7 SpatialPolygonsDataFrame components. +#' The data.frame associated with each SpatialPolygons object has the following variable: +#' \describe{ +#' \item{Status}{status of land during the year reviewed, +#' either \dQuote{irrigated}, \dQuote{semi-irrigated}, or \dQuote{non-irrigated}.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on November 17, 2014; +#' polygons derived from U.S. Department of Agriculture Common Land Unit polygons +#' with some refinement of polygons. +#' Irrigation status interpreted using satellite imagery and aerial photography. +#' +#' @seealso \code{\link{irr.lands.year}} +#' +#' @keywords datasets +#' +#' @examples +#' sp::spplot(irr.lands[["2010"]], "Status") +#' print(irr.lands) +#' +"irr.lands" + +#' Irrigation Lands for a Given Year +#' +#' Annual land classification for irrigation practices is only available for select years. +#' For missing years, this dataset provides substitute years when land-classification was +#' available (see \code{\link{irr.lands}}). +#' +#' @format An object of data.frame class with 16 records and the following variables: +#' \describe{ +#' \item{Year}{year with a required date format of YYYY.} +#' \item{IL_Year}{substitute year with a required date format of YYYY.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on April 25, 2014 +#' +#' @keywords datasets +#' +#' @examples +#' str(irr.lands.year) +#' +"irr.lands.year" + +#' Kriging Zones +#' +#' Location of kriging zones in the Wood River Valley, used in parameter estimation. +#' +#' @format An object of SpatialPolygonsDataFrame class containing 18 Polygons and a +#' data.frame with the following variables: +#' \describe{ +#' \item{Zone}{kriging zone, interpolation in this zone is based on the +#' parameter values of pilot points located within this zone.} +#' \item{Layer}{model layer} +#' \item{Name}{local name} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on June 11, 2015 +#' +#' @seealso \code{\link{pilot.points}} +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(kriging.zones) +#' str(kriging.zones@data) +#' +"kriging.zones" + +#' Lakes and Reservoirs +#' +#' Lakes and reservoirs of the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialPolygonsDataFrame class containing 55 Polygons. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources +#' (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +#' accessed on April 2, 2014 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(lakes, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) +#' str(lakes@data) +#' +"lakes" + +#' Topography of Land Surface +#' +#' The Wood River Valley (WRV) is a geologic feature located in south-central Idaho. +#' This dataset gives the topography of the land surface in the WRV and vicinity. +#' +#' @format An object of SpatialGridDataFrame class. +#' Each cell on the surface grid represents an elevation in meters above the +#' North American Vertical Datum of 1988 (NAVD 88). +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' The spatial grid is composed of 565 rows and 429 columns, +#' and has cell sizes that are constant at 100 meters by 100 meters. +#' +#' @source The National Elevation Dataset (\href{http://ned.usgs.gov/}{NED}) +#' 1/3-arc-second raster (Gesch, 2007; Gesch and others, 2002), +#' accessed on December 1, 2015. +#' This dataset can be downloaded in a Esri ArcGRID format using the +#' \href{http://viewer.nationalmap.gov/viewer/}{National Map Viewer}. +#' NED data are distributed in geographic coordinates in units of decimal degrees, +#' and in conformance with the NAD 83. +#' Elevation values are in meters above the NAVD 88. +#' The west, east, south, and north bounding coordinates for this dataset are +#' -115, -114, 43, and 44 decimal degrees, respectively. +#' Post-processing includes: +#' (1) project the values of the NED dataset into the \code{\link{alluvium.thickness}} +#' spatial grid using bilinear interpolation, and +#' (2) set values in cells where the elevation of the alluvium bottom is missing to NA. +#' +#' @references Gesch, D.B., 2007, The National Elevation Dataset, in Maune, D., ed., +#' Digital Elevation Model Technologies and Applications: The DEM Users Manual, +#' 2nd Edition: Bethesda, Maryland, American Society for Photogrammetry and Remote Sensing, +#' p. 99-118. +#' +#' Gesch, D., Oimoen, M., Greenlee, S., Nelson, C., Steuck, M., and Tyler, D., 2002, +#' The National Elevation Dataset: Photogrammetric Engineering and Remote Sensing, +#' v. 68, no. 1, p. 5-11. +#' +#' @keywords datasets +#' +#' @examples +#' raster::image(land.surface) +#' summary(land.surface) +#' +"land.surface" + +#' Major Roads +#' +#' Major roads in the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialLinesDataFrame class containing 475 Lines. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources +#' (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +#' accessed on October 20, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(major.roads) +#' str(major.roads@data) +#' +"major.roads" + +#' Map Labels +#' +#' Map labels in the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialPointsDataFrame class containing +#' 40 points with the following variables: +#' \describe{ +#' \item{label}{text to be written.} +#' \item{cex}{character expansion factor} +#' \item{col,font}{color and font to be used, respectively.} +#' \item{srt}{string rotation in degrees.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Best estimates of map label locations. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(map.labels, col = "red") +#' lab <- cbind(map.labels@coords, map.labels@data) +#' for (i in seq_len(nrow(lab))) { +#' text(lab$x[i], lab$y[i], labels = lab$label[i], cex = lab$cex[i], +#' col = lab$col[i], font = lab$font[i], srt = lab$srt[i]) +#' } +#' +"map.labels" + +#' Miscellaneous Locations +#' +#' Miscellaneous locations in the Bellevue triangle area. +#' +#' @format An object of SpatialPointsDataFrame class containing 3 points +#' with the following variable: +#' \describe{ +#' \item{label}{description of point location.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources +#' (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +#' accessed on December 23, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(misc.locations, pch = 20, col = "red") +#' text(misc.locations, labels = misc.locations@data$label, pos = 3, cex = 0.6) +#' +"misc.locations" + +#' Direct Recharge from Miscellaneous Seepage Sites +#' +#' Direct recharge from miscellaneous seepage sites in the Wood River Valley, Idaho. +#' +#' @format An object of data.frame class with 2 records and the following variables: +#' \describe{ +#' \item{RechSite}{name of the recharge site, see \code{\link{bellevue.wwtp.ponds}} and +#' \code{\link{bypass.canal}} datasets.} +#' \item{199501,\dots,201012}{monthly volume of recharge during a stress period, in cubic meters. +#' The variable name is specified as year and month.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on January 15, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' str(misc.seepage) +#' +"misc.seepage" + +#' Observation Wells +#' +#' Observation wells in the Wood River Valley aquifer system. +#' +#' @format An object of SpatialPointsDataFrame class containing 776 points +#' with the following variables: +#' \describe{ +#' \item{id}{unique well identifier used in this study.} +#' \item{SiteNo}{unique well identifier within the +#' National Water Information System (NWIS).} +#' \item{SITEIDIDWR}{unique well identifier within the +#' Idaho Department of Water Resources (IDWR) hydrologic database.} +#' \item{WELLNUMBER}{USGS or IDWR site name for the well.} +#' \item{PESTNAME}{unique well identifier for PEST.} +#' \item{METHODDRIL}{drilling method} +#' \item{TOTALDEPTH}{depth at which drilling stopped, in feet.} +#' \item{OPENINGMIN}{top of the screened interval, in feet.} +#' \item{OPENINGMAX}{bottom of the screened interval, in feet.} +#' \item{COMPLETION}{date on which the well drilling and construction stopped.} +#' \item{WCWELLID}{well construction well identifier.} +#' \item{ALTITUDE}{land surface elevation, in feet.} +#' \item{ALTMETHOD}{method for obtaining the land surface elevation.} +#' \item{XYMETHOD}{method of obtaining the spatial coordinates.} +#' \item{BASINNO}{basin number} +#' \item{COUNTYNAME}{Idaho county name} +#' \item{TWPRGE}{township and range the well is located in.} +#' \item{SITENAME}{local name for well.} +#' \item{desc}{description of well type.} +#' \item{TopOpen1}{depth to the top of the first open interval in a groundwater well, +#' in meters below land surface.} +#' \item{BotOpen1}{depth to the bottom of the first open interval in a groundwater well, +#' in meters below land surface.} +#' \item{TopOpen2}{not applicable} +#' \item{BotOpen2}{not applicable} +#' } +#' +#' @source Idaho Department of Water Resources well construction database, +#' accessed on June 29, 2015 +#' +#' @seealso \code{\link{obs.wells.head}} +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(obs.wells) +#' str(obs.wells@data) +#' +"obs.wells" + +#' Hydraulic Heads in Observation Wells +#' +#' Hydraulic-head (groundwater-level) measurements recorded in observation wells in the +#' Wood River Valley aquifer system. +#' Values are used as observations during the parameter estimation process. +#' +#' @format An object of class data.frame with 3,477 records and the following variables: +#' \describe{ +#' \item{PESTNAME}{unique well identifier for PEST.} +#' \item{DateTime}{date and time when the measurement was recorded.} +#' \item{Head}{groundwater-level measurement (hydraulic head) +#' in meters above the North American Vertical Datum of 1988 (NAVD 88).} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on June 26, 2015 +#' +#' @seealso \code{\link{obs.wells}} +#' +#' @keywords datasets +#' +#' @examples +#' str(obs.wells.head) +#' +"obs.wells.head" + +#' Pilot Points +#' +#' Location of pilot points in the model domain. +#' +#' @format An object of SpatialPointsDataFrame class containing 106 points +#' with the following variables: +#' \describe{ +#' \item{Layer}{model layer} +#' \item{Zone}{kriging-zone identifier} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on June 11, 2015 +#' +#' @seealso \code{\link{kriging.zones}} +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(pilot.points) +#' str(pilot.points@data) +#' +"pilot.points" + +#' Points of Diversion for Groundwater +#' +#' Points of diversion for groundwater within the Wood River Valley model study area. +#' +#' @format An object of class data.frame with 1,755 records and the following variables: +#' \describe{ +#' \item{WMISNumber}{unique number assigned to a water right point of diversion.} +#' \item{WaterRight}{number identifying a specific authorization to use +#' water in a prescribed manner.} +#' \item{EntityName}{name of the irrigation entity the point of diversion is assigned to.} +#' \item{EntitySrce}{source of water for an irrigation entity. +#' Possible sources of water include surface water, groundwater and mixed. +#' Mixed source entities derive water from both groundwater and surface water.} +#' \item{Pdate}{priority date, the date the water right was established.} +#' \item{IrrRate}{irrigation rate in cubic meters per day, +#' the maximum permitted water use rate associated with a water right.} +#' } +#' +#' @source Idaho Department of Water Resources water rights database, +#' accessed on December 11, 2014 +#' +#' @seealso \code{\link{pod.wells}} +#' +#' @keywords datasets +#' +#' @examples +#' summary(pod.gw) +#' +"pod.gw" + +#' Well Completions +#' +#' Well completions for pumping wells in the Wood River Valley aquifer system. +#' +#' @format An object of SpatialPointsDataFrame class containing 1,243 points +#' with the following variables: +#' \describe{ +#' \item{WMISNumber}{is a unique number assigned to a water right point of diversion.} +#' \item{WellUse}{permitted use(s) for a groundwater well.} +#' \item{TopOpen1}{depth to the top of the first open interval in a groundwater well, +#' in meters below land surface.} +#' \item{BotOpen1}{depth to the bottom of the first open interval in a groundwater well, +#' in meters below land surface.} +#' \item{TopOpen2}{depth to the top of the second open interval in a groundwater well, +#' in meters below land surface.} +#' \item{BotOpen2}{depth to the bottom of the second open interval in a groundwater well, +#' in meters below land surface.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources water rights database, +#' accessed on November 29, 2014 +#' +#' @seealso \code{\link{pod.gw}} +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(pod.wells) +#' str(pod.wells@data) +#' +"pod.wells" + +#' Precipitation Zones +#' +#' Precipitation zones specified for the Wood River Valley and surrounding areas. +#' There are three precipitation zones, each containing a single weather station. +#' Precipitation zones were distributed to maintain the geographic similarity between +#' weather stations and zones. +#' +#' @format An object of SpatialPolygonsDataFrame class containing 3 Polygons and a +#' data.frame with the following variables: +#' \describe{ +#' \item{ID}{numeric identifier assigned to the polygon.} +#' \item{PrecipZone}{name of the precipitation zone: +#' \dQuote{Ketchum}, the northernmost zone with data from the +#' Ketchum National Weather Service coop weather station. +#' \dQuote{Hailey}, central zone with data from the +#' Hailey 3NNW National Weather Service coop weather station. +#' \dQuote{Picabo}, southernmost zone with data from the +#' Picabo AgriMet weather station.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Created using the northing midpoint between weather stations, +#' see \code{\link{weather.stations}} dataset. +#' +#' @seealso \code{\link{precipitation}} +#' +#' @keywords datasets +#' +#' @examples +#' col <- c("#D1F2A5", "#FFC48C", "#F56991") +#' sp::plot(precip.zones, col = col) +#' legend("topright", legend = precip.zones@data$PrecipZone, fill = col, bty = "n") +#' sp::plot(alluvium.extent, add = TRUE) +#' +#' print(precip.zones) +#' +"precip.zones" + +#' Precipitation Rate +#' +#' Precipitation rates in the Wood River Valley and surrounding areas. +#' +#' @format An object of data.frame class with 582 records and the following variables: +#' with the following variables: +#' \describe{ +#' \item{YearMonth}{year and month during which precipitation were recorded, +#' with a required date format of \code{YYYYMM}.} +#' \item{PrecipZone}{name of the precipitation zone, +#' see \code{\link{precip.zones}} dataset for details.} +#' \item{Precip}{monthly depth of precipitation accounting for spring melt, in meters.} +#' \item{Precip.raw}{monthly depth of precipitation recorded at the weather station, +#' in meters.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on April 24, 2015 +#' +#' @references National Oceanic and Atmospheric Administration's National Weather Service +#' (\href{http://www.nws.noaa.gov/om/coop/}{NWS}) Cooperative Observer Program +#' +#' U.S. Bureau of Reclamation's Cooperative Agricultural Weather Network +#' (\href{http://www.usbr.gov/pn/agrimet/}{AgriMet}) +#' +#' @seealso \code{\link{precip.zones}}, \code{\link{swe}} +#' +#' @keywords datasets +#' +#' @examples +#' str(precipitation) +#' +#' d <- precipitation +#' d <- data.frame(Date = as.Date(paste0(d$YearMonth, "15"), format = "\%Y\%m\%d"), +#' Precip = d$Precip) +#' zones <- c("Hailey", "Ketchum", "Picabo") +#' d1 <- d[precipitation$PrecipZone == zones[1], ] +#' d2 <- d[precipitation$PrecipZone == zones[2], ] +#' d3 <- d[precipitation$PrecipZone == zones[3], ] +#' d <- merge(merge(d1, d2, by = "Date"), d3, by = "Date") +#' +#' col <- c("red", "blue", "green") +#' ylab <- paste("Precipitation in", c("meters", "feet")) +#' inlmisc::PlotGraph(d, ylab = ylab, col = col, lty = 1:3, conversion.factor = 3.28084) +#' legend("topright", zones, col = col, lty = 1:3, inset = 0.02, cex = 0.7, +#' box.lty = 1, bg = "#FFFFFFE7") +#' +#' graphics.off() +#' +"precipitation" + +#' Priority Cuts +#' +#' Priority cut dates applied to Big Wood River above Magic Reservoir and +#' Silver Creek by Water District 37 and 37M at the end of each month. +#' +#' @format An object of data.frame class with 112 records +#' and the following variables: +#' \describe{ +#' \item{YearMonth}{year and month during of the priority cut date, +#' with a required date format of YYYYMM.} +#' \item{Pdate_BWR}{date of the priority cut applied to +#' Big Wood River above Magic Reservoir by Water District 37.} +#' \item{Pdate_SC}{date of the priority cut applied to +#' Silver Creek by Water District 37M.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on November 17, 2014; +#' compiled priority cut dates in effect at the end of each month, +#' derived from Water District 37 and 37M records. +#' +#' @keywords datasets +#' +#' @examples +#' str(priority.cuts) +#' +"priority.cuts" + +#' Public Land Parcels +#' +#' Non-irrigated public land parcels in the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialPolygons class containing 669 Polygons. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on November 29, 2014; +#' derived from Blaine County tax lots and aerial photography. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(public.parcels) +#' print(public.parcels) +#' +"public.parcels" + +#' Rasterized Canals +#' +#' Canal systems of the Wood River Valley and surrounding areas transferred to raster cells. +#' +#' @format An object of RasterLayer class with indexed cell values linked to +#' a raster attribute table (RAT). +#' The RAT is a \code{data.frame} with the following components: +#' \describe{ +#' \item{ID}{cell index} +#' \item{COUNT}{frequency of the cell index in the raster grid.} +#' \item{EntityName}{name of the irrigation entity served by the canal system.} +#' } +#' +#' @source Calculated by transferring the \code{\link{canals}} dataset to grid cells in the +#' \code{\link{land.surface}} dataset using the \code{rasterize} function; +#' see the appendix C. Package Dataset Creation for the \R code used in this calculation. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(r.canals) +#' print(levels(r.canals)[[1]]) +#' +"r.canals" + +#' Stream-Aquifer Flow Exchange Along River Reaches +#' +#' Stream-aquifer flow exchange along river reaches specified as aquifer recharge. +#' Values used as observations in parameter estimation. +#' +#' @format An object of \code{data.frame} class with 192 records and the following variables: +#' \describe{ +#' \item{YearMonth}{year and month of the measurement record, +#' with a required date format of \code{YYYYMM}.} +#' \item{nKet_Hai}{stream-aquifer flow exchange in the Big Wood River, +#' near Ketchum to Hailey river reach, in cubic meters per day.} +#' \item{Hai_StC}{stream-aquifer flow exchange in the Big Wood River, +#' Hailey to Stanton Crossing river reach, in cubic meters per day.} +#' \item{WillowCr}{stream-aquifer flow exchange in the Willow Creek river reach, +#' in cubic meters per day.} +#' \item{SilverAbv}{stream-aquifer flow exchange in Silver Creek, +#' above Sportsman Access river reach, in cubic meters per day.} +#' \item{SilverBlw}{stream-aquifer flow exchange in Silver Creek, +#' Sportsman Access to near Picabo river reach, in cubic meters per day.} +#' } +#' +#' @details A positive stream-aquifer flow exchange indicates aquifer recharge +#' (a losing river reach). +#' +#' @source Calculated from continuous stream flow measurements, diversion data, +#' return flow data, and exchange well data using a flow difference method to +#' estimate groundwater inflows and outflows along a river reach, +#' accessed on September 1, 2015. +#' Derived from U.S. Geological Survey, Idaho Power Company, +#' and Water District 37 and 37M records. +#' +#' @keywords datasets +#' +#' @examples +#' str(reach.recharge) +#' +"reach.recharge" + +#' Major River Reaches +#' +#' Major river reaches of the Wood River Valley, Idaho. +#' +#' @format An object of SpatialLinesDataFrame class containing 22 Lines and a +#' data.frame with the following variables: +#' \describe{ +#' \item{Reach}{name of the subreaches measured in U.S. Geological Survey (USGS) +#' seepage survey.} +#' \item{BigReach}{name of the reaches for which time series targets are available for +#' part or all of the calibration period.} +#' \item{DrainRiver}{model boundary assignment, either \dQuote{drain} or \dQuote{river}.} +#' \item{RchAvg}{estimated average reach gain in cubic meters per day for 1995-2010 +#' based on a combination of gage data and the USGS seepage survey.} +#' \item{BigRAv}{estimated average reach gain in cubic meters per day for 1995-2010 +#' based on gage data.} +#' \item{ReachNo}{reach number identifier.} +#' \item{Depth}{estimated average depth in meters of water in reach, +#' measured from the air-water interface to the top of the riverbed sediments.} +#' \item{BedThk}{estimated thickness in meters of the saturated riverbed sediments.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on June 6, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(river.reaches) +#' str(river.reaches@data) +#' +"river.reaches" + +#' Rasterized Monthly Irrigation Entities +#' +#' Irrigation entities of the Wood River Valley and surrounding areas transferred to raster cells. +#' +#' @format An object of RasterStack class containing a 192 RasterLayer objects, +#' one layer for each month in the 1995-2010 time period. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' For each raster layer, indexed cell values are linked to a raster attribute table (RAT). +#' The RAT is an object of data.frame class with the following components: +#' \describe{ +#' \item{ID}{cell index} +#' \item{COUNT}{frequency of the cell index in the raster grid.} +#' \item{EntityName}{name of the irrigation entity served by a group of diversions.} +#' } +#' +#' @source Calculated by transferring the \code{\link{entity.components}} dataset to grid cells +#' in the \code{\link{land.surface}} dataset using the rasterize function; +#' see the appendix C. Package Dataset Creation for the \R code used in this calculation. +#' +#' @keywords datasets +#' +#' @examples +#' names(rs.entities) +#' sp::plot(rs.entities[["199507"]]) +#' print(levels(rs.entities[["199507"]])[[1]]) +#' +"rs.entities" + +#' Rasterized Monthly Recharge on Non-Irrigated Lands +#' +#' Aerial recharge and discharge on non-irrigated lands of the Wood River Valley and +#' surrounding areas transferred to raster cells. +#' +#' @format An object of RasterStack class containing 192 RasterLayer objects, +#' one layer for each month in the 1995-2010 time period. +#' Each cell on a layers surface grid represents the monthly recharge in meters. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Calculated from the \code{\link{et}}, \code{\link{precipitation}}, +#' \code{\link{precip.zones}}, and \code{\link{soils}} datasets; +#' see the appendix C. Package Dataset Creation for the \R code used in this calculation. +#' +#' @keywords datasets +#' +#' @examples +#' names(rs.rech.non.irr) +#' sp::plot(rs.rech.non.irr[["199507"]]) +#' +"rs.rech.non.irr" + +#' Stream Seepage Study +#' +#' A Wood River Valley stream seepage study with streamflow measurements made during +#' the months of August 2012, October 2012, and March 2013. +#' +#' @format An object of SpatialPointsDataFrame class containing 82 points +#' with the following variables: +#' \describe{ +#' \item{Order}{index used to preserve the downstream order of measurement sites.} +#' \item{Name}{local name for the measurement site.} +#' \item{SiteNo}{unique identifier for the measurement site within the +#' National Water Information System (NWIS).} +#' \item{Type}{the type of measurement site: +#' \dQuote{Big Wood River}, \dQuote{Willow Creek}, \dQuote{Spring fed creeks}, +#' \dQuote{Silver Creek}, \dQuote{Diversion}, \dQuote{Exchange well inflow}, +#' \dQuote{Return}, and \dQuote{Tributary}.} +#' \item{Comments}{abbreviated site name} +#' \item{Aug}{volumetric flow rate measured during August 2012, in cubic meters per day.} +#' \item{Oct}{volumetric flow rate measured during October 2012, in cubic meters per day.} +#' \item{Mar}{volumetric flow rate measured during March 2013, in cubic meters per day.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Derived from Bartolino (2014) seepage study, +#' Idaho Department of Water Resources, Water District 37 and 37M flow records. +#' +#' @references Bartolino, J.R., 2014, Stream seepage and groundwater levels, Wood River Valley, +#' south-central Idaho, 2012--13: U.S. Geological Survey Scientific Investigations Report 2014-5151, +#' 34 p., \url{http://dx.doi.org/10.3133/sir20145151}. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(seepage.study) +#' str(seepage.study@data) +#' +"seepage.study" + +#' PEST Sensitivity +#' +#' Calibrated parameter values and composite sensitivities generated by PEST. +#' +#' @format An object of data.frame class with 336 records and the following variables: +#' \describe{ +#' \item{parameter.desc}{parameter description} +#' \item{ID}{unique identifier within the parameter type, +#' such as an identifier for a pilot point or irrigation entity.} +#' \item{units}{parameter units} +#' \item{start.value}{starting parameter value prior to model calibration.} +#' \item{lower.bound}{lower bound placed on the parameter value +#' during the model-calibration process.} +#' \item{upper.bound}{upper bound placed on the parameter value +#' during the model-calibration process.} +#' \item{parameter.name}{\href{http://www.pesthomepage.org/}{PEST} parameter name} +#' \item{group}{PEST parameter group} +#' \item{value}{calibrated parameter value estimated by PEST.} +#' \item{comp.sens}{composite sensitivity generated during the final iteration of PEST.} +#' \item{rel.comp.sens}{relative composite sensitivity} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on January 15, 2016 +#' +#' @seealso \code{\link{pilot.points}}, \code{\link{irr.entities}}, +#' \code{\link{river.reaches}}, \code{\link{drains}}, \code{\link{tributaries}} +#' +#' @keywords datasets +#' +#' @examples +#' str(sensitivity) +#' +"sensitivity" + +#' Soil Units +#' +#' Representation of mapped surficial soil units created by the Idaho Office of the +#' National Resource Conservation Service (NRCS). +#' Soils have been assigned a percolation rate based on the average, +#' saturated hydraulic conductivity of the soils as classified using the +#' Unified Soil Classification System (USCS). +#' +#' @format An object of SpatialPolygonsDataFrame class containing 718 Polygons and a +#' data.frame with the following variables: +#' \describe{ +#' \item{GroupSymbol}{soil class identifier} +#' \item{SoilLayer}{identifier used to differentiate the soil data source +#' used to create the soils map. +#' Data sources are either \sQuote{USCS} or \sQuote{STATSGO}, +#' the NRCS State Soil Geographic Data Base.} +#' \item{SoilClass}{description of the soil class.} +#' \item{MinRate}{lower percolation rate limit for the soil class, in meters per month.} +#' \item{MaxRate}{upper percolation rate limit for the soil class, in meters per month.} +#' \item{PercolationRate}{percolation rate in meters per month.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on April 22, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' sp::spplot(soils, "PercolationRate") +#' str(soils@data) +#' +"soils" + +#' Streamgages +#' +#' Select streamgages in the Wood River Valley. +#' +#' @format An object of SpatialPointsDataFrame class containing 9 points and a +#' data.frame with the following variable: +#' \describe{ +#' \item{SiteNo}{unique site number for the streamgage.} +#' \item{SiteName}{official name of the streamgage.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source National Water Information System (\href{http://waterdata.usgs.gov/nwis}{NWIS}), +#' accessed on May 29, 2015. +#' +#' @keywords datasets +#' +#' @examples +#' str(streamgages) +#' +"streamgages" + +#' Streams and Rivers +#' +#' Streams and rivers of the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialLinesDataFrame class containing 581 Lines. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources +#' (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +#' accessed on April 2, 2014 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(streams.rivers, col = "#3399CC") +#' str(streams.rivers@data) +#' +"streams.rivers" + +#' Stream-Aquifer Flow Exchange Along River Subreaches +#' +#' Stream-aquifer flow exchange along river subreaches specified as aquifer recharge. +#' Values used as observations in parameter estimation. +#' +#' @format An object of data.frame class with 19 records and the following variables: +#' \describe{ +#' \item{ReachNo}{subreach number identifier} +#' \item{Reach}{name of the subreach.} +#' \item{BigReachNo}{reach number identifier} +#' \item{BigReach}{name of the reach.} +#' \item{Aug}{estimated volumetric flow rate measured during August 2012, +#' in cubic meters per day.} +#' \item{Oct}{estimated volumetric flow rate measured during October 2012, +#' in cubic meters per day.} +#' \item{Mar}{estimated volumetric flow rate measured during March 2013, +#' in cubic meters per day.} +#' } +#' +#' @details A positive stream-aquifer flow exchange indicates aquifer recharge +#' (also know as a losing river subreach). +#' +#' @source Flow values calculated from \code{\link{seepage.study}} data. +#' +#' @keywords datasets +#' +#' @examples +#' str(subreach.recharge) +#' +"subreach.recharge" + +#' Snow Water Equivalent +#' +#' Average daily snow water equivalent (SWE) at weather stations in the +#' Wood River Valley and surrounding areas. +#' +#' @format An object of data.frame class with 366 records and the following variables: +#' \describe{ +#' \item{MonthDay}{month and day, with a required date format of \code{MMDD}.} +#' \item{Choco}{daily SWE recorded at the Chocolate Gulch snow telemetry (SNOTEL) +#' weather station.} +#' \item{Hailey}{daily SWE recorded at the Hailey Ranger Station at Hailey +#' hydrometeorological automated data system (HADS) weather station.} +#' \item{Picabo}{daily SWE recorded at the Picabo PICI HADS weather station.} +#' } +#' +#' @source Idaho Department of Water Resources, accessed on April 24, 2015 +#' +#' @seealso \code{\link{weather.stations}}, \code{\link{precip.zones}}, +#' \code{\link{precipitation}} +#' +#' @keywords datasets +#' +#' @examples +#' str(swe) +#' +"swe" + +#' Tributary Basin Underflow +#' +#' Location and average flow conditions for model boundaries in the +#' major tributary canyons and upper part of the Wood River Valley, south-central Idaho. +#' +#' @format An object of SpatialPolygonsDataFrame class containing a set of 22 Polygons and a +#' data.frame with the following variable: +#' \describe{ +#' \item{Name}{tributary name} +#' \item{MinLSD}{minimum land-surface datum (elevation) along the transect, +#' in meters above the North American Vertical Datum of 1988 (NAVD 88).} +#' \item{BdrkDepth}{mean saturated thickness along the transect line, in meters; +#' estimated as the distance between the estimated water table and bedrock elevations.} +#' \item{TribWidth}{width of the tributary canyon, or length of the transect line, in meters.} +#' \item{LandGrad}{land surface elevation gradient perpendicular to the +#' cross-sectional transect line, a dimensionless quantity.} +#' \item{K}{hydraulic conductivity in meters per day.} +#' \item{SatArea}{estimated saturated cross-sectional area, in square meters; +#' its geometry is represented as the lower-half of an ellipse with +#' width and height equal to \code{TribWidth} and \code{BdrkDepth}, respectively.} +#' \item{DarcyFlow}{groundwater flow rate, in cubic meters per day, calculated using a +#' \href{http://en.wikipedia.org/wiki/Darcy_law}{Darcian} analysis.} +#' \item{BasinArea}{land-surface area defined by the basin above the cross-sectional transect line.} +#' \item{BasinAreaType}{label that describes the relative basin size; where +#' \code{"big"} indicates a basin area greater than 10 square miles (25.9 square kilometers), and +#' \code{"small"} indicates a basin area that is less than this breakpoint value.} +#' \item{PrecipRate}{mean precipitation rate within the basin area, in meters per day.} +#' \item{PrecipFlow}{mean precipitation flow rate, in cubic meters per day, +#' calculated by multiplying \code{PrecipRate} by \code{BasinArea}.} +#' \item{FlowRatio}{ratio of darcy flow rate to precipitation flow rate, +#' or \code{DarcyFlow} divided by \code{PrecipFlow}, a dimensionless quantity.} +#' \item{Flow}{estimated average volumetric flow rate, in cubic meters per day.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source U.S. Geological Survey, accessed on July 2, 2015; +#' a Keyhole Markup Language (\href{http://en.wikipedia.org/wiki/Kml}{KML}) file created in +#' \href{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in +#' areas of known specified flow boundaries. +#' Transect lines are defined by the polygon boundaries within the extent of +#' alluvium aquifer (see \code{\link{alluvium.extent}} dataset). +#' The land surface gradient (\code{LandGrad}) was estimated from the +#' \code{\link{land.surface}} dataset. +#' Hydraulic conductivity (\code{K}) is the average of two geometric means of hydraulic conductivity +#' in the unconfined aquifer taken from table 2 in Bartolino and Adkins (2012). +#' The U.S. Geologic Survey \href{http://water.usgs.gov/osw/streamstats/}{StreamStats} tool +#' (Ries and others, 2004) was used to delineate the basin area (\code{BasinArea}) and +#' estimate the precipitation rate (\code{PrecipRate}). +#' See the appendix C. Package Dataset Creation for the \R code used to calculate the +#' flow estimates (\code{Flow}). +#' +#' @references Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the +#' Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey +#' Scientific Investigations Report 2012-5053, 46 p., +#' available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +#' +#' Ries, K.G., Steeves, P.A., Coles, J.D., Rea, A.H., and Stewart, D.W., 2004, +#' StreamStats--A U.S. Geological Survey web application for stream information: +#' U.S. Geological Survey Fact Sheet FS-2004-3115, 4 p., available at +#' \url{http://pubs.er.usgs.gov/usgspubs/fs/fs20043115}. +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(tributaries, border = "red") +#' sp::plot(alluvium.extent, add = TRUE) +#' str(tributaries@data) +#' +"tributaries" + +#' Tributary Streams +#' +#' Tributary streams of the upper Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialLinesDataFrame class containing 88 Lines. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source Idaho Department of Water Resources, accessed on June 1, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(tributary.streams, col = "#3399CC") +#' str(tributary.streams@data) +#' +"tributary.streams" + +#' Weather Stations +#' +#' Weather stations in the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialPointsDataFrame class containing 5 points +#' and the following variables: +#' \describe{ +#' \item{name}{name of the weather station.} +#' \item{id}{unique identifier for the weather station.} +#' \item{type}{type of weather stations: +#' \code{"HADS"}, a Hydrometeorological Automated Data System operated by the +#' National Weather Service Office of Dissemination; +#' \code{"AgriMet"}, a satellite-telemetry network of +#' automated agricultural weather stations operated and +#' maintained by the Bureau of Reclamation; and +#' \code{"SNOTEL"}, an automated system of snowpack and +#' related climate sensors operated by the +#' Natural Resources Conservation Service.} +#' \item{organization}{is the managing organization.} +#' \item{elevation}{is the elevation of the weather station in +#' meters above the North American Vertical Datum of 1988 (NAVD 88).} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source National Oceanic and Atmospheric Administration (NOAA), +#' Bureau of Reclamation, Natural Resources Conservation Service (NRCS), +#' accessed on May 1, 2015 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(alluvium.extent) +#' sp::plot(weather.stations, col = "red", add = TRUE) +#' str(weather.stations@data) +#' +"weather.stations" + +#' Wetlands +#' +#' Wetlands in the Wood River Valley and surrounding areas. +#' +#' @format An object of SpatialPolygons class containing 3,024 Polygons. +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source U.S. Fish and Wildlife Service National Wetlands Inventory, +#' accessed on April 2, 2014 +#' +#' @keywords datasets +#' +#' @examples +#' sp::plot(wetlands, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) +#' print(wetlands) +#' +"wetlands" + +#' Groundwater-Level Contours for October 2006 +#' +#' Groundwater-level contours with a 20 foot (6.096 meter) contour interval for the +#' unconfined aquifer in the Wood River Valley, south-central Idaho, +#' representing conditions during October 2006. +#' +#' @format An object of SpatialLinesDataFrame class containing 265 Lines and a +#' data.frame with the following variables: +#' \describe{ +#' \item{CONTOUR}{groundwater elevation contour value in meters above the +#' North American Vertical Datum of 1988 (NAVD 88).} +#' \item{certainty}{certainty of the groundwater-level contour based on +#' data position and density, specified as \code{"good"} or \code{"poor"}.} +#' } +#' Geographic coordinates are in units of meters, in conformance with the +#' North American Datum of 1983 (NAD 83), and placed in the +#' Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +#' +#' @source This dataset is from Plate 1 in Skinner and others (2007), and available on the +#' \href{http://water.usgs.gov/GIS/metadata/usgswrd/XML/sir2007-5258_oct2006wl.xml}{WRD NSDI Node}. +#' +#' @references Skinner, K.D., Bartolino, J.R., and Tranmer, A.W., 2007, +#' Water-resource trends and comparisons between partial development and +#' October 2006 hydrologic conditions, Wood River Valley, south-central, Idaho: +#' U.S. Geological Survey Scientific Investigations Report 2007-5258, 30 p., +#' available at \url{http://pubs.usgs.gov/sir/2007/5258/} +#' +#' @keywords datasets +#' +#' @examples +#' is.good <- wl.200610@data$certainty == "good" +#' sp::plot(wl.200610[is.good, ], col = "blue") +#' sp::plot(wl.200610[!is.good, ], col = "red", lty = 2, add = TRUE) +#' str(wl.200610@data) +#' +"wl.200610" + +#' Hydraulic Properties of Hydrogeologic Zones +#' +#' Estimates of the hydraulic properties for each hydrogeologic zone. +#' +#' @format An object of \code{data.frame} class with the following variables: +#' \describe{ +#' \item{ID}{numeric identifier for the hydrogeologic zone.} +#' \item{name}{name of the hydrogeologic zone.} +#' \item{vani}{vertical anisotropy, a dimensionless quantity.} +#' \item{sc}{storage coefficient, a dimensionless quantity.} +#' \item{sy}{specific yield, a dimensionless quantity.} +#' \item{hk}{horizontal hydraulic conductivity in meters per day.} +#' \item{ss}{specific storage in inverse meter.} +#' } +#' +#' @references Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the +#' Wood River Valley aquifer system, south-central Idaho: +#' U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., +#' available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +#' +#' @keywords datasets +#' +#' @examples +#' str(zone.properties) +#' +"zone.properties" diff --git a/R/zzz.R b/R/zzz.R index 2c3c437..c0cc58b 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -2,11 +2,7 @@ if (interactive()) { ver <- read.dcf(file.path(lib, pkg, "DESCRIPTION"), "Version") packageStartupMessage(pkg, ": version: ", ver) - - s <- paste(" Type 'citation(\"", pkg, "\")' for citing this R package in publications.", sep="") - packageStartupMessage(s) - - if (ver < 1) { + if (ver < 1 || grepl("\\.9000$", ver)) { s <- paste("This information is preliminary or provisional and is subject to revision.", "It is being provided to meet the need for timely best science.", "The information has not received final approval by the U.S. Geological Survey (USGS) and", diff --git a/README.md b/README.md index 27fd61b..e023c7a 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,45 @@ # wrv -An [R](http://www.r-project.org/ "The R Project for Statistical Computing") package for processing the +The [R](http://www.r-project.org/) package **wrv** is for processing the groundwater-flow model of the Wood River Valley (WRV) aquifer system, south-central Idaho. The groundwater-flow model is described in the associated [model report](http://dx.doi.org/10.3133/sir20165080 "USGS Scientific Investigations Report") and [model archive](http://dx.doi.org/10.5066/F7C827DT "USGS Data Release"). -Included in the package is [MODFLOW-USG](http://water.usgs.gov/ogw/mfusg/ "MODFLOW-USG") version 1.2, +Included in the package is [MODFLOW-USG](http://water.usgs.gov/ogw/mfusg/ "MODFLOW-USG") version 1.3, a U.S. Geological Survey (USGS) computer code that solves the groundwater-flow equation. -The set of standards used for coding this package is documented in -[Google's R Style Guide](https://google.github.io/styleguide/Rguide.xml "Google's R Style Guide"). ## Install -If R is not already installed on your computer, download and install the latest binary distribution from the Comprehensive R Archive Network -([CRAN](http://cran.r-project.org/ "The Comprehensive R Archive Network")). -Next, open an R session and install user-contributed R packages from CRAN and the Geological Survey R Archive Network -([GRAN](http://owi.usgs.gov/R/gran.html "The Geological Survey R Archive Network")) using the following commands: +You can install the stable version of **wrv** from [GRAN](http://owi.usgs.gov/R/gran.html), +and its dependencies from [CRAN](http://cran.r-project.org/), using the following commands: ```r repos <- c("http://owi.usgs.gov/R", getOption("repos")) install.packages("wrv", repos = repos, dependencies = TRUE) ``` +Or use **devtools** to install the development version from GitHub. + +```r +devtools::install_github("USGS-R/wrv") +``` + ## Run -Load the **wrv** package in the current R session: +Load **wrv** in the current R session ```r library(wrv) ``` -Access package documentation: +Access package documentation ```r help(package = "wrv") ``` +See [course material](https://jfisher-usgs.github.io/wrv-training/) for example applications using the **wrv** package. + ## Bugs Please consider reporting bugs and asking questions on the [Issues page](https://github.com/USGS-R/wrv/issues). @@ -45,7 +49,7 @@ Please consider reporting bugs and asking questions on the [Issues page](https:/ This software is in the public domain because it contains materials that originally came from the USGS, an agency of the United States Department of Interior. For more information, see the -[official USGS copyright policy](http://www.usgs.gov/visual-id/credit_usgs.html#copyright/ "official USGS copyright policy"). +[official USGS copyright policy](https://www2.usgs.gov/visual-id/credit_usgs.html "official USGS copyright policy"). Although this software program has been used by the USGS, no warranty, expressed or implied, is made by the USGS or the U.S. Government as to the accuracy and functioning of the program and related program material nor shall the fact of distribution constitute any such warranty, diff --git a/inst/doc/sir20165080.Rnw b/inst/doc/sir20165080.Rnw index 59f2e3f..ba09680 100644 --- a/inst/doc/sir20165080.Rnw +++ b/inst/doc/sir20165080.Rnw @@ -4,7 +4,7 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} % ========================================================================= diff --git a/inst/doc/sir20165080_AppendixA.R b/inst/doc/sir20165080_AppendixA.R index b57a7c7..a7ffa38 100644 --- a/inst/doc/sir20165080_AppendixA.R +++ b/inst/doc/sir20165080_AppendixA.R @@ -92,7 +92,7 @@ v <- c(paste("Diagram showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nc ## ----eval=FALSE---------------------------------------------------------- # help("UpdateWaterBudget") # open help documentation for function call -# UpdateWaterBudget(file.path(getwd(), "model/model1"), "wrv_mfusg", qa.tables = "english") +# UpdateWaterBudget("model/model1", "wrv_mfusg", qa.tables = "english") ## ----include=FALSE------------------------------------------------------- v <- "Procedures used in a single PEST run." diff --git a/inst/doc/sir20165080_AppendixA.Rnw b/inst/doc/sir20165080_AppendixA.Rnw index 5ef0a19..98a43c6 100644 --- a/inst/doc/sir20165080_AppendixA.Rnw +++ b/inst/doc/sir20165080_AppendixA.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{A\arabic{figure}} \renewcommand{\thetable}{A\arabic{table}} \renewcommand{\thepage}{A\arabic{page}} @@ -91,7 +93,7 @@ help(package = "wrv") @ MODFLOW-USG is a computer program for simulating three-dimensional, steady-state and transient groundwater flow using a control volume finite-difference formulation \citep{Panday2013}. -Source code and executable files for MODFLOW-USG (version 1.2) are provided in the \textbf{wrv} package. +Source code and executable files for MODFLOW-USG (version 1.3) are provided in the \textbf{wrv} package. PEST is a software suite that allows model-independent parameter estimation, sensitivity analysis, and uncertainty estimation, developed by \citet{Doherty2005}. If PEST (version $\geq$ 13.0) is not already installed on your computer, download and install the latest binary distribution and enable it to run from the command line. @@ -250,7 +252,7 @@ and pumping demands (appendix G). Many of the parameters adjusted during model calibration (such as the horizontal hydraulic conductivity) are contained within MODFLOW input files (including data reference files [`.ref'] read by MODFLOW). At the end of each PEST iteration the newly updated parameter values are written to these model input files. The exception to this method of directly updating parameter values in the model input files occurs when the calibrated parameter values are used as input for a pre-processing program that generates a model input file(s). -For example, in this study, the \texttt{UpdateWaterBudget} function (appendix B, p. B67-B69) is used to create the MODFLOW well file (`.wel'), an input file containing specified flow boundary conditions. +For example, in this study, the \texttt{UpdateWaterBudget} function (appendix B, p. B46-B48) is used to create the MODFLOW well file (`.wel'), an input file containing specified flow boundary conditions. Input parameters for this function include, but are not limited to, the following: irrigation efficiency, tributary-underflow control parameters, and horizontal hydraulic conductivity---all of which are varied during the model-calibration process. @@ -264,7 +266,7 @@ and output quality-assurance tables for the water-budget calculation: <>= help("UpdateWaterBudget") # open help documentation for function call -UpdateWaterBudget(file.path(getwd(), "model/model1"), "wrv_mfusg", qa.tables = "english") +UpdateWaterBudget("model/model1", "wrv_mfusg", qa.tables = "english") @ \begin{figure} @@ -289,7 +291,7 @@ v <- c(paste("Diagram showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nc \label{fig:flowchart_update} \end{figure} -The general processing steps for model calibration are shown in \hyperref[fig:flowchart_calibrate]{Figure~\ref{fig:flowchart_calibrate}}. +The general processing steps for model calibration are shown in \hyperref[fig:flowchart_calibrate]{figure~\ref{fig:flowchart_calibrate}}. Notice that the processing steps are represented in a linear workflow. This is an oversimplification of the approach taken for model calibration; in reality, the workflow was very non-linear because a new PEST run was required following any change in model conceptualization. diff --git a/inst/doc/sir20165080_AppendixB.Rnw b/inst/doc/sir20165080_AppendixB.Rnw index c98d074..58fc657 100644 --- a/inst/doc/sir20165080_AppendixB.Rnw +++ b/inst/doc/sir20165080_AppendixB.Rnw @@ -61,7 +61,7 @@ This vignette is a reference manual for functions and datasets in the \textbf{wr A short description and \R{} usage information (such as examples of how to use a function) are given for all functions and datasets. Dataset documentation include sections describing the format of a dataset (such as a vector or matrix) and details on the original or secondary data source. Functions and datasets are named according to the following conventions. -The form for function names is no separator between words and initial capital letters (such as \code{AddScaleBar}); +The form for function names is no separator between words and initial capital letters (such as \code{GetSeasonalMult}); dataset names have words separated with dots and all lower case letters (such as \code{alluvium.extent}). \vspace{10 mm} @@ -72,9 +72,6 @@ dataset names have words separated with dots and all lower case letters (such as % ========================================================================= -% Create Rd2.tex from the command line: -% R CMD Rd2pdf --no-clean --force "./wrv" - <>= f <- "Rd2.tex" p <- ifelse(file.exists(f), f, system.file("misc", f, package="wrv")) diff --git a/inst/doc/sir20165080_AppendixC.R b/inst/doc/sir20165080_AppendixC.R index 7a292d0..175fe2b 100644 --- a/inst/doc/sir20165080_AppendixC.R +++ b/inst/doc/sir20165080_AppendixC.R @@ -17,12 +17,7 @@ fin.cs <- c(7.16, 5.39) fin.cs.0 <- c(7.16, 4.73) # Extreme coordinates of plotting region (x1, x2, y1, y2) -usr.map <- c(2451504, 2497815, 1342484, 1402354) -usr.map.s <- c(2472304, 2497015, 1343284, 1358838) -usr.map.n.1 <- c(2463000, 2475356, 1386500, 1398856) -usr.map.n.2 <- c(2467500, 2479856, 1376500, 1388856) -usr.map.n.3 <- c(2466696, 2479052, 1366501, 1378857) -usr.map.n.4 <- c(2471500, 2483856, 1356482, 1368838) +usr.map <- c(2451504, 2497815, 1342484, 1402354) # Map credit credit <- paste("Base derived from U.S. Geological Survey National Elevation Dataset 10-meter digital elevation model.", @@ -37,26 +32,30 @@ CheckStatus <- function(s) { } ## ----warning=FALSE, message=FALSE, results="hide"------------------------ -library("rgdal") # bindings for the geospatial data abstraction library -library("raster") # gridded spatial data toolkit -loadNamespace("rgeos") # interface to geometry engine -loadNamespace("dplyr") # tool for working with data frame like objects -loadNamespace("wrv") # processor for groundwater-flow model +library("rgdal") # bindings for the geospatial data abstraction library +library("raster") # gridded spatial data toolkit ## ------------------------------------------------------------------------ rasterOptions(standardnames = FALSE) -## ------------------------------------------------------------------------ -url.git <- "https://raw.githubusercontent.com/USGS-R/wrv/master/inst/extdata/" +## ----download_git, message=FALSE, results="hide"------------------------- +url <- "https://github.com/USGS-R/wrv.git" +path <- file.path(tempdir(), basename(tools::file_path_sans_ext(url))) +git2r::clone(url, path, progress = FALSE) +dir.in <- file.path(path, "inst/extdata") +files <- list.files(dir.in, pattern = "*.zip$", full.names = TRUE, recursive = TRUE) +for (i in files) unzip(i, exdir = dirname(i)) -## ------------------------------------------------------------------------ -ftp.ned <- paste0("ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/", - "13/ArcGrid/n44w115.zip") +## ----download_ned, message=FALSE----------------------------------------- +ftp <- "ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/13/ArcGrid/n44w115.zip" +file <- file.path(tempdir(), basename(ftp)) +download.file(ftp, file) +unzip(file, exdir = dir.in) -## ------------------------------------------------------------------------ -dir.create(dir.dat <- file.path(getwd(), "data"), showWarnings = FALSE) +## ----create_data_dir----------------------------------------------------- +dir.create(dir.out <- "data", showWarnings = FALSE) -## ------------------------------------------------------------------------ +## ----unit_conversions---------------------------------------------------- in.to.m <- 0.0254 # inches to meters ft.to.m <- 0.3048 # feet to meters mm.to.m <- 0.001 # millimeters to meters @@ -66,107 +65,110 @@ in.per.y.to.m.per.d <- 6.95429e-05 # inches per year to meters per day af.per.y.to.m3.per.d <- 3.377 # acre-feet per year to cubic meters per day cfs.to.m3.per.d <- 2446.57555 # cubic feet per second to cubic meters per day -## ------------------------------------------------------------------------ +## ----crs----------------------------------------------------------------- crs <- CRS(paste("+proj=tmerc +lat_0=42 +lon_0=-114 +k=0.9996 +x_0=2500000 +y_0=1200000", "+datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0")) -## ------------------------------------------------------------------------ +## ----spatial------------------------------------------------------------- ext <- extent(2453200, 2496100, 1344139, 1400639) # xmin, xmax, ymin, ymax in IDTM spatial.grid <- raster(crs = crs, ext = ext, resolution = 100) -## ------------------------------------------------------------------------ +## ----high_res_spatial---------------------------------------------------- +high.res.spatial.grid <- disaggregate(spatial.grid, fact = 5L) + +## ----temporal------------------------------------------------------------ tr.interval <- as.Date(c("1995-01-01", "2011-01-01"), tz = "MST") tr.stress.periods <- seq(tr.interval[1] , tr.interval[2], "1 month") yr.mo <- format(head(tr.stress.periods, -1), "%Y%m") yr.mo.irr <- yr.mo[months(head(tr.stress.periods, -1), abbreviate = TRUE) %in% c("Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")] -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "canal/canal.seep.csv")) +## ----canal_seep_1-------------------------------------------------------- +file <- file.path(dir.in, "canal/canal.seep.csv") canal.seep <- read.csv(file, strip.white = TRUE) -save(canal.seep, file = file.path(dir.dat, "canal.seep.rda"), compress = "xz") +save(canal.seep, file = file.path(dir.out, "canal.seep.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("canal.seep") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "div/comb.sw.irr.csv")) +## ----comb_sw_irr_1------------------------------------------------------- +file <- file.path(dir.in, "div/comb.sw.irr.csv") comb.sw.irr <- read.csv(file, strip.white = TRUE) comb.sw.irr$Pdate <- as.Date(comb.sw.irr$Pdate, format = "%m/%d/%Y") comb.sw.irr$MaxDivRate <- comb.sw.irr$MaxDivRate * cfs.to.m3.per.d -save(comb.sw.irr, file = file.path(dir.dat, "comb.sw.irr.rda"), compress = "xz") +save(comb.sw.irr, file = file.path(dir.out, "comb.sw.irr.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("comb.sw.irr") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "et/et.method.csv")) +## ----et_method_1--------------------------------------------------------- +file <- file.path(dir.in, "et/et.method.csv") et.method <- read.csv(file, strip.white = TRUE) et.method$YearMonth <- as.character(et.method$YearMonth) -save(et.method, file = file.path(dir.dat, "et.method.rda"), compress = "xz") +save(et.method, file = file.path(dir.out, "et.method.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("et.method") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "div/div.gw.csv")) +## ----div_gw_1------------------------------------------------------------ +file <- file.path(dir.in, "div/div.gw.csv") div.gw <- read.csv(file, strip.white = TRUE) div.gw$YearMonth <- as.factor(div.gw$YearMonth) div.gw$GWDiv <- div.gw$GWDiv_af * af.to.m3 div.gw$GWDiv_af <- NULL div.gw[is.na(div.gw$GWDiv), "GWDiv"] <- 0 -save(div.gw, file = file.path(dir.dat, "div.gw.rda"), compress = "xz") +save(div.gw, file = file.path(dir.out, "div.gw.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("div.gw") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "irr/efficiency.csv")) +## ----efficiency_1-------------------------------------------------------- +file <- file.path(dir.in, "irr/efficiency.csv") efficiency <- read.csv(file, strip.white = TRUE) -save(efficiency, file = file.path(dir.dat, "efficiency.rda"), compress = "xz") +save(efficiency, file = file.path(dir.out, "efficiency.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("efficiency") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "irr/irr.lands.year.csv")) +## ----irr_lands_year_1---------------------------------------------------- +file <- file.path(dir.in, "irr/irr.lands.year.csv") irr.lands.year <- read.csv(file, strip.white = TRUE, colClasses = "character") -save(irr.lands.year, file = file.path(dir.dat, "irr.lands.year.rda"), compress = "xz") +save(irr.lands.year, file = file.path(dir.out, "irr.lands.year.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("irr.lands.year") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.choco.csv")) +## ----swe_1--------------------------------------------------------------- +file <- file.path(dir.in, "precip/swe.choco.csv") swe.choco <- read.csv(file, strip.white = TRUE) swe.choco$MonthDay <- format(as.Date(swe.choco$Date, "%m/%d/%Y"), "%m%d") swe.choco$SWE <- swe.choco$SWE_in * in.to.m -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.hailey.csv")) +file <- file.path(dir.in, "precip/swe.hailey.csv") swe.hailey <- read.csv(file, strip.white = TRUE) swe.hailey$MonthDay <- format(as.Date(swe.hailey$Date, "%m/%d/%Y"), "%m%d") swe.hailey$SWE <- swe.hailey$SWE_in * in.to.m -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.picabo.csv")) +file <- file.path(dir.in, "precip/swe.picabo.csv") swe.picabo <- read.csv(file, strip.white = TRUE) swe.picabo$MonthDay <- format(as.Date(swe.picabo$Date, "%m/%d/%Y"), "%m%d") swe.picabo$SWE <- swe.picabo$SWE_in * in.to.m -## ------------------------------------------------------------------------ +## ----swe_2--------------------------------------------------------------- swe.choco <- aggregate(swe.choco$SWE, list(swe.choco$MonthDay), mean) swe.hailey <- aggregate(swe.hailey$SWE, list(swe.hailey$MonthDay), mean) swe.picabo <- aggregate(swe.picabo$SWE, list(swe.picabo$MonthDay), mean) -## ------------------------------------------------------------------------ +## ----swe_3--------------------------------------------------------------- swe <- swe.choco[order(swe.choco[[1]]), ] swe <- dplyr::left_join(swe, swe.hailey, by = "Group.1") swe <- dplyr::left_join(swe, swe.picabo, by = "Group.1") names(swe) <- c("MonthDay", "Choco", "Hailey", "Picabo") -save(swe, file = file.path(dir.dat, "swe.rda"), compress = "xz") +save(swe, file = file.path(dir.out, "swe.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("swe") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "precip/precip.csv")) +## ----precipitation_1----------------------------------------------------- +file <- file.path(dir.in, "precip/precip.csv") d <- read.csv(file, strip.white = TRUE) d$Ketchum <- d$Ketchum_ft * ft.to.m d$Hailey <- d$Hailey_ft * ft.to.m @@ -175,12 +177,12 @@ d$Ketchum_ft <- NULL d$Hailey_ft <- NULL d$Picabo_ft <- NULL -## ------------------------------------------------------------------------ +## ----precipitation_2----------------------------------------------------- x <- apply(d[, c("Picabo", "Ketchum")], 1, mean) y <- d$Hailey LM <- lm(y ~ x) -## ------------------------------------------------------------------------ +## ----precipitation_3----------------------------------------------------- is.na.hailey <- is.na(y) d$Hailey[is.na.hailey] <- predict(LM, data.frame(x))[is.na.hailey] precipitation <- d @@ -198,15 +200,14 @@ d2 <- d[ is.na.hailey, ] cols <- "#327CCB" ylab <- paste("Monthly precipitation, in", c("meters", "feet")) ltys <- c(1, 2) -wrv::PlotGraph(d, xlim=tr.interval, ylab=ylab, col=cols, lty=0, - conversion.factor=1 / ft.to.m, center.date.labels=TRUE) +inlmisc::PlotGraph(d, xlim=tr.interval, ylab=ylab, col=cols, lty=0, + conversion.factor=1 / ft.to.m, center.date.labels=TRUE) lines(d1, lty=ltys[1], col=cols, type="s") lines(d2, lty=ltys[2], col=cols, type="s") legend("topright", c("Measured", "Estimated"), col=cols, lty=ltys, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) -## ------------------------------------------------------------------------ +## ----precipitation_4----------------------------------------------------- d <- precipitation mo <- month.abb[as.integer(substr(precipitation$YearMonth, 5, 6))] for (i in seq_along(mo)) { @@ -234,11 +235,11 @@ precipitation <- dplyr::left_join(d, precipitation, by = "YearMonth") sites <- c("Ketchum", "Hailey", "Picabo") names(precipitation) <- c("YearMonth", paste0(sites, ".raw"), sites) -## ------------------------------------------------------------------------ +## ----precipitation_5----------------------------------------------------- date.time <- as.Date(paste0(precipitation[, "YearMonth"], "01"), "%Y%m%d") precipitation <- precipitation[date.time >= tr.interval[1] & date.time < tr.interval[2], ] -## ------------------------------------------------------------------------ +## ----precipitation_6----------------------------------------------------- d <- data.frame(YearMonth = as.factor(rep(as.character(precipitation$YearMonth), 3)), PrecipZone = rep(sites, each = nrow(precipitation)), Precip = NA, Precip.raw = NA) @@ -246,51 +247,51 @@ d[d$PrecipZone == "Ketchum", 3:4] <- precipitation[, c("Ketchum", "Ketchum.raw") d[d$PrecipZone == "Hailey", 3:4] <- precipitation[, c("Hailey", "Hailey.raw")] d[d$PrecipZone == "Picabo", 3:4] <- precipitation[, c("Picabo", "Picabo.raw")] -## ------------------------------------------------------------------------ +## ----precipitation_7----------------------------------------------------- precipitation <- d -save(precipitation, file = file.path(dir.dat, "precipitation.rda"), compress = "xz") +save(precipitation, file = file.path(dir.out, "precipitation.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("precipitation") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "div/priority.cuts.csv")) +## ----priority_cuts_1----------------------------------------------------- +file <- file.path(dir.in, "div/priority.cuts.csv") priority.cuts <- read.csv(file, strip.white = TRUE) priority.cuts$YearMonth <- as.factor(priority.cuts$YearMonth) priority.cuts$Pdate_BWR <- as.Date(priority.cuts$Pdate_BWR, format = "%m/%d/%Y") priority.cuts$Pdate_SC <- as.Date(priority.cuts$Pdate_SC, format = "%m/%d/%Y") -save(priority.cuts, file = file.path(dir.dat, "priority.cuts.rda"), compress = "xz") +save(priority.cuts, file = file.path(dir.out, "priority.cuts.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("priority.cuts") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "div/div.sw.csv")) +## ----div_sw_1------------------------------------------------------------ +file <- file.path(dir.in, "div/div.sw.csv") div.sw <- read.csv(file, strip.white = TRUE) div.sw$YearMonth <- as.factor(div.sw$YearMonth) div.sw$SWDiv <- div.sw$SWDiv_af * af.to.m3 div.sw$SWDiv_af <- NULL div.sw[is.na(div.sw$SWDiv), "SWDiv"] <- 0 -save(div.sw, file = file.path(dir.dat, "div.sw.rda"), compress = "xz") +save(div.sw, file = file.path(dir.out, "div.sw.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("div.sw") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "div/div.ww.csv")) +## ----div_ww_1------------------------------------------------------------ +file <- file.path(dir.in, "div/div.ww.csv") div.ww <- read.csv(file, strip.white = TRUE) div.ww$YearMonth <- as.factor(div.ww$YearMonth) div.ww$WWDiv <- div.ww$WWTP_af * af.to.m3 div.ww$WWTP_af <- NULL div.ww[is.na(div.ww$WWDiv), "WWDiv"] <- 0 -save(div.ww, file = file.path(dir.dat, "div.ww.rda"), compress = "xz") +save(div.ww, file = file.path(dir.out, "div.ww.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("div.ww") -## ------------------------------------------------------------------------ +## ----gage_disch_1-------------------------------------------------------- FUN <- function(i) { - file <- wrv::DownloadFile(paste0(url.git, "gage/", i)) + file <- file.path(dir.in, "gage", i) d <- read.csv(file, colClasses = "character", strip.white = TRUE) d$Date <- as.Date(d$Date, format = "%Y-%m-%d") d$Disch <- suppressWarnings(as.numeric(d$Disch_cfs)) * cfs.to.m3.per.d @@ -300,7 +301,7 @@ gage.13135500.disch <- FUN("gage.13135500.disch.csv") gage.13139510.disch <- FUN("gage.13139510.disch.csv") gage.13140800.disch <- FUN("gage.13140800.disch.csv") -## ------------------------------------------------------------------------ +## ----gage_disch_2-------------------------------------------------------- dlim <- range(c(gage.13135500.disch$Date, gage.13139510.disch$Date, gage.13140800.disch$Date)) d <- data.frame(Date=seq(dlim[1], dlim[2], by = "day")) @@ -309,14 +310,14 @@ d <- dplyr::left_join(d, gage.13139510.disch, by = "Date") d <- dplyr::left_join(d, gage.13140800.disch, by = "Date") colnames(d) <- c("Date", "13135500", "13139510", "13140800") gage.disch <- d -save(gage.disch, file = file.path(dir.dat, "gage.disch.rda"), compress = "xz") +save(gage.disch, file = file.path(dir.out, "gage.disch.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("gage.disch") -## ------------------------------------------------------------------------ +## ----gage_height_1------------------------------------------------------- FUN <- function(i) { - file <- wrv::DownloadFile(paste0(url.git, "gage/", i)) + file <- file.path(dir.in, "gage", i) d <- read.csv(file, colClasses = "character", strip.white = TRUE) d$DateTime <- strptime(d$DateTime, "%Y-%m-%d %H:%M", tz = "MST") d$Date <- as.Date(d$DateTime) @@ -330,7 +331,7 @@ gage.13135500.height <- FUN("gage.13135500.height.csv") gage.13139510.height <- FUN("gage.13139510.height.csv") gage.13140800.height <- FUN("gage.13140800.height.csv") -## ------------------------------------------------------------------------ +## ----gage_height_2------------------------------------------------------- dlim <- range(c(gage.13135500.height$Date, gage.13139510.height$Date, gage.13140800.height$Date)) d <- data.frame(Date=seq(dlim[1], dlim[2], by = "day")) @@ -339,19 +340,19 @@ d <- dplyr::left_join(d, gage.13139510.height, by = "Date") d <- dplyr::left_join(d, gage.13140800.height, by = "Date") colnames(d) <- c("Date", "13135500", "13139510", "13140800") -## ------------------------------------------------------------------------ +## ----gage_height_3------------------------------------------------------- d[d < 0] <- NA -## ------------------------------------------------------------------------ +## ----gage_height_4------------------------------------------------------- x <- d[["13139510"]] y <- d[["13135500"]] LM <- lm(y ~ x) -## ------------------------------------------------------------------------ +## ----gage_height_5------------------------------------------------------- is.na.13135500 <- is.na(y) d[["13135500"]][is.na.13135500] <- predict(LM, data.frame(x))[is.na.13135500] -## ------------------------------------------------------------------------ +## ----gage_height_6------------------------------------------------------- jday <- as.integer(julian(as.Date(paste0("1900-", format(d$Date, "%m-%d"))), origin = as.Date("1899-12-31"))) m <- cbind(jday, height = d[["13140800"]]) @@ -365,9 +366,9 @@ ave.heights <- predict(LPM, newdata = 1:365)[jday] is.na.13140800 <- is.na(d[["13140800"]]) d[["13140800"]][is.na.13140800] <- ave.heights[is.na.13140800] -## ------------------------------------------------------------------------ +## ----gage_height_7------------------------------------------------------- gage.height <- d -save(gage.height, file = file.path(dir.dat, "gage.height.rda"), compress = "xz") +save(gage.height, file = file.path(dir.out, "gage.height.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("gage.height") @@ -387,28 +388,27 @@ x <- merge(d1, d2, by = "Date")[d$Date >= tr.interval[1] & d$Date < tr.interval[ cols <- rep(c("#1B9E77", "#D95F02", "#7570B3"), 2) ltys <- c(rep(1, 3), rep(3, 3)) ylab <- paste("Gage height, in", c("meters", "feet")) -wrv::PlotGraph(x, ylab=ylab, col=cols, lty=ltys, conversion.factor=1 / ft.to.m, - center.date.labels=TRUE) +inlmisc::PlotGraph(x, ylab=ylab, col=cols, lty=ltys, conversion.factor=1 / ft.to.m, + center.date.labels=TRUE) leg <- c(sprintf("%s measured", names(d)[-1]), sprintf("%s estimated", names(d)[-1])) legend("topright", leg, col=cols, lty=ltys, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "div/pod.gw.csv")) +## ----pod_gw_1------------------------------------------------------------ +file <- file.path(dir.in, "div/pod.gw.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$Pdate <- as.Date(d$PriorityDa, format = "%m/%d/%Y") d$IrrRate <- d$IRRcfs * cfs.to.m3.per.d columns <- c("WMISNumber", "WaterRight", "EntityName", "EntitySrce", "Pdate", "IrrRate") pod.gw <- d[, columns] -save(pod.gw, file = file.path(dir.dat, "pod.gw.rda"), compress = "xz") +save(pod.gw, file = file.path(dir.out, "pod.gw.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("pod.gw") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "misc.seepage.csv")) +## ----misc_seepage_1------------------------------------------------------ +file <- file.path(dir.in, "misc.seepage.csv") d <- read.csv(file, strip.white = TRUE) d$Rech <- d$Rech_af * af.to.m3 FUN <- function(i) { @@ -418,34 +418,34 @@ FUN <- function(i) { } l <- lapply(yr.mo, FUN) misc.seepage <- Reduce(function(x, y) merge(x, y, all = TRUE, by = "RechSite"), l) -save(misc.seepage, file = file.path(dir.dat, "misc.seepage.rda"), compress = "xz") +save(misc.seepage, file = file.path(dir.out, "misc.seepage.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("misc.seepage") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "zone.properties.csv")) +## ----zone_properties_1--------------------------------------------------- +file <- file.path(dir.in, "zone.properties.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$hk <- d$hk_ft.per.d * ft.to.m d$hk_ft.per.d <- NULL d$ss <- d$ss_per.ft / ft.to.m d$ss_per.ft <- NULL zone.properties <- d -save(zone.properties, file = file.path(dir.dat, "zone.properties.rda"), compress = "xz") +save(zone.properties, file = file.path(dir.out, "zone.properties.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("zone.properties") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "perennial.reaches.csv")) +## ----drybed_1------------------------------------------------------------ +file <- file.path(dir.in, "perennial.reaches.csv") perennial.reaches <- read.csv(file, colClasses = "character", strip.white = TRUE)[, 1] drybed <- as.data.frame(matrix(NA, nrow = length(perennial.reaches), ncol = length(yr.mo))) colnames(drybed) <- yr.mo rownames(drybed) <- perennial.reaches drybed[perennial.reaches, ] <- TRUE -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "canal/bypass.canal.op.csv")) +## ----drybed_2------------------------------------------------------------ +file <- file.path(dir.in, "canal/bypass.canal.op.csv") d <- read.csv(file, colClasses = "character", strip.white = TRUE) date1 <- as.Date(d$StartDate, tz = "MST") date2 <- as.Date(d$EndDate, tz = "MST") @@ -468,32 +468,32 @@ episodic.reaches <- c("Big Wood, Glendale to Sluder", "Big Wood, Wood River Ranch to Stanton Crossing") for (i in episodic.reaches) drybed[i, ] <- is.drybed -## ------------------------------------------------------------------------ +## ----drybed_3------------------------------------------------------------ drybed["Big Wood, Wood River Ranch to Stanton Crossing", substr(colnames(drybed), 5, 6) == "10"] <- FALSE -## ------------------------------------------------------------------------ +## ----drybed_4------------------------------------------------------------ drybed <- data.frame(Reach = rownames(drybed), drybed, check.names = FALSE, row.names = NULL, stringsAsFactors = FALSE) -save(drybed, file = file.path(dir.dat, "drybed.rda"), compress = "xz") +save(drybed, file = file.path(dir.out, "drybed.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("drybed") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "opt/obs.wells.head.csv")) +## ----obs_wells_head_1---------------------------------------------------- +file <- file.path(dir.in, "opt/obs.wells.head.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$DateTime <- as.POSIXct(d$DateTime, tz = "MST", format = "%Y-%m-%d %H:%M:%S") d$Head <- as.numeric(d$Head_m) d$Head_m <- NULL obs.wells.head <- d -save(obs.wells.head, file = file.path(dir.dat, "obs.wells.head.rda"), compress = "xz") +save(obs.wells.head, file = file.path(dir.out, "obs.wells.head.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("obs.wells.head") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "opt/reach.recharge.csv")) +## ----reach_recharge_1---------------------------------------------------- +file <- file.path(dir.in, "opt/reach.recharge.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$YearMonth <- as.character(d$YearMonth) d$nKet_Hai <- d$nKet_Hai_cfs * cfs.to.m3.per.d @@ -507,27 +507,27 @@ d$SilverAbv_cfs <- NULL d$SilverBlw <- d$SilverBlw_cfs * cfs.to.m3.per.d d$SilverBlw_cfs <- NULL reach.recharge <- d -save(reach.recharge, file = file.path(dir.dat, "reach.recharge.rda"), compress = "xz") +save(reach.recharge, file = file.path(dir.out, "reach.recharge.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("reach.recharge") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "opt/subreach.recharge.csv")) +## ----subreach_recharge_1------------------------------------------------- +file <- file.path(dir.in, "opt/subreach.recharge.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d[, c("Aug", "Oct", "Mar")] <- d[, c("Aug_cfs", "Oct_cfs", "Mar_cfs")] * cfs.to.m3.per.d d$Aug_cfs <- NULL d$Oct_cfs <- NULL d$Mar_cfs <- NULL subreach.recharge <- d -save(subreach.recharge, file = file.path(dir.dat, "subreach.recharge.rda"), +save(subreach.recharge, file = file.path(dir.out, "subreach.recharge.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("subreach.recharge") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "opt/sensitivity.csv")) +## ----sensitivity_1------------------------------------------------------- +file <- file.path(dir.in, "opt/sensitivity.csv") sensitivity <- read.csv(file, strip.white = TRUE) sensitivity$parameter.name <- as.character(sensitivity$parameter.name) rel <- with(sensitivity, comp.sens * abs(value)) # Realtive Composite Sensitivity @@ -537,50 +537,49 @@ is.log <- sensitivity$parameter.desc %in% c("Horizontal hydraulic conductivity", "Drain conductance") rel[is.log] <- with(sensitivity, comp.sens * abs(log10(value)))[is.log] sensitivity$rel.comp.sens <- rel -save(sensitivity, file = file.path(dir.dat, "sensitivity.rda"), compress = "xz") +save(sensitivity, file = file.path(dir.out, "sensitivity.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("sensitivity") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "decorative/cities.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -cities <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----cities_1------------------------------------------------------------ +path <- file.path(dir.in, "decorative") +cities <- readOGR(dsn = path, layer = "cities", verbose = FALSE) cities <- spTransform(cities, crs) cities <- cities[cities@data$FEATURE_NA != "Elkhorn Village", ] -save(cities, file = file.path(dir.dat, "cities.rda"), compress = "xz") +save(cities, file = file.path(dir.out, "cities.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("cities") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "decorative/map.labels.csv")) +## ----map_labels_1-------------------------------------------------------- +file <- file.path(dir.in, "decorative/map.labels.csv") map.labels <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) map.labels$label <- sub("\\\\n", "\\\n", map.labels$label) coordinates(map.labels) <- 1:2 colnames(map.labels@coords) <- c("x", "y") proj4string(map.labels) <- CRS("+init=epsg:4326") map.labels <- spTransform(map.labels, crs) -save(map.labels, file = file.path(dir.dat, "map.labels.rda"), compress = "xz") +save(map.labels, file = file.path(dir.out, "map.labels.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("map.labels") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "decorative/misc.locations.csv")) +## ----misc_locations_1---------------------------------------------------- +file <- file.path(dir.in, "decorative/misc.locations.csv") misc.locations <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) misc.locations$label <- sub("\\\\n", "\\\n", misc.locations$label) coordinates(misc.locations) <- 1:2 colnames(misc.locations@coords) <- c("x", "y") proj4string(misc.locations) <- CRS("+init=epsg:4326") misc.locations <- spTransform(misc.locations, crs) -save(misc.locations, file = file.path(dir.dat, "misc.locations.rda"), compress = "xz") +save(misc.locations, file = file.path(dir.out, "misc.locations.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("misc.locations") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "precip/weather.stations.csv")) +## ----weather_stations_1-------------------------------------------------- +file <- file.path(dir.in, "precip/weather.stations.csv") weather.stations <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) weather.stations$elevation <- weather.stations$elevation_ft * ft.to.m weather.stations$elevation_ft <- NULL @@ -589,15 +588,14 @@ coordinates(weather.stations) <- 1:2 colnames(weather.stations@coords) <- c("x", "y") proj4string(weather.stations) <- CRS("+init=epsg:4326") weather.stations <- spTransform(weather.stations, crs) -save(weather.stations, file = file.path(dir.dat, "weather.stations.rda"), compress = "xz") +save(weather.stations, file = file.path(dir.out, "weather.stations.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("weather.stations") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "div/pod.wells.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -pod.wells <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----pod_wells_1--------------------------------------------------------- +path <- file.path(dir.in, "div") +pod.wells <- readOGR(dsn = path, layer = "pod.wells", verbose = FALSE) pod.wells <- spTransform(pod.wells, crs) d <- pod.wells@data columns <- c("TopOpen1", "BotOpen1", "TopOpen2", "BotOpen2") @@ -605,7 +603,7 @@ d[, columns] <- d[, columns] * ft.to.m d[d$TopOpen1 == 0 | d$BotOpen1 == 0, c("TopOpen1", "BotOpen1")] <- NA d[d$TopOpen2 == 0 | d$BotOpen2 == 0, c("TopOpen2", "BotOpen2")] <- NA -## ----results="hide"------------------------------------------------------ +## ----pod_wells_2, results="hide"----------------------------------------- is.pred <- is.na(d$TopOpen1) dists <- as.matrix(dist(coordinates(pod.wells))) dists <- dists[!is.pred & d$WellUse %in% "Irrigation", ] @@ -614,16 +612,16 @@ d$TopOpen1[is.pred] <- d$TopOpen1[nearest.well[is.pred]] d$BotOpen1[is.pred] <- d$BotOpen1[nearest.well[is.pred]] columns <- c("WMISNumber", "WellUse", "TopOpen1", "BotOpen1", "TopOpen2", "BotOpen2") pod.wells@data <- d[, columns] -save(pod.wells, file = file.path(dir.dat, "pod.wells.rda"), compress = "xz") +save(pod.wells, file = file.path(dir.out, "pod.wells.rda"), compress = "xz") ## ----include=FALSE------------------------------------------------------- v <- "Location of pumping wells and their completion status in the Wood River Valley aquifer system, south-central Idaho." v <- c(paste("Map showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nchar(v)))), v) ## ----map_completions, echo=FALSE, fig.width=fin.map.0[1], fig.height=fin.map.0[2], fig.scap=sprintf("{%s}", v[1]), fig.cap=sprintf("{%s}", v[2])---- -wrv::PlotMap(crs, xlim=usr.map[1:2], ylim=usr.map[3:4], bg.image=wrv::hill.shading, - dms.tick=TRUE, bg.image.alpha=0.6, rivers=list(x=wrv::streams.rivers), - lakes=list(x=wrv::lakes), credit=credit) +inlmisc::PlotMap(crs, xlim=usr.map[1:2], ylim=usr.map[3:4], bg.image=wrv::hill.shading, + dms.tick=TRUE, bg.image.alpha=0.6, rivers=list(x=wrv::streams.rivers), + lakes=list(x=wrv::lakes), credit=credit) plot(wrv::alluvium.extent, border="#FFFFFFCC", add=TRUE) cols <- c("#9061C2D9", "#FBB829D9") pchs <- c(24, 21) @@ -635,25 +633,22 @@ text(wrv::cities, labels=wrv::cities@data$FEATURE_NA, col="#333333", cex=0.5, po leg <- paste(c("Estimated", "Measured"), "well completion") legend("topright", leg, col=NA, pt.bg=cols, pch=pchs, pt.cex=pt.cexs, pt.lwd=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- CheckStatus("pod.wells") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "gage/streamgages.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -streamgages <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----streamgages_1------------------------------------------------------- +path <- file.path(dir.in, "gage") +streamgages <- readOGR(dsn = path, layer = "streamgages", verbose = FALSE) streamgages <- spTransform(streamgages, crs) -save(streamgages, file = file.path(dir.dat, "streamgages.rda"), compress = "xz") +save(streamgages, file = file.path(dir.out, "streamgages.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("streamgages") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "opt/obs.wells.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -obs.wells <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE, +## ----obs_wells_1--------------------------------------------------------- +path <- file.path(dir.in, "opt") +obs.wells <- readOGR(dsn = path, layer = "obs.wells", verbose = FALSE, stringsAsFactors = FALSE) obs.wells <- spTransform(obs.wells, crs) d <- obs.wells@data @@ -667,7 +662,7 @@ d$BotOpen1 <- as.numeric(d$OPENINGMAX) * ft.to.m d$TopOpen2 <- NA d$BotOpen2 <- NA -## ------------------------------------------------------------------------ +## ----obs_wells_2--------------------------------------------------------- is.pred <- is.na(d$TopOpen1) dists <- as.matrix(dist(coordinates(obs.wells)))[!is.pred, ] nearest.well <- as.integer(apply(dists, 2, function(i) names(which.min(i)))) @@ -675,16 +670,15 @@ d$TopOpen1[is.pred] <- d$TopOpen1[nearest.well[is.pred]] d$BotOpen1[is.pred] <- d$BotOpen1[nearest.well[is.pred]] obs.wells@data <- d -## ------------------------------------------------------------------------ -save(obs.wells, file = file.path(dir.dat, "obs.wells.rda"), compress = "xz") +## ----obs_wells_3--------------------------------------------------------- +save(obs.wells, file = file.path(dir.out, "obs.wells.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("obs.wells") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "opt/seepage.study.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -seepage.study <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----seepage_study_1----------------------------------------------------- +path <- file.path(dir.in, "opt") +seepage.study <- readOGR(dsn = path, layer = "seepage.study", verbose = FALSE) seepage.study <- spTransform(seepage.study, crs) d <- seepage.study@data d$Aug <- d$Aug_cfs * cfs.to.m3.per.d @@ -694,47 +688,42 @@ d$Aug_cfs <- NULL d$Oct_cfs <- NULL d$Mar_cfs <- NULL seepage.study@data <- d -save(seepage.study, file = file.path(dir.dat, "seepage.study.rda"), compress = "xz") +save(seepage.study, file = file.path(dir.out, "seepage.study.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("seepage.study") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "opt/div.ret.exch.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -div.ret.exch <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----div_ret_exch_1------------------------------------------------------ +path <- file.path(dir.in, "opt") +div.ret.exch <- readOGR(dsn = path, layer = "div.ret.exch", verbose = FALSE) div.ret.exch <- spTransform(div.ret.exch, crs) -save(div.ret.exch, file = file.path(dir.dat, "div.ret.exch.rda"), compress = "xz") +save(div.ret.exch, file = file.path(dir.out, "div.ret.exch.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("div.ret.exch") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "opt/pilot.points.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -pilot.points <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----pilot_points_1------------------------------------------------------ +path <- file.path(dir.in, "opt") +pilot.points <- readOGR(dsn = path, layer = "pilot.points", verbose = FALSE) pilot.points <- spTransform(pilot.points, crs) -save(pilot.points, file = file.path(dir.dat, "pilot.points.rda"), compress = "xz") +save(pilot.points, file = file.path(dir.out, "pilot.points.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("pilot.points") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "canal/canals.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -canals <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----canals_1------------------------------------------------------------ +path <- file.path(dir.in, "canal") +canals <- readOGR(dsn = path, layer = "canals", verbose = FALSE) canals <- spTransform(canals, crs) canals@data$Name <- as.character(canals@data$NAME) canals@data <- canals@data[, c("EntityName", "Name")] -save(canals, file = file.path(dir.dat, "canals.rda"), compress = "xz") +save(canals, file = file.path(dir.out, "canals.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("canals") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "river.reaches.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -river.reaches <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----river_reaches_1----------------------------------------------------- +river.reaches <- readOGR(dsn = dir.in, layer = "river.reaches", verbose = FALSE) river.reaches <- spTransform(river.reaches, crs) d <- river.reaches@data d$RchAvg <- d$RchAvg_cfs * cfs.to.m3.per.d @@ -744,116 +733,107 @@ d$BedThk <- d$BedThk_ft * ft.to.m columns <- c("Reach", "BigReach", "DrainRiver", "RchAvg", "BigRAv", "ReachNo", "Depth", "BedThk") river.reaches@data <- d[, columns] -save(river.reaches, file = file.path(dir.dat, "river.reaches.rda"), compress = "xz") +save(river.reaches, file = file.path(dir.out, "river.reaches.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("river.reaches") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "decorative/rivers.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -streams.rivers <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----streams_rivers_1---------------------------------------------------- +path <- file.path(dir.in, "decorative") +streams.rivers <- readOGR(dsn = path, layer = "rivers", verbose = FALSE) streams.rivers <- spTransform(streams.rivers, crs) -save(streams.rivers, file = file.path(dir.dat, "streams.rivers.rda"), compress = "xz") +save(streams.rivers, file = file.path(dir.out, "streams.rivers.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("streams.rivers") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "decorative/tributary.streams.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -tributary.streams <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----tributary_streams_1------------------------------------------------- +path <- file.path(dir.in, "decorative") +tributary.streams <- readOGR(dsn = path, layer = "tributary.streams", verbose = FALSE) tributary.streams <- spTransform(tributary.streams, crs) -save(tributary.streams, file = file.path(dir.dat, "tributary.streams.rda"), +save(tributary.streams, file = file.path(dir.out, "tributary.streams.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("tributary.streams") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "canal/bypass.canal.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -bypass.canal <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----bypass_canal_1------------------------------------------------------ +path <- file.path(dir.in, "canal") +bypass.canal <- readOGR(dsn = path, layer = "bypass.canal", verbose = FALSE) bypass.canal <- spTransform(bypass.canal, crs) bypass.canal <- as(bypass.canal, "SpatialLines") -save(bypass.canal, file = file.path(dir.dat, "bypass.canal.rda"), compress = "xz") +save(bypass.canal, file = file.path(dir.out, "bypass.canal.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("bypass.canal") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "wl.200610.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -wl.200610 <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----wl_200610_1--------------------------------------------------------- +wl.200610 <- readOGR(dsn = dir.in, layer = "wl.200610", verbose = FALSE) wl.200610 <- spTransform(wl.200610, crs) wl.200610@data$CONTOUR <- wl.200610@data$CONTOUR * ft.to.m -save(wl.200610, file = file.path(dir.dat, "wl.200610.rda"), compress = "xz") +save(wl.200610, file = file.path(dir.out, "wl.200610.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("wl.200610") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "decorative/major.roads.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -major.roads <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----major_roads_1------------------------------------------------------- +path <- file.path(dir.in, "decorative") +major.roads <- readOGR(dsn = path, layer = "major.roads", verbose = FALSE) major.roads <- spTransform(major.roads, crs) -save(major.roads, file = file.path(dir.dat, "major.roads.rda"), compress = "xz") +save(major.roads, file = file.path(dir.out, "major.roads.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("major.roads") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "extent/alluvium.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -alluvium.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----alluvium_extent_1--------------------------------------------------- +path <- file.path(dir.in, "extent") +alluvium.extent <- readOGR(dsn = path, layer = "alluvium.extent", verbose = FALSE) alluvium.extent <- spTransform(alluvium.extent, crs) -save(alluvium.extent, file = file.path(dir.dat, "alluvium.extent.rda"), compress = "xz") +save(alluvium.extent, file = file.path(dir.out, "alluvium.extent.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("alluvium.extent") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "extent/clay.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -clay.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----clay_extent_1------------------------------------------------------- +path <- file.path(dir.in, "extent") +clay.extent <- readOGR(dsn = path, layer = "clay.extent", verbose = FALSE) clay.extent <- spTransform(clay.extent, crs) -save(clay.extent, file = file.path(dir.dat, "clay.extent.rda"), compress = "xz") +save(clay.extent, file = file.path(dir.out, "clay.extent.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("clay.extent") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "extent/basalt.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -basalt.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----basalt_extent_1----------------------------------------------------- +path <- file.path(dir.in, "extent") +basalt.extent <- readOGR(dsn = path, layer = "basalt.extent", verbose = FALSE) basalt.extent <- spTransform(basalt.extent, crs) -save(basalt.extent, file = file.path(dir.dat, "basalt.extent.rda"), compress = "xz") +save(basalt.extent, file = file.path(dir.out, "basalt.extent.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("basalt.extent") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "drains.kml")) +## ----drains_1------------------------------------------------------------ +file <- file.path(dir.in, "drains.kml") p <- suppressWarnings(readOGR(file, basename(file), verbose = FALSE)) p@data$Description <- NULL -file <- wrv::DownloadFile(paste0(url.git, "drains.csv")) +file <- file.path(dir.in, "drains.csv") d <- read.csv(file, strip.white = TRUE) p@data <- dplyr::left_join(p@data, d, by = "Name") p <- spTransform(p, crs) drains <- p -save(drains, file = file.path(dir.dat, "drains.rda"), compress = "xz") +save(drains, file = file.path(dir.out, "drains.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("drains") -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "tributaries.kml")) +## ----tributaries_1------------------------------------------------------- +file <- file.path(dir.in, "tributaries.kml") p <- suppressWarnings(readOGR(file, basename(file), verbose = FALSE)) p <- spTransform(p, crs) p@data$Description <- NULL -## ------------------------------------------------------------------------ -file <- wrv::DownloadFile(paste0(url.git, "tributaries.csv")) +## ----tributaries_2------------------------------------------------------- +file <- file.path(dir.in, "tributaries.csv") d <- read.csv(file, strip.white = TRUE) names(d) <- sub("_m$", "", names(d)) d$K <- d$K_ft.per.d * ft.to.m @@ -861,34 +841,34 @@ d$K_ft.per.d <- NULL d$SatArea <- (pi * d$TribWidth * d$BdrkDepth) / 4 # area of lower-half of ellipse d$DarcyFlow <- d$K * d$SatArea * d$LandGrad -## ------------------------------------------------------------------------ +## ----tributaries_3------------------------------------------------------- d$BasinArea <- d$BasinArea_mi2 * mi2.to.m2 d$BasinArea_mi2 <- NULL natural.basin.area.break <- 2.59e+7 # 10 square-miles is.small <- d$BasinArea < natural.basin.area.break d$BasinAreaType <- as.factor(c("big", "small")[is.small + 1L]) -## ------------------------------------------------------------------------ +## ----tributaries_4------------------------------------------------------- d$PrecipRate <- d$PrecipRate_in.per.yr * in.per.y.to.m.per.d d$PrecipRate_in.per.yr <- NULL d$PrecipFlow <- d$BasinArea * d$PrecipRate -## ------------------------------------------------------------------------ +## ----tributaries_5------------------------------------------------------- d$FlowRatio <- d$DarcyFlow / d$PrecipFlow -## ------------------------------------------------------------------------ +## ----tributaries_6------------------------------------------------------- d$Flow <- d$DarcyFlow d$Flow[is.small] <- d$PrecipFlow[is.small] * mean(d$FlowRatio[!is.small]) -## ------------------------------------------------------------------------ +## ----tributaries_7------------------------------------------------------- p@data <- dplyr::left_join(p@data, d, by = "Name") tributaries <- p -save(tributaries, file = file.path(dir.dat, "tributaries.rda"), compress = "xz") +save(tributaries, file = file.path(dir.out, "tributaries.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("tributaries") -## ------------------------------------------------------------------------ +## ----precip_zones_1------------------------------------------------------ ids <- c("Ketchum", "Hailey", "Picabo") y <- coordinates(weather.stations)[match(rev(ids), weather.stations@data$id), "y"] s <- c(mean(y[1:2]), mean(y[2:3])) # northing zone separators @@ -902,34 +882,32 @@ p3 <- Polygons(list(Polygon(rbind(p3, p3[1, ]))), ID = 3) p <- SpatialPolygons(list(p1, p2, p3), proj4string = crs) p <- SpatialPolygonsDataFrame(p, data.frame(ID = 1:3, PrecipZone = ids)) precip.zones <- p -save(precip.zones, file = file.path(dir.dat, "precip.zones.rda"), compress = "xz") +save(precip.zones, file = file.path(dir.out, "precip.zones.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("precip.zones") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "irr/irr.entities.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -irr.entities <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----irr_entities_1------------------------------------------------------ +path <- file.path(dir.in, "irr") +irr.entities <- readOGR(dsn = path, layer = "irr.entities", verbose = FALSE) irr.entities <- spTransform(irr.entities, crs) irr.entities <- rgeos::gBuffer(irr.entities, width = 0, byid = TRUE) d <- irr.entities@data d$EntitySrce <- as.factor(paste(d$EntityName, d$Source)) d$PrecipZone <- over(rgeos::gCentroid(irr.entities, byid = TRUE), precip.zones)$PrecipZone irr.entities@data <- d[, c("EntityName", "Source", "EntitySrce", "PrecipZone")] -save(irr.entities, file = file.path(dir.dat, "irr.entities.rda"), compress = "xz") +save(irr.entities, file = file.path(dir.out, "irr.entities.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("irr.entities") -## ------------------------------------------------------------------------ +## ----irr_lands_1--------------------------------------------------------- +path <- file.path(dir.in, "irr") yr <- c(1996, 2000, 2002, 2006, 2008, 2009, 2010) -urls <- paste0(url.git, "irr/irr.lands.", yr, ".zip") +files <- paste0("irr.lands.", yr) irr.lands <- list() -for (i in seq_along(urls)) { - files <- wrv::DownloadFile(urls[i]) - layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) - p <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +for (i in seq_along(files)) { + p <- readOGR(dsn = path, layer = files[i], verbose = FALSE) p <- spTransform(p, crs) p@data <- p@data[, paste0("STATUS_", substr(yr[i], 1, 3)), drop = FALSE] names(p@data) <- "Status" @@ -939,40 +917,35 @@ for (i in seq_along(urls)) { irr.lands[[i]] <- p } names(irr.lands) <- as.character(yr) -save(irr.lands, file = file.path(dir.dat, "irr.lands.rda"), compress = "xz") +save(irr.lands, file = file.path(dir.out, "irr.lands.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("irr.lands") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "decorative/lakes.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -lakes <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----lakes_1------------------------------------------------------------- +path <- file.path(dir.in, "decorative") +lakes <- readOGR(dsn = path, layer = "lakes", verbose = FALSE) lakes <- spTransform(lakes, crs) -save(lakes, file = file.path(dir.dat, "lakes.rda"), compress = "xz") +save(lakes, file = file.path(dir.out, "lakes.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("lakes") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "public.parcels.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -public.parcels <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----public_parcels_1---------------------------------------------------- +public.parcels <- readOGR(dsn = dir.in, layer = "public.parcels", verbose = FALSE) public.parcels <- spTransform(public.parcels, crs) public.parcels <- as(public.parcels, "SpatialPolygons") -save(public.parcels, file = file.path(dir.dat, "public.parcels.rda"), compress = "xz") +save(public.parcels, file = file.path(dir.out, "public.parcels.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("public.parcels") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "soils.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -soils <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----soils_1------------------------------------------------------------- +soils <- readOGR(dsn = dir.in, layer = "soils", verbose = FALSE) soils <- spTransform(soils, crs) soils@data <- soils@data[, c("GroupSym", "SoilLayer")] names(soils@data)[1] <- "GroupSymbol" -file <- wrv::DownloadFile(paste0(url.git, "soils.csv")) +file <- file.path(dir.in, "soils.csv") d <- read.csv(file, strip.white = TRUE) d$MinRate <- d$MinRate_ft.per.mo * ft.to.m d$MaxRate <- d$MaxRate_ft.per.mo * ft.to.m @@ -982,84 +955,75 @@ d <- suppressWarnings(dplyr::left_join(soils@data, d, by = "GroupSymbol")) d$GroupSymbol <- as.factor(d$GroupSymbol) d$PercolationRate[is.na(d$PercolationRate)] <- 0 soils@data <- d -save(soils, file = file.path(dir.dat, "soils.rda"), compress = "xz") +save(soils, file = file.path(dir.out, "soils.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("soils") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "wetlands.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -wetlands <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----wetlands_1---------------------------------------------------------- +wetlands <- readOGR(dsn = dir.in, layer = "wetlands", verbose = FALSE) wetlands <- spTransform(wetlands, crs) wetlands <- as(wetlands, "SpatialPolygons") -save(wetlands, file = file.path(dir.dat, "wetlands.rda"), compress = "xz") +save(wetlands, file = file.path(dir.out, "wetlands.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("wetlands") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "bellevue.wwtp.ponds.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -bellevue.wwtp.ponds <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----bellevue_wwtp_ponds_1----------------------------------------------- +bellevue.wwtp.ponds <- readOGR(dsn = dir.in, layer = "bellevue.wwtp.ponds", + verbose = FALSE) bellevue.wwtp.ponds <- spTransform(bellevue.wwtp.ponds, crs) bellevue.wwtp.ponds <- as(bellevue.wwtp.ponds, "SpatialPolygons") -save(bellevue.wwtp.ponds, file = file.path(dir.dat, "bellevue.wwtp.ponds.rda"), +save(bellevue.wwtp.ponds, file = file.path(dir.out, "bellevue.wwtp.ponds.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("bellevue.wwtp.ponds") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "opt/kriging.zones.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -kriging.zones <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----kriging_zones_1----------------------------------------------------- +path <- file.path(dir.in, "opt") +kriging.zones <- readOGR(dsn = path, layer = "kriging.zones", verbose = FALSE) kriging.zones <- spTransform(kriging.zones, crs) -save(kriging.zones, file = file.path(dir.dat, "kriging.zones.rda"), compress = "xz") +save(kriging.zones, file = file.path(dir.out, "kriging.zones.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("kriging.zones") -## ------------------------------------------------------------------------ -files <- wrv::DownloadFile(paste0(url.git, "decorative/idaho.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -idaho <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +## ----idaho_1------------------------------------------------------------- +path <- file.path(dir.in, "decorative") +idaho <- readOGR(dsn = path, layer = "idaho", verbose = FALSE) idaho <- as(idaho, "SpatialPolygons") idaho <- spTransform(idaho, crs) -save(idaho, file = file.path(dir.dat, "idaho.rda"), compress = "xz") +save(idaho, file = file.path(dir.out, "idaho.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("idaho") -## ------------------------------------------------------------------------ -high.res.spatial.grid <- disaggregate(spatial.grid, fact = 5L) - -## ----eval=TRUE----------------------------------------------------------- -file <- wrv::DownloadFile(paste0(url.git, "alluvium.thickness.tif")) +## ----alluvium_thickness_1------------------------------------------------ +file <- file.path(dir.in, "alluvium.thickness.tif") alluvium.thickness <- readGDAL(file, band = 1, silent = TRUE) alluvium.thickness <- projectRaster(raster(alluvium.thickness), high.res.spatial.grid) alluvium.thickness <- aggregate(alluvium.thickness, fact = 5L, fun = median) names(alluvium.thickness) <- "alluvium.thickness" -save(alluvium.thickness, file = file.path(dir.dat, "alluvium.thickness.rda"), +save(alluvium.thickness, file = file.path(dir.out, "alluvium.thickness.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("alluvium.thickness") -## ----eval=TRUE----------------------------------------------------------- -wrv::DownloadFile(ftp.ned) -file <- file.path(tempdir(), "grdn44w115_13") -r <- raster(readGDAL(file, band = 1, silent = TRUE)) +## ----land_surface_1------------------------------------------------------ +path <- file.path(dir.in, "grdn44w115_13") +r <- raster(readGDAL(path, band = 1, silent = TRUE)) land.surface <- projectRaster(r, high.res.spatial.grid) land.surface <- aggregate(land.surface, fact = 5L, fun = median) land.surface[is.na(alluvium.thickness)] <- NA names(land.surface) <- "land.surface" -save(land.surface, file = file.path(dir.dat, "land.surface.rda"), compress = "xz") +save(land.surface, file = file.path(dir.out, "land.surface.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("land.surface") -## ----eval=TRUE----------------------------------------------------------- +## ----hill_shading_1------------------------------------------------------ ext <- extent(spatial.grid) ext <- extent(c(extendrange(c(ext@xmin, ext@xmax), f = 0.05), extendrange(c(ext@ymin, ext@ymax), f = 0.05))) @@ -1072,24 +1036,23 @@ r.range <- range(r[], na.rm = TRUE) r[] <- findInterval(r[], seq(r.range[1], r.range[2], length.out = 255)) / 255 r[] <- round(r[], digits = 6) hill.shading <- r -save(hill.shading, file = file.path(dir.dat, "hill.shading.rda"), compress = "xz") +save(hill.shading, file = file.path(dir.out, "hill.shading.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("hill.shading") rm(hill.shading) -## ------------------------------------------------------------------------ -urls <- paste0(url.git, "et/et.", yr.mo, ".tif") +## ----et_1---------------------------------------------------------------- +files <- file.path(dir.in, "et", paste0("et.", yr.mo, ".tif")) FUN <- function(i) { - file <- wrv::DownloadFile(urls[i]) - r <- readGDAL(file, band = 1, silent = TRUE) + r <- readGDAL(files[i], band = 1, silent = TRUE) r[[1]] <- r[[1]] * mm.to.m return(r) } -et.raw <- lapply(seq_along(urls), FUN) +et.raw <- lapply(seq_along(files), FUN) names(et.raw) <- as.character(yr.mo) -## ------------------------------------------------------------------------ +## ----et_2---------------------------------------------------------------- is.missing <- is.na(alluvium.thickness) FUN <- function(i) { r <- aggregate(projectRaster(raster(i), high.res.spatial.grid), fact = 5L) @@ -1100,23 +1063,23 @@ FUN <- function(i) { } et <- stack(lapply(et.raw, FUN), quick = TRUE) names(et) <- as.character(yr.mo) -save(et, file = file.path(dir.dat, "et.rda"), compress = "xz") +save(et, file = file.path(dir.out, "et.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("et") -## ------------------------------------------------------------------------ +## ----entity_components_1------------------------------------------------- p <- irr.lands -p <- lapply(p, function(i) wrv::SetPolygons(i, wetlands, "gDifference", 0.001)) -p <- lapply(p, function(i) wrv::SetPolygons(i, public.parcels, "gDifference", 0.001)) -p <- lapply(p, function(i) wrv::SetPolygons(irr.entities, i, "gIntersection", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(i, wetlands, "gDifference", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(i, public.parcels, "gDifference", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(irr.entities, i, "gIntersection", 0.001)) for (i in seq_along(p)) p[[i]]@data$area <- rgeos::gArea(p[[i]], byid = TRUE) irr.by.entity <- p ## ----echo=FALSE---------------------------------------------------------- rm(list=c("irr.lands", "wetlands", "public.parcels")) -## ------------------------------------------------------------------------ +## ----entity_components_2------------------------------------------------- FUN <- function(i) { d <- aggregate(i@data$area, by = list(i@data$EntitySrce), sum, na.rm = TRUE) names(d) <- c("EntitySrce", "area") @@ -1126,7 +1089,7 @@ FUN <- function(i) { } area.by.entity <- lapply(irr.by.entity, FUN) -## ------------------------------------------------------------------------ +## ----entity_components_3------------------------------------------------- FUN <- function(i) { yr <- irr.lands.year$IL_Year[irr.lands.year$Year %in% substr(i, 1, 4)] p <- irr.by.entity[[yr]] @@ -1155,26 +1118,26 @@ FUN <- function(i) { } entity.components <- lapply(yr.mo, FUN) names(entity.components) <- yr.mo -save(entity.components, file = file.path(dir.dat, "entity.components.rda"), +save(entity.components, file = file.path(dir.out, "entity.components.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("entity.components") rm(et.raw) -## ------------------------------------------------------------------------ +## ----r_canals_1---------------------------------------------------------- r <- rasterize(canals, land.surface, "EntityName", silent = TRUE) r <- ratify(r, count = TRUE) d <- levels(r)[[1]] d$EntityName <- levels(canals@data$EntityName)[d$ID] levels(r) <- d r.canals <- r -save(r.canals, file = file.path(dir.dat, "r.canals.rda"), compress = "xz") +save(r.canals, file = file.path(dir.out, "r.canals.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("r.canals") -## ------------------------------------------------------------------------ +## ----rs_entities_1------------------------------------------------------- FUN <- function(i) { r <- rasterize(entity.components[[i]], land.surface, "EntityName", silent = TRUE) r <- ratify(r, count = TRUE) @@ -1185,12 +1148,12 @@ FUN <- function(i) { } rs.entities <- stack(lapply(yr.mo, FUN), quick = TRUE) names(rs.entities) <- yr.mo -save(rs.entities, file = file.path(dir.dat, "rs.entities.rda"), compress = "xz") +save(rs.entities, file = file.path(dir.out, "rs.entities.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("rs.entities") -## ------------------------------------------------------------------------ +## ----rs_rech_non_irr_1--------------------------------------------------- r.zones <- ratify(rasterize(precip.zones, land.surface, "ID", silent = TRUE)) levels(r.zones) <- cbind(levels(r.zones)[[1]], att = precip.zones@data$PrecipZone) r.soils <- rasterize(soils, land.surface, "PercolationRate", silent = TRUE) @@ -1211,7 +1174,7 @@ FUN <- function(i) { } rs.rech.non.irr <- stack(lapply(yr.mo, FUN), quick = TRUE) names(rs.rech.non.irr) <- yr.mo -save(rs.rech.non.irr, file = file.path(dir.dat, "rs.rech.non.irr.rda"), compress = "xz") +save(rs.rech.non.irr, file = file.path(dir.out, "rs.rech.non.irr.rda"), compress = "xz") ## ----echo=FALSE---------------------------------------------------------- CheckStatus("rs.rech.non.irr") diff --git a/inst/doc/sir20165080_AppendixC.Rnw b/inst/doc/sir20165080_AppendixC.Rnw index 4f7d26b..d791424 100644 --- a/inst/doc/sir20165080_AppendixC.Rnw +++ b/inst/doc/sir20165080_AppendixC.Rnw @@ -4,7 +4,9 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} + +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} \renewcommand{\thefigure}{C\arabic{figure}} \renewcommand{\thetable}{C\arabic{table}} @@ -35,12 +37,7 @@ fin.cs <- c(7.16, 5.39) fin.cs.0 <- c(7.16, 4.73) # Extreme coordinates of plotting region (x1, x2, y1, y2) -usr.map <- c(2451504, 2497815, 1342484, 1402354) -usr.map.s <- c(2472304, 2497015, 1343284, 1358838) -usr.map.n.1 <- c(2463000, 2475356, 1386500, 1398856) -usr.map.n.2 <- c(2467500, 2479856, 1376500, 1388856) -usr.map.n.3 <- c(2466696, 2479052, 1366501, 1378857) -usr.map.n.4 <- c(2471500, 2483856, 1356482, 1368838) +usr.map <- c(2451504, 2497815, 1342484, 1402354) # Map credit credit <- paste("Base derived from U.S. Geological Survey National Elevation Dataset 10-meter digital elevation model.", @@ -88,14 +85,11 @@ It is assumed that the reader of this vignette is familiar with the \R{}-program \section{R Environment} -Load the following user-contributed packages into the current \R{} session: +Load the following packages into the current \R{} session: <>= -library("rgdal") # bindings for the geospatial data abstraction library -library("raster") # gridded spatial data toolkit -loadNamespace("rgeos") # interface to geometry engine -loadNamespace("dplyr") # tool for working with data frame like objects -loadNamespace("wrv") # processor for groundwater-flow model +library("rgdal") # bindings for the geospatial data abstraction library +library("raster") # gridded spatial data toolkit @ \noindent Set a \textbf{raster} package option to prevent the standardization of raster names: @@ -110,28 +104,38 @@ rasterOptions(standardnames = FALSE) \section{Input/Output Paths} -Package datasets are primarily created from unprocessed data files located on \href{https://github.com/USGS-R/wrv}{GitHub}, a web-based distributed revision control system. -The top-level uniform resource locator (URL) for these files is specified as: +Package datasets are primarily created from unprocessed data files located on \href{https://github.com/USGS-R/wrv}{GitHub}, +a web-based distributed revision control system. +Download these files to a temporary directory and uncompress the ZIP files. -<<>>= -url.git <- "https://raw.githubusercontent.com/USGS-R/wrv/master/inst/extdata/" +<>= +url <- "https://github.com/USGS-R/wrv.git" +path <- file.path(tempdir(), basename(tools::file_path_sans_ext(url))) +git2r::clone(url, path, progress = FALSE) +dir.in <- file.path(path, "inst/extdata") +files <- list.files(dir.in, pattern = "*.zip$", full.names = TRUE, recursive = TRUE) +for (i in files) unzip(i, exdir = dirname(i)) @ \noindent The data file containing land-surface elevations was deemed too large in file size (about 500 megabytes) to be placed in the package repository. These elevations are part of the National Elevation Dataset (\href{http://ned.usgs.gov/}{NED}) $\sfrac{1}{3}$-arc-second raster and available in a ArcGRID file format. -The File Transfer Protocol (FTP) for this compressed file is specified as: +Download the ZIP file to a temporary directory and uncompress. -<<>>= -ftp.ned <- paste0("ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/", - "13/ArcGrid/n44w115.zip") +<>= +ftp <- "ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/13/ArcGrid/n44w115.zip" +file <- file.path(tempdir(), basename(ftp)) +download.file(ftp, file) +unzip(file, exdir = dir.in) @ \noindent Output from this vignette is placed in the current working directory. -<<>>= -dir.create(dir.dat <- file.path(getwd(), "data"), showWarnings = FALSE) +<>= +dir.create(dir.out <- "data", showWarnings = FALSE) @ +\newpage + % ========================================================================= \section{Space-Time Grid Scale} @@ -139,7 +143,7 @@ dir.create(dir.dat <- file.path(getwd(), "data"), showWarnings = FALSE) The length and time dimensions for datasets are in units of meters and days, respectively. Conversion factors are listed with an explanation of how they are used: -<<>>= +<>= in.to.m <- 0.0254 # inches to meters ft.to.m <- 0.3048 # feet to meters mm.to.m <- 0.001 # millimeters to meters @@ -150,28 +154,34 @@ af.per.y.to.m3.per.d <- 3.377 # acre-feet per year to cubic meters per cfs.to.m3.per.d <- 2446.57555 # cubic feet per second to cubic meters per day @ -\newpage - \noindent The common coordinate reference system (CRS) applied to all spatial datasets is the Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM83}). \href{http://trac.osgeo.org/proj/}{PROJ.4} projection arguments are used to specify a CRS in R. The CRS that all unprocessed data are converted into is specified as: -<<>>= +<>= crs <- CRS(paste("+proj=tmerc +lat_0=42 +lon_0=-114 +k=0.9996 +x_0=2500000 +y_0=1200000", "+datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0")) @ \noindent The common spatial grid applied to all gridded datasets is composed of 565 rows and 429 columns, and has a constant cell size of 100 meters by 100 meters. -<<>>= +<>= ext <- extent(2453200, 2496100, 1344139, 1400639) # xmin, xmax, ymin, ymax in IDTM spatial.grid <- raster(crs = crs, ext = ext, resolution = 100) @ +\noindent Gridded data are available at a higher resolution (smaller cells) than the resolution of the model grid. +Projecting the higher resolution data into the model grid first requires the projection of this data into a high resolution spatial grid of comparable cell size. +The high resolution spatial grid is defined using a constant cell size of 20 meters by 20 meters. + +<>= +high.res.spatial.grid <- disaggregate(spatial.grid, fact = 5L) +@ + \noindent The transient model simulates groundwater flow from 1995 through 2010, using monthly stress periods. -<<>>= +<>= tr.interval <- as.Date(c("1995-01-01", "2011-01-01"), tz = "MST") tr.stress.periods <- seq(tr.interval[1] , tr.interval[2], "1 month") yr.mo <- format(head(tr.stress.periods, -1), "%Y%m") @@ -179,6 +189,8 @@ yr.mo.irr <- yr.mo[months(head(tr.stress.periods, -1), abbreviate = TRUE) %in% c("Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")] @ +\newpage + % ========================================================================= \section{Level 1 Data} @@ -198,10 +210,10 @@ Variable names, for the most part, are maintained between unprocessed and proces Canal seepage as a fraction of diversions for irrigation entities in the Wood River Valley (WRV). -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "canal/canal.seep.csv")) +<>= +file <- file.path(dir.in, "canal/canal.seep.csv") canal.seep <- read.csv(file, strip.white = TRUE) -save(canal.seep, file = file.path(dir.dat, "canal.seep.rda"), compress = "xz") +save(canal.seep, file = file.path(dir.out, "canal.seep.rda"), compress = "xz") @ <>= @@ -214,12 +226,12 @@ CheckStatus("canal.seep") Supplemental groundwater rights and associated surface-water rights. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/comb.sw.irr.csv")) +<>= +file <- file.path(dir.in, "div/comb.sw.irr.csv") comb.sw.irr <- read.csv(file, strip.white = TRUE) comb.sw.irr$Pdate <- as.Date(comb.sw.irr$Pdate, format = "%m/%d/%Y") comb.sw.irr$MaxDivRate <- comb.sw.irr$MaxDivRate * cfs.to.m3.per.d -save(comb.sw.irr, file = file.path(dir.dat, "comb.sw.irr.rda"), compress = "xz") +save(comb.sw.irr, file = file.path(dir.out, "comb.sw.irr.rda"), compress = "xz") @ <>= @@ -232,11 +244,11 @@ CheckStatus("comb.sw.irr") Methods used to calculate monthly distributions of evapotranspiration rate. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "et/et.method.csv")) +<>= +file <- file.path(dir.in, "et/et.method.csv") et.method <- read.csv(file, strip.white = TRUE) et.method$YearMonth <- as.character(et.method$YearMonth) -save(et.method, file = file.path(dir.dat, "et.method.rda"), compress = "xz") +save(et.method, file = file.path(dir.out, "et.method.rda"), compress = "xz") @ <>= @@ -250,14 +262,14 @@ CheckStatus("et.method") Groundwater diversions recorded by Water District 37 or municipal water providers. Groundwater is diverted from the aquifer by means of either pumping wells or flowing artesian wells. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/div.gw.csv")) +<>= +file <- file.path(dir.in, "div/div.gw.csv") div.gw <- read.csv(file, strip.white = TRUE) div.gw$YearMonth <- as.factor(div.gw$YearMonth) div.gw$GWDiv <- div.gw$GWDiv_af * af.to.m3 div.gw$GWDiv_af <- NULL div.gw[is.na(div.gw$GWDiv), "GWDiv"] <- 0 -save(div.gw, file = file.path(dir.dat, "div.gw.rda"), compress = "xz") +save(div.gw, file = file.path(dir.out, "div.gw.rda"), compress = "xz") @ <>= @@ -270,10 +282,10 @@ CheckStatus("div.gw") Irrigation efficiency for irrigation entities. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "irr/efficiency.csv")) +<>= +file <- file.path(dir.in, "irr/efficiency.csv") efficiency <- read.csv(file, strip.white = TRUE) -save(efficiency, file = file.path(dir.dat, "efficiency.rda"), compress = "xz") +save(efficiency, file = file.path(dir.out, "efficiency.rda"), compress = "xz") @ <>= @@ -287,10 +299,10 @@ CheckStatus("efficiency") The annual land classification for irrigation practices is only available for select years. For missing years, this dataset provides substitute years when land-classification was available. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "irr/irr.lands.year.csv")) +<>= +file <- file.path(dir.in, "irr/irr.lands.year.csv") irr.lands.year <- read.csv(file, strip.white = TRUE, colClasses = "character") -save(irr.lands.year, file = file.path(dir.dat, "irr.lands.year.rda"), compress = "xz") +save(irr.lands.year, file = file.path(dir.out, "irr.lands.year.rda"), compress = "xz") @ <>= @@ -303,16 +315,16 @@ CheckStatus("irr.lands.year") Average daily snow water equivalent (SWE) at weather stations in the WRV and surrounding areas. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.choco.csv")) +<>= +file <- file.path(dir.in, "precip/swe.choco.csv") swe.choco <- read.csv(file, strip.white = TRUE) swe.choco$MonthDay <- format(as.Date(swe.choco$Date, "%m/%d/%Y"), "%m%d") swe.choco$SWE <- swe.choco$SWE_in * in.to.m -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.hailey.csv")) +file <- file.path(dir.in, "precip/swe.hailey.csv") swe.hailey <- read.csv(file, strip.white = TRUE) swe.hailey$MonthDay <- format(as.Date(swe.hailey$Date, "%m/%d/%Y"), "%m%d") swe.hailey$SWE <- swe.hailey$SWE_in * in.to.m -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.picabo.csv")) +file <- file.path(dir.in, "precip/swe.picabo.csv") swe.picabo <- read.csv(file, strip.white = TRUE) swe.picabo$MonthDay <- format(as.Date(swe.picabo$Date, "%m/%d/%Y"), "%m%d") swe.picabo$SWE <- swe.picabo$SWE_in * in.to.m @@ -320,7 +332,7 @@ swe.picabo$SWE <- swe.picabo$SWE_in * in.to.m \noindent Aggregate SWE data by day in a year: -<<>>= +<>= swe.choco <- aggregate(swe.choco$SWE, list(swe.choco$MonthDay), mean) swe.hailey <- aggregate(swe.hailey$SWE, list(swe.hailey$MonthDay), mean) swe.picabo <- aggregate(swe.picabo$SWE, list(swe.picabo$MonthDay), mean) @@ -328,26 +340,28 @@ swe.picabo <- aggregate(swe.picabo$SWE, list(swe.picabo$MonthDay), mean) \noindent Combine datasets and write to disk: -<<>>= +<>= swe <- swe.choco[order(swe.choco[[1]]), ] swe <- dplyr::left_join(swe, swe.hailey, by = "Group.1") swe <- dplyr::left_join(swe, swe.picabo, by = "Group.1") names(swe) <- c("MonthDay", "Choco", "Hailey", "Picabo") -save(swe, file = file.path(dir.dat, "swe.rda"), compress = "xz") +save(swe, file = file.path(dir.out, "swe.rda"), compress = "xz") @ <>= CheckStatus("swe") @ +\newpage + % ========================================================================= \subsubsection{Precipitation Rate (precipitation)} Precipitation rates in the WRV and surrounding areas. Combine precipitation records into a single data table: -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "precip/precip.csv")) +<>= +file <- file.path(dir.in, "precip/precip.csv") d <- read.csv(file, strip.white = TRUE) d$Ketchum <- d$Ketchum_ft * ft.to.m d$Hailey <- d$Hailey_ft * ft.to.m @@ -360,7 +374,7 @@ d$Picabo_ft <- NULL \noindent Create a linear regression model between the average of the precipitation depth recorded at the Picabo and Ketchum weather stations, and the precipitation depth recorded at the Hailey weather station: -<<>>= +<>= x <- apply(d[, c("Picabo", "Ketchum")], 1, mean) y <- d$Hailey LM <- lm(y ~ x) @@ -369,7 +383,7 @@ LM <- lm(y ~ x) \noindent A strong positive correlation (R-squared of \Sexpr{format(summary(LM)$r.squared, digits=3)}) indicates that the regression model may be used to estimate missing data at the Hailey weather station (\hyperref[fig:graph_precip_hailey]{fig.~\ref{fig:graph_precip_hailey}}). -<<>>= +<>= is.na.hailey <- is.na(y) d$Hailey[is.na.hailey] <- predict(LM, data.frame(x))[is.na.hailey] precipitation <- d @@ -389,20 +403,19 @@ d2 <- d[ is.na.hailey, ] cols <- "#327CCB" ylab <- paste("Monthly precipitation, in", c("meters", "feet")) ltys <- c(1, 2) -wrv::PlotGraph(d, xlim=tr.interval, ylab=ylab, col=cols, lty=0, - conversion.factor=1 / ft.to.m, center.date.labels=TRUE) +inlmisc::PlotGraph(d, xlim=tr.interval, ylab=ylab, col=cols, lty=0, + conversion.factor=1 / ft.to.m, center.date.labels=TRUE) lines(d1, lty=ltys[1], col=cols, type="s") lines(d2, lty=ltys[2], col=cols, type="s") legend("topright", c("Measured", "Estimated"), col=cols, lty=ltys, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ \newpage \noindent Use a monthly precipitation redistribution model to account for frozen precipitation (snow): -<<>>= +<>= d <- precipitation mo <- month.abb[as.integer(substr(precipitation$YearMonth, 5, 6))] for (i in seq_along(mo)) { @@ -433,14 +446,14 @@ names(precipitation) <- c("YearMonth", paste0(sites, ".raw"), sites) \noindent Remove precipitation records that occurred outside the model simulation period: -<<>>= +<>= date.time <- as.Date(paste0(precipitation[, "YearMonth"], "01"), "%Y%m%d") precipitation <- precipitation[date.time >= tr.interval[1] & date.time < tr.interval[2], ] @ \noindent Add precipitation zone meta data: -<<>>= +<>= d <- data.frame(YearMonth = as.factor(rep(as.character(precipitation$YearMonth), 3)), PrecipZone = rep(sites, each = nrow(precipitation)), Precip = NA, Precip.raw = NA) @@ -451,9 +464,9 @@ d[d$PrecipZone == "Picabo", 3:4] <- precipitation[, c("Picabo", "Picabo.raw")] \noindent Save the dataset to disk: -<<>>= +<>= precipitation <- d -save(precipitation, file = file.path(dir.dat, "precipitation.rda"), compress = "xz") +save(precipitation, file = file.path(dir.out, "precipitation.rda"), compress = "xz") @ <>= @@ -466,13 +479,13 @@ CheckStatus("precipitation") Priority cut dates applied to Big Wood River above Magic Reservoir and Silver Creek by Water District 37 and 37M at the end of each month. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/priority.cuts.csv")) +<>= +file <- file.path(dir.in, "div/priority.cuts.csv") priority.cuts <- read.csv(file, strip.white = TRUE) priority.cuts$YearMonth <- as.factor(priority.cuts$YearMonth) priority.cuts$Pdate_BWR <- as.Date(priority.cuts$Pdate_BWR, format = "%m/%d/%Y") priority.cuts$Pdate_SC <- as.Date(priority.cuts$Pdate_SC, format = "%m/%d/%Y") -save(priority.cuts, file = file.path(dir.dat, "priority.cuts.rda"), compress = "xz") +save(priority.cuts, file = file.path(dir.out, "priority.cuts.rda"), compress = "xz") @ <>= @@ -485,14 +498,14 @@ CheckStatus("priority.cuts") Surface-water diversions recorded by Water District 37 or municipal water providers. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/div.sw.csv")) +<>= +file <- file.path(dir.in, "div/div.sw.csv") div.sw <- read.csv(file, strip.white = TRUE) div.sw$YearMonth <- as.factor(div.sw$YearMonth) div.sw$SWDiv <- div.sw$SWDiv_af * af.to.m3 div.sw$SWDiv_af <- NULL div.sw[is.na(div.sw$SWDiv), "SWDiv"] <- 0 -save(div.sw, file = file.path(dir.dat, "div.sw.rda"), compress = "xz") +save(div.sw, file = file.path(dir.out, "div.sw.rda"), compress = "xz") @ <>= @@ -505,14 +518,14 @@ CheckStatus("div.sw") Discharge from wastewater treatment plants. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/div.ww.csv")) +<>= +file <- file.path(dir.in, "div/div.ww.csv") div.ww <- read.csv(file, strip.white = TRUE) div.ww$YearMonth <- as.factor(div.ww$YearMonth) div.ww$WWDiv <- div.ww$WWTP_af * af.to.m3 div.ww$WWTP_af <- NULL div.ww[is.na(div.ww$WWDiv), "WWDiv"] <- 0 -save(div.ww, file = file.path(dir.dat, "div.ww.rda"), compress = "xz") +save(div.ww, file = file.path(dir.out, "div.ww.rda"), compress = "xz") @ <>= @@ -528,9 +541,9 @@ Big Wood River near Ketchum, Idaho (13135500); Big Wood River at Hailey, Idaho (13139510); and Big Wood River at Stanton Crossing near Bellevue, Idaho (13140800). -<<>>= +<>= FUN <- function(i) { - file <- wrv::DownloadFile(paste0(url.git, "gage/", i)) + file <- file.path(dir.in, "gage", i) d <- read.csv(file, colClasses = "character", strip.white = TRUE) d$Date <- as.Date(d$Date, format = "%Y-%m-%d") d$Disch <- suppressWarnings(as.numeric(d$Disch_cfs)) * cfs.to.m3.per.d @@ -543,7 +556,7 @@ gage.13140800.disch <- FUN("gage.13140800.disch.csv") \noindent Combine discharge records into a single data table: -<<>>= +<>= dlim <- range(c(gage.13135500.disch$Date, gage.13139510.disch$Date, gage.13140800.disch$Date)) d <- data.frame(Date=seq(dlim[1], dlim[2], by = "day")) @@ -552,7 +565,7 @@ d <- dplyr::left_join(d, gage.13139510.disch, by = "Date") d <- dplyr::left_join(d, gage.13140800.disch, by = "Date") colnames(d) <- c("Date", "13135500", "13139510", "13140800") gage.disch <- d -save(gage.disch, file = file.path(dir.dat, "gage.disch.rda"), compress = "xz") +save(gage.disch, file = file.path(dir.out, "gage.disch.rda"), compress = "xz") @ <>= @@ -570,9 +583,9 @@ Big Wood River near Ketchum, Idaho (13135500); Big Wood River at Hailey, Idaho (13139510); and Big Wood River at Stanton Crossing near Bellevue, Idaho (13140800) (\hyperref[fig:graph_gage_height]{fig.~\ref{fig:graph_gage_height}}). -<<>>= +<>= FUN <- function(i) { - file <- wrv::DownloadFile(paste0(url.git, "gage/", i)) + file <- file.path(dir.in, "gage", i) d <- read.csv(file, colClasses = "character", strip.white = TRUE) d$DateTime <- strptime(d$DateTime, "%Y-%m-%d %H:%M", tz = "MST") d$Date <- as.Date(d$DateTime) @@ -589,7 +602,7 @@ gage.13140800.height <- FUN("gage.13140800.height.csv") \noindent Combine gage-height records into a single data table: -<<>>= +<>= dlim <- range(c(gage.13135500.height$Date, gage.13139510.height$Date, gage.13140800.height$Date)) d <- data.frame(Date=seq(dlim[1], dlim[2], by = "day")) @@ -601,13 +614,13 @@ colnames(d) <- c("Date", "13135500", "13139510", "13140800") \noindent Remove negative values of gage height (n = \Sexpr{length(which(d < 0))}): -<<>>= +<>= d[d < 0] <- NA @ \noindent Create a linear regression model between gage-height data recorded at the Hailey gage and Near Ketchum gage: -<<>>= +<>= x <- d[["13139510"]] y <- d[["13135500"]] LM <- lm(y ~ x) @@ -616,7 +629,7 @@ LM <- lm(y ~ x) \noindent A strong positive correlation (R-squared of \Sexpr{format(summary(LM)$r.squared, digits=3)}) indicates that the regression model may be used to estimate missing data at the Near Ketchum gage. -<<>>= +<>= is.na.13135500 <- is.na(y) d[["13135500"]][is.na.13135500] <- predict(LM, data.frame(x))[is.na.13135500] @ @@ -624,7 +637,7 @@ d[["13135500"]][is.na.13135500] <- predict(LM, data.frame(x))[is.na.13135500] \noindent Missing data at the Stanton Crossing near Bellevue gage are replaced with average gage-height values recorded at this gage. Substantial seepage losses and surface-water diversions between the Hailey gage and Stanton Crossing near Bellevue gage make regression inappropriate. -<<>>= +<>= jday <- as.integer(julian(as.Date(paste0("1900-", format(d$Date, "%m-%d"))), origin = as.Date("1899-12-31"))) m <- cbind(jday, height = d[["13140800"]]) @@ -641,9 +654,9 @@ d[["13140800"]][is.na.13140800] <- ave.heights[is.na.13140800] \noindent Save the dataset to disk: -<<>>= +<>= gage.height <- d -save(gage.height, file = file.path(dir.dat, "gage.height.rda"), compress = "xz") +save(gage.height, file = file.path(dir.out, "gage.height.rda"), compress = "xz") @ <>= @@ -666,13 +679,12 @@ x <- merge(d1, d2, by = "Date")[d$Date >= tr.interval[1] & d$Date < tr.interval[ cols <- rep(c("#1B9E77", "#D95F02", "#7570B3"), 2) ltys <- c(rep(1, 3), rep(3, 3)) ylab <- paste("Gage height, in", c("meters", "feet")) -wrv::PlotGraph(x, ylab=ylab, col=cols, lty=ltys, conversion.factor=1 / ft.to.m, - center.date.labels=TRUE) +inlmisc::PlotGraph(x, ylab=ylab, col=cols, lty=ltys, conversion.factor=1 / ft.to.m, + center.date.labels=TRUE) leg <- c(sprintf("%s measured", names(d)[-1]), sprintf("%s estimated", names(d)[-1])) legend("topright", leg, col=cols, lty=ltys, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= @@ -681,14 +693,14 @@ invisible(dev.off()) Points of diversion for groundwater. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/pod.gw.csv")) +<>= +file <- file.path(dir.in, "div/pod.gw.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$Pdate <- as.Date(d$PriorityDa, format = "%m/%d/%Y") d$IrrRate <- d$IRRcfs * cfs.to.m3.per.d columns <- c("WMISNumber", "WaterRight", "EntityName", "EntitySrce", "Pdate", "IrrRate") pod.gw <- d[, columns] -save(pod.gw, file = file.path(dir.dat, "pod.gw.rda"), compress = "xz") +save(pod.gw, file = file.path(dir.out, "pod.gw.rda"), compress = "xz") @ <>= @@ -701,8 +713,8 @@ CheckStatus("pod.gw") Recharge from miscellaneous seepage sites. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "misc.seepage.csv")) +<>= +file <- file.path(dir.in, "misc.seepage.csv") d <- read.csv(file, strip.white = TRUE) d$Rech <- d$Rech_af * af.to.m3 FUN <- function(i) { @@ -712,7 +724,7 @@ FUN <- function(i) { } l <- lapply(yr.mo, FUN) misc.seepage <- Reduce(function(x, y) merge(x, y, all = TRUE, by = "RechSite"), l) -save(misc.seepage, file = file.path(dir.dat, "misc.seepage.rda"), compress = "xz") +save(misc.seepage, file = file.path(dir.out, "misc.seepage.rda"), compress = "xz") @ <>= @@ -725,15 +737,15 @@ CheckStatus("misc.seepage") Hydraulic properties for each hydrogeologic zone. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "zone.properties.csv")) +<>= +file <- file.path(dir.in, "zone.properties.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$hk <- d$hk_ft.per.d * ft.to.m d$hk_ft.per.d <- NULL d$ss <- d$ss_per.ft / ft.to.m d$ss_per.ft <- NULL zone.properties <- d -save(zone.properties, file = file.path(dir.dat, "zone.properties.rda"), compress = "xz") +save(zone.properties, file = file.path(dir.out, "zone.properties.rda"), compress = "xz") @ <>= @@ -747,8 +759,8 @@ CheckStatus("zone.properties") Spring fed creek conditions are specified for select stream reaches. The mathematical representation of spring fed creeks using the MODFLOW river package is identical to the mathematical representation for a dry stream bed. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "perennial.reaches.csv")) +<>= +file <- file.path(dir.in, "perennial.reaches.csv") perennial.reaches <- read.csv(file, colClasses = "character", strip.white = TRUE)[, 1] drybed <- as.data.frame(matrix(NA, nrow = length(perennial.reaches), ncol = length(yr.mo))) colnames(drybed) <- yr.mo @@ -763,8 +775,8 @@ Between Wood River Ranch and Stanton Crossing, the Big Wood River gains water fr thus this reach acts as a spring fed creek when dry bed conditions are specified between Glendale and Wood River Ranch and there is no return flow from the Bypass Canal to the Big Wood River. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "canal/bypass.canal.op.csv")) +<>= +file <- file.path(dir.in, "canal/bypass.canal.op.csv") d <- read.csv(file, colClasses = "character", strip.white = TRUE) date1 <- as.Date(d$StartDate, tz = "MST") date2 <- as.Date(d$EndDate, tz = "MST") @@ -791,17 +803,17 @@ for (i in episodic.reaches) drybed[i, ] <- is.drybed \noindent During the month of October the water district stops monitoring diversions and much of the water diverted into the Bypass Canal is returned to the Big Wood River at Wood River Ranch. Therefore, flows in the Big Wood, Wood River Ranch to Stanton Crossing reach are accounted for in the model. -<<>>= +<>= drybed["Big Wood, Wood River Ranch to Stanton Crossing", substr(colnames(drybed), 5, 6) == "10"] <- FALSE @ \noindent Save the dataset to disk: -<<>>= +<>= drybed <- data.frame(Reach = rownames(drybed), drybed, check.names = FALSE, row.names = NULL, stringsAsFactors = FALSE) -save(drybed, file = file.path(dir.dat, "drybed.rda"), compress = "xz") +save(drybed, file = file.path(dir.out, "drybed.rda"), compress = "xz") @ <>= @@ -815,14 +827,14 @@ CheckStatus("drybed") Groundwater-level measurements recorded in observation wells in the WRV. Values used as observations in parameter estimation. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "opt/obs.wells.head.csv")) +<>= +file <- file.path(dir.in, "opt/obs.wells.head.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$DateTime <- as.POSIXct(d$DateTime, tz = "MST", format = "%Y-%m-%d %H:%M:%S") d$Head <- as.numeric(d$Head_m) d$Head_m <- NULL obs.wells.head <- d -save(obs.wells.head, file = file.path(dir.dat, "obs.wells.head.rda"), compress = "xz") +save(obs.wells.head, file = file.path(dir.out, "obs.wells.head.rda"), compress = "xz") @ <>= @@ -836,8 +848,8 @@ CheckStatus("obs.wells.head") Stream-aquifer flow exchange along river reaches specified as aquifer recharge. Values used as observations in parameter estimation. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "opt/reach.recharge.csv")) +<>= +file <- file.path(dir.in, "opt/reach.recharge.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$YearMonth <- as.character(d$YearMonth) d$nKet_Hai <- d$nKet_Hai_cfs * cfs.to.m3.per.d @@ -851,7 +863,7 @@ d$SilverAbv_cfs <- NULL d$SilverBlw <- d$SilverBlw_cfs * cfs.to.m3.per.d d$SilverBlw_cfs <- NULL reach.recharge <- d -save(reach.recharge, file = file.path(dir.dat, "reach.recharge.rda"), compress = "xz") +save(reach.recharge, file = file.path(dir.out, "reach.recharge.rda"), compress = "xz") @ <>= @@ -865,15 +877,15 @@ CheckStatus("reach.recharge") Stream-aquifer flow exchange along river subreaches specified as aquifer recharge. Values used as observations in parameter estimation. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "opt/subreach.recharge.csv")) +<>= +file <- file.path(dir.in, "opt/subreach.recharge.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d[, c("Aug", "Oct", "Mar")] <- d[, c("Aug_cfs", "Oct_cfs", "Mar_cfs")] * cfs.to.m3.per.d d$Aug_cfs <- NULL d$Oct_cfs <- NULL d$Mar_cfs <- NULL subreach.recharge <- d -save(subreach.recharge, file = file.path(dir.dat, "subreach.recharge.rda"), +save(subreach.recharge, file = file.path(dir.out, "subreach.recharge.rda"), compress = "xz") @ @@ -887,8 +899,8 @@ CheckStatus("subreach.recharge") Calibrated parameter values and composite sensitivities generated by PEST during its last iteration. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "opt/sensitivity.csv")) +<>= +file <- file.path(dir.in, "opt/sensitivity.csv") sensitivity <- read.csv(file, strip.white = TRUE) sensitivity$parameter.name <- as.character(sensitivity$parameter.name) rel <- with(sensitivity, comp.sens * abs(value)) # Realtive Composite Sensitivity @@ -898,7 +910,7 @@ is.log <- sensitivity$parameter.desc %in% c("Horizontal hydraulic conductivity", "Drain conductance") rel[is.log] <- with(sensitivity, comp.sens * abs(log10(value)))[is.log] sensitivity$rel.comp.sens <- rel -save(sensitivity, file = file.path(dir.dat, "sensitivity.rda"), compress = "xz") +save(sensitivity, file = file.path(dir.out, "sensitivity.rda"), compress = "xz") @ <>= @@ -915,13 +927,12 @@ CheckStatus("sensitivity") Cities and towns in the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/cities.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -cities <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +cities <- readOGR(dsn = path, layer = "cities", verbose = FALSE) cities <- spTransform(cities, crs) cities <- cities[cities@data$FEATURE_NA != "Elkhorn Village", ] -save(cities, file = file.path(dir.dat, "cities.rda"), compress = "xz") +save(cities, file = file.path(dir.out, "cities.rda"), compress = "xz") @ <>= @@ -934,15 +945,15 @@ CheckStatus("cities") Map labels in the WRV and surrounding areas. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "decorative/map.labels.csv")) +<>= +file <- file.path(dir.in, "decorative/map.labels.csv") map.labels <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) map.labels$label <- sub("\\\\n", "\\\n", map.labels$label) coordinates(map.labels) <- 1:2 colnames(map.labels@coords) <- c("x", "y") proj4string(map.labels) <- CRS("+init=epsg:4326") map.labels <- spTransform(map.labels, crs) -save(map.labels, file = file.path(dir.dat, "map.labels.rda"), compress = "xz") +save(map.labels, file = file.path(dir.out, "map.labels.rda"), compress = "xz") @ <>= @@ -955,15 +966,15 @@ CheckStatus("map.labels") Miscellaneous locations in the Bellevue triangle area. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "decorative/misc.locations.csv")) +<>= +file <- file.path(dir.in, "decorative/misc.locations.csv") misc.locations <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) misc.locations$label <- sub("\\\\n", "\\\n", misc.locations$label) coordinates(misc.locations) <- 1:2 colnames(misc.locations@coords) <- c("x", "y") proj4string(misc.locations) <- CRS("+init=epsg:4326") misc.locations <- spTransform(misc.locations, crs) -save(misc.locations, file = file.path(dir.dat, "misc.locations.rda"), compress = "xz") +save(misc.locations, file = file.path(dir.out, "misc.locations.rda"), compress = "xz") @ <>= @@ -978,8 +989,8 @@ CheckStatus("misc.locations") Weather stations in the WRV and surrounding areas. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "precip/weather.stations.csv")) +<>= +file <- file.path(dir.in, "precip/weather.stations.csv") weather.stations <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) weather.stations$elevation <- weather.stations$elevation_ft * ft.to.m weather.stations$elevation_ft <- NULL @@ -988,7 +999,7 @@ coordinates(weather.stations) <- 1:2 colnames(weather.stations@coords) <- c("x", "y") proj4string(weather.stations) <- CRS("+init=epsg:4326") weather.stations <- spTransform(weather.stations, crs) -save(weather.stations, file = file.path(dir.dat, "weather.stations.rda"), compress = "xz") +save(weather.stations, file = file.path(dir.out, "weather.stations.rda"), compress = "xz") @ <>= @@ -1001,10 +1012,9 @@ CheckStatus("weather.stations") Well completions for pumping wells in the WRV aquifer system. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "div/pod.wells.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -pod.wells <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "div") +pod.wells <- readOGR(dsn = path, layer = "pod.wells", verbose = FALSE) pod.wells <- spTransform(pod.wells, crs) d <- pod.wells@data columns <- c("TopOpen1", "BotOpen1", "TopOpen2", "BotOpen2") @@ -1015,7 +1025,7 @@ d[d$TopOpen2 == 0 | d$BotOpen2 == 0, c("TopOpen2", "BotOpen2")] <- NA \noindent A missing well completion is assumed identical to the completion of its nearest-neighbor well. -<>= +<>= is.pred <- is.na(d$TopOpen1) dists <- as.matrix(dist(coordinates(pod.wells))) dists <- dists[!is.pred & d$WellUse %in% "Irrigation", ] @@ -1024,7 +1034,7 @@ d$TopOpen1[is.pred] <- d$TopOpen1[nearest.well[is.pred]] d$BotOpen1[is.pred] <- d$BotOpen1[nearest.well[is.pred]] columns <- c("WMISNumber", "WellUse", "TopOpen1", "BotOpen1", "TopOpen2", "BotOpen2") pod.wells@data <- d[, columns] -save(pod.wells, file = file.path(dir.dat, "pod.wells.rda"), compress = "xz") +save(pod.wells, file = file.path(dir.out, "pod.wells.rda"), compress = "xz") @ \noindent There are a total of \Sexpr{format(nrow(d), big.mark=",")} pumping wells; @@ -1037,9 +1047,9 @@ v <- c(paste("Map showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nchar( @ <>= -wrv::PlotMap(crs, xlim=usr.map[1:2], ylim=usr.map[3:4], bg.image=wrv::hill.shading, - dms.tick=TRUE, bg.image.alpha=0.6, rivers=list(x=wrv::streams.rivers), - lakes=list(x=wrv::lakes), credit=credit) +inlmisc::PlotMap(crs, xlim=usr.map[1:2], ylim=usr.map[3:4], bg.image=wrv::hill.shading, + dms.tick=TRUE, bg.image.alpha=0.6, rivers=list(x=wrv::streams.rivers), + lakes=list(x=wrv::lakes), credit=credit) plot(wrv::alluvium.extent, border="#FFFFFFCC", add=TRUE) cols <- c("#9061C2D9", "#FBB829D9") pchs <- c(24, 21) @@ -1051,7 +1061,6 @@ text(wrv::cities, labels=wrv::cities@data$FEATURE_NA, col="#333333", cex=0.5, po leg <- paste(c("Estimated", "Measured"), "well completion") legend("topright", leg, col=NA, pt.bg=cols, pch=pchs, pt.cex=pt.cexs, pt.lwd=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ <>= @@ -1064,12 +1073,11 @@ CheckStatus("pod.wells") Select streamgages in the WRV. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "gage/streamgages.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -streamgages <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "gage") +streamgages <- readOGR(dsn = path, layer = "streamgages", verbose = FALSE) streamgages <- spTransform(streamgages, crs) -save(streamgages, file = file.path(dir.dat, "streamgages.rda"), compress = "xz") +save(streamgages, file = file.path(dir.out, "streamgages.rda"), compress = "xz") @ <>= @@ -1084,10 +1092,9 @@ CheckStatus("streamgages") Observation wells in the WRV. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/obs.wells.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -obs.wells <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE, +<>= +path <- file.path(dir.in, "opt") +obs.wells <- readOGR(dsn = path, layer = "obs.wells", verbose = FALSE, stringsAsFactors = FALSE) obs.wells <- spTransform(obs.wells, crs) d <- obs.wells@data @@ -1104,7 +1111,7 @@ d$BotOpen2 <- NA \noindent A missing well completion is assumed identical to the completion of its nearest-neighbor well. -<<>>= +<>= is.pred <- is.na(d$TopOpen1) dists <- as.matrix(dist(coordinates(obs.wells)))[!is.pred, ] nearest.well <- as.integer(apply(dists, 2, function(i) names(which.min(i)))) @@ -1119,8 +1126,8 @@ are missing well completions. Well completion depths are not relevant in the northern portion of the model area where only model layer 1 is active. Well completion data were not compiled for this area. -<<>>= -save(obs.wells, file = file.path(dir.dat, "obs.wells.rda"), compress = "xz") +<>= +save(obs.wells, file = file.path(dir.out, "obs.wells.rda"), compress = "xz") @ <>= @@ -1133,10 +1140,9 @@ CheckStatus("obs.wells") A Wood River Valley stream seepage study with streamflow measurements made during the months of August 2012, October 2012, and March 2013. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/seepage.study.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -seepage.study <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "opt") +seepage.study <- readOGR(dsn = path, layer = "seepage.study", verbose = FALSE) seepage.study <- spTransform(seepage.study, crs) d <- seepage.study@data d$Aug <- d$Aug_cfs * cfs.to.m3.per.d @@ -1146,27 +1152,24 @@ d$Aug_cfs <- NULL d$Oct_cfs <- NULL d$Mar_cfs <- NULL seepage.study@data <- d -save(seepage.study, file = file.path(dir.dat, "seepage.study.rda"), compress = "xz") +save(seepage.study, file = file.path(dir.out, "seepage.study.rda"), compress = "xz") @ <>= CheckStatus("seepage.study") @ -\newpage - % ========================================================================= \subsubsection{Diversions, returns, and exchange wells (div.ret.exch)} Location of streamflow diversions, irrigation canal or pond returns, and exchange well returns. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/div.ret.exch.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -div.ret.exch <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "opt") +div.ret.exch <- readOGR(dsn = path, layer = "div.ret.exch", verbose = FALSE) div.ret.exch <- spTransform(div.ret.exch, crs) -save(div.ret.exch, file = file.path(dir.dat, "div.ret.exch.rda"), compress = "xz") +save(div.ret.exch, file = file.path(dir.out, "div.ret.exch.rda"), compress = "xz") @ <>= @@ -1179,12 +1182,11 @@ CheckStatus("div.ret.exch") Location of pilot points in the model domain. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/pilot.points.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -pilot.points <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "opt") +pilot.points <- readOGR(dsn = path, layer = "pilot.points", verbose = FALSE) pilot.points <- spTransform(pilot.points, crs) -save(pilot.points, file = file.path(dir.dat, "pilot.points.rda"), compress = "xz") +save(pilot.points, file = file.path(dir.out, "pilot.points.rda"), compress = "xz") @ <>= @@ -1201,14 +1203,13 @@ CheckStatus("pilot.points") Canal systems in the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "canal/canals.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -canals <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "canal") +canals <- readOGR(dsn = path, layer = "canals", verbose = FALSE) canals <- spTransform(canals, crs) canals@data$Name <- as.character(canals@data$NAME) canals@data <- canals@data[, c("EntityName", "Name")] -save(canals, file = file.path(dir.dat, "canals.rda"), compress = "xz") +save(canals, file = file.path(dir.out, "canals.rda"), compress = "xz") @ <>= @@ -1221,10 +1222,8 @@ CheckStatus("canals") Stream reaches of the Big Wood River and Silver Creek. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "river.reaches.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -river.reaches <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +river.reaches <- readOGR(dsn = dir.in, layer = "river.reaches", verbose = FALSE) river.reaches <- spTransform(river.reaches, crs) d <- river.reaches@data d$RchAvg <- d$RchAvg_cfs * cfs.to.m3.per.d @@ -1234,27 +1233,24 @@ d$BedThk <- d$BedThk_ft * ft.to.m columns <- c("Reach", "BigReach", "DrainRiver", "RchAvg", "BigRAv", "ReachNo", "Depth", "BedThk") river.reaches@data <- d[, columns] -save(river.reaches, file = file.path(dir.dat, "river.reaches.rda"), compress = "xz") +save(river.reaches, file = file.path(dir.out, "river.reaches.rda"), compress = "xz") @ <>= CheckStatus("river.reaches") @ -\newpage - % ========================================================================= \subsubsection{Streams and rivers (streams.rivers)} Streams and rivers of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/rivers.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -streams.rivers <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +streams.rivers <- readOGR(dsn = path, layer = "rivers", verbose = FALSE) streams.rivers <- spTransform(streams.rivers, crs) -save(streams.rivers, file = file.path(dir.dat, "streams.rivers.rda"), compress = "xz") +save(streams.rivers, file = file.path(dir.out, "streams.rivers.rda"), compress = "xz") @ <>= @@ -1267,12 +1263,11 @@ CheckStatus("streams.rivers") Tributary streams of the upper WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/tributary.streams.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -tributary.streams <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +tributary.streams <- readOGR(dsn = path, layer = "tributary.streams", verbose = FALSE) tributary.streams <- spTransform(tributary.streams, crs) -save(tributary.streams, file = file.path(dir.dat, "tributary.streams.rda"), +save(tributary.streams, file = file.path(dir.out, "tributary.streams.rda"), compress = "xz") @ @@ -1286,13 +1281,12 @@ CheckStatus("tributary.streams") The location of the Bypass Canal. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "canal/bypass.canal.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -bypass.canal <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "canal") +bypass.canal <- readOGR(dsn = path, layer = "bypass.canal", verbose = FALSE) bypass.canal <- spTransform(bypass.canal, crs) bypass.canal <- as(bypass.canal, "SpatialLines") -save(bypass.canal, file = file.path(dir.dat, "bypass.canal.rda"), compress = "xz") +save(bypass.canal, file = file.path(dir.out, "bypass.canal.rda"), compress = "xz") @ <>= @@ -1305,13 +1299,11 @@ CheckStatus("bypass.canal") Groundwater-level contours for the unconfined aquifer in the Wood River Valley, south-central Idaho, representing conditions during October 2006. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "wl.200610.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -wl.200610 <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +wl.200610 <- readOGR(dsn = dir.in, layer = "wl.200610", verbose = FALSE) wl.200610 <- spTransform(wl.200610, crs) wl.200610@data$CONTOUR <- wl.200610@data$CONTOUR * ft.to.m -save(wl.200610, file = file.path(dir.dat, "wl.200610.rda"), compress = "xz") +save(wl.200610, file = file.path(dir.out, "wl.200610.rda"), compress = "xz") @ <>= @@ -1324,12 +1316,11 @@ CheckStatus("wl.200610") Major roads in the Wood River Valley and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/major.roads.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -major.roads <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +major.roads <- readOGR(dsn = path, layer = "major.roads", verbose = FALSE) major.roads <- spTransform(major.roads, crs) -save(major.roads, file = file.path(dir.dat, "major.roads.rda"), compress = "xz") +save(major.roads, file = file.path(dir.out, "major.roads.rda"), compress = "xz") @ <>= @@ -1346,12 +1337,11 @@ CheckStatus("major.roads") The estimated extent of the WRV aquifer system. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "extent/alluvium.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -alluvium.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "extent") +alluvium.extent <- readOGR(dsn = path, layer = "alluvium.extent", verbose = FALSE) alluvium.extent <- spTransform(alluvium.extent, crs) -save(alluvium.extent, file = file.path(dir.dat, "alluvium.extent.rda"), compress = "xz") +save(alluvium.extent, file = file.path(dir.out, "alluvium.extent.rda"), compress = "xz") @ <>= @@ -1364,12 +1354,11 @@ CheckStatus("alluvium.extent") The estimated extent of the confining hydrogeologic clay unit (aquitard) separating the unconfined aquifer from the underlying confined aquifer in the WRV. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "extent/clay.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -clay.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "extent") +clay.extent <- readOGR(dsn = path, layer = "clay.extent", verbose = FALSE) clay.extent <- spTransform(clay.extent, crs) -save(clay.extent, file = file.path(dir.dat, "clay.extent.rda"), compress = "xz") +save(clay.extent, file = file.path(dir.out, "clay.extent.rda"), compress = "xz") @ <>= @@ -1382,12 +1371,11 @@ CheckStatus("clay.extent") The estimated extent of the basalt hydrogeologic unit underlying the alluvial WRV aquifer system. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "extent/basalt.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -basalt.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "extent") +basalt.extent <- readOGR(dsn = path, layer = "basalt.extent", verbose = FALSE) basalt.extent <- spTransform(basalt.extent, crs) -save(basalt.extent, file = file.path(dir.dat, "basalt.extent.rda"), compress = "xz") +save(basalt.extent, file = file.path(dir.out, "basalt.extent.rda"), compress = "xz") @ <>= @@ -1401,24 +1389,22 @@ CheckStatus("basalt.extent") Polygons used to define the location of drain boundary conditions in the model domain. The polygons clip the line segments along the aquifer boundary (see alluvium.extent), and model cells intersecting these clipped-line segments are defined as boundary cells. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "drains.kml")) +<>= +file <- file.path(dir.in, "drains.kml") p <- suppressWarnings(readOGR(file, basename(file), verbose = FALSE)) p@data$Description <- NULL -file <- wrv::DownloadFile(paste0(url.git, "drains.csv")) +file <- file.path(dir.in, "drains.csv") d <- read.csv(file, strip.white = TRUE) p@data <- dplyr::left_join(p@data, d, by = "Name") p <- spTransform(p, crs) drains <- p -save(drains, file = file.path(dir.dat, "drains.rda"), compress = "xz") +save(drains, file = file.path(dir.out, "drains.rda"), compress = "xz") @ <>= CheckStatus("drains") @ -\newpage - % ========================================================================= \subsubsection{Tributary basin underflow (tributaries)} @@ -1426,8 +1412,8 @@ CheckStatus("drains") Data that describe the location and average flow conditions for model boundaries in the major tributary canyons of the WRV. Spatial polygons are used to define the boundary locations in the study area. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "tributaries.kml")) +<>= +file <- file.path(dir.in, "tributaries.kml") p <- suppressWarnings(readOGR(file, basename(file), verbose = FALSE)) p <- spTransform(p, crs) p@data$Description <- NULL @@ -1436,8 +1422,8 @@ p@data$Description <- NULL \noindent For each tributary canyon, the mean rate of tributary basin underflow is first estimated using a \href{http://en.wikipedia.org/wiki/Darcy_law}{Darcian} analysis. The lower-half of an ellipse is used to describe the geometry of the saturated cross-sectional area. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "tributaries.csv")) +<>= +file <- file.path(dir.in, "tributaries.csv") d <- read.csv(file, strip.white = TRUE) names(d) <- sub("_m$", "", names(d)) d$K <- d$K_ft.per.d * ft.to.m @@ -1451,7 +1437,7 @@ Smaller basins were identified by plotting basin areas for each tributary canyon A natural break was found at about 26 square-kilometers (10 square-miles) and tributary basins less than this break were designated as ``small'', and all others were designated as ``big''. -<<>>= +<>= d$BasinArea <- d$BasinArea_mi2 * mi2.to.m2 d$BasinArea_mi2 <- NULL natural.basin.area.break <- 2.59e+7 # 10 square-miles @@ -1461,7 +1447,7 @@ d$BasinAreaType <- as.factor(c("big", "small")[is.small + 1L]) \noindent Multiplying a basin's average rate of precipitation by its drainage area gives a secondary estimate of the mean volumetric flow rate at the boundary. -<<>>= +<>= d$PrecipRate <- d$PrecipRate_in.per.yr * in.per.y.to.m.per.d d$PrecipRate_in.per.yr <- NULL d$PrecipFlow <- d$BasinArea * d$PrecipRate @@ -1469,31 +1455,31 @@ d$PrecipFlow <- d$BasinArea * d$PrecipRate \noindent The ratio of Darcy to precipitation volumetric flow rate estimates is then calculated. -<<>>= +<>= d$FlowRatio <- d$DarcyFlow / d$PrecipFlow @ +\newpage + \noindent Finally, the mean volumetric flow rate of a small tributary canyon is calculated by multiplying its precipitation flow rate estimate by the average flow rate ratio for the larger tributary canyons. -<<>>= +<>= d$Flow <- d$DarcyFlow d$Flow[is.small] <- d$PrecipFlow[is.small] * mean(d$FlowRatio[!is.small]) @ \noindent Save the dataset to disk: -<<>>= +<>= p@data <- dplyr::left_join(p@data, d, by = "Name") tributaries <- p -save(tributaries, file = file.path(dir.dat, "tributaries.rda"), compress = "xz") +save(tributaries, file = file.path(dir.out, "tributaries.rda"), compress = "xz") @ <>= CheckStatus("tributaries") @ -\newpage - % ========================================================================= \subsubsection{Precipitation zones (precip.zones)} @@ -1501,7 +1487,7 @@ CheckStatus("tributaries") Precipitation zones of the WRV and surrounding areas. Northing coordinate of zone separators is based on the northing midpoint between weather stations. -<<>>= +<>= ids <- c("Ketchum", "Hailey", "Picabo") y <- coordinates(weather.stations)[match(rev(ids), weather.stations@data$id), "y"] s <- c(mean(y[1:2]), mean(y[2:3])) # northing zone separators @@ -1515,7 +1501,7 @@ p3 <- Polygons(list(Polygon(rbind(p3, p3[1, ]))), ID = 3) p <- SpatialPolygons(list(p1, p2, p3), proj4string = crs) p <- SpatialPolygonsDataFrame(p, data.frame(ID = 1:3, PrecipZone = ids)) precip.zones <- p -save(precip.zones, file = file.path(dir.dat, "precip.zones.rda"), compress = "xz") +save(precip.zones, file = file.path(dir.out, "precip.zones.rda"), compress = "xz") @ <>= @@ -1528,37 +1514,37 @@ CheckStatus("precip.zones") Irrigation entities of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "irr/irr.entities.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -irr.entities <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "irr") +irr.entities <- readOGR(dsn = path, layer = "irr.entities", verbose = FALSE) irr.entities <- spTransform(irr.entities, crs) irr.entities <- rgeos::gBuffer(irr.entities, width = 0, byid = TRUE) d <- irr.entities@data d$EntitySrce <- as.factor(paste(d$EntityName, d$Source)) d$PrecipZone <- over(rgeos::gCentroid(irr.entities, byid = TRUE), precip.zones)$PrecipZone irr.entities@data <- d[, c("EntityName", "Source", "EntitySrce", "PrecipZone")] -save(irr.entities, file = file.path(dir.dat, "irr.entities.rda"), compress = "xz") +save(irr.entities, file = file.path(dir.out, "irr.entities.rda"), compress = "xz") @ <>= CheckStatus("irr.entities") @ +\newpage + % ========================================================================= \subsubsection{Irrigation lands (irr.lands)} Irrigated and semi-irrigated lands of the WRV. -<<>>= +<>= +path <- file.path(dir.in, "irr") yr <- c(1996, 2000, 2002, 2006, 2008, 2009, 2010) -urls <- paste0(url.git, "irr/irr.lands.", yr, ".zip") +files <- paste0("irr.lands.", yr) irr.lands <- list() -for (i in seq_along(urls)) { - files <- wrv::DownloadFile(urls[i]) - layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) - p <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +for (i in seq_along(files)) { + p <- readOGR(dsn = path, layer = files[i], verbose = FALSE) p <- spTransform(p, crs) p@data <- p@data[, paste0("STATUS_", substr(yr[i], 1, 3)), drop = FALSE] names(p@data) <- "Status" @@ -1568,7 +1554,7 @@ for (i in seq_along(urls)) { irr.lands[[i]] <- p } names(irr.lands) <- as.character(yr) -save(irr.lands, file = file.path(dir.dat, "irr.lands.rda"), compress = "xz") +save(irr.lands, file = file.path(dir.out, "irr.lands.rda"), compress = "xz") @ <>= @@ -1581,12 +1567,11 @@ CheckStatus("irr.lands") Lakes and reservoirs of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/lakes.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -lakes <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +lakes <- readOGR(dsn = path, layer = "lakes", verbose = FALSE) lakes <- spTransform(lakes, crs) -save(lakes, file = file.path(dir.dat, "lakes.rda"), compress = "xz") +save(lakes, file = file.path(dir.out, "lakes.rda"), compress = "xz") @ <>= @@ -1599,13 +1584,11 @@ CheckStatus("lakes") Non-irrigated public land parcels for areas north of Bellevue. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "public.parcels.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -public.parcels <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +public.parcels <- readOGR(dsn = dir.in, layer = "public.parcels", verbose = FALSE) public.parcels <- spTransform(public.parcels, crs) public.parcels <- as(public.parcels, "SpatialPolygons") -save(public.parcels, file = file.path(dir.dat, "public.parcels.rda"), compress = "xz") +save(public.parcels, file = file.path(dir.out, "public.parcels.rda"), compress = "xz") @ <>= @@ -1618,14 +1601,12 @@ CheckStatus("public.parcels") Soil units of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "soils.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -soils <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +soils <- readOGR(dsn = dir.in, layer = "soils", verbose = FALSE) soils <- spTransform(soils, crs) soils@data <- soils@data[, c("GroupSym", "SoilLayer")] names(soils@data)[1] <- "GroupSymbol" -file <- wrv::DownloadFile(paste0(url.git, "soils.csv")) +file <- file.path(dir.in, "soils.csv") d <- read.csv(file, strip.white = TRUE) d$MinRate <- d$MinRate_ft.per.mo * ft.to.m d$MaxRate <- d$MaxRate_ft.per.mo * ft.to.m @@ -1635,7 +1616,7 @@ d <- suppressWarnings(dplyr::left_join(soils@data, d, by = "GroupSymbol")) d$GroupSymbol <- as.factor(d$GroupSymbol) d$PercolationRate[is.na(d$PercolationRate)] <- 0 soils@data <- d -save(soils, file = file.path(dir.dat, "soils.rda"), compress = "xz") +save(soils, file = file.path(dir.out, "soils.rda"), compress = "xz") @ <>= @@ -1648,34 +1629,29 @@ CheckStatus("soils") Wetlands of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "wetlands.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -wetlands <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +wetlands <- readOGR(dsn = dir.in, layer = "wetlands", verbose = FALSE) wetlands <- spTransform(wetlands, crs) wetlands <- as(wetlands, "SpatialPolygons") -save(wetlands, file = file.path(dir.dat, "wetlands.rda"), compress = "xz") +save(wetlands, file = file.path(dir.out, "wetlands.rda"), compress = "xz") @ <>= CheckStatus("wetlands") @ -\newpage - % ========================================================================= \subsubsection{Bellevue WWTP ponds (bellevue.wwtp.ponds)} Bellevue Waste Water Treatment Plant ponds. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "bellevue.wwtp.ponds.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -bellevue.wwtp.ponds <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +bellevue.wwtp.ponds <- readOGR(dsn = dir.in, layer = "bellevue.wwtp.ponds", + verbose = FALSE) bellevue.wwtp.ponds <- spTransform(bellevue.wwtp.ponds, crs) bellevue.wwtp.ponds <- as(bellevue.wwtp.ponds, "SpatialPolygons") -save(bellevue.wwtp.ponds, file = file.path(dir.dat, "bellevue.wwtp.ponds.rda"), +save(bellevue.wwtp.ponds, file = file.path(dir.out, "bellevue.wwtp.ponds.rda"), compress = "xz") @ @@ -1689,12 +1665,11 @@ CheckStatus("bellevue.wwtp.ponds") Kriging zones used in parameter estimation. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/kriging.zones.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -kriging.zones <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "opt") +kriging.zones <- readOGR(dsn = path, layer = "kriging.zones", verbose = FALSE) kriging.zones <- spTransform(kriging.zones, crs) -save(kriging.zones, file = file.path(dir.dat, "kriging.zones.rda"), compress = "xz") +save(kriging.zones, file = file.path(dir.out, "kriging.zones.rda"), compress = "xz") @ <>= @@ -1707,13 +1682,12 @@ CheckStatus("kriging.zones") Boundary of the U.S. state of Idaho. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/idaho.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -idaho <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +idaho <- readOGR(dsn = path, layer = "idaho", verbose = FALSE) idaho <- as(idaho, "SpatialPolygons") idaho <- spTransform(idaho, crs) -save(idaho, file = file.path(dir.dat, "idaho.rda"), compress = "xz") +save(idaho, file = file.path(dir.out, "idaho.rda"), compress = "xz") @ <>= @@ -1724,26 +1698,19 @@ CheckStatus("idaho") \subsection{Grids} -Raster data are available at a higher resolution (smaller cells) than the resolution of the model grid. -Projecting the raster data into the model grid first requires the projection of raster data into a high resolution spatial grid of comparable cell size. -The high resolution spatial grid is defined using a constant cell size of 20 meters by 20 meters. -<<>>= -high.res.spatial.grid <- disaggregate(spatial.grid, fact = 5L) -@ - % ========================================================================= \subsubsection{Thickness of the quaternary sediment (alluvium.thickness)} The estimated thickness of the Quaternary sediment in the WRV aquifer system. -<>= -file <- wrv::DownloadFile(paste0(url.git, "alluvium.thickness.tif")) +<>= +file <- file.path(dir.in, "alluvium.thickness.tif") alluvium.thickness <- readGDAL(file, band = 1, silent = TRUE) alluvium.thickness <- projectRaster(raster(alluvium.thickness), high.res.spatial.grid) alluvium.thickness <- aggregate(alluvium.thickness, fact = 5L, fun = median) names(alluvium.thickness) <- "alluvium.thickness" -save(alluvium.thickness, file = file.path(dir.dat, "alluvium.thickness.rda"), +save(alluvium.thickness, file = file.path(dir.out, "alluvium.thickness.rda"), compress = "xz") @ @@ -1759,15 +1726,14 @@ CheckStatus("alluvium.thickness") The topography of the land surface in the WRV and vicinity. -<>= -wrv::DownloadFile(ftp.ned) -file <- file.path(tempdir(), "grdn44w115_13") -r <- raster(readGDAL(file, band = 1, silent = TRUE)) +<>= +path <- file.path(dir.in, "grdn44w115_13") +r <- raster(readGDAL(path, band = 1, silent = TRUE)) land.surface <- projectRaster(r, high.res.spatial.grid) land.surface <- aggregate(land.surface, fact = 5L, fun = median) land.surface[is.na(alluvium.thickness)] <- NA names(land.surface) <- "land.surface" -save(land.surface, file = file.path(dir.dat, "land.surface.rda"), compress = "xz") +save(land.surface, file = file.path(dir.out, "land.surface.rda"), compress = "xz") @ <>= @@ -1776,7 +1742,7 @@ CheckStatus("land.surface") \noindent Hillshading based on the slope and aspect of land-surface elevations. -<>= +<>= ext <- extent(spatial.grid) ext <- extent(c(extendrange(c(ext@xmin, ext@xmax), f = 0.05), extendrange(c(ext@ymin, ext@ymax), f = 0.05))) @@ -1789,7 +1755,7 @@ r.range <- range(r[], na.rm = TRUE) r[] <- findInterval(r[], seq(r.range[1], r.range[2], length.out = 255)) / 255 r[] <- round(r[], digits = 6) hill.shading <- r -save(hill.shading, file = file.path(dir.dat, "hill.shading.rda"), compress = "xz") +save(hill.shading, file = file.path(dir.out, "hill.shading.rda"), compress = "xz") @ <>= @@ -1803,21 +1769,20 @@ rm(hill.shading) Average monthly evapotranspiration in the WRV and surrounding areas. -<<>>= -urls <- paste0(url.git, "et/et.", yr.mo, ".tif") +<>= +files <- file.path(dir.in, "et", paste0("et.", yr.mo, ".tif")) FUN <- function(i) { - file <- wrv::DownloadFile(urls[i]) - r <- readGDAL(file, band = 1, silent = TRUE) + r <- readGDAL(files[i], band = 1, silent = TRUE) r[[1]] <- r[[1]] * mm.to.m return(r) } -et.raw <- lapply(seq_along(urls), FUN) +et.raw <- lapply(seq_along(files), FUN) names(et.raw) <- as.character(yr.mo) @ \noindent Project the raster data into the model grid, and place an upper and lower limit on evapotranspiration that is 3 standard deviations from the mean value. -<<>>= +<>= is.missing <- is.na(alluvium.thickness) FUN <- function(i) { r <- aggregate(projectRaster(raster(i), high.res.spatial.grid), fact = 5L) @@ -1828,7 +1793,7 @@ FUN <- function(i) { } et <- stack(lapply(et.raw, FUN), quick = TRUE) names(et) <- as.character(yr.mo) -save(et, file = file.path(dir.dat, "et.rda"), compress = "xz") +save(et, file = file.path(dir.out, "et.rda"), compress = "xz") @ <>= @@ -1856,11 +1821,11 @@ An irrigation entity is defined as an area served by a group of surface-water an Start with the spatial polygon representing the irrigated lands and remove those areas that are designated as wetlands or public parcels. Intersect the resulting polygon with the irrigation entities and calculate the area for each entity. -<<>>= +<>= p <- irr.lands -p <- lapply(p, function(i) wrv::SetPolygons(i, wetlands, "gDifference", 0.001)) -p <- lapply(p, function(i) wrv::SetPolygons(i, public.parcels, "gDifference", 0.001)) -p <- lapply(p, function(i) wrv::SetPolygons(irr.entities, i, "gIntersection", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(i, wetlands, "gDifference", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(i, public.parcels, "gDifference", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(irr.entities, i, "gIntersection", 0.001)) for (i in seq_along(p)) p[[i]]@data$area <- rgeos::gArea(p[[i]], byid = TRUE) irr.by.entity <- p @ @@ -1872,7 +1837,7 @@ rm(list=c("irr.lands", "wetlands", "public.parcels")) \noindent Irrigation entities are subdivided by water source; that is, ``surface-water only'', ``groundwater only'', or ``mixed source''. Aggregate irrigation entities by water source and calculate their area. -<<>>= +<>= FUN <- function(i) { d <- aggregate(i@data$area, by = list(i@data$EntitySrce), sum, na.rm = TRUE) names(d) <- c("EntitySrce", "area") @@ -1883,11 +1848,9 @@ FUN <- function(i) { area.by.entity <- lapply(irr.by.entity, FUN) @ -\newpage - \noindent Calculate the volumetric components of evapotranspiration, precipitation, and crop irrigation requirement for each irrigation entity and water source. -<<>>= +<>= FUN <- function(i) { yr <- irr.lands.year$IL_Year[irr.lands.year$Year %in% substr(i, 1, 4)] p <- irr.by.entity[[yr]] @@ -1916,7 +1879,7 @@ FUN <- function(i) { } entity.components <- lapply(yr.mo, FUN) names(entity.components) <- yr.mo -save(entity.components, file = file.path(dir.dat, "entity.components.rda"), +save(entity.components, file = file.path(dir.out, "entity.components.rda"), compress = "xz") @ @@ -1935,29 +1898,27 @@ rm(et.raw) Rasterize canals on model grid. -<<>>= +<>= r <- rasterize(canals, land.surface, "EntityName", silent = TRUE) r <- ratify(r, count = TRUE) d <- levels(r)[[1]] d$EntityName <- levels(canals@data$EntityName)[d$ID] levels(r) <- d r.canals <- r -save(r.canals, file = file.path(dir.dat, "r.canals.rda"), compress = "xz") +save(r.canals, file = file.path(dir.out, "r.canals.rda"), compress = "xz") @ <>= CheckStatus("r.canals") @ -\newpage - % ========================================================================= \subsubsection{Rasterized monthly irrigation entities (rs.entities)} Rasterize monthly irrigation entities on model grid. -<<>>= +<>= FUN <- function(i) { r <- rasterize(entity.components[[i]], land.surface, "EntityName", silent = TRUE) r <- ratify(r, count = TRUE) @@ -1968,20 +1929,22 @@ FUN <- function(i) { } rs.entities <- stack(lapply(yr.mo, FUN), quick = TRUE) names(rs.entities) <- yr.mo -save(rs.entities, file = file.path(dir.dat, "rs.entities.rda"), compress = "xz") +save(rs.entities, file = file.path(dir.out, "rs.entities.rda"), compress = "xz") @ <>= CheckStatus("rs.entities") @ +\newpage + % ========================================================================= \subsubsection{Rasterized monthly recharge on non-irrigated lands (rs.rech.non.irr)} Calculate rasterized monthly volumetric flow rates of areal recharge beneath non-irrigated lands. -<<>>= +<>= r.zones <- ratify(rasterize(precip.zones, land.surface, "ID", silent = TRUE)) levels(r.zones) <- cbind(levels(r.zones)[[1]], att = precip.zones@data$PrecipZone) r.soils <- rasterize(soils, land.surface, "PercolationRate", silent = TRUE) @@ -2002,7 +1965,7 @@ FUN <- function(i) { } rs.rech.non.irr <- stack(lapply(yr.mo, FUN), quick = TRUE) names(rs.rech.non.irr) <- yr.mo -save(rs.rech.non.irr, file = file.path(dir.dat, "rs.rech.non.irr.rda"), compress = "xz") +save(rs.rech.non.irr, file = file.path(dir.out, "rs.rech.non.irr.rda"), compress = "xz") @ <>= diff --git a/inst/doc/sir20165080_AppendixD.R b/inst/doc/sir20165080_AppendixD.R index fba9406..0af4dfe 100644 --- a/inst/doc/sir20165080_AppendixD.R +++ b/inst/doc/sir20165080_AppendixD.R @@ -3,8 +3,6 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) options(preferRaster=TRUE, scipen=0, digits=2) -loadNamespace("xtable") -loadNamespace("sfsmisc") # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -79,7 +77,9 @@ FmtFlow <- function(x, u=c("m\\textsuperscript{3}/d", "acre-ft/yr"), conv=m3.per } ## ----warning=FALSE, message=FALSE, results="hide"------------------------ -library("wrv") +library("wrv") # processor for groundwater-flow model +library("raster") # gridded spatial data toolkit +library("inlmisc") # miscellaneous functions for the USGS INL project office ## ----results="hide"------------------------------------------------------ getwd() @@ -102,7 +102,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) ## ------------------------------------------------------------------------ r <- rs.data[["land.surface"]] - rs.data[["alluvium.thickness"]] @@ -143,9 +142,8 @@ text(misc.locations, labels=misc.locations@data$label, pos=c(3, 2, 2), cex=0.5, offset=0.3) legend("topright", "Basalt unit", fill=col, border=NA, inset=c(0.02, 0.55), cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0, -9)), - sub.label=list("Map area", adj=c(1.9, 0.5)), loc="topright") -invisible(dev.off()) +AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0.25, -9)), + sub.label=list("Map area", adj=c(1.65, 0.5)), loc="topright") ## ------------------------------------------------------------------------ depth.to.basalt.bottom <- 52 # in meters @@ -168,7 +166,6 @@ PlotMap(r, breaks=pretty(range(r[], na.rm=TRUE), n=12), xlim=usr.map.s[1:2], yli rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) ## ------------------------------------------------------------------------ r <- raster(rs.data) @@ -190,7 +187,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) legend("topright", "Clay confining unit", fill=col, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) ## ------------------------------------------------------------------------ aquitard.thickness <- 5 # in meters @@ -223,7 +219,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=range(pretty(r[])), rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) ## ------------------------------------------------------------------------ l <- rgeos::gIntersection(as(tributaries, "SpatialLinesDataFrame"), alluvium.extent, TRUE) @@ -259,7 +254,6 @@ text(getSpatialLinesMidPoints(trib.lines), labels=rownames(trib.lines@data), leg <- as.character(levels(r)[[1]]$att) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Schematic cross-section representation of (\\textit{\\textbf{A}}) hydrogeologic units and (\\textit{\\textbf{B}}) the layered model grid. \\label{fig:cs_schematic}" @@ -313,7 +307,7 @@ dz2 <- as.numeric(na.omit(rs.model[["lay1.bot"]][] - rs.model[["lay2.bot"]][])) dz3 <- as.numeric(na.omit(rs.model[["lay2.bot"]][] - rs.model[["lay3.bot"]][])) cell.area <- xres(rs.model) * yres(rs.model) -## ------------------------------------------------------------------------ +## ----model_grid---------------------------------------------------------- rs.model <- stack(crop(rs.model, extent(trim(rs.model[["lay1.top"]])))) ## ----table_model_structure, echo=FALSE, results="asis"------------------- @@ -375,7 +369,7 @@ rs.model[["lay3.zones"]] <- r ## ----echo=FALSE---------------------------------------------------------- transect <- SpatialLines(list(Lines(list(Line(transect.coords)), ID="Transect")), - proj4string=CRS("+proj=longlat +datum=WGS84")) + proj4string=CRS("+init=epsg:4326")) transect <- spTransform(transect, crs(hill.shading)) verticies <- as(transect, "SpatialPoints") transect.ends <- verticies[c(1, length(verticies)), ] @@ -408,7 +402,6 @@ FUN("lay2.zones") ## ----map_zones_c, echo=FALSE, results="asis", fig.width=fin.map.0[1], fig.height=fin.map.0[2]---- FUN("lay3.zones") -invisible(dev.off()) ## ----cs_zones, echo=FALSE, fig.width=fin.cs.0[1], fig.height=fin.cs.0[2], fig.cap="{Vertical cross-section of hydrogeologic zones along transect line A--A' shown in \\hyperref[fig:map_zones]{figure~\\ref{fig:map_zones}}.}"---- geo.lays <- c("lay1.top", paste0("lay", 1:3, ".bot")) @@ -420,7 +413,6 @@ PlotCrossSection(transect, rs.model, geo.lays, val.lays, asp=80, col=cols, is.categorical=TRUE, draw.key=FALSE) legend("topright", paste("Zone", 1:4), fill=cols, ncol=1, border=NA, inset=c(0.02, 0), cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) ## ----table_zones, echo=FALSE, results="asis"----------------------------- d <- zone.properties[, c("name", "hk", "vani", "ss", "sy", "sc")] @@ -479,7 +471,6 @@ leg <- format(match(colnames(d)[-1], make.names(tributaries@data$Name))) legend("topright", leg, lwd=1, col=cols, ncol=2, pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD", title=expression(bold("Tributary"))) -invisible(dev.off()) ## ------------------------------------------------------------------------ flow <- cbind(flow, ss = apply(flow[, ss.yr.mo], 1, mean)) @@ -563,7 +554,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=3, offse leg <- as.character(levels(r)[[1]]$Name) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) ## ------------------------------------------------------------------------ cells <- sort(which(!is.na(r[]))) @@ -653,7 +643,6 @@ text(misc.locations, labels=misc.locations@data$label, pos=c(3, 2, 2), cex=0.5, offset=0.3) legend("topright", "Streamgage", pch=17, col="#333333", pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) ## ------------------------------------------------------------------------ rs.model[["riv.stage"]] <- mask(rs.model[["lay1.top"]], rs.model[["riv.reach"]]) @@ -695,7 +684,7 @@ rs.model[["lay3.bot"]][cells] <- rs.model[["lay3.bot"]][cells] - d$diff ## ------------------------------------------------------------------------ d <- gage.height -d <- d[d$Date >= tr.interval[1] & d$Date < tr.interval[2], ] +d <- d[d$Date >= tr.stress.periods[1] & d$Date < tail(tr.stress.periods, 1), ] d <- data.frame(Date = format(d$Date, "%Y%m"), d[, -1], check.names = FALSE) d <- aggregate(d[, -1], by = list(YearMonth = d$Date), mean, na.rm = TRUE) d[, -1] <- apply(d[, -1], 2, function(x) x - median(x, na.rm = TRUE)) @@ -739,7 +728,6 @@ cols <- c("#1B9E77", "#D95F02", "#7570B3") PlotGraph(x, y, ylab=ylab, col=cols, conversion.factor=m.to.ft, center.date.labels=TRUE) legend("topright", colnames(y), lwd=c(1, 1, 1), col=cols, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD", title=expression(bold("Streamgages"))) -invisible(dev.off()) ## ------------------------------------------------------------------------ is.bwr <- river$Reach %in% grep("^Big Wood", levels(river$Reach), value = TRUE) @@ -780,9 +768,16 @@ river <- river[order(river$id, river$lay), ] ## ------------------------------------------------------------------------ river <- cbind(river, ss = apply(river[, ss.yr.mo], 1, mean)) -## ------------------------------------------------------------------------ -l <- RunWaterBalance(tr.stress.periods, rs.model[["lay1.bot"]], efficiency, - canal.seep, ss.stress.periods) +## ----run_water_balance--------------------------------------------------- +l <- RunWaterBalance(rs.model[["lay1.bot"]], tr.stress.periods, + ss.stress.periods, canal.seep = canal.seep, + comb.sw.irr = comb.sw.irr, div.gw = div.gw, + div.sw = div.sw, div.ww = div.ww, efficiency = efficiency, + entity.components = entity.components, et = et, + irr.entities = irr.entities, land.surface = land.surface, + pod.gw = pod.gw, priority.cuts = priority.cuts, + r.canals = r.canals, rs.entities = rs.entities, + rs.rech.non.irr = rs.rech.non.irr) cells <- which(!is.na(l[["areal.rech"]][[1]][])) rc <- rowColFromCell(l[["areal.rech"]], cells) rech <- cbind(lay = 1, row = rc[, 1], col = rc[, 2], l[["areal.rech"]][cells]) @@ -810,7 +805,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) legend("topright", "Pumping well", pch=21, col=NA, pt.bg=col, pt.cex=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Total areal recharge. Values are preliminary and were modified by adjustments to irrigation efficiency during the model-calibration process." @@ -829,7 +823,6 @@ PlotGraph(d, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) legend("topright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Total groundwater withdrawals from production wells in the model domain. Values are preliminary and were modified by adjustments to irrigation efficiency during the model-calibration process." @@ -843,7 +836,6 @@ ylab <- paste("Total withdrawals from wells, in", c("cubic meters per day", "acr col <- "#C80C0B" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Steady-state areal recharge. Values are preliminary and were modified by adjustments to irrigation efficiency during the model-calibration process." @@ -870,7 +862,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=zlim, bg.image=hill.shadin rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) ## ------------------------------------------------------------------------ r <- raster(rs.model) @@ -906,7 +897,6 @@ ylab <- paste("Seepage rate, in", c("cubic meters per day", "acre-feet per year" col <- "#67A9CF" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Seepage beneath the Bellevue Waste Water Treatment Plant Ponds." @@ -921,7 +911,6 @@ ylab <- paste("Seepage rate, in", c("cubic meters per day", "acre-feet per year" col <- "#67A9CF" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=FALSE, center.date.labels=TRUE) -invisible(dev.off()) ## ------------------------------------------------------------------------ misc <- cbind(misc, ss = apply(misc[, ss.yr.mo], 1, mean)) @@ -937,9 +926,9 @@ r <- rs.model[["lay1.strt"]] r[is.na(rs.model[["lay3.bot"]])] <- NA rs.model[["lay3.strt"]] <- r -## ------------------------------------------------------------------------ +## ----write_modflow_input------------------------------------------------- id <- "wrv_mfusg" # model run identifier -dir.run <- file.path(getwd(), "model/model1") +dir.run <- "model/model1" WriteModflowInput(rs.model, rech, well, trib, misc, river, drain, id, dir.run, is.convertible = FALSE, tr.stress.periods = tr.stress.periods, ntime.steps = ntime.steps, verbose = FALSE) @@ -951,7 +940,7 @@ file.exe <- file.path(system.file("bin", arch, package = "wrv"), file) invisible(file.copy(file.exe, dir.run, copy.date = TRUE)) ## ------------------------------------------------------------------------ -file.bat <- file.path(dir.run, "RunModflow.bat") +file.bat <- file.path(getwd(), dir.run, "RunModflow.bat") cmd <- paste(sub("\\.exe$", "", basename(file.exe)), shQuote(paste0(id, ".nam"))) cat(cmd, file = file.bat) Sys.chmod(file.bat, mode = "755") @@ -959,13 +948,13 @@ wd <- setwd(dir.run) system2(file.bat, stdout = FALSE, stderr = FALSE) setwd(wd) -## ------------------------------------------------------------------------ +## ----read_budget_1------------------------------------------------------- file.bud <- file.path(dir.run, paste0(id, ".bud")) budget <- ReadModflowBinary(file.bud, "flow", rm.totim.0 = TRUE) budget <- SummariseBudget(budget) -budget <- dplyr::mutate(budget, totim.date = as.Date(totim, origin = tr.interval[1])) +budget <- dplyr::mutate(budget, totim.date = as.Date(totim, origin = tr.stress.periods[1])) -## ----echo=FALSE---------------------------------------------------------- +## ----read_budget_2, echo=FALSE------------------------------------------- b <- budget[, c("desc", "id", "flow.dir", "totim.date")] b$flow <- budget$flow.sum @@ -979,7 +968,7 @@ d.river <- d d <- b[b$desc == "drains" & b$flow.dir == "out", ] d$id <- as.factor(d$id) -levels(d$id) <- levels(rs.model[["drains"]])[[1]]$Name +levels(d$id) <- drains@data$Name d.drain.1 <- d[d$id == "Stanton Crossing", c("totim.date", "flow")] d.drain.2 <- d[d$id == "Silver Creek", c("totim.date", "flow")] @@ -1003,7 +992,7 @@ v <- "Volumetric water budget components by year, including annual change in sto v <- c(paste("Graph showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nchar(v)))), v) ## ----graph_budget, echo=FALSE, fig.width=fin.graph[1], fig.height=fin.graph[2], fig.scap=sprintf("{%s}", v[1]), fig.cap=sprintf("{%s}", v[2])---- -cols <- format(seq(tr.interval[1], tr.interval[2] - 1, "year"), "%Y") +cols <- format(seq(tr.stress.periods[1], tail(tr.stress.periods, 1) - 1, "year"), "%Y") rows <- c("Areal recharge", "Streamflow losses", "Tributary bain underflow", "Areal discharge", "Streamflow gains", "Well pumping", "Outlet boundaries") m <- matrix(NA, nrow=length(rows), ncol=length(cols), dimnames=list(rows, cols)) @@ -1051,20 +1040,17 @@ idxs <- c(rev(pos.idxs), neg.idxs) legend("topright", rows[idxs], fill=cols[idxs], inset=0.02, cex=cex, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Component"))) box(lwd=0.5) -invisible(dev.off()) ## ----table_budget, echo=FALSE, results="asis"---------------------------- -sdate <- as.Date("1995-01-01", tz="MST") -is.date <- colnames(m) >= format(sdate, "%Y") -flow <- c("Water-table recharge" = as.integer(mean(d.rech$flow.in[is.date])), - "Streamflow losses" = as.integer(mean(d.river$flow.in[is.date])), - "Tributary basin underflow" = as.integer(mean(d.trib$flow[is.date])), +flow <- c("Water-table recharge" = as.integer(mean(d.rech$flow.in)), + "Streamflow losses" = as.integer(mean(d.river$flow.in)), + "Tributary basin underflow" = as.integer(mean(d.trib$flow)), " " = NA, - "Water-table discharge" = as.integer(abs(mean(d.rech$flow.out[is.date]))), - "Streamflow gains" = as.integer(abs(mean(d.river$flow.out[is.date]))), - "Production well pumping" = as.integer(abs(mean(d.well$flow[is.date]))), - "Stanton Crossing outlet boundary" = as.integer(abs(mean(d.drain.1$flow[is.date]))), - "Silver Creek outlet boundary" = as.integer(abs(mean(d.drain.2$flow[is.date]))), + "Water-table discharge" = as.integer(abs(mean(d.rech$flow.out))), + "Streamflow gains" = as.integer(abs(mean(d.river$flow.out))), + "Production well pumping" = as.integer(abs(mean(d.well$flow))), + "Stanton Crossing outlet boundary" = as.integer(abs(mean(d.drain.1$flow))), + "Silver Creek outlet boundary" = as.integer(abs(mean(d.drain.2$flow))), " " = NA, "Change in aquifer storage" = NA) flow[11] <- sum(flow[1:3]) - sum(flow[5:9]) @@ -1099,9 +1085,9 @@ print(tbl, include.rownames=FALSE, caption.placement="top", booktabs=TRUE, format.args=list(big.mark=","), sanitize.colnames.function=function(x){x}, sanitize.text.function=identity, size="\\small") -## ------------------------------------------------------------------------ +## ----read_head----------------------------------------------------------- heads <- ReadModflowBinary(file.path(dir.run, paste0(id, ".hds"))) -dates <- as.Date(vapply(heads, function(i) i$totim, 0), origin = tr.interval[1]) +dates <- as.Date(vapply(heads, function(i) i$totim, 0), origin = tr.stress.periods[1]) layer <- vapply(heads, function(i) i$ilay, 0L) FUN <- function(i) {return(setValues(raster(rs.model), i$d))} rs.heads.lay1 <- mask(stack(lapply(heads[layer == 1L], FUN)), rs.model[["lay1.bot"]]) @@ -1112,7 +1098,7 @@ names(rs.heads.lay1) <- raster.names names(rs.heads.lay2) <- raster.names names(rs.heads.lay3) <- raster.names -## ------------------------------------------------------------------------ +## ----water_table--------------------------------------------------------- land <- mask(crop(rs.data[["land.surface"]], raster(rs.model)), rs.heads.lay1[[1]]) FUN <- function(i) { r <- rs.heads.lay1[[i]] @@ -1149,7 +1135,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=zlim, bg.image=hill.shadin rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Simulated water table in the Wood River Valley aquifer system, south-central Idaho, during December 2010---based on uncalibrated model results." @@ -1178,7 +1163,6 @@ leg <- c("Inset areas, fig. D23", "Line of cross section, fig. D24") legend("topright", leg, lwd=c(NA, 1), pch=c(22, NA), col=c("#000000", "#1F1F1F"), pt.bg=c(NA, NA), pt.cex=c(1.5, NA), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- FUN <- function(usr, credit=NULL, max.dev.dim=c(21, 56), add.legend=FALSE) { @@ -1210,7 +1194,6 @@ FUN(usr.map.n.3) ## ----map_wt_d, echo=FALSE, results="asis", fig.width=fin.map.n.small[1], fig.height=fin.map.n.small[2]---- FUN(usr.map.n.4) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Simulated water table in model layer 1 (\\textit{\\textbf{A}}) north of Ketchum, (\\textit{\\textbf{B}}) south of Ketchum and north of Gimlet, (\\textit{\\textbf{C}}) south of Gimlet and north of Hailey, (\\textit{\\textbf{D}}) south of Hailey and north of Bellevue, and (\\textit{\\textbf{E}}) south of Bellevue, December 2010---based on uncalibrated model results. \\label{fig:map_wt}" @@ -1218,7 +1201,6 @@ v <- c(paste("Maps showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nchar ## ----map_wt_e, echo=FALSE, results="asis", fig.width=fin.map.s[1], fig.height=fin.map.s[2]---- FUN(usr.map.s, credit, max.dev.dim=c(43, 56), add.legend=TRUE) -invisible(dev.off()) ## ----cs_heads, echo=FALSE, fig.width=fin.cs[1], fig.height=fin.cs[2], fig.cap="{Vertical cross-section of simulated hydraulic heads along transect line A--A', December 2010---based on uncalibrated model results.}"---- geo.lays <- c("lay1.top", paste0("lay", 1:3, ".bot")) @@ -1236,7 +1218,6 @@ PlotCrossSection(transect, rs, geo.lays, val.lays, wt.lay, asp=80, leg <- c("Head contour", "Water table") legend("bottomleft", leg, col=c("#1F1F1F", "#3B80F4"), lty=c(1, 1), lwd=c(0.5, 1), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Comparison of measured and simulated (uncalibrated model) water-table contours, contour interval about 6 meters (20 feet), October 2006, southern part of the Wood River Valley aquifer system, south-central Idaho. Contour elevations specified in meters above the North American Vertical Datum of 1988." @@ -1274,7 +1255,6 @@ text(locs, labels=labs, cex=0.5, pos=1, offset=0.1, col=cols[2]) leg <- c("Simulated contour", "Measured contour (interpolated)", "Measured contour (extrapolated)") legend("topright", leg, col=c(cols, cols[2]), lwd=1, lty=c(1, 1, 2), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- p <- obs.wells @@ -1351,7 +1331,6 @@ FUN("Driller-located driller well") ## ----graph_res_sim_d, echo=FALSE, results="asis", fig.width=fig.graph.small[1], fig.height=fig.graph.small[2]---- FUN(c("Sun Valley Water and Sewer well", "Nature Conservancy well")) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Hydraulic head residuals in (\\textit{\\textbf{A}}) U.S. Geological Survey (USGS) groundwater-monitoring network wells, (\\textit{\\textbf{B}}) geolocated driller wells, (\\textit{\\textbf{C}}) Public Land Survey System (PLSS)-located driller wells, and (\\textit{\\textbf{D}}) two of the Sun Valley Water and Sewer District (SVWSD) production wells and The Nature Conservancy (TNC) groundwater-monitoring network wells---based on uncalibrated model results. \\label{fig:graph_res_sim}" @@ -1426,7 +1405,6 @@ points(pp[3:6, ], pch=18) text(pp[3:6, ], labels=well.labs[3:6], col="#333333", cex=0.6, pos=c(4, 4, 2, 2), offset=0.4) legend("topleft", "Wells in figs. D32 and D33", pch=18, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- FUN <- function(idx, add.legend=FALSE) { @@ -1477,7 +1455,6 @@ FUN(5, TRUE) ## ----graph_wells_tnc_b, echo=FALSE, fig.width=fin.graph.short[1], fig.height=fin.graph.short[2]---- FUN(6) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Measured and simulated (uncalibrated model) groundwater-level hydrographs for The Nature Conservancy wells (\\textit{\\textbf{A}}) 02N 18E 09BCD1 and (\\textit{\\textbf{B}}) 02N 18E 35ACC1, Wood River Valley, Idaho. \\label{fig:graph_wells_tnc}" @@ -1497,7 +1474,6 @@ PlotGraph(d, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) legend("bottomright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- FUN <- function(reach.name, reach.ids) { @@ -1582,7 +1558,6 @@ FUN(d4, TRUE) ## ----graph_reaches_sc_b, echo=FALSE, fig.width=fin.graph.short[1], fig.height=fin.graph.short[2]---- FUN(d5) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Measured and simulated (uncalibrated model) stream-aquifer flow exchange along (\\textit{\\textbf{A}}) Silver Creek, above Sportsman Access river reach, and (\\textit{\\textbf{B}}) Silver Creek, Sportsman Access to near Picabo river reach. \\label{fig:graph_reaches_sc}" @@ -1635,7 +1610,6 @@ cols <- c("#2A8FBDCB", "#FAFAD2") legend("center", leg, pch=c(20, 15), col=cols, pt.cex=c(1, 1.5), pt.lwd=0.5, inset=0.02, cex=0.7, bty="n", xpd=NA, bg="#FFFFFFCD", title=expression(bold("EXPLANATION"))) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Mean stream-aquifer flow-exchange residuals along river reaches (\\textit{\\textbf{A}}) Big Wood River, near Ketchum to Hailey and (\\textit{\\textbf{B}}) Hailey to Stanton Crossing; (\\textit{\\textbf{C}}) Willow Creek; (\\textit{\\textbf{D}}) Silver Creek, above Sportsman Access; and (\\textit{\\textbf{E}}) Silver Creek, Sportsman Access to near Picabo---based on uncalibrated model results. \\label{fig:graph_exch}" @@ -1646,7 +1620,6 @@ FUN(d4) ## ----graph_exch_e, echo=FALSE, results="asis", fig.width=fig.graph.small[1], fig.height=fig.graph.small[2]---- FUN(d5) -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- d <- reach.recharge @@ -1731,7 +1704,6 @@ cols <- c("#7FC97F", "#BEAED4", "#FAFAD2") legend("center", leg, pch=c(20, 18, 15), col=cols, pt.cex=c(1, 1, 1.5), pt.lwd=0.5, inset=0.02, cex=0.7, bty="n", xpd=NA, bg="#FFFFFFCD", title=expression(bold("EXPLANATION"))) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Mean stream-aquifer flow-exchange ratio residuals for river subreaches during (\\textit{\\textbf{A}}) March, (\\textit{\\textbf{B}}) August, and (\\textit{\\textbf{C}}) October---based on uncalibrated model results. \\label{fig:graph_ratio}" @@ -1746,7 +1718,6 @@ ylab <- paste("Groundwater discharge, in", c("cubic meters per day", "acre-feet col <- "#C80C0B" PlotGraph(d.drain.1, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=FALSE, center.date.labels=TRUE) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Groundwater discharge across the Silver Creek outlet boundary---based on uncalibrated model results." @@ -1757,14 +1728,13 @@ ylab <- paste("Groundwater discharge, in", c("cubic meters per day", "acre-feet col <- "#C80C0B" PlotGraph(d.drain.2, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) -invisible(dev.off()) -## ----echo=FALSE, message=FALSE------------------------------------------------ +## ----echo=FALSE, message=FALSE------------------------------------------- # save R objects that will be used to update the water budget -layers <- c("lay1.top", sprintf("lay%s.bot", 1:3), sprintf("lay%s.zones", 1:3)) +layers <- c("lay1.top", sprintf("lay%s.bot", 1:3)) rs <- subset(rs.model, layers) save(rs, misc, trib, tr.stress.periods, ss.stress.periods, reduction, d.in.mv.ave, - file=file.path(dir.run, "model.rda"), compress=FALSE) + file=file.path(dir.run, "model.rda")) # read raster data from from reference file and store in stack FUN <- function(f, mv.flag=1e+09) { @@ -1791,7 +1761,7 @@ if (file.exists(file.path(dir.run, "sy1.ref"))) { } # write raster stacks -path <- file.path(getwd(), "ancillary", "uncalibrated") +path <- "ancillary/uncalibrated" ExportRasterStack(rs.data, file.path(path, "data")) ExportRasterStack(rs.model, file.path(path, "model")) @@ -1847,7 +1817,7 @@ animation::saveHTML({ setwd(wd) # write model domain shapefile -path <- file.path(getwd(), "georef") +path <- "georef" dir.create(path, showWarnings=FALSE, recursive=TRUE) p1 <- as(extent(rs.model), "SpatialPolygons") r <- is.na(rs.model[["lay1.bot"]]) @@ -1863,11 +1833,11 @@ p <- SpatialPolygons(list(p1=p1@polygons[[1]], p2=p2@polygons[[1]], p3=p3@polygo d <- data.frame(Area=c("maximum model extent", "active model domain", "inactive model domain"), row.names=sapply(slot(p, "polygons"), function(x) slot(x, "ID"))) p <- SpatialPolygonsDataFrame(p, d) -writeOGR(p, dsn=path, layer="sir2016_5080", driver="ESRI Shapefile", - overwrite_layer=TRUE, encoding="UTF-8") +rgdal::writeOGR(p, dsn=path, layer="sir2016_5080", driver="ESRI Shapefile", + overwrite_layer=TRUE, encoding="UTF-8") # write model grid shapefile -path <- file.path(getwd(), "ancillary/modelgrid") +path <- "ancillary/modelgrid" dir.create(path, showWarnings=FALSE, recursive=TRUE) r <- raster(rs.model) r[] <- seq_len(ncell(r)) @@ -1878,18 +1848,17 @@ p@data <- cbind(p@data, rowColFromCell(r, p@data$cell), lay1.bot=rs.model[["lay1.bot"]][p@data$cell], lay2.bot=rs.model[["lay2.bot"]][p@data$cell], lay3.bot=rs.model[["lay3.bot"]][p@data$cell]) -writeOGR(p, dsn=path, layer="grid", driver="ESRI Shapefile", - overwrite_layer=TRUE, encoding="UTF-8") +rgdal::writeOGR(p, dsn=path, layer="grid", driver="ESRI Shapefile", + overwrite_layer=TRUE, encoding="UTF-8") # write modelgeoref file -path <- getwd() r <- raster(rs.model) e <- rs.model@extent pts <- rbind(nw=c(e@xmin, e@ymax), ne=c(e@xmax, e@ymax), se=c(e@xmax, e@ymin), sw=c(e@xmin, e@ymin)) corners <- c("upper_left", "upper_right", "lower_right", "lower_left") pts.xy <- SpatialPoints(pts, proj4string=crs(r)) -crs.ll <- CRS("+proj=longlat +datum=WGS84") +crs.ll <- CRS("+init=epsg:4326") pts.ll <- spTransform(pts.xy, crs.ll) lng <- coordinates(pts.ll)[, 1] lat <- coordinates(pts.ll)[, 2] @@ -1899,11 +1868,9 @@ ll <- paste(ll, collapse="\n") replacement <- list(ll=ll, crs.ll=crs.ll@projargs) file <- system.file("misc", "modelgeoref-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "modelgeoref.txt") -cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") +cat(ReplaceInTemplate(text, replacement), file="modelgeoref.txt", sep="\n") # write readme file -path <- getwd() desc <- packageDescription("wrv") fields <- c("Depends", "Imports", "Suggests") FUN <- function(i) strsplit(gsub("\n", " ", desc[[i]]), ", ")[[1]] @@ -1913,47 +1880,43 @@ pkgs <- paste(pkgs, collapse="\n ") replacement <- list(pkgs=pkgs, id=id) file <- system.file("misc", "readme-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "readme.txt") options(width=70) -cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") +cat(ReplaceInTemplate(text, replacement), file="readme.txt", sep="\n") options(width=80) # write usgs.model.reference file -path <- file.path(getwd(), "model/model1") replacement <- list(xul=coordinates(pts)["ne", 1], yul=coordinates(pts)["ne", 2], - start_date=format(sdate, "%m/%d/%Y"), + start_date=format(tr.stress.periods[1], "%m/%d/%Y"), model="modflow-usg", proj4=proj4string(rs.model)) file <- system.file("misc", "usgs.model.ref-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "usgs.model.reference") +file <- "model/model1/usgs.model.reference" cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") # remove temporary files -path <- file.path(getwd(), "model/model1") -file <- file.path(path, "fort.6") +file <- "model/model1/fort.6" if (file.exists(file)) invisible(file.remove(file)) # move modflow output files -path <- file.path(getwd(), "output/output.model1") +path <- "output/output.model1" dir.create(path, showWarnings=FALSE, recursive=TRUE) file.names <- paste(id, c("bud", "hds", "lst"), sep=".") -invisible(file.rename(file.path(getwd(), "model/model1", file.names), +invisible(file.rename(file.path("model/model1", file.names), file.path(path, file.names))) # move modflow executable file -path <- file.path(getwd(), "bin") +path <- "bin" dir.create(path=path, showWarnings=FALSE, recursive=TRUE) -invisible(file.rename(file.path(getwd(), "model/model1/mfusg.exe"), +invisible(file.rename(file.path("model/model1/mfusg.exe"), file.path(path, "mfusg.exe"))) # create source directory -path <- file.path(getwd(), "source") -dir.create(path=path, showWarnings=FALSE, recursive=TRUE) +dir.create(path="source", showWarnings=FALSE, recursive=TRUE) # write xml metadata and thumbnail image -path <- file.path(getwd(), "webrelease") +path <- "webrelease" dir.create(path, showWarnings=FALSE, recursive=TRUE) file <- system.file("misc", "sir2016-5080_usgsdatarelease.xml", package="wrv") @@ -2000,5 +1963,4 @@ axis(1, at=xat, tcl=tcl, lwd=-1, lwd.ticks=0.3, labels=FALSE, mgp=mgp) axis(4, at=yat, tcl=tcl, lwd=-1, lwd.ticks=0.3, labels=FALSE, mgp=mgp) mtext("Columns", side=3, line=1, cex=cex, font=2) mtext("Rows", side=2, line=1, cex=cex, font=2) -invisible(dev.off()) diff --git a/inst/doc/sir20165080_AppendixD.Rnw b/inst/doc/sir20165080_AppendixD.Rnw index 6c32a08..5f21ce3 100644 --- a/inst/doc/sir20165080_AppendixD.Rnw +++ b/inst/doc/sir20165080_AppendixD.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{D\arabic{figure}} \renewcommand{\thetable}{D\arabic{table}} \renewcommand{\thepage}{D\arabic{page}} @@ -22,8 +24,6 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) options(preferRaster=TRUE, scipen=0, digits=2) -loadNamespace("xtable") -loadNamespace("sfsmisc") # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -132,10 +132,12 @@ Flow in the WRV aquifer system is simulated using \href{http://water.usgs.gov/og \section{R Environment} -Load the \textbf{wrv} package in the current \R{} session: +Load the following user-contributed packages into the current \R{} session: <>= -library("wrv") +library("wrv") # processor for groundwater-flow model +library("raster") # gridded spatial data toolkit +library("inlmisc") # miscellaneous functions for the USGS INL project office @ \noindent The memory requirement for running \R{} code in this vignette is about 5 gigabytes. @@ -198,7 +200,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) @ \noindent The elevation of the pre-Quaternary bedrock surface and top of Quaternary basalt is calculated by subtracting the thickness of the Quaternary sediments from land-surface elevations. @@ -250,9 +251,8 @@ text(misc.locations, labels=misc.locations@data$label, pos=c(3, 2, 2), cex=0.5, offset=0.3) legend("topright", "Basalt unit", fill=col, border=NA, inset=c(0.02, 0.55), cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0, -9)), - sub.label=list("Map area", adj=c(1.9, 0.5)), loc="topright") -invisible(dev.off()) +AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0.25, -9)), + sub.label=list("Map area", adj=c(1.65, 0.5)), loc="topright") @ Basalt underlies the Quaternary sediments; however, very little data are available to describe the unit thickness of basalt. @@ -289,7 +289,6 @@ PlotMap(r, breaks=pretty(range(r[], na.rm=TRUE), n=12), xlim=usr.map.s[1:2], yli rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ \newpage @@ -319,7 +318,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) legend("topright", "Clay confining unit", fill=col, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ \noindent Well-driller reports and geophysical surveys describe the clay confining unit as about 5 m (16 ft) thick, and generally lying at a depth of about 30 m (98 ft) below land surface. @@ -362,7 +360,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=range(pretty(r[])), rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ \noindent The total number of vertically adjusted cells is \Sexpr{format(length(adj.cells), big.mark=",")}, or \Sexpr{round(length(adj.cells) / length(cells) * 100)} percent of active cells, @@ -414,7 +411,6 @@ text(getSpatialLinesMidPoints(trib.lines), labels=rownames(trib.lines@data), leg <- as.character(levels(r)[[1]]$att) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ The presence of the clay confining unit significantly influences groundwater-level responses, necessitating a multi-layer model. @@ -520,7 +516,7 @@ A summary of the structured model grid attributes is shown in \hyperref[table_mo The model domain covers \Sexpr{round(active.lay1.area)} square kilometers (\Sexpr{round(active.lay1.area * km2.to.mi2)} square miles), or \Sexpr{percent.of.study.area} percent of the WRV aquifer system area. -<<>>= +<>= rs.model <- stack(crop(rs.model, extent(trim(rs.model[["lay1.top"]])))) @ @@ -703,7 +699,7 @@ rs.model[["lay3.zones"]] <- r <>= transect <- SpatialLines(list(Lines(list(Line(transect.coords)), ID="Transect")), - proj4string=CRS("+proj=longlat +datum=WGS84")) + proj4string=CRS("+init=epsg:4326")) transect <- spTransform(transect, crs(hill.shading)) verticies <- as(transect, "SpatialPoints") transect.ends <- verticies[c(1, length(verticies)), ] @@ -758,7 +754,6 @@ FUN <- function(i) { \caption{Model layer 3 \label{fig:map_zones_c}} <>= FUN("lay3.zones") - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -775,7 +770,6 @@ PlotCrossSection(transect, rs.model, geo.lays, val.lays, asp=80, col=cols, is.categorical=TRUE, draw.key=FALSE) legend("topright", paste("Zone", 1:4), fill=cols, ncol=1, border=NA, inset=c(0.02, 0), cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ Hydraulic properties assigned to each hydrogeologic zone (zone) are given in \hyperref[table_zones]{table~\ref{table_zones}}. @@ -875,7 +869,6 @@ leg <- format(match(colnames(d)[-1], make.names(tributaries@data$Name))) legend("topright", leg, lwd=1, col=cols, ncol=2, pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD", title=expression(bold("Tributary"))) -invisible(dev.off()) @ \noindent Steady-state volumetric flow rates are calculated for each boundary by averaging flows over time. @@ -1007,7 +1000,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=3, offse leg <- as.character(levels(r)[[1]]$Name) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ \noindent The drain boundary conditions are bundled into a single data table. @@ -1138,7 +1130,6 @@ text(misc.locations, labels=misc.locations@data$label, pos=c(3, 2, 2), cex=0.5, offset=0.3) legend("topright", "Streamgage", pch=17, col="#333333", pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ If the head in a model cell that contains a river subreach falls below the bottom of the riverbed, @@ -1249,7 +1240,7 @@ Normalization is done by subtracting the median of the monthly mean gage-height <<>>= d <- gage.height -d <- d[d$Date >= tr.interval[1] & d$Date < tr.interval[2], ] +d <- d[d$Date >= tr.stress.periods[1] & d$Date < tail(tr.stress.periods, 1), ] d <- data.frame(Date = format(d$Date, "%Y%m"), d[, -1], check.names = FALSE) d <- aggregate(d[, -1], by = list(YearMonth = d$Date), mean, na.rm = TRUE) d[, -1] <- apply(d[, -1], 2, function(x) x - median(x, na.rm = TRUE)) @@ -1311,7 +1302,6 @@ cols <- c("#1B9E77", "#D95F02", "#7570B3") PlotGraph(x, y, ylab=ylab, col=cols, conversion.factor=m.to.ft, center.date.labels=TRUE) legend("topright", colnames(y), lwd=c(1, 1, 1), col=cols, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD", title=expression(bold("Streamgages"))) -invisible(dev.off()) @ \noindent The northing-distance to the cell center is calculated for each of the river-boundary cells composing the Big Wood River. @@ -1402,9 +1392,16 @@ Areal recharge and pumping demand are specified for each month in the model simu (\hyperref[fig:graph_areal_rech]{figs.~\ref{fig:graph_areal_rech}} and \ref{fig:graph_wells}). The steady-state areal recharge is shown in \hyperref[fig:map_areal_rech]{figure~\ref{fig:map_areal_rech}}. -<<>>= -l <- RunWaterBalance(tr.stress.periods, rs.model[["lay1.bot"]], efficiency, - canal.seep, ss.stress.periods) +<>= +l <- RunWaterBalance(rs.model[["lay1.bot"]], tr.stress.periods, + ss.stress.periods, canal.seep = canal.seep, + comb.sw.irr = comb.sw.irr, div.gw = div.gw, + div.sw = div.sw, div.ww = div.ww, efficiency = efficiency, + entity.components = entity.components, et = et, + irr.entities = irr.entities, land.surface = land.surface, + pod.gw = pod.gw, priority.cuts = priority.cuts, + r.canals = r.canals, rs.entities = rs.entities, + rs.rech.non.irr = rs.rech.non.irr) cells <- which(!is.na(l[["areal.rech"]][[1]][])) rc <- rowColFromCell(l[["areal.rech"]], cells) rech <- cbind(lay = 1, row = rc[, 1], col = rc[, 2], l[["areal.rech"]][cells]) @@ -1441,7 +1438,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) legend("topright", "Pumping well", pch=21, col=NA, pt.bg=col, pt.cex=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ <>= @@ -1462,7 +1458,6 @@ PlotGraph(d, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) legend("topright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ <>= @@ -1478,7 +1473,6 @@ ylab <- paste("Total withdrawals from wells, in", c("cubic meters per day", "acr col <- "#C80C0B" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) -invisible(dev.off()) @ <>= @@ -1507,7 +1501,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=zlim, bg.image=hill.shadin rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ Seepage beneath the Bypass Canal and Bellevue Wastewater Treatment Plant Ponds (Bellevue WWTP Ponds) (locations shown in \hyperref[fig:map_basalt_extent]{fig.~\ref{fig:map_basalt_extent}}) @@ -1553,7 +1546,6 @@ ylab <- paste("Seepage rate, in", c("cubic meters per day", "acre-feet per year" col <- "#67A9CF" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) @ <>= @@ -1570,7 +1562,6 @@ ylab <- paste("Seepage rate, in", c("cubic meters per day", "acre-feet per year" col <- "#67A9CF" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=FALSE, center.date.labels=TRUE) -invisible(dev.off()) @ \noindent Steady-state volumetric flow rates are calculated by averaging flows over time. @@ -1607,9 +1598,9 @@ Groundwater flow in the WRV aquifer system is simulated using the MODFLOW-USG nu This model was chosen for its ability to solve complex unconfined groundwater flow simulations. The model-input files are written to disk. -<<>>= +<>= id <- "wrv_mfusg" # model run identifier -dir.run <- file.path(getwd(), "model/model1") +dir.run <- "model/model1" WriteModflowInput(rs.model, rech, well, trib, misc, river, drain, id, dir.run, is.convertible = FALSE, tr.stress.periods = tr.stress.periods, ntime.steps = ntime.steps, verbose = FALSE) @@ -1627,7 +1618,7 @@ invisible(file.copy(file.exe, dir.run, copy.date = TRUE)) \noindent Create and execute a `batch file' containing commands that run MODFLOW-USG: <<>>= -file.bat <- file.path(dir.run, "RunModflow.bat") +file.bat <- file.path(getwd(), dir.run, "RunModflow.bat") cmd <- paste(sub("\\.exe$", "", basename(file.exe)), shQuote(paste0(id, ".nam"))) cat(cmd, file = file.bat) Sys.chmod(file.bat, mode = "755") @@ -1653,14 +1644,14 @@ Water budget components are as follows: (4) groundwater discharge at the Stanton Crossing and Silver Creek outlet boundaries. \hyperref[fig:graph_budget]{Figure~\ref{fig:graph_budget}} shows the annual water budget components and change in aquifer system storage during the uncalibrated model simulation period (1995--2010). -<<>>= +<>= file.bud <- file.path(dir.run, paste0(id, ".bud")) budget <- ReadModflowBinary(file.bud, "flow", rm.totim.0 = TRUE) budget <- SummariseBudget(budget) -budget <- dplyr::mutate(budget, totim.date = as.Date(totim, origin = tr.interval[1])) +budget <- dplyr::mutate(budget, totim.date = as.Date(totim, origin = tr.stress.periods[1])) @ -<>= +<>= b <- budget[, c("desc", "id", "flow.dir", "totim.date")] b$flow <- budget$flow.sum @@ -1674,7 +1665,7 @@ d.river <- d d <- b[b$desc == "drains" & b$flow.dir == "out", ] d$id <- as.factor(d$id) -levels(d$id) <- levels(rs.model[["drains"]])[[1]]$Name +levels(d$id) <- drains@data$Name d.drain.1 <- d[d$id == "Stanton Crossing", c("totim.date", "flow")] d.drain.2 <- d[d$id == "Silver Creek", c("totim.date", "flow")] @@ -1700,7 +1691,7 @@ v <- c(paste("Graph showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, ncha @ <>= -cols <- format(seq(tr.interval[1], tr.interval[2] - 1, "year"), "%Y") +cols <- format(seq(tr.stress.periods[1], tail(tr.stress.periods, 1) - 1, "year"), "%Y") rows <- c("Areal recharge", "Streamflow losses", "Tributary bain underflow", "Areal discharge", "Streamflow gains", "Well pumping", "Outlet boundaries") m <- matrix(NA, nrow=length(rows), ncol=length(cols), dimnames=list(rows, cols)) @@ -1748,21 +1739,18 @@ idxs <- c(rev(pos.idxs), neg.idxs) legend("topright", rows[idxs], fill=cols[idxs], inset=0.02, cex=cex, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Component"))) box(lwd=0.5) -invisible(dev.off()) @ <>= -sdate <- as.Date("1995-01-01", tz="MST") -is.date <- colnames(m) >= format(sdate, "%Y") -flow <- c("Water-table recharge" = as.integer(mean(d.rech$flow.in[is.date])), - "Streamflow losses" = as.integer(mean(d.river$flow.in[is.date])), - "Tributary basin underflow" = as.integer(mean(d.trib$flow[is.date])), +flow <- c("Water-table recharge" = as.integer(mean(d.rech$flow.in)), + "Streamflow losses" = as.integer(mean(d.river$flow.in)), + "Tributary basin underflow" = as.integer(mean(d.trib$flow)), " " = NA, - "Water-table discharge" = as.integer(abs(mean(d.rech$flow.out[is.date]))), - "Streamflow gains" = as.integer(abs(mean(d.river$flow.out[is.date]))), - "Production well pumping" = as.integer(abs(mean(d.well$flow[is.date]))), - "Stanton Crossing outlet boundary" = as.integer(abs(mean(d.drain.1$flow[is.date]))), - "Silver Creek outlet boundary" = as.integer(abs(mean(d.drain.2$flow[is.date]))), + "Water-table discharge" = as.integer(abs(mean(d.rech$flow.out))), + "Streamflow gains" = as.integer(abs(mean(d.river$flow.out))), + "Production well pumping" = as.integer(abs(mean(d.well$flow))), + "Stanton Crossing outlet boundary" = as.integer(abs(mean(d.drain.1$flow))), + "Silver Creek outlet boundary" = as.integer(abs(mean(d.drain.2$flow))), " " = NA, "Change in aquifer storage" = NA) flow[11] <- sum(flow[1:3]) - sum(flow[5:9]) @@ -1807,9 +1795,9 @@ print(tbl, include.rownames=FALSE, caption.placement="top", booktabs=TRUE, The simulated hydraulic head values are read for each of the 193 monthly model stress periods and placed in a raster stack. Recall that the model simulates head distributions for an initial steady-state stress period followed by 768 weekly time steps (4 time steps per stress period) during the 1995 through 2010 time period. -<<>>= +<>= heads <- ReadModflowBinary(file.path(dir.run, paste0(id, ".hds"))) -dates <- as.Date(vapply(heads, function(i) i$totim, 0), origin = tr.interval[1]) +dates <- as.Date(vapply(heads, function(i) i$totim, 0), origin = tr.stress.periods[1]) layer <- vapply(heads, function(i) i$ilay, 0L) FUN <- function(i) {return(setValues(raster(rs.model), i$d))} rs.heads.lay1 <- mask(stack(lapply(heads[layer == 1L], FUN)), rs.model[["lay1.bot"]]) @@ -1826,7 +1814,7 @@ and should be considered an overprediction of head because land surface is the t The simulated water table is represented using model layer 1 head values bounded by the land-surface elevation; that is, head values that are above land surface are specified at land surface. -<<>>= +<>= land <- mask(crop(rs.data[["land.surface"]], raster(rs.model)), rs.heads.lay1[[1]]) FUN <- function(i) { r <- rs.heads.lay1[[i]] @@ -1872,7 +1860,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=zlim, bg.image=hill.shadin rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ <>= @@ -1903,7 +1890,6 @@ leg <- c("Inset areas, fig. D23", "Line of cross section, fig. D24") legend("topright", leg, lwd=c(NA, 1), pch=c(22, NA), col=c("#000000", "#1F1F1F"), pt.bg=c(NA, NA), pt.cex=c(1.5, NA), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ <>= @@ -1952,7 +1938,6 @@ FUN <- function(usr, credit=NULL, max.dev.dim=c(21, 56), add.legend=FALSE) { \caption{South of Hailey and north of Bellevue \label{fig:map_wt_d}} <>= FUN(usr.map.n.4) - invisible(dev.off()) @ \end{subfigure} @@ -1970,7 +1955,6 @@ FUN <- function(usr, credit=NULL, max.dev.dim=c(21, 56), add.legend=FALSE) { \caption{South of Bellevue \label{fig:map_wt_e}} <>= FUN(usr.map.s, credit, max.dev.dim=c(43, 56), add.legend=TRUE) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -1993,7 +1977,6 @@ PlotCrossSection(transect, rs, geo.lays, val.lays, wt.lay, asp=80, leg <- c("Head contour", "Water table") legend("bottomleft", leg, col=c("#1F1F1F", "#3B80F4"), lty=c(1, 1), lwd=c(0.5, 1), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ \clearpage @@ -2044,7 +2027,6 @@ text(locs, labels=labs, cex=0.5, pos=1, offset=0.1, col=cols[2]) leg <- c("Simulated contour", "Measured contour (interpolated)", "Measured contour (extrapolated)") legend("topright", leg, col=c(cols, cols[2]), lwd=1, lty=c(1, 1, 2), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ <>= @@ -2195,7 +2177,6 @@ FUN <- function(desc) { \caption{SVWSD and TNC wells \label{fig:graph_res_sim_d}} <>= FUN(c("Sun Valley Water and Sewer well", "Nature Conservancy well")) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2282,7 +2263,6 @@ points(pp[3:6, ], pch=18) text(pp[3:6, ], labels=well.labs[3:6], col="#333333", cex=0.6, pos=c(4, 4, 2, 2), offset=0.4) legend("topleft", "Wells in figs. D32 and D33", pch=18, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ Comparisons between simulated and measured groundwater levels over time are made for selected wells in the WRV @@ -2379,7 +2359,6 @@ FUN <- function(idx, add.legend=FALSE) { \caption{\Sexpr{paste("Well No.", well.labs[6])} \label{fig:graph_wells_tnc_b}} <>= FUN(6) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2420,7 +2399,6 @@ PlotGraph(d, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) legend("bottomright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ % === @@ -2543,7 +2521,6 @@ FUN(d3, TRUE) \caption{Silver Creek, Sportsman Access to near Picabo river reach \label{fig:graph_reaches_sc_b}} <>= FUN(d5) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2615,7 +2592,6 @@ FUN <- function(d, add.legend=FALSE) { legend("center", leg, pch=c(20, 15), col=cols, pt.cex=c(1, 1.5), pt.lwd=0.5, inset=0.02, cex=0.7, bty="n", xpd=NA, bg="#FFFFFFCD", title=expression(bold("EXPLANATION"))) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2638,7 +2614,6 @@ FUN <- function(d, add.legend=FALSE) { \caption{Sportsman Access to near Picabo \label{fig:graph_exch_e}} <>= FUN(d5) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -2757,7 +2732,6 @@ FUN <- function(mo) { legend("center", leg, pch=c(20, 18, 15), col=cols, pt.cex=c(1, 1, 1.5), pt.lwd=0.5, inset=0.02, cex=0.7, bty="n", xpd=NA, bg="#FFFFFFCD", title=expression(bold("EXPLANATION"))) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2791,7 +2765,6 @@ ylab <- paste("Groundwater discharge, in", c("cubic meters per day", "acre-feet col <- "#C80C0B" PlotGraph(d.drain.1, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=FALSE, center.date.labels=TRUE) -invisible(dev.off()) @ <>= @@ -2804,17 +2777,16 @@ ylab <- paste("Groundwater discharge, in", c("cubic meters per day", "acre-feet col <- "#C80C0B" PlotGraph(d.drain.2, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) -invisible(dev.off()) @ % ========================================================================= <>= # save R objects that will be used to update the water budget -layers <- c("lay1.top", sprintf("lay%s.bot", 1:3), sprintf("lay%s.zones", 1:3)) +layers <- c("lay1.top", sprintf("lay%s.bot", 1:3)) rs <- subset(rs.model, layers) save(rs, misc, trib, tr.stress.periods, ss.stress.periods, reduction, d.in.mv.ave, - file=file.path(dir.run, "model.rda"), compress=FALSE) + file=file.path(dir.run, "model.rda")) # read raster data from from reference file and store in stack FUN <- function(f, mv.flag=1e+09) { @@ -2841,7 +2813,7 @@ if (file.exists(file.path(dir.run, "sy1.ref"))) { } # write raster stacks -path <- file.path(getwd(), "ancillary", "uncalibrated") +path <- "ancillary/uncalibrated" ExportRasterStack(rs.data, file.path(path, "data")) ExportRasterStack(rs.model, file.path(path, "model")) @@ -2897,7 +2869,7 @@ animation::saveHTML({ setwd(wd) # write model domain shapefile -path <- file.path(getwd(), "georef") +path <- "georef" dir.create(path, showWarnings=FALSE, recursive=TRUE) p1 <- as(extent(rs.model), "SpatialPolygons") r <- is.na(rs.model[["lay1.bot"]]) @@ -2913,11 +2885,11 @@ p <- SpatialPolygons(list(p1=p1@polygons[[1]], p2=p2@polygons[[1]], p3=p3@polygo d <- data.frame(Area=c("maximum model extent", "active model domain", "inactive model domain"), row.names=sapply(slot(p, "polygons"), function(x) slot(x, "ID"))) p <- SpatialPolygonsDataFrame(p, d) -writeOGR(p, dsn=path, layer="sir2016_5080", driver="ESRI Shapefile", - overwrite_layer=TRUE, encoding="UTF-8") +rgdal::writeOGR(p, dsn=path, layer="sir2016_5080", driver="ESRI Shapefile", + overwrite_layer=TRUE, encoding="UTF-8") # write model grid shapefile -path <- file.path(getwd(), "ancillary/modelgrid") +path <- "ancillary/modelgrid" dir.create(path, showWarnings=FALSE, recursive=TRUE) r <- raster(rs.model) r[] <- seq_len(ncell(r)) @@ -2928,18 +2900,17 @@ p@data <- cbind(p@data, rowColFromCell(r, p@data$cell), lay1.bot=rs.model[["lay1.bot"]][p@data$cell], lay2.bot=rs.model[["lay2.bot"]][p@data$cell], lay3.bot=rs.model[["lay3.bot"]][p@data$cell]) -writeOGR(p, dsn=path, layer="grid", driver="ESRI Shapefile", - overwrite_layer=TRUE, encoding="UTF-8") +rgdal::writeOGR(p, dsn=path, layer="grid", driver="ESRI Shapefile", + overwrite_layer=TRUE, encoding="UTF-8") # write modelgeoref file -path <- getwd() r <- raster(rs.model) e <- rs.model@extent pts <- rbind(nw=c(e@xmin, e@ymax), ne=c(e@xmax, e@ymax), se=c(e@xmax, e@ymin), sw=c(e@xmin, e@ymin)) corners <- c("upper_left", "upper_right", "lower_right", "lower_left") pts.xy <- SpatialPoints(pts, proj4string=crs(r)) -crs.ll <- CRS("+proj=longlat +datum=WGS84") +crs.ll <- CRS("+init=epsg:4326") pts.ll <- spTransform(pts.xy, crs.ll) lng <- coordinates(pts.ll)[, 1] lat <- coordinates(pts.ll)[, 2] @@ -2949,11 +2920,9 @@ ll <- paste(ll, collapse="\n") replacement <- list(ll=ll, crs.ll=crs.ll@projargs) file <- system.file("misc", "modelgeoref-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "modelgeoref.txt") -cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") +cat(ReplaceInTemplate(text, replacement), file="modelgeoref.txt", sep="\n") # write readme file -path <- getwd() desc <- packageDescription("wrv") fields <- c("Depends", "Imports", "Suggests") FUN <- function(i) strsplit(gsub("\n", " ", desc[[i]]), ", ")[[1]] @@ -2963,47 +2932,43 @@ pkgs <- paste(pkgs, collapse="\n ") replacement <- list(pkgs=pkgs, id=id) file <- system.file("misc", "readme-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "readme.txt") options(width=70) -cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") +cat(ReplaceInTemplate(text, replacement), file="readme.txt", sep="\n") options(width=80) # write usgs.model.reference file -path <- file.path(getwd(), "model/model1") replacement <- list(xul=coordinates(pts)["ne", 1], yul=coordinates(pts)["ne", 2], - start_date=format(sdate, "%m/%d/%Y"), + start_date=format(tr.stress.periods[1], "%m/%d/%Y"), model="modflow-usg", proj4=proj4string(rs.model)) file <- system.file("misc", "usgs.model.ref-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "usgs.model.reference") +file <- "model/model1/usgs.model.reference" cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") # remove temporary files -path <- file.path(getwd(), "model/model1") -file <- file.path(path, "fort.6") +file <- "model/model1/fort.6" if (file.exists(file)) invisible(file.remove(file)) # move modflow output files -path <- file.path(getwd(), "output/output.model1") +path <- "output/output.model1" dir.create(path, showWarnings=FALSE, recursive=TRUE) file.names <- paste(id, c("bud", "hds", "lst"), sep=".") -invisible(file.rename(file.path(getwd(), "model/model1", file.names), +invisible(file.rename(file.path("model/model1", file.names), file.path(path, file.names))) # move modflow executable file -path <- file.path(getwd(), "bin") +path <- "bin" dir.create(path=path, showWarnings=FALSE, recursive=TRUE) -invisible(file.rename(file.path(getwd(), "model/model1/mfusg.exe"), +invisible(file.rename(file.path("model/model1/mfusg.exe"), file.path(path, "mfusg.exe"))) # create source directory -path <- file.path(getwd(), "source") -dir.create(path=path, showWarnings=FALSE, recursive=TRUE) +dir.create(path="source", showWarnings=FALSE, recursive=TRUE) # write xml metadata and thumbnail image -path <- file.path(getwd(), "webrelease") +path <- "webrelease" dir.create(path, showWarnings=FALSE, recursive=TRUE) file <- system.file("misc", "sir2016-5080_usgsdatarelease.xml", package="wrv") @@ -3050,7 +3015,6 @@ axis(1, at=xat, tcl=tcl, lwd=-1, lwd.ticks=0.3, labels=FALSE, mgp=mgp) axis(4, at=yat, tcl=tcl, lwd=-1, lwd.ticks=0.3, labels=FALSE, mgp=mgp) mtext("Columns", side=3, line=1, cex=cex, font=2) mtext("Rows", side=2, line=1, cex=cex, font=2) -invisible(dev.off()) @ % ========================================================================= diff --git a/inst/doc/sir20165080_AppendixE.R b/inst/doc/sir20165080_AppendixE.R index 0e6b738..d307a4d 100644 --- a/inst/doc/sir20165080_AppendixE.R +++ b/inst/doc/sir20165080_AppendixE.R @@ -2,9 +2,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -70,7 +71,6 @@ legend("topleft", leg, pch=c(15, 17, 22, NA), lwd=c(NA, NA, NA, 1), col=cols, box.lwd=0.5, bg="#FFFFFFE7", seg.len=1.4) AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) ## ----table_tribs, echo=FALSE, results="asis"----------------------------- d <- tributaries@data @@ -164,7 +164,6 @@ leg <- c("Transect line", "Axial line", "Aquifer extent") legend("topleft", leg, lwd=c(2, 2, 1), col=cols, pt.bg="#33333366", inset=0.02, cex=0.7, box.lty=1, box.lwd=0.3, bg="#FFFFFFE7", seg.len=1) -invisible(dev.off()) ## ----map_graph_trib_b, echo=FALSE, results="asis", fig.width=fin.map.n.small.0[1], fig.height=fin.map.n.small.0[2]---- asp <- 10 @@ -196,7 +195,6 @@ text(xlim[1], ylim[2], "B", cex=0.7, pos=3, font=4) text(xlim[2], ylim[2], "B'", cex=0.7, pos=3, font=4) text(xlim[2], ylim[2], "B'", cex=0.7, pos=3, font=4) text(mean(xlim), ylim[2], "LAND SURFACE", cex=0.7, pos=3) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Basin area in ascending order plotted on a logarithmic scale." @@ -220,7 +218,6 @@ text(seq_along(x[, 1]), x[, 2], x[, 1], pos=pos, offset=0.3, cex=0.6, srt=90) xlim <- par("usr")[1:2] text(xlim[2] - diff(xlim) * 0.15, natural.basin.area.break, "Natural break in basin areas", col=col, cex=0.7, pos=1, offset=0.2) -invisible(dev.off()) ## ----hist_flux_est, echo=FALSE, fig.width=fin.graph.short[1], fig.height=fin.graph.short[2], fig.cap="{Estimated mean tributary basin underflow in the Wood River Valley aquifer system, south-central Idaho. Values are preliminary and were adjusted during model calibration.}"---- d <- tributaries@data[order(tributaries@data$Flow, decreasing=TRUE), ] @@ -238,7 +235,6 @@ axis(1, at=at, labels=labs, cex.axis=0.7, tcl=tcl, lwd=0.5) labs <- paste("Basin size is", c("'big'", "'small'")) legend("topright", labs, fill=cols, border=cols, inset=0.05, cex=0.7, pt.cex=1, box.lwd=NA, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Daily streamflow at the Hailey (13139510) streamgage located on the Big Wood River, Idaho." @@ -330,5 +326,4 @@ PlotGraph(d, ylab=ylab, col=cols, fill=fill, conversion.factor=m3.per.d.to.af.pe center.date.labels=TRUE, scientific=c(FALSE, FALSE, FALSE)) legend("topright", labs, col=cols, lty=1, inset=0.02, cex=0.7, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) diff --git a/inst/doc/sir20165080_AppendixE.Rnw b/inst/doc/sir20165080_AppendixE.Rnw index c6212f2..541469e 100644 --- a/inst/doc/sir20165080_AppendixE.Rnw +++ b/inst/doc/sir20165080_AppendixE.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{E\arabic{figure}} \renewcommand{\thetable}{E\arabic{table}} \renewcommand{\thepage}{E\arabic{page}} @@ -21,9 +23,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -182,7 +185,6 @@ legend("topleft", leg, pch=c(15, 17, 22, NA), lwd=c(NA, NA, NA, 1), col=cols, box.lwd=0.5, bg="#FFFFFFE7", seg.len=1.4) AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) @ \begin{landscape} @@ -333,7 +335,6 @@ RotateLine <- function(m, ang=90) { legend("topleft", leg, lwd=c(2, 2, 1), col=cols, pt.bg="#33333366", inset=0.02, cex=0.7, box.lty=1, box.lwd=0.3, bg="#FFFFFFE7", seg.len=1) - invisible(dev.off()) @ \end{subfigure}% \begin{subfigure}{0.5\textwidth} @@ -368,7 +369,6 @@ RotateLine <- function(m, ang=90) { text(xlim[2], ylim[2], "B'", cex=0.7, pos=3, font=4) text(xlim[2], ylim[2], "B'", cex=0.7, pos=3, font=4) text(mean(xlim), ylim[2], "LAND SURFACE", cex=0.7, pos=3) - invisible(dev.off()) @ \end{subfigure} @@ -467,7 +467,6 @@ text(seq_along(x[, 1]), x[, 2], x[, 1], pos=pos, offset=0.3, cex=0.6, srt=90) xlim <- par("usr")[1:2] text(xlim[2] - diff(xlim) * 0.15, natural.basin.area.break, "Natural break in basin areas", col=col, cex=0.7, pos=1, offset=0.2) -invisible(dev.off()) @ <>= @@ -486,7 +485,6 @@ axis(1, at=at, labels=labs, cex.axis=0.7, tcl=tcl, lwd=0.5) labs <- paste("Basin size is", c("'big'", "'small'")) legend("topright", labs, fill=cols, border=cols, inset=0.05, cex=0.7, pt.cex=1, box.lwd=NA, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= @@ -757,7 +755,6 @@ PlotGraph(d, ylab=ylab, col=cols, fill=fill, conversion.factor=m3.per.d.to.af.pe center.date.labels=TRUE, scientific=c(FALSE, FALSE, FALSE)) legend("topright", labs, col=cols, lty=1, inset=0.02, cex=0.7, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= diff --git a/inst/doc/sir20165080_AppendixF.R b/inst/doc/sir20165080_AppendixF.R index 43b835f..b424366 100644 --- a/inst/doc/sir20165080_AppendixF.R +++ b/inst/doc/sir20165080_AppendixF.R @@ -2,9 +2,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -94,7 +95,6 @@ legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, leg <- "Weather stations" legend("topleft", leg, pch=23, pt.bg="#333333", pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Daily average snow water equivalent recorded at weather stations in the Wood River Valley and surrounding areas, Idaho." @@ -119,7 +119,6 @@ axis.Date(1, at=at, tcl=0, cex.axis=0.6, lwd=-1, labels=xlabs, padj=1.5) leg <- c("Chocolate Gulch SNOTEL", "Hailey HADS", "Picabo AgriMet") legend("topright", leg, col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- elev <- weather.stations@data[, "elevation"] @@ -158,7 +157,6 @@ FUN("Hailey", "#D95F02") ## ----graph_precip_c, echo=FALSE, results="asis", fig.width=fin.graph.short[1], fig.height=fin.graph.short[2]---- FUN("Picabo", "#7570B3") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Methods used to estimate evapotranspiration." @@ -184,7 +182,6 @@ legend(mean(par("usr")[1:2]), 1, levels(y)[idxs], fill=cols[idxs], horiz=TRUE, cex=0.7, bty="n", xpd=TRUE, xjust=0.5, yjust=0, border=c("#333333", cols[idxs][-1])) box(lwd=0.5) -invisible(dev.off()) ## ----table_et_picabo-ar, echo=FALSE, results="asis"---------------------- covers <- c("100 percent impervious", "Grass turf (lawns) - irrigated", "Alfalfa - less frequent cuttings", @@ -339,7 +336,6 @@ v <- c(paste("Maps showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nchar ## ----map_et_b, echo=FALSE, results="asis", fig.width=fin.map[1], fig.height=fin.map[2]---- FUN(et[["200808"]]) -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- x <- as.Date(paste0(names(et), "15"), format="%Y%m%d") @@ -371,7 +367,6 @@ FUN(c("2003-01-01", "2007-01-01")) ## ----graph_et_d, echo=FALSE, results="asis", fig.width=fin.graph.short[1], fig.height=fin.graph.short[2]---- FUN(c("2007-01-01", "2011-01-01")) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Spatial distribution of surficial soil types in the Wood River Valley, Idaho." @@ -396,7 +391,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse leg <- as.character(levels(polys@data$GroupSymbol)) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Soil Types"))) -invisible(dev.off()) ## ----table_soils, echo=FALSE, results="asis"----------------------------- d <- soils@data[!is.na(soils@data$SoilClass), ] @@ -441,7 +435,6 @@ PlotMap(r, breaks=breaks, xlim=usr.map[1:2], ylim=usr.map[3:4], labels=list(at=at, labels=labels), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- rs <- rs.rech.non.irr @@ -476,7 +469,6 @@ v <- c(paste("Maps showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nchar ## ----map_rate_b, echo=FALSE, results="asis", fig.width=fin.map[1], fig.height=fin.map[2]---- FUN(rs[["200808"]]) -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- x <- as.Date(paste0(names(rs), "15"), format="%Y%m%d") @@ -508,5 +500,4 @@ FUN(c("2003-01-01", "2007-01-01")) ## ----graph_rate_d, echo=FALSE, results="asis", fig.width=fin.graph.short[1], fig.height=fin.graph.short[2]---- FUN(c("2007-01-01", "2011-01-01")) -invisible(dev.off()) diff --git a/inst/doc/sir20165080_AppendixF.Rnw b/inst/doc/sir20165080_AppendixF.Rnw index 0b6c6a5..cd3c440 100644 --- a/inst/doc/sir20165080_AppendixF.Rnw +++ b/inst/doc/sir20165080_AppendixF.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{F\arabic{figure}} \renewcommand{\thetable}{F\arabic{table}} \renewcommand{\thepage}{F\arabic{page}} @@ -21,9 +23,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -237,7 +240,6 @@ legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, leg <- "Weather stations" legend("topleft", leg, pch=23, pt.bg="#333333", pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ Colder winter temperatures during the months of November through March result in frozen precipitation (snow). @@ -274,7 +276,6 @@ axis.Date(1, at=at, tcl=0, cex.axis=0.6, lwd=-1, labels=xlabs, padj=1.5) leg <- c("Chocolate Gulch SNOTEL", "Hailey HADS", "Picabo AgriMet") legend("topright", leg, col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ \newpage @@ -394,7 +395,6 @@ FUN <- function(i, col) { \caption{Picabo \label{fig:graph_precip_c}} <>= FUN("Picabo", "#7570B3") - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -444,7 +444,6 @@ legend(mean(par("usr")[1:2]), 1, levels(y)[idxs], fill=cols[idxs], horiz=TRUE, cex=0.7, bty="n", xpd=TRUE, xjust=0.5, yjust=0, border=c("#333333", cols[idxs][-1])) box(lwd=0.5) -invisible(dev.off()) @ % ========================================================================= @@ -854,7 +853,6 @@ FUN <- function(i) { \caption{August 2008 \label{fig:map_et_b}} <>= FUN(et[["200808"]]) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -920,7 +918,6 @@ FUN <- function(xlim) { \caption{2007 through 2010 \label{fig:graph_et_d}} <>= FUN(c("2007-01-01", "2011-01-01")) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -968,7 +965,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse leg <- as.character(levels(polys@data$GroupSymbol)) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Soil Types"))) -invisible(dev.off()) @ <>= @@ -1016,7 +1012,6 @@ PlotMap(r, breaks=breaks, xlim=usr.map[1:2], ylim=usr.map[3:4], labels=list(at=at, labels=labels), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ % ========================================================================= @@ -1081,7 +1076,6 @@ FUN <- function(i) { \caption{August 2008 \label{fig:map_rate_b}} <>= FUN(rs[["200808"]]) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -1147,7 +1141,6 @@ FUN <- function(xlim) { \caption{2007 through 2010 \label{fig:graph_rate_d}} <>= FUN(c("2007-01-01", "2011-01-01")) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} diff --git a/inst/doc/sir20165080_AppendixG.R b/inst/doc/sir20165080_AppendixG.R index 761b2bb..2448e08 100644 --- a/inst/doc/sir20165080_AppendixG.R +++ b/inst/doc/sir20165080_AppendixG.R @@ -2,9 +2,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -90,7 +91,6 @@ legend("topleft", leg, pch=c(22, NA, 22), lwd=c(NA, 1, NA), col=cols, box.lwd=0.5, bg="#FFFFFFE7") AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- Pal <- function(...) { @@ -133,7 +133,6 @@ FUN(usr.map.n.3, max.dev.dim=c(21, 56)) ## ----map_canals_d, echo=FALSE, results="asis", fig.width=fin.map.n.small.0[1], fig.height=fin.map.n.small.0[2]---- FUN(usr.map.n.4, pos=3, max.dev.dim=c(21, 56)) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Canal systems mapped to the model grid (\\textit{\\textbf{A}}) north of Ketchum, (\\textit{\\textbf{B}}) south of Ketchum and north of Gimlet, (\\textit{\\textbf{C}}) south of Gimlet and north of Hailey, (\\textit{\\textbf{D}}) south of Hailey and north of Bellevue, and (\\textit{\\textbf{E}}) south of Bellevue. \\label{fig:map_canals}" @@ -141,7 +140,6 @@ v <- c(paste("Maps showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nchar ## ----map_canals_e, echo=FALSE, results="asis", fig.width=fin.map.s.0[1], fig.height=fin.map.s.0[2]---- FUN(usr.map.s, credit) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "The Bypass Canal and City of Bellevue wastewater treatment plant ponds mapped to the model grid." @@ -173,7 +171,6 @@ text(suppressWarnings(getSpatialPolygonsLabelPoints(bellevue.wwtp.ponds)), labels="Bellevue WWTP Ponds", cex=0.5, col="#333333", font=1, pos=2) legend("topright", as.character(levels(r)[[1]]$RechSite), fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) ## ----table_irr_lands_year, echo=FALSE, results="asis"-------------------- d <- irr.lands.year @@ -231,7 +228,6 @@ FUN("2009") ## ----map_land_use_g, echo=FALSE, results="asis", fig.width=fin.map.0[1], fig.height=fin.map.0[2]---- FUN("2010") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Wetlands and non-irrigated public land parcels in the Wood River Valley and surrounding areas, Idaho." @@ -247,7 +243,6 @@ legend("topright", c("Wetlands", "Public parcels"), fill=c("#59A80F", "#CDBB99C0 border=c(NA, "#755C3BC0"), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") box(lwd=0.5) -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- x <- irr.entities@data @@ -321,11 +316,9 @@ FUN(usr.map.n.3) ## ----map_entities_d, echo=FALSE, results="asis", fig.width=fin.map.n[1], fig.height=fin.map.n[2]---- FUN(usr.map.n.4) -invisible(dev.off()) ## ----map_entities_e, echo=FALSE, results="asis", fig.width=fin.map.s.0[1], fig.height=fin.map.s.0[2]---- FUN(usr.map.s) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Irrigation entities mapped to irrigated lands in the southern part of the model grid during the 2008 growing season (April--October)." @@ -349,7 +342,6 @@ ids <- unique(crop(r, extent(usr.map.s))) legend("topright", as.character(ids), fill=cols[ids], ncol=2, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Irrigation Entity"))) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Irrigation entity water sources in the Wood River Valley, Idaho." @@ -367,7 +359,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse legend("topright", levels(polys@data$Source), fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Source"))) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Water supply and fate of water in municipal areas." @@ -398,5 +389,4 @@ points(pod.wells[ is.obs, ], pch=pchs[2], cex=pt.cexs[2], lwd=0.5, col=NA, bg=co leg <- paste(c("Unmeasured", "Measured"), "groundwater diversion") legend("topright", leg, col=NA, pt.bg=cols, pch=pchs, pt.cex=pt.cexs, pt.lwd=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) diff --git a/inst/doc/sir20165080_AppendixG.Rnw b/inst/doc/sir20165080_AppendixG.Rnw index 2486ba2..4466614 100644 --- a/inst/doc/sir20165080_AppendixG.Rnw +++ b/inst/doc/sir20165080_AppendixG.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{G\arabic{figure}} \renewcommand{\thetable}{G\arabic{table}} \renewcommand{\thepage}{G\arabic{page}} @@ -21,9 +23,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -315,7 +318,6 @@ legend("topleft", leg, pch=c(22, NA, 22), lwd=c(NA, 1, NA), col=cols, box.lwd=0.5, bg="#FFFFFFE7") AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) @ <>= @@ -376,7 +378,6 @@ FUN <- function(usr, credit=NULL, pos=1, max.dev.dim=c(43, 56)) { \caption{South of Hailey and north of Bellevue \label{fig:map_canals_d}} <>= FUN(usr.map.n.4, pos=3, max.dev.dim=c(21, 56)) - invisible(dev.off()) @ \end{subfigure} <>= @@ -393,7 +394,6 @@ FUN <- function(usr, credit=NULL, pos=1, max.dev.dim=c(43, 56)) { \caption{South of Bellevue \label{fig:map_canals_e}} <>= FUN(usr.map.s, credit) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -453,7 +453,6 @@ text(suppressWarnings(getSpatialPolygonsLabelPoints(bellevue.wwtp.ponds)), labels="Bellevue WWTP Ponds", cex=0.5, col="#333333", font=1, pos=2) legend("topright", as.character(levels(r)[[1]]$RechSite), fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= @@ -580,7 +579,6 @@ FUN <- function(i) { \caption{2010 \label{fig:map_land_use_g}} <>= FUN("2010") - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -602,7 +600,6 @@ legend("topright", c("Wetlands", "Public parcels"), fill=c("#59A80F", "#CDBB99C0 border=c(NA, "#755C3BC0"), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") box(lwd=0.5) -invisible(dev.off()) @ \newpage @@ -747,7 +744,6 @@ FUN <- function(usr) { \caption{South of Hailey and north of Bellevue \label{fig:map_entities_d}} <>= FUN(usr.map.n.4) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -759,7 +755,6 @@ FUN <- function(usr) { \caption{South of Bellevue \label{fig:map_entities_e}} <>= FUN(usr.map.s) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -789,7 +784,6 @@ ids <- unique(crop(r, extent(usr.map.s))) legend("topright", as.character(ids), fill=cols[ids], ncol=2, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Irrigation Entity"))) -invisible(dev.off()) @ Irrigation entities are further subdivided by the irrigation water source type; @@ -815,7 +809,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse legend("topright", levels(polys@data$Source), fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Source"))) -invisible(dev.off()) @ \clearpage @@ -1047,7 +1040,6 @@ points(pod.wells[ is.obs, ], pch=pchs[2], cex=pt.cexs[2], lwd=0.5, col=NA, bg=co leg <- paste(c("Unmeasured", "Measured"), "groundwater diversion") legend("topright", leg, col=NA, pt.bg=cols, pch=pchs, pt.cex=pt.cexs, pt.lwd=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= diff --git a/inst/doc/sir20165080_AppendixH.R b/inst/doc/sir20165080_AppendixH.R index a95f683..48fa42f 100644 --- a/inst/doc/sir20165080_AppendixH.R +++ b/inst/doc/sir20165080_AppendixH.R @@ -2,9 +2,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -147,7 +148,6 @@ legend("topright", leg, pch=21, col=col, pt.bg=bg, pt.lwd=0.25, pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topleft") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Location of geolocated driller wells and Public Land Survey System (PLSS)-located driller wells in the Wood River Valley, Idaho." @@ -173,7 +173,6 @@ leg <- c(paste("Geolocated driller well", no.1), legend("topright", leg, pch=pch, col=col, pt.bg=bg, pt.cex=cex, pt.lwd=0.25, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Location of two Sun Valley Water and Sewer District (SVWSD) production wells, and wells in The Nature Conservancy (TNC) groundwater monitoring network, Wood River Valley, Idaho." @@ -198,7 +197,6 @@ text(p.2, labels=p.2@data$id, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- c("SVWSD well", "TNC well") legend("topright", leg, pch=pch, col=col, pt.bg=col, pt.cex=cex, pt.lwd=0.25, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "River network and streamflow measurement sites in the Wood River Valley, Idaho." @@ -238,8 +236,6 @@ legend("topright", leg, pch=c(NA, 24, 24), lwd=c(1, NA, NA), col=c("#3399CC", "#A40802", "#A40802"), pt.bg=c(NA, "#A40802", "#FDFDFD"), pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) - ## ----echo=FALSE---------------------------------------------------------- GetSiteNo <- function(i) { sprintf("site No.~%s", sites@data$site.no[sites@data$SiteNo %in% i]) @@ -346,7 +342,6 @@ text(p, labels=p@data$ret.no, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- c("Irrigation canal or pond return", "Exchange-well return") legend("topright", leg, pch=c(23, 21), lwd=NA, col=cols, pt.bg=cols, pt.cex=0.7, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) ## ----table_ret, echo=FALSE, results="asis"------------------------------- d <- p.ret@data @@ -398,7 +393,6 @@ text(p.div, labels=lab, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- "Stream diversion" legend("topright", leg, pch=22, lwd=NA, col="#F98C64", pt.bg="#F98C64", pt.cex=0.7, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) ## ----table_div, echo=FALSE, results="asis"------------------------------- d <- p.div@data @@ -463,7 +457,6 @@ points(sites[sites@data$SiteNo %in% ids, ], pch=24, cex=0.7, legend("topright", format(unique(reach.numbers)), lwd=1, col=unique(cols), pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", title=expression(bold("Reach"))) -invisible(dev.off()) ## ----table_reach, echo=FALSE, results="asis"----------------------------- d <- data.frame(ReachNo=seq_along(reach.names)) @@ -532,7 +525,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Stream-aquifer flow exchange in the Big Wood River, Hailey to Stanton Crossing river reach." @@ -549,7 +541,6 @@ PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) legend("bottomright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Stream-aquifer flow exchange in the Willow Creek river reach." @@ -561,7 +552,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Stream-aquifer flow exchange in Silver Creek, above Sportsman Access river reach." @@ -573,7 +563,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) ## ----echo=FALSE---------------------------------------------------------- subreaches <- river.reaches @@ -617,8 +606,6 @@ legend("topright", leg, lwd=1, col=cols[order(reach.numbers)], ncol=2, pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", title=expression(bold("Subreach"))) -invisible(dev.off()) - ## ----table_subreach, echo=FALSE, results="asis"-------------------------- d <- subreaches@data[order(subreaches@data$ReachNo), c("ReachNo", "Reach", "BigReachNo")] d$BigReachNo[duplicated(d$BigReachNo)] <- "" @@ -798,9 +785,8 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=3, offset=0.4) legend("topleft", leg, lwd=2, col=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Outlet Boundaries"))) -AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0, -9)), - sub.label=list("Map area", adj=c(1.9, 0.5)), loc="topright") -invisible(dev.off()) +AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0.25, -9)), + sub.label=list("Map area", adj=c(1.65, 0.5)), loc="topright") ## ----table_zones, echo=FALSE, results="asis"----------------------------- d <- kriging.zones@data @@ -869,7 +855,6 @@ FUN(2L) ## ----map_pilot_c, echo=FALSE, results="asis", fig.width=fin.map.0[1], fig.height=fin.map.0[2]---- FUN(3L) -invisible(dev.off()) ## ----table_hk_sc, echo=FALSE, results="asis"----------------------------- d <- zone.properties @@ -942,7 +927,6 @@ leg <- c("Underflow boundaries", "Aquifer extent") legend("topright", leg, pch=c(15, 22), lwd=NA, col=cols, pt.bg="#33333366", pt.cex=c(0.7, 1.5), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", seg.len=1.4) -invisible(dev.off()) ## ----include=FALSE------------------------------------------------------- v <- "Irrigation entities in the Wood River Valley, Idaho." @@ -960,7 +944,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse leg <- c("Irrigation entity", "Irrigation entity with possible natural sub-irrigation") legend("topright", leg, fill=cols, border="#FFFFFFCC", inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) ## ----table_weights, echo=FALSE, results="asis"--------------------------- d <- data.frame(typ=c("Groundwater level", "", "", "", "", diff --git a/inst/doc/sir20165080_AppendixH.Rnw b/inst/doc/sir20165080_AppendixH.Rnw index c7504d9..55a5c8f 100644 --- a/inst/doc/sir20165080_AppendixH.Rnw +++ b/inst/doc/sir20165080_AppendixH.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{H\arabic{figure}} \renewcommand{\thetable}{H\arabic{table}} \renewcommand{\thepage}{H\arabic{page}} @@ -21,9 +23,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -326,7 +329,6 @@ legend("topright", leg, pch=21, col=col, pt.bg=bg, pt.lwd=0.25, pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topleft") -invisible(dev.off()) @ <>= @@ -354,7 +356,6 @@ leg <- c(paste("Geolocated driller well", no.1), legend("topright", leg, pch=pch, col=col, pt.bg=bg, pt.cex=cex, pt.lwd=0.25, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ <>= @@ -381,7 +382,6 @@ text(p.2, labels=p.2@data$id, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- c("SVWSD well", "TNC well") legend("topright", leg, pch=pch, col=col, pt.bg=col, pt.cex=cex, pt.lwd=0.25, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ \clearpage @@ -434,8 +434,6 @@ leg <- c("Rivers and streams", "Streamgage with continuous record", legend("topright", leg, pch=c(NA, 24, 24), lwd=c(1, NA, NA), col=c("#3399CC", "#A40802", "#A40802"), pt.bg=c(NA, "#A40802", "#FDFDFD"), pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") - -invisible(dev.off()) @ % ========================================================================= @@ -602,7 +600,6 @@ text(p, labels=p@data$ret.no, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- c("Irrigation canal or pond return", "Exchange-well return") legend("topright", leg, pch=c(23, 21), lwd=NA, col=cols, pt.bg=cols, pt.cex=0.7, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ <>= @@ -665,7 +662,6 @@ text(p.div, labels=lab, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- "Stream diversion" legend("topright", leg, pch=22, lwd=NA, col="#F98C64", pt.bg="#F98C64", pt.cex=0.7, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ <>= @@ -779,7 +775,6 @@ points(sites[sites@data$SiteNo %in% ids, ], pch=24, cex=0.7, legend("topright", format(unique(reach.numbers)), lwd=1, col=unique(cols), pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", title=expression(bold("Reach"))) -invisible(dev.off()) @ <>= @@ -871,7 +866,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) @ % Big Wood River, Hailey to Stanton Crossing reach @@ -906,7 +900,6 @@ PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) legend("bottomright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ % Willow Creek reach @@ -937,7 +930,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) @ % Silver Creek above Sportsman Access reach @@ -969,7 +961,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) @ % Silver Creek, Sportsman Access to near Picabo @@ -1076,8 +1067,6 @@ leg <- format(reach.numbers[order(reach.numbers)]) legend("topright", leg, lwd=1, col=cols[order(reach.numbers)], ncol=2, pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", title=expression(bold("Subreach"))) - -invisible(dev.off()) @ <>= @@ -1318,9 +1307,8 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=3, offset=0.4) legend("topleft", leg, lwd=2, col=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Outlet Boundaries"))) -AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0, -9)), - sub.label=list("Map area", adj=c(1.9, 0.5)), loc="topright") -invisible(dev.off()) +AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0.25, -9)), + sub.label=list("Map area", adj=c(1.65, 0.5)), loc="topright") @ % ========================================================================= @@ -1466,7 +1454,6 @@ FUN <- function(layer) { \caption{Model layer 3 \label{fig:map_pilot_c}} <>= FUN(3L) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -1629,7 +1616,6 @@ leg <- c("Underflow boundaries", "Aquifer extent") legend("topright", leg, pch=c(15, 22), lwd=NA, col=cols, pt.bg="#33333366", pt.cex=c(0.7, 1.5), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", seg.len=1.4) -invisible(dev.off()) @ % === @@ -1663,7 +1649,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse leg <- c("Irrigation entity", "Irrigation entity with possible natural sub-irrigation") legend("topright", leg, fill=cols, border="#FFFFFFCC", inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= diff --git a/inst/extdata/README.md b/inst/extdata/README.md index 663b01d..1d3ca78 100644 --- a/inst/extdata/README.md +++ b/inst/extdata/README.md @@ -31,6 +31,9 @@ The only unprocessed dataset used during model construction and not included und | +-- div.gw.csv (groundwater diversions) | +-- div.sw.csv (surface-water diversions) | +-- div.ww.csv (discharge from wastewater treatment plants) +| +-- pod.gw.csv (points of diversion for groundwater) +| +-- pod.wells.zip (well sites) +| +-- priority.cuts.csv (priority cuts) +-- et (evapotranspiration) | +-- et.199501.tif (mean rates of evapotranspiration for Jan 1995) | +-- et.199502.tif (mean rates of evapotranspiration for Feb 1995) diff --git a/inst/misc/README.md b/inst/misc/README.md index fbaa58c..c8ad528 100644 --- a/inst/misc/README.md +++ b/inst/misc/README.md @@ -8,7 +8,6 @@ Files accessed during vignette and model-archive construction. . +-- miscellaneous.Rnw (part of the analysis for main body of report) +-- modelgeoref-template.txt (template for modelgeoref.txt file in the model archive) -+-- preamble.tex (preamble of the LaTeX input files for package vignettes) +-- Rd2.tex (documentation for package) +-- README.md +-- readme-template.txt (template for readme file in the model archive) diff --git a/inst/misc/Rd2.tex b/inst/misc/Rd2.tex index 3111e68..3b9e773 100644 --- a/inst/misc/Rd2.tex +++ b/inst/misc/Rd2.tex @@ -1,7 +1,7 @@ \documentclass[a4paper]{book} \usepackage[times,inconsolata,hyper]{Rd} \usepackage{makeidx} -\usepackage[utf8,latin1]{inputenc} +\usepackage[utf8]{inputenc} % @SET ENCODING@ % \usepackage{graphicx} % @USE GRAPHICX@ \makeindex{} \begin{document} @@ -12,291 +12,57 @@ \chapter*{} \end{center} \begin{description} \raggedright{} -\item[Type]\AsIs{Package} -\item[Version]\AsIs{1.0.3} -\item[Date]\AsIs{2016-07-05} +\inputencoding{utf8} \item[Title]\AsIs{Wood River Valley Groundwater-Flow Model} -\item[Author]\AsIs{Jason C. Fisher} -\item[Maintainer]\AsIs{Jason C. Fisher }\email{jfisher@usgs.gov}\AsIs{} -\item[Depends]\AsIs{R (>= 3.2.0), sp, rgdal, raster} -\item[Imports]\AsIs{methods, rgeos, igraph, dplyr} -\item[Suggests]\AsIs{RCurl, knitr, xtable, sfsmisc, animation, viridis, colorspace} -\item[SystemRequirements]\AsIs{PEST (>= 13.0, optional)} +\item[Version]\AsIs{1.1.0} \item[Description]\AsIs{A processing program for the groundwater-flow model of the Wood River Valley aquifer system, south-central Idaho. Included in the package is -MODFLOW-USG version 1.2, a U.S. Geological Survey groundwater-flow model.} +MODFLOW-USG version 1.3, a U.S. Geological Survey groundwater-flow model.} +\item[Depends]\AsIs{ +R (>= 3.2.0)} +\item[Imports]\AsIs{ +dplyr, +grDevices, +graphics, +inlmisc, +methods, +sp, +stats, +raster, +rgdal, +rgeos} +\item[Suggests]\AsIs{ +animation, +dataRetrieval, +git2r, +knitr, +leaflet, +sfsmisc, +viridis, +xtable} +\item[SystemRequirements]\AsIs{PEST (>= 13.0, optional)} \item[License]\AsIs{CC0} \item[Copyright]\AsIs{This software is in the public domain because it contains materials that originally came from the United States Geological Survey (USGS), an -agency of the United States Department of Interior. For more information, see -the official USGS copyright policy at -http://www.usgs.gov/visual-id/credit\_usgs.html\#copyright} +agency of the United States Department of Interior. For more information, +see the official USGS copyright policy at +https://www2.usgs.gov/visual-id/credit\_usgs.html} \item[URL]\AsIs{}\url{https://github.com/USGS-R/wrv}\AsIs{} \item[BugReports]\AsIs{}\url{https://github.com/USGS-R/wrv/issues}\AsIs{} -\item[ByteCompile]\AsIs{yes} -\item[LazyData]\AsIs{yes} +\item[Encoding]\AsIs{UTF-8} +\item[ByteCompile]\AsIs{true} +\item[LazyData]\AsIs{true} \item[LazyDataCompression]\AsIs{xz} \item[VignetteBuilder]\AsIs{knitr} +\item[RoxygenNote]\AsIs{5.0.1} \end{description} \Rdcontents{\R{} topics documented:} \inputencoding{utf8} -\HeaderA{AddBubbles}{Add Bubble Map to Plot}{AddBubbles} -\keyword{hplot}{AddBubbles} -% -\begin{Description}\relax -This function can be used to add a bubble map to a plot. -Proportional circle symbols are used to represent spatial point data, where symbol area varies in proportion to an attribute variable. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -AddBubbles(x, y = NULL, z, zlim = NULL, inches = c(0, 0.2), - scaling = c("perceptual", "mathematical"), - bg.pos = "red", bg.neg = "blue", fg = NA, lwd = 0.25, - cex = 0.7, format = NULL, draw.legend = TRUE, - loc = c("bottomleft", "topleft", "topright", "bottomright"), - inset = 0.02, breaks = NULL, break.labels = NULL, - quantile.breaks = FALSE, make.intervals = FALSE, - title = NULL, subtitle = NULL, add = TRUE) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{x, y}] \code{numeric}; the x and y coordinates for the centers of the circle symbols. They can be specified in any way which is accepted by \code{xy.coords}. -\item[\code{z}] \code{numeric}; is the attribute variable. -\item[\code{zlim}] \code{numeric}; the minimum and maximum \code{z} values that circle symbols are plotted; defaults to the range of the finite values of \code{z}. -\item[\code{inches}] \code{numeric}; a vector of length 2 specifying the radii limits for the drawn circle symbol. -\item[\code{scaling}] \code{character}; selects the proportional symbol mapping algorithm to be used; either \code{"perceptual"} or \code{"mathematical"} scaling (Tanimura and others, 2006). -\item[\code{bg.pos, bg.neg}] \code{character} or \code{function}; the fill color(s) for circle symbols corresponding to positive and negative \code{z} values, respectively. -A color palette also may be specified. -\item[\code{fg}] \code{character}; the outer-line color for circle symbols. -Specify an \code{NA} value to remove the symbols outer line, and a \code{NULL} value to match the outer-line color with the symbols fill color. -\item[\code{lwd}] \code{numeric}; is the line width for drawing circle symbols. -\item[\code{cex}] \code{numeric}; the character expansion factor for legend labels. -\item[\code{format}] \code{character}; the formatting for legend values, see \code{formatC} for options. -\item[\code{draw.legend}] \code{logical}; if \code{TRUE}, a legend is drawn. -\item[\code{loc}] \code{character}; the position of the legend in the main plot region: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote scale location. -\item[\code{inset}] \code{numeric}; the inset distance of the legend from the margins as a fraction of the main plot region. -Defaults to 2 percent of the axis range. -\item[\code{breaks}] \code{numeric}; a set of finite breakpoints for the legend circle symbols. -\item[\code{break.labels}] \code{character}; a vector of break labels with length equal to \code{breaks}. -\item[\code{quantile.breaks}] \code{logical}; if \code{TRUE}, \code{breaks} are set to the sample quantiles of \code{z}. -\item[\code{make.intervals}] \code{logical}; if \code{TRUE}, represent \code{z} within intervals. -See \code{findInterval} function for details. -\item[\code{title}] \code{character}; the main title to be placed at the top of the legend. -\item[\code{subtitle}] \code{character}; a legend subtitle to be placed below the main title. -\item[\code{add}] \code{logical}; if \code{TRUE}, circle symbols (and an optional legend) are added to an existing plot. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -Symbols are sequentially drawn in decreasing order of circle diameter. -\end{Details} -% -\begin{Value} -Primarily used for the side-effect of a bubble map drawn on the current graphics device. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{References}\relax -Tanimura, S., Kuroiwa, C., and Mizota, T., 2006, Proportional Symbol Mapping in R: Journal of Statistical Software, v. 15, no. 5, 7 p. -\end{References} -% -\begin{SeeAlso}\relax -\code{symbols} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -n <- 50L -x <- cbind(runif(n, 1, 10), runif(n, 1, 10)) -z <- runif(n, -5000, 10000) -AddBubbles(x, z = z, fg = "green", lwd = 2, title = "Title", loc = "topright", - breaks=pretty(z, n = 8), add = FALSE) - -Pal1 <- colorRampPalette(c("#F4A582", "#CA0020")) -Pal2 <- colorRampPalette(c("#92C5DE", "#0571B0")) -AddBubbles(x, z = z, bg.pos = Pal1, bg.neg = Pal2, add = FALSE) - -AddBubbles(x, z = z, bg.pos = Pal1, bg.neg = Pal2, add = FALSE, - make.intervals = TRUE) - -AddBubbles(x, z = runif(n, 10, 10000), title = "Quantiles", bg.pos = topo.colors, - quantile.breaks = TRUE, fg = NULL, add = FALSE) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{AddColorKey}{Add Color Key to Plot}{AddColorKey} -\keyword{hplot}{AddColorKey} -% -\begin{Description}\relax -This function can be used to add a color key to a plot. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -AddColorKey(mai, is.categorical, breaks, col, at = NULL, labels = TRUE, - scientific = FALSE, explanation = NULL, padx = 0.2) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{mai}] \code{numeric}; a numerical vector of the form \code{c(bottom, left, top, right)} which gives the margin size specified in inches (optional). -\item[\code{is.categorical}] \code{logical}; if \code{TRUE}, color-key values represent categorical data; otherwise, these data values are assumed continuous. -\item[\code{breaks}] \code{numeric}; a set of finite numeric breakpoints for the colors: must have one more breakpoint than color and be in increasing order. -\item[\code{col}] \code{character}; a vector of colors to be used in the plot. -This argument requires \code{breaks} specification for continuous data. -For continuous data there should be one less color than breaks; whereas, categorical data require a color for each category. -\item[\code{at}] \code{numeric}; the points at which tick-marks and labels are to be drawn, only applicable for continuous data. -The tick-marks will be located at the color breaks if the length of \code{at} is greater than or equal to one minus the length of \code{breaks}. -\item[\code{labels}] \code{logical} or \code{character}; this can either be a logical value specifying whether (numerical) annotations are to be made at the tickmarks, or a character or expression vector of labels to be placed at the tickpoints. -\item[\code{scientific}] \code{logical}; indicates if axes labels should be formatted for scientific notation, see \code{\LinkA{ToScientific}{ToScientific}} for details. -\item[\code{explanation}] \code{character}; a label that describes the data values. -\item[\code{padx}] \code{numeric}; the inner padding for the left and right margins specified in inches. -\end{ldescription} -\end{Arguments} -% -\begin{Value} -Used for the side-effect of a color key drawn on the current graphics device. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{\LinkA{PlotCrossSection}{PlotCrossSection}}, \code{\LinkA{PlotMap}{PlotMap}} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -dev.new(width = 7, height = 2) - -AddColorKey(is.categorical = FALSE, breaks = 0:10, scientific = TRUE, - explanation = "Example description for data variables in meters.") -AddColorKey(is.categorical = FALSE, breaks = 0:10, at = pretty(0:10)) -AddColorKey(is.categorical = FALSE, breaks = seq(0.5, 10.5, by = 1), at = 1:10) - -AddColorKey(is.categorical = TRUE, labels = LETTERS[1:5]) -AddColorKey(is.categorical = TRUE, col = terrain.colors(5)) - -graphics.off() -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{AddInsetMap}{Add Inset Map to Plot}{AddInsetMap} -\keyword{hplot}{AddInsetMap} -% -\begin{Description}\relax -This function can be used to add an inset map to a plot. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -AddInsetMap(p, col = c("#D8D8D8", "#BFA76F"), - main.label = list(label = NA, adj = NULL), - sub.label = list(label = NA, adj = NULL), - loc = c("bottomleft", "topleft", "topright", "bottomright"), - inset = 0.02, width = NULL) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{p}] \code{SpatialPolygons}; the polygon describing the large map. -\item[\code{col}] \code{character}; a vector of length 2 giving the colors for filling the large map polygon \code{p} and the smaller plot extent rectangle. -\item[\code{main.label}] \code{list}; a list with components \code{label} and \code{adj}. -The text label and position (\code{x} and \code{y} adjustment of the label) for the large map, respectively. -\item[\code{sub.label}] \code{list}; identical to the \code{main.label} argument but for the plot extent rectangle. -\item[\code{loc}] \code{character}; the position of the inset map in the main plot region: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote scale location. -\item[\code{inset}] \code{numeric}; the inset distance from the margins as a fraction of the main plot region. -Defaults to 2 percent of the axis range. -\item[\code{width}] \code{numeric}; the width of the inset map, in inches. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -The smaller axis-aligned rectangle (relative to the larger map polygon) is defined by the user coordinate extent of the main plot region, see \code{par("usr")}. -\end{Details} -% -\begin{Value} -Used for the side-effect of a inset map drawn on the current graphics device. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{\LinkA{PlotMap}{PlotMap}} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -PlotMap(alluvium.thickness@crs, bg.image = hill.shading, reg.axs = FALSE) -AddInsetMap(idaho, width = 1, main.label = list("IDAHO", adj = c(-0.4, -4.9)), - sub.label = list("Map area", adj = c(0.5, 2.5)), loc = "topright") - -graphics.off() -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{AddScaleBar}{Add Scale Bar to Plot}{AddScaleBar} -\keyword{hplot}{AddScaleBar} -% -\begin{Description}\relax -This function can be used to add a scale bar to a plot. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -AddScaleBar(asp = 1, unit = NULL, is.lonlat = FALSE, - loc = c("bottomleft", "topleft", "topright", "bottomright"), - offset = c(0, 0), lab.vert.exag = NULL) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{asp}] \code{numeric}; the \emph{y/x} aspect ratio for spatial axes. -\item[\code{unit}] \code{character}; axis unit of measurement, for example \code{"METERS"}. -\item[\code{is.lonlat}] \code{logical}; if \code{TRUE}, plot coordinates are in longitude and latitude. -\item[\code{loc}] \code{character}; the position of the scale bar in the plot region: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote scale location. -\item[\code{offset}] \code{numeric}; the \code{x} and \code{y} adjustments of the scale bar, in inches. -\item[\code{lab.vert.exag}] \code{logical}; if \code{TRUE}, a label is drawn specifying the vertical exaggeration. -\end{ldescription} -\end{Arguments} -% -\begin{Value} -Used for the side-effect of a scale bar drawn on the current graphics device. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{\LinkA{PlotCrossSection}{PlotCrossSection}}, \code{\LinkA{PlotMap}{PlotMap}} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -plot(-100:100, -100:100, type = "n", xlab = "x", ylab = "y", asp = 2) -AddScaleBar(2, unit = "FEET", loc = "topleft") -AddScaleBar(2, unit = "METERS", loc = "bottomright", offset = c(-0.2, 0)) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} \HeaderA{alluvium.extent}{Extent of Alluvium Unit}{alluvium.extent} \keyword{datasets}{alluvium.extent} % \begin{Description}\relax -The estimated extent of alluvium unit in the Wood River Valley, south-central Idaho. +Estimated extent of alluvium unit in the Wood River Valley aquifer system. \end{Description} % \begin{Usage} @@ -306,8 +72,9 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing 1 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialPolygonsDataFrame class containing 1 Polygons. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -316,13 +83,17 @@ \chapter*{} \end{Source} % \begin{References}\relax -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +Bartolino, J.R., and Adkins, C.B., 2012, +Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: +U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., +available at \url{http://pubs.usgs.gov/sir/2012/5053/}. \end{References} % \begin{Examples} \begin{ExampleCode} -plot(alluvium.extent, col = "#BFA76F") +sp::plot(alluvium.extent, col = "#BFA76F") str(alluvium.extent) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -330,7 +101,7 @@ \chapter*{} \keyword{datasets}{alluvium.thickness} % \begin{Description}\relax -The estimated thickness of the Quaternary sediment in the Wood River Valley aquifer system, South-Central Idaho. +Estimated thickness of the Quaternary sediment in the Wood River Valley aquifer system. \end{Description} % \begin{Usage} @@ -340,26 +111,33 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{RasterLayer} class. +An object of RasterLayer class. Each cell on the surface grid represents a depth measured from land surface in meters. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -The spatial grid is composed of 565 rows and 429 columns, and has cell sizes that are constant at 100 meters by 100 meters. +The spatial grid is composed of 565 rows and 429 columns, +and has cell sizes that are constant at 100 meters by 100 meters. \end{Format} % \begin{Source}\relax -This dataset is a revised version of Plate 1 in Bartolino and Adkins (2012). +Revised version of Plate 1 in Bartolino and Adkins (2012). \end{Source} % \begin{References}\relax -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +Bartolino, J.R., and Adkins, C.B., 2012, +Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: +U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., +available at \url{http://pubs.usgs.gov/sir/2012/5053/}. \end{References} % \begin{Examples} \begin{ExampleCode} col <- rainbow(255, start = 0.0, end = 0.8) -image(alluvium.thickness, col = col, asp = 1, axes = FALSE, xlab = "", ylab = "") +raster::image(alluvium.thickness, col = col, asp = 1, axes = FALSE, + xlab = "", ylab = "") summary(alluvium.thickness) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -367,7 +145,7 @@ \chapter*{} \keyword{datasets}{basalt.extent} % \begin{Description}\relax -The estimated extent of the basalt unit underlying the alluvial Wood River Valley aquifer system. +Estimated extent of the basalt unit underlying the alluvial Wood River Valley aquifer system. \end{Description} % \begin{Usage} @@ -377,24 +155,29 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing 1 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialPolygonsDataFrame class containing 1 Polygons. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Extent defined by Bartolino and Adkins (2012, Plate 1). +Extent defined by Bartollino and Adkins (2012, Plate 1). \end{Source} % \begin{References}\relax -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +Bartolino, J.R., and Adkins, C.B., 2012, +Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: +U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., +available at \url{http://pubs.usgs.gov/sir/2012/5053/}. \end{References} % \begin{Examples} \begin{ExampleCode} -plot(basalt.extent, col = "#BEAED4", border = NA) -plot(alluvium.extent, add = TRUE) +sp::plot(basalt.extent, col = "#BEAED4", border = NA) +sp::plot(alluvium.extent, add = TRUE) str(basalt.extent) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -402,7 +185,7 @@ \chapter*{} \keyword{datasets}{bellevue.wwtp.ponds} % \begin{Description}\relax -The location of the Bellevue Waste Water Treatment Plant ponds. +Location of the Bellevue Waste Water Treatment Plant ponds. \end{Description} % \begin{Usage} @@ -412,8 +195,9 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygons} class containing 1 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialPolygonsDataFrame class containing 1 Polygons. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -423,105 +207,8 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(bellevue.wwtp.ponds) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{BumpDisconnectCells}{Adjustment for Vertically Disconnected Cells}{BumpDisconnectCells} -\keyword{utilities}{BumpDisconnectCells} -% -\begin{Description}\relax -This function decreases model cell values (such as, land-surface elevations) in the lower raster layer if they violate a minimum vertical overlap between adjacent cells. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -BumpDisconnectCells(rs, min.overlap = 2, bump.by = 0.1, max.itr = 1e+04) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{rs}] \code{RasterStack}; a collection of two raster layers, the first and second layers represent the top and bottom of a model layer. -\item[\code{min.overlap}] \code{numeric}; the minimum vertical overlap between adjacent cells. -\item[\code{bump.by}] \code{numeric}; the amount to decrease a cell value by during each iteration of the algorithm. -\item[\code{max.itr}] \code{numeric}; the maximum number of iterations. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -During each iteration of the algorithm: -(1) Cells are identified that violate the minimum vertical overlap between adjacent cells; that is, the bottom of cell \code{i} is greater than or equal to the top of an adjacent cell \code{j} minus the minimum overlap specified by the \code{min.overlap} argument. -(2) For cells violating the minimum vertical overlap, lower raster layer (\code{rs[[2]]}) values are decreased by the value specified in the \code{bump.by} argument. -\end{Details} -% -\begin{Value} -Returns a \code{RasterLayer} that can be added to \code{rs[[2]]} to ensure connectivity between cells. -Cell values in the returned raster grid represent vertical adjustments. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{Examples} -\begin{ExampleCode} -set.seed(0) -r.top <- raster(ncols = 10, nrows = 10) -r.bot <- raster(ncols = 10, nrows = 10) -r.top[] <- rnorm(ncell(r.top), mean = 12) -r.bot[] <- rnorm(ncell(r.bot), mean = 10) -summary(r.top - r.bot) - -r <- BumpDisconnectCells(stack(r.top, r.bot), min.overlap = 0.1) -plot(r.bot + r) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{BumpRiverStage}{Adjustment for Implausible River Stage}{BumpRiverStage} -\keyword{utilities}{BumpRiverStage} -% -\begin{Description}\relax -This function decreases stage values in river cells if they are implausible with respect to water always flowing downhill. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -BumpRiverStage(r, outlets, min.drop = 1e-06) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{r}] \code{RasterLayer}; each cell on the surface grid represents a river stage. -\item[\code{outlets}] \code{SpatialPoints*}, \code{SpatialLines*}, \code{SpatialPolygons*} or \code{Extent}; the location of discharge outlets. -The \code{rasterize} function is used to locate outlet cells in the raster grid \code{r}. -\item[\code{min.drop}] \code{numeric}; the minimum drop in stage between adjacent river cells. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -The \Rhref{http://en.wikipedia.org/wiki/Lee_algorithm}{Lee algorithm} (Lee, 1961) is used to identify flow paths among the modeled river cells. -An analysis of river cell stage values along a flow path identifies any problematic cells that are obstructing downhill surface-water flow. -Stage values for these problematic cells are then lowered to an acceptable elevation. -\end{Details} -% -\begin{Value} -Returns a \code{RasterLayer} with cell values representing the vertical change in stream stage. -These changes can be added to \code{r} to ensure that water always flows downhill. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{References}\relax -Lee, C.Y., 1961, An algorithm for path connections and its applications: IRE Transactions on Electronic Computers, v. EC-10, no. 2, p. 346--365. -\end{References} -% -\begin{Examples} -\begin{ExampleCode} -## Not run: # see uncalibrated-model vignette +sp::plot(bellevue.wwtp.ponds) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -529,7 +216,7 @@ \chapter*{} \keyword{datasets}{bypass.canal} % \begin{Description}\relax -The location of the Bypass Canal. +Location of the Bypass Canal in the Wood River Valley. \end{Description} % \begin{Usage} @@ -539,8 +226,9 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialLines} class containing 4 \code{Lines}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialLines class containing 4 Lines. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -550,7 +238,8 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(bypass.canal) +sp::plot(bypass.canal) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -568,14 +257,13 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 19 records and the following variables: +An object of class data.frame with 19 records and the following variables: \begin{description} -\item[EntityName] is the name of the irrigation entity served by the canal system. -\item[SeepFrac] is the estimated canal seepage as a fraction of diversions. +\item[EntityName] name of the irrigation entity served by the canal system. +\item[SeepFrac] estimated canal seepage as a fraction of diversions. \end{description} - \end{Format} % \begin{Source}\relax @@ -596,6 +284,7 @@ \chapter*{} cex.axis = 0.7, cex.lab = 0.7, las = 1, xlab = "Seepage fraction") graphics.off() + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -603,7 +292,7 @@ \chapter*{} \keyword{datasets}{canals} % \begin{Description}\relax -The canal systems in the Wood River Valley and surrounding areas. +Canal systems in the Wood River Valley and surrounding areas. \end{Description} % \begin{Usage} @@ -613,14 +302,14 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialLinesDataFrame} class containing 113 \code{Lines} and a \code{data.frame} with the following variable: +An object of SpatialLinesDataFrame class containing +113 Lines and a data.frame with the following variable: \begin{description} -\item[EntityName] the name of the irrigation entity served by the canal system. -\item[Name] the local canal name. +\item[EntityName] name of the irrigation entity served by the canal system. +\item[Name] local canal name \end{description} - \end{Format} % \begin{Source}\relax @@ -633,8 +322,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(canals, col = "#3399CC") +sp::plot(canals, col = "#3399CC") str(canals@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -652,13 +342,16 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 11 points. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialPointsDataFrame class containing 11 points. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources (\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on April 15, 2015 +Idaho Department of Water Resources +(\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +accessed on April 15, 2015 \end{Source} % \begin{Examples} @@ -666,8 +359,9 @@ \chapter*{} str(cities) col <- "#333333" -plot(cities, pch = 15, cex = 0.8, col = col) +sp::plot(cities, pch = 15, cex = 0.8, col = col) text(cities, labels = cities@data$FEATURE_NA, col = col, cex = 0.5, pos = 1, offset = 0.4) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -675,7 +369,9 @@ \chapter*{} \keyword{datasets}{clay.extent} % \begin{Description}\relax -The estimated extent of the clay confining unit (aquitard) separating the unconfined aquifer from the underlying confined aquifer in the Wood River Valley. +Estimated extent of the clay confining unit (aquitard) separating the +unconfined aquifer from the underlying confined aquifer in the +Wood River Valley aquifer system. \end{Description} % \begin{Usage} @@ -685,26 +381,32 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing 2 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialPolygonsDataFrame class containing 2 Polygons. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax Extent defined by Moreland (1977, fig. 3 in USGS Open-File report). -Moreland (1977) shows an outlier by Picabo that is assumed to indicate confined conditions in the basalt and not the lake sediments. +Moreland (1977) shows an outlier by Picabo that is assumed to +indicate confined conditions in the basalt and not the lake sediments. \end{Source} % \begin{References}\relax -Moreland, J.A., 1977, Ground water-surface water relations in the Silver Creek area, Blaine County, Idaho: Boise, Idaho Department of Water Resources, Water Information Bulletin 44, 42 p., 5 plates in pocket, accessed January 31, 2012. -Also published as U.S. Geological Survey Open-File report 77-456, 66 p., available at \url{http://pubs.er.usgs.gov/pubs/ofr/ofr77456}. +Moreland, J.A., 1977, Ground water-surface water relations in the Silver Creek area, +Blaine County, Idaho: Boise, Idaho Department of Water Resources, Water Information Bulletin 44, +42 p., 5 plates in pocket, accessed January 31, 2012. +Also published as U.S. Geological Survey Open-File report 77-456, 66 p., +available at \url{http://pubs.er.usgs.gov/pubs/ofr/ofr77456}. \end{References} % \begin{Examples} \begin{ExampleCode} -plot(clay.extent, col = "#FDC086", border = NA) -plot(alluvium.extent, add = TRUE) +sp::plot(clay.extent, col = "#FDC086", border = NA) +sp::plot(alluvium.extent, add = TRUE) str(clay.extent) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -722,18 +424,19 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 1,213 records and the following variables: +An object of class data.frame with 1,213 records and the following variables: \begin{description} -\item[WaterRight] is the name of the supplemental groundwater right. -\item[CombWaterRight] is the name of the surface-water right that shares a combined limit with the groundwater right. -\item[Source] is the river or stream source name for the surface-water right. -\item[WaterUse] is the authorized beneficial use for the surface-water right. -\item[MaxDivRate] is the authorized maximum diversion rate for the surface-water right, in cubic meters per day. -\item[Pdate] is the priority date of the surface-water right. +\item[WaterRight] name of the supplemental groundwater right. +\item[CombWaterRight] name of the surface-water right that shares a +combined limit with the groundwater right. +\item[Source] river or stream source name for the surface-water right. +\item[WaterUse] authorized beneficial use for the surface-water right. +\item[MaxDivRate] authorized maximum diversion rate for the surface-water right, +in cubic meters per day. +\item[Pdate] priority date of the surface-water right. \end{description} - \end{Format} % \begin{Source}\relax @@ -744,6 +447,7 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} str(comb.sw.irr) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -752,7 +456,8 @@ \chapter*{} % \begin{Description}\relax Groundwater diversions recorded by Water District 37 or municipal water providers. -Groundwater is diverted from the aquifer by means of either pumping wells or flowing-artesian wells. +Groundwater is diverted from the aquifer by means of either pumping wells or +flowing-artesian wells. \end{Description} % \begin{Usage} @@ -762,29 +467,34 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 7,292 records and the following variables: +An object of class data.frame with 7,292 records and the following variables: \begin{description} -\item[YearMonth] is the year and month during which diversions were recorded, with a required date format of \code{YYYYMM}. -\item[Diversion] is the name of the well. -\item[Reach] is the name of the river subreach into which the well water is discharged; only applicable to exchange wells. -\item[BigReach] is the name of the river reach into which the well water is discharged; only applicable to exchange wells. -\item[EntityName] is the name of the irrigation entity which the well supplies water. -\item[WMISNumber] is the well number in the Idaho Department of Water Resources (IDWR) Water Measurement Information System. -\item[GWDiv] is the volume of water diverted during the month, in cubic meters. +\item[YearMonth] year and month during which diversions were recorded, +with a required date format of YYYYMM. +\item[Diversion] name of the well +\item[Reach] name of the river subreach into which the well water is discharged; +only applicable to exchange wells. +\item[BigReach] name of the river reach into which the well water is discharged; +only applicable to exchange wells. +\item[EntityName] name of the irrigation entity which the well supplies water. +\item[WMISNumber] well number in the Idaho Department of Water Resources (IDWR) +Water Measurement Information System. +\item[GWDiv] volume of water diverted during the month, in cubic meters. \end{description} - \end{Format} % \begin{Source}\relax -IDWR, accessed on December 11, 2014; -compiled data records from Water District 37 and 37M, City of Ketchum, Sun Valley Water and Sewer District, City of Hailey, and City of Bellevue. +Idaho Department of Water Resources (IDWR), accessed on December 11, 2014; +compiled data records from Water District 37 and 37M, City of Ketchum, +Sun Valley Water and Sewer District, City of Hailey, and City of Bellevue. \end{Source} % \begin{Examples} \begin{ExampleCode} str(div.gw) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -792,7 +502,8 @@ \chapter*{} \keyword{datasets}{div.ret.exch} % \begin{Description}\relax -The location of streamflow diversions, irrigation canal or pond returns, and exchange well returns. +Location of streamflow diversions, irrigation canal or pond returns, and +exchange well returns. \end{Description} % \begin{Usage} @@ -802,17 +513,20 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 117 points with the following variables: +An object of SpatialPointsDataFrame class containing 117 points with the +following variables: \begin{description} -\item[Name] a local name for the diversion/return site. -\item[Type] the data type: ``Diversion'', ``Return'', and ``Exchange well inflow''. -\item[LocSource] the data source. -\item[Big] the corresponding river reach. +\item[Name] local name for the diversion/return site. +\item[Type] data type, either ``Diversion'', ``Return'', or +``Exchange well inflow''. +\item[LocSource] data source +\item[Big] corresponding river reach \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -822,8 +536,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(div.ret.exch) +sp::plot(div.ret.exch) str(div.ret.exch@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -841,28 +556,30 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 15,550 records and the following variables: +An object of class data.frame with 15,550 records and the following variables: \begin{description} -\item[YearMonth] is the year and month during which diversions were recorded, with a required date format of \code{YYYYMM}. -\item[Diversion] is the name of the surface-water diversion. -\item[Reach] is the river subreach from which the water is diverted. -\item[BigReach] is the river reach from which the water is diverted. -\item[EntityName] is the name of the irrigation entity which the diversion supplies water. -\item[SWDiv] is the volume of water diverted during the month, in cubic meters. +\item[YearMonth] year and month during which diversions were recorded, +with a required date format of YYYYMM. +\item[Diversion] name of the surface-water diversion. +\item[Reach] river subreach from which the water is diverted. +\item[BigReach] river reach from which the water is diverted. +\item[EntityName] name of the irrigation entity which the diversion supplies water. +\item[SWDiv] volume of water diverted during the month, in cubic meters. \end{description} - \end{Format} % \begin{Source}\relax Idaho Department of Water Resources, accessed on December 11, 2014; -compiled data records from Water District 37 and 37M, City of Hailey, City of Bellevue, City of Ketchum, and Sun Valley Water and Sewer District. +compiled data records from Water District 37 and 37M, City of Hailey, +City of Bellevue, City of Ketchum, and Sun Valley Water and Sewer District. \end{Source} % \begin{Examples} \begin{ExampleCode} str(div.sw) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -880,80 +597,34 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 1,182 records and the following variables: +An object of class data.frame with 1,182 records and the following variables: \begin{description} -\item[YearMonth] is the year and month during which diversions were recorded, with a required date format of \code{YYYYMM}. -\item[Return] is the name of the wastewater treatment plant. -\item[Reach] is the name of the river subreach to which treated effluent is discharged; only applicable to wastewater treatment plants that discharge to the river. -\item[BigReach] is the name of the river reach to which treated effluent is discharged; only applicable to wastewater treatment plants that discharge to the river. -\item[EntityName] is the name of the irrigation entity served by the wastewater treatment plant. -\item[WWDiv] is the volume of wastewater discharged during the month, in cubic meters. +\item[YearMonth] year and month during which diversions were recorded, +with a required date format of YYYYMM. +\item[Return] name of the wastewater treatment plant. +\item[Reach] name of the river subreach to which treated effluent is discharged; +only applicable to wastewater treatment plants that discharge to the river. +\item[BigReach] name of the river reach to which treated effluent is discharged; +only applicable to wastewater treatment plants that discharge to the river. +\item[EntityName] name of the irrigation entity served by the wastewater treatment plant. +\item[WWDiv] volume of wastewater discharged during the month, in cubic meters. \end{description} - \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources and U.S. Geological Survey, accessed on August 11, 2014; -compiled data records from the U.S. Environmental Protection Agency for plants that discharge to the river, and from records of the Idaho Department of Environmental Quality for plants that discharge to land application. +Idaho Department of Water Resources and U.S. Geological Survey, +accessed on August 11, 2014; compiled data records from the +U.S. Environmental Protection Agency for plants that discharge to the river, +and from records of the Idaho Department of Environmental Quality for +plants that discharge to land application. \end{Source} % \begin{Examples} \begin{ExampleCode} str(div.ww) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{DownloadFile}{Download File from the Internet}{DownloadFile} -\keyword{IO}{DownloadFile} -% -\begin{Description}\relax -This function downloads a file from the Internet. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -DownloadFile(url, dest.dir = tempdir(), mode = NULL, extract = TRUE, - max.attempts = 10L, wait.time = 30) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{url}] \code{character}; the URL (or FTP) of a resource to be downloaded. -\item[\code{dest.dir}] \code{character}; the directory where the downloaded file is saved. -\item[\code{mode}] \code{character}; the mode with which to write the file, such as \code{"w"}, \code{"wb"} (binary), \code{"a"} (append) and \code{"ab"}. -\item[\code{extract}] \code{logical}; if \code{TRUE}, an attempt is made to extract files from the file archive. -\item[\code{max.attempts}] \code{integer}; the maximum number of attempts to download a file. -\item[\code{wait.time}] \code{numeric}; the time to wait between download attempts, in seconds. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -This function requires package \pkg{RCurl}. -\end{Details} -% -\begin{Value} -Returns the file path(s) to the downloaded file (or uncompressed files). -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{CFILE}, \code{curlPerform} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -## Not run: -url <- paste0("https://raw.githubusercontent.com/USGS-R/", - "wrv/master/inst/extdata/alluvium.extent.zip") -files <- DownloadFile(url) -unlink(files) -## End(Not run) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -962,7 +633,8 @@ \chapter*{} % \begin{Description}\relax Polygons used to define the locations of drain boundaries in the model domain. -The polygons clip the line segments along the aquifer boundary (see \code{\LinkA{alluvium.extent}{alluvium.extent}}), and model cells intersecting these clipped-line segments are defined as boundary cells. +The polygons clip the line segments along the aquifer boundary (see \code{\LinkA{alluvium.extent}{alluvium.extent}}), +and model cells intersecting these clipped-line segments are defined as boundary cells. \end{Description} % \begin{Usage} @@ -972,30 +644,36 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing a set of 2 \code{Polygons} and a \code{data.frame} with the following variable: +An object of SpatialPolygonsDataFrame class containing a set of 2 Polygons and +a data.frame with the following variable: \begin{description} -\item[Name] is an identifier for the polygon. -\item[cond] is the drain conductance in square meters per day. -\item[elev] is the drain threshold elevation in meters above the North American Vertical Datum of 1988 (NAVD 88). +\item[Name] identifier for the polygon. +\item[cond] drain conductance in square meters per day. +\item[elev] drain threshold elevation in meters above the +North American Vertical Datum of 1988 (NAVD 88). \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax U.S. Geological Survey, accessed on March 27, 2015; -a Keyhole Markup Language (\Rhref{http://en.wikipedia.org/wiki/Kml}{KML}) file created in \Rhref{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in areas of known drains. +a Keyhole Markup Language (\Rhref{http://en.wikipedia.org/wiki/Kml}{KML}) file created in +\Rhref{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in +areas of known drains. \end{Source} % \begin{Examples} \begin{ExampleCode} str(drains) -plot(drains, border = "red") -plot(alluvium.extent, add = TRUE) +sp::plot(drains, border = "red") +sp::plot(alluvium.extent, add = TRUE) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1005,7 +683,8 @@ \chapter*{} \begin{Description}\relax A summary of dry river bed and stream fed conditions in the Wood River Valley, Idaho. Stream reaches on the Big Wood River between Glendale and Wood River Ranch are episodically dry; -these dry periods are specified for calendar months when water diversions to the Bypass Canal begins before the 16th of the month and ends after the 15th of the month. +these dry periods are specified for calendar months when water diversions to the +Bypass Canal begins before the 16th of the month and ends after the 15th of the month. \end{Description} % \begin{Usage} @@ -1015,14 +694,14 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 12 records and the following variables: +An object of data.frame class with 12 records and the following variables: \begin{description} -\item[Reach] is the stream reach name. -\item[199501, \dots, 201012] are logical values indicating whether the stream reach exhibits dry-bed conditions during a stress period. +\item[Reach] stream reach name +\item[199501,\dots,201012] logical values indicating whether the stream reach exhibits +dry-bed conditions during a stress period. \end{description} - \end{Format} % \begin{Source}\relax @@ -1033,6 +712,7 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} str(drybed) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1040,7 +720,7 @@ \chapter*{} \keyword{datasets}{efficiency} % \begin{Description}\relax -The irrigation efficiency of irrigation entities. +The irrigation efficiency of irrigation entities in the Wood River Valley, Idaho. \end{Description} % \begin{Usage} @@ -1050,15 +730,15 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 88 records and the following variables: +An object of data.frame class with 88 records and the following variables: \begin{description} -\item[EntityName] is the name of the irrigation entity which the irrigation efficiency is applied. -\item[Eff] is the estimated irrigation efficiency, the ratio of the amount of water consumed by the crop to the amount of water supplied through irrigation. -\item[Comment] a brief comment on irrigation conditions. +\item[EntityName] name of the irrigation entity which the irrigation efficiency is applied. +\item[Eff] estimated irrigation efficiency, the ratio of the amount of +water consumed by the crop to the amount of water supplied through irrigation. +\item[Comment] brief comment on irrigation conditions. \end{description} - \end{Format} % \begin{Source}\relax @@ -1068,6 +748,7 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} str(efficiency) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1076,7 +757,8 @@ \chapter*{} % \begin{Description}\relax Irrigation entities and their components in the Wood River Valley and surrounding areas. -An irrigation entity is defined as an area served by a group of surface-water and/or groundwater diversion(s). +An irrigation entity is defined as an area served by a group of surface-water and/or +groundwater diversion(s). \end{Description} % \begin{Usage} @@ -1086,36 +768,39 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{list} object with components of \code{SpatialPolygonsDataFrame-class}. +An object of list class with components of SpatialPolygonsDataFrame-class. There are a total of 192 components, one for each month in the 1995--2010 time period. -Linked \code{data.frame} objects have the following variables: +Linked data.frame objects have the following variables: \begin{description} -\item[EntitySrce] a concatenation of the \code{EntityName} and \code{Source} character strings. -\item[mean.et] the mean evapotranspiration (ET) on irrigated and semi-irrigated lands in meters. -\item[area] the area of irrigated and semi-irrigated lands in square meters. -\item[PrecipZone] the name of the precipitation zone. -See \code{\LinkA{precip.zones}{precip.zones}} dataset for details. -\item[et.vol] the volume of ET on irrigated and semi-irrigated lands in cubic meters. -\item[precip.vol] the volume of precipitation on irrigated and semi-irrigated lands in cubic meters. -\item[cir.vol] the volume of crop irrigation requirement in cubic meters (ET minus precipitation). -\item[EntityName] is the name of the irrigation entity. -\item[Source] is the water source: ``Mixed'' for a mixture of surface water and groundwater, ``SW Only'' for surface water only, and ``GW Only'' for groundwater only. +\item[EntitySrce] concatenation of the \code{EntityName} and \code{Source} character strings. +\item[mean.et] mean evapotranspiration (ET) on irrigated and semi-irrigated lands in meters. +\item[area] area of irrigated and semi-irrigated lands in square meters. +\item[PrecipZone] name of the precipitation zone; +see \code{\LinkA{precip.zones}{precip.zones}} dataset for details. +\item[et.vol] volume of ET on irrigated and semi-irrigated lands in cubic meters. +\item[precip.vol] volume of precipitation on irrigated and semi-irrigated lands in cubic meters. +\item[cir.vol] volume of crop irrigation requirement in cubic meters (ET minus precipitation). +\item[EntityName] name of the irrigation entity. +\item[Source] water source, either ``Mixed'' for a mixture of surface water and groundwater, +``SW Only'' for surface water only, or ``GW Only'' for groundwater only. \end{description} - \end{Format} % \begin{Source}\relax -Calculated from the \code{\LinkA{irr.entities}{irr.entities}}, \code{\LinkA{wetlands}{wetlands}}, \code{\LinkA{public.parcels}{public.parcels}}, \code{\LinkA{irr.lands.year}{irr.lands.year}}, \code{\LinkA{et}{et}}, and \code{\LinkA{precipitation}{precipitation}} datasets; +Calculated from the \code{\LinkA{irr.entities}{irr.entities}}, \code{\LinkA{wetlands}{wetlands}}, +\code{\LinkA{public.parcels}{public.parcels}}, \code{\LinkA{irr.lands.year}{irr.lands.year}}, \code{\LinkA{et}{et}}, and +\code{\LinkA{precipitation}{precipitation}} datasets; see the \file{package-datasets} vignette for the \R{} code used in this calculation. \end{Source} % \begin{Examples} \begin{ExampleCode} names(entity.components) -plot(entity.components[["199506"]]) +sp::plot(entity.components[["199506"]]) print(entity.components[["199506"]]) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1124,7 +809,8 @@ \chapter*{} % \begin{Description}\relax Evapotranspiration (ET) in the Wood River Valley and surrounding areas. -Defined as the amount of water lost to the atmosphere via direct evaporation, transpiration by vegetation, or sublimation from snow covered areas. +Defined as the amount of water lost to the atmosphere via direct evaporation, +transpiration by vegetation, or sublimation from snow covered areas. \end{Description} % \begin{Usage} @@ -1134,9 +820,11 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{RasterStack} class containing 192 \code{RasterLayer} objects, one layer for each month in the 1995-2010 time period. +An object of RasterStack class containing 192 RasterLayer objects, +one layer for each month in the 1995-2010 time period. Each cell on a layers surface grid represents the monthly depth of ET in meters. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -1150,8 +838,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} +sp::plot(et[["199505"]]) print(et) -plot(et[["199505"]]) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1159,7 +848,7 @@ \chapter*{} \keyword{datasets}{et.method} % \begin{Description}\relax -The methods used to estimate monthly distributions of evapotranspiration (ET) rate. +Methods used to estimate monthly distributions of evapotranspiration (ET) rate. \end{Description} % \begin{Usage} @@ -1169,21 +858,22 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 122 records with the following variables: +An object of data.frame class with 122 records with the following variables: \begin{description} -\item[YearMonth] The year and month during which the method was applied, with a required date format of \code{YYYYMM}. -\item[ETMethod] An identifier that indicates the method used to estimate ET values. -Identifiers include: +\item[YearMonth] year and month during which the method was applied, +with a required date format of YYYYMM. +\item[ETMethod] Identifier that indicates the method used to estimate ET values. +Identifiers include either ``Allen-Robison'', the Allen and Robison method (Allen and Robison, 2007); -``METRIC'', the Mapping Evapotranspiration at high Resolution and with Internalized Calibration (METRIC) model (Allen and others, 2010a); -``NDVI'', the Normalized Difference Vegetation Index (NDVI) method (Allen and others, 2010b); -``Interpolation'', interpolation from known ET data; and +``METRIC'', the Mapping Evapotranspiration at high Resolution and with +Internalized Calibration (METRIC) model (Allen and others, 2010a); +``NDVI'', the Normalized Difference Vegetation Index (NDVI) method +(Allen and others, 2010b); +``Interpolation'', interpolation from known ET data; or ``METRIC-NDVI'', a combination of METRIC and NDVI methods. - \end{description} - \end{Format} % \begin{Source}\relax @@ -1191,11 +881,16 @@ \chapter*{} \end{Source} % \begin{References}\relax -Allen, R., and Robison, C.W., 2007, Evapotranspiration and consumptive water requirements for Idaho, University of Idaho, Kimberly, Idaho. +Allen, R., and Robison, C.W., 2007, Evapotranspiration and +consumptive water requirements for Idaho, University of Idaho, Kimberly, Idaho. -Allen, R., Tasumi, M., Trezza, R., and Kjaersgaard, J., 2010a, METRIC mapping evapotranspiration at high resolution applications manual for Landsat satellite imagery version 2.07, University of Idaho, Kimberly, ID. +Allen, R., Tasumi, M., Trezza, R., and Kjaersgaard, J., 2010a, +METRIC mapping evapotranspiration at high resolution applications manual for +Landsat satellite imagery version 2.07, University of Idaho, Kimberly, ID. -Allen, R., Robison, C.W., Garcia, M., Trezza, R., Tasumi, M., and Kjaersgaard, J., 2010b, ETrF vs NDVI relationships for southern Idaho for rapid estimation of evapotranspiration, University of Idaho, Kimberly, ID. +Allen, R., Robison, C.W., Garcia, M., Trezza, R., Tasumi, M., and Kjaersgaard, J., 2010b, +ETrF vs NDVI relationships for southern Idaho for rapid estimation of evapotranspiration, +University of Idaho, Kimberly, ID. ET Idaho: \url{http://data.kimberly.uidaho.edu/ETIdaho/} \end{References} @@ -1203,141 +898,7 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} str(et.method) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{ExportRasterStack}{Export Raster Stack}{ExportRasterStack} -\keyword{IO}{ExportRasterStack} -% -\begin{Description}\relax -This function writes a raster-stack, a collection of raster layers, to local directories using multiple file formats. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -ExportRasterStack(rs, path, zip = "", col = rainbow(250, start = 0.0, end = 0.8)) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{rs}] \code{RasterStack}; a collection of \code{\LinkA{RasterLayer}{RasterLayer.Rdash.class}} objects with the same extent and resolution. -\item[\code{path}] \code{character}; path name to write raster stack. -\item[\code{zip}] \code{character}; if there is no zip program on your path (on windows), you can supply the full path to a \file{zip.exe} here, in order to make a KMZ file. -\item[\code{col}] \code{character}; a vector of colors. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -Five local directories are created under \code{path} and named after their intended file formats: -Comma-Separated Values (\file{csv}), -Portable Network Graphics (\file{png}), -georeferenced TIFF (\file{tif}), -R Data (\file{rda}), -and Keyhole Markup Language (\file{kml}). -For its reference system, \file{kml} uses geographic coordinates: longitude and latitude components as defined by the World Geodetic System of 1984. -Therefore, the conversion of gridded data between cartographic projections may introduce a new source of error. - -To install \file{zip.exe} on windows, download the latest binary version from the \Rhref{http://www.info-zip.org/Zip.html#Downloads}{Info-ZIP} website: -select one of the given FTP locations, enter directory \file{win32}, download \file{zip300xn.zip}, and extract. -\end{Details} -% -\begin{Value} -None. Used for the side-effect files written to disk. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{writeRaster} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -## Not run: -f <- file.path(getwd(), "SIR2016-5080/ancillary/uncalibrated/data/rda/rasters.rda") -load(file = f) -ExportRasterStack(rs, tempdir()) -## End(Not run) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{ExtractAlongTransect}{Extract Raster Values Along Transect Line}{ExtractAlongTransect} -\keyword{utilities}{ExtractAlongTransect} -% -\begin{Description}\relax -This function extracts values from raster layer(s) along a user defined transect line. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -ExtractAlongTransect(transect, r) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{transect}] \code{SpatialPoints} or \code{SpatialLines}; transect line or its vertices. -\item[\code{r}] \code{RasterLayer}, \code{RasterStack}, or \code{RasterBrick}; the raster layer(s) -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -The transect line is described using a simple polygonal chain. -The transect line and raster layer(s) must be specified in a coordinate reference system. -\end{Details} -% -\begin{Value} -A \code{list} is returned with components of class \code{SpatialPointsDataFrame}. -These components represent continuous piecewise line segments along the transect. -The following variables are specified for each coordinate point in the line segment: -\begin{ldescription} -\item[\code{dist}] \code{numeric}; the distance along the transect line. -\item[\code{2, ..., n}] \code{numeric}; the extracted value for each raster layer in \code{r}, where column names match their respective raster layer name. -\end{ldescription} -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{\LinkA{PlotCrossSection}{PlotCrossSection}} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -coords <- rbind(c(-100, -90), c(80, 90), c(80, 0), c(40, -40)) -crs <- CRS("+proj=longlat +datum=WGS84") -transect <- SpatialPoints(coords, proj4string = crs) -r <- raster(nrows = 10, ncols = 10, ymn = -80, ymx = 80, crs = crs) -names(r) <- "value" -set.seed(0) -r[] <- runif(ncell(r)) -r[4, 6] <- NA -plot(r, xlab = "x", ylab = "y") -lines(SpatialLines(list(Lines(list(Line(coords)), ID = "Transect")), proj4string = crs)) -points(transect, pch = 21, bg = "red") -segs <- ExtractAlongTransect(transect, r) -for (i in 1:length(segs)) points(segs[[i]], col = "blue") - -dev.new() -xlab <- "Distance along transect" -ylab <- "Raster value" -xlim <- range(vapply(segs, function(seg) range(seg@data[, "dist"]), c(0, 0))) -ylim <- range(vapply(segs, function(seg) range(seg@data[, "value"], na.rm = TRUE), - c(0, 0))) -plot(NA, type = "n", xlab = xlab, ylab = ylab, xlim = xlim, ylim = ylim) -for (i in 1:length(segs)) - lines(segs[[i]]@data[, c("dist", "value")], col = rainbow(length(segs))[i]) -coords <- coordinates(transect) -n <- length(transect) -d <- cumsum(c(0, as.matrix(dist((coords)))[cbind(1:(n - 1), 2:n)])) -abline(v = d, col = "grey", lty = 2) -mtext(paste0("(", paste(head(coords, 1), collapse = ", "), ")"), adj = 0) -mtext(paste0("(", paste(tail(coords, 1), collapse = ", "), ")"), adj = 1) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1346,7 +907,8 @@ \chapter*{} % \begin{Description}\relax The daily mean discharge at streamgages in the Big Wood River Valley, Idaho. -Discharge records bracket the 1992-2014 time period and are based on records with quality assurance code of approved (`A'). +Discharge records bracket the 1992-2014 time period and are based on +records with quality assurance code of approved (`A'). \end{Description} % \begin{Usage} @@ -1356,20 +918,26 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 8,315 records and the following variables: +An object of data.frame class with 8,315 records and the following variables: \begin{description} -\item[Date] is the date during which discharge was averaged. -\item[13135500] is the daily mean discharge in cubic meters per day, recorded at the USGS \Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} Big Wood River near Ketchum streamgage. -\item[13139510] is the daily mean discharge in cubic meters per day, recorded at the USGS \Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} Big Wood River at Hailey streamgage. -\item[13140800] is the daily mean discharge in cubic meters per day, recorded at the USGS \Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} Big Wood River at Stanton Crossing near Bellevue streamgage. +\item[Date] date during which discharge was averaged. +\item[13135500] daily mean discharge in cubic meters per day, recorded at the USGS +\Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} +Big Wood River near Ketchum streamgage. +\item[13139510] daily mean discharge in cubic meters per day, recorded at the USGS +\Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} +Big Wood River at Hailey streamgage. +\item[13140800] daily mean discharge in cubic meters per day, recorded at the USGS +\Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} +Big Wood River at Stanton Crossing near Bellevue streamgage. \end{description} - \end{Format} % \begin{Source}\relax -National Water Information System (\Rhref{http://waterdata.usgs.gov/nwis}{NWIS}), accessed on January 8, 2015 +National Water Information System (\Rhref{http://waterdata.usgs.gov/nwis}{NWIS}), +accessed on January 8, 2015 \end{Source} % \begin{Examples} @@ -1378,12 +946,14 @@ \chapter*{} col <- c("red", "blue", "green") ylab <- paste("Discharge in cubic", c("meters per day", "acre-foot per year")) -PlotGraph(gage.disch, ylab = ylab, col = col, lty = 1:3, conversion.factor = 0.29611) -leg <- sprintf("USGS %s", names(gage.disch)[-1]) +inlmisc::PlotGraph(gage.disch, ylab = ylab, col = col, lty = 1:3, + conversion.factor = 0.29611) +leg <- sprintf("USGS \%s", names(gage.disch)[-1]) legend("topright", leg, col = col, lty = 1:3, inset = 0.02, cex = 0.7, box.lty = 1, bg = "#FFFFFFE7") graphics.off() + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1392,8 +962,9 @@ \chapter*{} % \begin{Description}\relax The daily mean gage height at streamgages in the Big Wood River Valley, Idaho. -Gage height records bracket the 1987-2014 and are based on records with quality assurance codes of working (`W'), in review (`R'), and approved (`A'). - +Gage height records bracket the 1987-2014 and are based on records with +quality assurance codes of working (`W'), in review (`R'), and +approved (`A'). \end{Description} % \begin{Usage} @@ -1403,23 +974,34 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 9,980 records and the following variables: +An object of data.frame class with 9,980 records and the following variables: \begin{description} -\item[Date] is the date during which gage height was averaged. -\item[13135500] is the daily mean gage height in meters, recorded at the USGS \Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} Big Wood River near Ketchum streamgage. -\item[13139510] is the daily mean gage height in meters, recorded at the USGS \Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} Big Wood River at Hailey streamgage. -\item[13140800] is the daily mean gage height in meters, recorded at the USGS \Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} Big Wood River at Stanton Crossing near Bellevue streamgages. +\item[Date] date during which gage height was averaged. +\item[13135500] daily mean gage height in meters, recorded at the USGS +\Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} +Big Wood River near Ketchum streamgage. +\item[13139510] daily mean gage height in meters, recorded at the USGS +\Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} +Big Wood River at Hailey streamgage. +\item[13140800] daily mean gage height in meters, recorded at the USGS +\Rhref{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} +Big Wood River at Stanton Crossing near Bellevue streamgages. \end{description} - \end{Format} % \begin{Source}\relax -Data queried from the National Water Information System (\Rhref{http://waterdata.usgs.gov/nwis}{NWIS}) database on December 15, 2014, by Ross Dickinson (USGS). -Records recorded on May 26-28, 1991 and March 15-22, 1995 were reassigned quality assurance codes of `I' because of assumed ice build-up. -Missing data at the Big Wood River near Ketchum gage was estimated using a linear regression model based on recorded gage-height data at the Big Wood River at Hailey and Near Ketchum streamgages. -Missing data at the Stanton Crossing near Bellevue gage was replaced with average gage-height values recorded at this gage. +Data queried from the National Water Information System +(\Rhref{http://waterdata.usgs.gov/nwis}{NWIS}) database on December 15, 2014, +by Ross Dickinson (USGS). +Records recorded on May 26-28, 1991 and March 15-22, 1995 were reassigned +quality assurance codes of `I' because of assumed ice build-up. +Missing data at the Big Wood River near Ketchum gage was estimated using a +linear regression model based on recorded gage-height data at the Big Wood River at +Hailey and Near Ketchum streamgages. +Missing data at the Stanton Crossing near Bellevue gage was replaced with +average gage-height values recorded at this gage. \end{Source} % \begin{Examples} @@ -1428,45 +1010,14 @@ \chapter*{} col <- c("red", "blue", "green") ylab <- paste("Gage height in", c("meters", "feet")) -PlotGraph(gage.height, ylab = ylab, col = col, lty = 1:3, conversion.factor = 3.28084) -leg <- sprintf("USGS %s", names(gage.height)[-1]) +inlmisc::PlotGraph(gage.height, ylab = ylab, col = col, lty = 1:3, + conversion.factor = 3.28084) +leg <- sprintf("USGS \%s", names(gage.height)[-1]) legend("topright", leg, col = col, lty = 1:3, inset = 0.02, cex = 0.7, box.lty = 1, bg = "#FFFFFFE7") graphics.off() -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{GetDaysInMonth}{Get Number of Days in a Year and Month}{GetDaysInMonth} -\keyword{utilities}{GetDaysInMonth} -% -\begin{Description}\relax -This function determines the number of days in a year and month. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -GetDaysInMonth(x) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{x}] \code{character} or \code{integer}; a vector of year and month values, with a required date format of \code{YYYYMM}. -\end{ldescription} -\end{Arguments} -% -\begin{Value} -Returns an integer vector indicating the number of days in each year and month value specified in \code{x}. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{Examples} -\begin{ExampleCode} -GetDaysInMonth(c("199802", "199804", "200412")) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1479,45 +1030,66 @@ \chapter*{} % \begin{Usage} \begin{verbatim} -GetSeasonalMult(x, reduction, d.in.mv.ave, tr.stress.periods) +GetSeasonalMult(x, reduction, d.in.mv.ave, fixed.dates) \end{verbatim} \end{Usage} % \begin{Arguments} \begin{ldescription} -\item[\code{x}] \code{data.frame}; a time series with \code{Date} and \code{numeric} components. -\item[\code{reduction}] \code{numeric}; is the signal amplitude reduction, a dimensionless quantity. -Its magnitude should be greater than or equal to 1, where a value of 1 indicates no reduction in the signal amplitude. -\item[\code{d.in.mv.ave}] \code{numeric}; is the number of days in the moving average subset. -\item[\code{tr.stress.periods}] \code{Date}; a vector giving the start and end dates for each model stress period. +\item[\code{x}] data.frame. +Time series data (observations) with components of class Date and numeric. + +\item[\code{reduction}] numeric. +Signal amplitude reduction, a dimensionless quantity. +Its magnitude should be greater than or equal to 1; +where a value of 1 indicates no reduction in the signal amplitude. + +\item[\code{d.in.mv.ave}] numeric. +Number of days in the moving average subset. + +\item[\code{fixed.dates}] Date. +Vector of equally spaced dates, these are the fixed locations where the moving average is calculated. +The final date is neglected. \end{ldescription} \end{Arguments} % \begin{Details}\relax -A simple moving average is first calculated for each month using the previous data (such as the previous 9-months of stage data recorded at a streamgage). -The seasonal average of the monthly moving average is then passed through a signal amplitude reduction algorithm. -The reduced values are then divided by the mean of the seasonal reduced data to give the seasonal fraction of the mean (seasonal multiplier). +A simple moving average is first calculated at dates specified in \code{fixed.dates} +using past observational data in \code{x} +(such as the previous 9-months of stage data recorded at a streamgage). +The seasonal average of the moving average is then passed through a signal amplitude reduction algorithm. +The reduced values are then divided by the mean of the seasonal reduced data to give +the seasonal fraction of the mean (also known as the seasonal scaling index). \end{Details} % \begin{Value} -An object of \code{data.frame} class with \code{Date} and \code{numeric} components; that is, the starting date and multiplier for each season. +Returns an object of class data.frame with the following variables: +\begin{description} + +\item[\code{names(x)[1]}] start date for each season in \code{fixed.dates}. +\item[multiplier] seasonal scaling index + +\end{description} + \end{Value} % \begin{Author}\relax -J.C. Fisher and J.R. Bartolino, U.S. Geological Survey, Idaho Water Science Center +J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center A.H. Wylie and J. Sukow, Idaho Department of Water Resources \end{Author} % \begin{Examples} \begin{ExampleCode} -tr.interval <- as.Date(c("1995-01-01", "2011-01-01")) -tr.stress.periods <- seq(tr.interval[1] , tr.interval[2], "1 month") -m <- GetSeasonalMult(gage.disch[, c("Date", "13139510")], 2, 273.932, tr.stress.periods) -f <- vapply(tributaries$Flow, function(i) m$multiplier * i, rep(0, nrow(m))) -colnames(f) <- tributaries$ID -d <- cbind(m, f) +obs <- dataRetrieval::readNWISdata(sites = "13139510", parameterCd = "00060", + startDate = "1992-01-01", endDate = "2011-01-01") +obs <- obs[, c("dateTime", "X_00060_00003")] +obs[, 1] <- as.Date(obs[, 1]) + +fixed.dates <- seq(as.Date("1995-01-01"), as.Date("2011-01-01"), "1 month") +d <- GetSeasonalMult(obs, 2, 273.932, fixed.dates) str(d) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1528,42 +1100,61 @@ \chapter*{} This function determines well completions and pumping rates in model space. The pumping rate is specified for each model cell intersecting a well's open interval(s) and calculated by multiplying the estimated pumping demand by the cell's transmissivity fraction. -The transmissivity fraction is calculated by dividing the cell's aquifer transmissivity by the sum of all transmissivity values for cells belonging to the same well. +The transmissivity fraction is calculated by dividing the cell's aquifer transmissivity by +the sum of all transmissivity values for cells belonging to the same well. The transmissivity fraction calculation assumes saturated conditions in the model cell. \end{Description} % \begin{Usage} \begin{verbatim} -GetWellConfig(rs.model, wells, well.col, rate.col = NULL, lay2.hk.tol = 1e-02) +GetWellConfig(rs.model, wells, well.col, rate.col = NULL, + lay2.hk.tol = 0.01) \end{verbatim} \end{Usage} % \begin{Arguments} \begin{ldescription} -\item[\code{rs.model}] \code{RasterStack}; is composed of raster layers describing the model grid and hydraulic conductivity distribution: -\code{lay1.top}, \code{lay1.bot}, \code{lay2.bot}, \code{lay3.bot}, \code{lay1.top}, \code{lay1.hk}, \code{lay2.hk}, and \code{lay3.hk}. -\item[\code{wells}] \code{SpatialPointsDataFrame}; is the average pumping rate for each well during various times. -\item[\code{well.col}] \code{character}; is the column name of the well identifier field. -\item[\code{rate.col}] \code{character}; is a vector of column names for the pumping rate fields. -\item[\code{lay2.hk.tol}] \code{numeric}; is the hydraulic conductivity tolerance for model cells in layer 2. +\item[\code{rs.model}] RasterStack. +Composed of raster layers describing the model grid and hydraulic conductivity distribution: +\code{lay1.top}, \code{lay1.bot}, \code{lay2.bot}, \code{lay3.bot}, +\code{lay1.hk}, \code{lay2.hk}, and \code{lay3.hk}. + +\item[\code{wells}] SpatialPointsDataFrame. +Average pumping rate for each well during various times. + +\item[\code{well.col}] character. +Column name of the well identifier field. + +\item[\code{rate.col}] character. +Vector of column names for the pumping rate fields. + +\item[\code{lay2.hk.tol}] numeric. +Hydraulic conductivity tolerance for model cells in layer 2. Used to prevent pumping in the aquitard layer of the aquifer system. -Pumping is prohibited in model layer 2 cells with hydraulic conductivity values less than \code{lay2.hk.tol} and a well opening isolated to layer 2; +Pumping is prohibited in model layer 2 cells with hydraulic conductivity values less than +\code{lay2.hk.tol} and a well opening isolated to layer 2; for these cases, pumping is allocated to the adjacent layer 1 cell. \end{ldescription} \end{Arguments} % \begin{Value} -An object of \code{data.frame} class with the following components: -\begin{ldescription} -\item[\code{...}] \code{numeric}; a unique identifier assigned to a well, its name is specified by \code{well.col}. -\item[\code{lay, row, col}] \code{integer}; is the layer, row, and column number of a model cell, respectively. -\item[\code{hk}] \code{numeric}; is the hydraulic conductivity of the model cell, in meters per day. -\item[\code{thk}] \code{numeric}; is the vertical length of the well opening (open borehole or screen) in the model cell, in meters. +Returns an object of class data.frame with the following components: +\begin{description} + +\item[\dots] unique identifier assigned to a well, its name is specified by \code{well.col}. +\item[lay,row,col] layer, row, and column number of a model cell, respectively. +\item[hk] hydraulic conductivity of the model cell, in meters per day. +\item[thk] vertical length of the well opening (open borehole or screen) in the model cell, in meters. A value of zero indicates that the well opening is unknown or below the modeled bedrock surface. -\item[\code{frac}] \code{numeric}; is the transmissivity fraction for a model cell, where transmissivity is defined as \code{hk} multiplied by \code{thk}. -\item[\code{...}] \code{numeric}; is the pumping rate allocated to the model cell for each time period specified by \code{rate.col}, in cubic meters per day. -The pumping rate is calculated by multiplying the pumping demand for a well (specified in \code{wells}) by \code{frac}. -\end{ldescription} +\item[frac] transmissivity fraction for a model cell, +where transmissivity is defined as \code{hk} multiplied by \code{thk}. +\item[\dots] pumping rate allocated to the model cell for each time period +specified by \code{rate.col}, in cubic meters per day. +The pumping rate is calculated by multiplying the pumping demand for a well +(specified in \code{wells}) by \code{frac}. + +\end{description} + \end{Value} % \begin{Author}\relax @@ -1574,7 +1165,8 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -## Not run: # see uncalibrated-model vignette +## Not run: # see Appendix D. Uncalibrated Groundwater-Flow Model + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1594,20 +1186,24 @@ \chapter*{} \begin{Format} An object of \code{RasterLayer} class. Each cell on the surface grid represents the hill shade. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -The spatial grid is composed of 3,108 rows and 2,360 columns, and has cell sizes that are constant at 20 meters by 20 meters. +The spatial grid is composed of 3,108 rows and 2,360 columns, +and has cell sizes that are constant at 20 meters by 20 meters. \end{Format} % \begin{Source}\relax -Calculated from the slope and aspect of the \code{\LinkA{land.surface}{land.surface}} dataset using the \code{terrain} and \code{hillShade} functions; -see the \file{package-datasets} vignette for the \R{} code used in this calculation. +Calculated from the slope and aspect of the \code{\LinkA{land.surface}{land.surface}} dataset +using the \code{terrain} and \code{hillShade} functions; +see the appendix C. Package Dataset Creation for the \R{} code used in this calculation. \end{Source} % \begin{Examples} \begin{ExampleCode} -image(hill.shading, length(hill.shading), col = grey(0:255 / 255), asp = 1, - axes = FALSE, xlab = "", ylab = "") +raster::image(hill.shading, length(hill.shading), col = grey(0:255 / 255), asp = 1, + axes = FALSE, xlab = "", ylab = "") + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1615,7 +1211,7 @@ \chapter*{} \keyword{datasets}{idaho} % \begin{Description}\relax -The boundary of Idaho, a state in the northwestern region of the United States. +Boundary of Idaho, a state in the northwestern region of the United States. \end{Description} % \begin{Usage} @@ -1625,19 +1221,25 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygons} class containing 1 \code{Polygons}. +An object of SpatialPolygons class containing 1 Polygons. Cartographic boundary at 5m (1:5,000,000) resolution. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the +Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -U.S. Department of Commerce, U.S. Census Bureau, Geography Division/Cartographic Products Branch. -A simplified representation of the State of Idaho from the 2014 Census Bureau's MAF/\Rhref{http://www.census.gov/geo/maps-data/data/tiger.html}{TIGER} geographic database. +U.S. Department of Commerce, U.S. Census Bureau, +Geography Division/Cartographic Products Branch. +A simplified representation of the State of Idaho from the 2014 Census Bureau's +MAF/\Rhref{http://www.census.gov/geo/maps-data/data/tiger.html}{TIGER} geographic database. \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(idaho, col = "#EAE2CF", border = "#BFA76F", lwd = 0.5) +sp::plot(idaho, col = "#EAE2CF", border = "#BFA76F", lwd = 0.5) print(idaho) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1645,7 +1247,7 @@ \chapter*{} \keyword{datasets}{irr.entities} % \begin{Description}\relax -The delineation of areas served by a group of surface-water and (or) groundwater diversions. +Delineation of areas served by a group of surface-water and (or) groundwater diversions. \end{Description} % \begin{Usage} @@ -1655,28 +1257,35 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing 235 \code{Polygons} and a \code{data.frame} with the following variables: +An object of SpatialPolygonsDataFrame class containing 235 Polygons and +a data.frame with the following variables: \begin{description} -\item[EntityName] is the name of the irrigation entity served by a group of diversions. -\item[Source] is the water source: ``Mixed'' for a mixture of surface water and groundwater, ``SW Only'' for surface-water only, and ``GW Only'' for groundwater only. -\item[EntitySrce] is a concatenation of the \code{EntityName} and \code{Source} character strings. -\item[PrecipZone] is the name of the precipitation zone. +\item[EntityName] name of the irrigation entity served by a group of diversions. +\item[Source] water source, either ``Mixed'' for a mixture of surface water and groundwater, +``SW Only'' for surface-water only, or ``GW Only'' for groundwater only. +\item[EntitySrce] concatenation of the \code{EntityName} and \code{Source} character strings. +\item[PrecipZone] name of the precipitation zone. See \code{\LinkA{precip.zones}{precip.zones}} dataset for details. \end{description} +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the +Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax Idaho Department of Water Resources (IDWR), accessed on December 11, 2014; -derived from IDWR water rights database, Blaine County tax lot data, and IDWR irrigated land classification files. +derived from IDWR water rights database, Blaine County tax lot data, +and IDWR irrigated land classification files. \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(irr.entities) +sp::plot(irr.entities) print(irr.entities) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1684,7 +1293,8 @@ \chapter*{} \keyword{datasets}{irr.lands} % \begin{Description}\relax -The irrigation classification of land area in the Wood River Valley and surrounding areas; available for years 1996, 2000, 2002, 2006, 2008, 2009, and 2010. +Classification of irrigated lands in the Wood River Valley and surrounding areas; +available for years 1996, 2000, 2002, 2006, 2008, 2009, and 2010. \end{Description} % \begin{Usage} @@ -1694,19 +1304,24 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{list object} of length 7 with components of \code{SpatialPolygonsDataFrame-class}. -The \code{data.frame} associated with each of the \code{SpatialPolygons} objects has the following variable: +An object of list class with 7 SpatialPolygonsDataFrame components. +The data.frame associated with each SpatialPolygons object has the following variable: \begin{description} -\item[Status] is the status of land during the year reviewed, may be ``irrigated'', ``semi-irrigated'', or ``non-irrigated''. +\item[Status] status of land during the year reviewed, +either ``irrigated'', ``semi-irrigated'', or ``non-irrigated''. \end{description} +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the +Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax Idaho Department of Water Resources, accessed on November 17, 2014; -polygons derived from U.S. Department of Agriculture Common Land Unit polygons with some refinement of polygons. +polygons derived from U.S. Department of Agriculture Common Land Unit polygons +with some refinement of polygons. Irrigation status interpreted using satellite imagery and aerial photography. \end{Source} % @@ -1716,8 +1331,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -spplot(irr.lands[["2010"]], "Status") +sp::spplot(irr.lands[["2010"]], "Status") print(irr.lands) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1725,8 +1341,9 @@ \chapter*{} \keyword{datasets}{irr.lands.year} % \begin{Description}\relax -The annual land classification for irrigation practices is only available for select years. -For missing years, this dataset provides substitute years when land-classification was available (see \code{\LinkA{irr.lands}{irr.lands}}). +Annual land classification for irrigation practices is only available for select years. +For missing years, this dataset provides substitute years when land-classification was +available (see \code{\LinkA{irr.lands}{irr.lands}}). \end{Description} % \begin{Usage} @@ -1736,14 +1353,13 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 16 records and the following variables: +An object of data.frame class with 16 records and the following variables: \begin{description} -\item[Year] is the year with a required date format of \code{YYYY}. -\item[IL\_Year] is the substitute year with a required date format of \code{YYYY}. +\item[Year] year with a required date format of YYYY. +\item[IL\_Year] substitute year with a required date format of YYYY. \end{description} - \end{Format} % \begin{Source}\relax @@ -1753,6 +1369,7 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} str(irr.lands.year) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1760,7 +1377,7 @@ \chapter*{} \keyword{datasets}{kriging.zones} % \begin{Description}\relax -The location of kriging zones in the Wood River Valley, used in parameter estimation. +Location of kriging zones in the Wood River Valley, used in parameter estimation. \end{Description} % \begin{Usage} @@ -1770,21 +1387,24 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing 18 \code{Polygons} and a \code{data.frame} with the following variables: +An object of SpatialPolygonsDataFrame class containing 18 Polygons and a +data.frame with the following variables: \begin{description} -\item[Zone] is the kriging zone, interpolation in this zone is based on the parameter values of pilot points located within this zone. -\item[Layer] is the model layer. -\item[Name] is the local name. +\item[Zone] kriging zone, interpolation in this zone is based on the +parameter values of pilot points located within this zone. +\item[Layer] model layer +\item[Name] local name \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources +Idaho Department of Water Resources, accessed on June 11, 2015 \end{Source} % \begin{SeeAlso}\relax @@ -1793,7 +1413,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} +sp::plot(kriging.zones) str(kriging.zones@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1811,19 +1433,23 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing 55 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialPolygonsDataFrame class containing 55 Polygons. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources (\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on April 2, 2014 +Idaho Department of Water Resources +(\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +accessed on April 2, 2014 \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(lakes, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) +sp::plot(lakes, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) str(lakes@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1842,34 +1468,49 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialGridDataFrame} class. -Each cell on the surface grid represents an elevation in meters above the North American Vertical Datum of 1988 (NAVD 88). -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialGridDataFrame class. +Each cell on the surface grid represents an elevation in meters above the +North American Vertical Datum of 1988 (NAVD 88). +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -The spatial grid is composed of 565 rows and 429 columns, and has cell sizes that are constant at 100 meters by 100 meters. +The spatial grid is composed of 565 rows and 429 columns, +and has cell sizes that are constant at 100 meters by 100 meters. \end{Format} % \begin{Source}\relax -The National Elevation Dataset (\Rhref{http://ned.usgs.gov/}{NED}) 1/3-arc-second raster (Gesch, 2007; Gesch and others, 2002), accessed on December 1, 2015. -This dataset can be downloaded in a Esri ArcGRID format using the \Rhref{http://viewer.nationalmap.gov/viewer/}{National Map Viewer}. -NED data are distributed in geographic coordinates in units of decimal degrees, and in conformance with the NAD 83. +The National Elevation Dataset (\Rhref{http://ned.usgs.gov/}{NED}) +1/3-arc-second raster (Gesch, 2007; Gesch and others, 2002), +accessed on December 1, 2015. +This dataset can be downloaded in a Esri ArcGRID format using the +\Rhref{http://viewer.nationalmap.gov/viewer/}{National Map Viewer}. +NED data are distributed in geographic coordinates in units of decimal degrees, +and in conformance with the NAD 83. Elevation values are in meters above the NAVD 88. -The west, east, south, and north bounding coordinates for this dataset are -115, -114, 43, and 44 decimal degrees, respectively. +The west, east, south, and north bounding coordinates for this dataset are +-115, -114, 43, and 44 decimal degrees, respectively. Post-processing includes: -(1) project the values of the NED dataset into the \code{\LinkA{alluvium.thickness}{alluvium.thickness}} spatial grid using bilinear interpolation, and -(2) set values in cells where the elevation of the alluvium bottom is missing to \code{NA}. +(1) project the values of the NED dataset into the \code{\LinkA{alluvium.thickness}{alluvium.thickness}} +spatial grid using bilinear interpolation, and +(2) set values in cells where the elevation of the alluvium bottom is missing to NA. \end{Source} % \begin{References}\relax -Gesch, D.B., 2007, The National Elevation Dataset, in Maune, D., ed., Digital Elevation Model Technologies and Applications: The DEM Users Manual, 2nd Edition: Bethesda, Maryland, American Society for Photogrammetry and Remote Sensing, p. 99-118. - -Gesch, D., Oimoen, M., Greenlee, S., Nelson, C., Steuck, M., and Tyler, D., 2002, The National Elevation Dataset: Photogrammetric Engineering and Remote Sensing, v. 68, no. 1, p. 5-11. +Gesch, D.B., 2007, The National Elevation Dataset, in Maune, D., ed., +Digital Elevation Model Technologies and Applications: The DEM Users Manual, +2nd Edition: Bethesda, Maryland, American Society for Photogrammetry and Remote Sensing, +p. 99-118. + +Gesch, D., Oimoen, M., Greenlee, S., Nelson, C., Steuck, M., and Tyler, D., 2002, +The National Elevation Dataset: Photogrammetric Engineering and Remote Sensing, +v. 68, no. 1, p. 5-11. \end{References} % \begin{Examples} \begin{ExampleCode} -image(land.surface) +raster::image(land.surface) summary(land.surface) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1887,19 +1528,23 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialLinesDataFrame} class containing 475 \code{Lines}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialLinesDataFrame class containing 475 Lines. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources (\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on October 20, 2015 +Idaho Department of Water Resources +(\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +accessed on October 20, 2015 \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(major.roads) +sp::plot(major.roads) str(major.roads@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1917,17 +1562,19 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 40 points with the following variables: +An object of SpatialPointsDataFrame class containing +40 points with the following variables: \begin{description} -\item[label] is the text to be written. -\item[cex] is the character expansion factor. -\item[col, font] is the color and font to be used. -\item[srt] is the string rotation in degrees. +\item[label] text to be written. +\item[cex] character expansion factor +\item[col,font] color and font to be used, respectively. +\item[srt] string rotation in degrees. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -1937,12 +1584,13 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(map.labels, col = "red") +sp::plot(map.labels, col = "red") lab <- cbind(map.labels@coords, map.labels@data) for (i in seq_len(nrow(lab))) { text(lab$x[i], lab$y[i], labels = lab$label[i], cex = lab$cex[i], col = lab$col[i], font = lab$font[i], srt = lab$srt[i]) } + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -1960,33 +1608,38 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 3 points with the following variable: +An object of SpatialPointsDataFrame class containing 3 points +with the following variable: \begin{description} -\item[label] is a description of the point location. +\item[label] description of point location. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources (\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on December 23, 2015 +Idaho Department of Water Resources +(\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +accessed on December 23, 2015 \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(misc.locations, pch = 20, col = "red") +sp::plot(misc.locations, pch = 20, col = "red") text(misc.locations, labels = misc.locations@data$label, pos = 3, cex = 0.6) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} -\HeaderA{misc.seepage}{Recharge from Miscellaneous Seepage Sites}{misc.seepage} +\HeaderA{misc.seepage}{Direct Recharge from Miscellaneous Seepage Sites}{misc.seepage} \keyword{datasets}{misc.seepage} % \begin{Description}\relax -Recharge from miscellaneous seepage sites in the Wood River Valley, Idaho. +Direct recharge from miscellaneous seepage sites in the Wood River Valley, Idaho. \end{Description} % \begin{Usage} @@ -1996,15 +1649,15 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 2 records and the following variables: +An object of data.frame class with 2 records and the following variables: \begin{description} -\item[RechSite] is the name of the recharge site, see \code{\LinkA{bellevue.wwtp.ponds}{bellevue.wwtp.ponds}} and \code{\LinkA{bypass.canal}{bypass.canal}} datasets. -\item[199501, \dots, 201012] is the monthly volume of recharge during a stress period, in cubic meters. +\item[RechSite] name of the recharge site, see \code{\LinkA{bellevue.wwtp.ponds}{bellevue.wwtp.ponds}} and +\code{\LinkA{bypass.canal}{bypass.canal}} datasets. +\item[199501,\dots,201012] monthly volume of recharge during a stress period, in cubic meters. The variable name is specified as year and month. \end{description} - \end{Format} % \begin{Source}\relax @@ -2014,6 +1667,7 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} str(misc.seepage) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2031,41 +1685,44 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 776 points with the following variables: +An object of SpatialPointsDataFrame class containing 776 points +with the following variables: \begin{description} -\item[id] a unique well identifier used in this study. -\item[SiteNo] a unique well identifier within the National Water Information System (NWIS). -\item[SITEIDIDWR] a unique well identifier within the Idaho Department of Water Resources (IDWR) hydrologic database. -\item[WELLNUMBER] the USGS or IDWR site name for the well. -\item[PESTNAME] a unique well identifier for PEST. -\item[METHODDRIL] the drilling method. -\item[TOTALDEPTH] the depth at which drilling stopped, in feet. -\item[OPENINGMIN] the top of the screened interval, in feet. -\item[OPENINGMAX] the bottom of the screened interval, in feet. -\item[COMPLETION] the date on which the well drilling and construction stopped. -\item[WCWELLID] the well construction well identifier. -\item[ALTITUDE] the land surface elevation, in feet. -\item[ALTMETHOD] the method for obtaining the land surface elevation. -\item[XYMETHOD] the method of obtaining the spatial coordinates. -\item[BASINNO] the basin number. -\item[COUNTYNAME] the Idaho county name. -\item[TWPRGE] the township and range the well is located in. -\item[SITENAME] a local name for the well. -\item[desc] is a description of the well type. -\item[TopOpen1] is the depth to the top of the first open interval in a groundwater well, in meters below land surface. -\item[BotOpen1] is the depth to the bottom of the first open interval in a groundwater well, in meters below land surface. -\item[TopOpen2] is not applicable. -\item[BotOpen2] is not applicable. +\item[id] unique well identifier used in this study. +\item[SiteNo] unique well identifier within the +National Water Information System (NWIS). +\item[SITEIDIDWR] unique well identifier within the +Idaho Department of Water Resources (IDWR) hydrologic database. +\item[WELLNUMBER] USGS or IDWR site name for the well. +\item[PESTNAME] unique well identifier for PEST. +\item[METHODDRIL] drilling method +\item[TOTALDEPTH] depth at which drilling stopped, in feet. +\item[OPENINGMIN] top of the screened interval, in feet. +\item[OPENINGMAX] bottom of the screened interval, in feet. +\item[COMPLETION] date on which the well drilling and construction stopped. +\item[WCWELLID] well construction well identifier. +\item[ALTITUDE] land surface elevation, in feet. +\item[ALTMETHOD] method for obtaining the land surface elevation. +\item[XYMETHOD] method of obtaining the spatial coordinates. +\item[BASINNO] basin number +\item[COUNTYNAME] Idaho county name +\item[TWPRGE] township and range the well is located in. +\item[SITENAME] local name for well. +\item[desc] description of well type. +\item[TopOpen1] depth to the top of the first open interval in a groundwater well, +in meters below land surface. +\item[BotOpen1] depth to the bottom of the first open interval in a groundwater well, +in meters below land surface. +\item[TopOpen2] not applicable +\item[BotOpen2] not applicable \end{description} - -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -IDWR well construction database, accessed on June 29, 2015 +Idaho Department of Water Resources well construction database, +accessed on June 29, 2015 \end{Source} % \begin{SeeAlso}\relax @@ -2074,8 +1731,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(obs.wells) +sp::plot(obs.wells) str(obs.wells@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2083,7 +1741,8 @@ \chapter*{} \keyword{datasets}{obs.wells.head} % \begin{Description}\relax -Hydraulic-head (groundwater-level) measurements recorded in observation wells in the Wood River Valley aquifer system. +Hydraulic-head (groundwater-level) measurements recorded in observation wells in the +Wood River Valley aquifer system. Values are used as observations during the parameter estimation process. \end{Description} % @@ -2094,15 +1753,15 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 3,477 records and the following variables: +An object of class data.frame with 3,477 records and the following variables: \begin{description} -\item[PESTNAME] is a unique well identifier for PEST. -\item[DateTime] is the date and time when the measurement was recorded. -\item[Head] is the groundwater-level measurement (hydraulic head) in meters above NAVD 88. +\item[PESTNAME] unique well identifier for PEST. +\item[DateTime] date and time when the measurement was recorded. +\item[Head] groundwater-level measurement (hydraulic head) +in meters above the North American Vertical Datum of 1988 (NAVD 88). \end{description} - \end{Format} % \begin{Source}\relax @@ -2116,6 +1775,7 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} str(obs.wells.head) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2133,15 +1793,17 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 106 points with the following variables: +An object of SpatialPointsDataFrame class containing 106 points +with the following variables: \begin{description} -\item[Layer] is the model layer. -\item[Zone] is the kriging zone. +\item[Layer] model layer +\item[Zone] kriging-zone identifier \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -2155,348 +1817,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(pilot.points) +sp::plot(pilot.points) str(pilot.points@data) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{PlotCrossSection}{Plot Method for Cross Sections}{PlotCrossSection} -\keyword{hplot}{PlotCrossSection} -% -\begin{Description}\relax -This function creates a cross-section view of raster data. -A key showing how the colors map to raster values is shown below the map. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -PlotCrossSection(transect, rs, geo.lays = names(rs), val.lays = NULL, - wt.lay = NULL, asp = 1, ylim = NULL, max.dev.dim = c(43, 56), - n = NULL, breaks = NULL, pal = NULL, col = NULL, ylab = NULL, - unit = NULL, id = c("A", "A'"), labels = NULL, - explanation = NULL, features = NULL, max.feature.dist = Inf, - draw.key = TRUE, draw.sep = TRUE, is.categorical = FALSE, - contour.lines = NULL, bg.col = "#E1E1E1", wt.col = "#FFFFFFD8") -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{transect}] \code{SpatialLines}; the piecewise linear transect line. -\item[\code{rs}] \code{RasterStack}; a collection of \code{RasterLayer} objects with the same extent and resolution. -\item[\code{geo.lays}] \code{character}; a vector of names in \code{rs} that specify the geometry raster layers; these must be given in decreasing order, that is, from the upper most (such as land surface) to the lowest (such as a bedrock surface). -\item[\code{val.lays}] \code{character}; a vector of names in \code{rs} that specify the value raster layers (optional). -Values from the first layer are mapped as colors to the area between the first and second geometry layers; the second layer mapped between the second and third geometry layers, and so on. -\item[\code{wt.lay}] \code{character}; the name in \code{rs} that specifies the water-table raster layer (optional). -\item[\code{asp}] \code{numeric}; the \emph{y/x} aspect ratio for spatial axes. -\item[\code{ylim}] \code{numeric}; a vector of length 2 giving the minimum and maximum values for the \emph{y}-axis. -\item[\code{max.dev.dim}] \code{numeric}; a vector of length 2 giving the maximum width and height for the graphics device in picas, respectively. -Suggested dimensions for single-column, double-column, and sidetitle figures are \code{c(21, 56)}, \code{c(43, 56)}, and \code{c(56, 43)}, respectively. -\item[\code{n}] \code{integer}; the desired number of intervals to partition the range of raster values (optional). -\item[\code{breaks}] \code{numeric}; a vector of break points used to partition the colors representing numeric raster values (optional). -\item[\code{pal}] \code{function}; a color palette to be used to assign colors in the plot, \code{rainbow} by default. -\item[\code{col}] \code{character}; a vector of colors to be used in the plot. -This argument requires \code{breaks} specification for numeric raster values and overrides any palette function specification. -For numeric values there should be one less color than breaks. -Categorical data require a color for each category. -\item[\code{ylab}] \code{character}; a label for the \emph{y} axis. -\item[\code{unit}] \code{character}; a label for the measurement unit of the \emph{x}- and \emph{y}-axes. -\item[\code{id}] \code{character}; a vector of length 2 giving the labels for the end points of the transect line, defaults to \emph{A--A'}. -\item[\code{labels}] \code{list}; describes the location and values of labels in the color key. -This list may include components \code{at} and \code{labels}, numeric and character vectors, respectively. -\item[\code{explanation}] \code{character}; a label that describes the cell values. -\item[\code{features}] \code{SpatialGridDataFrame}; point features adjacent to the transect line that are used as reference labels for the upper geometry layer. -\item[\code{max.feature.dist}] \code{numeric}; the maximum distance from a point feature to the transect line, specified in the units of the \code{rs} projection. -\item[\code{draw.key}] \code{logical}; if \code{FALSE}, a color key is not drawn. -\item[\code{draw.sep}] \code{logical}; if \code{TRUE}, lines separating geometry layers are drawn. -\item[\code{is.categorical}] \code{logical}; if \code{TRUE}, cell values in \code{val.lays} represent categorical data; otherwise, these data values are assumed continuous. -\item[\code{contour.lines}] \code{list}; if specified, contour lines are drawn. -The contours are described using a list of arguments supplied to \code{contour}. -Passed arguments include \code{"drawlables"}, \code{"method"}, and \code{"col"}. -\item[\code{bg.col}] \code{character}; the color used for the background of the area below the upper geometry raster layer. -\item[\code{wt.col}] \code{character}; the color used for the water-table line. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -The dimensions of a new graphics device is dependent on the argument values of \code{max.dev.dim} and \code{asp}. -\end{Details} -% -\begin{Value} -Used for the side-effect of a new plot generated. -Returns a \code{list} object with the following graphical parameters: -\begin{ldescription} -\item[\code{din}] \code{numeric}; the device dimensions \code{(width, height)}, in inches. -\item[\code{usr}] \code{numeric}; the extremes of the coordinates of the plotting region \code{(x1, x2, y1, y2)}. -\item[\code{heights}] \code{numeric}; the relative heights on the device \code{(upper, lower)} for the map and color-key plots. -\end{ldescription} -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{\LinkA{ExtractAlongTransect}{ExtractAlongTransect}}, \code{\LinkA{AddScaleBar}{AddScaleBar}}, \code{\LinkA{AddColorKey}{AddColorKey}} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -data(volcano) -x <- seq(from = 2667405, length.out = 61, by = 10) -y <- seq(from = 6478705, length.out = 87, by = 10) -r1 <- raster(volcano, xmn = min(x), xmx = max(x), ymn = min(y), ymx = max(y), - crs = CRS("+init=epsg:27200")) -r2 <- min(r1[]) - r1 / 10 -r3 <- r1 - r2 -rs <- stack(r1, r2, r3) -names(rs) <- c("r1", "r2", "r3") - -xy <- rbind(c(2667508, 6479501), c(2667803, 6479214), c(2667508, 6478749)) -transect <- SpatialLines(list(Lines(list(Line(xy)), ID = "Transect")), - proj4string = crs(rs)) - -plot(r1) -lines(transect) -text(as(transect, "SpatialPoints"), labels = c("A", "BEND", "A'"), cex = 0.7, - pos = c(3, 4, 1), offset = 0.1, font = 4) - -graphics.off() -PlotCrossSection(transect, rs, geo.lays = c("r1", "r2"), val.lays = "r3", - ylab="Elevation", asp = 5, unit = "METERS", - explanation = "Vertical thickness between layers, in meters.") - -graphics.off() -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{PlotGraph}{Plot Method for Graphs}{PlotGraph} -\keyword{hplot}{PlotGraph} -% -\begin{Description}\relax -This function draws a sequence of points, lines, or box-and-whiskers using specified coordinates. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -PlotGraph(x, y, xlab, ylab, asp = NA, xlim = NULL, ylim = NULL, - xn = 5L, yn = 5L, ylog = FALSE, type = "s", lty = 1, lwd = 1, - pch = NULL, col = NULL, bg = NA, fill = NULL, pt.cex = 1, - seq.date.by = "year", scientific = NA, conversion.factor = NULL, - boxwex = 0.8, center.date.labels = FALSE, bg.polygon = NULL) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{x, y}] \code{Date}, \code{numeric}, \code{matrix}, or \code{data.frame}; vectors or matrices of data for plotting. -The vector length or number of rows should match. -If \code{y} is missing, then \code{x = x[, 1]} and \code{y = x[, 2:n]}. -\item[\code{xlab}] \code{character}; title for \emph{x} and axis. -\item[\code{ylab}] \code{character}; a vector of length 2 giving the title for the 1st and 2nd \emph{y} axes. -The title for the 2nd \emph{y} axis is optional and requires \code{conversion.factor} be specified. -\item[\code{asp}] \code{numeric}; the \emph{y/x} aspect ratio. -\item[\code{xlim}] \code{numeric} or \code{Date}; the \code{x} limits \code{(x1, x2)} of the plot. -\item[\code{ylim}] \code{numeric}; the \code{y} limits \code{(y1, y2)} of the plot. -\item[\code{xn, yn}] \code{integer}; the desired number of intervals between tick-marks on the \emph{x}- and \emph{y}-axis, respectively. -\item[\code{ylog}] \code{logical}; if \code{TRUE}, a logarithm scale is used for the \emph{y} axis. -\item[\code{type}] \code{character}; is the type of plot for each column of \code{y}, see \code{plot} for possible types. -A box-and-whisker plot is drawn when \code{type = "box"}, with whiskers extending to the data extremes. -\item[\code{lty}] \code{integer}; is the line type, see \code{par} for all possible types. -Line types are used cyclically. -\item[\code{lwd}] \code{numeric}; is the line width. -\item[\code{pch}] \code{integer}; is the point type, see \code{points} for all possible types. -Point types are used cyclically. -\item[\code{col}] \code{character} or \code{function}; is the point or line color, see \code{par} for all possible ways this can be specified. -Colors are used cyclically. -\item[\code{bg}] \code{character}; a vector of background colors for the open plot symbols given by \code{pch = 21:25} as in \code{points}. -\item[\code{fill}] \code{character}; a vector of fill colors for areas beneath (or above, direction towards 0) lines of type \code{"l"} or \code{"s"}. -\item[\code{pt.cex}] \code{numeric}; expansion factor for the points. -\item[\code{seq.date.by}] \code{character}, \code{numeric}, or \code{difftime}; is the increment of the date sequence, see \code{seq.Date} for all possible ways this can be specified. -\item[\code{scientific}] \code{logical}; a vector of length 3 that indicates if axes labels should be encoded in nice scientific format. -Vector elements correspond to the \code{x}-axis, \code{y}-axis, and second \code{y}-axis labels. -Values are recycled as necessary. -\item[\code{conversion.factor}] \code{numeric}; a conversion factor for the 2nd \emph{y} axis. -\item[\code{boxwex}] \code{numeric}; a scale factor to be applied to all boxes, only applicable for box-and-whisker plots. -\item[\code{center.date.labels}] \code{logical}; if \code{TRUE}, date labels are horizontally centered between \emph{x}-axis tickmarks. -\item[\code{bg.polygon}] \code{list}; if specified, a background polygon is drawn. -The polygon is described using a list of arguments supplied to the \code{polygon} function. -Passed arguments include \code{"x"} and \code{"col"}. -\end{ldescription} -\end{Arguments} -% -\begin{Value} -Used for the side-effect of a new plot generated. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{matplot}, \code{boxplot} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -n <- 50L - -x <- as.Date("2008-07-12") + 1:n -y <- sample.int(n, replace = TRUE) -PlotGraph(x, y, ylab = paste("Random number in", c("meters", "feet")), type = "p", - pch = 16, seq.date.by = "weeks", scientific = FALSE, conversion.factor = 3.28) - -graphics.off() -y <- data.frame(lapply(1:3, function(i) sample(n, replace = TRUE))) -PlotGraph(x, y, ylab = "Random number", type = "s", pch = 1, seq.date.by = "days", - scientific=TRUE) - -graphics.off() -y <- sapply(1:3, function(i) sample((1:100) + i * 100, n, replace = TRUE)) -m <- cbind(as.numeric(x), y) -col <- c("red", "gold", "green") -PlotGraph(m, xlab = "Number", ylab = "Random number", type = "b", pch = 15:17, - col = col, pt.cex = 0.9) -legend("topright", LETTERS[1:3], inset = 0.05, col = col, lty = 1, pch = 15:17, - pt.cex = 0.9, cex = 0.8, bg = "white") - -graphics.off() -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{PlotMap}{Plot Method for Maps}{PlotMap} -\keyword{hplot}{PlotMap} -% -\begin{Description}\relax -This function maps raster layer values. A key showing how the colors map to raster values is shown below the map. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -PlotMap(r, layer = 1, att = NULL, n, breaks, xlim = NULL, ylim = NULL, - zlim = NULL, asp = 1, extend.xy = FALSE, extend.z = FALSE, - reg.axs = TRUE, trim.r = TRUE, dms.tick = FALSE, bg.lines = FALSE, - bg.image = NULL, bg.image.alpha = 1, pal = NULL, col = NULL, - max.dev.dim = c(43, 56), labels = NULL, scale.loc = "bottomleft", - arrow.loc = NULL, explanation = NULL, credit = proj4string(r), - shade = NULL, contour.lines = NULL, rivers = NULL, lakes = NULL, - roads = NULL, draw.key = NULL, draw.raster = TRUE, useRaster) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{r}] \code{RasterLayer}, \code{SpatialGridDataFrame}, or \code{CRS}; a raster layer with values to be plotted or a coordinate reference system (CRS). -\item[\code{layer}] \code{integer}; the column to use in the \code{SpatialGridDataFrame}. -\item[\code{att}] \code{numeric} or \code{character}; the variable identifying the levels attribute to use in the Raster Attribute Table (RAT). -This argument requires \code{r} values that are of class \code{factor}. -\item[\code{n}] \code{integer}; the desired number of intervals to partition the range of raster values (or \code{zlim} if specified) (optional). -\item[\code{breaks}] \code{numeric}; a vector of break points used to partition the colors representing numeric raster values (optional). -\item[\code{xlim}] \code{numeric}; a vector of length 2 giving the minimum and maximum values for the \emph{x}-axis. -\item[\code{ylim}] \code{numeric}; a vector of length 2 giving the minimum and maximum values for the \emph{y}-axis. -\item[\code{zlim}] \code{numeric}; a vector of length 2 giving the minimum and maximum raster values for which colors should be plotted. -\item[\code{asp}] \code{numeric}; the \emph{y/x} aspect ratio for spatial axes. -\item[\code{extend.xy}] \code{logical}; if \code{TRUE}, the spatial limits will be extended to the next tick mark on the axes beyond the grid extent. -\item[\code{extend.z}] \code{logical}; if \code{TRUE}, the raster value limits will be extended to the next tick mark on the color key beyond the measured range. -\item[\code{reg.axs}] \code{logical}; if \code{TRUE}, the spatial data range is extended. -\item[\code{trim.r}] \code{logical}; if \code{TRUE}, the outer rows and columns that consist of all \code{NA} values will be removed. -\item[\code{dms.tick}] \code{logical}; if \code{TRUE}, the axes tickmarks are specified in degrees, minutes, and decimal seconds. -\item[\code{bg.lines}] \code{logical}; if \code{TRUE}, the graticule is drawn in back of the raster layer using white lines and a grey background. -\item[\code{bg.image}] \code{RasterLayer}; an image to drawn in back of the main raster layer \code{r}. -\item[\code{bg.image.alpha}] \code{numeric}; the opacity of the background image from 0 to 1. -\item[\code{pal}] \code{function}; a color palette to be used to assign colors in the plot, \code{rainbow} by default. -\item[\code{col}] \code{character}; a vector of colors to be used in the plot. -This argument requires \code{breaks} specification for numeric values of \code{r} and overrides any palette function specification. -For numeric values there should be one less color than breaks. Factors require a color for each level. -\item[\code{max.dev.dim}] \code{numeric}; a vector of length 2 giving the maximum width and height for the graphics device in picas, respectively. -Suggested dimensions for single-column, double-column, and sidetitle figures are \code{c(21, 56)}, \code{c(43, 56)}, and \code{c(56, 43)}, respectively. -\item[\code{labels}] \code{list}; describes the location and values of labels in the color key. -This list may include components \code{at} and \code{labels}. -\item[\code{scale.loc}] \code{character}; the position of the scale bar: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote scale location. -\item[\code{arrow.loc}] \code{character}; the position of the north arrow: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote arrow location. -\item[\code{explanation}] \code{character}; a label explaining the raster value. -\item[\code{credit}] \code{character}; a label crediting the base map. -\item[\code{shade}] \code{list}; if specified, a semi-transparent shade layer is drawn on top of the raster layer. -This layer is described using a list of arguments supplied to \code{hillShade}. -Passed arguments include \code{"angle"} and \code{"direction"}. -Additional arguments also may be passed that control the vertical aspect ratio (\code{"z.factor"}) and color opacity (\code{"alpha"}). -\item[\code{contour.lines}] \code{list}; if specified, contour lines are drawn. -The contours are described using a list of arguments supplied to \code{contour}. -Passed arguments include \code{"drawlables"}, \code{"method"}, and \code{"col"}. -\item[\code{rivers}] \code{list}; if specified, lines are drawn. -The lines are described using a list of arguments supplied to the plot method for \code{SpatialLines}. -Passed arguments include \code{"x"}, \code{"col"}, and \code{"lwd"}. -\item[\code{lakes}] \code{list}; if specified, polygons are drawn. -The polygons are described using a list of arguments supplied to the plot method for \code{SpatialPolygons}. -Passed arguments include \code{"x"}, \code{"col"}, \code{"border"}, and \code{"lwd"}. -Bitmap images require a regular grid. -\item[\code{roads}] \code{list}; if specified, lines are drawn. -The lines are described using a list of arguments supplied to the plot method for \code{SpatialLines}. -Passed arguments include \code{"x"}, \code{"col"}, and \code{"lwd"}. -\item[\code{draw.key}] \code{logical}; indicates if a color key should be drawn. -\item[\code{draw.raster}] \code{logical}; if \code{FALSE}, the raster image is not drawn. -\item[\code{useRaster}] \code{logical}; if \code{TRUE}, a bitmap raster is used to plot \code{r} instead of polygons. -If \code{UseRaster} is not specified, raster images are used when the \code{getOption("preferRaster")} is true. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -The dimensions of a new graphics device is dependent on the argument values of \code{max.dev.dim} and \code{asp}. -\end{Details} -% -\begin{Value} -Used for the side-effect of a new plot generated. -Returns a \code{list} object with the following graphical parameters: -\begin{ldescription} -\item[\code{din}] \code{numeric}; the device dimensions \code{(width, height)}, in inches. -\item[\code{usr}] \code{numeric}; the extremes of the coordinates of the plotting region \code{(x1, x2, y1, y2)}. -\item[\code{heights}] \code{numeric}; the relative heights on the device \code{(upper, lower)} for the map and color-key plots. -\end{ldescription} -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{\LinkA{AddScaleBar}{AddScaleBar}}, \code{\LinkA{AddColorKey}{AddColorKey}} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -r <- raster(system.file("external/test.grd", package="raster")) -PlotMap(r, scale.loc = "topleft", dms.tick = TRUE, trim.r = TRUE) - -graphics.off() -r <- raster(nrow = 10, ncol = 10) -r[] <- 1L -r[51:100] <- 2L -r[3:6, 1:5] <- 8L -r <- ratify(r) -rat <- levels(r)[[1]] -rat$land.cover <- c("Pine", "Oak", "Meadow") -rat$code <- c(12, 25, 30) -levels(r) <- rat -PlotMap(r, att = "land.cover", col = c("grey", "orange", "purple")) -PlotMap(r, att = "code") - -graphics.off() -r <- alluvium.thickness -PlotMap(r@crs, bg.image = hill.shading, reg.axs = FALSE) -plot(alluvium.extent, border = "red", add = TRUE) -PlotMap(r, bg.image = hill.shading, bg.image.alpha = 0.6) -PlotMap(r, n = 10, extend.xy = TRUE) -graphics.off() -PlotMap(r, ylim = c(NA, 1360000), max.dev.dim = c(56, 43), n = 10, extend.z = TRUE, - contour.lines = list(col = "#A9A9A9")) -plot(alluvium.extent, add = TRUE) -shade <- list(z.factor = 15, alpha = 0.4) -txt <- "Land surface elevation in meters above National Geodetic Vertical Datum of 1929." -ans <- PlotMap(r, ylim = c(NA, 1360000), max.dev.dim = c(56, 43), bg.lines = TRUE, - shade = shade, arrow.loc = "topright", explanation = txt) - -graphics.off() \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2514,24 +1837,26 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 1,755 records and the following variables: +An object of class data.frame with 1,755 records and the following variables: \begin{description} -\item[WMISNumber] is a unique number assigned to a water right point of diversion. -\item[WaterRight] is a number identifying a specific authorization to use water in a prescribed manner. -\item[EntityName] is the name of the irrigation entity the point of diversion is assigned to. -\item[EntitySrce] is the source of water for an irrigation entity. +\item[WMISNumber] unique number assigned to a water right point of diversion. +\item[WaterRight] number identifying a specific authorization to use +water in a prescribed manner. +\item[EntityName] name of the irrigation entity the point of diversion is assigned to. +\item[EntitySrce] source of water for an irrigation entity. Possible sources of water include surface water, groundwater and mixed. Mixed source entities derive water from both groundwater and surface water. -\item[Pdate] is the priority date, the date the water right was established. -\item[IrrRate] is the irrigation rate in cubic meters per day, the maximum permitted water use rate associated with a water right. +\item[Pdate] priority date, the date the water right was established. +\item[IrrRate] irrigation rate in cubic meters per day, +the maximum permitted water use rate associated with a water right. \end{description} - \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources water rights database, accessed on December 11, 2014 +Idaho Department of Water Resources water rights database, +accessed on December 11, 2014 \end{Source} % \begin{SeeAlso}\relax @@ -2541,6 +1866,7 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} summary(pod.gw) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2558,24 +1884,31 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 1,243 points with the following variables: +An object of SpatialPointsDataFrame class containing 1,243 points +with the following variables: \begin{description} \item[WMISNumber] is a unique number assigned to a water right point of diversion. -\item[WellUse] is the permitted use(s) for a groundwater well. -\item[TopOpen1] is the depth to the top of the first open interval in a groundwater well, in meters below land surface. -\item[BotOpen1] is the depth to the bottom of the first open interval in a groundwater well, in meters below land surface. -\item[TopOpen2] is the depth to the top of the second open interval in a groundwater well, in meters below land surface. -\item[BotOpen2] is the depth to the bottom of the second open interval in a groundwater well, in meters below land surface. +\item[WellUse] permitted use(s) for a groundwater well. +\item[TopOpen1] depth to the top of the first open interval in a groundwater well, +in meters below land surface. +\item[BotOpen1] depth to the bottom of the first open interval in a groundwater well, +in meters below land surface. +\item[TopOpen2] depth to the top of the second open interval in a groundwater well, +in meters below land surface. +\item[BotOpen2] depth to the bottom of the second open interval in a groundwater well, +in meters below land surface. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources water rights database, accessed on November 29, 2014 +Idaho Department of Water Resources water rights database, +accessed on November 29, 2014 \end{Source} % \begin{SeeAlso}\relax @@ -2584,8 +1917,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(pod.wells) +sp::plot(pod.wells) str(pod.wells@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2595,7 +1929,8 @@ \chapter*{} \begin{Description}\relax Precipitation zones specified for the Wood River Valley and surrounding areas. There are three precipitation zones, each containing a single weather station. -Precipitation zones were distributed to maintain the geographic similarity between weather stations and zones. +Precipitation zones were distributed to maintain the geographic similarity between +weather stations and zones. \end{Description} % \begin{Usage} @@ -2605,24 +1940,29 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing 3 \code{Polygons} and a \code{data.frame} with the following variables: +An object of SpatialPolygonsDataFrame class containing 3 Polygons and a +data.frame with the following variables: \begin{description} -\item[ID] a numeric identifier assigned to the polygon. -\item[PrecipZone] the name of the precipitation zone: -``Ketchum'', the northernmost zone with data from the Ketchum National Weather Service coop weather station. -``Hailey'', the central zone with data from the Hailey 3NNW National Weather Service coop weather station. -``Picabo'', the southernmost zone with data from the Picabo AgriMet weather station. - +\item[ID] numeric identifier assigned to the polygon. +\item[PrecipZone] name of the precipitation zone: +``Ketchum'', the northernmost zone with data from the +Ketchum National Weather Service coop weather station. +``Hailey'', central zone with data from the +Hailey 3NNW National Weather Service coop weather station. +``Picabo'', southernmost zone with data from the +Picabo AgriMet weather station. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Created using the northing midpoint between weather stations, see \code{\LinkA{weather.stations}{weather.stations}} dataset. +Created using the northing midpoint between weather stations, +see \code{\LinkA{weather.stations}{weather.stations}} dataset. \end{Source} % \begin{SeeAlso}\relax @@ -2632,11 +1972,12 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} col <- c("#D1F2A5", "#FFC48C", "#F56991") -plot(precip.zones, col = col) +sp::plot(precip.zones, col = col) legend("topright", legend = precip.zones@data$PrecipZone, fill = col, bty = "n") -plot(alluvium.extent, add = TRUE) +sp::plot(alluvium.extent, add = TRUE) print(precip.zones) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2654,16 +1995,19 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 582 records and the following variables: +An object of data.frame class with 582 records and the following variables: +with the following variables: \begin{description} -\item[YearMonth] is the year and month during which precipitation were recorded, with a required date format of \code{YYYYMM}. -\item[PrecipZone] the name of the precipitation zone, see \code{\LinkA{precip.zones}{precip.zones}} dataset for details. -\item[Precip] is the monthly depth of precipitation accounting for spring melt, in meters. -\item[Precip.raw] is the monthly depth of precipitation recorded at the weather station, in meters. +\item[YearMonth] year and month during which precipitation were recorded, +with a required date format of \code{YYYYMM}. +\item[PrecipZone] name of the precipitation zone, +see \code{\LinkA{precip.zones}{precip.zones}} dataset for details. +\item[Precip] monthly depth of precipitation accounting for spring melt, in meters. +\item[Precip.raw] monthly depth of precipitation recorded at the weather station, +in meters. \end{description} - \end{Format} % \begin{Source}\relax @@ -2671,9 +2015,11 @@ \chapter*{} \end{Source} % \begin{References}\relax -National Oceanic and Atmospheric Administration's National Weather Service (\Rhref{http://www.nws.noaa.gov/om/coop/}{NWS}) Cooperative Observer Program +National Oceanic and Atmospheric Administration's National Weather Service +(\Rhref{http://www.nws.noaa.gov/om/coop/}{NWS}) Cooperative Observer Program -U.S. Bureau of Reclamation's Cooperative Agricultural Weather Network (\Rhref{http://www.usbr.gov/pn/agrimet/}{AgriMet}) +U.S. Bureau of Reclamation's Cooperative Agricultural Weather Network +(\Rhref{http://www.usbr.gov/pn/agrimet/}{AgriMet}) \end{References} % \begin{SeeAlso}\relax @@ -2685,7 +2031,7 @@ \chapter*{} str(precipitation) d <- precipitation -d <- data.frame(Date = as.Date(paste0(d$YearMonth, "15"), format = "%Y%m%d"), +d <- data.frame(Date = as.Date(paste0(d$YearMonth, "15"), format = "\%Y\%m\%d"), Precip = d$Precip) zones <- c("Hailey", "Ketchum", "Picabo") d1 <- d[precipitation$PrecipZone == zones[1], ] @@ -2695,11 +2041,12 @@ \chapter*{} col <- c("red", "blue", "green") ylab <- paste("Precipitation in", c("meters", "feet")) -PlotGraph(d, ylab = ylab, col = col, lty = 1:3, conversion.factor = 3.28084) +inlmisc::PlotGraph(d, ylab = ylab, col = col, lty = 1:3, conversion.factor = 3.28084) legend("topright", zones, col = col, lty = 1:3, inset = 0.02, cex = 0.7, box.lty = 1, bg = "#FFFFFFE7") graphics.off() + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2707,7 +2054,8 @@ \chapter*{} \keyword{datasets}{priority.cuts} % \begin{Description}\relax -Priority cut dates applied to Big Wood River above Magic Reservoir and Silver Creek by Water District 37 and 37M at the end of each month. +Priority cut dates applied to Big Wood River above Magic Reservoir and +Silver Creek by Water District 37 and 37M at the end of each month. \end{Description} % \begin{Usage} @@ -2717,25 +2065,30 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 112 records and the following variables: +An object of data.frame class with 112 records +and the following variables: \begin{description} -\item[YearMonth] is the year and month during of the priority cut date, with a required date format of \code{YYYYMM}. -\item[Pdate\_BWR] is the date of the priority cut applied to Big Wood River above Magic Reservoir by Water District 37. -\item[Pdate\_SC] is the date of the priority cut applied to Silver Creek by Water District 37M. +\item[YearMonth] year and month during of the priority cut date, +with a required date format of YYYYMM. +\item[Pdate\_BWR] date of the priority cut applied to +Big Wood River above Magic Reservoir by Water District 37. +\item[Pdate\_SC] date of the priority cut applied to +Silver Creek by Water District 37M. \end{description} - \end{Format} % \begin{Source}\relax Idaho Department of Water Resources, accessed on November 17, 2014; -compiled priority cut dates in effect at the end of each month, derived from Water District 37 and 37M records +compiled priority cut dates in effect at the end of each month, +derived from Water District 37 and 37M records. \end{Source} % \begin{Examples} \begin{ExampleCode} str(priority.cuts) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2753,18 +2106,22 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygons} class containing 669 \code{Polygons}. +An object of SpatialPolygons class containing 669 Polygons. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the +Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax Idaho Department of Water Resources, accessed on November 29, 2014; -derived from Blaine County tax lots and aerial photography +derived from Blaine County tax lots and aerial photography. \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(public.parcels) +sp::plot(public.parcels) print(public.parcels) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -2782,265 +2139,135 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{RasterLayer} class with indexed cell values linked to a raster attribute table (RAT). +An object of RasterLayer class with indexed cell values linked to +a raster attribute table (RAT). The RAT is a \code{data.frame} with the following components: \begin{description} -\item[ID] the integer cell index. -\item[COUNT] the frequency of the cell index in the raster grid. -\item[EntityName] the name of the irrigation entity served by the canal system. - -\end{description} - -\end{Format} -% -\begin{Source}\relax -Calculated by transferring the \code{\LinkA{canals}{canals}} dataset to grid cells in the \code{\LinkA{land.surface}{land.surface}} dataset using the \code{rasterize} function; -see the \file{package-datasets} vignette for the \R{} code used in this calculation. -\end{Source} -% -\begin{Examples} -\begin{ExampleCode} -plot(r.canals) -print(levels(r.canals)[[1]]) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{reach.recharge}{Stream-Aquifer Flow Exchange Along River Reaches}{reach.recharge} -\keyword{datasets}{reach.recharge} -% -\begin{Description}\relax -Stream-aquifer flow exchange along river reaches specified as aquifer recharge. -Values used as observations in parameter estimation. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -reach.recharge -\end{verbatim} -\end{Usage} -% -\begin{Format} -A \code{data.frame} object with 192 records and the following variables: -\begin{description} - -\item[YearMonth] is the year and month of the measurement record, with a required date format of \code{YYYYMM}. -\item[nKet\_Hai] the stream-aquifer flow exchange in the Big Wood River, near Ketchum to Hailey river reach, in cubic meters per day. -\item[Hai\_StC] the stream-aquifer flow exchange in the Big Wood River, Hailey to Stanton Crossing river reach, in cubic meters per day. -\item[WillowCr] the stream-aquifer flow exchange in the Willow Creek river reach, in cubic meters per day. -\item[SilverAbv] the stream-aquifer flow exchange in Silver Creek, above Sportsman Access river reach, in cubic meters per day. -\item[SilverBlw] the stream-aquifer flow exchange in Silver Creek, Sportsman Access to near Picabo river reach, in cubic meters per day. +\item[ID] cell index +\item[COUNT] frequency of the cell index in the raster grid. +\item[EntityName] name of the irrigation entity served by the canal system. \end{description} - \end{Format} % -\begin{Details}\relax -A positive stream-aquifer flow exchange indicates aquifer recharge (a losing river reach). -\end{Details} -% -\begin{Source}\relax -Calculated from continuous stream flow measurements, diversion data, return flow data, and exchange well data -using a flow difference method to estimate groundwater inflows and outflows along a river reach, accessed on September 1, 2015. -Derived from U.S. Geological Survey, Idaho Power Company, and Water District 37 and 37M records. -\end{Source} -% -\begin{Examples} -\begin{ExampleCode} -str(reach.recharge) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{ReadModflowBinary}{Read MODFLOW Binary File}{ReadModflowBinary} -\keyword{IO}{ReadModflowBinary} -% -\begin{Description}\relax -This function reads binary output data from a \Rhref{http://water.usgs.gov/ogw/modflow/}{MODFLOW} run. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -ReadModflowBinary(f, data.type = c("array", "flow"), rm.totim.0 = FALSE) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{f}] \code{character}; the name of the binary file. -\item[\code{data.type}] \code{character}; a description of how the data are saved. -\item[\code{rm.totim.0}] \code{logical}; if \code{TRUE}, stress-periods at time zero are removed. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -This function reads binary head (\file{.hds}), drawdown (\file{.ddn}), and budget (\file{.bud}) files generated from a MODFLOW run. -\end{Details} -% -\begin{Value} -Returns a \code{list} object of length equal to the number of times the data type is written to the binary file. -List components are \code{list} objects with the following components: -\begin{ldescription} -\item[\code{d}] \code{matrix} or \code{data.frame}; the data values. -\item[\code{kstp}] \code{integer}; the time step. -\item[\code{kper}] \code{integer}; the stress period. -\item[\code{desc}] \code{character}; the variable name. -\item[\code{ilay}] \code{integer}; the model-grid layer. -\item[\code{delt}] \code{numeric}; the length of the current time step. -\item[\code{pertim}] \code{numeric}; the time in the stress period. -\item[\code{totim}] \code{numeric}; the total elapsed time. -\end{ldescription} -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{\LinkA{SummariseBudget}{SummariseBudget}} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -## Not run: -path <- file.path(getwd(), "SIR2016-5080/output/output.model1") -hds <- ReadModflowBinary(file.path(path, "wrv_mfusg.hds"), "array") -bud <- ReadModflowBinary(file.path(path, "wrv_mfusg.bud"), "flow") -## End(Not run) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{ReplaceInTemplate}{Replace Values in a Template Text}{ReplaceInTemplate} -\keyword{IO}{ReplaceInTemplate} -% -\begin{Description}\relax -This function replaces keys within special markups in a template text with specified values. -Pieces of \R{} code can be put into the markups of the template text, and are evaluated during the replacement. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -ReplaceInTemplate(text, replacement) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{text}] \code{character}; a vector of character strings, the template text. -\item[\code{replacement}] \code{list}; the values to replace in \code{text}. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -Keys are enclosed into markups of the form \code{\$(KEY)} and \code{@\{CODE\}}. -\end{Details} -% -\begin{Value} -A vector of character strings after key replacement. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{References}\relax -This code was derived from the \Rhref{http://cran.r-project.org/web/packages/sensitivity/}{sensitivity}\code{::template.replace} function. -\end{References} +\begin{Source}\relax +Calculated by transferring the \code{\LinkA{canals}{canals}} dataset to grid cells in the +\code{\LinkA{land.surface}{land.surface}} dataset using the \code{rasterize} function; +see the appendix C. Package Dataset Creation for the \R{} code used in this calculation. +\end{Source} % \begin{Examples} \begin{ExampleCode} -text <- c("Hello $(name)!", "$(a) + $(b) = @{$(a) + $(b)}", - "pi = @{format(pi, digits = 5)}") -replacement <- list(name = "world", a = 1, b = 2) -cat(ReplaceInTemplate(text, replacement), sep = "\n") +sp::plot(r.canals) +print(levels(r.canals)[[1]]) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} -\HeaderA{river.reaches}{Major River Reaches}{river.reaches} -\keyword{datasets}{river.reaches} +\HeaderA{reach.recharge}{Stream-Aquifer Flow Exchange Along River Reaches}{reach.recharge} +\keyword{datasets}{reach.recharge} % \begin{Description}\relax -The major river reaches of the Wood River Valley, Idaho. +Stream-aquifer flow exchange along river reaches specified as aquifer recharge. +Values used as observations in parameter estimation. \end{Description} % \begin{Usage} \begin{verbatim} -river.reaches +reach.recharge \end{verbatim} \end{Usage} % \begin{Format} -An object of \code{SpatialLinesDataFrame} class containing 22 \code{Lines} and a \code{data.frame} with the following variables: +An object of \code{data.frame} class with 192 records and the following variables: \begin{description} -\item[Reach] is the name of the subreaches measured in U.S. Geological Survey (USGS) seepage survey. -\item[BigReach] is the name of the reaches for which time series targets are available for part or all of the calibration period. -\item[DrainRiver] is the model boundary assignment, either ``drain'' or ``river''. -\item[RchAvg] is the estimated average reach gain in cubic meters per day for 1995-2010 based on a combination of gage data and the USGS seepage survey. -\item[BigRAv] is the estimated average reach gain in cubic meters per day for 1995-2010 based on gage data. -\item[ReachNo] is the reach number identifier. -\item[Depth] is the estimated average depth in meters of water in reach, measured from the air-water interface to the top of the riverbed sediments. -\item[BedThk] is the estimated thickness in meters of the saturated riverbed sediments. +\item[YearMonth] year and month of the measurement record, +with a required date format of \code{YYYYMM}. +\item[nKet\_Hai] stream-aquifer flow exchange in the Big Wood River, +near Ketchum to Hailey river reach, in cubic meters per day. +\item[Hai\_StC] stream-aquifer flow exchange in the Big Wood River, +Hailey to Stanton Crossing river reach, in cubic meters per day. +\item[WillowCr] stream-aquifer flow exchange in the Willow Creek river reach, +in cubic meters per day. +\item[SilverAbv] stream-aquifer flow exchange in Silver Creek, +above Sportsman Access river reach, in cubic meters per day. +\item[SilverBlw] stream-aquifer flow exchange in Silver Creek, +Sportsman Access to near Picabo river reach, in cubic meters per day. \end{description} - -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % +\begin{Details}\relax +A positive stream-aquifer flow exchange indicates aquifer recharge +(a losing river reach). +\end{Details} +% \begin{Source}\relax -Idaho Department of Water Resources, accessed on June 6, 2015 +Calculated from continuous stream flow measurements, diversion data, +return flow data, and exchange well data using a flow difference method to +estimate groundwater inflows and outflows along a river reach, +accessed on September 1, 2015. +Derived from U.S. Geological Survey, Idaho Power Company, +and Water District 37 and 37M records. \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(river.reaches) -str(river.reaches@data) +str(reach.recharge) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} -\HeaderA{RmSmallCellChunks}{Remove Small Cell Chunks}{RmSmallCellChunks} -\keyword{utilities}{RmSmallCellChunks} +\HeaderA{river.reaches}{Major River Reaches}{river.reaches} +\keyword{datasets}{river.reaches} % \begin{Description}\relax -This function identifies cell chunks in a single raster grid layer, -where a cell chunk is defined as a group of connected cells with non-missing values. -The cell chunk with the largest surface area is preserved and all others removed. +Major river reaches of the Wood River Valley, Idaho. \end{Description} % \begin{Usage} \begin{verbatim} -RmSmallCellChunks(r) +river.reaches \end{verbatim} \end{Usage} % -\begin{Arguments} -\begin{ldescription} -\item[\code{r}] \code{RasterLayer}; a raster grid layer with cell values. -\end{ldescription} -\end{Arguments} -% -\begin{Value} -The raster grid layer \code{r} with cell values in the smaller cell chunks set to \code{NA}. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} +\begin{Format} +An object of SpatialLinesDataFrame class containing 22 Lines and a +data.frame with the following variables: +\begin{description} + +\item[Reach] name of the subreaches measured in U.S. Geological Survey (USGS) +seepage survey. +\item[BigReach] name of the reaches for which time series targets are available for +part or all of the calibration period. +\item[DrainRiver] model boundary assignment, either ``drain'' or ``river''. +\item[RchAvg] estimated average reach gain in cubic meters per day for 1995-2010 +based on a combination of gage data and the USGS seepage survey. +\item[BigRAv] estimated average reach gain in cubic meters per day for 1995-2010 +based on gage data. +\item[ReachNo] reach number identifier. +\item[Depth] estimated average depth in meters of water in reach, +measured from the air-water interface to the top of the riverbed sediments. +\item[BedThk] estimated thickness in meters of the saturated riverbed sediments. + +\end{description} + +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the +Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\end{Format} % -\begin{SeeAlso}\relax -\code{clump} -\end{SeeAlso} +\begin{Source}\relax +Idaho Department of Water Resources, accessed on June 6, 2015 +\end{Source} % \begin{Examples} \begin{ExampleCode} -set.seed(0) -r <- raster(ncols = 10, nrows = 10) -r[] <- round(runif(ncell(r)) * 0.7) -r <- clump(r) -plot(r) - -r.new <- RmSmallCellChunks(r) -plot(r.new, zlim = range(r[], na.rm = TRUE)) +sp::plot(river.reaches) +str(river.reaches@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3058,29 +2285,34 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of class \code{RasterStack} class containing a 192 \code{RasterLayer} objects, one layer for each month in the 1995-2010 time period. +An object of RasterStack class containing a 192 RasterLayer objects, +one layer for each month in the 1995-2010 time period. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the +Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). For each raster layer, indexed cell values are linked to a raster attribute table (RAT). -The RAT is a \code{data.frame} with the following components: +The RAT is an object of data.frame class with the following components: \begin{description} -\item[ID] the integer cell index. -\item[COUNT] the frequency of the cell index in the raster grid. -\item[EntityName] the name of the irrigation entity served by a group of diversions. +\item[ID] cell index +\item[COUNT] frequency of the cell index in the raster grid. +\item[EntityName] name of the irrigation entity served by a group of diversions. \end{description} - \end{Format} % \begin{Source}\relax -Calculated by transferring the \code{\LinkA{entity.components}{entity.components}} dataset to grid cells in the \code{\LinkA{land.surface}{land.surface}} dataset using the \code{rasterize} function; -see the \file{package-datasets} vignette for the \R{} code used in this calculation. +Calculated by transferring the \code{\LinkA{entity.components}{entity.components}} dataset to grid cells +in the \code{\LinkA{land.surface}{land.surface}} dataset using the rasterize function; +see the appendix C. Package Dataset Creation for the \R{} code used in this calculation. \end{Source} % \begin{Examples} \begin{ExampleCode} names(rs.entities) -plot(rs.entities[["199507"]]) +sp::plot(rs.entities[["199507"]]) print(levels(rs.entities[["199507"]])[[1]]) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3088,7 +2320,8 @@ \chapter*{} \keyword{datasets}{rs.rech.non.irr} % \begin{Description}\relax -Aerial recharge and discharge on non-irrigated lands of the Wood River Valley and surrounding areas transferred to raster cells. +Aerial recharge and discharge on non-irrigated lands of the Wood River Valley and +surrounding areas transferred to raster cells. \end{Description} % \begin{Usage} @@ -3098,19 +2331,25 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{RasterStack} class containing 192 \code{RasterLayer} objects, one layer for each month in the 1995-2010 time period. +An object of RasterStack class containing 192 RasterLayer objects, +one layer for each month in the 1995-2010 time period. Each cell on a layers surface grid represents the monthly recharge in meters. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the +Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Calculated from the \code{et}, \code{\LinkA{precipitation}{precipitation}}, \code{\LinkA{precip.zones}{precip.zones}}, and \code{\LinkA{soils}{soils}} datasets; -see the \file{package-datasets} vignette for the \R{} code used in this calculation. +Calculated from the \code{\LinkA{et}{et}}, \code{\LinkA{precipitation}{precipitation}}, +\code{\LinkA{precip.zones}{precip.zones}}, and \code{\LinkA{soils}{soils}} datasets; +see the appendix C. Package Dataset Creation for the \R{} code used in this calculation. \end{Source} % \begin{Examples} \begin{ExampleCode} names(rs.rech.non.irr) -plot(rs.rech.non.irr[["199507"]]) +sp::plot(rs.rech.non.irr[["199507"]]) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3118,7 +2357,8 @@ \chapter*{} \keyword{manip}{RunWaterBalance} % \begin{Description}\relax -This function estimates areal recharge, and pumping demand at production wells. +This function estimates natural and incidental groundwater recharge at the water table, +and pumping demand at production wells. A water-balance approach is used to calculate these volumetric flow rate estimates, where positive values are flow into the aqufer system (groundwater recharge), and negative values are flow out of the system (groundwater discharge). @@ -3126,89 +2366,189 @@ \chapter*{} % \begin{Usage} \begin{verbatim} -RunWaterBalance(tr.stress.periods, r.grid, eff, seep, ss.stress.periods = NULL, - verbose = FALSE) +RunWaterBalance(r.grid, tr.stress.periods, ss.stress.periods = NULL, + canal.seep = wrv::canal.seep, comb.sw.irr = wrv::comb.sw.irr, + div.gw = wrv::div.gw, div.sw = wrv::div.sw, div.ww = wrv::div.ww, + efficiency = wrv::efficiency, entity.components = wrv::entity.components, + et = wrv::et, irr.entities = wrv::irr.entities, + land.surface = wrv::land.surface, pod.gw = wrv::pod.gw, + priority.cuts = wrv::priority.cuts, r.canals = wrv::r.canals, + rs.entities = wrv::rs.entities, rs.rech.non.irr = wrv::rs.rech.non.irr, + verbose = FALSE) \end{verbatim} \end{Usage} % \begin{Arguments} \begin{ldescription} -\item[\code{tr.stress.periods}] \code{Date}; a vector of start and end dates for each stress period in the simulation. -\item[\code{r.grid}] \code{RasterLayer}; a raster of numeric values where \code{NA} indicates an `inactive' cell in the top layer of the model. -\item[\code{eff}] \code{data.frame}; see \code{\LinkA{efficiency}{efficiency}} dataset for details. -\item[\code{seep}] \code{data.frame}; see \code{\LinkA{canal.seep}{canal.seep}} dataset for details. -\item[\code{ss.stress.periods}] \code{Date}; a vector of start and end dates for stress periods used to create steady-state conditions. -\item[\code{verbose}] \code{logical}; indicates whether to return summary tables \code{natural.rech}, \code{inciden.rech}, \code{pumping.rech}; -see `Value' section for table formats. +\item[\code{r.grid}] RasterLayer. +Gridded numeric values where NA indicates an `inactive' cell in +the top model layer. + +\item[\code{tr.stress.periods}] Date. +Vector of start and end dates for each stress period in the simulation. + +\item[\code{ss.stress.periods}] Date. +Vector of start and end dates for stress periods used to create steady-state conditions. + +\item[\code{canal.seep}] data.frame. +See \code{\LinkA{canal.seep}{canal.seep}} dataset for details. + +\item[\code{comb.sw.irr}] data.frame. +See \code{\LinkA{comb.sw.irr}{comb.sw.irr}} dataset for details. + +\item[\code{div.gw}] data.frame. +See \code{\LinkA{div.gw}{div.gw}} dataset for details. + +\item[\code{div.sw}] data.frame. +See \code{\LinkA{div.sw}{div.sw}} dataset for details. + +\item[\code{div.ww}] data.frame. +See \code{\LinkA{div.gw}{div.gw}} dataset for details. + +\item[\code{efficiency}] data.frame. +See \code{\LinkA{efficiency}{efficiency}} dataset for details. + +\item[\code{entity.components}] list. +See \code{\LinkA{entity.components}{entity.components}} dataset for details. + +\item[\code{et}] RasterStack. +See \code{\LinkA{et}{et}} dataset for details. + +\item[\code{irr.entities}] SpatialPolygonsDataFrame. +See \code{\LinkA{irr.entities}{irr.entities}} dataset for details. + +\item[\code{land.surface}] RasterLayer. +See \code{\LinkA{land.surface}{land.surface}} dataset for details. + +\item[\code{pod.gw}] data.frame. +See \code{\LinkA{pod.gw}{pod.gw}} dataset for details. + +\item[\code{priority.cuts}] data.frame. +See \code{\LinkA{priority.cuts}{priority.cuts}} dataset for details. + +\item[\code{r.canals}] RasterLayer. +See \code{\LinkA{r.canals}{r.canals}} dataset for details. + +\item[\code{rs.entities}] RasterStack. +See \code{\LinkA{rs.entities}{rs.entities}} dataset for details. + +\item[\code{rs.rech.non.irr}] RasterStack. +See \code{\LinkA{rs.rech.non.irr}{rs.rech.non.irr}} dataset for details. + +\item[\code{verbose}] logical. +Indicates whether to return summary tables: +\code{natural.rech}, \code{inciden.rech}, and \code{pumping.rech}. \end{ldescription} \end{Arguments} % \begin{Value} -Returns a \code{list} object with the following components: +Returns an object of class list with the following components: -(1) Water-table flow data (combines natural and incidental groundwater recharge and discharge) are stored in \code{areal.rech}, -an object of \code{RasterStack} class with raster layers for each model stress period; +(1) Water-table flow data (combines natural and incidental groundwater recharge) +are stored in \code{areal.rech}, +an object of RasterStack class with raster layers for each model stress period; cell values are specified as volumetric flow rates in cubic meters per day. -(2) Production well pumping data are stored in \code{pod.rech}, an object of \code{data.frame} class with the following components: -\begin{ldescription} -\item[\code{WMISNumber}] \code{numeric}; a unique number assigned to a water right point of diversion. -\item[\code{ss, 199501, ..., 201012}] \code{numeric}; is the volumetric flow rate, specified for each stress period, in cubic meters per day. +(2) Production well pumping data are stored in \code{pod.rech}, +an object of \code{data.frame} class with the following components: +\begin{description} -\end{ldescription} -(3) Natural groundwater recharge and discharge data are stored in \code{natural.rech}, an object of \code{data.frame} class with the following components: -\begin{ldescription} -\item[\code{YearMonth}] \code{factor}; is the calendar year and month \code{YYYYMM}. -\item[\code{Area}] \code{numeric}; the land-surface area of non-irrigated lands, in square meters. -\item[\code{ET}] \code{numeric}; evapotranspiration on non-irrigated lands, in cubic meters per month. -\item[\code{Rech}] \code{numeric}; is the volumetric flow rate, in cubic meters per month. +\item[WMISNumber] unique number assigned to a water right point of diversion. +\item[ss,199501,\dots,201012] volumetric flow rate, specified for each stress period, +in cubic meters per day. -\end{ldescription} -(4) Incidental groundwater recharge data are stored in \code{inciden.rech}, an object of \code{data.frame} class with the following components: -\begin{ldescription} -\item[\code{EntityName}] \code{character}; is the name of the irrigation entity. -\item[\code{YearMonth}] \code{factor}; is the calendar year and month \code{YYYYMM}. -\item[\code{SWDiv}] \code{numeric}; surface-water diversions, in cubic meters per month. -\item[\code{SeepFrac}] \code{numeric}; canal seepage as a fraction of diversions, a dimensionless quantity. -\item[\code{CanalSeep}] \code{numeric}; canal seepage, in cubic meters per month. -\item[\code{SWDel}] \code{numeric}; surface-water delivered to field headgates, in cubic meters per month. -\item[\code{area.sw}] \code{numeric}; area irrigated by only surface water, in square meters. -\item[\code{et.sw}] \code{numeric}; evapotranspiration on lands irrigated by only surface water, in cubic meters per month. -\item[\code{precip.sw}] \code{numeric}; precipitation on lands irrigated by only surface water, in cubic meters per month. -\item[\code{cir.sw}] \code{numeric}; crop irrigation requirement on lands irrigated by only surface water, in cubic meters per month. -\item[\code{area.mix}] \code{numeric}; area irrigated by both surface and groundwater, in square meters. -\item[\code{et.mix}] \code{numeric}; evapotranspiration on lands irrigated by both surface and groundwater, in cubic meters per month. -\item[\code{precip.mix}] \code{numeric}; precipitation on lands irrigated by both surface and groundwater, in cubic meters per month. -\item[\code{cir.mix}] \code{numeric}; crop irrigation requirement on lands irrigated by both surface and groundwater, in cubic meters per month. -\item[\code{area.gw}] \code{numeric}; area irrigated by only groundwater, in square meters. -\item[\code{et.gw}] \code{numeric}; evapotranspiration on lands irrigated by only groundwater, in cubic meters per month. -\item[\code{precip.gw}] \code{numeric}; precipitation on lands irrigated by only groundwater, in cubic meters per month. -\item[\code{cir.gw}] \code{numeric}; crop irrigation requirement on lands irrigated by only groundwater, in cubic meters per month. -\item[\code{Eff}] \code{numeric}; irrigation efficiency, a dimensionless quantity. -\item[\code{GWDiv}] \code{numeric}; recorded groundwater diversions, in cubic meters per month. -\item[\code{WWDiv}] \code{numeric}; inflow to municipal wastewater treatment plants, in cubic meters per month. -\item[\code{hg.sw}] \code{numeric}; surface-water delivered to field headgates on lands irrigated by only surface water, in cubic meters per month. -\item[\code{hg.mix}] \code{numeric}; surface-water delivered to field headgates on lands irrigation by both surface and groundwater, in cubic meters per month. -\item[\code{rech.sw}] \code{numeric}; incidental groundwater recharge beneath lands irrigated by only surface water, in cubic meters per month. -\item[\code{gw.dem.mix}] \code{numeric}; groundwater demand on lands irrigated by both surface and groundwater, in cubic meters per month. -\item[\code{gw.div.est}] \code{numeric}; calculated groundwater diversions, in cubic meters per month. -\item[\code{rech.mix}] \code{numeric}; incidental groundwater recharge beneath lands irrigated by both surface and groundwater, in cubic meters per month. -\item[\code{gw.only}] \code{numeric}; groundwater demand on lands irrigated by only groundwater in entities with lands also irrigated by both surface and groundwater, in cubic meters per month. -\item[\code{rech.muni}] \code{numeric}; incidental groundwater recharge beneath entities with lands irrigated by only groundwater and lands irrigated by both surface and groundwater, in cubic meters per month. -\item[\code{gw.dem.gw}] \code{numeric}; groundwater demand on lands irrigated by only groundwater in entities without surface-water irrigation, in cubic meters per month. -\item[\code{rech.gw}] \code{numeric}; incidental groundwater recharge beneath lands irrigated by only groundwater, in cubic meters per month. -\item[\code{area.model}] \code{numeric}; area of the irrigation entity that is located in the model domain, in square meters. -\end{ldescription} -Volumetric flow rates are calculated for their respective area in the irrigation entity---not just that part overlying the model area. -Flow rate values are given this way in order to facilitate with quality assurance of the water-budget calculation. -To calculate a simulated volumetric-flow rate: divide the flow rate by the affected area, and then multiply this value by the area of the irrigation entity that is located in the model domain (\code{area.model}). +\end{description} + + +(3) Natural groundwater recharge data are stored in \code{natural.rech}, +an object of data.frame class with the following components: +\begin{description} + +\item[YearMonth] calendar year and month YYYYMM. +\item[Area] land-surface area of non-irrigated lands, in square meters. +\item[ET] evapotranspiration on non-irrigated lands, in cubic meters per month. +\item[Rech] volumetric flow rate, in cubic meters per month. + +\end{description} + + +(4) Incidental groundwater recharge data are stored in \code{inciden.rech}, +an object of data.frame class with the following components: +\begin{description} + +\item[EntityName] name of the irrigation entity. +\item[YearMonth] calendar year and month YYYYMM. +\item[SWDiv] surface-water diversions, in cubic meters per month. +\item[SeepFrac] canal seepage as a fraction of diversions, a dimensionless quantity. +\item[CanalSeep] canal seepage, in cubic meters per month. +\item[SWDel] surface-water delivered to field headgates, in cubic meters per month. +\item[area.sw] area irrigated by only surface water, in square meters. +\item[et.sw] evapotranspiration on lands irrigated by only surface water, +in cubic meters per month. +\item[precip.sw] precipitation on lands irrigated by only surface water, +in cubic meters per month. +\item[cir.sw] crop irrigation requirement on lands irrigated by only surface water, +in cubic meters per month. +\item[area.mix] area irrigated by both surface and groundwater, in square meters. +\item[et.mix] evapotranspiration on lands irrigated by both surface and groundwater, +in cubic meters per month. +\item[precip.mix] precipitation on lands irrigated by both surface and groundwater, +in cubic meters per month. +\item[cir.mix] crop irrigation requirement on lands irrigated by both surface and groundwater, +in cubic meters per month. +\item[area.gw] area irrigated by only groundwater, in square meters. +\item[et.gw] evapotranspiration on lands irrigated by only groundwater, +in cubic meters per month. +\item[precip.gw] precipitation on lands irrigated by only groundwater, +in cubic meters per month. +\item[cir.gw] crop irrigation requirement on lands irrigated by only groundwater, +in cubic meters per month. +\item[Eff] irrigation efficiency, a dimensionless quantity. +\item[GWDiv] recorded groundwater diversions, in cubic meters per month. +\item[WWDiv] inflow to municipal wastewater treatment plants, in cubic meters per month. +\item[hg.sw] surface-water delivered to field headgates on lands irrigated by only surface water, +in cubic meters per month. +\item[hg.mix] surface-water delivered to field headgates on lands irrigation by both surface and groundwater, +in cubic meters per month. +\item[rech.sw] incidental groundwater recharge beneath lands irrigated by only surface water, +in cubic meters per month. +\item[gw.dem.mix] groundwater demand on lands irrigated by both surface and groundwater, +in cubic meters per month. +\item[gw.div.est] calculated groundwater diversions, in cubic meters per month. +\item[rech.mix] incidental groundwater recharge beneath lands irrigated by both surface and groundwater, +in cubic meters per month. +\item[gw.only] groundwater demand on lands irrigated by only groundwater in entities with +lands also irrigated by both surface and groundwater, in cubic meters per month. +\item[rech.muni] incidental groundwater recharge beneath entities with +lands irrigated by only groundwater and lands irrigated by both surface and groundwater, +in cubic meters per month. +\item[gw.dem.gw] groundwater demand on lands irrigated by only groundwater in +entities without surface-water irrigation, in cubic meters per month. +\item[rech.gw] incidental groundwater recharge beneath lands irrigated by only groundwater, +in cubic meters per month. +\item[area.model] area of the irrigation entity that is located in the model domain, +in square meters. + +\end{description} + +Volumetric flow rates are calculated for their respective area in +the irrigation entity---not just that part overlying the model area. +Flow rate values are given this way in order to facilitate with quality assurance of +the water-budget calculation. +To calculate a simulated volumetric-flow rate: divide the flow rate by the affected area, +and then multiply this value by the area of the irrigation entity that is located in +the model domain (\code{area.model}). + +(5) Well pumping data are also stored in \code{pumping.rech} (see \code{pod.rech} component), +an object of data.frame class with the following components: +\begin{description} + +\item[WMISNumber] unique number assigned to a water right point of diversion. +\item[YearMonth] calendar year and month YYYYMM. +\item[Pumping] volumetric rate of pumping, in cubic meters per month. + +\end{description} -(5) Well pumping data are also stored in \code{pumping.rech} (see \code{pod.rech} component), an object of \code{data.frame} class with the following components: -\begin{ldescription} -\item[\code{WMISNumber}] \code{numeric}; a unique number assigned to a water right point of diversion. -\item[\code{YearMonth}] \code{factor}; is the calendar year and month \code{YYYYMM}. -\item[\code{Pumping}] \code{numeric}; is the volumetric rate of pumping, in cubic meters per month. -\end{ldescription} \end{Value} % \begin{Author}\relax @@ -3223,7 +2563,8 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -## Not run: # see wrv-introduction vignette +## Not run: # see Appendix A. Package Introduction + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3231,7 +2572,8 @@ \chapter*{} \keyword{datasets}{seepage.study} % \begin{Description}\relax -A Wood River Valley stream seepage study with streamflow measurements made during the months of August 2012, October 2012, and March 2013. +A Wood River Valley stream seepage study with streamflow measurements made during +the months of August 2012, October 2012, and March 2013. \end{Description} % \begin{Usage} @@ -3241,37 +2583,46 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 82 points with the following variables: +An object of SpatialPointsDataFrame class containing 82 points +with the following variables: \begin{description} -\item[Order] an index used to preserve the downstream order of measurement sites. -\item[Name] a local name for the measurement site. -\item[SiteNo] a unique identifier for the measurement site within the National Water Information System (NWIS). +\item[Order] index used to preserve the downstream order of measurement sites. +\item[Name] local name for the measurement site. +\item[SiteNo] unique identifier for the measurement site within the +National Water Information System (NWIS). \item[Type] the type of measurement site: -``Big Wood River'', ``Willow Creek'', ``Spring fed creeks'', ``Silver Creek'', ``Diversion'', ``Exchange well inflow'', ``Return'', and ``Tributary''. -\item[Comments] an abbreviated site name. -\item[Aug] the volumetric flow rate measured during August 2012, in cubic meters per day. -\item[Oct] the volumetric flow rate measured during October 2012, in cubic meters per day. -\item[Mar] the volumetric flow rate measured during March 2013, in cubic meters per day. +``Big Wood River'', ``Willow Creek'', ``Spring fed creeks'', +``Silver Creek'', ``Diversion'', ``Exchange well inflow'', +``Return'', and ``Tributary''. +\item[Comments] abbreviated site name +\item[Aug] volumetric flow rate measured during August 2012, in cubic meters per day. +\item[Oct] volumetric flow rate measured during October 2012, in cubic meters per day. +\item[Mar] volumetric flow rate measured during March 2013, in cubic meters per day. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Derived from Bartolino (2014) seepage study, Idaho Department of Water Resources, Water District 37 and 37M flow records. +Derived from Bartolino (2014) seepage study, +Idaho Department of Water Resources, Water District 37 and 37M flow records. \end{Source} % \begin{References}\relax -Bartolino, J.R., 2014, Stream seepage and groundwater levels, Wood River Valley, south-central Idaho, 2012--13: U.S. Geological Survey Scientific Investigations Report 2014-5151, 34 p., \url{http://dx.doi.org/10.3133/sir20145151}. +Bartolino, J.R., 2014, Stream seepage and groundwater levels, Wood River Valley, +south-central Idaho, 2012--13: U.S. Geological Survey Scientific Investigations Report 2014-5151, +34 p., \url{http://dx.doi.org/10.3133/sir20145151}. \end{References} % \begin{Examples} \begin{ExampleCode} -plot(seepage.study) +sp::plot(seepage.study) str(seepage.study@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3289,23 +2640,25 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 336 records and the following variables: +An object of data.frame class with 336 records and the following variables: \begin{description} -\item[parameter.desc] is a description of the parameter. -\item[ID] is a unique identifier within the parameter type, such as an identifier for a pilot point or irrigation entity. -\item[units] is the parameter units. -\item[start.value] is the starting parameter value prior to model calibration. -\item[lower.bound] is the lower bound placed on the parameter value during the model-calibration process. -\item[upper.bound] is the upper bound placed on the parameter value during the model-calibration process. -\item[parameter.name] is the \Rhref{http://www.pesthomepage.org/}{PEST} parameter name. -\item[group] is the PEST parameter group. -\item[value] is the calibrated parameter value estimated by PEST. -\item[comp.sens] is the composite sensitivity generated during the final iteration of PEST. -\item[rel.comp.sens] is the relative composite sensitivity. +\item[parameter.desc] parameter description +\item[ID] unique identifier within the parameter type, +such as an identifier for a pilot point or irrigation entity. +\item[units] parameter units +\item[start.value] starting parameter value prior to model calibration. +\item[lower.bound] lower bound placed on the parameter value +during the model-calibration process. +\item[upper.bound] upper bound placed on the parameter value +during the model-calibration process. +\item[parameter.name] \Rhref{http://www.pesthomepage.org/}{PEST} parameter name +\item[group] PEST parameter group +\item[value] calibrated parameter value estimated by PEST. +\item[comp.sens] composite sensitivity generated during the final iteration of PEST. +\item[rel.comp.sens] relative composite sensitivity \end{description} - \end{Format} % \begin{Source}\relax @@ -3313,75 +2666,14 @@ \chapter*{} \end{Source} % \begin{SeeAlso}\relax -\code{\LinkA{pilot.points}{pilot.points}}, \code{\LinkA{irr.entities}{irr.entities}}, \code{\LinkA{river.reaches}{river.reaches}}, \code{\LinkA{drains}{drains}}, \code{\LinkA{tributaries}{tributaries}} +\code{\LinkA{pilot.points}{pilot.points}}, \code{\LinkA{irr.entities}{irr.entities}}, +\code{\LinkA{river.reaches}{river.reaches}}, \code{\LinkA{drains}{drains}}, \code{\LinkA{tributaries}{tributaries}} \end{SeeAlso} % \begin{Examples} \begin{ExampleCode} str(sensitivity) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{SetPolygons}{Analysis of Multi-Polygon Objects}{SetPolygons} -\keyword{utilities}{SetPolygons} -% -\begin{Description}\relax -Determines the intersection or difference between two multi-polygon objects. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -SetPolygons(x, y, cmd = c("gIntersection", "gDifference"), buffer.width = NA) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{x}] \code{SpatialPolygons*}; a multi-polygon object. -\item[\code{y}] \code{SpatialPolygons*} or \code{Extent}; a multi-polygon object. -\item[\code{cmd}] \code{character}; specifying \code{"gIntersection"}, the default, cuts out portions of the \code{x} polygons that overlay the \code{y} polygons. -If \code{"gDifference"} is specified, only those portions of the \code{x} polygons falling outside the \code{y} polygons are copied to the output polygons. -\item[\code{buffer.width}] \code{numeric}; expands or contracts the geometry of \code{y} to include the area within the specified width, see \code{gBuffer}. -Specifying \code{NA}, the default, indicates no buffer. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -This function tests if the resulting geometry is valid, see \code{gIsValid}. -\end{Details} -% -\begin{Value} -Returns an object of \code{SpatialPolygons*} class. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{SeeAlso}\relax -\code{gIntersection}, \code{gDifference} -\end{SeeAlso} -% -\begin{Examples} -\begin{ExampleCode} -library(sp) - -m1a <- matrix(c(17.5, 24.7, 22.6, 16.5, 55.1, 55.0, 61.1, 59.7), nrow = 4, ncol = 2) -m1b <- m1a -m1b[, 1] <- m1b[, 1] + 11 -p1 <- SpatialPolygons(list(Polygons(list(Polygon(m1a, FALSE), Polygon(m1b, FALSE)), 1))) -plot(p1, col = "blue") -m2a <- matrix(c(19.6, 35.7, 28.2, 60.0, 58.8, 64.4), nrow = 3, ncol = 2) -m2b <- matrix(c(20.6, 30.9, 27.3, 56.2, 53.8, 51.4), nrow = 3, ncol = 2) -p2 <- SpatialPolygons(list(Polygons(list(Polygon(m2a, FALSE), Polygon(m2b, FALSE)), 2))) -plot(p2, col = "red", add = TRUE) - -p <- SetPolygons(p1, p2, "gIntersection") -plot(p, col = "green", add = TRUE) - -p <- SetPolygons(p2, p1, "gDifference") -plot(p, col = "purple", add = TRUE) \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3389,8 +2681,11 @@ \chapter*{} \keyword{datasets}{soils} % \begin{Description}\relax -Representation of mapped surficial soil units created by the Idaho Office of the National Resource Conservation Service (NRCS). -Soils have been assigned a percolation rate based on the average, saturated hydraulic conductivity of the soils as classified using the Unified Soil Classification System (USCS). +Representation of mapped surficial soil units created by the Idaho Office of the +National Resource Conservation Service (NRCS). +Soils have been assigned a percolation rate based on the average, +saturated hydraulic conductivity of the soils as classified using the +Unified Soil Classification System (USCS). \end{Description} % \begin{Usage} @@ -3400,20 +2695,24 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing 718 \code{Polygons} and a \code{data.frame} with the following variables: +An object of SpatialPolygonsDataFrame class containing 718 Polygons and a +data.frame with the following variables: \begin{description} -\item[GroupSymbol] is a soil class identifier. -\item[SoilLayer] is an identifier used to differentiate the soil data source used to create the soils map. -Data sources are either `USCS' or `STATSGO', the NRCS State Soil Geographic Data Base. -\item[SoilClass] is a description of the soil class. -\item[MinRate] is the lower percolation rate limit for the soil class, in meters per month. -\item[MaxRate] is the upper percolation rate limit for the soil class, in meters per month. -\item[PercolationRate] is the percolation rate in meters per month. +\item[GroupSymbol] soil class identifier +\item[SoilLayer] identifier used to differentiate the soil data source +used to create the soils map. +Data sources are either `USCS' or `STATSGO', +the NRCS State Soil Geographic Data Base. +\item[SoilClass] description of the soil class. +\item[MinRate] lower percolation rate limit for the soil class, in meters per month. +\item[MaxRate] upper percolation rate limit for the soil class, in meters per month. +\item[PercolationRate] percolation rate in meters per month. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -3423,8 +2722,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -spplot(soils, "PercolationRate") +sp::spplot(soils, "PercolationRate") str(soils@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3442,25 +2742,29 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 9 points and a \code{data.frame} with the following variable: +An object of SpatialPointsDataFrame class containing 9 points and a +data.frame with the following variable: \begin{description} -\item[SiteNo] the unique site number for the streamgage. -\item[SiteName] the official name of the streamgage. +\item[SiteNo] unique site number for the streamgage. +\item[SiteName] official name of the streamgage. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -National Water Information System (\Rhref{http://waterdata.usgs.gov/nwis}{NWIS}), accessed on May 29, 2015. +National Water Information System (\Rhref{http://waterdata.usgs.gov/nwis}{NWIS}), +accessed on May 29, 2015. \end{Source} % \begin{Examples} \begin{ExampleCode} str(streamgages) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3478,19 +2782,23 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialLinesDataFrame} class containing 581 \code{Lines}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialLinesDataFrame class containing 581 Lines. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -Idaho Department of Water Resources (\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on April 2, 2014 +Idaho Department of Water Resources +(\Rhref{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), +accessed on April 2, 2014 \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(streams.rivers, col = "#3399CC") +sp::plot(streams.rivers, col = "#3399CC") str(streams.rivers@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3509,92 +2817,36 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 19 records and the following variables: +An object of data.frame class with 19 records and the following variables: \begin{description} -\item[ReachNo] is the subreach number identifier. -\item[Reach] is the name of the subreach. -\item[BigReachNo] is the reach number identifier. -\item[BigReach] is the name of the reach. -\item[Aug] the estimated volumetric flow rate measured during August 2012, in cubic meters per day. -\item[Oct] the estimated volumetric flow rate measured during October 2012, in cubic meters per day. -\item[Mar] the estimated volumetric flow rate measured during March 2013, in cubic meters per day. +\item[ReachNo] subreach number identifier +\item[Reach] name of the subreach. +\item[BigReachNo] reach number identifier +\item[BigReach] name of the reach. +\item[Aug] estimated volumetric flow rate measured during August 2012, +in cubic meters per day. +\item[Oct] estimated volumetric flow rate measured during October 2012, +in cubic meters per day. +\item[Mar] estimated volumetric flow rate measured during March 2013, +in cubic meters per day. \end{description} - \end{Format} % \begin{Details}\relax -A positive stream-aquifer flow exchange indicates aquifer recharge (also know as a losing river subreach). +A positive stream-aquifer flow exchange indicates aquifer recharge +(also know as a losing river subreach). \end{Details} % \begin{Source}\relax -Flow values calculated from \code{seepage.study} data. +Flow values calculated from \code{\LinkA{seepage.study}{seepage.study}} data. \end{Source} % \begin{Examples} \begin{ExampleCode} str(subreach.recharge) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{SummariseBudget}{Summarize Volumetric Water Budget}{SummariseBudget} -\keyword{utilities}{SummariseBudget} -% -\begin{Description}\relax -Summarizes volumetric flow rates for boundary condition types. -Splits the budget data into subsets, computes summary statistics for each, and returns the result in a summary table. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -SummariseBudget(budget, desc = c("wells", "drains", "river leakage")) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{budget}] \code{character} or \code{list}; either a description of the path to the MODFLOW Budget File or the returned results from a call to the \code{\LinkA{ReadModflowBinary}{ReadModflowBinary}} function. -\item[\code{desc}] \code{character}; a vector of MODFLOW package identifiers. -Data of this package type is included in the summary table. -\end{ldescription} -\end{Arguments} -% -\begin{Details}\relax -The \code{budget[[i]]\$d} data table component must contain a numeric \code{id} field, see \code{\LinkA{WriteModflowInput}{WriteModflowInput}} for variable description. -Subsets are grouped by the MODFLOW package identifier (\code{desc}), stress period (\code{kper}), time step (\code{kstp}), and location identifier (\code{id}). -\end{Details} -% -\begin{Value} -Returns an object of \code{data.frame} class with the following components: -\begin{ldescription} -\item[\code{desc}] \code{factor}; is the MODFLOW package identifier. -\item[\code{kper}] \code{integer}; is the stress period. -\item[\code{kstp}] \code{integer}; is the time step. -\item[\code{id}] \code{integer}; is a location identifier. -\item[\code{delt}] \code{numeric}; is the length of the current time step. -\item[\code{pertim}] \code{numeric}; is the time in the stress period. -\item[\code{totim}] \code{numeric}; is the total elapsed time. -\item[\code{count}] \code{integer}; is the number of cells in each subset. -\item[\code{flow.sum}] \code{numeric}; is the total volumetric flow rate. -\item[\code{flow.mean}] \code{numeric}; is the mean volumetric flow rate. -\item[\code{flow.median}] \code{numeric}; is the median volumetric flow rate. -\item[\code{flow.sd}] \code{numeric}; is the standard deviation of the volumetric flow rate. -\item[\code{flow.dir}] \code{factor}; is the flow direction where \code{"in"} and \code{"out"} indicate water entering and leaving the groundwater system, respectively. -\end{ldescription} -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{Examples} -\begin{ExampleCode} -## Not run: -f <- file.path(getwd(), "SIR2016-5080/output/output.model1/wrv_mfusg.bud") -d <- SummariseBudget(f) -str(d) -## End(Not run) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3602,7 +2854,8 @@ \chapter*{} \keyword{datasets}{swe} % \begin{Description}\relax -Average daily snow water equivalent (SWE) at weather stations in the Wood River Valley and surrounding areas. +Average daily snow water equivalent (SWE) at weather stations in the +Wood River Valley and surrounding areas. \end{Description} % \begin{Usage} @@ -3612,16 +2865,17 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with 366 records and the following variables: +An object of data.frame class with 366 records and the following variables: \begin{description} -\item[MonthDay] is the month and day, with a required date format of \code{MMDD}. -\item[Choco] is the daily SWE recorded at the Chocolate Gulch snow telemetry (SNOTEL) weather station. -\item[Hailey] is the daily SWE recorded at the Hailey Ranger Station at Hailey hydrometeorological automated data system (HADS) weather station. -\item[Picabo] is the daily SWE recorded at the Picabo PICI HADS weather station. +\item[MonthDay] month and day, with a required date format of \code{MMDD}. +\item[Choco] daily SWE recorded at the Chocolate Gulch snow telemetry (SNOTEL) +weather station. +\item[Hailey] daily SWE recorded at the Hailey Ranger Station at Hailey +hydrometeorological automated data system (HADS) weather station. +\item[Picabo] daily SWE recorded at the Picabo PICI HADS weather station. \end{description} - \end{Format} % \begin{Source}\relax @@ -3629,54 +2883,14 @@ \chapter*{} \end{Source} % \begin{SeeAlso}\relax -\code{\LinkA{weather.stations}{weather.stations}}, \code{\LinkA{precip.zones}{precip.zones}}, \code{\LinkA{precipitation}{precipitation}} +\code{\LinkA{weather.stations}{weather.stations}}, \code{\LinkA{precip.zones}{precip.zones}}, +\code{\LinkA{precipitation}{precipitation}} \end{SeeAlso} % \begin{Examples} \begin{ExampleCode} str(swe) -\end{ExampleCode} -\end{Examples} -\inputencoding{utf8} -\HeaderA{ToScientific}{Format for Scientific Notation}{ToScientific} -\keyword{utilities}{ToScientific} -% -\begin{Description}\relax -This function formats numbers in scientific notation \eqn{m \times 10^{n}}{}. -\end{Description} -% -\begin{Usage} -\begin{verbatim} -ToScientific(x, digits = format.info(as.numeric(x))[2], - lab.type = c("latex", "plotmath")) -\end{verbatim} -\end{Usage} -% -\begin{Arguments} -\begin{ldescription} -\item[\code{x}] \code{numeric}; a vector of numbers. -\item[\code{digits}] \code{integer}; the number of digits after the decimal point for the mantissa. -\item[\code{lab.type}] \code{character}; by default, LaTeX formatted strings for labels are returned. -Alternatively, \code{lab.type = "plotmath"} returns \code{plotmath}-compatible expressions. -\end{ldescription} -\end{Arguments} -% -\begin{Value} -For the default \code{lab.type = "latex"}, a \code{character} vector of the same length as argument \code{x}. -And for \code{lab.type = "plotmath"}, an \code{expression} of the same length as \code{x}, typically with elements of the form \code{m x 10\textasciicircum{}n}. -In order to comply with \Rhref{http://www.section508.gov/}{Section 508}, -an ``\code{x}'' is used as the label separator for the \code{plotmath} type---rather than the more common ``\code{\%*\%}'' seperator. -\end{Value} -% -\begin{Author}\relax -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -\end{Author} -% -\begin{Examples} -\begin{ExampleCode} -x <- c(-1e+09, 0, NA, pi * 10^(-5:5)) -ToScientific(x, digits = 2) -ToScientific(x, digits = 2, lab.type = "plotmath") + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3684,7 +2898,8 @@ \chapter*{} \keyword{datasets}{tributaries} % \begin{Description}\relax -The location and average flow conditions for model boundaries in the major tributary canyons and upper part of the Wood River Valley, south-central Idaho. +Location and average flow conditions for model boundaries in the +major tributary canyons and upper part of the Wood River Valley, south-central Idaho. \end{Description} % \begin{Usage} @@ -3694,55 +2909,82 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygonsDataFrame} class containing a set of 22 \code{Polygons} and a \code{data.frame} with the following variable: +An object of SpatialPolygonsDataFrame class containing a set of 22 Polygons and a +data.frame with the following variable: \begin{description} -\item[Name] is the tributary name. -\item[MinLSD] is the minimum land-surface datum (elevation) along the transect, in meters above the North American Vertical Datum of 1988 (NAVD 88). -\item[BdrkDepth] is the mean saturated thickness along the transect line, in meters; estimated as the distance between the estimated water table and bedrock elevations. -\item[TribWidth] is the width of the tributary canyon, or length of the transect line, in meters. -\item[LandGrad] is the land surface elevation gradient perpendicular to the cross-sectional transect line, a dimensionless quantity. -\item[K] is the hydraulic conductivity, in meters per day. -\item[SatArea] is the estimated saturated cross-sectional area, in square meters; its geometry is represented as the lower-half of an ellipse with width and height equal to \code{TribWidth} and \code{BdrkDepth}, respectively. -\item[DarcyFlow] is the groundwater flow rate, in cubic meters per day, calculated using a \Rhref{http://en.wikipedia.org/wiki/Darcy_law}{Darcian} analysis. -\item[BasinArea] is the land-surface area defined by the basin above the cross-sectional transect line. -\item[BasinAreaType] is a label that describes the relative basin size; where \code{"big"} indicates a basin area greater than 10 square miles (25.9 square kilometers), and \code{"small"} indicates a basin area that is less than this breakpoint value. -\item[PrecipRate] is the mean precipitation rate within the basin area, in meters per day. -\item[PrecipFlow] is the mean precipitation flow rate, in cubic meters per day, calculated by multiplying \code{PrecipRate} by \code{BasinArea}. -\item[FlowRatio] is the ratio of darcy flow rate to precipitation flow rate, or \code{DarcyFlow} divided by \code{PrecipFlow}, a dimensionless quantity. -\item[Flow] is the estimated average volumetric flow rate, in cubic meters per day. +\item[Name] tributary name +\item[MinLSD] minimum land-surface datum (elevation) along the transect, +in meters above the North American Vertical Datum of 1988 (NAVD 88). +\item[BdrkDepth] mean saturated thickness along the transect line, in meters; +estimated as the distance between the estimated water table and bedrock elevations. +\item[TribWidth] width of the tributary canyon, or length of the transect line, in meters. +\item[LandGrad] land surface elevation gradient perpendicular to the +cross-sectional transect line, a dimensionless quantity. +\item[K] hydraulic conductivity in meters per day. +\item[SatArea] estimated saturated cross-sectional area, in square meters; +its geometry is represented as the lower-half of an ellipse with +width and height equal to \code{TribWidth} and \code{BdrkDepth}, respectively. +\item[DarcyFlow] groundwater flow rate, in cubic meters per day, calculated using a +\Rhref{http://en.wikipedia.org/wiki/Darcy_law}{Darcian} analysis. +\item[BasinArea] land-surface area defined by the basin above the cross-sectional transect line. +\item[BasinAreaType] label that describes the relative basin size; where +\code{"big"} indicates a basin area greater than 10 square miles (25.9 square kilometers), and +\code{"small"} indicates a basin area that is less than this breakpoint value. +\item[PrecipRate] mean precipitation rate within the basin area, in meters per day. +\item[PrecipFlow] mean precipitation flow rate, in cubic meters per day, +calculated by multiplying \code{PrecipRate} by \code{BasinArea}. +\item[FlowRatio] ratio of darcy flow rate to precipitation flow rate, +or \code{DarcyFlow} divided by \code{PrecipFlow}, a dimensionless quantity. +\item[Flow] estimated average volumetric flow rate, in cubic meters per day. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax U.S. Geological Survey, accessed on July 2, 2015; -a Keyhole Markup Language (\Rhref{http://en.wikipedia.org/wiki/Kml}{KML}) file created in \Rhref{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in areas of known specified flow boundaries. -Transect lines are defined by the polygon boundaries within the extent of alluvium aquifer (see \code{\LinkA{alluvium.extent}{alluvium.extent}} dataset). -The land surface gradient (\code{LandGrad}) was estimated from the \code{\LinkA{land.surface}{land.surface}} dataset. -Hydraulic conductivity (\code{K}) is the average of two geometric means of hydraulic conductivity in the unconfined aquifer taken from table 2 in Bartolino and Adkins (2012). -The U.S. Geologic Survey \Rhref{http://water.usgs.gov/osw/streamstats/}{StreamStats} tool (Ries and others, 2004) was used to delineate the basin area (\code{BasinArea}) and estimate the precipitation rate (\code{PrecipRate}). -See the \file{package-datasets} vignette for the \R{} code used to calculate the flow estimates (\code{Flow}). +a Keyhole Markup Language (\Rhref{http://en.wikipedia.org/wiki/Kml}{KML}) file created in +\Rhref{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in +areas of known specified flow boundaries. +Transect lines are defined by the polygon boundaries within the extent of +alluvium aquifer (see \code{\LinkA{alluvium.extent}{alluvium.extent}} dataset). +The land surface gradient (\code{LandGrad}) was estimated from the +\code{\LinkA{land.surface}{land.surface}} dataset. +Hydraulic conductivity (\code{K}) is the average of two geometric means of hydraulic conductivity +in the unconfined aquifer taken from table 2 in Bartolino and Adkins (2012). +The U.S. Geologic Survey \Rhref{http://water.usgs.gov/osw/streamstats/}{StreamStats} tool +(Ries and others, 2004) was used to delineate the basin area (\code{BasinArea}) and +estimate the precipitation rate (\code{PrecipRate}). +See the appendix C. Package Dataset Creation for the \R{} code used to calculate the +flow estimates (\code{Flow}). \end{Source} % \begin{References}\relax -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. - -Ries, K.G., Steeves, P.A., Coles, J.D., Rea, A.H., and Stewart, D.W., 2004, StreamStats--A U.S. Geological Survey web application for stream information: U.S. Geological Survey Fact Sheet FS-2004-3115, 4 p., available at \url{http://pubs.er.usgs.gov/usgspubs/fs/fs20043115}. +Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the +Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey +Scientific Investigations Report 2012-5053, 46 p., +available at \url{http://pubs.usgs.gov/sir/2012/5053/}. + +Ries, K.G., Steeves, P.A., Coles, J.D., Rea, A.H., and Stewart, D.W., 2004, +StreamStats--A U.S. Geological Survey web application for stream information: +U.S. Geological Survey Fact Sheet FS-2004-3115, 4 p., available at +\url{http://pubs.er.usgs.gov/usgspubs/fs/fs20043115}. \end{References} % \begin{Examples} \begin{ExampleCode} -plot(tributaries, border = "red") -plot(alluvium.extent, add = TRUE) +sp::plot(tributaries, border = "red") +sp::plot(alluvium.extent, add = TRUE) str(tributaries@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} -\HeaderA{tributary.streams}{Streams and Rivers}{tributary.streams} +\HeaderA{tributary.streams}{Tributary Streams}{tributary.streams} \keyword{datasets}{tributary.streams} % \begin{Description}\relax @@ -3756,8 +2998,9 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialLinesDataFrame} class containing 88 \code{Lines}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +An object of SpatialLinesDataFrame class containing 88 Lines. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % @@ -3767,8 +3010,9 @@ \chapter*{} % \begin{Examples} \begin{ExampleCode} -plot(tributary.streams, col = "#3399CC") +sp::plot(tributary.streams, col = "#3399CC") str(tributary.streams@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3776,103 +3020,162 @@ \chapter*{} \keyword{utilities}{UpdateWaterBudget} % \begin{Description}\relax -This function runs the water budget calculation and updates the MODFLOW Well Package file. -It is executed during each iteration of PEST and my be run in an interactive \R{} session to initialize the parameter estimation files. +This function determines the specified-flow boundary conditions for the groundwater-flow model. +These boundary conditions include: +(1) natural and incidental groundwater recharge at the water table, +(2) groundwater pumping at production wells, and +(3) groundwater underflow in the major tributary valleys. +Specified-flow values are saved to disk by rewriting the +\Rhref{http://water.usgs.gov/ogw/modflow/}{MODFLOW} Well Package file (\file{.wel}). +Note that this function is executed after each iteration of \Rhref{http://www.pesthomepage.org/}{PEST}. \end{Description} % \begin{Usage} \begin{verbatim} UpdateWaterBudget(dir.run, id, qa.tables = c("none", "si", "english"), - ss.interval = NULL, iwelcb = 0L) + ss.interval = NULL, iwelcb = ifelse(interactive(), 50L, 0L), + canal.seep = wrv::canal.seep, efficiency = wrv::efficiency, + gage.disch = wrv::gage.disch, pod.wells = wrv::pod.wells, + tributaries = wrv::tributaries, ...) \end{verbatim} \end{Usage} % \begin{Arguments} \begin{ldescription} -\item[\code{dir.run}] \code{character}; the path name of the directory to read/write model files. -\item[\code{id}] \code{character}; a short identifier (file name) for model files. -\item[\code{qa.tables}] \code{character}; indicates if quality assurance tables are written to disk; by default \code{"none"} of these tables are written. -Values of \code{"si"} and \code{"english"} indicate that table values are written in metric and English units, respectively. -\item[\code{ss.interval}] \code{Date} or \code{character}; a vector of length 2 specifying the start and end dates for the period used to represent steady-state boundary conditions. -That is, recharge values for stress periods coinciding with this time period are averaged and used as steady-state boundary conditions. -The required date format is \code{YYYY-MM-DD}. -This argument overrides the \code{ss.stress.periods} object in the \file{model.rda} file, see `Details' section for additional information. -\item[\code{iwelcb}] \code{integer}; is a flag and unit number. -If equal to zero, the default, cell-by-cell flow terms resulting from conditions in the MODFLOW Well Package will not be written to disk. -This default value is appropriate for model calibration, where MODFLOW run times are kept as short as possible. +\item[\code{dir.run}] character. +Path name of the directory to read/write model files. + +\item[\code{id}] character. +Short identifier (file name) for model files. + +\item[\code{qa.tables}] character. +Indicates if quality assurance tables are written to disk; +by default "none" of these tables are written. +Values of "si" and "english" indicate that table values are written in +metric and English units, respectively. + +\item[\code{ss.interval}] Date or character. +Vector of length 2 specifying the start and end dates for the period used to +represent steady-state boundary conditions. +That is, recharge values for stress periods coinciding with this time period are +averaged and used as steady-state boundary conditions. +The required date format is YYYY-MM-DD. +This argument overrides the \code{ss.stress.periods} object in the \file{model.rda} file, +see `Details' section for additional information. + +\item[\code{iwelcb}] integer. +A flag and unit number. +If equal to zero, the default, cell-by-cell flow terms resulting from +conditions in the MODFLOW Well Package will not be written to disk. +A value of 0 is appropriate for model calibration, +where MODFLOW run times are kept as short as possible. If greater than zero, the cell-by-cell flow terms are written to disk. -See the MODFLOW Name File (\file{*.nam}) for the unit number associated with the budget file (\file{*.bud}). +See the MODFLOW Name File (\file{*.nam}) for the unit number associated with +the budget file (\file{*.bud}). +The default value is 50 (value specified in the \code{\LinkA{WriteModflowInput}{WriteModflowInput}} function) +if \R{} is being used interactively and 0 otherwise. + +\item[\code{canal.seep}] data.frame. +See \code{\LinkA{canal.seep}{canal.seep}} dataset for details. + +\item[\code{efficiency}] data.frame. +See \code{\LinkA{efficiency}{efficiency}} dataset for details. + +\item[\code{gage.disch}] data.frame. +See \code{\LinkA{gage.disch}{gage.disch}} dataset for details. +\item[\code{pod.wells}] SpatialPointsDataFrame. +See \code{\LinkA{pod.wells}{pod.wells}} dataset for details. + +\item[\code{tributaries}] SpatialPolygonsDataFrame. +See \code{\LinkA{tributaries}{tributaries}} dataset for details. + +\item[\code{...}] Arguments to be passed to \code{\LinkA{RunWaterBalance}{RunWaterBalance}}, such as evapotranspiration \code{et}. \end{ldescription} \end{Arguments} % \begin{Details}\relax -Files read during execution, and located within the \code{dir.run} directory, include -the MODFLOW hydraulic conductivity reference files \file{hk1.ref}, \file{hk2.ref}, and \file{hk3.ref} -corresponding to model layers 1, 2, and 3, respectively. -Hydraulic conductivity values are read from a two-dimensional array in matrix format with `white-space' delimited fields. +Files read during execution, and located within the \code{dir.run} directory, +inlcude the MODFLOW hydraulic conductivity reference files \file{hk1.ref}, +\file{hk2.ref}, and \file{hk3.ref} corresponding to model layers 1, 2, and 3, respectively. +Hydraulic conductivity values are read from a two-dimensional array in +matrix format with `white-space' delimited fields. And a binary data file \file{model.rda} containing the following serialized \R{} objects: \code{rs}, \code{misc}, \code{trib}, \code{tr.stress.periods}, and \code{ss.stress.periods}. -\code{rs} is an object of \code{RasterStack} class with raster layers -``lay1.top'', ``lay1.bot'', ``lay2.bot'', and ``lay3.bot''. +\code{rs} is an object of RasterStack class with raster layers ``lay1.top'', +``lay1.bot'', ``lay2.bot'', and ``lay3.bot''. These raster layers describe the geometry of the model grid; that is, the upper and lower elevation of model layer 1, and the bottom elevations of model layers 2 and 3. -In addition to these layers, \code{rs} includes ancillary raster layers ``lay1.zones'', ``lay2.zones'', and ``lay3.zones'' -describing the distribution of hydrogeologic zones in the model grid. -Missing cell values (equal to \code{NA}) indicate inactive model cells lying outside of the model domain. +Missing cell values (equal to NA) indicate inactive model cells lying outside of the model domain. -\code{misc} is a \code{data.frame} object with miscellaneous seepage, +\code{misc} is a data.frame object with miscellaneous seepage, such as from the `Bellevue Waste Water Treatment Plant ponds' and the `Bypass Canal'. This object is comprised of the following components: -\bold{lay}, \bold{row}, \bold{col} are \code{integer} values specifying a model cell's layer, row, and column index, respectively; and -\bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of elevation during each stress period, respectively, +\bold{lay}, \bold{row}, \bold{col} are integer values specifying a +model cell's layer, row, and column index, respectively; and +\bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of +elevation during each stress period, respectively, in meters above the North American Vertical Datum of 1988. -\code{trib} is a \code{data.frame} object with default values for the long-term mean underflows in each of the tributary basins. +\code{trib} is a data.frame object with default values for the +long-term mean underflows in each of the tributary basins. The object is comprised of the following components: \bold{Name} is a unique identifier for the tributary basin; -\bold{lay}, \bold{row}, \bold{col} are \code{integer} values of a model cell's layer, row, and column index, respectively; and -\bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of underflow during each stress period, respectively, -in cubic meters per day. +\bold{lay}, \bold{row}, \bold{col} are \code{integer} values of a +model cell's layer, row, and column index, respectively; and +\bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of +underflow during each stress period, respectively, in cubic meters per day. -\code{tr.stress.periods} is a vector of \code{Date} values giving the start and end dates for stress periods in the model simulation period (1995--2010). +\code{tr.stress.periods} is a vector of Date values giving the start and end dates for +stress periods in the model simulation period (1995--2010). -\code{ss.stress.periods} is a vector of \code{Date} values giving the start and end dates for stress periods used to define steady-state conditions. +\code{ss.stress.periods} is a vector of Date values giving the start and end dates for +stress periods used to define steady-state conditions. -\code{reduction} is a \code{numeric} default value for the signal amplitude reduction algorithm, a dimensionless quantity. +\code{reduction} is a numeric default value for the signal amplitude reduction algorithm, +a dimensionless quantity. -\code{d.in.mv.ave} is a \code{numeric} default value for the number of days in the moving average subset. +\code{d.in.mv.ave} is a numeric default value for the number of days in the +moving average subset. \end{Details} % \begin{Value} -Returns an object of \code{difftime} class, the runtime for this function. +Returns an object of difftime class, the runtime for this function. Used for the side-effect of files written to disk. A MODFLOW Well Package file \file{.wel} is always written to disk; whereas, parameter estimation files \file{seep.csv}, \file{eff.csv}, and \file{trib.csv}, and a script file \file{UpdateBudget.bat}, are only written if they do not already exist. -The script file may be used to automate the execution of this function from a file manager (such as, Windows Explorer). - -The \file{seep.csv} file stores as tabular data the canal seepage fraction for each of the irrigation entities. -Its \code{character} and \code{numeric} data fields are delimited by commas (a comma-separated-value [CSV] file). -The first line is reserved for field names \code{EntityName} and \code{SeepFrac}. - -The \file{eff.csv} file stores as tabular data the irrigation efficiency for each of the irrigation entities. -Its \code{character} and \code{numeric} data fields are delimited by commas. -The first line is reserved for field names \code{EntityName} and \code{Eff}. - -The \file{trib.csv} file stores as tabular data the underflow boundary conditions for each tributary basin. -Its \code{character} and \code{numeric} data fields are delimited by commas. -The first line is reserved for field names \code{Name} and \code{Value}. -Data records include a long-term mean flow multiplier for each of the tributary basins (name is the unique identifier for the tributary), +The script file may be used to automate the execution of this function from a +file manager (such as, Windows Explorer). + +The \file{seep.csv} file stores as tabular data the canal seepage fraction for +each of the irrigation entities. +Its character and numeric data fields are delimited by commas (a comma-separated-value [CSV] file). +The first line is reserved for field names ``EntityName'' and ``SeepFrac''. + +The \file{eff.csv} file stores as tabular data the irrigation efficiency for +each of the irrigation entities. +Its character and numeric data fields are delimited by commas. +The first line is reserved for field names ``EntityName'' and ``Eff''. + +The \file{trib.csv} file stores as tabular data the underflow boundary conditions for +each tributary basin. +Its character and numeric data fields are delimited by commas. +The first line is reserved for field names ``Name'' and ``Value''. +Data records include a long-term mean flow multiplier for +each of the tributary basins (name is the unique identifier for the tributary), a record for the amplitude reduction (\code{reduction}), and a record for the number of days in the moving average (\code{d.in.mv.ave}). -If the \code{qa.tables} argument is specified as either \code{"si"} or \code{"english"}, quality assurance tables are written to disk as CSV files (`qa-*.csv'). -Volumetric flow rate data within these tables is described in the `Value' section of the \code{\LinkA{RunWaterBalance}{RunWaterBalance}} function; -see returned \code{list} components \code{natural.rech}, \code{inciden.rech}, and \code{pumping.rech}. -The well configuration data are described in the `Value' section of the \code{\LinkA{GetWellConfig}{GetWellConfig}} function. +If the \code{qa.tables} argument is specified as either ``si'' or ``english'', +quality assurance tables are written to disk as CSV files (\file{qa-*.csv}). +Volumetric flow rate data within these tables is described in the +`Value' section of the \code{\LinkA{RunWaterBalance}{RunWaterBalance}} function; +see returned list components \code{natural.rech}, \code{inciden.rech}, and \code{pumping.rech}. +The well configuration data are described in the `Value' section of the +\code{\LinkA{GetWellConfig}{GetWellConfig}} function. \end{Value} % \begin{Author}\relax @@ -3886,10 +3189,12 @@ \chapter*{} \begin{Examples} \begin{ExampleCode} ## Not run: -dir.run <- "C:/Users/jfisher/Documents/SIR2016-5080/model/model1" -UpdateWaterBudget(dir.run, "wrv_mfusg", qa.tables = "si", - ss.interval = c("1998-01-01", "2011-01-01")) + dir.run <- file.path(getwd(), "model/model1") + UpdateWaterBudget(dir.run, "wrv_mfusg", qa.tables = "si", + ss.interval = c("1998-01-01", "2011-01-01")) + ## End(Not run) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3897,7 +3202,7 @@ \chapter*{} \keyword{datasets}{weather.stations} % \begin{Description}\relax -Weather stations in the WRV and surrounding areas. +Weather stations in the Wood River Valley and surrounding areas. \end{Description} % \begin{Usage} @@ -3907,33 +3212,44 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPointsDataFrame} class containing 5 points and the following variables: +An object of SpatialPointsDataFrame class containing 5 points +and the following variables: \begin{description} -\item[name] is the name of the weather station. -\item[id] is a unique identifier for the weather station. -\item[type] is the type of weather stations: -\code{"HADS"}, a Hydrometeorological Automated Data System operated by the National Weather Service Office of Dissemination; -\code{"AgriMet"}, a satellite-telemetry network of automated agricultural weather stations operated and maintained by the Bureau of Reclamation; and -\code{"SNOTEL"}, an automated system of snowpack and related climate sensors operated by the Natural Resources Conservation Service. +\item[name] name of the weather station. +\item[id] unique identifier for the weather station. +\item[type] type of weather stations: +\code{"HADS"}, a Hydrometeorological Automated Data System operated by the +National Weather Service Office of Dissemination; +\code{"AgriMet"}, a satellite-telemetry network of +automated agricultural weather stations operated and +maintained by the Bureau of Reclamation; and +\code{"SNOTEL"}, an automated system of snowpack and +related climate sensors operated by the +Natural Resources Conservation Service. \item[organization] is the managing organization. -\item[elevation] is the elevation of the weather station in meters above the North American Vertical Datum of 1988 (NAVD 88). +\item[elevation] is the elevation of the weather station in +meters above the North American Vertical Datum of 1988 (NAVD 88). \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -National Oceanic and Atmospheric Administration (NOAA), Bureau of Reclamation, Natural Resources Conservation Service (NRCS), accessed on May 1, 2015 +National Oceanic and Atmospheric Administration (NOAA), +Bureau of Reclamation, Natural Resources Conservation Service (NRCS), +accessed on May 1, 2015 \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(alluvium.extent) -plot(weather.stations, col = "red", add = TRUE) +sp::plot(alluvium.extent) +sp::plot(weather.stations, col = "red", add = TRUE) str(weather.stations@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3951,17 +3267,22 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialPolygons} class containing 3,024 \code{Polygons}. +An object of SpatialPolygons class containing 3,024 Polygons. +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the +Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -U.S. Fish and Wildlife Service National Wetlands Inventory, accessed on April 2, 2014 +U.S. Fish and Wildlife Service National Wetlands Inventory, +accessed on April 2, 2014 \end{Source} % \begin{Examples} \begin{ExampleCode} -plot(wetlands, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) +sp::plot(wetlands, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) print(wetlands) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -3969,7 +3290,9 @@ \chapter*{} \keyword{datasets}{wl.200610} % \begin{Description}\relax -Groundwater-level contours with a 20 foot (6.096 meter) contour interval for the unconfined aquifer in the Wood River Valley, south-central Idaho, representing conditions during October 2006. +Groundwater-level contours with a 20 foot (6.096 meter) contour interval for the +unconfined aquifer in the Wood River Valley, south-central Idaho, +representing conditions during October 2006. \end{Description} % \begin{Usage} @@ -3979,32 +3302,42 @@ \chapter*{} \end{Usage} % \begin{Format} -An object of \code{SpatialLinesDataFrame} class containing 265 \code{Lines} and a \code{data.frame} with the following variables: +An object of SpatialLinesDataFrame class containing 265 Lines and a +data.frame with the following variables: \begin{description} -\item[CONTOUR] is the groundwater elevation contour value in meters above the North American Vertical Datum of 1988 (NAVD 88). -\item[certainty] is the certainty of the groundwater-level contour based on data position and density, specified as \code{"good"} or \code{"poor"}. +\item[CONTOUR] groundwater elevation contour value in meters above the +North American Vertical Datum of 1988 (NAVD 88). +\item[certainty] certainty of the groundwater-level contour based on +data position and density, specified as \code{"good"} or \code{"poor"}. \end{description} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the +Geographic coordinates are in units of meters, in conformance with the +North American Datum of 1983 (NAD 83), and placed in the Idaho Transverse Mercator projection (\Rhref{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). \end{Format} % \begin{Source}\relax -This dataset is from Plate 1 in Skinner and others (2007), and available on the \Rhref{http://water.usgs.gov/GIS/metadata/usgswrd/XML/sir2007-5258_oct2006wl.xml}{WRD NSDI Node}. +This dataset is from Plate 1 in Skinner and others (2007), and available on the +\Rhref{http://water.usgs.gov/GIS/metadata/usgswrd/XML/sir2007-5258_oct2006wl.xml}{WRD NSDI Node}. \end{Source} % \begin{References}\relax -Skinner, K.D., Bartolino, J.R., and Tranmer, A.W., 2007, Water-resource trends and comparisons between partial development and October 2006 hydrologic conditions, Wood River Valley, south-central, Idaho: U.S. Geological Survey Scientific Investigations Report 2007-5258, 30 p., available at \url{http://pubs.usgs.gov/sir/2007/5258/} +Skinner, K.D., Bartolino, J.R., and Tranmer, A.W., 2007, +Water-resource trends and comparisons between partial development and +October 2006 hydrologic conditions, Wood River Valley, south-central, Idaho: +U.S. Geological Survey Scientific Investigations Report 2007-5258, 30 p., +available at \url{http://pubs.usgs.gov/sir/2007/5258/} \end{References} % \begin{Examples} \begin{ExampleCode} is.good <- wl.200610@data$certainty == "good" -plot(wl.200610[is.good, ], col = "blue") -plot(wl.200610[!is.good, ], col = "red", lty = 2, add = TRUE) +sp::plot(wl.200610[is.good, ], col = "blue") +sp::plot(wl.200610[!is.good, ], col = "red", lty = 2, add = TRUE) str(wl.200610@data) + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -4012,89 +3345,155 @@ \chapter*{} \keyword{IO}{WriteModflowInput} % \begin{Description}\relax -This function generates and writes input files for a MODFLOW simulation of groundwater flow in the Wood River Valley (WRV) aquifer system. +This function generates and writes input files for a MODFLOW simulation of +groundwater flow in the Wood River Valley (WRV) aquifer system. \end{Description} % \begin{Usage} \begin{verbatim} WriteModflowInput(rs.model, rech, well, trib, misc, river, drain, id, dir.run, - is.convertible = FALSE, ss.perlen = 0L, - tr.stress.periods = NULL, ntime.steps = 4L, - mv.flag = 1e+09, auto.flow.reduce = FALSE, verbose = TRUE) + is.convertible = FALSE, ss.perlen = 0L, tr.stress.periods = NULL, + ntime.steps = 4L, mv.flag = 1e+09, auto.flow.reduce = FALSE, + verbose = TRUE) \end{verbatim} \end{Usage} % \begin{Arguments} \begin{ldescription} -\item[\code{rs.model}] \code{RasterStack}; a collection of \code{RasterLayer} objects with the same extent and resolution, see `Details' for required raster layers. -\item[\code{rech}] \code{data.frame}; is the areal recharge rate, in cubic meters per day. -Variables describe the model cell location (\code{lay}, \code{row}, \code{col}) and volumetric rate during each stress period (\code{ss}, \code{199501}, \code{199502}, \dots, \code{201012}). -\item[\code{well}] \code{data.frame}; is the well pumping at point locations in cubic meters per day. +\item[\code{rs.model}] RasterStack. +Collection of RasterLayer objects with the same extent and resolution, +see `Details' for required raster layers. + +\item[\code{rech}] data.frame. +Areal recharge rate, in cubic meters per day. +Variables describe the model cell location (\code{lay}, \code{row}, \code{col}) and +volumetric rate during each stress period +(\code{ss}, \code{199501}, \code{199502}, \dots, \code{201012}). + +\item[\code{well}] data.frame. +Well pumping at point locations in cubic meters per day. Variables describe the model cell location and volumetric rate during each stress period. -\item[\code{trib}] \code{data.frame}; is the incoming flows from the major tributary canyons. + +\item[\code{trib}] data.frame. +Incoming flows from the major tributary canyons. Variables describe the model cell location and volumetric rate during each stress period. -\item[\code{misc}] \code{data.frame}; is recharge from miscellaneous seepage sites in cubic meters per day. + +\item[\code{misc}] data.frame. +Direct recharge from miscellaneous seepage sites in cubic meters per day. Variables describe the model cell location and volumetric rate during each stress period. -\item[\code{river}] \code{data.frame}; is the river conditions. -Variables describe the model cell location, river conductance (\code{cond}) in square meters per day, river bottom elevation (\code{bottom}) in meters above the North American Vertical Datum of 1988 (NAVD 88), and a numeric river reach identifier (\code{id}). -\item[\code{drain}] \code{data.frame}; is the drain conditions for groundwater outlet boundaries. -Variables describe the model cell location, drain threshold elevation (\code{elev}) in meters above the NAVD 88, drain conductance (\code{cond}) in square meters per day, and a numeric identifier (\code{id}) indicating the drains general location. -\item[\code{id}] \code{character}; a short identifier for the model run. -\item[\code{dir.run}] \code{character}; the path name of the directory to write model input files. -\item[\code{is.convertible}] \code{logical}; if \code{TRUE}, indicates model layers are `convertible', with transmissivity computed using upstream water-table depth. + +\item[\code{river}] data.frame. +River conditions. +Variables describe the model cell location, river conductance +(\code{cond}) in square meters per day, river bottom elevation (\code{bottom}) in +meters above the North American Vertical Datum of 1988 (NAVD 88), and +a numeric river reach identifier (\code{id}). + +\item[\code{drain}] data.frame. +Drain conditions for groundwater outlet boundaries. +Variables describe the model cell location, drain threshold elevation +(\code{elev}) in meters above the NAVD 88, drain conductance (\code{cond}) in +square meters per day, and a numeric identifier (\code{id}) indicating the +drains general location. + +\item[\code{id}] character. +Short identifier for the model run. + +\item[\code{dir.run}] character. +Path name of the directory to write model input files. + +\item[\code{is.convertible}] logical. +If true, indicates model layers are `convertible', with +transmissivity computed using upstream water-table depth. Otherwise, model layers are `confined' and transmissivity is constant over time. -\item[\code{ss.perlen}] \code{integer} or \code{difftime}; the length of the steady-state stress period in days. -\item[\code{tr.stress.periods}] \code{Date}; a vector of start times for each stress period in the transient simulation. + +\item[\code{ss.perlen}] integer or difftime. +Length of the steady-state stress period in days. + +\item[\code{tr.stress.periods}] Date. +Vector of start times for each stress period in the transient simulation. If missing, only steady-state conditions are simulated. -\item[\code{ntime.steps}] \code{integer}; the number of uniform time steps in a stress period. -\item[\code{mv.flag}] \code{numeric}; default \code{NA}, missing value flag for output reference data files. -\item[\code{auto.flow.reduce}] \code{logical}; if \code{TRUE}, a simulated well will adjust pumping according to supply under bottom-hole conditions. -Pumping rates that have been automatically reduced will be written to a model output file (\file{.afr}). -\item[\code{verbose}] \code{logical}; if \code{TRUE}, additional information is written to the listing file (\file{.lst}) and budget file (\file{.bud}). + +\item[\code{ntime.steps}] integer. +Number of uniform time steps in a stress period. + +\item[\code{mv.flag}] numeric. +Missing value flag for output reference data files. + +\item[\code{auto.flow.reduce}] logical. +If true, a simulated well will adjust pumping according to +supply under bottom-hole conditions. +Pumping rates that have been automatically reduced will be written to a +model output file (\file{.afr}). + +\item[\code{verbose}] logical. +If true, additional information is written to the +listing file (\file{.lst}) and budget file (\file{.bud}) \end{ldescription} \end{Arguments} % \begin{Details}\relax -Groundwater flow in the WRV aquifer system is simulated using the \Rhref{http://water.usgs.gov/ogw/mfusg/}{MODFLOW-USG} groundwater-flow model. -This numerical model was chosen for its ability to solve complex unconfined groundwater flow simulations. -The solver implemented in MODFLOW-USG incorporates the Newton-Raphson formulation for improving solution convergence and avoiding problems with the drying and rewetting of cells (Niswonger and others, 2011). +Groundwater flow in the WRV aquifer system is simulated using the +\Rhref{http://water.usgs.gov/ogw/mfusg/}{MODFLOW-USG} groundwater-flow model. +This numerical model was chosen for its ability to solve +complex unconfined groundwater flow simulations. +The solver implemented in MODFLOW-USG incorporates the Newton-Raphson formulation for +improving solution convergence and avoiding problems with the drying and +rewetting of cells (Niswonger and others, 2011). A structured finite-difference grid is implemented in the model to (1) simplify discretization, -(2) keep formats and structures for the MODFLOW-USG packages identical to those of \Rhref{http://water.usgs.gov/nrp/gwsoftware/modflow2005/Guide/index.html}{MODFLOW-2005}, and -(3) allow any MODFLOW post-processor to be used to analyze the results of the MODFLOW-USG simulation (such as \Rhref{http://water.usgs.gov/nrp/gwsoftware/modelviewer/ModelViewer.html}{Model Viewer}). - -Model input files are written to \code{dir.run} and include the following MODFLOW Package files: Name (\file{.nam}), Basic (\file{.ba6}), Discretization (\file{.dis}), Layer-Property Flow (\file{.lpf}), Drain (\file{.drn}), River (\file{.riv}), Well (\file{.wel}), Sparse Matrix Solver (\file{.sms}), and Output Control (\file{.oc}). -See the users guide (\Cite{Description of Model Input and Output}) included with the MODFLOW-USG \Rhref{http://water.usgs.gov/ogw/mfusg/mfusg.1_2_00.zip}{software} for details on input file formats and structures. - -Data within the \code{rech}, \code{well}, \code{trib}, and \code{misc} arguments are combined in the MODFLOW Well Package and identifiable with added \code{id} values of 1, 2, 3, and 4, respectively. - -The Layer-Property Flow file includes options for the calculation of vertical flow in partially dewatered cells. -For the WRV model, where there is no indication that perched conditions exist, \code{CONSTANTCV} and \code{NOVFC} options are used to create the most stable solution (Panday and others, 2013, p. 15-16). -Options for the Sparse Matrix Solver were set for unconfined simulations by implementing an upstream-weighting scheme with Newton-Raphson linearization, Delta-Bar-Delta under-relaxation, and the \eqn{\chi}{}MD solver of Ibaraki (2005). +(2) keep formats and structures for the MODFLOW-USG packages identical to those of +\Rhref{http://water.usgs.gov/nrp/gwsoftware/modflow2005/Guide/index.html}{MODFLOW-2005}, and +(3) allow any MODFLOW post-processor to be used to analyze the results of the MODFLOW-USG simulation +(such as \Rhref{http://water.usgs.gov/nrp/gwsoftware/modelviewer/ModelViewer.html}{Model Viewer}). + +Model input files are written to \code{dir.run} and include the following MODFLOW Package files: +Name (\file{.nam}), Basic (\file{.ba6}), Discretization (\file{.dis}), +Layer-Property Flow (\file{.lpf}), Drain (\file{.drn}), River (\file{.riv}), +Well (\file{.wel}), Sparse Matrix Solver (\file{.sms}), and Output Control (\file{.oc}). +See the users guide (\Cite{Description of Model Input and Output}) included with the MODFLOW-USG +software for details on input file formats and structures. + +Data within the \code{rech}, \code{well}, \code{trib}, and \code{misc} arguments are +combined in the MODFLOW Well Package and identifiable with added \code{id} values of +1, 2, 3, and 4, respectively. + +The Layer-Property Flow file includes options for the calculation of vertical flow in +partially dewatered cells. +For the WRV model, where there is no indication that perched conditions exist, +CONSTANTCV and NOVFC options are used to create the most stable solution +(Panday and others, 2013, p. 15-16). +Options for the Sparse Matrix Solver were set for unconfined simulations by +implementing an upstream-weighting scheme with Newton-Raphson linearization, +Delta-Bar-Delta under-relaxation, and the \eqn{\chi}{}MD solver of Ibaraki (2005). The raster stack \code{rs.model} includes the following layers: \begin{description} -\item[lay1.top] is the elevation at the top of model layer 1 (land surface), in meters above the NAVD 88. -\item[lay1.bot] is the elevation at the bottom of model layer 1, in meters above the NAVD 88. -\item[lay2.bot] is the elevation at the bottom of model layer 2. -\item[lay3.bot] is the elevation at the bottom of model layer 3. -\item[lay1.strt] is the initial (starting) hydraulic head in model layer 1, in meters above the NAVD 88. -\item[lay2.strt] is the initial hydraulic head in model layer 2. -\item[lay3.strt] is the initial hydraulic head in model layer 3. -\item[lay1.zones] is the hydrogeologic zones in model layer 1 where values \code{= 1} is unconfined alluvium, \code{= 2} is basalt, \code{= 3} is clay, and \code{= 4} is confined alluvium. -\item[lay2.zones] is the hydrogeologic zones in model layer 2. -\item[lay3.zones] is the hydrogeologic zones in model layer 3. -\item[lay1.hk] is the horizontal hydraulic conductivity in model layer 1, in meters per day. -\item[lay2.hk] is the horizontal hydraulic conductivity in model layer 2. -\item[lay3.hk] is the horizontal hydraulic conductivity in model layer 3. +\item[lay1.top] elevation at the top of model layer 1 (land surface), +in meters above the NAVD 88. +\item[lay1.bot] elevation at the bottom of model layer 1, in meters above the NAVD 88. +\item[lay2.bot] elevation at the bottom of model layer 2. +\item[lay3.bot] elevation at the bottom of model layer 3. +\item[lay1.strt] initial (starting) hydraulic head in model layer 1, +in meters above the NAVD 88. +\item[lay2.strt] initial hydraulic head in model layer 2. +\item[lay3.strt] initial hydraulic head in model layer 3. +\item[lay1.zones] hydrogeologic zones in model layer 1 where values +equal to 1 is unconfined alluvium, equal to 2 is basalt, +equal to 3 is clay, and equal to 4 is confined alluvium. +\item[lay2.zones] hydrogeologic zones in model layer 2. +\item[lay3.zones] hydrogeologic zones in model layer 3. +\item[lay1.hk] horizontal hydraulic conductivity in model layer 1, in meters per day. +\item[lay2.hk] horizontal hydraulic conductivity in model layer 2. +\item[lay3.hk] horizontal hydraulic conductivity in model layer 3. \end{description} \end{Details} % \begin{Value} -None. Used for the side-effect of files written to disk. +Used for the side-effect of files written to disk. \end{Value} % \begin{Author}\relax @@ -4102,16 +3501,22 @@ \chapter*{} \end{Author} % \begin{References}\relax -Ibaraki, M., 2005, \eqn{\chi}{}MD User's guide-An efficient sparse matrix solver library, version 1.30: Columbus, Ohio State University School of Earth Sciences. +Ibaraki, M., 2005, \eqn{\chi}{}MD User's guide-An efficient sparse matrix solver library, version 1.30: +Columbus, Ohio State University School of Earth Sciences. -Niswonger, R.G., Panday, Sorab, and Ibaraki, Motomu, 2011, MODFLOW-NWT, A Newton formulation for MODFLOW-2005: U.S. Geological Survey Techniques and Methods 6-A37, 44 p., available at \url{http://pubs.usgs.gov/tm/tm6a37/}. +Niswonger, R.G., Panday, Sorab, and Ibaraki, Motomu, 2011, MODFLOW-NWT, A Newton formulation for MODFLOW-2005: +U.S. Geological Survey Techniques and Methods 6-A37, 44 p., available at \url{http://pubs.usgs.gov/tm/tm6a37/}. -Panday, Sorab, Langevin, C.D., Niswonger, R.G., Ibaraki, Motomu, and Hughes, J.D., 2013, MODFLOW-USG version 1: An unstructured grid version of MODFLOW for simulating groundwater flow and tightly coupled processes using a control volume finite-difference formulation: U.S. Geological Survey Techniques and Methods, book 6, chap. A45, 66 p., available at \url{http://pubs.usgs.gov/tm/06/a45/}. +Panday, Sorab, Langevin, C.D., Niswonger, R.G., Ibaraki, Motomu, and Hughes, J.D., 2013, MODFLOW-USG version 1: +An unstructured grid version of MODFLOW for simulating groundwater flow and tightly coupled processes using a +control volume finite-difference formulation: U.S. Geological Survey Techniques and Methods, book 6, chap. A45, +66 p., available at \url{http://pubs.usgs.gov/tm/06/a45/}. \end{References} % \begin{Examples} \begin{ExampleCode} -## Not run: # see uncalibrated-model vignette +## Not run: # see Appendix D. Uncalibrated Groundwater-Flow Model + \end{ExampleCode} \end{Examples} \inputencoding{utf8} @@ -4129,28 +3534,31 @@ \chapter*{} \end{Usage} % \begin{Format} -A \code{data.frame} object with the following variables: +An object of \code{data.frame} class with the following variables: \begin{description} -\item[ID] is a numeric identifier for the hydrogeologic zone. -\item[name] is the name of the hydrogeologic zone. -\item[vani] is the vertical anisotropy, a dimensionless quantity. -\item[sc] is the storage coefficient, a dimensionless quantity. -\item[sy] is the specific yield, a dimensionless quantity. -\item[hk] is the horizontal hydraulic conductivity in meters per day. -\item[ss] is the specific storage, in inverse meter. +\item[ID] numeric identifier for the hydrogeologic zone. +\item[name] name of the hydrogeologic zone. +\item[vani] vertical anisotropy, a dimensionless quantity. +\item[sc] storage coefficient, a dimensionless quantity. +\item[sy] specific yield, a dimensionless quantity. +\item[hk] horizontal hydraulic conductivity in meters per day. +\item[ss] specific storage in inverse meter. \end{description} - \end{Format} % -\begin{Source}\relax -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. -\end{Source} +\begin{References}\relax +Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the +Wood River Valley aquifer system, south-central Idaho: +U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., +available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +\end{References} % \begin{Examples} \begin{ExampleCode} str(zone.properties) + \end{ExampleCode} \end{Examples} \printindex{} diff --git a/inst/misc/miscellaneous.Rnw b/inst/misc/miscellaneous.Rnw index b2360c7..219dbcd 100644 --- a/inst/misc/miscellaneous.Rnw +++ b/inst/misc/miscellaneous.Rnw @@ -4,7 +4,7 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \renewcommand{\thefigure}{X\arabic{figure}} \renewcommand{\thetable}{X\arabic{table}} @@ -84,7 +84,7 @@ credit <- paste("Base derived from U.S. Geological Survey National Elevation Dat Set the path to the calibrated model run directory: -<<>>= +<>= path <- "C:/Users/jfisher/Desktop/Model Run" @ @@ -99,7 +99,7 @@ getwd() load(file.path(path, "model.rda")) transect <- SpatialLines(list(Lines(list(Line(transect.coords)), ID="Transect")), - proj4string=CRS("+proj=longlat +datum=WGS84")) + proj4string=CRS("+init=epsg:4326")) transect <- spTransform(transect, crs(rs)) verticies <- as(transect, "SpatialPoints") transect.ends <- verticies[c(1, length(verticies)), ] @@ -166,7 +166,6 @@ bg <- c("#C0C0C0FF", "#88263BFF") legend(x, y, leg, pch=c(22, 24), col=col, pt.bg=bg, pt.cex=c(1, 1), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD", title=expression(bold("EXPLANATION"))) -invisible(dev.off()) @ % ========================================================================= @@ -289,7 +288,6 @@ FUN <- function(i) { \caption{Model layer 3 \label{fig:map_config_c}} <>= FUN(3L) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -313,7 +311,6 @@ PlotGraph(d, ylab=ylab, col=col, fill=paste0(col, "66"), center.date.labels=TRUE) legend("topright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ Descriptive statistics for areal recharge rates, in cubic meters per day: @@ -335,7 +332,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) -invisible(dev.off()) @ Descriptive statistics for pumping rates, in cubic meters per day: @@ -420,7 +416,6 @@ FUN <- function(r) { \caption{Model layer 3 \label{fig:map_hk_c}} <>= FUN(rs[["lay3.hk"]]) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -439,7 +434,6 @@ PlotCrossSection(transect, rs.log, geo.lays, val.lays, asp=80, breaks=breaks, pa unit="METERS", features=cities[, "FEATURE_NA"], max.feature.dist=4000, is.categorical=FALSE, explanation="Horizontal hydraulic conductivity in meters per day, plotted on a logarithmic scale.", draw.sep=FALSE, labels=list(at=at, labels=labels)) -invisible(dev.off()) @ <>= @@ -591,7 +585,6 @@ FUN <- function(r) { \caption{Model layer 3 \label{fig:map_sc_c}} <>= FUN(rs[["lay3.sc"]]) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -610,7 +603,6 @@ PlotCrossSection(transect, rs.log, geo.lays, val.lays, asp=80, breaks=breaks, pa unit="METERS", features=cities[, "FEATURE_NA"], max.feature.dist=4000, is.categorical=FALSE, explanation="Storage coefficient, a dimensionless quantity, plotted on a logarithmic scale.", draw.sep=FALSE, labels=list(at=breaks, labels=labels)) -invisible(dev.off()) @ <>= @@ -746,7 +738,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) legend("topright", "Irrigation entity with no groundwater source", fill="#948979", border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ Descriptive statistics for the calibrated values of irrigation efficiency, a dimensionless quantity specified per irrigation entity: @@ -831,7 +822,6 @@ points(bwr.gages, pch=17, col="#333333") text(bwr.gages, labels=bwr.gages@data$SiteNo, col="#333333", cex=0.6, pos=2) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ % ========================================================================= @@ -949,7 +939,6 @@ AddBubbles(xy, z=z, inches=c(0.03, 0.3), fg="#FFFFFF65", format="d", plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) text(xy, labels=rownames(trib.lines@data), col="#333333", cex=0.6, adj=c(0.5, 0.5), offset=0) -invisible(dev.off()) @ <>= @@ -966,7 +955,6 @@ leg <- format(match(colnames(d)[-1], make.names(tributaries@data$Name))) legend("topright", leg, lwd=1, col=cols, ncol=2, pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", title=expression(bold("Tributary"))) -invisible(dev.off()) @ \clearpage @@ -1176,7 +1164,6 @@ FUN <- function(d, xlim, ylim, xlab=NULL, col="#666666") { xlab <- "Tributary-valley identifier (tributary No.)" col <- "#A8C0A8" FUN(d[order(d$ID), ], xlim, ylim, xlab, col=col) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -1187,8 +1174,7 @@ FUN <- function(d, xlim, ylim, xlab=NULL, col="#666666") { % ========================================================================= <>= -path <- file.path(getwd(), "ancillary/calibrated/model") -ExportRasterStack(rs, path) +ExportRasterStack(rs, "ancillary/calibrated/model") @ % ========================================================================= diff --git a/inst/misc/preamble.tex b/inst/misc/preamble.tex deleted file mode 100644 index 5c2491e..0000000 --- a/inst/misc/preamble.tex +++ /dev/null @@ -1,151 +0,0 @@ -\usepackage[T1]{fontenc} -\usepackage{mathptmx} -\usepackage{amsfonts} -\usepackage[scaled=0.92]{helvet} - -\usepackage[tmargin=1.00in, bmargin=0.67in, lmargin=0.58in, rmargin=0.75in]{geometry} -\usepackage{url} -\usepackage[backend=bibtex, style=authoryear-comp, maxbibnames=99, maxcitenames=3, natbib=true, dashed=false]{biblatex} -\usepackage{xpatch} -\usepackage{xcolor} -\usepackage{ragged2e} -\usepackage{caption} -\usepackage{subcaption} -\usepackage{titling} -\usepackage{booktabs, dcolumn, tabularx} -\usepackage{enumitem} -\usepackage{amsmath} -\usepackage[pdftex]{lscape} -\usepackage{xfrac} -\usepackage{textcomp} -\usepackage{array} -\usepackage{tocloft} -\usepackage{sectsty} -\usepackage{fancyhdr} -\usepackage[hidelinks, pdflang={en-US}]{hyperref} - -%%% References - -\DefineBibliographyStrings{english}{andothers={and~others}} -\setlength{\bibitemsep}{\baselineskip} - -\DeclareFieldFormat{title}{#1} -\DeclareFieldFormat[article,thesis,report,incollection,inproceedings,misc]{title}{#1} -\DeclareFieldFormat[incollection,inproceedings]{booktitle}{#1} - -\DeclareNameAlias{sortname}{last-first} -\DeclareNameAlias{default}{last-first} - -\DefineBibliographyStrings{english}{page={p\adddot}, pages={p\adddot}} -\DefineBibliographyStrings{english}{references={References Cited}} - -\renewcommand*{\newunitpunct}{\addcomma\space} -\renewcommand*{\intitlepunct}{\space} - -\DeclareFieldFormat[article]{volume}{v.\addnbspace #1} -\DeclareFieldFormat[article]{number}{no.\addnbspace #1} - -\DeclareFieldFormat[article]{journaltitle}{#1} - -\renewbibmacro*{volume+number+eid}{% - \printfield{volume}% - \setunit{\addcomma\space}% - \printfield{number}% - \setunit{\addcomma\space}% - \printfield{eid}} - -\renewbibmacro*{journal+issuetitle}{% - \usebibmacro{journal}% - \setunit*{\addcomma\space}% was: \setunit*{\addspace} - \iffieldundef{series} - {} - {\newunit - \printfield{series}% - \setunit{\addcomma\space}}% was: \setunit{\addspace} - \usebibmacro{volume+number+eid}% - \setunit{\addspace}% - \usebibmacro{issue+date}% - \setunit{\addcolon\space}% - \usebibmacro{issue}% - \newunit} - - -\xpatchbibmacro{date+extrayear}{% - \printtext[parens]% -}{% - \setunit*{\addcomma\space}% - \printtext% -}{}{} - -%%% - -\pagestyle{fancy} -\renewcommand{\sectionmark}[1]{\markboth{#1}{}} -\renewcommand{\headrulewidth}{0pt} -\fancyhf{} -\fancypagestyle{plain}{ - \fancyhf{} - \fancyhead[RO]{\normalfont\bfseries\sffamily \thepage} -} -\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} -\fancyhead[RO]{\normalfont\bfseries\sffamily \nouppercase{\leftmark} \quad \thepage} - -\sectionfont{\Large\bfseries\sffamily} -\subsectionfont{\large\bfseries\sffamily} -\subsubsectionfont{\large\mdseries\sffamily} - -\renewcommand\refname{References Cited} -\renewcommand\cftsecfont{\sffamily} -\renewcommand\cftsubsecfont{\sffamily} -\renewcommand\cftsubsubsecfont{\sffamily} -\renewcommand\cfttoctitlefont{\Large\bfseries\sffamily} -\renewcommand\cftloftitlefont{\Large\bfseries\sffamily} -\renewcommand\cftlottitlefont{\Large\bfseries\sffamily} -\renewcommand{\cftdotsep}{0.5} -\renewcommand\cftsecleader{\cftdotfill{\cftdotsep}} - -\renewcommand\cftsecpagefont{\normalfont} - -\renewcommand\cftfigaftersnum{.} -\renewcommand\cfttabaftersnum{.} - -\setlength{\cftbeforesecskip}{0.1cm} -\setlength{\cftbeforesubsecskip}{0.1cm} -\setlength{\cftbeforesubsubsecskip}{0.1cm} -\setlength{\cftbeforefigskip}{0.1cm} -\setlength{\cftbeforetabskip}{0.1cm} - -\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} -\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} -\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} - -\renewcommand{\sfdefault}{lmss} -\renewcommand{\ttdefault}{lmtt} - -\renewcommand*\descriptionlabel[1]{\hspace\leftmargin$#1$} - -\definecolor{Red}{rgb}{0.7,0,0} -\definecolor{Blue}{rgb}{0,0,0.8} -\hypersetup{colorlinks, urlcolor={Red}, linkcolor={Blue}, citecolor={Blue}, linktoc=page} - -\captionsetup[figure]{skip=5pt} -\captionsetup{labelsep=period, labelfont=bf} -\captionsetup[subfigure]{skip=-5pt, labelfont={bf,it}} -\renewcommand{\thesubfigure}{\Alph{subfigure}} - -\newcommand{\R}{{\normalfont\textsf{R}}{}} - -\widowpenalties 1 10000 -\raggedbottom - -%%% Paragraph -\renewenvironment{knitrout}{\setlength{\topsep}{0mm}}{} -\usepackage{indentfirst} -\setlength\RaggedRightParindent{15pt} - -\makeatletter -\setlength{\@fptop}{0pt} -\setlength{\@fpbot}{0pt plus 1fil} -\makeatother - -\setcounter{secnumdepth}{0} diff --git a/inst/misc/readme-template.txt b/inst/misc/readme-template.txt index 5add339..4f50e20 100644 --- a/inst/misc/readme-template.txt +++ b/inst/misc/readme-template.txt @@ -11,7 +11,7 @@ The underlying directories contain all of the input and output files for the simulation described in the report, processing scripts and datasets are bundled together in an R-package wrv, included in the package is the - MODFLOW-USG (v 1.2.00) source code. + MODFLOW-USG (v 1.3.00) source code. Descriptions of the data in each subdirectory are given to facilitate understanding of this data release. File descriptions are provided for @@ -182,7 +182,7 @@ System requirements ------------------- - MODFLOW-USG 1.2.00 (2014-03-21) + MODFLOW-USG 1.3 (2015-12-01) PEST 13.0 (2013-05-01) @{paste(capture.output(sessionInfo()), collapse="\n ")} @@ -215,12 +215,13 @@ are consistent with package versions documented in this README file. To recreate the R environment as it existed when this model archive was built, first download and install @{R.version.string} from a - snapshot of the Comprehensive R Archive Network (CRAN). + snapshot of the Comprehensive R Archive Network (CRAN), + https://mran.revolutionanalytics.com/snapshot/@{Sys.Date()}/. Open an R session and install user-contributed R packages from the CRAN snapshot by typing the following commands: - repo <- "https://mran.revolutionanalytics.com/snapshot/@{packageDescription('wrv', fields = 'Date')}/" + repo <- "https://mran.revolutionanalytics.com/snapshot/@{Sys.Date()}/" pkgs <- c($(pkgs)) install.packages(pkgs, repos = repo) diff --git a/man/AddBubbles.Rd b/man/AddBubbles.Rd deleted file mode 100644 index babb4e2..0000000 --- a/man/AddBubbles.Rd +++ /dev/null @@ -1,84 +0,0 @@ -\name{AddBubbles} - -\alias{AddBubbles} - -\title{Add Bubble Map to Plot} - -\description{ -This function can be used to add a bubble map to a plot. -Proportional circle symbols are used to represent spatial point data, where symbol area varies in proportion to an attribute variable. -} - -\usage{ -AddBubbles(x, y = NULL, z, zlim = NULL, inches = c(0, 0.2), - scaling = c("perceptual", "mathematical"), - bg.pos = "red", bg.neg = "blue", fg = NA, lwd = 0.25, - cex = 0.7, format = NULL, draw.legend = TRUE, - loc = c("bottomleft", "topleft", "topright", "bottomright"), - inset = 0.02, breaks = NULL, break.labels = NULL, - quantile.breaks = FALSE, make.intervals = FALSE, - title = NULL, subtitle = NULL, add = TRUE) -} - -\arguments{ -\item{x, y}{\code{numeric}; the x and y coordinates for the centers of the circle symbols. They can be specified in any way which is accepted by \code{xy.coords}.} -\item{z}{\code{numeric}; is the attribute variable.} -\item{zlim}{\code{numeric}; the minimum and maximum \code{z} values that circle symbols are plotted; defaults to the range of the finite values of \code{z}.} -\item{inches}{\code{numeric}; a vector of length 2 specifying the radii limits for the drawn circle symbol.} -\item{scaling}{\code{character}; selects the proportional symbol mapping algorithm to be used; either \code{"perceptual"} or \code{"mathematical"} scaling (Tanimura and others, 2006).} -\item{bg.pos, bg.neg}{\code{character} or \code{function}; the fill color(s) for circle symbols corresponding to positive and negative \code{z} values, respectively. - A color palette also may be specified.} -\item{fg}{\code{character}; the outer-line color for circle symbols. - Specify an \code{NA} value to remove the symbols outer line, and a \code{NULL} value to match the outer-line color with the symbols fill color.} -\item{lwd}{\code{numeric}; is the line width for drawing circle symbols.} -\item{cex}{\code{numeric}; the character expansion factor for legend labels.} -\item{format}{\code{character}; the formatting for legend values, see \code{formatC} for options.} -\item{draw.legend}{\code{logical}; if \code{TRUE}, a legend is drawn.} -\item{loc}{\code{character}; the position of the legend in the main plot region: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote scale location.} -\item{inset}{\code{numeric}; the inset distance of the legend from the margins as a fraction of the main plot region. - Defaults to 2 percent of the axis range.} -\item{breaks}{\code{numeric}; a set of finite breakpoints for the legend circle symbols.} -\item{break.labels}{\code{character}; a vector of break labels with length equal to \code{breaks}.} -\item{quantile.breaks}{\code{logical}; if \code{TRUE}, \code{breaks} are set to the sample quantiles of \code{z}.} -\item{make.intervals}{\code{logical}; if \code{TRUE}, represent \code{z} within intervals. - See \code{findInterval} function for details.} -\item{title}{\code{character}; the main title to be placed at the top of the legend.} -\item{subtitle}{\code{character}; a legend subtitle to be placed below the main title.} -\item{add}{\code{logical}; if \code{TRUE}, circle symbols (and an optional legend) are added to an existing plot.} -} - -\details{ -Symbols are sequentially drawn in decreasing order of circle diameter. -} - -\value{ -Primarily used for the side-effect of a bubble map drawn on the current graphics device. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\references{ -Tanimura, S., Kuroiwa, C., and Mizota, T., 2006, Proportional Symbol Mapping in R: Journal of Statistical Software, v. 15, no. 5, 7 p. -} - -\seealso{\code{symbols}} - -\examples{ -n <- 50L -x <- cbind(runif(n, 1, 10), runif(n, 1, 10)) -z <- runif(n, -5000, 10000) -AddBubbles(x, z = z, fg = "green", lwd = 2, title = "Title", loc = "topright", - breaks=pretty(z, n = 8), add = FALSE) - -Pal1 <- colorRampPalette(c("#F4A582", "#CA0020")) -Pal2 <- colorRampPalette(c("#92C5DE", "#0571B0")) -AddBubbles(x, z = z, bg.pos = Pal1, bg.neg = Pal2, add = FALSE) - -AddBubbles(x, z = z, bg.pos = Pal1, bg.neg = Pal2, add = FALSE, - make.intervals = TRUE) - -AddBubbles(x, z = runif(n, 10, 10000), title = "Quantiles", bg.pos = topo.colors, - quantile.breaks = TRUE, fg = NULL, add = FALSE) -} - -\keyword{hplot} diff --git a/man/AddColorKey.Rd b/man/AddColorKey.Rd deleted file mode 100644 index eca926b..0000000 --- a/man/AddColorKey.Rd +++ /dev/null @@ -1,53 +0,0 @@ -\name{AddColorKey} - -\alias{AddColorKey} - -\title{Add Color Key to Plot} - -\description{ -This function can be used to add a color key to a plot. -} - -\usage{ -AddColorKey(mai, is.categorical, breaks, col, at = NULL, labels = TRUE, - scientific = FALSE, explanation = NULL, padx = 0.2) -} - -\arguments{ -\item{mai}{\code{numeric}; a numerical vector of the form \code{c(bottom, left, top, right)} which gives the margin size specified in inches (optional).} -\item{is.categorical}{\code{logical}; if \code{TRUE}, color-key values represent categorical data; otherwise, these data values are assumed continuous.} -\item{breaks}{\code{numeric}; a set of finite numeric breakpoints for the colors: must have one more breakpoint than color and be in increasing order.} -\item{col}{\code{character}; a vector of colors to be used in the plot. - This argument requires \code{breaks} specification for continuous data. - For continuous data there should be one less color than breaks; whereas, categorical data require a color for each category.} -\item{at}{\code{numeric}; the points at which tick-marks and labels are to be drawn, only applicable for continuous data. - The tick-marks will be located at the color breaks if the length of \code{at} is greater than or equal to one minus the length of \code{breaks}.} -\item{labels}{\code{logical} or \code{character}; this can either be a logical value specifying whether (numerical) annotations are to be made at the tickmarks, or a character or expression vector of labels to be placed at the tickpoints.} -\item{scientific}{\code{logical}; indicates if axes labels should be formatted for scientific notation, see \code{\link{ToScientific}} for details.} -\item{explanation}{\code{character}; a label that describes the data values.} -\item{padx}{\code{numeric}; the inner padding for the left and right margins specified in inches.} -} - -\value{ -Used for the side-effect of a color key drawn on the current graphics device. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{\link{PlotCrossSection}}, \code{\link{PlotMap}}} - -\examples{ -dev.new(width = 7, height = 2) - -AddColorKey(is.categorical = FALSE, breaks = 0:10, scientific = TRUE, - explanation = "Example description for data variables in meters.") -AddColorKey(is.categorical = FALSE, breaks = 0:10, at = pretty(0:10)) -AddColorKey(is.categorical = FALSE, breaks = seq(0.5, 10.5, by = 1), at = 1:10) - -AddColorKey(is.categorical = TRUE, labels = LETTERS[1:5]) -AddColorKey(is.categorical = TRUE, col = terrain.colors(5)) - -graphics.off() -} - -\keyword{hplot} diff --git a/man/AddInsetMap.Rd b/man/AddInsetMap.Rd deleted file mode 100644 index ba438ba..0000000 --- a/man/AddInsetMap.Rd +++ /dev/null @@ -1,51 +0,0 @@ -\name{AddInsetMap} - -\alias{AddInsetMap} - -\title{Add Inset Map to Plot} - -\description{ -This function can be used to add an inset map to a plot. -} - -\usage{ -AddInsetMap(p, col = c("#D8D8D8", "#BFA76F"), - main.label = list(label = NA, adj = NULL), - sub.label = list(label = NA, adj = NULL), - loc = c("bottomleft", "topleft", "topright", "bottomright"), - inset = 0.02, width = NULL) -} - -\arguments{ -\item{p}{\code{SpatialPolygons}; the polygon describing the large map.} -\item{col}{\code{character}; a vector of length 2 giving the colors for filling the large map polygon \code{p} and the smaller plot extent rectangle.} -\item{main.label}{\code{list}; a list with components \code{label} and \code{adj}. - The text label and position (\code{x} and \code{y} adjustment of the label) for the large map, respectively.} -\item{sub.label}{\code{list}; identical to the \code{main.label} argument but for the plot extent rectangle.} -\item{loc}{\code{character}; the position of the inset map in the main plot region: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote scale location.} -\item{inset}{\code{numeric}; the inset distance from the margins as a fraction of the main plot region. - Defaults to 2 percent of the axis range.} -\item{width}{\code{numeric}; the width of the inset map, in inches.} -} - -\details{ -The smaller axis-aligned rectangle (relative to the larger map polygon) is defined by the user coordinate extent of the main plot region, see \code{par("usr")}. -} - -\value{ -Used for the side-effect of a inset map drawn on the current graphics device. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{\link{PlotMap}}} - -\examples{ -PlotMap(alluvium.thickness@crs, bg.image = hill.shading, reg.axs = FALSE) -AddInsetMap(idaho, main.label = list("IDAHO", adj = c(-0.4, -4.9)), - sub.label = list("Map area", adj = c(0.5, 2.5)), loc = "topright") - -graphics.off() -} - -\keyword{hplot} diff --git a/man/AddScaleBar.Rd b/man/AddScaleBar.Rd deleted file mode 100644 index 49b4b3c..0000000 --- a/man/AddScaleBar.Rd +++ /dev/null @@ -1,40 +0,0 @@ -\name{AddScaleBar} - -\alias{AddScaleBar} - -\title{Add Scale Bar to Plot} - -\description{ -This function can be used to add a scale bar to a plot. -} - -\usage{ -AddScaleBar(asp = 1, unit = NULL, is.lonlat = FALSE, - loc = c("bottomleft", "topleft", "topright", "bottomright"), - offset = c(0, 0), lab.vert.exag = NULL) -} - -\arguments{ -\item{asp}{\code{numeric}; the \emph{y/x} aspect ratio for spatial axes.} -\item{unit}{\code{character}; axis unit of measurement, for example \code{"METERS"}.} -\item{is.lonlat}{\code{logical}; if \code{TRUE}, plot coordinates are in longitude and latitude.} -\item{loc}{\code{character}; the position of the scale bar in the plot region: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote scale location.} -\item{offset}{\code{numeric}; the \code{x} and \code{y} adjustments of the scale bar, in inches.} -\item{lab.vert.exag}{\code{logical}; if \code{TRUE}, a label is drawn specifying the vertical exaggeration.} -} - -\value{ -Used for the side-effect of a scale bar drawn on the current graphics device. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{\link{PlotCrossSection}}, \code{\link{PlotMap}}} - -\examples{ -plot(-100:100, -100:100, type = "n", xlab = "x", ylab = "y", asp = 2) -AddScaleBar(2, unit = "FEET", loc = "topleft") -AddScaleBar(2, unit = "METERS", loc = "bottomright", offset = c(-0.2, 0)) -} - -\keyword{hplot} diff --git a/man/BumpDisconnectCells.Rd b/man/BumpDisconnectCells.Rd deleted file mode 100644 index 9e3c247..0000000 --- a/man/BumpDisconnectCells.Rd +++ /dev/null @@ -1,47 +0,0 @@ -\name{BumpDisconnectCells} - -\alias{BumpDisconnectCells} - -\title{Adjustment for Vertically Disconnected Cells} - -\description{ -This function decreases model cell values (such as, land-surface elevations) in the lower raster layer if they violate a minimum vertical overlap between adjacent cells. -} - -\usage{ -BumpDisconnectCells(rs, min.overlap = 2, bump.by = 0.1, max.itr = 1e+04) -} - -\arguments{ -\item{rs}{\code{RasterStack}; a collection of two raster layers, the first and second layers represent the top and bottom of a model layer.} -\item{min.overlap}{\code{numeric}; the minimum vertical overlap between adjacent cells.} -\item{bump.by}{\code{numeric}; the amount to decrease a cell value by during each iteration of the algorithm.} -\item{max.itr}{\code{numeric}; the maximum number of iterations.} -} - -\details{ -During each iteration of the algorithm: -(1) Cells are identified that violate the minimum vertical overlap between adjacent cells; that is, the bottom of cell \code{i} is greater than or equal to the top of an adjacent cell \code{j} minus the minimum overlap specified by the \code{min.overlap} argument. -(2) For cells violating the minimum vertical overlap, lower raster layer (\code{rs[[2]]}) values are decreased by the value specified in the \code{bump.by} argument. -} - -\value{ -Returns a \code{RasterLayer} that can be added to \code{rs[[2]]} to ensure connectivity between cells. -Cell values in the returned raster grid represent vertical adjustments. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\examples{ -set.seed(0) -r.top <- raster(ncols = 10, nrows = 10) -r.bot <- raster(ncols = 10, nrows = 10) -r.top[] <- rnorm(ncell(r.top), mean = 12) -r.bot[] <- rnorm(ncell(r.bot), mean = 10) -summary(r.top - r.bot) - -r <- BumpDisconnectCells(stack(r.top, r.bot), min.overlap = 0.1) -plot(r.bot + r) -} - -\keyword{utilities} diff --git a/man/BumpRiverStage.Rd b/man/BumpRiverStage.Rd deleted file mode 100644 index e8e6867..0000000 --- a/man/BumpRiverStage.Rd +++ /dev/null @@ -1,41 +0,0 @@ -\name{BumpRiverStage} - -\alias{BumpRiverStage} - -\title{Adjustment for Implausible River Stage} - -\description{ -This function decreases stage values in river cells if they are implausible with respect to water always flowing downhill. -} - -\usage{ -BumpRiverStage(r, outlets, min.drop = 1e-06) -} - -\arguments{ -\item{r}{\code{RasterLayer}; each cell on the surface grid represents a river stage.} -\item{outlets}{\code{SpatialPoints*}, \code{SpatialLines*}, \code{SpatialPolygons*} or \code{Extent}; the location of discharge outlets. - The \code{rasterize} function is used to locate outlet cells in the raster grid \code{r}.} -\item{min.drop}{\code{numeric}; the minimum drop in stage between adjacent river cells.} -} - -\details{ -The \href{http://en.wikipedia.org/wiki/Lee_algorithm}{Lee algorithm} (Lee, 1961) is used to identify flow paths among the modeled river cells. -An analysis of river cell stage values along a flow path identifies any problematic cells that are obstructing downhill surface-water flow. -Stage values for these problematic cells are then lowered to an acceptable elevation. -} - -\value{ -Returns a \code{RasterLayer} with cell values representing the vertical change in stream stage. -These changes can be added to \code{r} to ensure that water always flows downhill. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\references{ -Lee, C.Y., 1961, An algorithm for path connections and its applications: IRE Transactions on Electronic Computers, v. EC-10, no. 2, p. 346--365. -} - -\examples{\dontrun{# see uncalibrated-model vignette}} - -\keyword{utilities} diff --git a/man/DownloadFile.Rd b/man/DownloadFile.Rd deleted file mode 100644 index 5c7f4bf..0000000 --- a/man/DownloadFile.Rd +++ /dev/null @@ -1,46 +0,0 @@ -\name{DownloadFile} - -\alias{DownloadFile} - -\title{Download File from the Internet} - -\description{ -This function downloads a file from the Internet. -} - -\usage{ -DownloadFile(url, dest.dir = tempdir(), mode = NULL, extract = TRUE, - max.attempts = 10L, wait.time = 30) -} - -\arguments{ -\item{url}{\code{character}; the URL (or FTP) of a resource to be downloaded.} -\item{dest.dir}{\code{character}; the directory where the downloaded file is saved.} -\item{mode}{\code{character}; the mode with which to write the file, such as \code{"w"}, \code{"wb"} (binary), \code{"a"} (append) and \code{"ab"}.} -\item{extract}{\code{logical}; if \code{TRUE}, an attempt is made to extract files from the file archive.} -\item{max.attempts}{\code{integer}; the maximum number of attempts to download a file.} -\item{wait.time}{\code{numeric}; the time to wait between download attempts, in seconds.} -} - -\details{ -This function requires package \pkg{RCurl}. -} - -\value{ -Returns the file path(s) to the downloaded file (or uncompressed files). -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{ -\code{CFILE}, \code{curlPerform} -} - -\examples{\dontrun{ -url <- paste0("https://raw.githubusercontent.com/USGS-R/", - "wrv/master/inst/extdata/alluvium.extent.zip") -files <- DownloadFile(url) -unlink(files)} -} - -\keyword{IO} diff --git a/man/ExportRasterStack.Rd b/man/ExportRasterStack.Rd deleted file mode 100644 index 0b8cd5e..0000000 --- a/man/ExportRasterStack.Rd +++ /dev/null @@ -1,48 +0,0 @@ -\name{ExportRasterStack} - -\alias{ExportRasterStack} - -\title{Export Raster Stack} - -\description{ -This function writes a raster-stack, a collection of raster layers, to local directories using multiple file formats. -} - -\usage{ -ExportRasterStack(rs, path, zip = "", col = rainbow(250, start = 0.0, end = 0.8)) -} - -\arguments{ -\item{rs}{\code{RasterStack}; a collection of \code{\linkS4class{RasterLayer}} objects with the same extent and resolution.} -\item{path}{\code{character}; path name to write raster stack.} -\item{zip}{\code{character}; if there is no zip program on your path (on windows), you can supply the full path to a \file{zip.exe} here, in order to make a KMZ file.} -\item{col}{\code{character}; a vector of colors.} -} - -\details{ -Five local directories are created under \code{path} and named after their intended file formats: -Comma-Separated Values (\file{csv}), -Portable Network Graphics (\file{png}), -georeferenced TIFF (\file{tif}), -R Data (\file{rda}), -and Keyhole Markup Language (\file{kml}). -For its reference system, \file{kml} uses geographic coordinates: longitude and latitude components as defined by the World Geodetic System of 1984. -Therefore, the conversion of gridded data between cartographic projections may introduce a new source of error. - -To install \file{zip.exe} on windows, download the latest binary version from the \href{http://www.info-zip.org/Zip.html#Downloads}{Info-ZIP} website: -select one of the given FTP locations, enter directory \file{win32}, download \file{zip300xn.zip}, and extract. -} - -\value{None. Used for the side-effect files written to disk.} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{writeRaster}} - -\examples{\dontrun{ -f <- file.path(getwd(), "SIR2016-5080/ancillary/uncalibrated/data/rda/rasters.rda") -load(file = f) -ExportRasterStack(rs, tempdir())} -} - -\keyword{IO} diff --git a/man/ExtractAlongTransect.Rd b/man/ExtractAlongTransect.Rd deleted file mode 100644 index 98c4e40..0000000 --- a/man/ExtractAlongTransect.Rd +++ /dev/null @@ -1,69 +0,0 @@ -\name{ExtractAlongTransect} - -\alias{ExtractAlongTransect} - -\title{Extract Raster Values Along Transect Line} - -\description{ -This function extracts values from raster layer(s) along a user defined transect line. -} - -\usage{ -ExtractAlongTransect(transect, r) -} - -\arguments{ -\item{transect}{\code{SpatialPoints} or \code{SpatialLines}; transect line or its vertices.} -\item{r}{\code{RasterLayer}, \code{RasterStack}, or \code{RasterBrick}; the raster layer(s)} -} - -\details{ -The transect line is described using a simple polygonal chain. -The transect line and raster layer(s) must be specified in a coordinate reference system. -} - -\value{ -A \code{list} is returned with components of class \code{SpatialPointsDataFrame}. -These components represent continuous piecewise line segments along the transect. -The following variables are specified for each coordinate point in the line segment: -\item{dist}{\code{numeric}; the distance along the transect line.} -\item{2, \dots, n}{\code{numeric}; the extracted value for each raster layer in \code{r}, where column names match their respective raster layer name.} -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{\link{PlotCrossSection}}} - -\examples{ -coords <- rbind(c(-100, -90), c(80, 90), c(80, 0), c(40, -40)) -crs <- CRS("+proj=longlat +datum=WGS84") -transect <- SpatialPoints(coords, proj4string = crs) -r <- raster(nrows = 10, ncols = 10, ymn = -80, ymx = 80, crs = crs) -names(r) <- "value" -set.seed(0) -r[] <- runif(ncell(r)) -r[4, 6] <- NA -plot(r, xlab = "x", ylab = "y") -lines(SpatialLines(list(Lines(list(Line(coords)), ID = "Transect")), proj4string = crs)) -points(transect, pch = 21, bg = "red") -segs <- ExtractAlongTransect(transect, r) -for (i in 1:length(segs)) points(segs[[i]], col = "blue") - -dev.new() -xlab <- "Distance along transect" -ylab <- "Raster value" -xlim <- range(vapply(segs, function(seg) range(seg@data[, "dist"]), c(0, 0))) -ylim <- range(vapply(segs, function(seg) range(seg@data[, "value"], na.rm = TRUE), - c(0, 0))) -plot(NA, type = "n", xlab = xlab, ylab = ylab, xlim = xlim, ylim = ylim) -for (i in 1:length(segs)) - lines(segs[[i]]@data[, c("dist", "value")], col = rainbow(length(segs))[i]) -coords <- coordinates(transect) -n <- length(transect) -d <- cumsum(c(0, as.matrix(dist((coords)))[cbind(1:(n - 1), 2:n)])) -abline(v = d, col = "grey", lty = 2) -mtext(paste0("(", paste(head(coords, 1), collapse = ", "), ")"), adj = 0) -mtext(paste0("(", paste(tail(coords, 1), collapse = ", "), ")"), adj = 1) -} - -\keyword{utilities} diff --git a/man/GetDaysInMonth.Rd b/man/GetDaysInMonth.Rd deleted file mode 100644 index d76e020..0000000 --- a/man/GetDaysInMonth.Rd +++ /dev/null @@ -1,29 +0,0 @@ -\name{GetDaysInMonth} - -\alias{GetDaysInMonth} - -\title{Get Number of Days in a Year and Month} - -\description{ -This function determines the number of days in a year and month. -} - -\usage{ -GetDaysInMonth(x) -} - -\arguments{ -\item{x}{\code{character} or \code{integer}; a vector of year and month values, with a required date format of \code{YYYYMM}.} -} - -\value{ -Returns an integer vector indicating the number of days in each year and month value specified in \code{x}. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\examples{ -GetDaysInMonth(c("199802", "199804", "200412")) -} - -\keyword{utilities} diff --git a/man/GetSeasonalMult.Rd b/man/GetSeasonalMult.Rd index e5b9b72..e652fa7 100644 --- a/man/GetSeasonalMult.Rd +++ b/man/GetSeasonalMult.Rd @@ -1,49 +1,60 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/GetSeasonalMult.R \name{GetSeasonalMult} - \alias{GetSeasonalMult} - \title{Get Seasonal Multiplier} - -\description{ -This function determines the seasonal fraction of the long-term mean value. -} - \usage{ -GetSeasonalMult(x, reduction, d.in.mv.ave, tr.stress.periods) +GetSeasonalMult(x, reduction, d.in.mv.ave, fixed.dates) } - \arguments{ -\item{x}{\code{data.frame}; a time series with \code{Date} and \code{numeric} components.} -\item{reduction}{\code{numeric}; is the signal amplitude reduction, a dimensionless quantity. - Its magnitude should be greater than or equal to 1, where a value of 1 indicates no reduction in the signal amplitude.} -\item{d.in.mv.ave}{\code{numeric}; is the number of days in the moving average subset.} -\item{tr.stress.periods}{\code{Date}; a vector giving the start and end dates for each model stress period.} -} +\item{x}{data.frame. +Time series data (observations) with components of class Date and numeric.} -\details{ -A simple moving average is first calculated for each month using the previous data (such as the previous 9-months of stage data recorded at a streamgage). -The seasonal average of the monthly moving average is then passed through a signal amplitude reduction algorithm. -The reduced values are then divided by the mean of the seasonal reduced data to give the seasonal fraction of the mean (seasonal multiplier). -} +\item{reduction}{numeric. +Signal amplitude reduction, a dimensionless quantity. +Its magnitude should be greater than or equal to 1; +where a value of 1 indicates no reduction in the signal amplitude.} + +\item{d.in.mv.ave}{numeric. +Number of days in the moving average subset.} +\item{fixed.dates}{Date. +Vector of equally spaced dates, these are the fixed locations where the moving average is calculated. +The final date is neglected.} +} \value{ -An object of \code{data.frame} class with \code{Date} and \code{numeric} components; that is, the starting date and multiplier for each season. +Returns an object of class data.frame with the following variables: + \describe{ + \item{\code{names(x)[1]}}{start date for each season in \code{fixed.dates}.} + \item{multiplier}{seasonal scaling index} + } } - -\author{ -J.C. Fisher and J.R. Bartolino, U.S. Geological Survey, Idaho Water Science Center - -A.H. Wylie and J. Sukow, Idaho Department of Water Resources +\description{ +This function determines the seasonal fraction of the long-term mean value. +} +\details{ +A simple moving average is first calculated at dates specified in \code{fixed.dates} + using past observational data in \code{x} + (such as the previous 9-months of stage data recorded at a streamgage). + The seasonal average of the moving average is then passed through a signal amplitude reduction algorithm. + The reduced values are then divided by the mean of the seasonal reduced data to give + the seasonal fraction of the mean (also known as the seasonal scaling index). } - \examples{ -tr.interval <- as.Date(c("1995-01-01", "2011-01-01")) -tr.stress.periods <- seq(tr.interval[1] , tr.interval[2], "1 month") -m <- GetSeasonalMult(gage.disch[, c("Date", "13139510")], 2, 273.932, tr.stress.periods) -f <- vapply(tributaries$Flow, function(i) m$multiplier * i, rep(0, nrow(m))) -colnames(f) <- tributaries$ID -d <- cbind(m, f) +obs <- dataRetrieval::readNWISdata(sites = "13139510", parameterCd = "00060", + startDate = "1992-01-01", endDate = "2011-01-01") +obs <- obs[, c("dateTime", "X_00060_00003")] +obs[, 1] <- as.Date(obs[, 1]) + +fixed.dates <- seq(as.Date("1995-01-01"), as.Date("2011-01-01"), "1 month") +d <- GetSeasonalMult(obs, 2, 273.932, fixed.dates) str(d) + } +\author{ +J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center + A.H. Wylie and J. Sukow, Idaho Department of Water Resources +} \keyword{manip} + diff --git a/man/GetWellConfig.Rd b/man/GetWellConfig.Rd index 69684d3..f0126d9 100644 --- a/man/GetWellConfig.Rd +++ b/man/GetWellConfig.Rd @@ -1,51 +1,66 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/GetWellConfig.R \name{GetWellConfig} - \alias{GetWellConfig} - \title{Get Well Completion and Pumping Rate in Model Space} +\usage{ +GetWellConfig(rs.model, wells, well.col, rate.col = NULL, + lay2.hk.tol = 0.01) +} +\arguments{ +\item{rs.model}{RasterStack. +Composed of raster layers describing the model grid and hydraulic conductivity distribution: + \code{lay1.top}, \code{lay1.bot}, \code{lay2.bot}, \code{lay3.bot}, + \code{lay1.hk}, \code{lay2.hk}, and \code{lay3.hk}.} + +\item{wells}{SpatialPointsDataFrame. +Average pumping rate for each well during various times.} +\item{well.col}{character. +Column name of the well identifier field.} + +\item{rate.col}{character. +Vector of column names for the pumping rate fields.} + +\item{lay2.hk.tol}{numeric. +Hydraulic conductivity tolerance for model cells in layer 2. +Used to prevent pumping in the aquitard layer of the aquifer system. +Pumping is prohibited in model layer 2 cells with hydraulic conductivity values less than +\code{lay2.hk.tol} and a well opening isolated to layer 2; +for these cases, pumping is allocated to the adjacent layer 1 cell.} +} +\value{ +Returns an object of class data.frame with the following components: + \describe{ + \item{\dots}{unique identifier assigned to a well, its name is specified by \code{well.col}.} + \item{lay,row,col}{layer, row, and column number of a model cell, respectively.} + \item{hk}{hydraulic conductivity of the model cell, in meters per day.} + \item{thk}{vertical length of the well opening (open borehole or screen) in the model cell, in meters. + A value of zero indicates that the well opening is unknown or below the modeled bedrock surface.} + \item{frac}{transmissivity fraction for a model cell, + where transmissivity is defined as \code{hk} multiplied by \code{thk}.} + \item{\dots}{pumping rate allocated to the model cell for each time period + specified by \code{rate.col}, in cubic meters per day. + The pumping rate is calculated by multiplying the pumping demand for a well + (specified in \code{wells}) by \code{frac}.} + } +} \description{ This function determines well completions and pumping rates in model space. The pumping rate is specified for each model cell intersecting a well's open interval(s) and calculated by multiplying the estimated pumping demand by the cell's transmissivity fraction. -The transmissivity fraction is calculated by dividing the cell's aquifer transmissivity by the sum of all transmissivity values for cells belonging to the same well. +The transmissivity fraction is calculated by dividing the cell's aquifer transmissivity by +the sum of all transmissivity values for cells belonging to the same well. The transmissivity fraction calculation assumes saturated conditions in the model cell. } +\examples{ +\dontrun{# see Appendix D. Uncalibrated Groundwater-Flow Model} -\usage{ -GetWellConfig(rs.model, wells, well.col, rate.col = NULL, lay2.hk.tol = 1e-02) -} - -\arguments{ -\item{rs.model}{\code{RasterStack}; is composed of raster layers describing the model grid and hydraulic conductivity distribution: - \code{lay1.top}, \code{lay1.bot}, \code{lay2.bot}, \code{lay3.bot}, \code{lay1.top}, \code{lay1.hk}, \code{lay2.hk}, and \code{lay3.hk}.} -\item{wells}{\code{SpatialPointsDataFrame}; is the average pumping rate for each well during various times.} -\item{well.col}{\code{character}; is the column name of the well identifier field.} -\item{rate.col}{\code{character}; is a vector of column names for the pumping rate fields.} -\item{lay2.hk.tol}{\code{numeric}; is the hydraulic conductivity tolerance for model cells in layer 2. - Used to prevent pumping in the aquitard layer of the aquifer system. - Pumping is prohibited in model layer 2 cells with hydraulic conductivity values less than \code{lay2.hk.tol} and a well opening isolated to layer 2; - for these cases, pumping is allocated to the adjacent layer 1 cell.} } - -\value{ -An object of \code{data.frame} class with the following components: -\item{\dots}{\code{numeric}; a unique identifier assigned to a well, its name is specified by \code{well.col}.} -\item{lay, row, col}{\code{integer}; is the layer, row, and column number of a model cell, respectively.} -\item{hk}{\code{numeric}; is the hydraulic conductivity of the model cell, in meters per day.} -\item{thk}{\code{numeric}; is the vertical length of the well opening (open borehole or screen) in the model cell, in meters. - A value of zero indicates that the well opening is unknown or below the modeled bedrock surface.} -\item{frac}{\code{numeric}; is the transmissivity fraction for a model cell, where transmissivity is defined as \code{hk} multiplied by \code{thk}.} -\item{\dots}{\code{numeric}; is the pumping rate allocated to the model cell for each time period specified by \code{rate.col}, in cubic meters per day. - The pumping rate is calculated by multiplying the pumping demand for a well (specified in \code{wells}) by \code{frac}.} -} - \author{ J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -A.H. Wylie, Idaho Department of Water Resources + A.H. Wylie, Idaho Department of Water Resources } - -\examples{\dontrun{# see uncalibrated-model vignette}} - \keyword{manip} + diff --git a/man/PlotCrossSection.Rd b/man/PlotCrossSection.Rd deleted file mode 100644 index 8d12b80..0000000 --- a/man/PlotCrossSection.Rd +++ /dev/null @@ -1,102 +0,0 @@ -\name{PlotCrossSection} - -\alias{PlotCrossSection} - -\title{Plot Method for Cross Sections} - -\description{ -This function creates a cross-section view of raster data. -A key showing how the colors map to raster values is shown below the map. -} - -\usage{ -PlotCrossSection(transect, rs, geo.lays = names(rs), val.lays = NULL, - wt.lay = NULL, asp = 1, ylim = NULL, max.dev.dim = c(43, 56), - n = NULL, breaks = NULL, pal = NULL, col = NULL, ylab = NULL, - unit = NULL, id = c("A", "A'"), labels = NULL, - explanation = NULL, features = NULL, max.feature.dist = Inf, - draw.key = TRUE, draw.sep = TRUE, is.categorical = FALSE, - contour.lines = NULL, bg.col = "#E1E1E1", wt.col = "#FFFFFFD8") -} - -\arguments{ -\item{transect}{\code{SpatialLines}; the piecewise linear transect line.} -\item{rs}{\code{RasterStack}; a collection of \code{RasterLayer} objects with the same extent and resolution.} -\item{geo.lays}{\code{character}; a vector of names in \code{rs} that specify the geometry raster layers; these must be given in decreasing order, that is, from the upper most (such as land surface) to the lowest (such as a bedrock surface).} -\item{val.lays}{\code{character}; a vector of names in \code{rs} that specify the value raster layers (optional). - Values from the first layer are mapped as colors to the area between the first and second geometry layers; the second layer mapped between the second and third geometry layers, and so on.} -\item{wt.lay}{\code{character}; the name in \code{rs} that specifies the water-table raster layer (optional).} -\item{asp}{\code{numeric}; the \emph{y/x} aspect ratio for spatial axes.} -\item{ylim}{\code{numeric}; a vector of length 2 giving the minimum and maximum values for the \emph{y}-axis.} -\item{max.dev.dim}{\code{numeric}; a vector of length 2 giving the maximum width and height for the graphics device in picas, respectively. - Suggested dimensions for single-column, double-column, and sidetitle figures are \code{c(21, 56)}, \code{c(43, 56)}, and \code{c(56, 43)}, respectively.} -\item{n}{\code{integer}; the desired number of intervals to partition the range of raster values (optional).} -\item{breaks}{\code{numeric}; a vector of break points used to partition the colors representing numeric raster values (optional).} -\item{pal}{\code{function}; a color palette to be used to assign colors in the plot, \code{rainbow} by default.} -\item{col}{\code{character}; a vector of colors to be used in the plot. - This argument requires \code{breaks} specification for numeric raster values and overrides any palette function specification. - For numeric values there should be one less color than breaks. - Categorical data require a color for each category.} -\item{ylab}{\code{character}; a label for the \emph{y} axis.} -\item{unit}{\code{character}; a label for the measurement unit of the \emph{x}- and \emph{y}-axes.} -\item{id}{\code{character}; a vector of length 2 giving the labels for the end points of the transect line, defaults to \emph{A--A'}.} -\item{labels}{\code{list}; describes the location and values of labels in the color key. - This list may include components \code{at} and \code{labels}, numeric and character vectors, respectively.} -\item{explanation}{\code{character}; a label that describes the cell values.} -\item{features}{\code{SpatialGridDataFrame}; point features adjacent to the transect line that are used as reference labels for the upper geometry layer.} -\item{max.feature.dist}{\code{numeric}; the maximum distance from a point feature to the transect line, specified in the units of the \code{rs} projection.} -\item{draw.key}{\code{logical}; if \code{FALSE}, a color key is not drawn.} -\item{draw.sep}{\code{logical}; if \code{TRUE}, lines separating geometry layers are drawn.} -\item{is.categorical}{\code{logical}; if \code{TRUE}, cell values in \code{val.lays} represent categorical data; otherwise, these data values are assumed continuous.} -\item{contour.lines}{\code{list}; if specified, contour lines are drawn. - The contours are described using a list of arguments supplied to \code{contour}. - Passed arguments include \code{"drawlables"}, \code{"method"}, and \code{"col"}.} -\item{bg.col}{\code{character}; the color used for the background of the area below the upper geometry raster layer.} -\item{wt.col}{\code{character}; the color used for the water-table line.} -} - -\details{ -The dimensions of a new graphics device is dependent on the argument values of \code{max.dev.dim} and \code{asp}. -} - -\value{ -Used for the side-effect of a new plot generated. -Returns a \code{list} object with the following graphical parameters: -\item{din}{\code{numeric}; the device dimensions \code{(width, height)}, in inches.} -\item{usr}{\code{numeric}; the extremes of the coordinates of the plotting region \code{(x1, x2, y1, y2)}.} -\item{heights}{\code{numeric}; the relative heights on the device \code{(upper, lower)} for the map and color-key plots.} -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{\link{ExtractAlongTransect}}, \code{\link{AddScaleBar}}, \code{\link{AddColorKey}}} - -\examples{ -data(volcano) -x <- seq(from = 2667405, length.out = 61, by = 10) -y <- seq(from = 6478705, length.out = 87, by = 10) -r1 <- raster(volcano, xmn = min(x), xmx = max(x), ymn = min(y), ymx = max(y), - crs = CRS("+init=epsg:27200")) -r2 <- min(r1[]) - r1 / 10 -r3 <- r1 - r2 -rs <- stack(r1, r2, r3) -names(rs) <- c("r1", "r2", "r3") - -xy <- rbind(c(2667508, 6479501), c(2667803, 6479214), c(2667508, 6478749)) -transect <- SpatialLines(list(Lines(list(Line(xy)), ID = "Transect")), - proj4string = crs(rs)) - -plot(r1) -lines(transect) -text(as(transect, "SpatialPoints"), labels = c("A", "BEND", "A'"), cex = 0.7, - pos = c(3, 4, 1), offset = 0.1, font = 4) - -graphics.off() -PlotCrossSection(transect, rs, geo.lays = c("r1", "r2"), val.lays = "r3", - ylab="Elevation", asp = 5, unit = "METERS", - explanation = "Vertical thickness between layers, in meters.") - -graphics.off() -} - -\keyword{hplot} diff --git a/man/PlotGraph.Rd b/man/PlotGraph.Rd deleted file mode 100644 index 0c3726c..0000000 --- a/man/PlotGraph.Rd +++ /dev/null @@ -1,88 +0,0 @@ -\name{PlotGraph} - -\alias{PlotGraph} - -\title{Plot Method for Graphs} - -\description{ -This function draws a sequence of points, lines, or box-and-whiskers using specified coordinates. -} - -\usage{ -PlotGraph(x, y, xlab, ylab, asp = NA, xlim = NULL, ylim = NULL, - xn = 5L, yn = 5L, ylog = FALSE, type = "s", lty = 1, lwd = 1, - pch = NULL, col = NULL, bg = NA, fill = NULL, pt.cex = 1, - seq.date.by = "year", scientific = NA, conversion.factor = NULL, - boxwex = 0.8, center.date.labels = FALSE, bg.polygon = NULL) -} - -\arguments{ -\item{x, y}{\code{Date}, \code{numeric}, \code{matrix}, or \code{data.frame}; vectors or matrices of data for plotting. - The vector length or number of rows should match. - If \code{y} is missing, then \code{x = x[, 1]} and \code{y = x[, 2:n]}.} -\item{xlab}{\code{character}; title for \emph{x} and axis.} -\item{ylab}{\code{character}; a vector of length 2 giving the title for the 1st and 2nd \emph{y} axes. - The title for the 2nd \emph{y} axis is optional and requires \code{conversion.factor} be specified.} -\item{asp}{\code{numeric}; the \emph{y/x} aspect ratio.} -\item{xlim}{\code{numeric} or \code{Date}; the \code{x} limits \code{(x1, x2)} of the plot.} -\item{ylim}{\code{numeric}; the \code{y} limits \code{(y1, y2)} of the plot.} -\item{xn, yn}{\code{integer}; the desired number of intervals between tick-marks on the \emph{x}- and \emph{y}-axis, respectively.} -\item{ylog}{\code{logical}; if \code{TRUE}, a logarithm scale is used for the \emph{y} axis.} -\item{type}{\code{character}; is the type of plot for each column of \code{y}, see \code{plot} for possible types. - A box-and-whisker plot is drawn when \code{type = "box"}, with whiskers extending to the data extremes.} -\item{lty}{\code{integer}; is the line type, see \code{par} for all possible types. - Line types are used cyclically.} -\item{lwd}{\code{numeric}; is the line width.} -\item{pch}{\code{integer}; is the point type, see \code{points} for all possible types. - Point types are used cyclically.} -\item{col}{\code{character} or \code{function}; is the point or line color, see \code{par} for all possible ways this can be specified. - Colors are used cyclically.} -\item{bg}{\code{character}; a vector of background colors for the open plot symbols given by \code{pch = 21:25} as in \code{points}.} -\item{fill}{\code{character}; a vector of fill colors for areas beneath (or above, direction towards 0) lines of type \code{"l"} or \code{"s"}.} -\item{pt.cex}{\code{numeric}; expansion factor for the points.} -\item{seq.date.by}{\code{character}, \code{numeric}, or \code{difftime}; is the increment of the date sequence, see \code{seq.Date} for all possible ways this can be specified.} -\item{scientific}{\code{logical}; a vector of length 3 that indicates if axes labels should be encoded in nice scientific format. - Vector elements correspond to the \code{x}-axis, \code{y}-axis, and second \code{y}-axis labels. - Values are recycled as necessary.} -\item{conversion.factor}{\code{numeric}; a conversion factor for the 2nd \emph{y} axis.} -\item{boxwex}{\code{numeric}; a scale factor to be applied to all boxes, only applicable for box-and-whisker plots.} -\item{center.date.labels}{\code{logical}; if \code{TRUE}, date labels are horizontally centered between \emph{x}-axis tickmarks.} -\item{bg.polygon}{\code{list}; if specified, a background polygon is drawn. - The polygon is described using a list of arguments supplied to the \code{polygon} function. - Passed arguments include \code{"x"} and \code{"col"}.} -} - -\value{ -Used for the side-effect of a new plot generated. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{matplot}, \code{boxplot}} - -\examples{ -n <- 50L - -x <- as.Date("2008-07-12") + 1:n -y <- sample.int(n, replace = TRUE) -PlotGraph(x, y, ylab = paste("Random number in", c("meters", "feet")), type = "p", - pch = 16, seq.date.by = "weeks", scientific = FALSE, conversion.factor = 3.28) - -graphics.off() -y <- data.frame(lapply(1:3, function(i) sample(n, replace = TRUE))) -PlotGraph(x, y, ylab = "Random number", type = "s", pch = 1, seq.date.by = "days", - scientific=TRUE) - -graphics.off() -y <- sapply(1:3, function(i) sample((1:100) + i * 100, n, replace = TRUE)) -m <- cbind(as.numeric(x), y) -col <- c("red", "gold", "green") -PlotGraph(m, xlab = "Number", ylab = "Random number", type = "b", pch = 15:17, - col = col, pt.cex = 0.9) -legend("topright", LETTERS[1:3], inset = 0.05, col = col, lty = 1, pch = 15:17, - pt.cex = 0.9, cex = 0.8, bg = "white") - -graphics.off() -} - -\keyword{hplot} diff --git a/man/PlotMap.Rd b/man/PlotMap.Rd deleted file mode 100644 index edf177b..0000000 --- a/man/PlotMap.Rd +++ /dev/null @@ -1,128 +0,0 @@ -\name{PlotMap} - -\alias{PlotMap} - -\title{Plot Method for Maps} - -\description{ -This function maps raster layer values. A key showing how the colors map to raster values is shown below the map. -} - -\usage{ -PlotMap(r, layer = 1, att = NULL, n, breaks, xlim = NULL, ylim = NULL, - zlim = NULL, asp = 1, extend.xy = FALSE, extend.z = FALSE, - reg.axs = TRUE, trim.r = TRUE, dms.tick = FALSE, bg.lines = FALSE, - bg.image = NULL, bg.image.alpha = 1, pal = NULL, col = NULL, - max.dev.dim = c(43, 56), labels = NULL, scale.loc = "bottomleft", - arrow.loc = NULL, explanation = NULL, credit = proj4string(r), - shade = NULL, contour.lines = NULL, rivers = NULL, lakes = NULL, - roads = NULL, draw.key = NULL, draw.raster = TRUE, useRaster) -} - -\arguments{ -\item{r}{\code{RasterLayer}, \code{SpatialGridDataFrame}, or \code{CRS}; a raster layer with values to be plotted or a coordinate reference system (CRS).} -\item{layer}{\code{integer}; the column to use in the \code{SpatialGridDataFrame}.} -\item{att}{\code{numeric} or \code{character}; the variable identifying the levels attribute to use in the Raster Attribute Table (RAT). - This argument requires \code{r} values that are of class \code{factor}.} -\item{n}{\code{integer}; the desired number of intervals to partition the range of raster values (or \code{zlim} if specified) (optional).} -\item{breaks}{\code{numeric}; a vector of break points used to partition the colors representing numeric raster values (optional).} -\item{xlim}{\code{numeric}; a vector of length 2 giving the minimum and maximum values for the \emph{x}-axis.} -\item{ylim}{\code{numeric}; a vector of length 2 giving the minimum and maximum values for the \emph{y}-axis.} -\item{zlim}{\code{numeric}; a vector of length 2 giving the minimum and maximum raster values for which colors should be plotted.} -\item{asp}{\code{numeric}; the \emph{y/x} aspect ratio for spatial axes.} -\item{extend.xy}{\code{logical}; if \code{TRUE}, the spatial limits will be extended to the next tick mark on the axes beyond the grid extent.} -\item{extend.z}{\code{logical}; if \code{TRUE}, the raster value limits will be extended to the next tick mark on the color key beyond the measured range.} -\item{reg.axs}{\code{logical}; if \code{TRUE}, the spatial data range is extended.} -\item{trim.r}{\code{logical}; if \code{TRUE}, the outer rows and columns that consist of all \code{NA} values will be removed.} -\item{dms.tick}{\code{logical}; if \code{TRUE}, the axes tickmarks are specified in degrees, minutes, and decimal seconds.} -\item{bg.lines}{\code{logical}; if \code{TRUE}, the graticule is drawn in back of the raster layer using white lines and a grey background.} -\item{bg.image}{\code{RasterLayer}; an image to drawn in back of the main raster layer \code{r}.} -\item{bg.image.alpha}{\code{numeric}; the opacity of the background image from 0 to 1.} -\item{pal}{\code{function}; a color palette to be used to assign colors in the plot, \code{rainbow} by default.} -\item{col}{\code{character}; a vector of colors to be used in the plot. - This argument requires \code{breaks} specification for numeric values of \code{r} and overrides any palette function specification. - For numeric values there should be one less color than breaks. Factors require a color for each level.} -\item{max.dev.dim}{\code{numeric}; a vector of length 2 giving the maximum width and height for the graphics device in picas, respectively. - Suggested dimensions for single-column, double-column, and sidetitle figures are \code{c(21, 56)}, \code{c(43, 56)}, and \code{c(56, 43)}, respectively.} -\item{labels}{\code{list}; describes the location and values of labels in the color key. - This list may include components \code{at} and \code{labels}.} -\item{scale.loc}{\code{character}; the position of the scale bar: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote scale location.} -\item{arrow.loc}{\code{character}; the position of the north arrow: \code{"bottomleft"}, \code{"topleft"}, \code{"topright"}, or \code{"bottomright"} to denote arrow location.} -\item{explanation}{\code{character}; a label explaining the raster value.} -\item{credit}{\code{character}; a label crediting the base map.} -\item{shade}{\code{list}; if specified, a semi-transparent shade layer is drawn on top of the raster layer. - This layer is described using a list of arguments supplied to \code{hillShade}. - Passed arguments include \code{"angle"} and \code{"direction"}. - Additional arguments also may be passed that control the vertical aspect ratio (\code{"z.factor"}) and color opacity (\code{"alpha"}).} -\item{contour.lines}{\code{list}; if specified, contour lines are drawn. - The contours are described using a list of arguments supplied to \code{contour}. - Passed arguments include \code{"drawlables"}, \code{"method"}, and \code{"col"}.} -\item{rivers}{\code{list}; if specified, lines are drawn. - The lines are described using a list of arguments supplied to the plot method for \code{SpatialLines}. - Passed arguments include \code{"x"}, \code{"col"}, and \code{"lwd"}.} -\item{lakes}{\code{list}; if specified, polygons are drawn. - The polygons are described using a list of arguments supplied to the plot method for \code{SpatialPolygons}. - Passed arguments include \code{"x"}, \code{"col"}, \code{"border"}, and \code{"lwd"}. - Bitmap images require a regular grid.} -\item{roads}{\code{list}; if specified, lines are drawn. - The lines are described using a list of arguments supplied to the plot method for \code{SpatialLines}. - Passed arguments include \code{"x"}, \code{"col"}, and \code{"lwd"}.} -\item{draw.key}{\code{logical}; indicates if a color key should be drawn.} -\item{draw.raster}{\code{logical}; if \code{FALSE}, the raster image is not drawn.} -\item{useRaster}{\code{logical}; if \code{TRUE}, a bitmap raster is used to plot \code{r} instead of polygons. - If \code{UseRaster} is not specified, raster images are used when the \code{getOption("preferRaster")} is true.} -} - -\details{ -The dimensions of a new graphics device is dependent on the argument values of \code{max.dev.dim} and \code{asp}. -} - -\value{ -Used for the side-effect of a new plot generated. -Returns a \code{list} object with the following graphical parameters: -\item{din}{\code{numeric}; the device dimensions \code{(width, height)}, in inches.} -\item{usr}{\code{numeric}; the extremes of the coordinates of the plotting region \code{(x1, x2, y1, y2)}.} -\item{heights}{\code{numeric}; the relative heights on the device \code{(upper, lower)} for the map and color-key plots.} -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{\link{AddScaleBar}}, \code{\link{AddColorKey}}} - -\examples{ -r <- raster(system.file("external/test.grd", package="raster")) -PlotMap(r, scale.loc = "topleft", dms.tick = TRUE, trim.r = TRUE) - -graphics.off() -r <- raster(nrow = 10, ncol = 10) -r[] <- 1L -r[51:100] <- 2L -r[3:6, 1:5] <- 8L -r <- ratify(r) -rat <- levels(r)[[1]] -rat$land.cover <- c("Pine", "Oak", "Meadow") -rat$code <- c(12, 25, 30) -levels(r) <- rat -PlotMap(r, att = "land.cover", col = c("grey", "orange", "purple")) -PlotMap(r, att = "code") - -graphics.off() -r <- alluvium.thickness -PlotMap(r@crs, bg.image = hill.shading, reg.axs = FALSE) -plot(alluvium.extent, border = "red", add = TRUE) -PlotMap(r, bg.image = hill.shading, bg.image.alpha = 0.6) -PlotMap(r, n = 10, extend.xy = TRUE) - -graphics.off() -PlotMap(r, ylim = c(NA, 1360000), max.dev.dim = c(56, 43), n = 10, extend.z = TRUE, - contour.lines = list(col = "#A9A9A9")) -plot(alluvium.extent, add = TRUE) -shade <- list(z.factor = 15, alpha = 0.4) -txt <- "Land surface elevation in meters above National Geodetic Vertical Datum of 1929." -ans <- PlotMap(r, ylim = c(NA, 1360000), max.dev.dim = c(56, 43), bg.lines = TRUE, - shade = shade, arrow.loc = "topright", explanation = txt) - -graphics.off() -} - -\keyword{hplot} diff --git a/man/ReadModflowBinary.Rd b/man/ReadModflowBinary.Rd deleted file mode 100644 index 64561db..0000000 --- a/man/ReadModflowBinary.Rd +++ /dev/null @@ -1,48 +0,0 @@ -\name{ReadModflowBinary} - -\alias{ReadModflowBinary} - -\title{Read MODFLOW Binary File} - -\description{ -This function reads binary output data from a \href{http://water.usgs.gov/ogw/modflow/}{MODFLOW} run. -} - -\usage{ -ReadModflowBinary(f, data.type = c("array", "flow"), rm.totim.0 = FALSE) -} - -\arguments{ -\item{f}{\code{character}; the name of the binary file.} -\item{data.type}{\code{character}; a description of how the data are saved.} -\item{rm.totim.0}{\code{logical}; if \code{TRUE}, stress-periods at time zero are removed.} -} - -\details{ -This function reads binary head (\file{.hds}), drawdown (\file{.ddn}), and budget (\file{.bud}) files generated from a MODFLOW run. -} - -\value{ -Returns a \code{list} object of length equal to the number of times the data type is written to the binary file. -List components are \code{list} objects with the following components: -\item{d}{\code{matrix} or \code{data.frame}; the data values.} -\item{kstp}{\code{integer}; the time step.} -\item{kper}{\code{integer}; the stress period.} -\item{desc}{\code{character}; the variable name.} -\item{ilay}{\code{integer}; the model-grid layer.} -\item{delt}{\code{numeric}; the length of the current time step.} -\item{pertim}{\code{numeric}; the time in the stress period.} -\item{totim}{\code{numeric}; the total elapsed time.} -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{\link{SummariseBudget}}} - -\examples{\dontrun{ -path <- file.path(getwd(), "SIR2016-5080/output/output.model1") -hds <- ReadModflowBinary(file.path(path, "wrv_mfusg.hds"), "array") -bud <- ReadModflowBinary(file.path(path, "wrv_mfusg.bud"), "flow")} -} - -\keyword{IO} diff --git a/man/ReplaceInTemplate.Rd b/man/ReplaceInTemplate.Rd deleted file mode 100644 index e839aa4..0000000 --- a/man/ReplaceInTemplate.Rd +++ /dev/null @@ -1,40 +0,0 @@ -\name{ReplaceInTemplate} - -\alias{ReplaceInTemplate} - -\title{Replace Values in a Template Text} - -\description{ -This function replaces keys within special markups in a template text with specified values. -Pieces of \R code can be put into the markups of the template text, and are evaluated during the replacement. -} - -\usage{ReplaceInTemplate(text, replacement)} - -\arguments{ -\item{text}{\code{character}; a vector of character strings, the template text.} -\item{replacement}{\code{list}; the values to replace in \code{text}.} -} - -\details{ -Keys are enclosed into markups of the form \code{$(KEY)} and \code{@\{CODE\}}. -} - -\value{ -A vector of character strings after key replacement. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\references{ -This code was derived from the \href{http://cran.r-project.org/web/packages/sensitivity/}{sensitivity}\code{::template.replace} function. -} - -\examples{ -text <- c("Hello $(name)!", "$(a) + $(b) = @{$(a) + $(b)}", - "pi = @{format(pi, digits = 5)}") -replacement <- list(name = "world", a = 1, b = 2) -cat(ReplaceInTemplate(text, replacement), sep = "\n") -} - -\keyword{IO} diff --git a/man/RmSmallCellChunks.Rd b/man/RmSmallCellChunks.Rd deleted file mode 100644 index a3423dd..0000000 --- a/man/RmSmallCellChunks.Rd +++ /dev/null @@ -1,38 +0,0 @@ -\name{RmSmallCellChunks} - -\alias{RmSmallCellChunks} - -\title{Remove Small Cell Chunks} - -\description{ -This function identifies cell chunks in a single raster grid layer, -where a cell chunk is defined as a group of connected cells with non-missing values. -The cell chunk with the largest surface area is preserved and all others removed. -} - -\usage{RmSmallCellChunks(r)} - -\arguments{ -\item{r}{\code{RasterLayer}; a raster grid layer with cell values.} -} - -\value{ -The raster grid layer \code{r} with cell values in the smaller cell chunks set to \code{NA}. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{clump}} - -\examples{ -set.seed(0) -r <- raster(ncols = 10, nrows = 10) -r[] <- round(runif(ncell(r)) * 0.7) -r <- clump(r) -plot(r) - -r.new <- RmSmallCellChunks(r) -plot(r.new, zlim = range(r[], na.rm = TRUE)) -} - -\keyword{utilities} diff --git a/man/RunWaterBalance.Rd b/man/RunWaterBalance.Rd index d9b0920..8eeae83 100644 --- a/man/RunWaterBalance.Rd +++ b/man/RunWaterBalance.Rd @@ -1,99 +1,194 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RunWaterBalance.R \name{RunWaterBalance} - \alias{RunWaterBalance} - \title{Run Water Balance} +\usage{ +RunWaterBalance(r.grid, tr.stress.periods, ss.stress.periods = NULL, + canal.seep = wrv::canal.seep, comb.sw.irr = wrv::comb.sw.irr, + div.gw = wrv::div.gw, div.sw = wrv::div.sw, div.ww = wrv::div.ww, + efficiency = wrv::efficiency, entity.components = wrv::entity.components, + et = wrv::et, irr.entities = wrv::irr.entities, + land.surface = wrv::land.surface, pod.gw = wrv::pod.gw, + priority.cuts = wrv::priority.cuts, r.canals = wrv::r.canals, + rs.entities = wrv::rs.entities, rs.rech.non.irr = wrv::rs.rech.non.irr, + verbose = FALSE) +} +\arguments{ +\item{r.grid}{RasterLayer. +Gridded numeric values where NA indicates an \sQuote{inactive} cell in +the top model layer.} + +\item{tr.stress.periods}{Date. +Vector of start and end dates for each stress period in the simulation.} + +\item{ss.stress.periods}{Date. +Vector of start and end dates for stress periods used to create steady-state conditions.} + +\item{canal.seep}{data.frame. +See \code{\link{canal.seep}} dataset for details.} + +\item{comb.sw.irr}{data.frame. +See \code{\link{comb.sw.irr}} dataset for details.} + +\item{div.gw}{data.frame. +See \code{\link{div.gw}} dataset for details.} + +\item{div.sw}{data.frame. +See \code{\link{div.sw}} dataset for details.} + +\item{div.ww}{data.frame. +See \code{\link{div.gw}} dataset for details.} + +\item{efficiency}{data.frame. +See \code{\link{efficiency}} dataset for details.} + +\item{entity.components}{list. +See \code{\link{entity.components}} dataset for details.} + +\item{et}{RasterStack. +See \code{\link{et}} dataset for details.} + +\item{irr.entities}{SpatialPolygonsDataFrame. +See \code{\link{irr.entities}} dataset for details.} + +\item{land.surface}{RasterLayer. +See \code{\link{land.surface}} dataset for details.} + +\item{pod.gw}{data.frame. +See \code{\link{pod.gw}} dataset for details.} + +\item{priority.cuts}{data.frame. +See \code{\link{priority.cuts}} dataset for details.} +\item{r.canals}{RasterLayer. +See \code{\link{r.canals}} dataset for details.} + +\item{rs.entities}{RasterStack. +See \code{\link{rs.entities}} dataset for details.} + +\item{rs.rech.non.irr}{RasterStack. +See \code{\link{rs.rech.non.irr}} dataset for details.} + +\item{verbose}{logical. +Indicates whether to return summary tables: + \code{natural.rech}, \code{inciden.rech}, and \code{pumping.rech}.} +} +\value{ +Returns an object of class list with the following components: + + (1) Water-table flow data (combines natural and incidental groundwater recharge) + are stored in \code{areal.rech}, + an object of RasterStack class with raster layers for each model stress period; + cell values are specified as volumetric flow rates in cubic meters per day. + + (2) Production well pumping data are stored in \code{pod.rech}, + an object of \code{data.frame} class with the following components: + \describe{ + \item{WMISNumber}{unique number assigned to a water right point of diversion.} + \item{ss,199501,\dots,201012}{volumetric flow rate, specified for each stress period, + in cubic meters per day.} + } + + (3) Natural groundwater recharge data are stored in \code{natural.rech}, + an object of data.frame class with the following components: + \describe{ + \item{YearMonth}{calendar year and month YYYYMM.} + \item{Area}{land-surface area of non-irrigated lands, in square meters.} + \item{ET}{evapotranspiration on non-irrigated lands, in cubic meters per month.} + \item{Rech}{volumetric flow rate, in cubic meters per month.} + } + + (4) Incidental groundwater recharge data are stored in \code{inciden.rech}, + an object of data.frame class with the following components: + \describe{ + \item{EntityName}{name of the irrigation entity.} + \item{YearMonth}{calendar year and month YYYYMM.} + \item{SWDiv}{surface-water diversions, in cubic meters per month.} + \item{SeepFrac}{canal seepage as a fraction of diversions, a dimensionless quantity.} + \item{CanalSeep}{canal seepage, in cubic meters per month.} + \item{SWDel}{surface-water delivered to field headgates, in cubic meters per month.} + \item{area.sw}{area irrigated by only surface water, in square meters.} + \item{et.sw}{evapotranspiration on lands irrigated by only surface water, + in cubic meters per month.} + \item{precip.sw}{precipitation on lands irrigated by only surface water, + in cubic meters per month.} + \item{cir.sw}{crop irrigation requirement on lands irrigated by only surface water, + in cubic meters per month.} + \item{area.mix}{area irrigated by both surface and groundwater, in square meters.} + \item{et.mix}{evapotranspiration on lands irrigated by both surface and groundwater, + in cubic meters per month.} + \item{precip.mix}{precipitation on lands irrigated by both surface and groundwater, + in cubic meters per month.} + \item{cir.mix}{crop irrigation requirement on lands irrigated by both surface and groundwater, + in cubic meters per month.} + \item{area.gw}{area irrigated by only groundwater, in square meters.} + \item{et.gw}{evapotranspiration on lands irrigated by only groundwater, + in cubic meters per month.} + \item{precip.gw}{precipitation on lands irrigated by only groundwater, + in cubic meters per month.} + \item{cir.gw}{crop irrigation requirement on lands irrigated by only groundwater, + in cubic meters per month.} + \item{Eff}{irrigation efficiency, a dimensionless quantity.} + \item{GWDiv}{recorded groundwater diversions, in cubic meters per month.} + \item{WWDiv}{inflow to municipal wastewater treatment plants, in cubic meters per month.} + \item{hg.sw}{surface-water delivered to field headgates on lands irrigated by only surface water, + in cubic meters per month.} + \item{hg.mix}{surface-water delivered to field headgates on lands irrigation by both surface and groundwater, + in cubic meters per month.} + \item{rech.sw}{incidental groundwater recharge beneath lands irrigated by only surface water, + in cubic meters per month.} + \item{gw.dem.mix}{groundwater demand on lands irrigated by both surface and groundwater, + in cubic meters per month.} + \item{gw.div.est}{calculated groundwater diversions, in cubic meters per month.} + \item{rech.mix}{incidental groundwater recharge beneath lands irrigated by both surface and groundwater, + in cubic meters per month.} + \item{gw.only}{groundwater demand on lands irrigated by only groundwater in entities with + lands also irrigated by both surface and groundwater, in cubic meters per month.} + \item{rech.muni}{incidental groundwater recharge beneath entities with + lands irrigated by only groundwater and lands irrigated by both surface and groundwater, + in cubic meters per month.} + \item{gw.dem.gw}{groundwater demand on lands irrigated by only groundwater in + entities without surface-water irrigation, in cubic meters per month.} + \item{rech.gw}{incidental groundwater recharge beneath lands irrigated by only groundwater, + in cubic meters per month.} + \item{area.model}{area of the irrigation entity that is located in the model domain, + in square meters.} + } + Volumetric flow rates are calculated for their respective area in + the irrigation entity---not just that part overlying the model area. + Flow rate values are given this way in order to facilitate with quality assurance of + the water-budget calculation. + To calculate a simulated volumetric-flow rate: divide the flow rate by the affected area, + and then multiply this value by the area of the irrigation entity that is located in + the model domain (\code{area.model}). + + (5) Well pumping data are also stored in \code{pumping.rech} (see \code{pod.rech} component), + an object of data.frame class with the following components: + \describe{ + \item{WMISNumber}{unique number assigned to a water right point of diversion.} + \item{YearMonth}{calendar year and month YYYYMM.} + \item{Pumping}{volumetric rate of pumping, in cubic meters per month.} + } +} \description{ -This function estimates areal recharge, and pumping demand at production wells. +This function estimates natural and incidental groundwater recharge at the water table, +and pumping demand at production wells. A water-balance approach is used to calculate these volumetric flow rate estimates, where positive values are flow into the aqufer system (groundwater recharge), and negative values are flow out of the system (groundwater discharge). } +\examples{ +\dontrun{# see Appendix A. Package Introduction} -\usage{ -RunWaterBalance(tr.stress.periods, r.grid, eff, seep, ss.stress.periods = NULL, - verbose = FALSE) -} - -\arguments{ -\item{tr.stress.periods}{\code{Date}; a vector of start and end dates for each stress period in the simulation.} -\item{r.grid}{\code{RasterLayer}; a raster of numeric values where \code{NA} indicates an \sQuote{inactive} cell in the top layer of the model.} -\item{eff}{\code{data.frame}; see \code{\link{efficiency}} dataset for details.} -\item{seep}{\code{data.frame}; see \code{\link{canal.seep}} dataset for details.} -\item{ss.stress.periods}{\code{Date}; a vector of start and end dates for stress periods used to create steady-state conditions.} -\item{verbose}{\code{logical}; indicates whether to return summary tables \code{natural.rech}, \code{inciden.rech}, \code{pumping.rech}; - see \sQuote{Value} section for table formats.} } - -\value{ -Returns a \code{list} object with the following components: - -(1) Water-table flow data (combines natural and incidental groundwater recharge and discharge) are stored in \code{areal.rech}, -an object of \code{RasterStack} class with raster layers for each model stress period; -cell values are specified as volumetric flow rates in cubic meters per day. - -(2) Production well pumping data are stored in \code{pod.rech}, an object of \code{data.frame} class with the following components: -\item{WMISNumber}{\code{numeric}; a unique number assigned to a water right point of diversion.} -\item{ss, 199501, \dots, 201012}{\code{numeric}; is the volumetric flow rate, specified for each stress period, in cubic meters per day.} - -(3) Natural groundwater recharge and discharge data are stored in \code{natural.rech}, an object of \code{data.frame} class with the following components: -\item{YearMonth}{\code{factor}; is the calendar year and month \code{YYYYMM}.} -\item{Area}{\code{numeric}; the land-surface area of non-irrigated lands, in square meters.} -\item{ET}{\code{numeric}; evapotranspiration on non-irrigated lands, in cubic meters per month.} -\item{Rech}{\code{numeric}; is the volumetric flow rate, in cubic meters per month.} - -(4) Incidental groundwater recharge data are stored in \code{inciden.rech}, an object of \code{data.frame} class with the following components: -\item{EntityName}{\code{character}; is the name of the irrigation entity.} -\item{YearMonth}{\code{factor}; is the calendar year and month \code{YYYYMM}.} -\item{SWDiv}{\code{numeric}; surface-water diversions, in cubic meters per month.} -\item{SeepFrac}{\code{numeric}; canal seepage as a fraction of diversions, a dimensionless quantity.} -\item{CanalSeep}{\code{numeric}; canal seepage, in cubic meters per month.} -\item{SWDel}{\code{numeric}; surface-water delivered to field headgates, in cubic meters per month.} -\item{area.sw}{\code{numeric}; area irrigated by only surface water, in square meters.} -\item{et.sw}{\code{numeric}; evapotranspiration on lands irrigated by only surface water, in cubic meters per month.} -\item{precip.sw}{\code{numeric}; precipitation on lands irrigated by only surface water, in cubic meters per month.} -\item{cir.sw}{\code{numeric}; crop irrigation requirement on lands irrigated by only surface water, in cubic meters per month.} -\item{area.mix}{\code{numeric}; area irrigated by both surface and groundwater, in square meters.} -\item{et.mix}{\code{numeric}; evapotranspiration on lands irrigated by both surface and groundwater, in cubic meters per month.} -\item{precip.mix}{\code{numeric}; precipitation on lands irrigated by both surface and groundwater, in cubic meters per month.} -\item{cir.mix}{\code{numeric}; crop irrigation requirement on lands irrigated by both surface and groundwater, in cubic meters per month.} -\item{area.gw}{\code{numeric}; area irrigated by only groundwater, in square meters.} -\item{et.gw}{\code{numeric}; evapotranspiration on lands irrigated by only groundwater, in cubic meters per month.} -\item{precip.gw}{\code{numeric}; precipitation on lands irrigated by only groundwater, in cubic meters per month.} -\item{cir.gw}{\code{numeric}; crop irrigation requirement on lands irrigated by only groundwater, in cubic meters per month.} -\item{Eff}{\code{numeric}; irrigation efficiency, a dimensionless quantity.} -\item{GWDiv}{\code{numeric}; recorded groundwater diversions, in cubic meters per month.} -\item{WWDiv}{\code{numeric}; inflow to municipal wastewater treatment plants, in cubic meters per month.} -\item{hg.sw}{\code{numeric}; surface-water delivered to field headgates on lands irrigated by only surface water, in cubic meters per month.} -\item{hg.mix}{\code{numeric}; surface-water delivered to field headgates on lands irrigation by both surface and groundwater, in cubic meters per month.} -\item{rech.sw}{\code{numeric}; incidental groundwater recharge beneath lands irrigated by only surface water, in cubic meters per month.} -\item{gw.dem.mix}{\code{numeric}; groundwater demand on lands irrigated by both surface and groundwater, in cubic meters per month.} -\item{gw.div.est}{\code{numeric}; calculated groundwater diversions, in cubic meters per month.} -\item{rech.mix}{\code{numeric}; incidental groundwater recharge beneath lands irrigated by both surface and groundwater, in cubic meters per month.} -\item{gw.only}{\code{numeric}; groundwater demand on lands irrigated by only groundwater in entities with lands also irrigated by both surface and groundwater, in cubic meters per month.} -\item{rech.muni}{\code{numeric}; incidental groundwater recharge beneath entities with lands irrigated by only groundwater and lands irrigated by both surface and groundwater, in cubic meters per month.} -\item{gw.dem.gw}{\code{numeric}; groundwater demand on lands irrigated by only groundwater in entities without surface-water irrigation, in cubic meters per month.} -\item{rech.gw}{\code{numeric}; incidental groundwater recharge beneath lands irrigated by only groundwater, in cubic meters per month.} -\item{area.model}{\code{numeric}; area of the irrigation entity that is located in the model domain, in square meters.} -Volumetric flow rates are calculated for their respective area in the irrigation entity---not just that part overlying the model area. -Flow rate values are given this way in order to facilitate with quality assurance of the water-budget calculation. -To calculate a simulated volumetric-flow rate: divide the flow rate by the affected area, and then multiply this value by the area of the irrigation entity that is located in the model domain (\code{area.model}). - -(5) Well pumping data are also stored in \code{pumping.rech} (see \code{pod.rech} component), an object of \code{data.frame} class with the following components: -\item{WMISNumber}{\code{numeric}; a unique number assigned to a water right point of diversion.} -\item{YearMonth}{\code{factor}; is the calendar year and month \code{YYYYMM}.} -\item{Pumping}{\code{numeric}; is the volumetric rate of pumping, in cubic meters per month.} -} - \author{ J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -J. Sukow and M. McVay, Idaho Department of Water Resources + J. Sukow and M. McVay, Idaho Department of Water Resources +} +\seealso{ +\code{\link{UpdateWaterBudget}} } - -\seealso{\code{\link{UpdateWaterBudget}}} - -\examples{\dontrun{# see wrv-introduction vignette}} - \keyword{manip} + diff --git a/man/SetPolygons.Rd b/man/SetPolygons.Rd deleted file mode 100644 index 7c2a4f3..0000000 --- a/man/SetPolygons.Rd +++ /dev/null @@ -1,57 +0,0 @@ -\name{SetPolygons} - -\alias{SetPolygons} - -\title{Analysis of Multi-Polygon Objects} - -\description{ -Determines the intersection or difference between two multi-polygon objects. -} - -\usage{ -SetPolygons(x, y, cmd = c("gIntersection", "gDifference"), buffer.width = NA) -} - -\arguments{ -\item{x}{\code{SpatialPolygons*}; a multi-polygon object.} -\item{y}{\code{SpatialPolygons*} or \code{Extent}; a multi-polygon object.} -\item{cmd}{\code{character}; specifying \code{"gIntersection"}, the default, cuts out portions of the \code{x} polygons that overlay the \code{y} polygons. - If \code{"gDifference"} is specified, only those portions of the \code{x} polygons falling outside the \code{y} polygons are copied to the output polygons.} -\item{buffer.width}{\code{numeric}; expands or contracts the geometry of \code{y} to include the area within the specified width, see \code{gBuffer}. - Specifying \code{NA}, the default, indicates no buffer.} -} - -\details{ -This function tests if the resulting geometry is valid, see \code{gIsValid}. -} - -\value{ -Returns an object of \code{SpatialPolygons*} class. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{gIntersection}, \code{gDifference}} - -\examples{ -library(sp) - -m1a <- matrix(c(17.5, 24.7, 22.6, 16.5, 55.1, 55.0, 61.1, 59.7), nrow = 4, ncol = 2) -m1b <- m1a -m1b[, 1] <- m1b[, 1] + 11 -p1 <- SpatialPolygons(list(Polygons(list(Polygon(m1a, FALSE), Polygon(m1b, FALSE)), 1))) -plot(p1, col = "blue") - -m2a <- matrix(c(19.6, 35.7, 28.2, 60.0, 58.8, 64.4), nrow = 3, ncol = 2) -m2b <- matrix(c(20.6, 30.9, 27.3, 56.2, 53.8, 51.4), nrow = 3, ncol = 2) -p2 <- SpatialPolygons(list(Polygons(list(Polygon(m2a, FALSE), Polygon(m2b, FALSE)), 2))) -plot(p2, col = "red", add = TRUE) - -p <- SetPolygons(p1, p2, "gIntersection") -plot(p, col = "green", add = TRUE) - -p <- SetPolygons(p2, p1, "gDifference") -plot(p, col = "purple", add = TRUE) -} - -\keyword{utilities} diff --git a/man/SummariseBudget.Rd b/man/SummariseBudget.Rd deleted file mode 100644 index 97b9796..0000000 --- a/man/SummariseBudget.Rd +++ /dev/null @@ -1,54 +0,0 @@ -\name{SummariseBudget} - -\alias{SummariseBudget} - -\title{Summarize Volumetric Water Budget} - -\description{ -Summarizes volumetric flow rates for boundary condition types. -Splits the budget data into subsets, computes summary statistics for each, and returns the result in a summary table. -} - -\usage{ -SummariseBudget(budget, desc = c("wells", "drains", "river leakage")) -} - -\arguments{ -\item{budget}{\code{character} or \code{list}; either a description of the path to the MODFLOW Budget File or the returned results from a call to the \code{\link{ReadModflowBinary}} function.} -\item{desc}{\code{character}; a vector of MODFLOW package identifiers. - Data of this package type is included in the summary table.} -} - -\details{ -The \code{budget[[i]]$d} data table component must contain a numeric \code{id} field, see \code{\link{WriteModflowInput}} for variable description. -Subsets are grouped by the MODFLOW package identifier (\code{desc}), stress period (\code{kper}), time step (\code{kstp}), and location identifier (\code{id}). -} - -\value{ -Returns an object of \code{data.frame} class with the following components: -\item{desc}{\code{factor}; is the MODFLOW package identifier.} -\item{kper}{\code{integer}; is the stress period.} -\item{kstp}{\code{integer}; is the time step.} -\item{id}{\code{integer}; is a location identifier.} -\item{delt}{\code{numeric}; is the length of the current time step.} -\item{pertim}{\code{numeric}; is the time in the stress period.} -\item{totim}{\code{numeric}; is the total elapsed time.} -\item{count}{\code{integer}; is the number of cells in each subset.} -\item{flow.sum}{\code{numeric}; is the total volumetric flow rate.} -\item{flow.mean}{\code{numeric}; is the mean volumetric flow rate.} -\item{flow.median}{\code{numeric}; is the median volumetric flow rate.} -\item{flow.sd}{\code{numeric}; is the standard deviation of the volumetric flow rate.} -\item{flow.dir}{\code{factor}; is the flow direction where \code{"in"} and \code{"out"} indicate water entering and leaving the groundwater system, respectively.} -} - -\author{ -J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center -} - -\examples{\dontrun{ -f <- file.path(getwd(), "SIR2016-5080/output/output.model1/wrv_mfusg.bud") -d <- SummariseBudget(f) -str(d)} -} - -\keyword{utilities} diff --git a/man/ToScientific.Rd b/man/ToScientific.Rd deleted file mode 100644 index b51c19c..0000000 --- a/man/ToScientific.Rd +++ /dev/null @@ -1,38 +0,0 @@ -\name{ToScientific} - -\alias{ToScientific} - -\title{Format for Scientific Notation} - -\description{ -This function formats numbers in scientific notation \eqn{m \times 10^{n}}. -} - -\usage{ -ToScientific(x, digits = format.info(as.numeric(x))[2], - lab.type = c("latex", "plotmath")) -} - -\arguments{ -\item{x}{\code{numeric}; a vector of numbers.} -\item{digits}{\code{integer}; the number of digits after the decimal point for the mantissa.} -\item{lab.type}{\code{character}; by default, LaTeX formatted strings for labels are returned. - Alternatively, \code{lab.type = "plotmath"} returns \code{plotmath}-compatible expressions.} -} - -\value{ -For the default \code{lab.type = "latex"}, a \code{character} vector of the same length as argument \code{x}. -And for \code{lab.type = "plotmath"}, an \code{expression} of the same length as \code{x}, typically with elements of the form \code{m x 10^n}. -In order to comply with \href{http://www.section508.gov/}{Section 508}, -an \dQuote{\code{x}} is used as the label separator for the \code{plotmath} type---rather than the more common \dQuote{\code{\%*\%}} seperator. -} - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\examples{ -x <- c(-1e+09, 0, NA, pi * 10^(-5:5)) -ToScientific(x, digits = 2) -ToScientific(x, digits = 2, lab.type = "plotmath") -} - -\keyword{utilities} diff --git a/man/UpdateWaterBudget.Rd b/man/UpdateWaterBudget.Rd index ad04a27..b2ac955 100644 --- a/man/UpdateWaterBudget.Rd +++ b/man/UpdateWaterBudget.Rd @@ -1,111 +1,171 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/UpdateWaterBudget.R \name{UpdateWaterBudget} - \alias{UpdateWaterBudget} - \title{Update Water Budget} - -\description{ -This function runs the water budget calculation and updates the MODFLOW Well Package file. -It is executed during each iteration of PEST and my be run in an interactive \R session to initialize the parameter estimation files. -} - \usage{ UpdateWaterBudget(dir.run, id, qa.tables = c("none", "si", "english"), - ss.interval = NULL, iwelcb = 0L) + ss.interval = NULL, iwelcb = ifelse(interactive(), 50L, 0L), + canal.seep = wrv::canal.seep, efficiency = wrv::efficiency, + gage.disch = wrv::gage.disch, pod.wells = wrv::pod.wells, + tributaries = wrv::tributaries, ...) } - \arguments{ -\item{dir.run}{\code{character}; the path name of the directory to read/write model files.} -\item{id}{\code{character}; a short identifier (file name) for model files.} -\item{qa.tables}{\code{character}; indicates if quality assurance tables are written to disk; by default \code{"none"} of these tables are written. - Values of \code{"si"} and \code{"english"} indicate that table values are written in metric and English units, respectively.} -\item{ss.interval}{\code{Date} or \code{character}; a vector of length 2 specifying the start and end dates for the period used to represent steady-state boundary conditions. - That is, recharge values for stress periods coinciding with this time period are averaged and used as steady-state boundary conditions. - The required date format is \code{YYYY-MM-DD}. - This argument overrides the \code{ss.stress.periods} object in the \file{model.rda} file, see \sQuote{Details} section for additional information.} -\item{iwelcb}{\code{integer}; is a flag and unit number. - If equal to zero, the default, cell-by-cell flow terms resulting from conditions in the MODFLOW Well Package will not be written to disk. - This default value is appropriate for model calibration, where MODFLOW run times are kept as short as possible. - If greater than zero, the cell-by-cell flow terms are written to disk. - See the MODFLOW Name File (\file{*.nam}) for the unit number associated with the budget file (\file{*.bud}). - } +\item{dir.run}{character. +Path name of the directory to read/write model files.} + +\item{id}{character. +Short identifier (file name) for model files.} + +\item{qa.tables}{character. +Indicates if quality assurance tables are written to disk; +by default "none" of these tables are written. +Values of "si" and "english" indicate that table values are written in +metric and English units, respectively.} + +\item{ss.interval}{Date or character. +Vector of length 2 specifying the start and end dates for the period used to +represent steady-state boundary conditions. +That is, recharge values for stress periods coinciding with this time period are +averaged and used as steady-state boundary conditions. +The required date format is YYYY-MM-DD. +This argument overrides the \code{ss.stress.periods} object in the \file{model.rda} file, +see \sQuote{Details} section for additional information.} + +\item{iwelcb}{integer. +A flag and unit number. +If equal to zero, the default, cell-by-cell flow terms resulting from +conditions in the MODFLOW Well Package will not be written to disk. +A value of 0 is appropriate for model calibration, +where MODFLOW run times are kept as short as possible. +If greater than zero, the cell-by-cell flow terms are written to disk. +See the MODFLOW Name File (\file{*.nam}) for the unit number associated with +the budget file (\file{*.bud}). +The default value is 50 (value specified in the \code{\link{WriteModflowInput}} function) +if \R is being used interactively and 0 otherwise.} + +\item{canal.seep}{data.frame. +See \code{\link{canal.seep}} dataset for details.} + +\item{efficiency}{data.frame. +See \code{\link{efficiency}} dataset for details.} + +\item{gage.disch}{data.frame. +See \code{\link{gage.disch}} dataset for details.} + +\item{pod.wells}{SpatialPointsDataFrame. +See \code{\link{pod.wells}} dataset for details.} + +\item{tributaries}{SpatialPolygonsDataFrame. +See \code{\link{tributaries}} dataset for details.} + +\item{...}{Arguments to be passed to \code{\link{RunWaterBalance}}, such as evapotranspiration \code{et}.} +} +\value{ +Returns an object of difftime class, the runtime for this function. + Used for the side-effect of files written to disk. + + A MODFLOW Well Package file \file{.wel} is always written to disk; whereas, + parameter estimation files \file{seep.csv}, \file{eff.csv}, and \file{trib.csv}, and + a script file \file{UpdateBudget.bat}, are only written if they do not already exist. + The script file may be used to automate the execution of this function from a + file manager (such as, Windows Explorer). + + The \file{seep.csv} file stores as tabular data the canal seepage fraction for + each of the irrigation entities. + Its character and numeric data fields are delimited by commas (a comma-separated-value [CSV] file). + The first line is reserved for field names \dQuote{EntityName} and \dQuote{SeepFrac}. + + The \file{eff.csv} file stores as tabular data the irrigation efficiency for + each of the irrigation entities. + Its character and numeric data fields are delimited by commas. + The first line is reserved for field names \dQuote{EntityName} and \dQuote{Eff}. + + The \file{trib.csv} file stores as tabular data the underflow boundary conditions for + each tributary basin. + Its character and numeric data fields are delimited by commas. + The first line is reserved for field names \dQuote{Name} and \dQuote{Value}. + Data records include a long-term mean flow multiplier for + each of the tributary basins (name is the unique identifier for the tributary), + a record for the amplitude reduction (\code{reduction}), and + a record for the number of days in the moving average (\code{d.in.mv.ave}). + + If the \code{qa.tables} argument is specified as either \dQuote{si} or \dQuote{english}, + quality assurance tables are written to disk as CSV files (\file{qa-*.csv}). + Volumetric flow rate data within these tables is described in the + \sQuote{Value} section of the \code{\link{RunWaterBalance}} function; + see returned list components \code{natural.rech}, \code{inciden.rech}, and \code{pumping.rech}. + The well configuration data are described in the \sQuote{Value} section of the + \code{\link{GetWellConfig}} function. +} +\description{ +This function determines the specified-flow boundary conditions for the groundwater-flow model. +These boundary conditions include: + (1) natural and incidental groundwater recharge at the water table, + (2) groundwater pumping at production wells, and + (3) groundwater underflow in the major tributary valleys. +Specified-flow values are saved to disk by rewriting the +\href{http://water.usgs.gov/ogw/modflow/}{MODFLOW} Well Package file (\file{.wel}). +Note that this function is executed after each iteration of \href{http://www.pesthomepage.org/}{PEST}. } - \details{ -Files read during execution, and located within the \code{dir.run} directory, include -the MODFLOW hydraulic conductivity reference files \file{hk1.ref}, \file{hk2.ref}, and \file{hk3.ref} -corresponding to model layers 1, 2, and 3, respectively. -Hydraulic conductivity values are read from a two-dimensional array in matrix format with \sQuote{white-space} delimited fields. -And a binary data file \file{model.rda} containing the following serialized \R objects: -\code{rs}, \code{misc}, \code{trib}, \code{tr.stress.periods}, and \code{ss.stress.periods}. - -\code{rs} is an object of \code{RasterStack} class with raster layers -\dQuote{lay1.top}, \dQuote{lay1.bot}, \dQuote{lay2.bot}, and \dQuote{lay3.bot}. -These raster layers describe the geometry of the model grid; that is, -the upper and lower elevation of model layer 1, and the bottom elevations of model layers 2 and 3. -Missing cell values (equal to \code{NA}) indicate inactive model cells lying outside of the model domain. - -\code{misc} is a \code{data.frame} object with miscellaneous seepage, -such as from the \sQuote{Bellevue Waste Water Treatment Plant ponds} and the \sQuote{Bypass Canal}. -This object is comprised of the following components: -\bold{lay}, \bold{row}, \bold{col} are \code{integer} values specifying a model cell's layer, row, and column index, respectively; and -\bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of elevation during each stress period, respectively, -in meters above the North American Vertical Datum of 1988. - -\code{trib} is a \code{data.frame} object with default values for the long-term mean underflows in each of the tributary basins. -The object is comprised of the following components: -\bold{Name} is a unique identifier for the tributary basin; -\bold{lay}, \bold{row}, \bold{col} are \code{integer} values of a model cell's layer, row, and column index, respectively; and -\bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of underflow during each stress period, respectively, -in cubic meters per day. - -\code{tr.stress.periods} is a vector of \code{Date} values giving the start and end dates for stress periods in the model simulation period (1995--2010). - -\code{ss.stress.periods} is a vector of \code{Date} values giving the start and end dates for stress periods used to define steady-state conditions. - -\code{reduction} is a \code{numeric} default value for the signal amplitude reduction algorithm, a dimensionless quantity. - -\code{d.in.mv.ave} is a \code{numeric} default value for the number of days in the moving average subset. +Files read during execution, and located within the \code{dir.run} directory, + inlcude the MODFLOW hydraulic conductivity reference files \file{hk1.ref}, + \file{hk2.ref}, and \file{hk3.ref} corresponding to model layers 1, 2, and 3, respectively. + Hydraulic conductivity values are read from a two-dimensional array in + matrix format with \sQuote{white-space} delimited fields. + And a binary data file \file{model.rda} containing the following serialized \R objects: + \code{rs}, \code{misc}, \code{trib}, \code{tr.stress.periods}, and \code{ss.stress.periods}. + + \code{rs} is an object of RasterStack class with raster layers \dQuote{lay1.top}, + \dQuote{lay1.bot}, \dQuote{lay2.bot}, and \dQuote{lay3.bot}. + These raster layers describe the geometry of the model grid; that is, + the upper and lower elevation of model layer 1, and the bottom elevations of model layers 2 and 3. + Missing cell values (equal to NA) indicate inactive model cells lying outside of the model domain. + + \code{misc} is a data.frame object with miscellaneous seepage, + such as from the \sQuote{Bellevue Waste Water Treatment Plant ponds} and the \sQuote{Bypass Canal}. + This object is comprised of the following components: + \bold{lay}, \bold{row}, \bold{col} are integer values specifying a + model cell's layer, row, and column index, respectively; and + \bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of + elevation during each stress period, respectively, + in meters above the North American Vertical Datum of 1988. + + \code{trib} is a data.frame object with default values for the + long-term mean underflows in each of the tributary basins. + The object is comprised of the following components: + \bold{Name} is a unique identifier for the tributary basin; + \bold{lay}, \bold{row}, \bold{col} are \code{integer} values of a + model cell's layer, row, and column index, respectively; and + \bold{ss}, \bold{199501}, \bold{199502}, \dots, \bold{201012} are numeric values of + underflow during each stress period, respectively, in cubic meters per day. + + \code{tr.stress.periods} is a vector of Date values giving the start and end dates for + stress periods in the model simulation period (1995--2010). + + \code{ss.stress.periods} is a vector of Date values giving the start and end dates for + stress periods used to define steady-state conditions. + + \code{reduction} is a numeric default value for the signal amplitude reduction algorithm, + a dimensionless quantity. + + \code{d.in.mv.ave} is a numeric default value for the number of days in the + moving average subset. } - -\value{ -Returns an object of \code{difftime} class, the runtime for this function. -Used for the side-effect of files written to disk. - -A MODFLOW Well Package file \file{.wel} is always written to disk; whereas, -parameter estimation files \file{seep.csv}, \file{eff.csv}, and \file{trib.csv}, and -a script file \file{UpdateBudget.bat}, are only written if they do not already exist. -The script file may be used to automate the execution of this function from a file manager (such as, Windows Explorer). - -The \file{seep.csv} file stores as tabular data the canal seepage fraction for each of the irrigation entities. -Its \code{character} and \code{numeric} data fields are delimited by commas (a comma-separated-value [CSV] file). -The first line is reserved for field names \code{EntityName} and \code{SeepFrac}. - -The \file{eff.csv} file stores as tabular data the irrigation efficiency for each of the irrigation entities. -Its \code{character} and \code{numeric} data fields are delimited by commas. -The first line is reserved for field names \code{EntityName} and \code{Eff}. - -The \file{trib.csv} file stores as tabular data the underflow boundary conditions for each tributary basin. -Its \code{character} and \code{numeric} data fields are delimited by commas. -The first line is reserved for field names \code{Name} and \code{Value}. -Data records include a long-term mean flow multiplier for each of the tributary basins (name is the unique identifier for the tributary), -a record for the amplitude reduction (\code{reduction}), and -a record for the number of days in the moving average (\code{d.in.mv.ave}). - -If the \code{qa.tables} argument is specified as either \code{"si"} or \code{"english"}, quality assurance tables are written to disk as CSV files (\sQuote{qa-*.csv}). -Volumetric flow rate data within these tables is described in the \sQuote{Value} section of the \code{\link{RunWaterBalance}} function; -see returned \code{list} components \code{natural.rech}, \code{inciden.rech}, and \code{pumping.rech}. -The well configuration data are described in the \sQuote{Value} section of the \code{\link{GetWellConfig}} function. +\examples{ +\dontrun{ + dir.run <- file.path(getwd(), "model/model1") + UpdateWaterBudget(dir.run, "wrv_mfusg", qa.tables = "si", + ss.interval = c("1998-01-01", "2011-01-01")) } -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\seealso{\code{\link{RunWaterBalance}}, \code{\link{GetSeasonalMult}}} - -\examples{\dontrun{ -dir.run <- "C:/Users/jfisher/Documents/SIR2016-5080/model/model1" -UpdateWaterBudget(dir.run, "wrv_mfusg", qa.tables = "si", - ss.interval = c("1998-01-01", "2011-01-01"))} } - +\author{ +J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center +} +\seealso{ +\code{\link{RunWaterBalance}}, \code{\link{GetSeasonalMult}} +} \keyword{utilities} + diff --git a/man/WriteModflowInput.Rd b/man/WriteModflowInput.Rd index 545a197..b9073f8 100644 --- a/man/WriteModflowInput.Rd +++ b/man/WriteModflowInput.Rd @@ -1,96 +1,166 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/WriteModflowInput.R \name{WriteModflowInput} - \alias{WriteModflowInput} - \title{Write MODFLOW Input Files} - -\description{ -This function generates and writes input files for a MODFLOW simulation of groundwater flow in the Wood River Valley (WRV) aquifer system. -} - \usage{ WriteModflowInput(rs.model, rech, well, trib, misc, river, drain, id, dir.run, - is.convertible = FALSE, ss.perlen = 0L, - tr.stress.periods = NULL, ntime.steps = 4L, - mv.flag = 1e+09, auto.flow.reduce = FALSE, verbose = TRUE) + is.convertible = FALSE, ss.perlen = 0L, tr.stress.periods = NULL, + ntime.steps = 4L, mv.flag = 1e+09, auto.flow.reduce = FALSE, + verbose = TRUE) } - \arguments{ -\item{rs.model}{\code{RasterStack}; a collection of \code{RasterLayer} objects with the same extent and resolution, see \sQuote{Details} for required raster layers.} -\item{rech}{\code{data.frame}; is the areal recharge rate, in cubic meters per day. - Variables describe the model cell location (\code{lay}, \code{row}, \code{col}) and volumetric rate during each stress period (\code{ss}, \code{199501}, \code{199502}, \dots, \code{201012}).} -\item{well}{\code{data.frame}; is the well pumping at point locations in cubic meters per day. - Variables describe the model cell location and volumetric rate during each stress period.} -\item{trib}{\code{data.frame}; is the incoming flows from the major tributary canyons. - Variables describe the model cell location and volumetric rate during each stress period.} -\item{misc}{\code{data.frame}; is recharge from miscellaneous seepage sites in cubic meters per day. - Variables describe the model cell location and volumetric rate during each stress period.} -\item{river}{\code{data.frame}; is the river conditions. - Variables describe the model cell location, river conductance (\code{cond}) in square meters per day, river bottom elevation (\code{bottom}) in meters above the North American Vertical Datum of 1988 (NAVD 88), and a numeric river reach identifier (\code{id}).} -\item{drain}{\code{data.frame}; is the drain conditions for groundwater outlet boundaries. - Variables describe the model cell location, drain threshold elevation (\code{elev}) in meters above the NAVD 88, drain conductance (\code{cond}) in square meters per day, and a numeric identifier (\code{id}) indicating the drains general location.} -\item{id}{\code{character}; a short identifier for the model run.} -\item{dir.run}{\code{character}; the path name of the directory to write model input files.} -\item{is.convertible}{\code{logical}; if \code{TRUE}, indicates model layers are \sQuote{convertible}, with transmissivity computed using upstream water-table depth. - Otherwise, model layers are \sQuote{confined} and transmissivity is constant over time.} -\item{ss.perlen}{\code{integer} or \code{difftime}; the length of the steady-state stress period in days.} -\item{tr.stress.periods}{\code{Date}; a vector of start times for each stress period in the transient simulation. - If missing, only steady-state conditions are simulated.} -\item{ntime.steps}{\code{integer}; the number of uniform time steps in a stress period.} -\item{mv.flag}{\code{numeric}; default \code{NA}, missing value flag for output reference data files.} -\item{auto.flow.reduce}{\code{logical}; if \code{TRUE}, a simulated well will adjust pumping according to supply under bottom-hole conditions. - Pumping rates that have been automatically reduced will be written to a model output file (\file{.afr}).} -\item{verbose}{\code{logical}; if \code{TRUE}, additional information is written to the listing file (\file{.lst}) and budget file (\file{.bud}).} +\item{rs.model}{RasterStack. +Collection of RasterLayer objects with the same extent and resolution, +see \sQuote{Details} for required raster layers.} + +\item{rech}{data.frame. +Areal recharge rate, in cubic meters per day. +Variables describe the model cell location (\code{lay}, \code{row}, \code{col}) and +volumetric rate during each stress period +(\code{ss}, \code{199501}, \code{199502}, \dots, \code{201012}).} + +\item{well}{data.frame. +Well pumping at point locations in cubic meters per day. +Variables describe the model cell location and volumetric rate during each stress period.} + +\item{trib}{data.frame. +Incoming flows from the major tributary canyons. +Variables describe the model cell location and volumetric rate during each stress period.} + +\item{misc}{data.frame. +Direct recharge from miscellaneous seepage sites in cubic meters per day. +Variables describe the model cell location and volumetric rate during each stress period.} + +\item{river}{data.frame. +River conditions. +Variables describe the model cell location, river conductance +(\code{cond}) in square meters per day, river bottom elevation (\code{bottom}) in +meters above the North American Vertical Datum of 1988 (NAVD 88), and +a numeric river reach identifier (\code{id}).} + +\item{drain}{data.frame. +Drain conditions for groundwater outlet boundaries. +Variables describe the model cell location, drain threshold elevation +(\code{elev}) in meters above the NAVD 88, drain conductance (\code{cond}) in +square meters per day, and a numeric identifier (\code{id}) indicating the +drains general location.} + +\item{id}{character. +Short identifier for the model run.} + +\item{dir.run}{character. +Path name of the directory to write model input files.} + +\item{is.convertible}{logical. +If true, indicates model layers are \sQuote{convertible}, with +transmissivity computed using upstream water-table depth. +Otherwise, model layers are \sQuote{confined} and transmissivity is constant over time.} + +\item{ss.perlen}{integer or difftime. +Length of the steady-state stress period in days.} + +\item{tr.stress.periods}{Date. +Vector of start times for each stress period in the transient simulation. +If missing, only steady-state conditions are simulated.} + +\item{ntime.steps}{integer. +Number of uniform time steps in a stress period.} + +\item{mv.flag}{numeric. +Missing value flag for output reference data files.} + +\item{auto.flow.reduce}{logical. +If true, a simulated well will adjust pumping according to +supply under bottom-hole conditions. +Pumping rates that have been automatically reduced will be written to a +model output file (\file{.afr}).} + +\item{verbose}{logical. +If true, additional information is written to the +listing file (\file{.lst}) and budget file (\file{.bud})} } - -\details{ -Groundwater flow in the WRV aquifer system is simulated using the \href{http://water.usgs.gov/ogw/mfusg/}{MODFLOW-USG} groundwater-flow model. -This numerical model was chosen for its ability to solve complex unconfined groundwater flow simulations. -The solver implemented in MODFLOW-USG incorporates the Newton-Raphson formulation for improving solution convergence and avoiding problems with the drying and rewetting of cells (Niswonger and others, 2011). -A structured finite-difference grid is implemented in the model to -(1) simplify discretization, -(2) keep formats and structures for the MODFLOW-USG packages identical to those of \href{http://water.usgs.gov/nrp/gwsoftware/modflow2005/Guide/index.html}{MODFLOW-2005}, and -(3) allow any MODFLOW post-processor to be used to analyze the results of the MODFLOW-USG simulation (such as \href{http://water.usgs.gov/nrp/gwsoftware/modelviewer/ModelViewer.html}{Model Viewer}). - -Model input files are written to \code{dir.run} and include the following MODFLOW Package files: Name (\file{.nam}), Basic (\file{.ba6}), Discretization (\file{.dis}), Layer-Property Flow (\file{.lpf}), Drain (\file{.drn}), River (\file{.riv}), Well (\file{.wel}), Sparse Matrix Solver (\file{.sms}), and Output Control (\file{.oc}). -See the users guide (\cite{Description of Model Input and Output}) included with the MODFLOW-USG \href{http://water.usgs.gov/ogw/mfusg/mfusg.1_2_00.zip}{software} for details on input file formats and structures. - -Data within the \code{rech}, \code{well}, \code{trib}, and \code{misc} arguments are combined in the MODFLOW Well Package and identifiable with added \code{id} values of 1, 2, 3, and 4, respectively. - -The Layer-Property Flow file includes options for the calculation of vertical flow in partially dewatered cells. -For the WRV model, where there is no indication that perched conditions exist, \code{CONSTANTCV} and \code{NOVFC} options are used to create the most stable solution (Panday and others, 2013, p. 15-16). -Options for the Sparse Matrix Solver were set for unconfined simulations by implementing an upstream-weighting scheme with Newton-Raphson linearization, Delta-Bar-Delta under-relaxation, and the \eqn{\chi}MD solver of Ibaraki (2005). - -The raster stack \code{rs.model} includes the following layers: -\describe{ - \item{lay1.top}{is the elevation at the top of model layer 1 (land surface), in meters above the NAVD 88.} - \item{lay1.bot}{is the elevation at the bottom of model layer 1, in meters above the NAVD 88.} - \item{lay2.bot}{is the elevation at the bottom of model layer 2.} - \item{lay3.bot}{is the elevation at the bottom of model layer 3.} - \item{lay1.strt}{is the initial (starting) hydraulic head in model layer 1, in meters above the NAVD 88.} - \item{lay2.strt}{is the initial hydraulic head in model layer 2.} - \item{lay3.strt}{is the initial hydraulic head in model layer 3.} - \item{lay1.zones}{is the hydrogeologic zones in model layer 1 where values \code{= 1} is unconfined alluvium, \code{= 2} is basalt, \code{= 3} is clay, and \code{= 4} is confined alluvium.} - \item{lay2.zones}{is the hydrogeologic zones in model layer 2.} - \item{lay3.zones}{is the hydrogeologic zones in model layer 3.} - \item{lay1.hk}{is the horizontal hydraulic conductivity in model layer 1, in meters per day.} - \item{lay2.hk}{is the horizontal hydraulic conductivity in model layer 2.} - \item{lay3.hk}{is the horizontal hydraulic conductivity in model layer 3.} +\value{ +Used for the side-effect of files written to disk. } +\description{ +This function generates and writes input files for a MODFLOW simulation of +groundwater flow in the Wood River Valley (WRV) aquifer system. } +\details{ +Groundwater flow in the WRV aquifer system is simulated using the + \href{http://water.usgs.gov/ogw/mfusg/}{MODFLOW-USG} groundwater-flow model. + This numerical model was chosen for its ability to solve + complex unconfined groundwater flow simulations. + The solver implemented in MODFLOW-USG incorporates the Newton-Raphson formulation for + improving solution convergence and avoiding problems with the drying and + rewetting of cells (Niswonger and others, 2011). + A structured finite-difference grid is implemented in the model to + (1) simplify discretization, + (2) keep formats and structures for the MODFLOW-USG packages identical to those of + \href{http://water.usgs.gov/nrp/gwsoftware/modflow2005/Guide/index.html}{MODFLOW-2005}, and + (3) allow any MODFLOW post-processor to be used to analyze the results of the MODFLOW-USG simulation + (such as \href{http://water.usgs.gov/nrp/gwsoftware/modelviewer/ModelViewer.html}{Model Viewer}). + + Model input files are written to \code{dir.run} and include the following MODFLOW Package files: + Name (\file{.nam}), Basic (\file{.ba6}), Discretization (\file{.dis}), + Layer-Property Flow (\file{.lpf}), Drain (\file{.drn}), River (\file{.riv}), + Well (\file{.wel}), Sparse Matrix Solver (\file{.sms}), and Output Control (\file{.oc}). + See the users guide (\cite{Description of Model Input and Output}) included with the MODFLOW-USG + software for details on input file formats and structures. + + Data within the \code{rech}, \code{well}, \code{trib}, and \code{misc} arguments are + combined in the MODFLOW Well Package and identifiable with added \code{id} values of + 1, 2, 3, and 4, respectively. + + The Layer-Property Flow file includes options for the calculation of vertical flow in + partially dewatered cells. + For the WRV model, where there is no indication that perched conditions exist, + CONSTANTCV and NOVFC options are used to create the most stable solution + (Panday and others, 2013, p. 15-16). + Options for the Sparse Matrix Solver were set for unconfined simulations by + implementing an upstream-weighting scheme with Newton-Raphson linearization, + Delta-Bar-Delta under-relaxation, and the \eqn{\chi}MD solver of Ibaraki (2005). + + The raster stack \code{rs.model} includes the following layers: + \describe{ + \item{lay1.top}{elevation at the top of model layer 1 (land surface), + in meters above the NAVD 88.} + \item{lay1.bot}{elevation at the bottom of model layer 1, in meters above the NAVD 88.} + \item{lay2.bot}{elevation at the bottom of model layer 2.} + \item{lay3.bot}{elevation at the bottom of model layer 3.} + \item{lay1.strt}{initial (starting) hydraulic head in model layer 1, + in meters above the NAVD 88.} + \item{lay2.strt}{initial hydraulic head in model layer 2.} + \item{lay3.strt}{initial hydraulic head in model layer 3.} + \item{lay1.zones}{hydrogeologic zones in model layer 1 where values + equal to 1 is unconfined alluvium, equal to 2 is basalt, + equal to 3 is clay, and equal to 4 is confined alluvium.} + \item{lay2.zones}{hydrogeologic zones in model layer 2.} + \item{lay3.zones}{hydrogeologic zones in model layer 3.} + \item{lay1.hk}{horizontal hydraulic conductivity in model layer 1, in meters per day.} + \item{lay2.hk}{horizontal hydraulic conductivity in model layer 2.} + \item{lay3.hk}{horizontal hydraulic conductivity in model layer 3.} + } +} +\examples{ +\dontrun{# see Appendix D. Uncalibrated Groundwater-Flow Model} -\value{None. Used for the side-effect of files written to disk.} - +} +\author{ +J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center +} \references{ -Ibaraki, M., 2005, \eqn{\chi}MD User's guide-An efficient sparse matrix solver library, version 1.30: Columbus, Ohio State University School of Earth Sciences. +Ibaraki, M., 2005, \eqn{\chi}MD User's guide-An efficient sparse matrix solver library, version 1.30: + Columbus, Ohio State University School of Earth Sciences. -Niswonger, R.G., Panday, Sorab, and Ibaraki, Motomu, 2011, MODFLOW-NWT, A Newton formulation for MODFLOW-2005: U.S. Geological Survey Techniques and Methods 6-A37, 44 p., available at \url{http://pubs.usgs.gov/tm/tm6a37/}. + Niswonger, R.G., Panday, Sorab, and Ibaraki, Motomu, 2011, MODFLOW-NWT, A Newton formulation for MODFLOW-2005: + U.S. Geological Survey Techniques and Methods 6-A37, 44 p., available at \url{http://pubs.usgs.gov/tm/tm6a37/}. -Panday, Sorab, Langevin, C.D., Niswonger, R.G., Ibaraki, Motomu, and Hughes, J.D., 2013, MODFLOW-USG version 1: An unstructured grid version of MODFLOW for simulating groundwater flow and tightly coupled processes using a control volume finite-difference formulation: U.S. Geological Survey Techniques and Methods, book 6, chap. A45, 66 p., available at \url{http://pubs.usgs.gov/tm/06/a45/}. + Panday, Sorab, Langevin, C.D., Niswonger, R.G., Ibaraki, Motomu, and Hughes, J.D., 2013, MODFLOW-USG version 1: + An unstructured grid version of MODFLOW for simulating groundwater flow and tightly coupled processes using a + control volume finite-difference formulation: U.S. Geological Survey Techniques and Methods, book 6, chap. A45, + 66 p., available at \url{http://pubs.usgs.gov/tm/06/a45/}. } - -\author{J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center} - -\examples{\dontrun{# see uncalibrated-model vignette}} - \keyword{IO} + diff --git a/man/alluvium.extent.Rd b/man/alluvium.extent.Rd index 88d3ca4..2b50b0f 100644 --- a/man/alluvium.extent.Rd +++ b/man/alluvium.extent.Rd @@ -1,32 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{alluvium.extent} - \alias{alluvium.extent} - -\docType{data} - \title{Extent of Alluvium Unit} - -\description{ -The estimated extent of alluvium unit in the Wood River Valley, south-central Idaho. +\format{An object of SpatialPolygonsDataFrame class containing 1 Polygons. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Extent defined by Bartollino and Adkins (2012, Plate 1). } - -\usage{alluvium.extent} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing 1 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +alluvium.extent } - -\source{Extent defined by Bartollino and Adkins (2012, Plate 1).} - -\references{ -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +\description{ +Estimated extent of alluvium unit in the Wood River Valley aquifer system. } - \examples{ -plot(alluvium.extent, col = "#BFA76F") +sp::plot(alluvium.extent, col = "#BFA76F") str(alluvium.extent) -} +} +\references{ +Bartolino, J.R., and Adkins, C.B., 2012, + Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: + U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., + available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +} \keyword{datasets} + diff --git a/man/alluvium.thickness.Rd b/man/alluvium.thickness.Rd index a3c3806..88f78bf 100644 --- a/man/alluvium.thickness.Rd +++ b/man/alluvium.thickness.Rd @@ -1,37 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{alluvium.thickness} - \alias{alluvium.thickness} - -\docType{data} - \title{Thickness of the Quaternary Sediment} - -\description{ -The estimated thickness of the Quaternary sediment in the Wood River Valley aquifer system, South-Central Idaho. -} - -\usage{alluvium.thickness} - -\format{ -An object of \code{RasterLayer} class. -Each cell on the surface grid represents a depth measured from land surface in meters. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -The spatial grid is composed of 565 rows and 429 columns, and has cell sizes that are constant at 100 meters by 100 meters. -} - +\format{An object of RasterLayer class. + Each cell on the surface grid represents a depth measured from land surface in meters. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). + The spatial grid is composed of 565 rows and 429 columns, + and has cell sizes that are constant at 100 meters by 100 meters.} \source{ -This dataset is a revised version of Plate 1 in Bartolino and Adkins (2012). +Revised version of Plate 1 in Bartolino and Adkins (2012). } - -\references{ -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +\usage{ +alluvium.thickness +} +\description{ +Estimated thickness of the Quaternary sediment in the Wood River Valley aquifer system. } - \examples{ col <- rainbow(255, start = 0.0, end = 0.8) -image(alluvium.thickness, col = col, asp = 1, axes = FALSE, xlab = "", ylab = "") +raster::image(alluvium.thickness, col = col, asp = 1, axes = FALSE, + xlab = "", ylab = "") summary(alluvium.thickness) -} +} +\references{ +Bartolino, J.R., and Adkins, C.B., 2012, + Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: + U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., + available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +} \keyword{datasets} + diff --git a/man/basalt.extent.Rd b/man/basalt.extent.Rd index e33dac8..ba377f7 100644 --- a/man/basalt.extent.Rd +++ b/man/basalt.extent.Rd @@ -1,35 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{basalt.extent} - \alias{basalt.extent} - -\docType{data} - \title{Extent of Basalt Unit} - -\description{ -The estimated extent of the basalt unit underlying the alluvial Wood River Valley aquifer system. -} - -\usage{basalt.extent} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing 1 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPolygonsDataFrame class containing 1 Polygons. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ -Extent defined by Bartolino and Adkins (2012, Plate 1). +Extent defined by Bartollino and Adkins (2012, Plate 1). } - -\references{ -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +\usage{ +basalt.extent +} +\description{ +Estimated extent of the basalt unit underlying the alluvial Wood River Valley aquifer system. } - \examples{ -plot(basalt.extent, col = "#BEAED4", border = NA) -plot(alluvium.extent, add = TRUE) +sp::plot(basalt.extent, col = "#BEAED4", border = NA) +sp::plot(alluvium.extent, add = TRUE) str(basalt.extent) -} +} +\references{ +Bartolino, J.R., and Adkins, C.B., 2012, + Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: + U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., + available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +} \keyword{datasets} + diff --git a/man/bellevue.wwtp.ponds.Rd b/man/bellevue.wwtp.ponds.Rd index e66c47c..80bfbf1 100644 --- a/man/bellevue.wwtp.ponds.Rd +++ b/man/bellevue.wwtp.ponds.Rd @@ -1,29 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{bellevue.wwtp.ponds} - \alias{bellevue.wwtp.ponds} - -\docType{data} - \title{Bellevue Waste Water Treatment Plant Ponds} - -\description{ -The location of the Bellevue Waste Water Treatment Plant ponds. -} - -\usage{bellevue.wwtp.ponds} - -\format{ -An object of \code{SpatialPolygons} class containing 1 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPolygonsDataFrame class containing 1 Polygons. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on December 11, 2014 } - -\examples{ -plot(bellevue.wwtp.ponds) +\usage{ +bellevue.wwtp.ponds } +\description{ +Location of the Bellevue Waste Water Treatment Plant ponds. +} +\examples{ +sp::plot(bellevue.wwtp.ponds) +} \keyword{datasets} + diff --git a/man/bypass.canal.Rd b/man/bypass.canal.Rd index 861eded..dd5051b 100644 --- a/man/bypass.canal.Rd +++ b/man/bypass.canal.Rd @@ -1,29 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{bypass.canal} - \alias{bypass.canal} - -\docType{data} - \title{Bypass Canal} - -\description{ -The location of the Bypass Canal. -} - -\usage{bypass.canal} - -\format{ -An object of \code{SpatialLines} class containing 4 \code{Lines}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialLines class containing 4 Lines. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on January 15, 2015 } - -\examples{ -plot(bypass.canal) +\usage{ +bypass.canal } +\description{ +Location of the Bypass Canal in the Wood River Valley. +} +\examples{ +sp::plot(bypass.canal) +} \keyword{datasets} + diff --git a/man/canal.seep.Rd b/man/canal.seep.Rd index b946679..c8067d6 100644 --- a/man/canal.seep.Rd +++ b/man/canal.seep.Rd @@ -1,31 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{canal.seep} - \alias{canal.seep} - -\docType{data} - \title{Canal Seepage} - -\description{ -Canal seepage as a fraction of diversions for irrigation entities in the Wood River Valley. -} - -\usage{canal.seep} - -\format{ -A \code{data.frame} object with 19 records and the following variables: -\describe{ - \item{EntityName}{is the name of the irrigation entity served by the canal system.} - \item{SeepFrac}{is the estimated canal seepage as a fraction of diversions.} -} -} - +\format{An object of class data.frame with 19 records and the following variables: + \describe{ + \item{EntityName}{name of the irrigation entity served by the canal system.} + \item{SeepFrac}{estimated canal seepage as a fraction of diversions.} + }} \source{ Idaho Department of Water Resources, accessed on November 4, 2015 } - -\seealso{\code{\link{canals}}} - +\usage{ +canal.seep +} +\description{ +Canal seepage as a fraction of diversions for irrigation entities in the Wood River Valley. +} \examples{ str(canal.seep) @@ -35,6 +27,10 @@ barplot(d$SeepFrac, names.arg = d$EntityName, horiz = TRUE, cex.names = 0.7, cex.axis = 0.7, cex.lab = 0.7, las = 1, xlab = "Seepage fraction") graphics.off() -} +} +\seealso{ +\code{\link{canals}} +} \keyword{datasets} + diff --git a/man/canals.Rd b/man/canals.Rd index 84e283f..426db6b 100644 --- a/man/canals.Rd +++ b/man/canals.Rd @@ -1,34 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{canals} - \alias{canals} - -\docType{data} - \title{Canal Systems} - -\description{ -The canal systems in the Wood River Valley and surrounding areas. -} - -\usage{canals} - -\format{ -An object of \code{SpatialLinesDataFrame} class containing 113 \code{Lines} and a \code{data.frame} with the following variable: -\describe{ - \item{EntityName}{the name of the irrigation entity served by the canal system.} - \item{Name}{the local canal name.} -} -} - +\format{An object of SpatialLinesDataFrame class containing + 113 Lines and a data.frame with the following variable: + \describe{ + \item{EntityName}{name of the irrigation entity served by the canal system.} + \item{Name}{local canal name} + }} \source{ Idaho Department of Water Resources, accessed on November 29, 2014 } - -\seealso{\code{\link{r.canals}}, \code{\link{canal.seep}}} - +\usage{ +canals +} +\description{ +Canal systems in the Wood River Valley and surrounding areas. +} \examples{ -plot(canals, col = "#3399CC") +sp::plot(canals, col = "#3399CC") str(canals@data) -} +} +\seealso{ +\code{\link{r.canals}}, \code{\link{canal.seep}} +} \keyword{datasets} + diff --git a/man/cities.Rd b/man/cities.Rd index 136a046..a289a15 100644 --- a/man/cities.Rd +++ b/man/cities.Rd @@ -1,31 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{cities} - \alias{cities} - -\docType{data} - \title{Cities and Towns} - -\description{Cities and towns in the Wood River Valley and surrounding areas.} - -\usage{cities} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 11 points. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPointsDataFrame class containing 11 points. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ -Idaho Department of Water Resources (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on April 15, 2015 +Idaho Department of Water Resources + (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), + accessed on April 15, 2015 +} +\usage{ +cities +} +\description{ +Cities and towns in the Wood River Valley and surrounding areas. } - \examples{ str(cities) col <- "#333333" -plot(cities, pch = 15, cex = 0.8, col = col) +sp::plot(cities, pch = 15, cex = 0.8, col = col) text(cities, labels = cities@data$FEATURE_NA, col = col, cex = 0.5, pos = 1, offset = 0.4) -} +} \keyword{datasets} + diff --git a/man/clay.extent.Rd b/man/clay.extent.Rd index 53a8ba9..14d7857 100644 --- a/man/clay.extent.Rd +++ b/man/clay.extent.Rd @@ -1,37 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{clay.extent} - \alias{clay.extent} - -\docType{data} - \title{Extent of Clay Unit} - -\description{ -The estimated extent of the clay confining unit (aquitard) separating the unconfined aquifer from the underlying confined aquifer in the Wood River Valley. -} - -\usage{clay.extent} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing 2 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPolygonsDataFrame class containing 2 Polygons. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Extent defined by Moreland (1977, fig. 3 in USGS Open-File report). -Moreland (1977) shows an outlier by Picabo that is assumed to indicate confined conditions in the basalt and not the lake sediments. + Moreland (1977) shows an outlier by Picabo that is assumed to + indicate confined conditions in the basalt and not the lake sediments. } - -\references{ -Moreland, J.A., 1977, Ground water-surface water relations in the Silver Creek area, Blaine County, Idaho: Boise, Idaho Department of Water Resources, Water Information Bulletin 44, 42 p., 5 plates in pocket, accessed January 31, 2012. -Also published as U.S. Geological Survey Open-File report 77-456, 66 p., available at \url{http://pubs.er.usgs.gov/pubs/ofr/ofr77456}. +\usage{ +clay.extent +} +\description{ +Estimated extent of the clay confining unit (aquitard) separating the +unconfined aquifer from the underlying confined aquifer in the +Wood River Valley aquifer system. } - \examples{ -plot(clay.extent, col = "#FDC086", border = NA) -plot(alluvium.extent, add = TRUE) +sp::plot(clay.extent, col = "#FDC086", border = NA) +sp::plot(alluvium.extent, add = TRUE) str(clay.extent) -} +} +\references{ +Moreland, J.A., 1977, Ground water-surface water relations in the Silver Creek area, + Blaine County, Idaho: Boise, Idaho Department of Water Resources, Water Information Bulletin 44, + 42 p., 5 plates in pocket, accessed January 31, 2012. + Also published as U.S. Geological Survey Open-File report 77-456, 66 p., + available at \url{http://pubs.er.usgs.gov/pubs/ofr/ofr77456}. +} \keyword{datasets} + diff --git a/man/comb.sw.irr.Rd b/man/comb.sw.irr.Rd index 3e07970..33caaad 100644 --- a/man/comb.sw.irr.Rd +++ b/man/comb.sw.irr.Rd @@ -1,36 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{comb.sw.irr} - \alias{comb.sw.irr} - -\docType{data} - \title{Combined Surface-Water Irrigation Diversions} - -\description{ -Supplemental groundwater rights and associated surface-water rights. -} - -\usage{comb.sw.irr} - -\format{ -A \code{data.frame} object with 1,213 records and the following variables: -\describe{ - \item{WaterRight}{is the name of the supplemental groundwater right.} - \item{CombWaterRight}{is the name of the surface-water right that shares a combined limit with the groundwater right.} - \item{Source}{is the river or stream source name for the surface-water right.} - \item{WaterUse}{is the authorized beneficial use for the surface-water right.} - \item{MaxDivRate}{is the authorized maximum diversion rate for the surface-water right, in cubic meters per day.} - \item{Pdate}{is the priority date of the surface-water right.} -} -} - +\format{An object of class data.frame with 1,213 records and the following variables: + \describe{ + \item{WaterRight}{name of the supplemental groundwater right.} + \item{CombWaterRight}{name of the surface-water right that shares a + combined limit with the groundwater right.} + \item{Source}{river or stream source name for the surface-water right.} + \item{WaterUse}{authorized beneficial use for the surface-water right.} + \item{MaxDivRate}{authorized maximum diversion rate for the surface-water right, + in cubic meters per day.} + \item{Pdate}{priority date of the surface-water right.} + }} \source{ Idaho Department of Water Resources (IDWR), accessed on April 25, 2014; -derived from combined limit comments in IDWR water rights database. + derived from combined limit comments in IDWR water rights database. +} +\usage{ +comb.sw.irr +} +\description{ +Supplemental groundwater rights and associated surface-water rights. } - \examples{ str(comb.sw.irr) -} +} \keyword{datasets} + diff --git a/man/div.gw.Rd b/man/div.gw.Rd index f3f0ff2..936eac1 100644 --- a/man/div.gw.Rd +++ b/man/div.gw.Rd @@ -1,38 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{div.gw} - \alias{div.gw} - -\docType{data} - \title{Groundwater Diversions} - -\description{ -Groundwater diversions recorded by Water District 37 or municipal water providers. -Groundwater is diverted from the aquifer by means of either pumping wells or flowing-artesian wells. -} - -\usage{div.gw} - -\format{ -A \code{data.frame} object with 7,292 records and the following variables: -\describe{ - \item{YearMonth}{is the year and month during which diversions were recorded, with a required date format of \code{YYYYMM}.} - \item{Diversion}{is the name of the well.} - \item{Reach}{is the name of the river subreach into which the well water is discharged; only applicable to exchange wells.} - \item{BigReach}{is the name of the river reach into which the well water is discharged; only applicable to exchange wells.} - \item{EntityName}{is the name of the irrigation entity which the well supplies water.} - \item{WMISNumber}{is the well number in the Idaho Department of Water Resources (IDWR) Water Measurement Information System.} - \item{GWDiv}{is the volume of water diverted during the month, in cubic meters.} +\format{An object of class data.frame with 7,292 records and the following variables: + \describe{ + \item{YearMonth}{year and month during which diversions were recorded, + with a required date format of YYYYMM.} + \item{Diversion}{name of the well} + \item{Reach}{name of the river subreach into which the well water is discharged; + only applicable to exchange wells.} + \item{BigReach}{name of the river reach into which the well water is discharged; + only applicable to exchange wells.} + \item{EntityName}{name of the irrigation entity which the well supplies water.} + \item{WMISNumber}{well number in the Idaho Department of Water Resources (IDWR) + Water Measurement Information System.} + \item{GWDiv}{volume of water diverted during the month, in cubic meters.} + }} +\source{ +Idaho Department of Water Resources (IDWR), accessed on December 11, 2014; + compiled data records from Water District 37 and 37M, City of Ketchum, + Sun Valley Water and Sewer District, City of Hailey, and City of Bellevue. } +\usage{ +div.gw } - -\source{ -IDWR, accessed on December 11, 2014; -compiled data records from Water District 37 and 37M, City of Ketchum, Sun Valley Water and Sewer District, City of Hailey, and City of Bellevue. +\description{ +Groundwater diversions recorded by Water District 37 or municipal water providers. +Groundwater is diverted from the aquifer by means of either pumping wells or +flowing-artesian wells. } - \examples{ str(div.gw) -} +} \keyword{datasets} + diff --git a/man/div.ret.exch.Rd b/man/div.ret.exch.Rd index ff1b4ef..b3d4db3 100644 --- a/man/div.ret.exch.Rd +++ b/man/div.ret.exch.Rd @@ -1,36 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{div.ret.exch} - \alias{div.ret.exch} - -\docType{data} - \title{Diversions, Returns, and Exchange Wells} - -\description{ -The location of streamflow diversions, irrigation canal or pond returns, and exchange well returns. -} - -\usage{div.ret.exch} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 117 points with the following variables: -\describe{ - \item{Name}{a local name for the diversion/return site.} - \item{Type}{the data type: \dQuote{Diversion}, \dQuote{Return}, and \dQuote{Exchange well inflow}.} - \item{LocSource}{the data source.} - \item{Big}{the corresponding river reach.} -} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPointsDataFrame class containing 117 points with the + following variables: + \describe{ + \item{Name}{local name for the diversion/return site.} + \item{Type}{data type, either \dQuote{Diversion}, \dQuote{Return}, or + \dQuote{Exchange well inflow}.} + \item{LocSource}{data source} + \item{Big}{corresponding river reach} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on June 5, 2015 } - +\usage{ +div.ret.exch +} +\description{ +Location of streamflow diversions, irrigation canal or pond returns, and +exchange well returns. +} \examples{ -plot(div.ret.exch) +sp::plot(div.ret.exch) str(div.ret.exch@data) -} +} \keyword{datasets} + diff --git a/man/div.sw.Rd b/man/div.sw.Rd index 98f01b6..40321a5 100644 --- a/man/div.sw.Rd +++ b/man/div.sw.Rd @@ -1,36 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{div.sw} - \alias{div.sw} - -\docType{data} - \title{Surface-Water Diversions} - -\description{ -Surface-water diversions recorded by Water District 37 or municipal water providers. -} - -\usage{div.sw} - -\format{ -A \code{data.frame} object with 15,550 records and the following variables: -\describe{ - \item{YearMonth}{is the year and month during which diversions were recorded, with a required date format of \code{YYYYMM}.} - \item{Diversion}{is the name of the surface-water diversion.} - \item{Reach}{is the river subreach from which the water is diverted.} - \item{BigReach}{is the river reach from which the water is diverted.} - \item{EntityName}{is the name of the irrigation entity which the diversion supplies water.} - \item{SWDiv}{is the volume of water diverted during the month, in cubic meters.} -} -} - +\format{An object of class data.frame with 15,550 records and the following variables: + \describe{ + \item{YearMonth}{year and month during which diversions were recorded, + with a required date format of YYYYMM.} + \item{Diversion}{name of the surface-water diversion.} + \item{Reach}{river subreach from which the water is diverted.} + \item{BigReach}{river reach from which the water is diverted.} + \item{EntityName}{name of the irrigation entity which the diversion supplies water.} + \item{SWDiv}{volume of water diverted during the month, in cubic meters.} + }} \source{ Idaho Department of Water Resources, accessed on December 11, 2014; -compiled data records from Water District 37 and 37M, City of Hailey, City of Bellevue, City of Ketchum, and Sun Valley Water and Sewer District. + compiled data records from Water District 37 and 37M, City of Hailey, + City of Bellevue, City of Ketchum, and Sun Valley Water and Sewer District. +} +\usage{ +div.sw +} +\description{ +Surface-water diversions recorded by Water District 37 or municipal water providers. } - \examples{ str(div.sw) -} +} \keyword{datasets} + diff --git a/man/div.ww.Rd b/man/div.ww.Rd index 4cc442d..873e15b 100644 --- a/man/div.ww.Rd +++ b/man/div.ww.Rd @@ -1,36 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{div.ww} - \alias{div.ww} - -\docType{data} - \title{Wastewater Treatment Plant Diversions} - -\description{ -Discharge from wastewater treatment plants. -} - -\usage{div.ww} - -\format{ -A \code{data.frame} object with 1,182 records and the following variables: -\describe{ - \item{YearMonth}{is the year and month during which diversions were recorded, with a required date format of \code{YYYYMM}.} - \item{Return}{is the name of the wastewater treatment plant.} - \item{Reach}{is the name of the river subreach to which treated effluent is discharged; only applicable to wastewater treatment plants that discharge to the river.} - \item{BigReach}{is the name of the river reach to which treated effluent is discharged; only applicable to wastewater treatment plants that discharge to the river.} - \item{EntityName}{is the name of the irrigation entity served by the wastewater treatment plant.} - \item{WWDiv}{is the volume of wastewater discharged during the month, in cubic meters.} +\format{An object of class data.frame with 1,182 records and the following variables: + \describe{ + \item{YearMonth}{year and month during which diversions were recorded, + with a required date format of YYYYMM.} + \item{Return}{name of the wastewater treatment plant.} + \item{Reach}{name of the river subreach to which treated effluent is discharged; + only applicable to wastewater treatment plants that discharge to the river.} + \item{BigReach}{name of the river reach to which treated effluent is discharged; + only applicable to wastewater treatment plants that discharge to the river.} + \item{EntityName}{name of the irrigation entity served by the wastewater treatment plant.} + \item{WWDiv}{volume of wastewater discharged during the month, in cubic meters.} + }} +\source{ +Idaho Department of Water Resources and U.S. Geological Survey, + accessed on August 11, 2014; compiled data records from the + U.S. Environmental Protection Agency for plants that discharge to the river, + and from records of the Idaho Department of Environmental Quality for + plants that discharge to land application. } +\usage{ +div.ww } - -\source{ -Idaho Department of Water Resources and U.S. Geological Survey, accessed on August 11, 2014; -compiled data records from the U.S. Environmental Protection Agency for plants that discharge to the river, and from records of the Idaho Department of Environmental Quality for plants that discharge to land application. +\description{ +Discharge from wastewater treatment plants. } - \examples{ str(div.ww) -} +} \keyword{datasets} + diff --git a/man/drains.Rd b/man/drains.Rd index cd68325..e2275c2 100644 --- a/man/drains.Rd +++ b/man/drains.Rd @@ -1,39 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{drains} - \alias{drains} - -\docType{data} - \title{Drain Boundaries at Stanton Crossing and Silver Creek} - -\description{ -Polygons used to define the locations of drain boundaries in the model domain. -The polygons clip the line segments along the aquifer boundary (see \code{\link{alluvium.extent}}), and model cells intersecting these clipped-line segments are defined as boundary cells. -} - -\usage{drains} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing a set of 2 \code{Polygons} and a \code{data.frame} with the following variable: -\describe{ - \item{Name}{is an identifier for the polygon.} - \item{cond}{is the drain conductance in square meters per day.} - \item{elev}{is the drain threshold elevation in meters above the North American Vertical Datum of 1988 (NAVD 88).} -} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPolygonsDataFrame class containing a set of 2 Polygons and + a data.frame with the following variable: + \describe{ + \item{Name}{identifier for the polygon.} + \item{cond}{drain conductance in square meters per day.} + \item{elev}{drain threshold elevation in meters above the + North American Vertical Datum of 1988 (NAVD 88).} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ U.S. Geological Survey, accessed on March 27, 2015; -a Keyhole Markup Language (\href{http://en.wikipedia.org/wiki/Kml}{KML}) file created in \href{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in areas of known drains. + a Keyhole Markup Language (\href{http://en.wikipedia.org/wiki/Kml}{KML}) file created in + \href{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in + areas of known drains. +} +\usage{ +drains +} +\description{ +Polygons used to define the locations of drain boundaries in the model domain. +The polygons clip the line segments along the aquifer boundary (see \code{\link{alluvium.extent}}), +and model cells intersecting these clipped-line segments are defined as boundary cells. } - \examples{ str(drains) -plot(drains, border = "red") -plot(alluvium.extent, add = TRUE) -} +sp::plot(drains, border = "red") +sp::plot(alluvium.extent, add = TRUE) +} \keyword{datasets} + diff --git a/man/drybed.Rd b/man/drybed.Rd index 02abf37..689ed71 100644 --- a/man/drybed.Rd +++ b/man/drybed.Rd @@ -1,34 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{drybed} - \alias{drybed} - -\docType{data} - \title{Dry River Bed and Stream Fed Creek Conditions} - +\format{An object of data.frame class with 12 records and the following variables: + \describe{ + \item{Reach}{stream reach name} + \item{199501,\dots,201012}{logical values indicating whether the stream reach exhibits + dry-bed conditions during a stress period.} + }} +\source{ +Idaho Department of Water Resources, accessed on January 6, 2016; + compiled from Water District 37 records. +} +\usage{ +drybed +} \description{ A summary of dry river bed and stream fed conditions in the Wood River Valley, Idaho. Stream reaches on the Big Wood River between Glendale and Wood River Ranch are episodically dry; -these dry periods are specified for calendar months when water diversions to the Bypass Canal begins before the 16th of the month and ends after the 15th of the month. -} - -\usage{drybed} - -\format{ -A \code{data.frame} object with 12 records and the following variables: -\describe{ - \item{Reach}{is the stream reach name.} - \item{199501, \dots, 201012}{are logical values indicating whether the stream reach exhibits dry-bed conditions during a stress period.} -} +these dry periods are specified for calendar months when water diversions to the +Bypass Canal begins before the 16th of the month and ends after the 15th of the month. } - -\source{ -Idaho Department of Water Resources, accessed on January 6, 2016; -compiled from Water District 37 records. -} - \examples{ str(drybed) -} +} \keyword{datasets} + diff --git a/man/efficiency.Rd b/man/efficiency.Rd index 9c4201d..c25aed0 100644 --- a/man/efficiency.Rd +++ b/man/efficiency.Rd @@ -1,32 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{efficiency} - \alias{efficiency} - -\docType{data} - \title{Irrigation Efficiency} - -\description{ -The irrigation efficiency of irrigation entities. -} - -\usage{efficiency} - -\format{ -A \code{data.frame} object with 88 records and the following variables: -\describe{ - \item{EntityName}{is the name of the irrigation entity which the irrigation efficiency is applied.} - \item{Eff}{is the estimated irrigation efficiency, the ratio of the amount of water consumed by the crop to the amount of water supplied through irrigation.} - \item{Comment}{a brief comment on irrigation conditions.} -} -} - +\format{An object of data.frame class with 88 records and the following variables: + \describe{ + \item{EntityName}{name of the irrigation entity which the irrigation efficiency is applied.} + \item{Eff}{estimated irrigation efficiency, the ratio of the amount of + water consumed by the crop to the amount of water supplied through irrigation.} + \item{Comment}{brief comment on irrigation conditions.} + }} \source{ Idaho Department of Water Resources, accessed on July 9, 2015 } - +\usage{ +efficiency +} +\description{ +The irrigation efficiency of irrigation entities in the Wood River Valley, Idaho. +} \examples{ str(efficiency) -} +} \keyword{datasets} + diff --git a/man/entity.components.Rd b/man/entity.components.Rd index c438ecf..c648a3e 100644 --- a/man/entity.components.Rd +++ b/man/entity.components.Rd @@ -1,45 +1,44 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{entity.components} - \alias{entity.components} - -\docType{data} - \title{Irrigation Entity Components} - -\description{ -Irrigation entities and their components in the Wood River Valley and surrounding areas. -An irrigation entity is defined as an area served by a group of surface-water and/or groundwater diversion(s). -} - -\usage{entity.components} - -\format{ -A \code{list} object with components of \code{SpatialPolygonsDataFrame-class}. -There are a total of 192 components, one for each month in the 1995--2010 time period. -Linked \code{data.frame} objects have the following variables: -\describe{ - \item{EntitySrce}{a concatenation of the \code{EntityName} and \code{Source} character strings.} - \item{mean.et}{the mean evapotranspiration (ET) on irrigated and semi-irrigated lands in meters.} - \item{area}{the area of irrigated and semi-irrigated lands in square meters.} - \item{PrecipZone}{the name of the precipitation zone. - See \code{\link{precip.zones}} dataset for details.} - \item{et.vol}{the volume of ET on irrigated and semi-irrigated lands in cubic meters.} - \item{precip.vol}{the volume of precipitation on irrigated and semi-irrigated lands in cubic meters.} - \item{cir.vol}{the volume of crop irrigation requirement in cubic meters (ET minus precipitation).} - \item{EntityName}{is the name of the irrigation entity.} - \item{Source}{is the water source: \dQuote{Mixed} for a mixture of surface water and groundwater, \dQuote{SW Only} for surface water only, and \dQuote{GW Only} for groundwater only.} +\format{An object of list class with components of SpatialPolygonsDataFrame-class. + There are a total of 192 components, one for each month in the 1995--2010 time period. + Linked data.frame objects have the following variables: + \describe{ + \item{EntitySrce}{concatenation of the \code{EntityName} and \code{Source} character strings.} + \item{mean.et}{mean evapotranspiration (ET) on irrigated and semi-irrigated lands in meters.} + \item{area}{area of irrigated and semi-irrigated lands in square meters.} + \item{PrecipZone}{name of the precipitation zone; + see \code{\link{precip.zones}} dataset for details.} + \item{et.vol}{volume of ET on irrigated and semi-irrigated lands in cubic meters.} + \item{precip.vol}{volume of precipitation on irrigated and semi-irrigated lands in cubic meters.} + \item{cir.vol}{volume of crop irrigation requirement in cubic meters (ET minus precipitation).} + \item{EntityName}{name of the irrigation entity.} + \item{Source}{water source, either \dQuote{Mixed} for a mixture of surface water and groundwater, + \dQuote{SW Only} for surface water only, or \dQuote{GW Only} for groundwater only.} + }} +\source{ +Calculated from the \code{\link{irr.entities}}, \code{\link{wetlands}}, + \code{\link{public.parcels}}, \code{\link{irr.lands.year}}, \code{\link{et}}, and + \code{\link{precipitation}} datasets; + see the \file{package-datasets} vignette for the \R code used in this calculation. } +\usage{ +entity.components } - -\source{ -Calculated from the \code{\link{irr.entities}}, \code{\link{wetlands}}, \code{\link{public.parcels}}, \code{\link{irr.lands.year}}, \code{\link{et}}, and \code{\link{precipitation}} datasets; -see the \file{package-datasets} vignette for the \R code used in this calculation. +\description{ +Irrigation entities and their components in the Wood River Valley and surrounding areas. +An irrigation entity is defined as an area served by a group of surface-water and/or +groundwater diversion(s). } - \examples{ names(entity.components) -plot(entity.components[["199506"]]) +sp::plot(entity.components[["199506"]]) print(entity.components[["199506"]]) -} +} \keyword{datasets} + diff --git a/man/et.Rd b/man/et.Rd index 16a63cf..2b7f7e5 100644 --- a/man/et.Rd +++ b/man/et.Rd @@ -1,34 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{et} - \alias{et} - -\docType{data} - \title{Evapotranspiration} - -\description{ -Evapotranspiration (ET) in the Wood River Valley and surrounding areas. -Defined as the amount of water lost to the atmosphere via direct evaporation, transpiration by vegetation, or sublimation from snow covered areas. -} - -\usage{et} - -\format{ -An object of \code{RasterStack} class containing 192 \code{RasterLayer} objects, one layer for each month in the 1995-2010 time period. -Each cell on a layers surface grid represents the monthly depth of ET in meters. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of RasterStack class containing 192 RasterLayer objects, + one layer for each month in the 1995-2010 time period. + Each cell on a layers surface grid represents the monthly depth of ET in meters. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on November 17, 2014 } - -\seealso{\code{\link{et.method}}} - +\usage{ +et +} +\description{ +Evapotranspiration (ET) in the Wood River Valley and surrounding areas. +Defined as the amount of water lost to the atmosphere via direct evaporation, +transpiration by vegetation, or sublimation from snow covered areas. +} \examples{ +sp::plot(et[["199505"]]) print(et) -plot(et[["199505"]]) -} +} +\seealso{ +\code{\link{et.method}} +} \keyword{datasets} + diff --git a/man/et.method.Rd b/man/et.method.Rd index 17c5bb4..4078339 100644 --- a/man/et.method.Rd +++ b/man/et.method.Rd @@ -1,48 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{et.method} - \alias{et.method} - -\docType{data} - \title{Method Used to Calculate Evapotranspiration} - -\description{ -The methods used to estimate monthly distributions of evapotranspiration (ET) rate. +\format{An object of data.frame class with 122 records with the following variables: + \describe{ + \item{YearMonth}{year and month during which the method was applied, + with a required date format of YYYYMM.} + \item{ETMethod}{Identifier that indicates the method used to estimate ET values. + Identifiers include either + \dQuote{Allen-Robison}, the Allen and Robison method (Allen and Robison, 2007); + \dQuote{METRIC}, the Mapping Evapotranspiration at high Resolution and with + Internalized Calibration (METRIC) model (Allen and others, 2010a); + \dQuote{NDVI}, the Normalized Difference Vegetation Index (NDVI) method + (Allen and others, 2010b); + \dQuote{Interpolation}, interpolation from known ET data; or + \dQuote{METRIC-NDVI}, a combination of METRIC and NDVI methods.} + }} +\source{ +Idaho Department of Water Resources, accessed on April 27, 2015 } - -\usage{et.method} - -\format{ -A \code{data.frame} object with 122 records with the following variables: -\describe{ - \item{YearMonth}{The year and month during which the method was applied, with a required date format of \code{YYYYMM}.} - \item{ETMethod}{An identifier that indicates the method used to estimate ET values. - Identifiers include: - \dQuote{Allen-Robison}, the Allen and Robison method (Allen and Robison, 2007); - \dQuote{METRIC}, the Mapping Evapotranspiration at high Resolution and with Internalized Calibration (METRIC) model (Allen and others, 2010a); - \dQuote{NDVI}, the Normalized Difference Vegetation Index (NDVI) method (Allen and others, 2010b); - \dQuote{Interpolation}, interpolation from known ET data; and - \dQuote{METRIC-NDVI}, a combination of METRIC and NDVI methods. - } +\usage{ +et.method } +\description{ +Methods used to estimate monthly distributions of evapotranspiration (ET) rate. } +\examples{ +str(et.method) -\source{ -Idaho Department of Water Resources, accessed on April 27, 2015 } - \references{ -Allen, R., and Robison, C.W., 2007, Evapotranspiration and consumptive water requirements for Idaho, University of Idaho, Kimberly, Idaho. +Allen, R., and Robison, C.W., 2007, Evapotranspiration and + consumptive water requirements for Idaho, University of Idaho, Kimberly, Idaho. -Allen, R., Tasumi, M., Trezza, R., and Kjaersgaard, J., 2010a, METRIC mapping evapotranspiration at high resolution applications manual for Landsat satellite imagery version 2.07, University of Idaho, Kimberly, ID. + Allen, R., Tasumi, M., Trezza, R., and Kjaersgaard, J., 2010a, + METRIC mapping evapotranspiration at high resolution applications manual for + Landsat satellite imagery version 2.07, University of Idaho, Kimberly, ID. -Allen, R., Robison, C.W., Garcia, M., Trezza, R., Tasumi, M., and Kjaersgaard, J., 2010b, ETrF vs NDVI relationships for southern Idaho for rapid estimation of evapotranspiration, University of Idaho, Kimberly, ID. + Allen, R., Robison, C.W., Garcia, M., Trezza, R., Tasumi, M., and Kjaersgaard, J., 2010b, + ETrF vs NDVI relationships for southern Idaho for rapid estimation of evapotranspiration, + University of Idaho, Kimberly, ID. -ET Idaho: \url{http://data.kimberly.uidaho.edu/ETIdaho/} + ET Idaho: \url{http://data.kimberly.uidaho.edu/ETIdaho/} } - -\examples{ -str(et.method) -} - \keyword{datasets} + diff --git a/man/gage.disch.Rd b/man/gage.disch.Rd index df620c6..c4e3254 100644 --- a/man/gage.disch.Rd +++ b/man/gage.disch.Rd @@ -1,43 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{gage.disch} - \alias{gage.disch} - -\docType{data} - \title{Daily Mean Discharge at Streamgages} - -\description{ -The daily mean discharge at streamgages in the Big Wood River Valley, Idaho. -Discharge records bracket the 1992-2014 time period and are based on records with quality assurance code of approved (\sQuote{A}). -} - -\usage{gage.disch} - -\format{ -A \code{data.frame} object with 8,315 records and the following variables: -\describe{ - \item{Date}{is the date during which discharge was averaged.} - \item{13135500}{is the daily mean discharge in cubic meters per day, recorded at the USGS \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} Big Wood River near Ketchum streamgage.} - \item{13139510}{is the daily mean discharge in cubic meters per day, recorded at the USGS \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} Big Wood River at Hailey streamgage.} - \item{13140800}{is the daily mean discharge in cubic meters per day, recorded at the USGS \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} Big Wood River at Stanton Crossing near Bellevue streamgage.} +\format{An object of data.frame class with 8,315 records and the following variables: + \describe{ + \item{Date}{date during which discharge was averaged.} + \item{13135500}{daily mean discharge in cubic meters per day, recorded at the USGS + \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} + Big Wood River near Ketchum streamgage.} + \item{13139510}{daily mean discharge in cubic meters per day, recorded at the USGS + \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} + Big Wood River at Hailey streamgage.} + \item{13140800}{daily mean discharge in cubic meters per day, recorded at the USGS + \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} + Big Wood River at Stanton Crossing near Bellevue streamgage.} + }} +\source{ +National Water Information System (\href{http://waterdata.usgs.gov/nwis}{NWIS}), + accessed on January 8, 2015 } +\usage{ +gage.disch } - -\source{ -National Water Information System (\href{http://waterdata.usgs.gov/nwis}{NWIS}), accessed on January 8, 2015 +\description{ +The daily mean discharge at streamgages in the Big Wood River Valley, Idaho. +Discharge records bracket the 1992-2014 time period and are based on +records with quality assurance code of approved (\sQuote{A}). } - \examples{ str(gage.disch) col <- c("red", "blue", "green") ylab <- paste("Discharge in cubic", c("meters per day", "acre-foot per year")) -PlotGraph(gage.disch, ylab = ylab, col = col, lty = 1:3, conversion.factor = 0.29611) -leg <- sprintf("USGS \%s", names(gage.disch)[-1]) +inlmisc::PlotGraph(gage.disch, ylab = ylab, col = col, lty = 1:3, + conversion.factor = 0.29611) +leg <- sprintf("USGS \\\%s", names(gage.disch)[-1]) legend("topright", leg, col = col, lty = 1:3, inset = 0.02, cex = 0.7, box.lty = 1, bg = "#FFFFFFE7") graphics.off() -} +} \keyword{datasets} + diff --git a/man/gage.height.Rd b/man/gage.height.Rd index 4deb20a..d876f82 100644 --- a/man/gage.height.Rd +++ b/man/gage.height.Rd @@ -1,47 +1,56 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{gage.height} - \alias{gage.height} - -\docType{data} - \title{Daily Mean Gage Height at Streamgages} - -\description{ -The daily mean gage height at streamgages in the Big Wood River Valley, Idaho. -Gage height records bracket the 1987-2014 and are based on records with quality assurance codes of working (\sQuote{W}), in review (\sQuote{R}), and approved (\sQuote{A}). - -} - -\usage{gage.height} - -\format{ -A \code{data.frame} object with 9,980 records and the following variables: -\describe{ - \item{Date}{is the date during which gage height was averaged.} - \item{13135500}{is the daily mean gage height in meters, recorded at the USGS \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} Big Wood River near Ketchum streamgage.} - \item{13139510}{is the daily mean gage height in meters, recorded at the USGS \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} Big Wood River at Hailey streamgage.} - \item{13140800}{is the daily mean gage height in meters, recorded at the USGS \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} Big Wood River at Stanton Crossing near Bellevue streamgages.} +\format{An object of data.frame class with 9,980 records and the following variables: + \describe{ + \item{Date}{date during which gage height was averaged.} + \item{13135500}{daily mean gage height in meters, recorded at the USGS + \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13135500}{13135500} + Big Wood River near Ketchum streamgage.} + \item{13139510}{daily mean gage height in meters, recorded at the USGS + \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13139510}{13139510} + Big Wood River at Hailey streamgage.} + \item{13140800}{daily mean gage height in meters, recorded at the USGS + \href{http://waterdata.usgs.gov/id/nwis/uv/?site_no=13140800}{13140800} + Big Wood River at Stanton Crossing near Bellevue streamgages.} + }} +\source{ +Data queried from the National Water Information System + (\href{http://waterdata.usgs.gov/nwis}{NWIS}) database on December 15, 2014, + by Ross Dickinson (USGS). + Records recorded on May 26-28, 1991 and March 15-22, 1995 were reassigned + quality assurance codes of \sQuote{I} because of assumed ice build-up. + Missing data at the Big Wood River near Ketchum gage was estimated using a + linear regression model based on recorded gage-height data at the Big Wood River at + Hailey and Near Ketchum streamgages. + Missing data at the Stanton Crossing near Bellevue gage was replaced with + average gage-height values recorded at this gage. } +\usage{ +gage.height } - -\source{ -Data queried from the National Water Information System (\href{http://waterdata.usgs.gov/nwis}{NWIS}) database on December 15, 2014, by Ross Dickinson (USGS). -Records recorded on May 26-28, 1991 and March 15-22, 1995 were reassigned quality assurance codes of \sQuote{I} because of assumed ice build-up. -Missing data at the Big Wood River near Ketchum gage was estimated using a linear regression model based on recorded gage-height data at the Big Wood River at Hailey and Near Ketchum streamgages. -Missing data at the Stanton Crossing near Bellevue gage was replaced with average gage-height values recorded at this gage. +\description{ +The daily mean gage height at streamgages in the Big Wood River Valley, Idaho. +Gage height records bracket the 1987-2014 and are based on records with +quality assurance codes of working (\sQuote{W}), in review (\sQuote{R}), and +approved (\sQuote{A}). } - \examples{ str(gage.height) col <- c("red", "blue", "green") ylab <- paste("Gage height in", c("meters", "feet")) -PlotGraph(gage.height, ylab = ylab, col = col, lty = 1:3, conversion.factor = 3.28084) -leg <- sprintf("USGS \%s", names(gage.height)[-1]) +inlmisc::PlotGraph(gage.height, ylab = ylab, col = col, lty = 1:3, + conversion.factor = 3.28084) +leg <- sprintf("USGS \\\%s", names(gage.height)[-1]) legend("topright", leg, col = col, lty = 1:3, inset = 0.02, cex = 0.7, box.lty = 1, bg = "#FFFFFFE7") graphics.off() -} +} \keyword{datasets} + diff --git a/man/hill.shading.Rd b/man/hill.shading.Rd index 27363a3..5363c1e 100644 --- a/man/hill.shading.Rd +++ b/man/hill.shading.Rd @@ -1,33 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{hill.shading} - \alias{hill.shading} - -\docType{data} - \title{Land Surface Hill Shading} - -\description{ -Hill shading of the Wood River Valley and surrounding area. +\format{An object of \code{RasterLayer} class. + Each cell on the surface grid represents the hill shade. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). + The spatial grid is composed of 3,108 rows and 2,360 columns, + and has cell sizes that are constant at 20 meters by 20 meters.} +\source{ +Calculated from the slope and aspect of the \code{\link{land.surface}} dataset + using the \code{terrain} and \code{hillShade} functions; + see the appendix C. Package Dataset Creation for the \R code used in this calculation. } - -\usage{hill.shading} - -\format{ -An object of \code{RasterLayer} class. -Each cell on the surface grid represents the hill shade. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -The spatial grid is composed of 3,108 rows and 2,360 columns, and has cell sizes that are constant at 20 meters by 20 meters. +\usage{ +hill.shading } - -\source{ -Calculated from the slope and aspect of the \code{\link{land.surface}} dataset using the \code{terrain} and \code{hillShade} functions; -see the \file{package-datasets} vignette for the \R code used in this calculation. +\description{ +Hill shading of the Wood River Valley and surrounding area. } - \examples{ -image(hill.shading, length(hill.shading), col = grey(0:255 / 255), asp = 1, - axes = FALSE, xlab = "", ylab = "") -} +raster::image(hill.shading, length(hill.shading), col = grey(0:255 / 255), asp = 1, + axes = FALSE, xlab = "", ylab = "") +} \keyword{datasets} + diff --git a/man/idaho.Rd b/man/idaho.Rd index f425055..c6099ca 100644 --- a/man/idaho.Rd +++ b/man/idaho.Rd @@ -1,30 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{idaho} - \alias{idaho} - -\docType{data} - \title{U.S. State of Idaho} - -\description{ -The boundary of Idaho, a state in the northwestern region of the United States. +\format{An object of SpatialPolygons class containing 1 Polygons. + Cartographic boundary at 5m (1:5,000,000) resolution. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +U.S. Department of Commerce, U.S. Census Bureau, + Geography Division/Cartographic Products Branch. + A simplified representation of the State of Idaho from the 2014 Census Bureau's + MAF/\href{http://www.census.gov/geo/maps-data/data/tiger.html}{TIGER} geographic database. } - -\usage{idaho} - -\format{ -An object of \code{SpatialPolygons} class containing 1 \code{Polygons}. -Cartographic boundary at 5m (1:5,000,000) resolution. +\usage{ +idaho } - -\source{ -U.S. Department of Commerce, U.S. Census Bureau, Geography Division/Cartographic Products Branch. -A simplified representation of the State of Idaho from the 2014 Census Bureau's MAF/\href{http://www.census.gov/geo/maps-data/data/tiger.html}{TIGER} geographic database. +\description{ +Boundary of Idaho, a state in the northwestern region of the United States. } - \examples{ -plot(idaho, col = "#EAE2CF", border = "#BFA76F", lwd = 0.5) +sp::plot(idaho, col = "#EAE2CF", border = "#BFA76F", lwd = 0.5) print(idaho) -} +} \keyword{datasets} + diff --git a/man/irr.entities.Rd b/man/irr.entities.Rd index e0808e2..1cf88a0 100644 --- a/man/irr.entities.Rd +++ b/man/irr.entities.Rd @@ -1,36 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{irr.entities} - \alias{irr.entities} - -\docType{data} - \title{Irrigation Entities} - -\description{ -The delineation of areas served by a group of surface-water and (or) groundwater diversions. -} - -\usage{irr.entities} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing 235 \code{Polygons} and a \code{data.frame} with the following variables: -\describe{ - \item{EntityName}{is the name of the irrigation entity served by a group of diversions.} - \item{Source}{is the water source: \dQuote{Mixed} for a mixture of surface water and groundwater, \dQuote{SW Only} for surface-water only, and \dQuote{GW Only} for groundwater only.} - \item{EntitySrce}{is a concatenation of the \code{EntityName} and \code{Source} character strings.} - \item{PrecipZone}{is the name of the precipitation zone. - See \code{\link{precip.zones}} dataset for details.} -} -} - +\format{An object of SpatialPolygonsDataFrame class containing 235 Polygons and + a data.frame with the following variables: + \describe{ + \item{EntityName}{name of the irrigation entity served by a group of diversions.} + \item{Source}{water source, either \dQuote{Mixed} for a mixture of surface water and groundwater, + \dQuote{SW Only} for surface-water only, or \dQuote{GW Only} for groundwater only.} + \item{EntitySrce}{concatenation of the \code{EntityName} and \code{Source} character strings.} + \item{PrecipZone}{name of the precipitation zone. + See \code{\link{precip.zones}} dataset for details.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources (IDWR), accessed on December 11, 2014; -derived from IDWR water rights database, Blaine County tax lot data, and IDWR irrigated land classification files. + derived from IDWR water rights database, Blaine County tax lot data, + and IDWR irrigated land classification files. +} +\usage{ +irr.entities +} +\description{ +Delineation of areas served by a group of surface-water and (or) groundwater diversions. } - \examples{ -plot(irr.entities) +sp::plot(irr.entities) print(irr.entities) -} +} \keyword{datasets} + diff --git a/man/irr.lands.Rd b/man/irr.lands.Rd index f41c954..40d8bb7 100644 --- a/man/irr.lands.Rd +++ b/man/irr.lands.Rd @@ -1,36 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{irr.lands} - \alias{irr.lands} - -\docType{data} - \title{Irrigated Lands} - -\description{ -The irrigation classification of land area in the Wood River Valley and surrounding areas; available for years 1996, 2000, 2002, 2006, 2008, 2009, and 2010. -} - -\usage{irr.lands} - -\format{ -A \code{list object} of length 7 with components of \code{SpatialPolygonsDataFrame-class}. -The \code{data.frame} associated with each of the \code{SpatialPolygons} objects has the following variable: -\describe{ - \item{Status}{is the status of land during the year reviewed, may be \dQuote{irrigated}, \dQuote{semi-irrigated}, or \dQuote{non-irrigated}.} -} -} - +\format{An object of list class with 7 SpatialPolygonsDataFrame components. + The data.frame associated with each SpatialPolygons object has the following variable: + \describe{ + \item{Status}{status of land during the year reviewed, + either \dQuote{irrigated}, \dQuote{semi-irrigated}, or \dQuote{non-irrigated}.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on November 17, 2014; -polygons derived from U.S. Department of Agriculture Common Land Unit polygons with some refinement of polygons. -Irrigation status interpreted using satellite imagery and aerial photography. + polygons derived from U.S. Department of Agriculture Common Land Unit polygons + with some refinement of polygons. + Irrigation status interpreted using satellite imagery and aerial photography. +} +\usage{ +irr.lands +} +\description{ +Classification of irrigated lands in the Wood River Valley and surrounding areas; +available for years 1996, 2000, 2002, 2006, 2008, 2009, and 2010. } - -\seealso{\code{\link{irr.lands.year}}} - \examples{ -spplot(irr.lands[["2010"]], "Status") +sp::spplot(irr.lands[["2010"]], "Status") print(irr.lands) -} +} +\seealso{ +\code{\link{irr.lands.year}} +} \keyword{datasets} + diff --git a/man/irr.lands.year.Rd b/man/irr.lands.year.Rd index 6424e4c..da35c3b 100644 --- a/man/irr.lands.year.Rd +++ b/man/irr.lands.year.Rd @@ -1,32 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{irr.lands.year} - \alias{irr.lands.year} - -\docType{data} - \title{Irrigation Lands for a Given Year} - -\description{ -The annual land classification for irrigation practices is only available for select years. -For missing years, this dataset provides substitute years when land-classification was available (see \code{\link{irr.lands}}). -} - -\usage{irr.lands.year} - -\format{ -A \code{data.frame} object with 16 records and the following variables: -\describe{ - \item{Year}{is the year with a required date format of \code{YYYY}.} - \item{IL_Year}{is the substitute year with a required date format of \code{YYYY}.} -} -} - +\format{An object of data.frame class with 16 records and the following variables: + \describe{ + \item{Year}{year with a required date format of YYYY.} + \item{IL_Year}{substitute year with a required date format of YYYY.} + }} \source{ Idaho Department of Water Resources, accessed on April 25, 2014 } - +\usage{ +irr.lands.year +} +\description{ +Annual land classification for irrigation practices is only available for select years. +For missing years, this dataset provides substitute years when land-classification was +available (see \code{\link{irr.lands}}). +} \examples{ str(irr.lands.year) -} +} \keyword{datasets} + diff --git a/man/kriging.zones.Rd b/man/kriging.zones.Rd index 274f1e4..8e9569e 100644 --- a/man/kriging.zones.Rd +++ b/man/kriging.zones.Rd @@ -1,36 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{kriging.zones} - \alias{kriging.zones} - -\docType{data} - \title{Kriging Zones} - -\description{ -The location of kriging zones in the Wood River Valley, used in parameter estimation. -} - -\usage{kriging.zones} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing 18 \code{Polygons} and a \code{data.frame} with the following variables: -\describe{ - \item{Zone}{is the kriging zone, interpolation in this zone is based on the parameter values of pilot points located within this zone.} - \item{Layer}{is the model layer.} - \item{Name}{is the local name.} +\format{An object of SpatialPolygonsDataFrame class containing 18 Polygons and a +data.frame with the following variables: + \describe{ + \item{Zone}{kriging zone, interpolation in this zone is based on the + parameter values of pilot points located within this zone.} + \item{Layer}{model layer} + \item{Name}{local name} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Idaho Department of Water Resources, accessed on June 11, 2015 } -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +kriging.zones } - -\source{ -Idaho Department of Water Resources +\description{ +Location of kriging zones in the Wood River Valley, used in parameter estimation. } - -\seealso{\code{\link{pilot.points}}} - \examples{ +sp::plot(kriging.zones) str(kriging.zones@data) -} +} +\seealso{ +\code{\link{pilot.points}} +} \keyword{datasets} + diff --git a/man/lakes.Rd b/man/lakes.Rd index 7199bc0..237775e 100644 --- a/man/lakes.Rd +++ b/man/lakes.Rd @@ -1,30 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{lakes} - \alias{lakes} - -\docType{data} - \title{Lakes and Reservoirs} - -\description{ -Lakes and reservoirs of the Wood River Valley and surrounding areas. +\format{An object of SpatialPolygonsDataFrame class containing 55 Polygons. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Idaho Department of Water Resources + (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), + accessed on April 2, 2014 } - -\usage{lakes} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing 55 \code{Polygons}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +lakes } - -\source{ -Idaho Department of Water Resources (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on April 2, 2014 +\description{ +Lakes and reservoirs of the Wood River Valley and surrounding areas. } - \examples{ -plot(lakes, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) +sp::plot(lakes, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) str(lakes@data) -} +} \keyword{datasets} + diff --git a/man/land.surface.Rd b/man/land.surface.Rd index 6ee617b..673be22 100644 --- a/man/land.surface.Rd +++ b/man/land.surface.Rd @@ -1,46 +1,54 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{land.surface} - \alias{land.surface} - -\docType{data} - \title{Topography of Land Surface} - +\format{An object of SpatialGridDataFrame class. + Each cell on the surface grid represents an elevation in meters above the + North American Vertical Datum of 1988 (NAVD 88). + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). + The spatial grid is composed of 565 rows and 429 columns, + and has cell sizes that are constant at 100 meters by 100 meters.} +\source{ +The National Elevation Dataset (\href{http://ned.usgs.gov/}{NED}) + 1/3-arc-second raster (Gesch, 2007; Gesch and others, 2002), + accessed on December 1, 2015. + This dataset can be downloaded in a Esri ArcGRID format using the + \href{http://viewer.nationalmap.gov/viewer/}{National Map Viewer}. + NED data are distributed in geographic coordinates in units of decimal degrees, + and in conformance with the NAD 83. + Elevation values are in meters above the NAVD 88. + The west, east, south, and north bounding coordinates for this dataset are + -115, -114, 43, and 44 decimal degrees, respectively. + Post-processing includes: + (1) project the values of the NED dataset into the \code{\link{alluvium.thickness}} + spatial grid using bilinear interpolation, and + (2) set values in cells where the elevation of the alluvium bottom is missing to NA. +} +\usage{ +land.surface +} \description{ The Wood River Valley (WRV) is a geologic feature located in south-central Idaho. This dataset gives the topography of the land surface in the WRV and vicinity. } +\examples{ +raster::image(land.surface) +summary(land.surface) -\usage{land.surface} - -\format{ -An object of \code{SpatialGridDataFrame} class. -Each cell on the surface grid represents an elevation in meters above the North American Vertical Datum of 1988 (NAVD 88). -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -The spatial grid is composed of 565 rows and 429 columns, and has cell sizes that are constant at 100 meters by 100 meters. -} - -\source{ -The National Elevation Dataset (\href{http://ned.usgs.gov/}{NED}) 1/3-arc-second raster (Gesch, 2007; Gesch and others, 2002), accessed on December 1, 2015. -This dataset can be downloaded in a Esri ArcGRID format using the \href{http://viewer.nationalmap.gov/viewer/}{National Map Viewer}. -NED data are distributed in geographic coordinates in units of decimal degrees, and in conformance with the NAD 83. -Elevation values are in meters above the NAVD 88. -The west, east, south, and north bounding coordinates for this dataset are -115, -114, 43, and 44 decimal degrees, respectively. -Post-processing includes: -(1) project the values of the NED dataset into the \code{\link{alluvium.thickness}} spatial grid using bilinear interpolation, and -(2) set values in cells where the elevation of the alluvium bottom is missing to \code{NA}. } - \references{ -Gesch, D.B., 2007, The National Elevation Dataset, in Maune, D., ed., Digital Elevation Model Technologies and Applications: The DEM Users Manual, 2nd Edition: Bethesda, Maryland, American Society for Photogrammetry and Remote Sensing, p. 99-118. - -Gesch, D., Oimoen, M., Greenlee, S., Nelson, C., Steuck, M., and Tyler, D., 2002, The National Elevation Dataset: Photogrammetric Engineering and Remote Sensing, v. 68, no. 1, p. 5-11. +Gesch, D.B., 2007, The National Elevation Dataset, in Maune, D., ed., + Digital Elevation Model Technologies and Applications: The DEM Users Manual, + 2nd Edition: Bethesda, Maryland, American Society for Photogrammetry and Remote Sensing, + p. 99-118. + + Gesch, D., Oimoen, M., Greenlee, S., Nelson, C., Steuck, M., and Tyler, D., 2002, + The National Elevation Dataset: Photogrammetric Engineering and Remote Sensing, + v. 68, no. 1, p. 5-11. } - -\examples{ -image(land.surface) -summary(land.surface) -} - \keyword{datasets} + diff --git a/man/major.roads.Rd b/man/major.roads.Rd index 343fca1..8b51e83 100644 --- a/man/major.roads.Rd +++ b/man/major.roads.Rd @@ -1,30 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{major.roads} - \alias{major.roads} - -\docType{data} - \title{Major Roads} - -\description{ -Major roads in the Wood River Valley and surrounding areas. +\format{An object of SpatialLinesDataFrame class containing 475 Lines. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Idaho Department of Water Resources + (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), + accessed on October 20, 2015 } - -\usage{major.roads} - -\format{ -An object of \code{SpatialLinesDataFrame} class containing 475 \code{Lines}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +major.roads } - -\source{ -Idaho Department of Water Resources (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on October 20, 2015 +\description{ +Major roads in the Wood River Valley and surrounding areas. } - \examples{ -plot(major.roads) +sp::plot(major.roads) str(major.roads@data) -} +} \keyword{datasets} + diff --git a/man/map.labels.Rd b/man/map.labels.Rd index 3f3b13d..712d304 100644 --- a/man/map.labels.Rd +++ b/man/map.labels.Rd @@ -1,39 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{map.labels} - \alias{map.labels} - -\docType{data} - \title{Map Labels} - -\description{ -Map labels in the Wood River Valley and surrounding areas. -} - -\usage{map.labels} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 40 points with the following variables: -\describe{ - \item{label}{is the text to be written.} - \item{cex}{is the character expansion factor.} - \item{col, font}{is the color and font to be used.} - \item{srt}{is the string rotation in degrees.} -} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPointsDataFrame class containing + 40 points with the following variables: + \describe{ + \item{label}{text to be written.} + \item{cex}{character expansion factor} + \item{col,font}{color and font to be used, respectively.} + \item{srt}{string rotation in degrees.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Best estimates of map label locations. } - +\usage{ +map.labels +} +\description{ +Map labels in the Wood River Valley and surrounding areas. +} \examples{ -plot(map.labels, col = "red") +sp::plot(map.labels, col = "red") lab <- cbind(map.labels@coords, map.labels@data) for (i in seq_len(nrow(lab))) { text(lab$x[i], lab$y[i], labels = lab$label[i], cex = lab$cex[i], col = lab$col[i], font = lab$font[i], srt = lab$srt[i]) -}} +} +} \keyword{datasets} + diff --git a/man/misc.locations.Rd b/man/misc.locations.Rd index 87fb580..48234e9 100644 --- a/man/misc.locations.Rd +++ b/man/misc.locations.Rd @@ -1,33 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{misc.locations} - \alias{misc.locations} - -\docType{data} - \title{Miscellaneous Locations} - -\description{ -Miscellaneous locations in the Bellevue triangle area. -} - -\usage{misc.locations} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 3 points with the following variable: -\describe{ - \item{label}{is a description of the point location.} +\format{An object of SpatialPointsDataFrame class containing 3 points + with the following variable: + \describe{ + \item{label}{description of point location.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Idaho Department of Water Resources + (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), + accessed on December 23, 2015 } -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +misc.locations } - -\source{ -Idaho Department of Water Resources (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on December 23, 2015 +\description{ +Miscellaneous locations in the Bellevue triangle area. } - \examples{ -plot(misc.locations, pch = 20, col = "red") +sp::plot(misc.locations, pch = 20, col = "red") text(misc.locations, labels = misc.locations@data$label, pos = 3, cex = 0.6) -} +} \keyword{datasets} + diff --git a/man/misc.seepage.Rd b/man/misc.seepage.Rd index 1061af7..8d49417 100644 --- a/man/misc.seepage.Rd +++ b/man/misc.seepage.Rd @@ -1,32 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{misc.seepage} - \alias{misc.seepage} - -\docType{data} - -\title{Recharge from Miscellaneous Seepage Sites} - -\description{ -Recharge from miscellaneous seepage sites in the Wood River Valley, Idaho. -} - -\usage{misc.seepage} - -\format{ -A \code{data.frame} object with 2 records and the following variables: -\describe{ - \item{RechSite}{is the name of the recharge site, see \code{\link{bellevue.wwtp.ponds}} and \code{\link{bypass.canal}} datasets.} - \item{199501, \dots, 201012}{is the monthly volume of recharge during a stress period, in cubic meters. - The variable name is specified as year and month.} -} -} - +\title{Direct Recharge from Miscellaneous Seepage Sites} +\format{An object of data.frame class with 2 records and the following variables: + \describe{ + \item{RechSite}{name of the recharge site, see \code{\link{bellevue.wwtp.ponds}} and + \code{\link{bypass.canal}} datasets.} + \item{199501,\dots,201012}{monthly volume of recharge during a stress period, in cubic meters. + The variable name is specified as year and month.} + }} \source{ Idaho Department of Water Resources, accessed on January 15, 2015 } - +\usage{ +misc.seepage +} +\description{ +Direct recharge from miscellaneous seepage sites in the Wood River Valley, Idaho. +} \examples{ str(misc.seepage) -} +} \keyword{datasets} + diff --git a/man/obs.wells.Rd b/man/obs.wells.Rd index 7a4c3d0..c5cd86f 100644 --- a/man/obs.wells.Rd +++ b/man/obs.wells.Rd @@ -1,57 +1,57 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{obs.wells} - \alias{obs.wells} - -\docType{data} - \title{Observation Wells} - -\description{ -Observation wells in the Wood River Valley aquifer system. -} - -\usage{obs.wells} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 776 points with the following variables: -\describe{ - \item{id}{a unique well identifier used in this study.} - \item{SiteNo}{a unique well identifier within the National Water Information System (NWIS).} - \item{SITEIDIDWR}{a unique well identifier within the Idaho Department of Water Resources (IDWR) hydrologic database.} - \item{WELLNUMBER}{the USGS or IDWR site name for the well.} - \item{PESTNAME}{a unique well identifier for PEST.} - \item{METHODDRIL}{the drilling method.} - \item{TOTALDEPTH}{the depth at which drilling stopped, in feet.} - \item{OPENINGMIN}{the top of the screened interval, in feet.} - \item{OPENINGMAX}{the bottom of the screened interval, in feet.} - \item{COMPLETION}{the date on which the well drilling and construction stopped.} - \item{WCWELLID}{the well construction well identifier.} - \item{ALTITUDE}{the land surface elevation, in feet.} - \item{ALTMETHOD}{the method for obtaining the land surface elevation.} - \item{XYMETHOD}{the method of obtaining the spatial coordinates.} - \item{BASINNO}{the basin number.} - \item{COUNTYNAME}{the Idaho county name.} - \item{TWPRGE}{the township and range the well is located in.} - \item{SITENAME}{a local name for the well.} - \item{desc}{is a description of the well type.} - \item{TopOpen1}{is the depth to the top of the first open interval in a groundwater well, in meters below land surface.} - \item{BotOpen1}{is the depth to the bottom of the first open interval in a groundwater well, in meters below land surface.} - \item{TopOpen2}{is not applicable.} - \item{BotOpen2}{is not applicable.} +\format{An object of SpatialPointsDataFrame class containing 776 points + with the following variables: + \describe{ + \item{id}{unique well identifier used in this study.} + \item{SiteNo}{unique well identifier within the + National Water Information System (NWIS).} + \item{SITEIDIDWR}{unique well identifier within the + Idaho Department of Water Resources (IDWR) hydrologic database.} + \item{WELLNUMBER}{USGS or IDWR site name for the well.} + \item{PESTNAME}{unique well identifier for PEST.} + \item{METHODDRIL}{drilling method} + \item{TOTALDEPTH}{depth at which drilling stopped, in feet.} + \item{OPENINGMIN}{top of the screened interval, in feet.} + \item{OPENINGMAX}{bottom of the screened interval, in feet.} + \item{COMPLETION}{date on which the well drilling and construction stopped.} + \item{WCWELLID}{well construction well identifier.} + \item{ALTITUDE}{land surface elevation, in feet.} + \item{ALTMETHOD}{method for obtaining the land surface elevation.} + \item{XYMETHOD}{method of obtaining the spatial coordinates.} + \item{BASINNO}{basin number} + \item{COUNTYNAME}{Idaho county name} + \item{TWPRGE}{township and range the well is located in.} + \item{SITENAME}{local name for well.} + \item{desc}{description of well type.} + \item{TopOpen1}{depth to the top of the first open interval in a groundwater well, + in meters below land surface.} + \item{BotOpen1}{depth to the bottom of the first open interval in a groundwater well, + in meters below land surface.} + \item{TopOpen2}{not applicable} + \item{BotOpen2}{not applicable} + }} +\source{ +Idaho Department of Water Resources well construction database, + accessed on June 29, 2015 } -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +obs.wells } - -\source{ -IDWR well construction database, accessed on June 29, 2015 +\description{ +Observation wells in the Wood River Valley aquifer system. } - -\seealso{\code{\link{obs.wells.head}}} - \examples{ -plot(obs.wells) +sp::plot(obs.wells) str(obs.wells@data) -} +} +\seealso{ +\code{\link{obs.wells.head}} +} \keyword{datasets} + diff --git a/man/obs.wells.head.Rd b/man/obs.wells.head.Rd index 20485cf..97af030 100644 --- a/man/obs.wells.head.Rd +++ b/man/obs.wells.head.Rd @@ -1,35 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{obs.wells.head} - \alias{obs.wells.head} - -\docType{data} - \title{Hydraulic Heads in Observation Wells} - -\description{ -Hydraulic-head (groundwater-level) measurements recorded in observation wells in the Wood River Valley aquifer system. -Values are used as observations during the parameter estimation process. -} - -\usage{obs.wells.head} - -\format{ -A \code{data.frame} object with 3,477 records and the following variables: -\describe{ - \item{PESTNAME}{is a unique well identifier for PEST.} - \item{DateTime}{is the date and time when the measurement was recorded.} - \item{Head}{is the groundwater-level measurement (hydraulic head) in meters above NAVD 88.} -} -} - +\format{An object of class data.frame with 3,477 records and the following variables: + \describe{ + \item{PESTNAME}{unique well identifier for PEST.} + \item{DateTime}{date and time when the measurement was recorded.} + \item{Head}{groundwater-level measurement (hydraulic head) + in meters above the North American Vertical Datum of 1988 (NAVD 88).} + }} \source{ Idaho Department of Water Resources, accessed on June 26, 2015 } - -\seealso{\code{\link{obs.wells}}} - +\usage{ +obs.wells.head +} +\description{ +Hydraulic-head (groundwater-level) measurements recorded in observation wells in the +Wood River Valley aquifer system. +Values are used as observations during the parameter estimation process. +} \examples{ str(obs.wells.head) -} +} +\seealso{ +\code{\link{obs.wells}} +} \keyword{datasets} + diff --git a/man/pilot.points.Rd b/man/pilot.points.Rd index c970919..78442cb 100644 --- a/man/pilot.points.Rd +++ b/man/pilot.points.Rd @@ -1,36 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{pilot.points} - \alias{pilot.points} - -\docType{data} - \title{Pilot Points} - -\description{ -Location of pilot points in the model domain. -} - -\usage{pilot.points} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 106 points with the following variables: -\describe{ - \item{Layer}{is the model layer.} - \item{Zone}{is the kriging zone.} -} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPointsDataFrame class containing 106 points + with the following variables: + \describe{ + \item{Layer}{model layer} + \item{Zone}{kriging-zone identifier} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on June 11, 2015 } - -\seealso{\code{\link{kriging.zones}}} - +\usage{ +pilot.points +} +\description{ +Location of pilot points in the model domain. +} \examples{ -plot(pilot.points) +sp::plot(pilot.points) str(pilot.points@data) -} +} +\seealso{ +\code{\link{kriging.zones}} +} \keyword{datasets} + diff --git a/man/pod.gw.Rd b/man/pod.gw.Rd index 0e4fe78..b270957 100644 --- a/man/pod.gw.Rd +++ b/man/pod.gw.Rd @@ -1,39 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{pod.gw} - \alias{pod.gw} - -\docType{data} - \title{Points of Diversion for Groundwater} - -\description{ -Points of diversion for groundwater within the Wood River Valley model study area. -} - -\usage{pod.gw} - -\format{ -A \code{data.frame} object with 1,755 records and the following variables: -\describe{ - \item{WMISNumber}{is a unique number assigned to a water right point of diversion.} - \item{WaterRight}{is a number identifying a specific authorization to use water in a prescribed manner.} - \item{EntityName}{is the name of the irrigation entity the point of diversion is assigned to.} - \item{EntitySrce}{is the source of water for an irrigation entity. - Possible sources of water include surface water, groundwater and mixed. - Mixed source entities derive water from both groundwater and surface water.} - \item{Pdate}{is the priority date, the date the water right was established.} - \item{IrrRate}{is the irrigation rate in cubic meters per day, the maximum permitted water use rate associated with a water right.} +\format{An object of class data.frame with 1,755 records and the following variables: + \describe{ + \item{WMISNumber}{unique number assigned to a water right point of diversion.} + \item{WaterRight}{number identifying a specific authorization to use + water in a prescribed manner.} + \item{EntityName}{name of the irrigation entity the point of diversion is assigned to.} + \item{EntitySrce}{source of water for an irrigation entity. + Possible sources of water include surface water, groundwater and mixed. + Mixed source entities derive water from both groundwater and surface water.} + \item{Pdate}{priority date, the date the water right was established.} + \item{IrrRate}{irrigation rate in cubic meters per day, + the maximum permitted water use rate associated with a water right.} + }} +\source{ +Idaho Department of Water Resources water rights database, + accessed on December 11, 2014 } +\usage{ +pod.gw } - -\source{ -Idaho Department of Water Resources water rights database, accessed on December 11, 2014 +\description{ +Points of diversion for groundwater within the Wood River Valley model study area. } - -\seealso{\code{\link{pod.wells}}} - \examples{ summary(pod.gw) -} +} +\seealso{ +\code{\link{pod.wells}} +} \keyword{datasets} + diff --git a/man/pod.wells.Rd b/man/pod.wells.Rd index d5b0721..5d07524 100644 --- a/man/pod.wells.Rd +++ b/man/pod.wells.Rd @@ -1,40 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{pod.wells} - \alias{pod.wells} - -\docType{data} - \title{Well Completions} - -\description{ -Well completions for pumping wells in the Wood River Valley aquifer system. -} - -\usage{pod.wells} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 1,243 points with the following variables: -\describe{ - \item{WMISNumber}{is a unique number assigned to a water right point of diversion.} - \item{WellUse}{is the permitted use(s) for a groundwater well.} - \item{TopOpen1}{is the depth to the top of the first open interval in a groundwater well, in meters below land surface.} - \item{BotOpen1}{is the depth to the bottom of the first open interval in a groundwater well, in meters below land surface.} - \item{TopOpen2}{is the depth to the top of the second open interval in a groundwater well, in meters below land surface.} - \item{BotOpen2}{is the depth to the bottom of the second open interval in a groundwater well, in meters below land surface.} +\format{An object of SpatialPointsDataFrame class containing 1,243 points + with the following variables: + \describe{ + \item{WMISNumber}{is a unique number assigned to a water right point of diversion.} + \item{WellUse}{permitted use(s) for a groundwater well.} + \item{TopOpen1}{depth to the top of the first open interval in a groundwater well, + in meters below land surface.} + \item{BotOpen1}{depth to the bottom of the first open interval in a groundwater well, + in meters below land surface.} + \item{TopOpen2}{depth to the top of the second open interval in a groundwater well, + in meters below land surface.} + \item{BotOpen2}{depth to the bottom of the second open interval in a groundwater well, + in meters below land surface.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Idaho Department of Water Resources water rights database, + accessed on November 29, 2014 } -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +pod.wells } - -\source{ -Idaho Department of Water Resources water rights database, accessed on November 29, 2014 +\description{ +Well completions for pumping wells in the Wood River Valley aquifer system. } - -\seealso{\code{\link{pod.gw}}} - \examples{ -plot(pod.wells) +sp::plot(pod.wells) str(pod.wells@data) -} +} +\seealso{ +\code{\link{pod.gw}} +} \keyword{datasets} + diff --git a/man/precip.zones.Rd b/man/precip.zones.Rd index 4fdc583..f6559c2 100644 --- a/man/precip.zones.Rd +++ b/man/precip.zones.Rd @@ -1,46 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{precip.zones} - \alias{precip.zones} - -\docType{data} - \title{Precipitation Zones} - -\description{ -Precipitation zones specified for the Wood River Valley and surrounding areas. -There are three precipitation zones, each containing a single weather station. -Precipitation zones were distributed to maintain the geographic similarity between weather stations and zones. -} - -\usage{precip.zones} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing 3 \code{Polygons} and a \code{data.frame} with the following variables: -\describe{ - \item{ID}{a numeric identifier assigned to the polygon.} - \item{PrecipZone}{the name of the precipitation zone: - \dQuote{Ketchum}, the northernmost zone with data from the Ketchum National Weather Service coop weather station. - \dQuote{Hailey}, the central zone with data from the Hailey 3NNW National Weather Service coop weather station. - \dQuote{Picabo}, the southernmost zone with data from the Picabo AgriMet weather station. +\format{An object of SpatialPolygonsDataFrame class containing 3 Polygons and a + data.frame with the following variables: + \describe{ + \item{ID}{numeric identifier assigned to the polygon.} + \item{PrecipZone}{name of the precipitation zone: + \dQuote{Ketchum}, the northernmost zone with data from the + Ketchum National Weather Service coop weather station. + \dQuote{Hailey}, central zone with data from the + Hailey 3NNW National Weather Service coop weather station. + \dQuote{Picabo}, southernmost zone with data from the + Picabo AgriMet weather station.} } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Created using the northing midpoint between weather stations, + see \code{\link{weather.stations}} dataset. } -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +precip.zones } - -\source{ -Created using the northing midpoint between weather stations, see \code{\link{weather.stations}} dataset. +\description{ +Precipitation zones specified for the Wood River Valley and surrounding areas. +There are three precipitation zones, each containing a single weather station. +Precipitation zones were distributed to maintain the geographic similarity between +weather stations and zones. } - -\seealso{\code{\link{precipitation}}} - \examples{ col <- c("#D1F2A5", "#FFC48C", "#F56991") -plot(precip.zones, col = col) +sp::plot(precip.zones, col = col) legend("topright", legend = precip.zones@data$PrecipZone, fill = col, bty = "n") -plot(alluvium.extent, add = TRUE) +sp::plot(alluvium.extent, add = TRUE) print(precip.zones) -} +} +\seealso{ +\code{\link{precipitation}} +} \keyword{datasets} + diff --git a/man/precipitation.Rd b/man/precipitation.Rd index 9b2fa01..98f6ae5 100644 --- a/man/precipitation.Rd +++ b/man/precipitation.Rd @@ -1,44 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{precipitation} - \alias{precipitation} - -\docType{data} - \title{Precipitation Rate} - -\description{ -Precipitation rates in the Wood River Valley and surrounding areas. -} - -\usage{precipitation} - -\format{ -A \code{data.frame} object with 582 records and the following variables: -\describe{ - \item{YearMonth}{is the year and month during which precipitation were recorded, with a required date format of \code{YYYYMM}.} - \item{PrecipZone}{the name of the precipitation zone, see \code{\link{precip.zones}} dataset for details.} - \item{Precip}{is the monthly depth of precipitation accounting for spring melt, in meters.} - \item{Precip.raw}{is the monthly depth of precipitation recorded at the weather station, in meters.} -} -} - +\format{An object of data.frame class with 582 records and the following variables: + with the following variables: + \describe{ + \item{YearMonth}{year and month during which precipitation were recorded, + with a required date format of \code{YYYYMM}.} + \item{PrecipZone}{name of the precipitation zone, + see \code{\link{precip.zones}} dataset for details.} + \item{Precip}{monthly depth of precipitation accounting for spring melt, in meters.} + \item{Precip.raw}{monthly depth of precipitation recorded at the weather station, + in meters.} + }} \source{ Idaho Department of Water Resources, accessed on April 24, 2015 } - -\seealso{\code{\link{precip.zones}}, \code{\link{swe}}} - -\references{ -National Oceanic and Atmospheric Administration's National Weather Service (\href{http://www.nws.noaa.gov/om/coop/}{NWS}) Cooperative Observer Program - -U.S. Bureau of Reclamation's Cooperative Agricultural Weather Network (\href{http://www.usbr.gov/pn/agrimet/}{AgriMet}) +\usage{ +precipitation +} +\description{ +Precipitation rates in the Wood River Valley and surrounding areas. } - \examples{ str(precipitation) d <- precipitation -d <- data.frame(Date = as.Date(paste0(d$YearMonth, "15"), format = "\%Y\%m\%d"), +d <- data.frame(Date = as.Date(paste0(d$YearMonth, "15"), format = "\\\%Y\\\%m\\\%d"), Precip = d$Precip) zones <- c("Hailey", "Ketchum", "Picabo") d1 <- d[precipitation$PrecipZone == zones[1], ] @@ -48,11 +38,22 @@ d <- merge(merge(d1, d2, by = "Date"), d3, by = "Date") col <- c("red", "blue", "green") ylab <- paste("Precipitation in", c("meters", "feet")) -PlotGraph(d, ylab = ylab, col = col, lty = 1:3, conversion.factor = 3.28084) +inlmisc::PlotGraph(d, ylab = ylab, col = col, lty = 1:3, conversion.factor = 3.28084) legend("topright", zones, col = col, lty = 1:3, inset = 0.02, cex = 0.7, box.lty = 1, bg = "#FFFFFFE7") graphics.off() + } +\references{ +National Oceanic and Atmospheric Administration's National Weather Service + (\href{http://www.nws.noaa.gov/om/coop/}{NWS}) Cooperative Observer Program + U.S. Bureau of Reclamation's Cooperative Agricultural Weather Network + (\href{http://www.usbr.gov/pn/agrimet/}{AgriMet}) +} +\seealso{ +\code{\link{precip.zones}}, \code{\link{swe}} +} \keyword{datasets} + diff --git a/man/priority.cuts.Rd b/man/priority.cuts.Rd index aa460f5..bc6cbdc 100644 --- a/man/priority.cuts.Rd +++ b/man/priority.cuts.Rd @@ -1,33 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{priority.cuts} - \alias{priority.cuts} - -\docType{data} - \title{Priority Cuts} - -\description{ -Priority cut dates applied to Big Wood River above Magic Reservoir and Silver Creek by Water District 37 and 37M at the end of each month. -} - -\usage{priority.cuts} - -\format{ -A \code{data.frame} object with 112 records and the following variables: -\describe{ - \item{YearMonth}{is the year and month during of the priority cut date, with a required date format of \code{YYYYMM}.} - \item{Pdate_BWR}{is the date of the priority cut applied to Big Wood River above Magic Reservoir by Water District 37.} - \item{Pdate_SC}{is the date of the priority cut applied to Silver Creek by Water District 37M.} -} -} - +\format{An object of data.frame class with 112 records + and the following variables: + \describe{ + \item{YearMonth}{year and month during of the priority cut date, + with a required date format of YYYYMM.} + \item{Pdate_BWR}{date of the priority cut applied to + Big Wood River above Magic Reservoir by Water District 37.} + \item{Pdate_SC}{date of the priority cut applied to + Silver Creek by Water District 37M.} + }} \source{ Idaho Department of Water Resources, accessed on November 17, 2014; -compiled priority cut dates in effect at the end of each month, derived from Water District 37 and 37M records + compiled priority cut dates in effect at the end of each month, + derived from Water District 37 and 37M records. +} +\usage{ +priority.cuts +} +\description{ +Priority cut dates applied to Big Wood River above Magic Reservoir and +Silver Creek by Water District 37 and 37M at the end of each month. } - \examples{ str(priority.cuts) -} +} \keyword{datasets} + diff --git a/man/public.parcels.Rd b/man/public.parcels.Rd index 329db6c..dec2fd8 100644 --- a/man/public.parcels.Rd +++ b/man/public.parcels.Rd @@ -1,29 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{public.parcels} - \alias{public.parcels} - -\docType{data} - \title{Public Land Parcels} - -\description{ -Non-irrigated public land parcels in the Wood River Valley and surrounding areas. -} - -\usage{public.parcels} - -\format{ -An object of \code{SpatialPolygons} class containing 669 \code{Polygons}. -} - +\format{An object of SpatialPolygons class containing 669 Polygons. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on November 29, 2014; -derived from Blaine County tax lots and aerial photography + derived from Blaine County tax lots and aerial photography. +} +\usage{ +public.parcels +} +\description{ +Non-irrigated public land parcels in the Wood River Valley and surrounding areas. } - \examples{ -plot(public.parcels) +sp::plot(public.parcels) print(public.parcels) -} +} \keyword{datasets} + diff --git a/man/r.canals.Rd b/man/r.canals.Rd index 7370eb5..d7b3928 100644 --- a/man/r.canals.Rd +++ b/man/r.canals.Rd @@ -1,35 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{r.canals} - \alias{r.canals} - -\docType{data} - \title{Rasterized Canals} - -\description{ -Canal systems of the Wood River Valley and surrounding areas transferred to raster cells. -} - -\usage{r.canals} - -\format{ -An object of \code{RasterLayer} class with indexed cell values linked to a raster attribute table (RAT). -The RAT is a \code{data.frame} with the following components: -\describe{ - \item{ID}{the integer cell index.} - \item{COUNT}{the frequency of the cell index in the raster grid.} - \item{EntityName}{the name of the irrigation entity served by the canal system.} +\format{An object of RasterLayer class with indexed cell values linked to + a raster attribute table (RAT). + The RAT is a \code{data.frame} with the following components: + \describe{ + \item{ID}{cell index} + \item{COUNT}{frequency of the cell index in the raster grid.} + \item{EntityName}{name of the irrigation entity served by the canal system.} + }} +\source{ +Calculated by transferring the \code{\link{canals}} dataset to grid cells in the + \code{\link{land.surface}} dataset using the \code{rasterize} function; + see the appendix C. Package Dataset Creation for the \R code used in this calculation. } +\usage{ +r.canals } - -\source{ -Calculated by transferring the \code{\link{canals}} dataset to grid cells in the \code{\link{land.surface}} dataset using the \code{rasterize} function; -see the \file{package-datasets} vignette for the \R code used in this calculation. +\description{ +Canal systems of the Wood River Valley and surrounding areas transferred to raster cells. } - \examples{ -plot(r.canals) +sp::plot(r.canals) print(levels(r.canals)[[1]]) -} +} \keyword{datasets} + diff --git a/man/reach.recharge.Rd b/man/reach.recharge.Rd index dd1625b..6dd21ec 100644 --- a/man/reach.recharge.Rd +++ b/man/reach.recharge.Rd @@ -1,42 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{reach.recharge} - \alias{reach.recharge} - -\docType{data} - \title{Stream-Aquifer Flow Exchange Along River Reaches} - +\format{An object of \code{data.frame} class with 192 records and the following variables: + \describe{ + \item{YearMonth}{year and month of the measurement record, + with a required date format of \code{YYYYMM}.} + \item{nKet_Hai}{stream-aquifer flow exchange in the Big Wood River, + near Ketchum to Hailey river reach, in cubic meters per day.} + \item{Hai_StC}{stream-aquifer flow exchange in the Big Wood River, + Hailey to Stanton Crossing river reach, in cubic meters per day.} + \item{WillowCr}{stream-aquifer flow exchange in the Willow Creek river reach, + in cubic meters per day.} + \item{SilverAbv}{stream-aquifer flow exchange in Silver Creek, + above Sportsman Access river reach, in cubic meters per day.} + \item{SilverBlw}{stream-aquifer flow exchange in Silver Creek, + Sportsman Access to near Picabo river reach, in cubic meters per day.} + }} +\source{ +Calculated from continuous stream flow measurements, diversion data, + return flow data, and exchange well data using a flow difference method to + estimate groundwater inflows and outflows along a river reach, + accessed on September 1, 2015. + Derived from U.S. Geological Survey, Idaho Power Company, + and Water District 37 and 37M records. +} +\usage{ +reach.recharge +} \description{ Stream-aquifer flow exchange along river reaches specified as aquifer recharge. Values used as observations in parameter estimation. } - -\usage{reach.recharge} - -\format{ -A \code{data.frame} object with 192 records and the following variables: -\describe{ - \item{YearMonth}{is the year and month of the measurement record, with a required date format of \code{YYYYMM}.} - \item{nKet_Hai}{the stream-aquifer flow exchange in the Big Wood River, near Ketchum to Hailey river reach, in cubic meters per day.} - \item{Hai_StC}{the stream-aquifer flow exchange in the Big Wood River, Hailey to Stanton Crossing river reach, in cubic meters per day.} - \item{WillowCr}{the stream-aquifer flow exchange in the Willow Creek river reach, in cubic meters per day.} - \item{SilverAbv}{the stream-aquifer flow exchange in Silver Creek, above Sportsman Access river reach, in cubic meters per day.} - \item{SilverBlw}{the stream-aquifer flow exchange in Silver Creek, Sportsman Access to near Picabo river reach, in cubic meters per day.} -} -} - \details{ -A positive stream-aquifer flow exchange indicates aquifer recharge (a losing river reach). -} - -\source{ -Calculated from continuous stream flow measurements, diversion data, return flow data, and exchange well data -using a flow difference method to estimate groundwater inflows and outflows along a river reach, accessed on September 1, 2015. -Derived from U.S. Geological Survey, Idaho Power Company, and Water District 37 and 37M records. +A positive stream-aquifer flow exchange indicates aquifer recharge + (a losing river reach). } - \examples{ str(reach.recharge) -} +} \keyword{datasets} + diff --git a/man/river.reaches.Rd b/man/river.reaches.Rd index 8741bc9..48e88ef 100644 --- a/man/river.reaches.Rd +++ b/man/river.reaches.Rd @@ -1,40 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{river.reaches} - \alias{river.reaches} - -\docType{data} - \title{Major River Reaches} - -\description{ -The major river reaches of the Wood River Valley, Idaho. -} - -\usage{river.reaches} - -\format{ -An object of \code{SpatialLinesDataFrame} class containing 22 \code{Lines} and a \code{data.frame} with the following variables: -\describe{ - \item{Reach}{is the name of the subreaches measured in U.S. Geological Survey (USGS) seepage survey.} - \item{BigReach}{is the name of the reaches for which time series targets are available for part or all of the calibration period.} - \item{DrainRiver}{is the model boundary assignment, either \dQuote{drain} or \dQuote{river}.} - \item{RchAvg}{is the estimated average reach gain in cubic meters per day for 1995-2010 based on a combination of gage data and the USGS seepage survey.} - \item{BigRAv}{is the estimated average reach gain in cubic meters per day for 1995-2010 based on gage data.} - \item{ReachNo}{is the reach number identifier.} - \item{Depth}{is the estimated average depth in meters of water in reach, measured from the air-water interface to the top of the riverbed sediments.} - \item{BedThk}{is the estimated thickness in meters of the saturated riverbed sediments.} -} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialLinesDataFrame class containing 22 Lines and a + data.frame with the following variables: + \describe{ + \item{Reach}{name of the subreaches measured in U.S. Geological Survey (USGS) + seepage survey.} + \item{BigReach}{name of the reaches for which time series targets are available for + part or all of the calibration period.} + \item{DrainRiver}{model boundary assignment, either \dQuote{drain} or \dQuote{river}.} + \item{RchAvg}{estimated average reach gain in cubic meters per day for 1995-2010 + based on a combination of gage data and the USGS seepage survey.} + \item{BigRAv}{estimated average reach gain in cubic meters per day for 1995-2010 + based on gage data.} + \item{ReachNo}{reach number identifier.} + \item{Depth}{estimated average depth in meters of water in reach, + measured from the air-water interface to the top of the riverbed sediments.} + \item{BedThk}{estimated thickness in meters of the saturated riverbed sediments.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on June 6, 2015 } - +\usage{ +river.reaches +} +\description{ +Major river reaches of the Wood River Valley, Idaho. +} \examples{ -plot(river.reaches) +sp::plot(river.reaches) str(river.reaches@data) -} +} \keyword{datasets} + diff --git a/man/rs.entities.Rd b/man/rs.entities.Rd index fea0497..3f39ae3 100644 --- a/man/rs.entities.Rd +++ b/man/rs.entities.Rd @@ -1,37 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{rs.entities} - \alias{rs.entities} - -\docType{data} - \title{Rasterized Monthly Irrigation Entities} - -\description{ -Irrigation entities of the Wood River Valley and surrounding areas transferred to raster cells. -} - -\usage{rs.entities} - -\format{ -An object of class \code{RasterStack} class containing a 192 \code{RasterLayer} objects, one layer for each month in the 1995-2010 time period. -For each raster layer, indexed cell values are linked to a raster attribute table (RAT). -The RAT is a \code{data.frame} with the following components: -\describe{ - \item{ID}{the integer cell index.} - \item{COUNT}{the frequency of the cell index in the raster grid.} - \item{EntityName}{the name of the irrigation entity served by a group of diversions.} +\format{An object of RasterStack class containing a 192 RasterLayer objects, + one layer for each month in the 1995-2010 time period. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). + For each raster layer, indexed cell values are linked to a raster attribute table (RAT). + The RAT is an object of data.frame class with the following components: + \describe{ + \item{ID}{cell index} + \item{COUNT}{frequency of the cell index in the raster grid.} + \item{EntityName}{name of the irrigation entity served by a group of diversions.} + }} +\source{ +Calculated by transferring the \code{\link{entity.components}} dataset to grid cells + in the \code{\link{land.surface}} dataset using the rasterize function; + see the appendix C. Package Dataset Creation for the \R code used in this calculation. } +\usage{ +rs.entities } - -\source{ -Calculated by transferring the \code{\link{entity.components}} dataset to grid cells in the \code{\link{land.surface}} dataset using the \code{rasterize} function; -see the \file{package-datasets} vignette for the \R code used in this calculation. +\description{ +Irrigation entities of the Wood River Valley and surrounding areas transferred to raster cells. } - \examples{ names(rs.entities) -plot(rs.entities[["199507"]]) +sp::plot(rs.entities[["199507"]]) print(levels(rs.entities[["199507"]])[[1]]) -} +} \keyword{datasets} + diff --git a/man/rs.rech.non.irr.Rd b/man/rs.rech.non.irr.Rd index f7ccc82..d7e52f4 100644 --- a/man/rs.rech.non.irr.Rd +++ b/man/rs.rech.non.irr.Rd @@ -1,30 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{rs.rech.non.irr} - \alias{rs.rech.non.irr} - -\docType{data} - \title{Rasterized Monthly Recharge on Non-Irrigated Lands} - -\description{ -Aerial recharge and discharge on non-irrigated lands of the Wood River Valley and surrounding areas transferred to raster cells. +\format{An object of RasterStack class containing 192 RasterLayer objects, + one layer for each month in the 1995-2010 time period. + Each cell on a layers surface grid represents the monthly recharge in meters. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Calculated from the \code{\link{et}}, \code{\link{precipitation}}, + \code{\link{precip.zones}}, and \code{\link{soils}} datasets; + see the appendix C. Package Dataset Creation for the \R code used in this calculation. } - -\usage{rs.rech.non.irr} - -\format{ -An object of \code{RasterStack} class containing 192 \code{RasterLayer} objects, one layer for each month in the 1995-2010 time period. -Each cell on a layers surface grid represents the monthly recharge in meters. +\usage{ +rs.rech.non.irr } - -\source{ -Calculated from the \code{et}, \code{\link{precipitation}}, \code{\link{precip.zones}}, and \code{\link{soils}} datasets; -see the \file{package-datasets} vignette for the \R code used in this calculation. +\description{ +Aerial recharge and discharge on non-irrigated lands of the Wood River Valley and +surrounding areas transferred to raster cells. } - \examples{ names(rs.rech.non.irr) -plot(rs.rech.non.irr[["199507"]]) -} +sp::plot(rs.rech.non.irr[["199507"]]) +} \keyword{datasets} + diff --git a/man/seepage.study.Rd b/man/seepage.study.Rd index 33f7db0..b7b4c56 100644 --- a/man/seepage.study.Rd +++ b/man/seepage.study.Rd @@ -1,45 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{seepage.study} - \alias{seepage.study} - -\docType{data} - \title{Stream Seepage Study} - -\description{ -A Wood River Valley stream seepage study with streamflow measurements made during the months of August 2012, October 2012, and March 2013. +\format{An object of SpatialPointsDataFrame class containing 82 points + with the following variables: + \describe{ + \item{Order}{index used to preserve the downstream order of measurement sites.} + \item{Name}{local name for the measurement site.} + \item{SiteNo}{unique identifier for the measurement site within the + National Water Information System (NWIS).} + \item{Type}{the type of measurement site: + \dQuote{Big Wood River}, \dQuote{Willow Creek}, \dQuote{Spring fed creeks}, + \dQuote{Silver Creek}, \dQuote{Diversion}, \dQuote{Exchange well inflow}, + \dQuote{Return}, and \dQuote{Tributary}.} + \item{Comments}{abbreviated site name} + \item{Aug}{volumetric flow rate measured during August 2012, in cubic meters per day.} + \item{Oct}{volumetric flow rate measured during October 2012, in cubic meters per day.} + \item{Mar}{volumetric flow rate measured during March 2013, in cubic meters per day.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Derived from Bartolino (2014) seepage study, + Idaho Department of Water Resources, Water District 37 and 37M flow records. } - -\usage{seepage.study} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 82 points with the following variables: -\describe{ - \item{Order}{an index used to preserve the downstream order of measurement sites.} - \item{Name}{a local name for the measurement site.} - \item{SiteNo}{a unique identifier for the measurement site within the National Water Information System (NWIS).} - \item{Type}{the type of measurement site: - \dQuote{Big Wood River}, \dQuote{Willow Creek}, \dQuote{Spring fed creeks}, \dQuote{Silver Creek}, \dQuote{Diversion}, \dQuote{Exchange well inflow}, \dQuote{Return}, and \dQuote{Tributary}.} - \item{Comments}{an abbreviated site name.} - \item{Aug}{the volumetric flow rate measured during August 2012, in cubic meters per day.} - \item{Oct}{the volumetric flow rate measured during October 2012, in cubic meters per day.} - \item{Mar}{the volumetric flow rate measured during March 2013, in cubic meters per day.} +\usage{ +seepage.study } -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\description{ +A Wood River Valley stream seepage study with streamflow measurements made during +the months of August 2012, October 2012, and March 2013. } +\examples{ +sp::plot(seepage.study) +str(seepage.study@data) -\source{ -Derived from Bartolino (2014) seepage study, Idaho Department of Water Resources, Water District 37 and 37M flow records. } - \references{ -Bartolino, J.R., 2014, Stream seepage and groundwater levels, Wood River Valley, south-central Idaho, 2012--13: U.S. Geological Survey Scientific Investigations Report 2014-5151, 34 p., \url{http://dx.doi.org/10.3133/sir20145151}. -} - -\examples{ -plot(seepage.study) -str(seepage.study@data) +Bartolino, J.R., 2014, Stream seepage and groundwater levels, Wood River Valley, + south-central Idaho, 2012--13: U.S. Geological Survey Scientific Investigations Report 2014-5151, + 34 p., \url{http://dx.doi.org/10.3133/sir20145151}. } - \keyword{datasets} + diff --git a/man/sensitivity.Rd b/man/sensitivity.Rd index 367900a..3f5be83 100644 --- a/man/sensitivity.Rd +++ b/man/sensitivity.Rd @@ -1,44 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{sensitivity} - \alias{sensitivity} - -\docType{data} - \title{PEST Sensitivity} - -\description{ -Calibrated parameter values and composite sensitivities generated by PEST. -} - -\usage{sensitivity} - -\format{ -A \code{data.frame} object with 336 records and the following variables: -\describe{ - \item{parameter.desc}{is a description of the parameter.} - \item{ID}{is a unique identifier within the parameter type, such as an identifier for a pilot point or irrigation entity.} - \item{units}{is the parameter units.} - \item{start.value}{is the starting parameter value prior to model calibration.} - \item{lower.bound}{is the lower bound placed on the parameter value during the model-calibration process.} - \item{upper.bound}{is the upper bound placed on the parameter value during the model-calibration process.} - \item{parameter.name}{is the \href{http://www.pesthomepage.org/}{PEST} parameter name.} - \item{group}{is the PEST parameter group.} - \item{value}{is the calibrated parameter value estimated by PEST.} - \item{comp.sens}{is the composite sensitivity generated during the final iteration of PEST.} - \item{rel.comp.sens}{is the relative composite sensitivity.} -} -} - +\format{An object of data.frame class with 336 records and the following variables: + \describe{ + \item{parameter.desc}{parameter description} + \item{ID}{unique identifier within the parameter type, + such as an identifier for a pilot point or irrigation entity.} + \item{units}{parameter units} + \item{start.value}{starting parameter value prior to model calibration.} + \item{lower.bound}{lower bound placed on the parameter value + during the model-calibration process.} + \item{upper.bound}{upper bound placed on the parameter value + during the model-calibration process.} + \item{parameter.name}{\href{http://www.pesthomepage.org/}{PEST} parameter name} + \item{group}{PEST parameter group} + \item{value}{calibrated parameter value estimated by PEST.} + \item{comp.sens}{composite sensitivity generated during the final iteration of PEST.} + \item{rel.comp.sens}{relative composite sensitivity} + }} \source{ Idaho Department of Water Resources, accessed on January 15, 2016 } - -\seealso{ -\code{\link{pilot.points}}, \code{\link{irr.entities}}, \code{\link{river.reaches}}, \code{\link{drains}}, \code{\link{tributaries}} +\usage{ +sensitivity +} +\description{ +Calibrated parameter values and composite sensitivities generated by PEST. } - \examples{ str(sensitivity) -} +} +\seealso{ +\code{\link{pilot.points}}, \code{\link{irr.entities}}, + \code{\link{river.reaches}}, \code{\link{drains}}, \code{\link{tributaries}} +} \keyword{datasets} + diff --git a/man/soils.Rd b/man/soils.Rd index cb7b179..9d423d5 100644 --- a/man/soils.Rd +++ b/man/soils.Rd @@ -1,40 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{soils} - \alias{soils} - -\docType{data} - \title{Soil Units} - -\description{ -Representation of mapped surficial soil units created by the Idaho Office of the National Resource Conservation Service (NRCS). -Soils have been assigned a percolation rate based on the average, saturated hydraulic conductivity of the soils as classified using the Unified Soil Classification System (USCS). -} - -\usage{soils} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing 718 \code{Polygons} and a \code{data.frame} with the following variables: -\describe{ - \item{GroupSymbol}{is a soil class identifier.} - \item{SoilLayer}{is an identifier used to differentiate the soil data source used to create the soils map. - Data sources are either \sQuote{USCS} or \sQuote{STATSGO}, the NRCS State Soil Geographic Data Base.} - \item{SoilClass}{is a description of the soil class.} - \item{MinRate}{is the lower percolation rate limit for the soil class, in meters per month.} - \item{MaxRate}{is the upper percolation rate limit for the soil class, in meters per month.} - \item{PercolationRate}{is the percolation rate in meters per month.} -} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPolygonsDataFrame class containing 718 Polygons and a + data.frame with the following variables: + \describe{ + \item{GroupSymbol}{soil class identifier} + \item{SoilLayer}{identifier used to differentiate the soil data source + used to create the soils map. + Data sources are either \sQuote{USCS} or \sQuote{STATSGO}, + the NRCS State Soil Geographic Data Base.} + \item{SoilClass}{description of the soil class.} + \item{MinRate}{lower percolation rate limit for the soil class, in meters per month.} + \item{MaxRate}{upper percolation rate limit for the soil class, in meters per month.} + \item{PercolationRate}{percolation rate in meters per month.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on April 22, 2015 } - +\usage{ +soils +} +\description{ +Representation of mapped surficial soil units created by the Idaho Office of the +National Resource Conservation Service (NRCS). +Soils have been assigned a percolation rate based on the average, +saturated hydraulic conductivity of the soils as classified using the +Unified Soil Classification System (USCS). +} \examples{ -spplot(soils, "PercolationRate") +sp::spplot(soils, "PercolationRate") str(soils@data) -} +} \keyword{datasets} + diff --git a/man/streamgages.Rd b/man/streamgages.Rd index 5e7d2c7..20680a5 100644 --- a/man/streamgages.Rd +++ b/man/streamgages.Rd @@ -1,33 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{streamgages} - \alias{streamgages} - -\docType{data} - \title{Streamgages} - -\description{ -Select streamgages in the Wood River Valley. -} - -\usage{streamgages} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 9 points and a \code{data.frame} with the following variable: -\describe{ - \item{SiteNo}{the unique site number for the streamgage.} - \item{SiteName}{the official name of the streamgage.} +\format{An object of SpatialPointsDataFrame class containing 9 points and a + data.frame with the following variable: + \describe{ + \item{SiteNo}{unique site number for the streamgage.} + \item{SiteName}{official name of the streamgage.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +National Water Information System (\href{http://waterdata.usgs.gov/nwis}{NWIS}), + accessed on May 29, 2015. } -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +streamgages } - -\source{ -National Water Information System (\href{http://waterdata.usgs.gov/nwis}{NWIS}), accessed on May 29, 2015. +\description{ +Select streamgages in the Wood River Valley. } - \examples{ str(streamgages) -} +} \keyword{datasets} + diff --git a/man/streams.rivers.Rd b/man/streams.rivers.Rd index 62f239e..bed0ec5 100644 --- a/man/streams.rivers.Rd +++ b/man/streams.rivers.Rd @@ -1,30 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{streams.rivers} - \alias{streams.rivers} - -\docType{data} - \title{Streams and Rivers} - -\description{ -Streams and rivers of the Wood River Valley and surrounding areas. +\format{An object of SpatialLinesDataFrame class containing 581 Lines. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +Idaho Department of Water Resources + (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), + accessed on April 2, 2014 } - -\usage{streams.rivers} - -\format{ -An object of \code{SpatialLinesDataFrame} class containing 581 \code{Lines}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +streams.rivers } - -\source{ -Idaho Department of Water Resources (\href{https://research.idwr.idaho.gov/index.html#GIS-Data}{IDWR}), accessed on April 2, 2014 +\description{ +Streams and rivers of the Wood River Valley and surrounding areas. } - \examples{ -plot(streams.rivers, col = "#3399CC") +sp::plot(streams.rivers, col = "#3399CC") str(streams.rivers@data) -} +} \keyword{datasets} + diff --git a/man/subreach.recharge.Rd b/man/subreach.recharge.Rd index 7251df7..be3bcb8 100644 --- a/man/subreach.recharge.Rd +++ b/man/subreach.recharge.Rd @@ -1,41 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{subreach.recharge} - \alias{subreach.recharge} - -\docType{data} - \title{Stream-Aquifer Flow Exchange Along River Subreaches} - +\format{An object of data.frame class with 19 records and the following variables: + \describe{ + \item{ReachNo}{subreach number identifier} + \item{Reach}{name of the subreach.} + \item{BigReachNo}{reach number identifier} + \item{BigReach}{name of the reach.} + \item{Aug}{estimated volumetric flow rate measured during August 2012, + in cubic meters per day.} + \item{Oct}{estimated volumetric flow rate measured during October 2012, + in cubic meters per day.} + \item{Mar}{estimated volumetric flow rate measured during March 2013, + in cubic meters per day.} + }} +\source{ +Flow values calculated from \code{\link{seepage.study}} data. +} +\usage{ +subreach.recharge +} \description{ Stream-aquifer flow exchange along river subreaches specified as aquifer recharge. Values used as observations in parameter estimation. } - -\usage{subreach.recharge} - -\format{ -A \code{data.frame} object with 19 records and the following variables: -\describe{ - \item{ReachNo}{is the subreach number identifier.} - \item{Reach}{is the name of the subreach.} - \item{BigReachNo}{is the reach number identifier.} - \item{BigReach}{is the name of the reach.} - \item{Aug}{the estimated volumetric flow rate measured during August 2012, in cubic meters per day.} - \item{Oct}{the estimated volumetric flow rate measured during October 2012, in cubic meters per day.} - \item{Mar}{the estimated volumetric flow rate measured during March 2013, in cubic meters per day.} -} -} - \details{ -A positive stream-aquifer flow exchange indicates aquifer recharge (also know as a losing river subreach). -} - -\source{ -Flow values calculated from \code{seepage.study} data. +A positive stream-aquifer flow exchange indicates aquifer recharge + (also know as a losing river subreach). } - \examples{ str(subreach.recharge) -} +} \keyword{datasets} + diff --git a/man/swe.Rd b/man/swe.Rd index 7eb2a59..288f0b6 100644 --- a/man/swe.Rd +++ b/man/swe.Rd @@ -1,35 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{swe} - \alias{swe} - -\docType{data} - \title{Snow Water Equivalent} - -\description{ -Average daily snow water equivalent (SWE) at weather stations in the Wood River Valley and surrounding areas. -} - -\usage{swe} - -\format{ -A \code{data.frame} object with 366 records and the following variables: -\describe{ - \item{MonthDay}{is the month and day, with a required date format of \code{MMDD}.} - \item{Choco}{is the daily SWE recorded at the Chocolate Gulch snow telemetry (SNOTEL) weather station.} - \item{Hailey}{is the daily SWE recorded at the Hailey Ranger Station at Hailey hydrometeorological automated data system (HADS) weather station.} - \item{Picabo}{is the daily SWE recorded at the Picabo PICI HADS weather station.} -} -} - +\format{An object of data.frame class with 366 records and the following variables: + \describe{ + \item{MonthDay}{month and day, with a required date format of \code{MMDD}.} + \item{Choco}{daily SWE recorded at the Chocolate Gulch snow telemetry (SNOTEL) + weather station.} + \item{Hailey}{daily SWE recorded at the Hailey Ranger Station at Hailey + hydrometeorological automated data system (HADS) weather station.} + \item{Picabo}{daily SWE recorded at the Picabo PICI HADS weather station.} + }} \source{ Idaho Department of Water Resources, accessed on April 24, 2015 } - -\seealso{\code{\link{weather.stations}}, \code{\link{precip.zones}}, \code{\link{precipitation}}} - +\usage{ +swe +} +\description{ +Average daily snow water equivalent (SWE) at weather stations in the +Wood River Valley and surrounding areas. +} \examples{ str(swe) -} +} +\seealso{ +\code{\link{weather.stations}}, \code{\link{precip.zones}}, + \code{\link{precipitation}} +} \keyword{datasets} + diff --git a/man/tributaries.Rd b/man/tributaries.Rd index 5b0c78e..92f1fac 100644 --- a/man/tributaries.Rd +++ b/man/tributaries.Rd @@ -1,59 +1,80 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{tributaries} - \alias{tributaries} - -\docType{data} - \title{Tributary Basin Underflow} - -\description{ -The location and average flow conditions for model boundaries in the major tributary canyons and upper part of the Wood River Valley, south-central Idaho. -} - -\usage{tributaries} - -\format{ -An object of \code{SpatialPolygonsDataFrame} class containing a set of 22 \code{Polygons} and a \code{data.frame} with the following variable: -\describe{ - \item{Name}{is the tributary name.} - \item{MinLSD}{is the minimum land-surface datum (elevation) along the transect, in meters above the North American Vertical Datum of 1988 (NAVD 88).} - \item{BdrkDepth}{is the mean saturated thickness along the transect line, in meters; estimated as the distance between the estimated water table and bedrock elevations.} - \item{TribWidth}{is the width of the tributary canyon, or length of the transect line, in meters.} - \item{LandGrad}{is the land surface elevation gradient perpendicular to the cross-sectional transect line, a dimensionless quantity.} - \item{K}{is the hydraulic conductivity, in meters per day.} - \item{SatArea}{is the estimated saturated cross-sectional area, in square meters; its geometry is represented as the lower-half of an ellipse with width and height equal to \code{TribWidth} and \code{BdrkDepth}, respectively.} - \item{DarcyFlow}{is the groundwater flow rate, in cubic meters per day, calculated using a \href{http://en.wikipedia.org/wiki/Darcy_law}{Darcian} analysis.} - \item{BasinArea}{is the land-surface area defined by the basin above the cross-sectional transect line.} - \item{BasinAreaType}{is a label that describes the relative basin size; where \code{"big"} indicates a basin area greater than 10 square miles (25.9 square kilometers), and \code{"small"} indicates a basin area that is less than this breakpoint value.} - \item{PrecipRate}{is the mean precipitation rate within the basin area, in meters per day.} - \item{PrecipFlow}{is the mean precipitation flow rate, in cubic meters per day, calculated by multiplying \code{PrecipRate} by \code{BasinArea}.} - \item{FlowRatio}{is the ratio of darcy flow rate to precipitation flow rate, or \code{DarcyFlow} divided by \code{PrecipFlow}, a dimensionless quantity.} - \item{Flow}{is the estimated average volumetric flow rate, in cubic meters per day.} -} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialPolygonsDataFrame class containing a set of 22 Polygons and a + data.frame with the following variable: + \describe{ + \item{Name}{tributary name} + \item{MinLSD}{minimum land-surface datum (elevation) along the transect, + in meters above the North American Vertical Datum of 1988 (NAVD 88).} + \item{BdrkDepth}{mean saturated thickness along the transect line, in meters; + estimated as the distance between the estimated water table and bedrock elevations.} + \item{TribWidth}{width of the tributary canyon, or length of the transect line, in meters.} + \item{LandGrad}{land surface elevation gradient perpendicular to the + cross-sectional transect line, a dimensionless quantity.} + \item{K}{hydraulic conductivity in meters per day.} + \item{SatArea}{estimated saturated cross-sectional area, in square meters; + its geometry is represented as the lower-half of an ellipse with + width and height equal to \code{TribWidth} and \code{BdrkDepth}, respectively.} + \item{DarcyFlow}{groundwater flow rate, in cubic meters per day, calculated using a + \href{http://en.wikipedia.org/wiki/Darcy_law}{Darcian} analysis.} + \item{BasinArea}{land-surface area defined by the basin above the cross-sectional transect line.} + \item{BasinAreaType}{label that describes the relative basin size; where + \code{"big"} indicates a basin area greater than 10 square miles (25.9 square kilometers), and + \code{"small"} indicates a basin area that is less than this breakpoint value.} + \item{PrecipRate}{mean precipitation rate within the basin area, in meters per day.} + \item{PrecipFlow}{mean precipitation flow rate, in cubic meters per day, + calculated by multiplying \code{PrecipRate} by \code{BasinArea}.} + \item{FlowRatio}{ratio of darcy flow rate to precipitation flow rate, + or \code{DarcyFlow} divided by \code{PrecipFlow}, a dimensionless quantity.} + \item{Flow}{estimated average volumetric flow rate, in cubic meters per day.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ U.S. Geological Survey, accessed on July 2, 2015; -a Keyhole Markup Language (\href{http://en.wikipedia.org/wiki/Kml}{KML}) file created in \href{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in areas of known specified flow boundaries. -Transect lines are defined by the polygon boundaries within the extent of alluvium aquifer (see \code{\link{alluvium.extent}} dataset). -The land surface gradient (\code{LandGrad}) was estimated from the \code{\link{land.surface}} dataset. -Hydraulic conductivity (\code{K}) is the average of two geometric means of hydraulic conductivity in the unconfined aquifer taken from table 2 in Bartolino and Adkins (2012). -The U.S. Geologic Survey \href{http://water.usgs.gov/osw/streamstats/}{StreamStats} tool (Ries and others, 2004) was used to delineate the basin area (\code{BasinArea}) and estimate the precipitation rate (\code{PrecipRate}). -See the \file{package-datasets} vignette for the \R code used to calculate the flow estimates (\code{Flow}). + a Keyhole Markup Language (\href{http://en.wikipedia.org/wiki/Kml}{KML}) file created in + \href{http://www.google.com/earth/}{Google Earth} with polygons drawn by hand in + areas of known specified flow boundaries. + Transect lines are defined by the polygon boundaries within the extent of + alluvium aquifer (see \code{\link{alluvium.extent}} dataset). + The land surface gradient (\code{LandGrad}) was estimated from the + \code{\link{land.surface}} dataset. + Hydraulic conductivity (\code{K}) is the average of two geometric means of hydraulic conductivity + in the unconfined aquifer taken from table 2 in Bartolino and Adkins (2012). + The U.S. Geologic Survey \href{http://water.usgs.gov/osw/streamstats/}{StreamStats} tool + (Ries and others, 2004) was used to delineate the basin area (\code{BasinArea}) and + estimate the precipitation rate (\code{PrecipRate}). + See the appendix C. Package Dataset Creation for the \R code used to calculate the + flow estimates (\code{Flow}). } - -\references{ -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. - -Ries, K.G., Steeves, P.A., Coles, J.D., Rea, A.H., and Stewart, D.W., 2004, StreamStats--A U.S. Geological Survey web application for stream information: U.S. Geological Survey Fact Sheet FS-2004-3115, 4 p., available at \url{http://pubs.er.usgs.gov/usgspubs/fs/fs20043115}. +\usage{ +tributaries +} +\description{ +Location and average flow conditions for model boundaries in the +major tributary canyons and upper part of the Wood River Valley, south-central Idaho. } - \examples{ -plot(tributaries, border = "red") -plot(alluvium.extent, add = TRUE) +sp::plot(tributaries, border = "red") +sp::plot(alluvium.extent, add = TRUE) str(tributaries@data) + } +\references{ +Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the + Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey + Scientific Investigations Report 2012-5053, 46 p., + available at \url{http://pubs.usgs.gov/sir/2012/5053/}. + Ries, K.G., Steeves, P.A., Coles, J.D., Rea, A.H., and Stewart, D.W., 2004, + StreamStats--A U.S. Geological Survey web application for stream information: + U.S. Geological Survey Fact Sheet FS-2004-3115, 4 p., available at + \url{http://pubs.er.usgs.gov/usgspubs/fs/fs20043115}. +} \keyword{datasets} + diff --git a/man/tributary.streams.Rd b/man/tributary.streams.Rd index 06d3b59..a63b509 100644 --- a/man/tributary.streams.Rd +++ b/man/tributary.streams.Rd @@ -1,30 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{tributary.streams} - \alias{tributary.streams} - -\docType{data} - -\title{Streams and Rivers} - -\description{ -Tributary streams of the upper Wood River Valley and surrounding areas. -} - -\usage{tributary.streams} - -\format{ -An object of \code{SpatialLinesDataFrame} class containing 88 \code{Lines}. -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\title{Tributary Streams} +\format{An object of SpatialLinesDataFrame class containing 88 Lines. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ Idaho Department of Water Resources, accessed on June 1, 2015 } - +\usage{ +tributary.streams +} +\description{ +Tributary streams of the upper Wood River Valley and surrounding areas. +} \examples{ -plot(tributary.streams, col = "#3399CC") +sp::plot(tributary.streams, col = "#3399CC") str(tributary.streams@data) -} +} \keyword{datasets} + diff --git a/man/weather.stations.Rd b/man/weather.stations.Rd index af1335c..6e5aa0d 100644 --- a/man/weather.stations.Rd +++ b/man/weather.stations.Rd @@ -1,41 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{weather.stations} - \alias{weather.stations} - -\docType{data} - \title{Weather Stations} - -\description{ -Weather stations in the WRV and surrounding areas. -} - -\usage{weather.stations} - -\format{ -An object of \code{SpatialPointsDataFrame} class containing 5 points and the following variables: -\describe{ - \item{name}{is the name of the weather station.} - \item{id}{is a unique identifier for the weather station.} - \item{type}{is the type of weather stations: - \code{"HADS"}, a Hydrometeorological Automated Data System operated by the National Weather Service Office of Dissemination; - \code{"AgriMet"}, a satellite-telemetry network of automated agricultural weather stations operated and maintained by the Bureau of Reclamation; and - \code{"SNOTEL"}, an automated system of snowpack and related climate sensors operated by the Natural Resources Conservation Service.} - \item{organization}{is the managing organization.} - \item{elevation}{is the elevation of the weather station in meters above the North American Vertical Datum of 1988 (NAVD 88).} +\format{An object of SpatialPointsDataFrame class containing 5 points + and the following variables: + \describe{ + \item{name}{name of the weather station.} + \item{id}{unique identifier for the weather station.} + \item{type}{type of weather stations: + \code{"HADS"}, a Hydrometeorological Automated Data System operated by the + National Weather Service Office of Dissemination; + \code{"AgriMet"}, a satellite-telemetry network of + automated agricultural weather stations operated and + maintained by the Bureau of Reclamation; and + \code{"SNOTEL"}, an automated system of snowpack and + related climate sensors operated by the + Natural Resources Conservation Service.} + \item{organization}{is the managing organization.} + \item{elevation}{is the elevation of the weather station in + meters above the North American Vertical Datum of 1988 (NAVD 88).} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +National Oceanic and Atmospheric Administration (NOAA), + Bureau of Reclamation, Natural Resources Conservation Service (NRCS), + accessed on May 1, 2015 } -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). +\usage{ +weather.stations } - -\source{ -National Oceanic and Atmospheric Administration (NOAA), Bureau of Reclamation, Natural Resources Conservation Service (NRCS), accessed on May 1, 2015 +\description{ +Weather stations in the Wood River Valley and surrounding areas. } - \examples{ -plot(alluvium.extent) -plot(weather.stations, col = "red", add = TRUE) +sp::plot(alluvium.extent) +sp::plot(weather.stations, col = "red", add = TRUE) str(weather.stations@data) -} +} \keyword{datasets} + diff --git a/man/wetlands.Rd b/man/wetlands.Rd index 993cf1c..023115c 100644 --- a/man/wetlands.Rd +++ b/man/wetlands.Rd @@ -1,28 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{wetlands} - \alias{wetlands} - -\docType{data} - \title{Wetlands} - -\description{ -Wetlands in the Wood River Valley and surrounding areas. +\format{An object of SpatialPolygons class containing 3,024 Polygons. + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} +\source{ +U.S. Fish and Wildlife Service National Wetlands Inventory, + accessed on April 2, 2014 } - -\usage{wetlands} - -\format{ -An object of \code{SpatialPolygons} class containing 3,024 \code{Polygons}. +\usage{ +wetlands } - -\source{ -U.S. Fish and Wildlife Service National Wetlands Inventory, accessed on April 2, 2014 +\description{ +Wetlands in the Wood River Valley and surrounding areas. } - \examples{ -plot(wetlands, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) +sp::plot(wetlands, col = "#CCFFFF", border = "#3399CC", lwd = 0.5) print(wetlands) -} +} \keyword{datasets} + diff --git a/man/wl.200610.Rd b/man/wl.200610.Rd index 3417925..6174b0e 100644 --- a/man/wl.200610.Rd +++ b/man/wl.200610.Rd @@ -1,40 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{wl.200610} - \alias{wl.200610} - -\docType{data} - \title{Groundwater-Level Contours for October 2006} - -\description{ -Groundwater-level contours with a 20 foot (6.096 meter) contour interval for the unconfined aquifer in the Wood River Valley, south-central Idaho, representing conditions during October 2006. -} - -\usage{wl.200610} - -\format{ -An object of \code{SpatialLinesDataFrame} class containing 265 \code{Lines} and a \code{data.frame} with the following variables: -\describe{ - \item{CONTOUR}{is the groundwater elevation contour value in meters above the North American Vertical Datum of 1988 (NAVD 88).} - \item{certainty}{is the certainty of the groundwater-level contour based on data position and density, specified as \code{"good"} or \code{"poor"}.} -} -Geographic coordinates are in units of meters, in conformance with the North American Datum of 1983 (NAD 83), and placed in the -Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}). -} - +\format{An object of SpatialLinesDataFrame class containing 265 Lines and a + data.frame with the following variables: + \describe{ + \item{CONTOUR}{groundwater elevation contour value in meters above the + North American Vertical Datum of 1988 (NAVD 88).} + \item{certainty}{certainty of the groundwater-level contour based on + data position and density, specified as \code{"good"} or \code{"poor"}.} + } + Geographic coordinates are in units of meters, in conformance with the + North American Datum of 1983 (NAD 83), and placed in the + Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM}).} \source{ -This dataset is from Plate 1 in Skinner and others (2007), and available on the \href{http://water.usgs.gov/GIS/metadata/usgswrd/XML/sir2007-5258_oct2006wl.xml}{WRD NSDI Node}. +This dataset is from Plate 1 in Skinner and others (2007), and available on the + \href{http://water.usgs.gov/GIS/metadata/usgswrd/XML/sir2007-5258_oct2006wl.xml}{WRD NSDI Node}. } - -\references{ -Skinner, K.D., Bartolino, J.R., and Tranmer, A.W., 2007, Water-resource trends and comparisons between partial development and October 2006 hydrologic conditions, Wood River Valley, south-central, Idaho: U.S. Geological Survey Scientific Investigations Report 2007-5258, 30 p., available at \url{http://pubs.usgs.gov/sir/2007/5258/} +\usage{ +wl.200610 +} +\description{ +Groundwater-level contours with a 20 foot (6.096 meter) contour interval for the +unconfined aquifer in the Wood River Valley, south-central Idaho, +representing conditions during October 2006. } - \examples{ is.good <- wl.200610@data$certainty == "good" -plot(wl.200610[is.good, ], col = "blue") -plot(wl.200610[!is.good, ], col = "red", lty = 2, add = TRUE) +sp::plot(wl.200610[is.good, ], col = "blue") +sp::plot(wl.200610[!is.good, ], col = "red", lty = 2, add = TRUE) str(wl.200610@data) -} +} +\references{ +Skinner, K.D., Bartolino, J.R., and Tranmer, A.W., 2007, + Water-resource trends and comparisons between partial development and + October 2006 hydrologic conditions, Wood River Valley, south-central, Idaho: + U.S. Geological Survey Scientific Investigations Report 2007-5258, 30 p., + available at \url{http://pubs.usgs.gov/sir/2007/5258/} +} \keyword{datasets} + diff --git a/man/zone.properties.Rd b/man/zone.properties.Rd index 270293f..820efc5 100644 --- a/man/zone.properties.Rd +++ b/man/zone.properties.Rd @@ -1,36 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} \name{zone.properties} - \alias{zone.properties} - -\docType{data} - \title{Hydraulic Properties of Hydrogeologic Zones} - +\format{An object of \code{data.frame} class with the following variables: + \describe{ + \item{ID}{numeric identifier for the hydrogeologic zone.} + \item{name}{name of the hydrogeologic zone.} + \item{vani}{vertical anisotropy, a dimensionless quantity.} + \item{sc}{storage coefficient, a dimensionless quantity.} + \item{sy}{specific yield, a dimensionless quantity.} + \item{hk}{horizontal hydraulic conductivity in meters per day.} + \item{ss}{specific storage in inverse meter.} + }} +\usage{ +zone.properties +} \description{ Estimates of the hydraulic properties for each hydrogeologic zone. } - -\usage{zone.properties} - -\format{ -A \code{data.frame} object with the following variables: -\describe{ - \item{ID}{is a numeric identifier for the hydrogeologic zone.} - \item{name}{is the name of the hydrogeologic zone.} - \item{vani}{is the vertical anisotropy, a dimensionless quantity.} - \item{sc}{is the storage coefficient, a dimensionless quantity.} - \item{sy}{is the specific yield, a dimensionless quantity.} - \item{hk}{is the horizontal hydraulic conductivity in meters per day.} - \item{ss}{is the specific storage, in inverse meter.} -} -} - -\source{ -Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the Wood River Valley aquifer system, south-central Idaho: U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., available at \url{http://pubs.usgs.gov/sir/2012/5053/}. -} - \examples{ str(zone.properties) -} +} +\references{ +Bartolino, J.R., and Adkins, C.B., 2012, Hydrogeologic framework of the + Wood River Valley aquifer system, south-central Idaho: + U.S. Geological Survey Scientific Investigations Report 2012-5053, 46 p., + available at \url{http://pubs.usgs.gov/sir/2012/5053/}. +} \keyword{datasets} + diff --git a/src/cln2basu1.f b/src/cln2basu1.f index bc2903b..d4e20af 100644 --- a/src/cln2basu1.f +++ b/src/cln2basu1.f @@ -107,7 +107,6 @@ SUBROUTINE SDIS2CLN1AR(IUCLN) IF(ICLNHD.EQ.0) WRITE(IOUT,31) 31 FORMAT(1X,'CLN HEAD OUTPUT WILL NOT BE SAVED OR PRINTED', 1 1X,'(FLAG ICLNHD IS EQUAL TO ZERO)') - IF(ICLNHD.LT.0) ICLNHD = IHEDUN C IF(ICLNDD.LT.0) WRITE(IOUT,12) 12 FORMAT(1X,'CLN DDN OUTPUT WILL BE SAVED TO THE SAME UNIT',1X, @@ -119,7 +118,6 @@ SUBROUTINE SDIS2CLN1AR(IUCLN) IF(ICLNDD.EQ.0) WRITE(IOUT,14) 14 FORMAT(1X,'CLN DDN OUTPUT WILL NOT BE SAVED OR PRINTED', 1 1X,'(FLAG ICLNDD IS EQUAL TO ZERO)') - IF(ICLNDD.LT.0) ICLNDD = IDDNUN C IF(ICLNIB.LT.0) WRITE(IOUT,32) 32 FORMAT(1X,'CLN IBOUND OUTPUT WILL BE SAVED TO THE SAME UNIT',1X, @@ -131,7 +129,6 @@ SUBROUTINE SDIS2CLN1AR(IUCLN) IF(ICLNIB.EQ.0) WRITE(IOUT,17) 17 FORMAT(1X,'CLN IBOUND OUTPUT WILL NOT BE SAVED OR PRINTED', 1 1X,'(FLAG ICLNIB IS EQUAL TO ZERO)') - IF(ICLNDD.LT.0) ICLNIB = IBOUUN C-------------------------------------------------------------------------------- C C4------DIMENSION AND READ ARRAY THAT CONTAINS NUMBER OF NODES PER CLN SEGMENT @@ -350,6 +347,35 @@ SUBROUTINE FILLIAJA_CLN C14-----RETURN RETURN END +C --------------------------------------------------------------------- + SUBROUTINE FILLIDXGLO_CLN +C ****************************************************************** +C FILL POINTER ARRAY FOR CLN DOMAIN TO GLOBAL MATRIX IDXGLO_CLN +C ****************************************************************** +C +C SPECIFICATIONS: +C ------------------------------------------------------------------ + USE CLN1MODULE, ONLY: IDXGLO_CLN,NJA_CLN,NCLNNDS,ACLNNDS + USE GLOBAL, ONLY: IA,JA,NODES +C ------------------------------------------------------------------ + ALLOCATE(IDXGLO_CLN(NJA_CLN)) +C1--------LOOP OVER ALL CLN NODES + IPOS = 1 + DO NC1 = 1,NCLNNDS + ND1 = ACLNNDS(NC1,1) ! NC1 + NODES +C2-------LOOP OVER ALL CONNECTIONS OF NODE NC1 IN GLOBAL ARRAY + DO II = IA(ND1),IA(ND1+1)-1 + ND2 = JA(II) + IF(ND2.GT.NODES.AND.ND2.LE.NODES+NCLNNDS)THEN + IDXGLO_CLN(IPOS) = II + IPOS = IPOS + 1 + ENDIF + ENDDO + ENDDO +C---------------------------------------------------------------------------------------- +C3------RETURN + RETURN + END C --------------------------------------------------------------------- SUBROUTINE SCLN2DIS1SR C ****************************************************************** @@ -777,7 +803,7 @@ SUBROUTINE SFILLPGF_CLN USE GLOBAL, ONLY:NODES,NJA,IA,PGF,FAHL,TOP,BOT,CL1,CL2,NODES,NLAY, 1 NODLAY,IBOUND,JA,JAS,IVC,ISYM,AREA,IDEALLOC_HY USE CLN1MODULE, ONLY: ACLNNDS,NCLNNDS,NNDCLN,ACLNGWC,NCLNGWC, - 1 ACLNCOND,NCLN,CLNCON,IA_CLN,JA_CLN + 1 ACLNCOND,NCLN,CLNCON,IA_CLN,JA_CLN,IDXGLO_CLN USE GWFBCFMODULE,ONLY:HK,CV,LAYCON,LAYAVG,IKVFLAG DOUBLE PRECISION FK,AREAF,EL,RADFSQ,CWCn,RO,ROD,CWND,DEX,DEXN,DEZ, 1 AREAF1,AREAF2,FK1,FK2,FPER,FRAD,FANISO,EL1,EL2,AKVAL @@ -792,23 +818,9 @@ SUBROUTINE SFILLPGF_CLN DO II_CLN = IA_CLN(NC1)+1,IA_CLN(NC1+1)-1 NC2 = JA_CLN(II_CLN) IF(NC2.GT.NC1) CYCLE - ND1 = ACLNNDS(NC1,1) ! NC1 + NODES - ND2 = ACLNNDS(NC2,1) ! NC2 + NODES IC1 = ACLNNDS(NC1,2) !CLN TYPE FOR NODE 1 IC2 = ACLNNDS(NC2,2) !CLN TYPE FOR NODE 2 -C1C---------FIND LOWER ROW NUMBER TO FILL UPPER DIAGONAL OF PGF - IF(ND2.GT.ND1)THEN - NL = ND1 - NH = ND2 - ELSE - NL = ND2 - NH = ND1 - ENDIF -C-------------------------------------------------------------------------------------- -C2---------COMPUTE AND FILL CONDUCTANCE TERM FOR CLN-CLN CONNECTION IN PGF - DO II = IA(NL)+1,IA(NL+1)-1 - JJ = JA(II) - IF(JJ.NE.NH) CYCLE + II = IDXGLO_CLN(II_CLN) IIS = JAS(II) C CALL CLNA(IC1,AREAF1) @@ -829,7 +841,6 @@ SUBROUTINE SFILLPGF_CLN IVC(IIS) = 3 CL1(IIS) = ACLNNDS(NC1,4) !DIVIDE BY 2? CL2(IIS) = ACLNNDS(NC2,4) !DIVIDE BY 2? - ENDDO ENDDO ENDDO C @@ -1001,7 +1012,7 @@ SUBROUTINE SCLN1WADI 1 NODLAY,AMAT,RHS,IA,JA,JAS,PGF USE CLN1MODULE, ONLY: NCLN,NNDCLN,NCLNNDS,ACLNNDS,CLNCON, 1 ACLNGWC,NCLNGWC,IFLINCLN,HWADICC,HWADICG,ICCWADICLN,ICGWADICLN, - 2 IA_CLN,JA_CLN + 2 IA_CLN,JA_CLN,IDXGLO_CLN USE GWFBCFMODULE,ONLY:IWDFLG,WETFCT,IHDWET,IWETIT,LAYCON,HDRY, 1 HK,WETDRY,LAYAVG USE SMSMODULE, ONLY: EPSILON @@ -1032,34 +1043,19 @@ SUBROUTINE SCLN1WADI ND1 = ACLNNDS(NC1,1) ! NC1 + NODES ND2 = ACLNNDS(NC2,1) ! NC2 + NODES IF(IBOUND(ND1).EQ.0.OR.IBOUND(ND2).EQ.0) CYCLE -C2B---------FIND LOWER ROW NUMBER FOR UPPER DIAGONAL OF PGF - IF(ND2.GT.ND1)THEN - NL = ND1 - NH = ND2 - ELSE - NL = ND2 - NH = ND1 - ENDIF -C2C---------COMPUTE AND FILL CORRECTION TERM FOR CLN-CLN CONNECTION - DO II = IA(NL)+1,IA(NL+1)-1 - JJ = JA(II) - IF(JJ.NE.NH) CYCLE + II = IDXGLO_CLN(II_CLN) IIS = JAS(II) C2D---------FIND UPSTREAM AND DOWNSTREAM NODES - IUP = NL - IF(HNEW(NH).GT.HNEW(NL)) IUP = NH - IDN = NL - IF(IUP.EQ.NL) IDN = NH + IUP = ND1 + IF(HNEW(ND2).GT.HNEW(ND1)) IUP = ND2 + IDN = ND1 + IF(IUP.EQ.ND1) IDN = ND2 C2E---------SKIP CORRECTION IF DOWNSTREAM NODE DOES NOT NEED CORRECTION IDNL = IDN - NODES IF(ICCWADICLN(IDNL).EQ.0) CYCLE -C2F-----------FIND MATRIX LOCATION OF DOWNSTREAM NODE - ILOC = II !MATRIX LOCATION FOR NL BEING DOWNSTREAM NODE - IF(NH.EQ.IDN) ILOC = ISYM(II) -C2G---------FILL CORRECTION FOR CONNECTION - RHS(IDN) = RHS(IDN) + AMAT(ILOC)*(HWADICC(IDNL) - HNEW(IDN)) - RHS(IUP) = RHS(IUP) - AMAT(ILOC)*(HWADICC(IDNL) - HNEW(IDN)) - ENDDO +C2F---------FILL CORRECTION FOR CONNECTION + RHS(IDN) = RHS(IDN) + AMAT(II)*(HWADICC(IDNL) - HNEW(IDN)) + RHS(IUP) = RHS(IUP) - AMAT(II)*(HWADICC(IDNL) - HNEW(IDN)) ENDDO ENDDO C----------------------------------------------------------------------------- @@ -1115,7 +1111,7 @@ SUBROUTINE SCLN1H4 USE GLOBAL, ONLY:NODES,NLAY,IBOUND,HNEW,BUFF,BOT,TOP,ISYM,IOUT, 1 NODLAY,AMAT,RHS,IA,JA,JAS,PGF,ICONCV,Sn,AKRC,AKR,iunsat USE CLN1MODULE, ONLY: NCLN,NNDCLN,NCLNNDS,ACLNNDS,CLNCON, - 1 ACLNGWC,NCLNGWC,ACLNCOND,IFLINCLN,IA_CLN,JA_CLN + 1 ACLNGWC,NCLNGWC,ACLNCOND,IFLINCLN,IA_CLN,JA_CLN,IDXGLO_CLN USE GWFBCFMODULE,ONLY:IWDFLG,WETFCT,IHDWET,IWETIT,LAYCON,HDRY, 1 HK,WETDRY,LAYAVG USE SMSMODULE, ONLY: EPSILON @@ -1154,30 +1150,19 @@ SUBROUTINE SCLN1H4 ND1 = ACLNNDS(NC1,1) ! NC1 + NODES ND2 = ACLNNDS(NC2,1) ! NC2 + NODES IF(IBOUND(ND1).EQ.0.OR.IBOUND(ND2).EQ.0) CYCLE -C2B---------FIND LOWER ROW NUMBER FOR UPPER DIAGONAL OF PGF - IF(ND2.GT.ND1)THEN - NL = ND1 - NH = ND2 - ELSE - NL = ND2 - NH = ND1 - ENDIF -C2C---------COMPUTE AND FILL AKRC TERM FOR CLN-CLN CONNECTION - DO II = IA(NL)+1,IA(NL+1)-1 - JJ = JA(II) - IF(JJ.NE.NH) CYCLE + II = IDXGLO_CLN(II_CLN) IIS = JAS(II) C2D---------FIND UPSTREAM NODE AND HIGHER BOT NODE - IUPS = NL - IF(HNEW(JJ).GT.HNEW(NL)) IUPS = JJ - IHBOT = NL - BNL = ACLNNDS(NL-NODES,5) - BJJ = ACLNNDS(JJ-NODES,5) - IF(BJJ.GT.BNL) IHBOT = JJ + IUPS = ND1 + IF(HNEW(ND2).GT.HNEW(ND1)) IUPS = ND2 + IHBOT = ND1 + BC1 = ACLNNDS(NC1,5) + BC2 = ACLNNDS(NC2,5) + IF(BC2.GT.BC1) IHBOT = ND2 C2E---------FILL AKRC FOR CONNECTION INDK = 0 IF(IUPS.EQ.IHBOT) INDK = 1 - IF(ABS(BJJ-BNL).LT.0.01) INDK = 1 + IF(ABS(BC2-BC1).LT.0.01) INDK = 1 IF(INDK.EQ.1)THEN AKRC(IIS) = AKR(IUPS) ELSE @@ -1189,7 +1174,6 @@ SUBROUTINE SCLN1H4 CALL CLN_THIK(ICLN,HD,BBOT,THCK) AKRC(IIS) = THCK ENDIF - ENDDO ENDDO ENDDO C----------------------------------------------------------------------------- @@ -1258,28 +1242,16 @@ SUBROUTINE SCLN1H4 ND1 = ACLNNDS(NC1,1) ! NC1 + NODES ND2 = ACLNNDS(NC2,1) ! NC2 + NODES IF(IBOUND(ND1).EQ.0.OR.IBOUND(ND2).EQ.0) CYCLE -C3C---------FIND LOWER ROW NUMBER FOR UPPER DIAGONAL OF PGF - IF(ND2.GT.ND1)THEN - NL = ND1 - NH = ND2 - ELSE - NL = ND2 - NH = ND1 - ENDIF -C3D---------COMPUTE AND FILL AMAT TERM FOR CONDUIT-CONDUIT CONNECTION - DO II = IA(NL)+1,IA(NL+1)-1 - JJ = JA(II) - IF(JJ.NE.NH) CYCLE + II = IDXGLO_CLN(II_CLN) IIS = JAS(II) - IUPS = JJ - IF(HNEW(JJ).LT.HNEW(NL)) IUPS = NL -C3D1--------FILL OFFDIAGONAL TERMS IN ROWS NL AND NH + IUPS = ND2 + IF(HNEW(ND2).LT.HNEW(ND1)) IUPS = ND1 +C3D1--------FILL OFFDIAGONAL TERMS IN ROWS ND1 AND ND2 AMAT(II) = PGF(IIS)*AKRC(IIS) AMAT(ISYM(II)) = PGF(IIS)*AKRC(IIS) C3D2--------ADD TO DIAGONAL TERMS IN ROWS NL AND NH - AMAT(IA(NL)) = AMAT(IA(NL)) - PGF(IIS)*AKRC(IIS) - AMAT(IA(NH)) = AMAT(IA(NH)) - PGF(IIS)*AKRC(IIS) - ENDDO + AMAT(IA(ND1)) = AMAT(IA(ND1)) - PGF(IIS)*AKRC(IIS) + AMAT(IA(ND2)) = AMAT(IA(ND2)) - PGF(IIS)*AKRC(IIS) C ENDDO ENDDO @@ -1524,12 +1496,13 @@ SUBROUTINE GWF2CLNU1BDCHWR(KSTP,KPER) C CHARACTER*16 TEXT(1) DOUBLE PRECISION HD,CHIN,CHOUT,XX1,TMP,RATE,CHCH1,HDIFF, - * X1,CIN,COUT + * X1,CIN,COUT,ZERO C DATA TEXT(1) /' CLN CONST HEAD'/ C ------------------------------------------------------------------ C C1------CLN DOMAIN + ZERO = 0.0 IBD=0 IF(ICLNCB.LT.0 .AND. ICBCFL.NE.0) IBD=-1 IF(ICLNCB.GT.0) IBD=ICBCFL @@ -1725,7 +1698,7 @@ SUBROUTINE CLN1BDWR(KSTP,KPER) USE GLOBAL, ONLY:NCOL,NROW,NLAY,IBOUND,HNEW,BUFF,AMAT,NODLAY, 1 TOP,IOUT,NODES,NJA,IA,JA,JAS,IUNSTR,ISYM,ITRNSP,FLOWJA USE CLN1MODULE, ONLY: ICLNCB,NCLN,NNDCLN,CLNCON,NCLNNDS,ACLNNDS, - 1 NCLNGWC,ACLNGWC,IA_CLN,JA_CLN,NJA_CLN + 1 NCLNGWC,ACLNGWC,IA_CLN,JA_CLN,NJA_CLN,IDXGLO_CLN USE GWFBASMODULE,ONLY:ICBCFL,DELT,PERTIM,TOTIM,ICHFLG USE GWFBCFMODULE,ONLY:IBCFCB,LAYCON USE GWTBCTMODULE, ONLY: CBCF @@ -1769,17 +1742,13 @@ SUBROUTINE CLN1BDWR(KSTP,KPER) ND1 = ACLNNDS(NC1,1) ! NC1 + NODES ND2 = ACLNNDS(NC2,1) ! NC2 + NODES IF(IBOUND(ND1).EQ.0.OR.IBOUND(ND2).EQ.0) CYCLE -C4B---------FILL FLOW TERM FOR CLN-CLN CONNECTION - DO II = IA(ND1)+1,IA(ND1+1)-1 - JJ = JA(II) - IF(JJ.NE.ND2) CYCLE + II = IDXGLO_CLN(II_CLN) IF(ICHFLG.EQ.0) THEN - IF((IBOUND(ND1).LE.0) .AND. (IBOUND(JJ).LE.0)) CYCLE + IF((IBOUND(ND1).LE.0) .AND. (IBOUND(ND2).LE.0)) CYCLE END IF IIS = JAS(II) FLOWCLNCLN(II_CLN)= -FLOWJA(II) - IF(ITRNSP.GT.0) CBCF(IIS) = FLOWJA(II) - ENDDO + IF(ITRNSP.GT.0) CBCF(IIS) = -FLOWJA(II) ENDDO ENDDO C4D------RECORD CLN-CLN FLOW @@ -1985,7 +1954,7 @@ SUBROUTINE SCLN1IB(KSTP,KPER) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY: IBOUND,IOUT + USE GLOBAL, ONLY: IBOUND,IOUT,NODES USE CLN1MODULE, ONLY: NCLNNDS,ICLNIB USE GWFBASMODULE,ONLY:PERTIM,TOTIM,IBOUUN,LBBOSV,CBOUFM,IOFLG C diff --git a/src/disu2gncb1.f b/src/disu2gncb1.f index 2a3560d..dc5fe3b 100644 --- a/src/disu2gncb1.f +++ b/src/disu2gncb1.f @@ -472,7 +472,8 @@ SUBROUTINE SGNCb2BCFU1BDADJ1(NGNCb,GNCb,IRGNCb,ISYMGNCb,MXADJb, C SPECIFICATIONS: C ------------------------------------------------------------------ USE GLOBAL, ONLY:NCOL,NROW,HNEW,TOP,BOT,IBOUND,IOUT, - 1 AMAT,PGF,FAHL,IA,JA,JAS,ISYM,RHS,HNEW + 1 PGF,FAHL,IA,JA,JAS,ISYM,RHS,HNEW + USE SMSMODULE, ONLY: AMATFL DIMENSION GNCb(4+2*MXADJb,MXGNCb),IRGNCb(MXADJb,MXGNCb), 1 BOTb(MXGNCb) DOUBLE PRECISION ALPHA,Cnm,ATERM,ATERM1,ATERM2,RTERM,HN,BN, @@ -518,22 +519,22 @@ SUBROUTINE SGNCb2BCFU1BDADJ1(NGNCb,GNCb,IRGNCb,ISYMGNCb,MXADJb, IF(IBOUND(N3).EQ.0) CYCLE ALPHA = GNCb(1+MXADJb+IADJb,IG) C -C4-----------FIND LOCATION OF N2 IN ROW N1 AND ADJUST AMAT FOR ROWS N1 AND N2 +C4-----------FIND LOCATION OF N2 IN ROW N1 AND ADJUST AMATFL FOR ROWS N1 AND N2 ATERM = ALPHA * Cnm IF(ICASE.EQ.1)THEN C4A1------------FOR ROW N1 C4A1-----------LESSEN N1 LOCATION BY (ALPHA-1)*Cnm IN DIAGONAL OF ROW N1 - AMAT(IA(N1)) = AMAT(IA(N1)) - ATERM + AMATFL(IA(N1)) = AMATFL(IA(N1)) - ATERM C4A2-----------PUT -ATERM IN LOCATION J OF ROW N IF FULLY IMPLICIT IF(ISYMGNCb.EQ.0)THEN LOC_JN = IRGNCb(IADJb,IG) - AMAT(LOC_JN) = AMAT(LOC_JN) + ATERM + AMATFL(LOC_JN) = AMATFL(LOC_JN) + ATERM ENDIF ELSEIF(ICASE.EQ.2)THEN - AMAT(IA(N1)) = AMAT(IA(N1)) - ATERM + AMATFL(IA(N1)) = AMATFL(IA(N1)) - ATERM ELSEIF(ICASE.EQ.3.AND.ISYMGNCb.EQ.0)THEN LOC_JN = IRGNCb(IADJb,IG) - AMAT(LOC_JN) = AMAT(LOC_JN) + ATERM + AMATFL(LOC_JN) = AMATFL(LOC_JN) + ATERM ENDIF ENDDO 20 CONTINUE diff --git a/src/disu2gncn1.f b/src/disu2gncn1.f index 16a8ddb..b148062 100644 --- a/src/disu2gncn1.f +++ b/src/disu2gncn1.f @@ -307,12 +307,12 @@ SUBROUTINE SGNCn2DISU1RLU(NLIST,GNCn,LSTBEG,MXGNCn,INPACK,IOUT, DATA DASH/120*'-'/ DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C @@ -932,7 +932,8 @@ SUBROUTINE SGNCn2BCFU1BDADJ C ADJUST CBC FLUX FOR GHOST NODE TERMS C ****************************************************************** USE GLOBAL, ONLY:JA,IA,NODES,NEQS,IVC,JAS,ISYM,IBOUND,ICONCV,IOUT, - 1 HNEW,AMAT,FLOWJA + 1 HNEW,FLOWJA + USE SMSMODULE, ONLY: AMATFL USE GNCnMODULE,ONLY:NGNCn,GNCn,I2Kn,ISYMGNCn,MXADJn USE GWFBCFMODULE, ONLY: LAYCON DOUBLE PRECISION QNJ1,QMJ1,QNJ2,QMJ2,Cnm,ATERM,ALPHA,CORRECTnm, @@ -965,7 +966,7 @@ SUBROUTINE SGNCn2BCFU1BDADJ IF(JJ.EQ.N2)THEN C C6-----------ADJUST FLUXES FROM RHS - Cnm = AMAT(II) + Cnm = AMATFL(II) CORRECTnm = ATERM * Cnm FLOWJA(II) = FLOWJA(II) - CORRECTnm FLOWJA(ISYM(II)) = FLOWJA(ISYM(II)) + CORRECTnm @@ -985,8 +986,9 @@ SUBROUTINE SGNCn2BCFU1BDADJ1 C SPECIFICATIONS: C ------------------------------------------------------------------ USE GLOBAL, ONLY:NCOL,NROW,HNEW,TOP,BOT,IBOUND,IOUT, - 1 AMAT,PGF,FAHL,IA,JA,JAS,ISYM,RHS,HNEW + 1 PGF,FAHL,IA,JA,JAS,ISYM,RHS,HNEW USE GNCnMODULE,ONLY:NGNCn,GNCn,IRGNCn,ISYMGNCn,MXADJn + USE SMSMODULE, ONLY: AMATFL DOUBLE PRECISION ALPHA,BETA,Cnm,ATERM,ATERM1,ATERM2,RTERM C ------------------------------------------------------------------ C--------------------------------------------------------------------------- @@ -1007,7 +1009,7 @@ SUBROUTINE SGNCn2BCFU1BDADJ1 LOC_JN = IRGNCn(1,IADJn,IG) LOC_JM = IRGNCn(2,IADJn,IG) C -C4-----------FIND LOCATION OF N2 IN ROW N1 AND ADJUST AMAT FOR ROWS N1 AND N2 +C4-----------FIND LOCATION OF N2 IN ROW N1 AND ADJUST AMATFL FOR ROWS N1 AND N2 DO II = IA(N1)+1,IA(N1+1)-1 JJ = JA(II) IIS = JAS(II) @@ -1016,14 +1018,14 @@ SUBROUTINE SGNCn2BCFU1BDADJ1 ATERM = ALPHA * Cnm C4A1------------FOR ROW N1 C4A1-----------LESSEN N1 LOCATION BY (ALPHA-1)*Cnm IN DIAGONAL OF ROW N1 - AMAT(IA(N1)) = AMAT(IA(N1)) - ATERM + AMATFL(IA(N1)) = AMATFL(IA(N1)) - ATERM C4A2-----------PUT -ATERM IN LOCATION J OF ROW N - AMAT(LOC_JN) = AMAT(LOC_JN) + ATERM + AMATFL(LOC_JN) = AMATFL(LOC_JN) + ATERM C4B1------------FOR ROW N2 C4B1-----------LESSEN N1 LOCATION BY (ALPHA-1)*Cnm IN OFF-DIAGONAL OF ROW N2 - AMAT(ISYM(II)) = AMAT(ISYM(II)) + ATERM + AMATFL(ISYM(II)) = AMATFL(ISYM(II)) + ATERM C4B2-----------PUT ATERM IN LOCATION J OF ROW M - AMAT(LOC_JM) = AMAT(LOC_JM) - ATERM + AMATFL(LOC_JM) = AMATFL(LOC_JM) - ATERM GO TO 200 ENDIF ENDDO diff --git a/src/glo2basu1.f b/src/glo2basu1.f index 080fb31..3a444cd 100644 --- a/src/glo2basu1.f +++ b/src/glo2basu1.f @@ -8,8 +8,8 @@ SUBROUTINE GLO2BAS8AR(INUNIT,CUNIT,VERSION,IUDIS,IUZON,IUMLT, C ------------------------------------------------------------------ USE GLOBAL, ONLY:NCOL,NROW,NLAY,NPER,ITMUNI,NJA,NJAS,NJAG, 1 IVSD,LENUNI,IXSEC,ITRSS,INBAS,IFREFM,NODES,IOUT, - 2 IUNIT,NIUNIT,HNEW,LAYHDT,LAYHDS,NODLAY,NBOTM, - 3 PERLEN,NSTP,TSMULT,ISSFLG,IUNSTR,MXNODLAY,NCNFBD, + 2 IUNIT,NIUNIT,HNEW,LAYHDT,LAYHDS,NODLAY,NBOTM,IDPF,IDPT, + 3 PERLEN,NSTP,TSMULT,ISSFLG,IUNSTR,MXNODLAY,NCNFBD,DDREF, 4 HOLD,IBOUND,RHS,AMAT,BUFF,STRT,IPRCONN,IDSYMRD,ILAYCON4, 5 IDEALLOC_LPF,IDEALLOC_HY,INCLN,INGNC,INGNC2,INGNCn, 6 ITRNSP,Sn,So,NEQS,ISYMFLG,WADIEPS,IWADI,IWADICLN,iunsat @@ -20,8 +20,8 @@ SUBROUTINE GLO2BAS8AR(INUNIT,CUNIT,VERSION,IUDIS,IUZON,IUMLT, USE GWFBASMODULE,ONLY:MSUM,IHEDFM,IHEDUN,IDDNFM,IDDNUN,IBOUUN, 1 LBHDSV,LBDDSV,LBBOSV,IBUDFL,ICBCFL,IHDDFL,ISPCFL, 2 IAUXSV,IBDOPT,IPRTIM,IPEROC,ITSOC,ICHFLG,IFRCNVG, - 3 DELT,PERTIM,TOTIM,HNOFLO,CHEDFM,CDDNFM, - 4 CBOUFM,VBVL,VBNM,ISPCFM,ISPCUN,CSPCFM + 3 DELT,PERTIM,TOTIM,HNOFLO,CHEDFM,CDDNFM,CBOUFM, + 4 VBVL,VBNM,ISPCFM,ISPCUN,CSPCFM,IDDREF,IDDREFNEW C CHARACTER*4 CUNIT(NIUNIT) CHARACTER*(*) VERSION @@ -40,10 +40,10 @@ SUBROUTINE GLO2BAS8AR(INUNIT,CUNIT,VERSION,IUDIS,IUZON,IUMLT, allocate(iunsat) iunsat = 0 ! unsat formulation ALLOCATE(NCOL,NROW,NLAY,NPER,NBOTM,NCNFBD,ITMUNI,LENUNI,ITRSS) - ALLOCATE(NJA,NJAS,NJAG,ILAYCON4,WADIEPS,IWADI,IWADICLN) + ALLOCATE(NJA,NJAS,NJAG,ILAYCON4,WADIEPS,IWADI,IWADICLN,IDPF,IDPT) ALLOCATE(IXSEC,INBAS,IFREFM,NODES,IOUT,MXNODLAY,IUNSTR,IVSD) ALLOCATE(IDEALLOC_LPF,IDEALLOC_HY,ITRNSP,NEQS,IDSYMRD,IPRCONN) - ALLOCATE(INCLN,INGNC,INGNC2,INGNCn,ISYMFLG) + ALLOCATE(INCLN,INGNC,INGNC2,INGNCn,ISYMFLG,IDDREF,IDDREFNEW) INCLN = 0 INGNC = 0 INGNC2 = 0 @@ -52,6 +52,10 @@ SUBROUTINE GLO2BAS8AR(INUNIT,CUNIT,VERSION,IUDIS,IUZON,IUMLT, IDEALLOC_LPF = 0 IWADI = 0 IWADICLN = 0 + IDPF = 0 + IDPT = 0 + IDDREF=0 + IDDREFNEW=0 ALLOCATE(IUNIT(NIUNIT)) C ALLOCATE(ICLSUM,IPSUM,INAMLOC,NMLTAR,NZONAR,NPVAL) @@ -167,6 +171,7 @@ SUBROUTINE GLO2BAS8AR(INUNIT,CUNIT,VERSION,IUDIS,IUZON,IUMLT, ALLOCATE (RHS(NEQS)) ALLOCATE (BUFF(NEQS)) ALLOCATE (STRT(NEQS)) + DDREF=>STRT ALLOCATE (LAYHDT(NLAY)) ALLOCATE (LAYHDS(NLAY)) WRITE(IOUT,'(//)') @@ -192,7 +197,8 @@ SUBROUTINE GLO2BAS8AR(INUNIT,CUNIT,VERSION,IUDIS,IUZON,IUMLT, C C----------------------------------------------------------------------- C11-----SET UP OUTPUT CONTROL. - CALL SGWF2BAS7I(NLAY,IUNIT(IUOC),IOUT,IFREFM,NIUNIT,IUNIT(15)) + CALL SGWF2BAS7I(NLAY,IUNIT(IUOC),IOUT,IFREFM,NIUNIT,IUNIT(15), + 1 IUNIT(IUCLN)) C C12-----INITIALIZE VOLUMETRIC BUDGET ACCUMULATORS TO ZERO. 590 ZERO=0. @@ -219,12 +225,12 @@ SUBROUTINE SGWF2BAS8OPEN(INUNIT,IOUT,IUNIT,CUNIT, C SPECIFICATIONS: C ------------------------------------------------------------------ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C DIMENSION IUNIT(NIUNIT) CHARACTER*4 CUNIT(NIUNIT) @@ -544,8 +550,13 @@ SUBROUTINE SGLO2BAS8ARDIS(IUDIS,IOUT,IUCLN,IUGNC,IUGNC2,IUGNCn) ELSE JAFL => JA ENDIF +C-------------------------------------------------------------------------- +C7H------PREPARE IDXGLO ARRAY FOR CLN DOMAIN + IF(INCLN.NE.0)THEN + CALL FILLIDXGLO_CLN + ENDIF C -C7H-----SET GNC CONNECTION ARRAYS FROM JA STRUCTURE +C7I-----SET GNC CONNECTION ARRAYS FROM JA STRUCTURE IF(INGNCn.NE.0) THEN CALL SGNCn2DISU1MC ENDIF @@ -745,7 +756,7 @@ SUBROUTINE FILLISYM RETURN END C---------------------------------------------------------------------- - SUBROUTINE SGWF2BAS7I(NLAY,INOC,IOUT,IFREFM,NIUNIT,ITRUNIT) + SUBROUTINE SGWF2BAS7I(NLAY,INOC,IOUT,IFREFM,NIUNIT,ITRUNIT,ICUNIT) C ****************************************************************** C SET UP OUTPUT CONTROL. C ****************************************************************** @@ -754,9 +765,10 @@ SUBROUTINE SGWF2BAS7I(NLAY,INOC,IOUT,IFREFM,NIUNIT,ITRUNIT) C ------------------------------------------------------------------ USE GLOBAL, ONLY: ITRNSP USE GWFBASMODULE, ONLY: IHEDFM,IDDNFM,IHEDUN,IDDNUN,IPEROC,ITSOC, - 1 CHEDFM,CDDNFM,IBDOPT,LBHDSV,LBDDSV, - 2 IBOUUN,LBBOSV,CBOUFM,IAUXSV,IOFLG, - 3 VBVL,VBNM,ISPCFM,ISPCUN,CSPCFM + 1 CHEDFM,CDDNFM,IBDOPT,LBHDSV,LBDDSV, + 2 IBOUUN,LBBOSV,CBOUFM,IAUXSV,IOFLG, + 3 VBVL,VBNM,ISPCFM,ISPCUN,CSPCFM,IDDREF,IDDREFNEW + USE CLN1MODULE, ONLY: ICLNHD, ICLNDD, ICLNIB CHARACTER*200 LINE C ------------------------------------------------------------------ C @@ -764,6 +776,8 @@ SUBROUTINE SGWF2BAS7I(NLAY,INOC,IOUT,IFREFM,NIUNIT,ITRUNIT) ALLOCATE (IOFLG(NLAY,7)) ALLOCATE (VBVL(4,NIUNIT)) ALLOCATE (VBNM(NIUNIT)) + IDDREF=0 + IDDREFNEW=0 C C1A------ASSIGN DEFAULT VALUES. CHEDFM=' ' @@ -859,7 +873,7 @@ SUBROUTINE SGWF2BAS7I(NLAY,INOC,IOUT,IFREFM,NIUNIT,ITRUNIT) 113 FORMAT(1X,'HEAD PRINT FORMAT CODE IS',I4, 1 ' DRAWDOWN PRINT FORMAT CODE IS',I4, 1 ' CONC PRINT FORMAT CODE IS',I4) - WRITE(IOUT,114) IHEDUN,IDDNUN + WRITE(IOUT,114) IHEDUN,IDDNUN,ISPCUN 114 FORMAT(1X,'HEADS WILL BE SAVED ON UNIT ',I4, 1 ' DRAWDOWNS WILL BE SAVED ON UNIT ',I4, 1 ' CONC WILL BE SAVED ON UNIT ',I4) @@ -870,6 +884,11 @@ SUBROUTINE SGWF2BAS7I(NLAY,INOC,IOUT,IFREFM,NIUNIT,ITRUNIT) C4B-----ALPHABETIC OUTPUT CONTROL. CALL MODULE TO READ INITIAL RECORDS. CALL SGWF2BAS7J(INOC,IOUT,LINE,LLOC,ISTART,ISTOP) END IF + IF(ICUNIT.GT.0) THEN + IF(ICLNHD.LT.0) ICLNHD = IHEDUN + IF(ICLNDD.LT.0) ICLNDD = IDDNUN + IF(ICLNIB.LT.0) ICLNIB = IBOUUN + ENDIF C C5------RETURN. 1000 RETURN @@ -883,7 +902,7 @@ SUBROUTINE SGWF2BAS7J(INOC,IOUT,LINE,LLOC,ISTART,ISTOP) C ------------------------------------------------------------------ USE GLOBAL, ONLY: ITRNSP USE GWFBASMODULE, ONLY: IHEDFM,IDDNFM,IHEDUN,IDDNUN,IPEROC,ITSOC, - 1 CHEDFM,CDDNFM,IBDOPT,LBHDSV,LBDDSV, + 1 CHEDFM,CDDNFM,IBDOPT,LBHDSV,LBDDSV,IDDREFNEW, 2 IBOUUN,LBBOSV,CBOUFM,IAUXSV,ISPCFM,ISPCUN,CSPCFM C CHARACTER*200 LINE @@ -923,6 +942,13 @@ SUBROUTINE SGWF2BAS7J(INOC,IOUT,LINE,LLOC,ISTART,ISTOP) 1 ' DRAWDOWNS WILL BE SAVED ON UNIT ',I4, 2 ' CONCS WILL BE SAVED ON UNIT ',I4) ENDIF +C2Aii------READ DDREFERENCE FLAG + IF(LINE(ISTART:ISTOP).EQ.'DDREFERENCE') THEN + IDDREFNEW=1 + ELSE + IDDREFNEW=0 + END IF +C GO TO 1000 C C2B-----LOOK FOR "HEAD PRINT ..." AND "HEAD SAVE ...". IF @@ -1737,9 +1763,9 @@ SUBROUTINE GWF2BAS7OT(KSTP,KPER,ICNVG,ISA) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:ITMUNI,IOUT,IUNSTR,INCLN + USE GLOBAL, ONLY:ITMUNI,IOUT,IUNSTR,INCLN,DDREF,STRT,NEQS,HNEW USE GWFBASMODULE,ONLY:DELT,PERTIM,TOTIM,IHDDFL,IBUDFL, - 1 MSUM,VBVL,VBNM + 1 MSUM,VBVL,VBNM,IDDREF C ------------------------------------------------------------------ C C @@ -1791,10 +1817,22 @@ SUBROUTINE GWF2BAS7OT(KSTP,KPER,ICNVG,ISA) IF(IBUDFL.EQ.0) GO TO 120 CALL SGWF2BAS7V(MSUM,VBNM,VBVL,KSTP,KPER,IOUT) IPFLG=1 + 120 CONTINUE +C5------RESET DRADWOWN REFERENCE ARRAY OF FLAG IS ON + IF(IDDREF.NE.0) THEN + IF(ASSOCIATED(DDREF,STRT)) THEN + ALLOCATE(DDREF(NEQS)) + END IF + DDREF=HNEW + WRITE(IOUT,99) + 99 FORMAT(1X,'Drawdown Reference has been reset to the', + 1 ' end of this time step') + IDDREF=0 + END IF C -C5------END PRINTOUT WITH TIME SUMMARY AND FORM FEED IF ANY PRINTOUT -C5------WILL BE PRODUCED. - 120 IF(IPFLG.EQ.0) RETURN +C6------END PRINTOUT WITH TIME SUMMARY AND FORM FEED IF ANY PRINTOUT +C6------WILL BE PRODUCED. + IF(IPFLG.EQ.0) RETURN CALL SGWF2BAS7T(KSTP,KPER,DELT,PERTIM,TOTIM,ITMUNI,IOUT) WRITE(IOUT,101) 101 FORMAT('1') @@ -2040,7 +2078,7 @@ SUBROUTINE SGWF2BAS7N(KPER,KSTP,INOC,IOUT,NLAY) C SPECIFICATIONS: C ------------------------------------------------------------------ USE GWFBASMODULE, ONLY: IOFLG,IHDDFL,ISPCFL,IBUDFL,ICBCFL,IPEROC, - 1 ITSOC,IBDOPT + 1 ITSOC,IBDOPT,IDDREF,IDDREFNEW C CHARACTER*200 LINE C ------------------------------------------------------------------ @@ -2085,6 +2123,12 @@ SUBROUTINE SGWF2BAS7N(KPER,KSTP,INOC,IOUT,NLAY) 12 FORMAT(1X,/1X,'OUTPUT CONTROL FOR STRESS PERIOD ',I8, 1 ' TIME STEP ',I8) C +C4B-----SET IDDREF FLAG FROM NEW SETTING + IDDREF=IDDREFNEW + IF(IDDREFNEW.NE.0) WRITE(IOUT,52) + 52 FORMAT(1X,'Drawdown Reference will be reset at the', + 1 ' end of this time step') +C C4A-----OUTPUT CONTROL MATCHES SIMULATION TIME. READ NEXT OUTPUT C4A-----RECORD; SKIP ANY BLANK LINES. 50 READ(INOC,'(A)',END=1000) LINE @@ -2099,6 +2143,12 @@ SUBROUTINE SGWF2BAS7N(KPER,KSTP,INOC,IOUT,NLAY) CALL URWORD(LINE,LLOC,ISTART,ISTOP,1,N,R,IOUT,INOC) IF(LINE(ISTART:ISTOP).NE.'STEP') GO TO 2000 CALL URWORD(LINE,LLOC,ISTART,ISTOP,2,ITSOC,R,IOUT,INOC) +C4A1a------SET DDREF FLAG IF KEYWORD IS SET + IF(LINE(ISTART:ISTOP).EQ.'DDREFERENCE') THEN + IDDREFNEW=1 + ELSE + IDDREFNEW=0 + END IF RETURN C C4A2----LOOK FOR "PRINT", WHICH MAY REFER TO "BUDGET", "HEAD", OR @@ -2292,7 +2342,10 @@ SUBROUTINE GWF2BAS7U1DA C------------------------------------------------------- DEALLOCATE(ISYM) DEALLOCATE(BUFF) + IF(.NOT.ASSOCIATED(DDREF,STRT)) + 1 DEALLOCATE(DDREF) DEALLOCATE(STRT) + DEALLOCATE(IDDREF,IDDREFNEW) C DEALLOCATE(ICLSUM,IPSUM,INAMLOC,NMLTAR,NZONAR,NPVAL) DEALLOCATE (B) diff --git a/src/glo2sms-u1.f b/src/glo2sms-u1.f index d4609cd..2345dcf 100644 --- a/src/glo2sms-u1.f +++ b/src/glo2sms-u1.f @@ -42,6 +42,10 @@ SUBROUTINE SMS7U1AR(IN) C i = 1 Numtrack = 0 + THETA = 1.0 + Akappa = 0.0 + Gamma = 0.0 + Amomentum = 0.0 Btol = 0 Breduc = 0. RES_LIM = 0. @@ -237,11 +241,7 @@ SUBROUTINE SMS7U1AR(IN) ALLOCATE(HTEMP(NEQS)) ALLOCATE (Hncg(MXITER),Lrch(3,MXITER)) ALLOCATE (HncgL(MXITER),LrchL(MXITER)) - IF(NONMETH.GT.0)THEN - ALLOCATE (AMATFL(NJA)) - ELSE - AMATFL => AMAT - ENDIF + ALLOCATE (AMATFL(NJA)) IF(IABS(NONMETH).EQ.1)THEN ALLOCATE (Wsave(NEQS),hchold(NEQS),DEold(NEQS)) WSAVE = 0. @@ -347,6 +347,11 @@ SUBROUTINE GLO2SMS1AP(IOUT,KITER,ICNVG,KSTP,KPER) DEALLOCATE(HWADI, DWADI) IF(NOVFC.NE.1) DEALLOCATE (DWADIGW) IF(IWADICLN.NE.0) DEALLOCATE (DWADICC, DWADICG) + ELSE +C2H-------SAVE AMAT FOR USE IN MASS BALANCE CALCULATION + DO J=1,NJA + AMATFL(J) = AMAT(J) + ENDDO ENDIF C IF(ILAYCON4.EQ.1.OR.INCLN.GT.0)THEN @@ -362,13 +367,17 @@ SUBROUTINE GLO2SMS1AP(IOUT,KITER,ICNVG,KSTP,KPER) HTEMP(N) = HNEW(N) C3b-------SET DIRICHLET BOUNDARY AND NO-FLOW CONDITION IF(IBOUND(N).LE.0)THEN - AMAT(IA(N)) = 1.0*BIG - RHS(N) = HNEW(N)*BIG -CCB AMAT(IA(N)) = 1.0 -CCB RHS(N) = HNEW(N) -CCB DO JJ = IA(N)+1,IA(N+1)-1 -CCB AMAT(JJ) = AMAT(JJ) / BIG -CCB ENDDO + AMAT(IA(N)) = 1.0 + RHS(N) = HNEW(N) + DO JJ = IA(N)+1,IA(N+1)-1 + AMAT(JJ) = 0. + ENDDO +clang -- Replaced ibound<=0 approach in v 1.3.00 +ccb AMAT(IA(N)) = 1.0*BIG +ccb RHS(N) = HNEW(N)*BIG +ccb DO JJ = IA(N)+1,IA(N+1)-1 +ccb AMAT(JJ) = AMAT(JJ) / BIG +ccb ENDDO ELSE C3c---------TAKE CARE OF ZERO ROW DIAGONAL ADIAG = ABS(AMAT(IA(N))) @@ -540,14 +549,15 @@ SUBROUTINE SOLVERS(IOUT,KITER,ICNVG,KSTP,KPER,AMAT,SOLN,RHS,IBND, C2A---------CALL XMD SOLVER IF(ILUFLAG.EQ.0) GO TO 300 ! SKIP FACTORIZATION IF ONLY RHS IS UPDATED C2A1-------- ILU FACTORIZATION - IF(IDROPTOL.EQ.0)THEN + IF(IDROPTOL.EQ.0 .OR. ILUREUSE) THEN C2A2--------numerical factorization only for level based scheme call xmdnfctr(amat, rhs, ia, ja, nja, neqs, ierr) ELSE C2A3--------level/drop tolerance preconditioning call xmdprecd(amat, rhs, epsrn, ia, ja, nja, neqs, level, 1 ierr) - ENDIF + ILUREUSE = .TRUE. + END IF 300 CONTINUE C C2A4---------solve matrix @@ -917,7 +927,7 @@ SUBROUTINE SSMS2CLN1DK 2 NODES,NEQS,INCLN,IWADICLN USE CLN1MODULE, ONLY: ACLNNDS,NCLNNDS,CLNCON,NCLN,NNDCLN, 1 ACLNGWC,NCLNGWC,IFLINCLN,DWADICC,DWADICG, - 1 ICCWADICLN,ICGWADICLN,IA_CLN,JA_CLN + 1 ICCWADICLN,ICGWADICLN,IA_CLN,JA_CLN,IDXGLO_CLN USE SMSMODULE, ONLY: DKDH,DKDHC,NONMETH,EPSILON C DOUBLE PRECISION HD,BBOT,TTOP,THCK,ZERO,CONSTERM,FLOWTERM, @@ -953,34 +963,23 @@ SUBROUTINE SSMS2CLN1DK ND1 = ACLNNDS(NC1,1) ! NC1 + NODES ND2 = ACLNNDS(NC2,1) ! NC2 + NODES IF(IBOUND(ND1).EQ.0.OR.IBOUND(ND2).EQ.0) CYCLE -C2B---------FIND LOWER ROW NUMBER FOR UPPER DIAGONAL OF PGF - IF(ND2.GT.ND1)THEN - NL = ND1 - NH = ND2 - ELSE - NL = ND2 - NH = ND1 - ENDIF -C2C---------COMPUTE AND FILL DKDHC TERM FOR CLN-CLN CONNECTION - DO II = IA(NL)+1,IA(NL+1)-1 - JJ = JA(II) - IF(JJ.NE.NH) CYCLE + II = IDXGLO_CLN(II_CLN) IIS = JAS(II) C2D---------FIND UPSTREAM NODE AND HIGHER BOT NODE - IUPS = NL - IF(HNEW(JJ).GT.HNEW(NL)) IUPS = JJ - IHBOT = NL - BNL = ACLNNDS(NL-NODES,5) - BJJ = ACLNNDS(JJ-NODES,5) - BHBOT =BNL - IF(BJJ.GT.BNL) THEN - IHBOT = JJ - BHBOT = BJJ + IUPS = ND1 + IF(HNEW(ND2).GT.HNEW(ND1)) IUPS = ND2 + IHBOT = ND1 + BC1 = ACLNNDS(NC1,5) + BC2 = ACLNNDS(NC2,5) + BHBOT =BC1 + IF(BC2.GT.BC1) THEN + IHBOT = ND2 + BHBOT = BC2 ENDIF C2E---------FILL DKDHC FOR CONNECTION INDK = 0 IF(IUPS.EQ.IHBOT) INDK = 1 - IF(ABS(BJJ-BNL).LT.0.01) INDK = 1 + IF(ABS(BC2-BC1).LT.0.01) INDK = 1 IF(INDK.EQ.1)THEN DKDHC(IIS) = DKDH(IUPS) ELSEIF(IBOUND(IUPS).GT.0) THEN !DKDH IS ZERO ON CONSTANT HEAD NODE @@ -992,7 +991,6 @@ SUBROUTINE SSMS2CLN1DK CALL CLN_THIK(ICLN,HD,BHBOT,THCK) DKDHC(IIS) = (THCK - DKDHC(IIS))/(EPSILON) ENDIF - ENDDO C ENDDO ENDDO @@ -1114,7 +1112,7 @@ SUBROUTINE SSMS2WADITRAN 2 NODES,NEQS,INCLN,NOVFC,IWADICLN USE CLN1MODULE, ONLY: ACLNNDS,NCLNNDS,CLNCON,NCLN,NNDCLN, 1 ACLNGWC,HWADICC,DWADICC,HWADICG,DWADICG,NCLNGWC, - 2 IA_CLN,JA_CLN + 2 IA_CLN,JA_CLN,IDXGLO_CLN USE GWFBCFMODULE,ONLY:LAYCON,HWADIGW,DWADIGW USE SMSMODULE, ONLY: DKDHC,NONMETH,EPSILON C @@ -1174,24 +1172,13 @@ SUBROUTINE SSMS2WADITRAN ND1 = ACLNNDS(NC1,1) ! NC1 + NODES ND2 = ACLNNDS(NC2,1) ! NC2 + NODES IF(IBOUND(ND1).EQ.0.OR.IBOUND(ND2).EQ.0) CYCLE -C2B---------FIND LOWER ROW NUMBER FOR UPPER DIAGONAL OF PGF - IF(ND2.GT.ND1)THEN - NL = ND1 - NH = ND2 - ELSE - NL = ND2 - NH = ND1 - ENDIF -C2C---------FILL ARRAYS FOR CLN-CLN CONNECTION - DO II = IA(NL)+1,IA(NL+1)-1 - JJ = JA(II) - IF(JJ.NE.NH) CYCLE + II = IDXGLO_CLN(II_CLN) IIS = JAS(II) C2D---------FIND UPSTREAM AND DOWNSTREAM NODES - IUPS = NL - IF(HNEW(NH).GT.HNEW(NL)) IUPS = NH - IDN = NL - IF(IUPS.EQ.NL) IDN = NH + IUPS = ND1 + IF(HNEW(ND2).GT.HNEW(ND1)) IUPS = ND2 + IDN = ND1 + IF(IUPS.EQ.ND1) IDN = ND2 C IF(IWADICLN.EQ.1)THEN C2E-------------FILL ARRAYS WITH CORRECTED DOWNSTREAM HEADS OR HNEW STORED IN HWADICC @@ -1203,7 +1190,6 @@ SUBROUTINE SSMS2WADITRAN HWADI(IIS) = HNEW(IDN) DWADI(IIS) = 1.0 ENDIF - ENDDO ENDDO ENDDO C----------------------------------------------------------------------------- @@ -1588,6 +1574,7 @@ SUBROUTINE GWF2SMS7U1DA C DEALLOCATE(HTEMP) DEALLOCATE (Hncg,Lrch) + DEALLOCATE(AMATFL) DEALLOCATE (Akappa,Gamma,Amomentum,Breduc,Btol,Numtrack,THETA) DEALLOCATE (HncgL,LrchL) IF(IABS(NONMETH).EQ.1)THEN diff --git a/src/gmodules.f b/src/gmodules.f index 652e32e..68652fa 100644 --- a/src/gmodules.f +++ b/src/gmodules.f @@ -6,7 +6,7 @@ MODULE GLOBAL INTEGER, SAVE, POINTER :: IDEALLOC_LPF,IDEALLOC_HY,ISYMFLG INTEGER, SAVE, POINTER :: ITRNSP,NEQS,NODES,NJA,NJAS,NJAG INTEGER, SAVE, POINTER :: IOUT,IPRCONN,IDSYMRD,ILAYCON4,IWADI, - * IWADICLN + * IWADICLN,IDPF,IDPT INTEGER, SAVE, POINTER :: INCLN,INGNC,INGNC2,INGNCn INTEGER, SAVE,POINTER ::IFREFM,MXNODLAY,NOCVCO,ICONCV,NOVFC DOUBLE PRECISION, SAVE, POINTER::WADIEPS @@ -38,6 +38,7 @@ MODULE GLOBAL REAL, SAVE, DIMENSION(:),ALLOCATABLE ::CL1,CL2 REAL, SAVE, DIMENSION(:),ALLOCATABLE ::ARAD INTEGER, SAVE, DIMENSION(:), ALLOCATABLE ::NODLAY + INTEGER, SAVE, DIMENSION(:), ALLOCATABLE ::LAYNOD INTEGER, DIMENSION(:), ALLOCATABLE ::LAYCBD INTEGER, SAVE, DIMENSION(:), ALLOCATABLE ::LAYHDT INTEGER, SAVE, DIMENSION(:), ALLOCATABLE ::LAYHDS @@ -46,9 +47,10 @@ MODULE GLOBAL REAL, SAVE, DIMENSION(:), ALLOCATABLE ::TSMULT INTEGER, SAVE, DIMENSION(:), ALLOCATABLE ::ISSFLG REAL, SAVE, DIMENSION(:),ALLOCATABLE ::BUFF - REAL, SAVE, DIMENSION(:),ALLOCATABLE ::STRT + REAL, SAVE, DIMENSION(:), POINTER ::STRT DOUBLE PRECISION, SAVE, ALLOCATABLE, DIMENSION(:) ::HWADI DOUBLE PRECISION, SAVE, ALLOCATABLE, DIMENSION(:) ::DWADI + REAL, SAVE, DIMENSION(:), POINTER ::DDREF END MODULE GLOBAL C C ----------------------------------------------------------------------- @@ -86,6 +88,7 @@ MODULE GWFBASMODULE INTEGER, SAVE, DIMENSION(:,:), ALLOCATABLE ::IOFLG DOUBLE PRECISION, SAVE, DIMENSION(:,:), ALLOCATABLE ::VBVL CHARACTER(LEN=16), SAVE, DIMENSION(:), ALLOCATABLE ::VBNM + INTEGER, SAVE, POINTER ::IDDREF,IDDREFNEW END MODULE GWFBASMODULE C C ----------------------------------------------------------------------- @@ -126,6 +129,7 @@ MODULE CLN1MODULE INTEGER, SAVE, DIMENSION(:),ALLOCATABLE ::CLNCON INTEGER, SAVE, DIMENSION(:),POINTER ::IA_CLN INTEGER, SAVE, DIMENSION(:),POINTER ::JA_CLN + INTEGER, SAVE, DIMENSION(:),POINTER ::IDXGLO_CLN REAL, SAVE, DIMENSION(:,:),ALLOCATABLE ::ACLNNDS REAL, SAVE, DIMENSION(:,:),ALLOCATABLE ::ACLNGWC REAL, SAVE, DIMENSION(:,:),ALLOCATABLE ::ACLNCOND diff --git a/src/gwf2basu1.f b/src/gwf2basu1.f index 89c5be5..52720e7 100644 --- a/src/gwf2basu1.f +++ b/src/gwf2basu1.f @@ -501,12 +501,16 @@ SUBROUTINE SGWF2DIS8UR(IOUT,INDIS) C--------------------------------------------------------------------------- C C2------READ TOP ARRAY + ALLOCATE(TEMP(NODES)) DO K = 1,NLAY KK = K NNDLAY = NODLAY(K) NSTRT = NODLAY(K-1)+1 NDSLAY = NNDLAY - NODLAY(K-1) - CALL U1DREL8(TOP(NSTRT),ANAME(2),NDSLAY,K,INDIS,IOUT) + CALL U1DREL(TEMP(NSTRT),ANAME(2),NDSLAY,K,INDIS,IOUT) + ENDDO + DO J=1,NODES + TOP(J) = TEMP(J) ENDDO C C3------READ BOT ARRAY @@ -515,8 +519,12 @@ SUBROUTINE SGWF2DIS8UR(IOUT,INDIS) NNDLAY = NODLAY(K) NSTRT = NODLAY(K-1)+1 NDSLAY = NNDLAY - NODLAY(K-1) - CALL U1DREL8(BOT(NSTRT),ANAME(3),NDSLAY,K,INDIS,IOUT) + CALL U1DREL(TEMP(NSTRT),ANAME(3),NDSLAY,K,INDIS,IOUT) + ENDDO + DO J=1,NODES + BOT(J) = TEMP(J) ENDDO + DEALLOCATE(TEMP) C C4-----READ HORIZONTAL AREA IF(IVSD.EQ.-1)THEN @@ -953,7 +961,7 @@ SUBROUTINE SGWF2BAS7D(KSTP,KPER,IPFLG,ISA) C SPECIFICATIONS: C ------------------------------------------------------------------ USE GLOBAL, ONLY:NCOL,NROW,NLAY,IXSEC,HNEW,STRT,NODLAY, - 1 IBOUND,IOUT,SN,iunsat + 1 IBOUND,IOUT,SN,DDREF,iunsat USE GWFBASMODULE,ONLY:PERTIM,TOTIM,IDDNFM,IDDNUN,LBDDSV, 2 CDDNFM,IOFLG C @@ -980,7 +988,7 @@ SUBROUTINE SGWF2BAS7D(KSTP,KPER,IPFLG,ISA) DO 58 J=1,NCOL N = (K-1)*NROW*NCOL + (I-1)*NCOL + J BUFF(J,I,K)=HNEW(N) - SSTRT=STRT(N) + SSTRT=DDREF(N) IF(IBOUND(N).NE.0) BUFF(J,I,K)=SSTRT-HNEW(N) IF(IUNSAT.EQ.1) BUFF(J,I,K) = SN(N) 58 CONTINUE @@ -1393,7 +1401,6 @@ SUBROUTINE SGWF2BAS7HU(KSTP,KPER,IPFLG,ISA) CALL ULASV2U(BUFF,TEXT,KSTP,KPER,PERTIM,TOTIM,NSTRT, 1 NNDLAY,KK,IHEDUN,CHEDFM,LBHDSV,IBOUND(NSTRT),NODES) END IF - IPFLG=1 79 CONTINUE C C5A-----SAVE HEAD FOR CROSS SECTION. @@ -1407,7 +1414,6 @@ SUBROUTINE SGWF2BAS7HU(KSTP,KPER,IPFLG,ISA) CALL ULASV2U(BUFF,TEXT,KSTP,KPER,PERTIM,TOTIM,NSTRT, 1 NNDLAY,-1,IHEDUN,CHEDFM,LBHDSV,IBOUND,NODES) END IF - IPFLG=1 END IF END IF C diff --git a/src/gwf2bcf-lpf-u1.f b/src/gwf2bcf-lpf-u1.f index d60eb24..4acc62c 100644 --- a/src/gwf2bcf-lpf-u1.f +++ b/src/gwf2bcf-lpf-u1.f @@ -150,11 +150,7 @@ SUBROUTINE READBCF(IN) ELSE READ(IN,*) (LAYCON(I),I=1,NLAY) ENDIF -c---------hardwire to convert Surfact input to MF2K5_USGs input - do i=1,nlay - if(laycon(i).eq.43) laycon(i) = 04 - enddo -c------------end hardwire ------------------------------------- +C 51 FORMAT(40I2) WRITE(IOUT,52) 52 FORMAT(1X,5X,'LAYER LAYER-TYPE CODE INTERBLOCK T', @@ -265,7 +261,7 @@ SUBROUTINE READBCF(IN) ENDIF C8A-----FOR LAYERS WITH LAYCON=0 RESET TRANSMISSIVITIES TO HK VALUES DO K=1,NLAY - IF(LAYCON(K).EQ.0)THEN + IF(LAYCON(K).EQ.0.OR.LAYCON(K).EQ.2)THEN NNDLAY = NODLAY(K) NSTRT = NODLAY(K-1)+1 DO N=NSTRT,NNDLAY @@ -279,7 +275,7 @@ SUBROUTINE READBCF(IN) ENDIF ENDDO ENDIF - ENDDO + ENDDO C-------------------------------------------------------------------------------- C9------SET CONSTANT TERMS IN PGF ARRAY IF IT IS NOT READ DIRECTLY C-------FOR NODAL INPUT OF CONDUCTIVITIES @@ -697,20 +693,20 @@ SUBROUTINE SGWF2BCFU1G(IN) DO II = IA(N)+1,IA(N+1)-1 JJ = JA(II) IF(JJ.LE.NODES)THEN - IIS = JAS(II) + IIS = JAS(II) IF(JJ.GT.N)THEN AKN = AKN + PGF(IIS) / THICK * CL1(IIS) ELSE - AKN = AKN + PGF(IIS) / THICK * CL2(IIS) + AKN = AKN + PGF(IIS) / THICK * CL2(IIS) ENDIF IKN = IKN + 1 ENDIF ENDDO - IF(IKN.GT.0) THEN + IF(IKN.GT.0) THEN HK(N) = AKN / IKN ENDIF ENDDO -C----------------------------------------------------- +C----------------------------------------------------- DEALLOCATE(TEMP) ENDIF C @@ -1802,7 +1798,7 @@ SUBROUTINE GWF2BCFU1BDS(KSTP,KPER) C11----RETURN. RETURN END -C +C SUBROUTINE GWF2BCFU1BDCHWR(KSTP,KPER) C ****************************************************************** C SAVE FLOW FROM CONSTANT-HEAD CELLS @@ -1844,12 +1840,12 @@ SUBROUTINE GWF2BCFU1BDCHWR(KSTP,KPER) C--------------------------------------------------------------------------- IF(IBD.EQ.2) THEN C2A-----IF SAVING CELL-BY-CELL FLOW IN A LIST, COUNT CONSTANT-HEAD -C2A-----CELLS AND WRITE HEADER RECORDS. +C2A-----CELLS AND WRITE HEADER RECORDS. NCH=0 DO 7 N=1,NODES IF(IBOUND(N).LT.0) NCH=NCH+1 7 CONTINUE -C2B-------WRITE HEADER FOR THE LIST +C2B-------WRITE HEADER FOR THE LIST IF(IUNSTR.EQ.0)THEN CALL UBDSV2(KSTP,KPER,TEXT(1),IBCFCB,NCOL,NROW,NLAY, 1 NCH,IOUT,DELT,PERTIM,TOTIM,IBOUND) @@ -1886,7 +1882,7 @@ SUBROUTINE GWF2BCFU1BDCHWR(KSTP,KPER) IF(IBDLBL.EQ.0) WRITE(IOUT,899) TEXT(1),KPER,KSTP 899 FORMAT(1X,/1X,A,' PERIOD',I3,' STEP',I3) IF(IUNSTR.EQ.0)THEN - K = N / (NCOL*NROW) + 1 + K = N / (NCOL*NROW) + 1 IJ = N - (K-1)*NCOL*NROW I = (IJ-1)/NCOL + 1 J = IJ - (I-1)*NCOL @@ -1904,10 +1900,10 @@ SUBROUTINE GWF2BCFU1BDCHWR(KSTP,KPER) IF(IBD.EQ.2)THEN SRATE = RATE IF(IUNSTR.EQ.0)THEN - K = N / (NCOL*NROW) + 1 + K = N / (NCOL*NROW) + 1 IJ = N - (K-1)*NCOL*NROW I = (IJ-1)/NCOL + 1 - J = IJ - (I-1)*NCOL + J = IJ - (I-1)*NCOL CALL UBDSVA(IBCFCB,NCOL,NROW,J,I,K,SRATE,IBOUND,NLAY) ELSE CALL UBDSVAU(IBCFCB,NODES,N,SRATE,IBOUND) @@ -3057,7 +3053,7 @@ SUBROUTINE SGWF2LPFU1G(IN,NPHK,NPHANI,NPVK,NPVANI,NPSS,NPSY, DO IIS=1,NJAS PGF(IIS) = PGF(IIS) * TEMP(IIS) ENDDO -C-----------INCLUDE THICKNESS TERM +C-----------INCLUDE THICKNESS TERM DO N=1,NODES THICK1 = TOP(N) - BOT(N) C-----------GO OVER CONNECTIONS OF NODE N AND FILL FOR UPPER SYMMETRIC PART @@ -3414,17 +3410,19 @@ SUBROUTINE SGWF2LPFU1VCOND KK = K+1 C C4--------------CALCULATE VERTICAL HYDRAULIC CONDUCTIVITY FOR CELL. + hyc1 = 0.0 IF(LAYVKA(K).EQ.0) THEN HYC1=VKA(N) ELSE - HYC1=HK(N)/VKA(N) + if(vka(n).gt.1.0e-20) HYC1=HK(N)/VKA(N) END IF IF(HYC1.GT.ZERO) THEN C5----------------CALCULATE VERTICAL HYDRAULIC CONDUCTIVITY FOR ADJACENT CELL. + hyc2 = 0.0 IF(LAYVKA(KK).EQ.0) THEN HYC2=VKA(JJ) ELSE - HYC2=(HK(JJ)/VKA(JJ)) + if(vka(jj).gt.1.0e-20) HYC2=(HK(JJ)/VKA(JJ)) END IF IF(HYC2.GT.ZERO) THEN C @@ -3440,7 +3438,7 @@ SUBROUTINE SGWF2LPFU1VCOND TTOP=TOP(JJ) IF(LAYSTRT(KK).NE.0) TTOP=STRT(JJ) BOVK2=(TTOP-BBOT)*HALF/HYC2 - IF(BOVK2.LT.1.0E-20) BOVK2 = 1.0E-20 + IF(BOVK2.LT.1.0E-20) BOVK2 = 1.0E-20 C C8------------------CALCULATE VERTICAL HYDRAULIC CONDUCTIVITY FOR CONFINING BED. IUP = N diff --git a/src/gwf2chd7u1.f b/src/gwf2chd7u1.f index a45c73a..ffad1c4 100644 --- a/src/gwf2chd7u1.f +++ b/src/gwf2chd7u1.f @@ -13,7 +13,7 @@ SUBROUTINE GWF2CHD7U1AR(IN) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,NODES,IUNSTR + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,NODES,IUNSTR,NEQS USE GWFCHDMODULE,ONLY:NCHDS,MXCHD,NCHDVL,IPRCHD,NPCHD,ICHDPB, 1 NNPCHD,CHDAUX,CHDS CHARACTER*200 LINE @@ -102,7 +102,7 @@ SUBROUTINE GWF2CHD7U1AR(IN) ELSE CALL ULSTRDU(NLST,CHDS,LB,NCHDVL,MXCHD,0,IN,IOUT, & 'CHD NO. NODE START FACTOR END FACTOR', - & CHDAUX,5,NAUX,IFREFM,NODES,4,5,IPRCHD) + & CHDAUX,5,NAUX,IFREFM,NEQS,4,5,IPRCHD) ENDIF LB=LB+NLST 110 CONTINUE @@ -119,7 +119,8 @@ SUBROUTINE GWF2CHD7U1RP(IN) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,IBOUND,IUNSTR,NODES + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,IBOUND,IUNSTR,NODES, + 1 NEQS USE GWFCHDMODULE,ONLY:NCHDS,MXCHD,NCHDVL,IPRCHD,NPCHD,ICHDPB, 1 NNPCHD,CHDAUX,CHDS C ------------------------------------------------------------------ @@ -176,7 +177,7 @@ SUBROUTINE GWF2CHD7U1RP(IN) ELSE CALL ULSTRDU(NNPCHD,CHDS,1,NCHDVL,MXCHD,0,IN,IOUT, & 'CHD NO. NODE START HEAD END HEAD', - & CHDAUX,5,NAUX,IFREFM,NODES,4,5,IPRCHD) + & CHDAUX,5,NAUX,IFREFM,NEQS,4,5,IPRCHD) ENDIF END IF NCHDS=NNPCHD diff --git a/src/gwf2drn7u1.f b/src/gwf2drn7u1.f index 9eca127..66b28de 100644 --- a/src/gwf2drn7u1.f +++ b/src/gwf2drn7u1.f @@ -21,7 +21,8 @@ SUBROUTINE GWF2DRN7U1AR(IN) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,NODES,IUNSTR + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,NODES,IUNSTR, + 1 NEQS USE GWFDRNMODULE, ONLY:NDRAIN,MXDRN,NDRNVL,IDRNCB,IPRDRN,NPDRN, 1 IDRNPB,NNPDRN,DRNAUX,DRAI CHARACTER*200 LINE @@ -103,7 +104,7 @@ SUBROUTINE GWF2DRN7U1AR(IN) ELSE CALL ULSTRDU(NLST,DRAI,LSTBEG,NDRNVL,MXDRN,1,IN,IOUT, 1 'DRAIN NO. NODE DRAIN EL. CONDUCTANCE', - 2 DRNAUX,5,NAUX,IFREFM,NODES,5,5,IPRDRN) + 2 DRNAUX,5,NAUX,IFREFM,NEQS,5,5,IPRDRN) ENDIF ELSE C5B-----READ INSTANCES @@ -114,13 +115,12 @@ SUBROUTINE GWF2DRN7U1AR(IN) CALL ULSTRD(NINLST,DRAI,LSTBEG,NDRNVL,MXDRN,1,IN,IOUT, & 'DRAIN NO. LAYER ROW COL DRAIN EL. STRESS FACTOR', & DRNAUX,20,NAUX,IFREFM,NCOL,NROW,NLAY,5,5,IPRDRN) - LSTBEG=LSTBEG+NINLST ELSE CALL ULSTRDU(NINLST,DRAI,LSTBEG,NDRNVL,MXDRN,1,IN,IOUT, 1 'DRAIN NO. NODE DRAIN EL. CONDUCTANCE', - 2 DRNAUX,20,NAUX,IFREFM,NODES,5,5,IPRDRN) + 2 DRNAUX,20,NAUX,IFREFM,NEQS,5,5,IPRDRN) ENDIF - + LSTBEG=LSTBEG+NINLST 110 CONTINUE END IF 120 CONTINUE @@ -136,7 +136,8 @@ SUBROUTINE GWF2DRN7U1RP(IN) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,IUNSTR,NODES + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,IUNSTR,NODES, + 1 NEQS USE GWFDRNMODULE, ONLY:NDRAIN,MXDRN,NDRNVL,IPRDRN,NPDRN, 1 IDRNPB,NNPDRN,DRNAUX,DRAI C ------------------------------------------------------------------ @@ -193,7 +194,7 @@ SUBROUTINE GWF2DRN7U1RP(IN) ELSE CALL ULSTRDU(NNPDRN,DRAI,1,NDRNVL,MXDRN,1,IN,IOUT, 1 'DRAIN NO. NODE DRAIN EL. CONDUCTANCE', - 2 DRNAUX,20,NAUX,IFREFM,NODES,5,5,IPRDRN) + 2 DRNAUX,20,NAUX,IFREFM,NEQS,5,5,IPRDRN) ENDIF END IF NDRAIN=NNPDRN diff --git a/src/gwf2evt8u1.f b/src/gwf2evt8u1.f index 5af25aa..6c11e49 100644 --- a/src/gwf2evt8u1.f +++ b/src/gwf2evt8u1.f @@ -455,6 +455,7 @@ SUBROUTINE GWF2EVT8U1BD(KSTP,KPER,INBCT) C DOUBLE PRECISION RATOUT,QQ,HH,SS,DD,XX,HHCOF,RRHS INTEGER,ALLOCATABLE,DIMENSION(:,:) :: ITEMP + INTEGER,ALLOCATABLE,DIMENSION(:) :: IBUFF CHARACTER*16 TEXT DATA TEXT /' ET'/ C ------------------------------------------------------------------ @@ -474,6 +475,7 @@ SUBROUTINE GWF2EVT8U1BD(KSTP,KPER,INBCT) ENDIF IBD=0 IF(IEVTCB.GT.0) IBD=ICBCFL + ALLOCATE(IBUFF(NIEVT)) C C4------PROCESS EACH HORIZONTAL CELL LOCATION. DO 10 NN=1,NIEVT @@ -483,6 +485,7 @@ SUBROUTINE GWF2EVT8U1BD(KSTP,KPER,INBCT) IF(NEVTOP.EQ.3.AND.IBOUND(N).EQ.0)THEN CALL FIRST_ACTIVE_BELOW(N) ENDIF + IBUFF(NN) = N C C7------IF CELL IS EXTERNAL THEN IGNORE IT. IF(IBOUND(N).LE.0)GO TO 10 @@ -527,7 +530,7 @@ SUBROUTINE GWF2EVT8U1BD(KSTP,KPER,INBCT) DO I=1,NROW DO J=1,NCOL N=N+1 - ITEMP(J,I)= (IEVT(N)-1) / (NCOL*NROW) + 1 + ITEMP(J,I)= (IBUFF(N)-1) / (NCOL*NROW) + 1 ENDDO ENDDO CALL UBDSV3(KSTP,KPER,TEXT,IEVTCB,BUFF,ITEMP,NEVTOP, @@ -537,7 +540,7 @@ SUBROUTINE GWF2EVT8U1BD(KSTP,KPER,INBCT) ELSE IF(IBD.EQ.1) CALL UBUDSVU(KSTP,KPER,TEXT,IEVTCB,BUFF,NODES, 1 IOUT,PERTIM,TOTIM) - IF(IBD.EQ.2) CALL UBDSV3U(KSTP,KPER,TEXT,IEVTCB,BUFF,IEVT, + IF(IBD.EQ.2) CALL UBDSV3U(KSTP,KPER,TEXT,IEVTCB,BUFF,IBUFF, 1 NIEVT,NEVTOP,NODES,IOUT,DELT,PERTIM,TOTIM,IBOUND) ENDIF C @@ -554,6 +557,7 @@ SUBROUTINE GWF2EVT8U1BD(KSTP,KPER,INBCT) C C17-----INCREMENT BUDGET TERM COUNTER. MSUM=MSUM+1 + DEALLOCATE(IBUFF) C C18-----RETURN. RETURN diff --git a/src/gwf2fhb7u1.f b/src/gwf2fhb7u1.f index 0c48c5d..98b23e4 100644 --- a/src/gwf2fhb7u1.f +++ b/src/gwf2fhb7u1.f @@ -591,7 +591,7 @@ SUBROUTINE GWF2FHB7U1BD(KSTP,KPER) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IBOUND,BUFF,IUNSTR,NJA + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IBOUND,BUFF,IUNSTR,NODES USE GWFBASMODULE,ONLY:MSUM,VBVL,VBNM,ICBCFL,DELT,PERTIM,TOTIM USE GWFFHBMODULE,ONLY:NBDTIM,NFLW,NHED,IFHBCB,NFHBX1,NFHBX2, 1 IFHBSS,IFLLOC,IHDLOC,BDTIM,FLWRAT,SBHED, @@ -699,7 +699,7 @@ SUBROUTINE GWF2FHB7U1BD(KSTP,KPER) CALL UBUDSV(KSTP,KPER,TEXT,IFHBCB,BUFF,NCOL,NROW, 1 NLAY,IOUT) ELSE - CALL UBUDSVU(KSTP,KPER,TEXT,IFHBCB,BUFF,NJA, + CALL UBUDSVU(KSTP,KPER,TEXT,IFHBCB,BUFF,NODES, 1 IOUT,PERTIM,TOTIM) ENDIF ENDIF diff --git a/src/gwf2ghb7u1.f b/src/gwf2ghb7u1.f index b238290..00d4891 100644 --- a/src/gwf2ghb7u1.f +++ b/src/gwf2ghb7u1.f @@ -21,7 +21,8 @@ SUBROUTINE GWF2GHB7U1AR(IN) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,NODES,IUNSTR + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,NODES,IUNSTR, + 1 NEQS USE GWFGHBMODULE, ONLY:NBOUND,MXBND,NGHBVL,IGHBCB,IPRGHB,NPGHB, 1 IGHBPB,NNPGHB,GHBAUX,BNDS C @@ -106,7 +107,7 @@ SUBROUTINE GWF2GHB7U1AR(IN) ELSE CALL ULSTRDU(NLST,BNDS,LSTBEG,NGHBVL,MXBND,1,IN,IOUT, 1 'BOUND NO. NODE STAGE CONDUCTANCE', - 2 GHBAUX,20,NAUX,IFREFM,NODES,5,5,IPRGHB) + 2 GHBAUX,20,NAUX,IFREFM,NEQS,5,5,IPRGHB) ENDIF ELSE C5B-----READ INSTANCES @@ -120,7 +121,7 @@ SUBROUTINE GWF2GHB7U1AR(IN) ELSE CALL ULSTRDU(NINLST,BNDS,LSTBEG,NGHBVL,MXBND,1,IN,IOUT, 1 'BOUND NO. NODE STAGE CONDUCTANCE', - 2 GHBAUX,20,NAUX,IFREFM,NODES,5,5,IPRGHB) + 2 GHBAUX,20,NAUX,IFREFM,NEQS,5,5,IPRGHB) ENDIF LSTBEG=LSTBEG+NINLST 110 CONTINUE @@ -138,7 +139,8 @@ SUBROUTINE GWF2GHB7U1RP(IN) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,IUNSTR,NODES + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,IUNSTR,NODES, + 1 NEQS USE GWFGHBMODULE, ONLY:NBOUND,MXBND,NGHBVL,IPRGHB,NPGHB, 1 IGHBPB,NNPGHB,GHBAUX,BNDS C ------------------------------------------------------------------ @@ -195,7 +197,7 @@ SUBROUTINE GWF2GHB7U1RP(IN) ELSE CALL ULSTRDU(NNPGHB,BNDS,1,NGHBVL,MXBND,1,IN,IOUT, 1 'BOUND NO. NODE STAGE CONDUCTANCE', - 2 GHBAUX,20,NAUX,IFREFM,NODES,5,5,IPRGHB) + 2 GHBAUX,20,NAUX,IFREFM,NEQS,5,5,IPRGHB) ENDIF END IF NBOUND=NNPGHB diff --git a/src/gwf2hfb7u1.f b/src/gwf2hfb7u1.f index 1b569b6..333754c 100644 --- a/src/gwf2hfb7u1.f +++ b/src/gwf2hfb7u1.f @@ -152,7 +152,7 @@ SUBROUTINE GWF2HFB7U1FM C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:NCOL,NROW,HNEW,TOP,BOT,IBOUND, + USE GLOBAL, ONLY:NCOL,NROW,HNEW,TOP,BOT,IBOUND,IVC, 1 AMAT,PGF,FAHL,IA,JA,JAS,ISYM USE GWFBCFMODULE, ONLY: LAYCON USE GWFHFBMODULE,ONLY:NHFB,HFB @@ -176,20 +176,27 @@ SUBROUTINE GWF2HFB7U1FM IF(IBOUND(N1).EQ.0.OR.IBOUND(N2).EQ.0) CYCLE C HCDW = HFB(6,II) -C -C8------CALCULATE AVERAGE SATURATED THICKNESS BETWEEN CELLS N1 AND N2. - HD1 = HNEW(N1) - HD2 = HNEW(N2) - IF (HD1.GT.TOP(N1)) HD1 = TOP(N1) - IF (HD2.GT.TOP(N2)) HD2 = TOP(N2) - IF (HD1.LT.BOT(N1))HD1 = BOT(N1) - IF (HD2.LT.BOT(N2))HD2 = BOT(N2) - THKAVG = ((HD1-BOT(N1)) + (HD2-BOT(N2)))/2. C-------------FIND BARRIER LOCATION AND ADJUST AMAT DO IAJ = IA(N1)+1,IA(N1+1)-1 JJ = JA(IAJ) IAJS = JAS(IAJ) IF(JJ.EQ.N2)THEN +C +C8----------CALCULATE AVERAGE SATURATED THICKNESS BETWEEN CELLS N1 AND N2. + HD1 = HNEW(N1) + HD2 = HNEW(N2) + IF (HD1.GT.TOP(N1)) HD1 = TOP(N1) + IF (HD2.GT.TOP(N2)) HD2 = TOP(N2) + IF(IVC(IAJS).EQ.2)THEN + BMAX = MAX( BOT(N1),BOT(N2)) + IF (HD1.LT.BMAX)HD1 = BMAX + IF (HD2.LT.BMAX)HD2 = BMAX + THKAVG = 0.5*(TH1+TH2) + ELSE + IF (HD1.LT.BOT(N1))HD1 = BOT(N1) + IF (HD2.LT.BOT(N2))HD2 = BOT(N2) + THKAVG = ((HD1-BOT(N1)) + (HD2-BOT(N2)))/2. + ENDIF HFB(7,II) = PGF(IAJS) TDW = THKAVG*HCDW C-------------FILL TERM AND DIAGONAL @@ -221,7 +228,7 @@ SUBROUTINE SGWF2HFB7MC C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,TOP,BOT,PGF,FAHL,IA,JA,JAS,ISYM + USE GLOBAL, ONLY:IOUT,TOP,BOT,PGF,FAHL,IA,JA,JAS,ISYM,IVC USE GWFBCFMODULE, ONLY: LAYCON USE GWFHFBMODULE,ONLY:NHFB,HFB C ------------------------------------------------------------------ @@ -238,15 +245,20 @@ SUBROUTINE SGWF2HFB7MC N2 = HFB(2,II) K = HFB(3,II) IF (LAYCON(K).EQ.3.OR.LAYCON(K).EQ.1) CYCLE - TH0 = TOP(N1) - BOT(N1) - TH1 = TOP(N2) - BOT(N2) - THKAVG = (TH0+TH1)/2.0 - TDW = THKAVG*HFB(6,II) +C C ------FIND BARRIER LOCATION AND ADJUST PGF DO IAJ = IA(N1)+1,IA(N1+1)-1 JJ = JA(IAJ) IAJS = JAS(IAJ) IF(JJ.EQ.N2)THEN + TH0 = TOP(N1) - BOT(N1) + TH1 = TOP(N2) - BOT(N2) + IF(IVC(IAJS).EQ.2)THEN + THKAVG = MIN(TH0,TH1) + ELSE + THKAVG = (TH0+TH1)/2.0 + ENDIF + TDW = THKAVG*HFB(6,II) HFB(7,II) = PGF(IAJS) PGF(IAJS) = TDW*PGF(IAJS)*FAHL(IAJS)/ * (TDW*FAHL(IAJS) + PGF(IAJS)) @@ -323,12 +335,12 @@ SUBROUTINE SGWF2HFB7RL(NLIST,HFB,LSTBEG,MXHFB,INPACK, DATA DASH/120*'-'/ DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C @@ -440,12 +452,12 @@ SUBROUTINE SGWF2HFB7RLU(NLIST,HFB,LSTBEG,MXHFB,INPACK, DATA DASH/120*'-'/ DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C diff --git a/src/gwf2lak7u1.f b/src/gwf2lak7u1.f index 3f5f420..40a80fb 100644 --- a/src/gwf2lak7u1.f +++ b/src/gwf2lak7u1.f @@ -183,7 +183,7 @@ SUBROUTINE GWF2LAK7U1AR(IN,IUNITSFR,IUNITGWT,IUNITUZF,NSOL) C VALUE OF MXLKND (NUMBER OF LAKE-AQUIFER INTERFACES) IS AN ESTIMATE. C TO SAVE MEMORY, REDUCE ITS SIZE IF APPROPRIATE. C IF MXLKND TOO SMALL, ERROR MESSAGE WILL BE PRINTED. - NODES = NCOL*NROW*NLAY +csp NODES = NCOL*NROW*NLAY MXLKND=NODES/2 IF (NLAKES.LT.1) THEN WRITE(IOUT,2) @@ -682,7 +682,7 @@ SUBROUTINE GWF2LAK7U1RPS(IN,IUNITBCF,IUNITGWT,IUNITLPF,IUNITHUF, IF(K.EQ.NLAY.AND.LKARR1(N).NE.0) BEDLAK(M) = 0.0 BGAREA(LID) = BGAREA(LID) + DELC(J)*DELR(I) WRITE(IOUT,5) K,J,I,(ILAKE(I1,M),I1=4,5), BEDLAK(M) -5 FORMAT(5I10,10X,F10.5) +5 FORMAT(5I10,10X,G10.5) IF(LKARR1(N).NE.0) GO TO 180 C C SEARCH FOR CELL(S) ADJACENT TO LAKE @@ -1295,7 +1295,8 @@ SUBROUTINE GWF2LAK7U1RPU(IN,IUNITBCF,IUNITGWT,IUNITLPF,IUNITHUF, C 150 K2 = K DO 175 K1=K2,NLAY - NL1 = NL + (K1-1)*NODLAY(1) +CSP NL1 = NL + (K1-1)*NODLAY(1) + NL1 = NL + NODLAY(K1-1) ! IF(LKARR1(NL1).EQ.0) CYCLE C I1 = IA(NL1)+1 @@ -1321,7 +1322,8 @@ SUBROUTINE GWF2LAK7U1RPU(IN,IUNITBCF,IUNITGWT,IUNITLPF,IUNITHUF, BEDLAK(M) = BDLKN1(NL1) K4 = K1 - 1 DO 3158 K3=1,K4 - NL3 = NL + (K3-1)*NODLAY(1) +CSP NL3 = NL + (K3-1)*NODLAY(1) + NL3 = NL + NODLAY(K3-1) IF(LKARR1(NL3).EQ.0) GO TO 3158 GO TO 3162 3158 CONTINUE @@ -3566,9 +3568,9 @@ SUBROUTINE SGWF2LAK7BCFU1RPS() IF(BEDLAK(II).LE.0.0) GO TO 315 IWRN1 = 1 CNDFC1 = BEDLAK(II)*AREA(N) - IF (IWDFLG.EQ.0) THEN - CNDFCT(II) = CNDFC1 - ELSE +! IF (IWDFLG.EQ.0) THEN !RGN 12/13/13 +! CNDFCT(II) = CNDFC1 !RGN 12/13/13 +! ELSE !RGN 12/13/13 DO IIN =IA(NTYP)+1, IA(NTYP+1)-1 !NTYP IS THE ABOVE NODE, N IS THE BELOW NODE JJ = JA(IIN) IF(JJ.EQ.N)GO TO 210 @@ -3577,9 +3579,9 @@ SUBROUTINE SGWF2LAK7BCFU1RPS() IINS = JAS(IIN) IF(PGF(IINS).LE.0.0.OR.CNDFC1.LE.0.0) GO TO 315 CNDFCT(II) = 1.0/(0.5/PGF(IINS)+1.0/CNDFC1) ! PGF(IINS) CONTAINS THE CV FOR ABOVE NODE TO THIS NODE - END IF - 315 IF (IWDFLG.EQ.0) THEN - IF(IUNSTR.EQ.0)THEN +! END IF !RGN 12/13/13 +! 315 IF (IWDFLG.EQ.0) THEN !RGN 12/13/13 +315 IF(IUNSTR.EQ.0)THEN !RGN added 315 here, 12/13/13 WRITE(IOUT,7324)K, J, I, 1 (ILAKE(I1,II),I1=4,5),DELC(J),DELR(I), 1 BEDLAK(II),CNDFC1,CNDFCT(II) @@ -3590,21 +3592,21 @@ SUBROUTINE SGWF2LAK7BCFU1RPS() 1 BEDLAK(II),CNDFC1,CNDFCT(II) 7334 FORMAT(I8,I3,I8,4X,1P,E10.2,8X,2E10.2,10X,E10.2) ENDIF - ELSE - IINS = JAS(IIN) - CVWD2= 2.0*PGF(IINS) - IF(IUNSTR.EQ.0)THEN - WRITE(IOUT,7325)K, J, I, - 1 (ILAKE(I1,II),I1=4,5),DELC(J),DELR(I), - 1 BEDLAK(II),CNDFC1,CVWD2,CNDFCT(II) - 7325 FORMAT(1X,5I3,2X,1P,6E10.2) - ELSE - WRITE(IOUT,7335) ILAKE(1,II), - 1 (ILAKE(I1,II),I1=4,5),AREA(N), - 1 BEDLAK(II),CNDFC1,CVWD2,CNDFCT(II) +! ELSE !RGN 12/13/13 +! IINS = JAS(IIN) !RGN 12/13/13 +! CVWD2= 2.0*PGF(IINS) !RGN 12/13/13 +! IF(IUNSTR.EQ.0)THEN !RGN 12/13/13 +! WRITE(IOUT,7325)K, J, I, !RGN 12/13/13 +! 1 (ILAKE(I1,II),I1=4,5),DELC(J),DELR(I), !RGN 12/13/13 +! 1 BEDLAK(II),CNDFC1,CVWD2,CNDFCT(II) !RGN 12/13/13 + 7325 FORMAT(1X,5I3,2X,1P,6E10.2) +! ELSE !RGN 12/13/13 +! WRITE(IOUT,7335) ILAKE(1,II), !RGN 12/13/13 +! 1 (ILAKE(I1,II),I1=4,5),AREA(N), !RGN 12/13/13 +! 1 BEDLAK(II),CNDFC1,CVWD2,CNDFCT(II) !RGN 12/13/13 7335 FORMAT(I8,I3,I8,4X,1P,E10.2,8X,4E10.2) - ENDIF - END IF +! ENDIF !RGN 12/13/13 +! END IF !RGN 12/13/13 ELSE C C Horizontal conductance @@ -4337,6 +4339,7 @@ subroutine FIRST_ACTIVE_BELOW2(N) 3 CONTINUE JJ = N + NNDLAY ! if deepest layer then return original value for N + if(jj.gt.nodes) go to 2 IF(IBOUND(JJ).NE.0)THEN ! on const head node is ok (no effect) N = JJ GO TO 2 diff --git a/src/gwf2rch8u1.f b/src/gwf2rch8u1.f index 4241250..905646b 100644 --- a/src/gwf2rch8u1.f +++ b/src/gwf2rch8u1.f @@ -3,9 +3,10 @@ MODULE GWFRCHMODULE INTEGER,SAVE, POINTER ::NPRCH,IRCHPF,INIRCH,NIRCH REAL, SAVE, DIMENSION(:), ALLOCATABLE ::RECH INTEGER, SAVE, DIMENSION(:), ALLOCATABLE ::IRCH + REAL, SAVE, DIMENSION(:), ALLOCATABLE ::RCHF END MODULE GWFRCHMODULE C - SUBROUTINE GWF2RCH8U1AR(IN) + SUBROUTINE GWF2RCH8U1AR(IN,INBCT) C ****************************************************************** C ALLOCATE ARRAY STORAGE FOR RECHARGE C ****************************************************************** @@ -14,7 +15,7 @@ SUBROUTINE GWF2RCH8U1AR(IN) C ------------------------------------------------------------------ USE GLOBAL, ONLY:IOUT,NCOL,NROW,IFREFM,NODLAY,IUNSTR USE GWFRCHMODULE,ONLY:NRCHOP,IRCHCB,NPRCH,IRCHPF,RECH,IRCH, - 1 MXNDRCH,INIRCH,NIRCH + 1 MXNDRCH,INIRCH,NIRCH,RCHF C CHARACTER*200 LINE CHARACTER*4 PTYP @@ -74,6 +75,10 @@ SUBROUTINE GWF2RCH8U1AR(IN) C7------ARRAYS. ALLOCATE (RECH(MXNDRCH)) ALLOCATE (IRCH(MXNDRCH)) +C8------IF TRANSPORT IS ACTIVE THEN ALLOCATE ARRAY TO STORE FLUXES + IF(INBCT.GT.0)THEN + ALLOCATE (RCHF(MXNDRCH)) + ENDIF C C8------READ NAMED PARAMETERS WRITE(IOUT,5) NPRCH @@ -329,7 +334,7 @@ subroutine FIRST_ACTIVE_BELOW(N) C------RETURN RETURN END - SUBROUTINE GWF2RCH8U1BD(KSTP,KPER) + SUBROUTINE GWF2RCH8U1BD(KSTP,KPER,INBCT) C ****************************************************************** C CALCULATE VOLUMETRIC BUDGET FOR RECHARGE C ****************************************************************** @@ -339,12 +344,13 @@ SUBROUTINE GWF2RCH8U1BD(KSTP,KPER) USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IBOUND,BUFF,IA,JA,JAS,NODES, 1 NODLAY,IUNSTR,IVC,hnew USE GWFBASMODULE,ONLY:MSUM,VBVL,VBNM,ICBCFL,DELT,PERTIM,TOTIM - USE GWFRCHMODULE,ONLY:NRCHOP,IRCHCB,RECH,IRCH,NIRCH + USE GWFRCHMODULE,ONLY:NRCHOP,IRCHCB,RECH,IRCH,NIRCH,RCHF C DOUBLE PRECISION RATIN,RATOUT,QQ DOUBLE PRECISION RECHFLUX,acoef,eps,pe,hd,rch CHARACTER*16 TEXT INTEGER,ALLOCATABLE,DIMENSION(:,:) :: ITEMP + INTEGER,ALLOCATABLE,DIMENSION(:) :: IBUFF DATA TEXT /' RECHARGE'/ C ------------------------------------------------------------------ C @@ -357,8 +363,14 @@ SUBROUTINE GWF2RCH8U1BD(KSTP,KPER) DO 2 N=1,NODES BUFF(N)=ZERO 2 CONTINUE + IF(INBCT.GT.0)THEN + DO N=1,NIRCH + RCHF(N) = ZERO + ENDDO + ENDIF IBD=0 IF(IRCHCB.GT.0) IBD=ICBCFL + ALLOCATE(IBUFF(NIRCH)) C C5------PROCESS EACH RECHARGE CELL LOCATION. DO 10 NN=1,NIRCH @@ -369,6 +381,7 @@ SUBROUTINE GWF2RCH8U1BD(KSTP,KPER) IF(NRCHOP.EQ.3.AND.IBOUND(N).EQ.0)THEN CALL FIRST_ACTIVE_BELOW(N) ENDIF + IBUFF(NN) = N C--------------------------------------------------------- C5A-----IF CELL IS VARIABLE HEAD, THEN DO BUDGET FOR IT. IF(IBOUND(N).GT.0) THEN @@ -377,6 +390,7 @@ SUBROUTINE GWF2RCH8U1BD(KSTP,KPER) C C5B-----ADD RECH TO BUFF. BUFF(N)=QQ + IF(INBCT.GT.0) RCHF(NN) = Q C C5C-----IF RECH POSITIVE ADD IT TO RATIN, ELSE ADD IT TO RATOUT. IF(Q.GE.ZERO) THEN @@ -398,7 +412,7 @@ SUBROUTINE GWF2RCH8U1BD(KSTP,KPER) DO I=1,NROW DO J=1,NCOL N=N+1 - ITEMP(J,I)= (IRCH(N)-1) / (NCOL*NROW) + 1 + ITEMP(J,I)= (IBUFF(N)-1) / (NCOL*NROW) + 1 ENDDO ENDDO CALL UBDSV3(KSTP,KPER,TEXT,IRCHCB,BUFF,ITEMP,NRCHOP, @@ -408,7 +422,7 @@ SUBROUTINE GWF2RCH8U1BD(KSTP,KPER) ELSE IF(IBD.EQ.1) CALL UBUDSVU(KSTP,KPER,TEXT,IRCHCB,BUFF,NODES, 1 IOUT,PERTIM,TOTIM) - IF(IBD.EQ.2) CALL UBDSV3U(KSTP,KPER,TEXT,IRCHCB,BUFF,IRCH, + IF(IBD.EQ.2) CALL UBDSV3U(KSTP,KPER,TEXT,IRCHCB,BUFF,IBUFF, 1 NIRCH,NRCHOP,NODES,IOUT,DELT,PERTIM,TOTIM,IBOUND) ENDIF C @@ -427,12 +441,13 @@ SUBROUTINE GWF2RCH8U1BD(KSTP,KPER) C C12-----INCREMENT BUDGET TERM COUNTER. MSUM=MSUM+1 + DEALLOCATE(IBUFF) C C13-----RETURN RETURN END C---------------------------------------------------------------- - SUBROUTINE GWF2RCH8U1DA + SUBROUTINE GWF2RCH8U1DA(INBCT) C Deallocate RCH DATA USE GWFRCHMODULE C @@ -445,6 +460,9 @@ SUBROUTINE GWF2RCH8U1DA DEALLOCATE(NIRCH) DEALLOCATE(RECH) DEALLOCATE(IRCH) + IF(INBCT.GT.0)THEN + DEALLOCATE(RCHF) + ENDIF C RETURN END diff --git a/src/gwf2riv7u1.f b/src/gwf2riv7u1.f index 22812b0..0fb5111 100644 --- a/src/gwf2riv7u1.f +++ b/src/gwf2riv7u1.f @@ -13,7 +13,8 @@ SUBROUTINE GWF2RIV7U1AR(IN) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,NODES,IUNSTR + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,NODES,IUNSTR, + 1 NEQS USE GWFRIVMODULE, ONLY:NRIVER,MXRIVR,NRIVVL,IRIVCB,IPRRIV,NPRIV, 1 IRIVPB,NNPRIV,RIVAUX,RIVR C @@ -100,7 +101,7 @@ SUBROUTINE GWF2RIV7U1AR(IN) CALL ULSTRDU(NLST,RIVR,LSTBEG,NRIVVL,MXRIVR,1,IN, & IOUT,'REACH NO. NODE '// & ' STAGE STRESS FACTOR BOTTOM EL.', - & RIVAUX,5,NAUX,IFREFM,NODES,5,5,IPRRIV) + & RIVAUX,5,NAUX,IFREFM,NEQS,5,5,IPRRIV) ENDIF ELSE C6B-----READ INSTANCES @@ -116,7 +117,7 @@ SUBROUTINE GWF2RIV7U1AR(IN) CALL ULSTRDU(NINLST,RIVR,LSTBEG,NRIVVL,MXRIVR,1,IN,IOUT, 1 'REACH NO. NODE '// 2 ' STAGE CONDUCTANCE BOTTOM EL.', - 3 RIVAUX,20,NAUX,IFREFM,NODES,5,5,IPRRIV) + 3 RIVAUX,20,NAUX,IFREFM,NEQS,5,5,IPRRIV) ENDIF LSTBEG=LSTBEG+NINLST 110 CONTINUE @@ -133,7 +134,8 @@ SUBROUTINE GWF2RIV7U1RP(IN) C C SPECIFICATIONS: C ------------------------------------------------------------------ - USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,IUNSTR,NODES + USE GLOBAL, ONLY:IOUT,NCOL,NROW,NLAY,IFREFM,IUNSTR,NODES, + 1 NEQS USE GWFRIVMODULE, ONLY:NRIVER,MXRIVR,NRIVVL,IPRRIV,NPRIV, 1 IRIVPB,NNPRIV,RIVAUX,RIVR C ------------------------------------------------------------------ @@ -192,7 +194,7 @@ SUBROUTINE GWF2RIV7U1RP(IN) CALL ULSTRDU(NNPRIV,RIVR,1,NRIVVL,MXRIVR,1,IN,IOUT, 1 'REACH NO. NODE '// 2 ' STAGE CONDUCTANCE BOTTOM EL.', - 3 RIVAUX,20,NAUX,IFREFM,NODES,5,5,IPRRIV) + 3 RIVAUX,20,NAUX,IFREFM,NEQS,5,5,IPRRIV) ENDIF END IF NRIVER=NNPRIV diff --git a/src/gwf2sfr7u1.f b/src/gwf2sfr7u1.f index e052736..cb7b418 100644 --- a/src/gwf2sfr7u1.f +++ b/src/gwf2sfr7u1.f @@ -209,8 +209,8 @@ SUBROUTINE GWF2SFR7U1AR(In, Iunitbcf, Iunitlpf, Iunithuf, ALLOCATE (STRIN(nssar), STROUT(nssar), FXLKOT(nssar)) STRIN = 0.0 STROUT = 0.0 - FXLKOT = 0.0 - ALLOCATE (STRM(30,nstrmar), ISTRM(6,nstrmar)) + FXLKOT = 0.0 + ALLOCATE (STRM(30,nstrmar), ISTRM(7,nstrmar)) !9/14/15 change 6 to 7 in ISTRM for storing layer number ALLOCATE (HSTRM(nstrmar,NUMTIM), HWDTH(nstrmar,NUMTIM)) ALLOCATE (QSTRM(nstrmar,NUMTIM)) ALLOCATE (HWTPRM(nstrmar,NUMTIM)) @@ -1070,7 +1070,6 @@ SUBROUTINE GWF2SFR7U1RP(In, Iunitgwt, Iunitlak, Kkper, Nsol, USE PARAMMODULE, ONLY: MXPAR, PARTYP, IACTIVE, IPLOC USE ICHKSTRBOT_MODULE ! USE GWFLPFMODULE, ONLY: LAYTYP - USE GWFBCFMODULE, ONLY: LAYCON IMPLICIT NONE type (check_bot) :: uzfrp_check C ------------------------------------------------------------------ @@ -1672,15 +1671,16 @@ SUBROUTINE GWF2SFR7U1RP(In, Iunitgwt, Iunitlak, Kkper, Nsol, C31-----SKIP IF CELL IS OUTSIDE ACTIVE BOUNDARY OR IS NOT WATER TABLE. Cdep C31B-----SEARCH FOR UPPER MOST ACTIVE CELL IN STREAM REACH. - IF ( IBOUND(NCP).GT.0 ) THEN +! IF ( IBOUND(NCP).GT.0 ) THEN C il=ISTRM(1,L) ilay = il NCPT = NCP + IF ( NLAY.GT.1 ) THEN IF(IVSD.EQ.-1)THEN -C-------------FIND ACTIVE NODE FOR STRUCTURED GRID - TOPCELL: DO WHILE ( ilay.LE.NLAY ) - IF ( HNEW(NCP).LE.BOT(NCP) ) THEN +C-------------FIND ACTIVE NODE FOR STACKED GRID + TOPCELL: DO WHILE ( ilay.LT.NLAY ) + IF ( IBOUND(NCPT).EQ.0 ) THEN ilay = ilay + 1 NCPT = NCPT + NODLAY(1) ELSE @@ -1689,14 +1689,15 @@ SUBROUTINE GWF2SFR7U1RP(In, Iunitgwt, Iunitlak, Kkper, Nsol, END DO TOPCELL ELSE C-------------FIND ACTIVE NODE VIA IVC CONNECTIONS FOR UNSTRUCTURED GRID - DO K = IL,NLAY + NCPT = NCP + DO K = IL,NLAY-1 I1 = IA(NCPT)+1 I2 = IA(NCPT+1)-1 DO II = I1,I2 IIS = JAS(II) IF(IVC(IIS).EQ.1)THEN JJ = JA(II) - IF(HNEW(JJ).LE.BOT(JJ))THEN + IF(IBOUND(JJ).EQ.0)THEN ILAY = ILAY + 1 NCPT = JJ GO TO 23 @@ -1708,14 +1709,11 @@ SUBROUTINE GWF2SFR7U1RP(In, Iunitgwt, Iunitlak, Kkper, Nsol, 23 CONTINUE ENDDO 24 CONTINUE -C ENDIF - ENDIF - IF ( ilay.LE.NLAY ) THEN - h = HNEW(NCPT) - ELSE - h = DBLE(BOT(NCPT)) END IF + IF ( ilay.LE.NLAY ) il = ilay + ISTRM(7,l) = NCPT !RGN 9/14/15 +! IF ( IBOUND(NCPT).LE.0 ) THEN UZDPST(1, l) = 0.0D0 UZFLST(1, l) = 0.0D0 @@ -2077,10 +2075,6 @@ SUBROUTINE GWF2SFR7U1FM(Kkiter, Kkper, Kkstp, Iunitlak, Nlakesar, END IF lsub = l ll = l - 1 - NCP = ISTRM(6, l) -csp IL = ISTRM(2,L) - il = 1 - NCPT = NCP C C4------DETERMINE STREAM SEGMENT AND REACH NUMBER. istsg = ISTRM(4, l) @@ -2248,15 +2242,19 @@ SUBROUTINE GWF2SFR7U1FM(Kkiter, Kkper, Kkstp, Iunitlak, Nlakesar, C IS GREATER THAN 1. ELSE IF ( nreach.GT.1 ) THEN flowin = STRM(9, ll) - END IF + END IF C C23-----SEARCH FOR UPPER MOST ACTIVE CELL IN STREAM REACH. + NCP = ISTRM(6, l) +csp IL = ISTRM(2,L) + il = 1 + NCPT = NCP ilay = IL IF ( NLAY.GT.1 ) THEN IF(IVSD.EQ.-1)THEN C-------------FIND ACTIVE NODE FOR STACKED GRID - TOPCELL: DO WHILE ( ilay.LE.NLAY ) - IF ( IBOUND(NCP).EQ.0 ) THEN + TOPCELL: DO WHILE ( ilay.LT.NLAY ) + IF ( IBOUND(NCPT).EQ.0 ) THEN ilay = ilay + 1 NCPT = NCPT + NODLAY(1) ELSE @@ -2266,7 +2264,7 @@ SUBROUTINE GWF2SFR7U1FM(Kkiter, Kkper, Kkstp, Iunitlak, Nlakesar, ELSE C-------------FIND ACTIVE NODE VIA IVC CONNECTIONS FOR UNSTRUCTURED GRID NCPT = NCP - DO K = IL,NLAY + DO K = IL,NLAY-1 I1 = IA(NCPT)+1 I2 = IA(NCPT+1)-1 DO II = I1,I2 @@ -2288,6 +2286,7 @@ SUBROUTINE GWF2SFR7U1FM(Kkiter, Kkper, Kkstp, Iunitlak, Nlakesar, ENDIF END IF IF ( ilay.LE.NLAY ) il = ilay + ISTRM(7,l) = NCPT !RGN 9/14/15 C30d----BEGIN LOOP FOR NEWTON SOLVER IF ACTIVE DO ii = 1, idr SUMLEAK(l) = 0.0D0 @@ -3735,8 +3734,6 @@ SUBROUTINE GWF2SFR7U1BD(Kkstp, Kkper, Iunitgwt, Iunitlak, END IF lsub = l ll = l - 1 - NCP = ISTRM(6, l) - NCPT = NCP C C6------DETERMINE STREAM SEGMENT AND REACH NUMBER. istsg = ISTRM(4, l) @@ -3840,18 +3837,22 @@ SUBROUTINE GWF2SFR7U1BD(Kkstp, Kkper, Iunitgwt, Iunitlak, C GREATER THAN 1. ELSE IF ( nreach.GT.1 ) THEN flowin = STRM(9, ll) - END IF + END IF C C25-----SEARCH FOR UPPER MOST ACTIVE CELL IN STREAM REACH. Revised ERB C31B-----SEARCH FOR UPPER MOST ACTIVE CELL IN STREAM REACH. - IF ( IBOUND(NCP).GT.0 ) THEN +! IF ( IBOUND(NCP).GT.0 ) THEN !RGN 9/15/15 made code below follow 1FM C - il=ISTRM(1,L) - ilay = il +! RGN 9/15/15 changes start here + NCP = ISTRM(6, l) + NCPT = NCP + il = 1 + ilay = IL + IF ( NLAY.GT.1 ) THEN IF(IVSD.EQ.-1)THEN C-------------FIND ACTIVE NODE FOR STACKED GRID - TOPCELL: DO WHILE ( ilay.LE.NLAY ) - IF ( HNEW(NCP).LE.BOT(NCP) ) THEN + TOPCELL: DO WHILE ( ilay.LT.NLAY ) + IF ( IBOUND(NCPT).EQ.0 ) THEN ilay = ilay + 1 NCPT = NCPT + NODLAY(1) ELSE @@ -3861,14 +3862,14 @@ SUBROUTINE GWF2SFR7U1BD(Kkstp, Kkper, Iunitgwt, Iunitlak, ELSE C-------------FIND ACTIVE NODE VIA IVC CONNECTIONS FOR UNSTRUCTURED GRID NCPT = NCP - DO K = IL,NLAY + DO K = IL,NLAY-1 I1 = IA(NCPT)+1 I2 = IA(NCPT+1)-1 DO II = I1,I2 IIS = JAS(II) IF(IVC(IIS).EQ.1)THEN JJ = JA(II) - IF(HNEW(JJ).LE.BOT(JJ))THEN + IF(IBOUND(JJ).EQ.0)THEN ILAY = ILAY + 1 NCPT = JJ GO TO 23 @@ -3880,9 +3881,10 @@ SUBROUTINE GWF2SFR7U1BD(Kkstp, Kkper, Iunitgwt, Iunitlak, 23 CONTINUE ENDDO 24 CONTINUE - ENDIF - ENDIF + END IF + IF ( ilay.LE.NLAY ) il = ilay + ISTRM(7,l) = NCPT !RGN 9/14/15 changes end here. C C26-----DETERMINE LEAKAGE THROUGH STREAMBED. hstr = HSTRM(l,irt) diff --git a/src/gwf2wel7u1.f b/src/gwf2wel7u1.f index 9952360..03de080 100644 --- a/src/gwf2wel7u1.f +++ b/src/gwf2wel7u1.f @@ -255,7 +255,7 @@ SUBROUTINE GWF2WEL7U1RP(IN) C C-------FOR STRUCTURED GRID, CALCULATE NODE NUMBER AND PLACE IN LAYER LOCATION IF(ITMP.GT.0.AND.IUNSTR.EQ.0)THEN - DO L=1,NWELLS + DO L=1,NNPWEL IR=WELL(2,L) IC=WELL(3,L) IL=WELL(1,L) diff --git a/src/mfusg.f b/src/mfusg.f index 600aaf5..969ea97 100644 --- a/src/mfusg.f +++ b/src/mfusg.f @@ -16,18 +16,17 @@ c USE DE4MODULE c USE GMGMODULE C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ -C +C INCLUDE 'openspec.inc' C C-------ASSIGN VERSION NUMBER AND DATE CHARACTER*40 VERSION CHARACTER*10 MFVNAM - PARAMETER (VERSION='1.2.00 03/21/2014') + PARAMETER (VERSION='1.3.00 12/01/2015') PARAMETER (MFVNAM='-USG') !USG = Un-Structured Grids C CHARACTER*80 HEADNG(2) @@ -43,7 +42,7 @@ & 'GNC ', ' ', 'CHOB', 'ETS ', 'DRT ', ' ', 'GMG ', ! 42 & 'hyd ', 'SFR ', ' ', 'GAGE', 'LVDA', ' ', 'lmt6', ! 49 & 'MNW1', ' ', ' ', 'KDEP', 'SUB ', 'UZF ', 'gwm ', ! 56 - & 'SWT ', ' ', ' ', ' ', ' ', ' ', ' ', ! 63 + & 'SWT ', 'PATH', ' ', ' ', ' ', ' ', ' ', ! 63 & 37*' '/ C ------------------------------------------------------------------ C @@ -93,7 +92,7 @@ IF(IUNIT(4).GT.0) CALL GWF2RIV7U1AR(IUNIT(4)) IF(IUNIT(5).GT.0) CALL GWF2EVT8U1AR(IUNIT(5),IUNIT(15)) IF(IUNIT(7).GT.0) CALL GWF2GHB7U1AR(IUNIT(7)) - IF(IUNIT(8).GT.0) CALL GWF2RCH8U1AR(IUNIT(8)) + IF(IUNIT(8).GT.0) CALL GWF2RCH8U1AR(IUNIT(8),(IUNIT(15))) IF(IUNIT(16).GT.0) CALL GWF2FHB7U1AR(IUNIT(16)) CSP IF(IUNIT(17).GT.0) CALL GWF2RES7U1AR(IUNIT(17),IGRID) IF(IUNIT(18).GT.0) CALL GWF2STR7U1AR(IUNIT(18)) @@ -209,9 +208,6 @@ C C7C2----ITERATIVELY FORMULATE AND SOLVE THE FLOW EQUATIONS. DO 30 KITER = 1, MXITER - if(kstp.eq.1.AND.KITER.EQ.41)then - yo=1 - endif KKITER = KITER 31 CONTINUE C @@ -336,7 +332,7 @@ C IF(IUNIT(8).GT.0) THEN IF(IUNIT(22).GT.0.AND.NRCHOP.EQ.3) CALL GWF2LAK7ST(0) - CALL GWF2RCH8U1BD(KKSTP,KKPER) + CALL GWF2RCH8U1BD(KKSTP,KKPER,(IUNIT(15))) IF(IUNIT(22).GT.0.AND.NRCHOP.EQ.3) CALL GWF2LAK7ST(1) END IF C @@ -406,7 +402,7 @@ IF(IUNIT(4).GT.0) CALL GWF2RIV7U1DA IF(IUNIT(5).GT.0) CALL GWF2EVT8U1DA(IUNIT(15)) IF(IUNIT(7).GT.0) CALL GWF2GHB7U1DA - IF(IUNIT(8).GT.0) CALL GWF2RCH8U1DA + IF(IUNIT(8).GT.0) CALL GWF2RCH8U1DA(IUNIT(15)) IF(IUNIT(16).GT.0) CALL GWF2FHB7U1DA CSP IF(IUNIT(17).GT.0) CALL GWF2RES7U1DA(IGRID) IF(IUNIT(18).GT.0) CALL GWF2STR7U1DA diff --git a/src/parutl7.f b/src/parutl7.f index f9f655f..102b537 100644 --- a/src/parutl7.f +++ b/src/parutl7.f @@ -542,7 +542,7 @@ SUBROUTINE UPARLSTAL(IN,IOUT,LINE,NP,MXL) CALL URWORD(LINE,LLOC,ISTART,ISTOP,2,MXL,R,IOUT,IN) IF(MXL.LT.0) MXL=0 WRITE(IOUT,31) NP,MXL - 31 FORMAT(1X,I5,' Named Parameters ',I5,' List entries') + 31 FORMAT(1X,I10,' Named Parameters ',I10,' List entries') READ(IN,'(A)') LINE ELSE WRITE(IOUT,'(A)') ' No named parameters' diff --git a/src/pcgu7.f b/src/pcgu7.f index 0ac3bb2..234f5b9 100644 --- a/src/pcgu7.f +++ b/src/pcgu7.f @@ -1,9 +1,10 @@ MODULE PCGUMODULE + INTEGER,SAVE,POINTER :: ILINMETH PRIVATE PUBLIC :: PCGU7U1AR PUBLIC :: PCGU7U1AP PUBLIC :: PCGU7U1DA - INTEGER,SAVE,POINTER :: ILINMETH + PUBLIC :: ILINMETH INTEGER,SAVE,POINTER :: ITER1C,IPC,ISCL,IORD,NITERC,NNZC,NIAC INTEGER,SAVE,POINTER :: NIABCGS INTEGER,SAVE,POINTER :: NIAPC,NJAPC,NNZAPC @@ -531,8 +532,8 @@ SUBROUTINE PCGU7U1DA() C Deallocate PCGU DATA !USE PCGUMODULE C - IGRID=1 - CALL PCGU7PNT(IGRID) + IGRID = 1 + CALL PCGU7PNT(IGRID) DEALLOCATE(ILINMETH) DEALLOCATE(ITER1C,IPC,ISCL,IORD,NITERC,NNZC,NIAC) DEALLOCATE(NIABCGS) @@ -1108,6 +1109,7 @@ SUBROUTINE SPCGU_CG(ICNVG,ITMAX,INNERIT) C C + + + CODE + + + INNERIT = 0 + rho0 = 0.0 machprec = EPSILON( DZERO ) dhclose = DBLE( HCLOSEPCGU ) drclose = DBLE( RCLOSEPCGU ) @@ -1208,7 +1210,8 @@ SUBROUTINE SPCGU_BCGS(ICNVG,ITMAX,INNERIT) machprec = EPSILON( DZERO ) dhclose = DBLE( HCLOSEPCGU ) drclose = DBLE( RCLOSEPCGU ) - + OMEGA0 = DZERO + ALPHA0 = DZERO alpha = DZERO beta = DZERO rho = DZERO diff --git a/src/utl7u1.f b/src/utl7u1.f index a6d4fa0..861ddf7 100644 --- a/src/utl7u1.f +++ b/src/utl7u1.f @@ -209,12 +209,12 @@ SUBROUTINE ULSTRD(NLIST,RLIST,LSTBEG,LDIM,MXLIST,IAL,INPACK,IOUT, CHARACTER*200 LINE,FNAME DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C @@ -351,12 +351,12 @@ SUBROUTINE ULSTRDU(NLIST,RLIST,LSTBEG,LDIM,MXLIST,IAL,INPACK,IOUT, CHARACTER*200 LINE,FNAME DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C @@ -514,13 +514,14 @@ SUBROUTINE U1DREL(A,ANAME,JJ,K,IN,IOUT) C A IS ARRAY TO INPUT C ANAME IS 24 CHARACTER DESCRIPTION OF A C JJ IS NO. OF ELEMENTS +C K IS LAYER NO. (USED WITH NAME TO TITLE PRINTOUT --) +C IF K=0, NO LAYER IS PRINTED C IN IS INPUT UNIT C IOUT IS OUTPUT UNIT C ****************************************************************** C C SPECIFICATIONS: C ------------------------------------------------------------------ - CHARACTER*16 TEXT CHARACTER*24 ANAME DIMENSION A(JJ) CHARACTER*20 FMTIN @@ -528,12 +529,12 @@ SUBROUTINE U1DREL(A,ANAME,JJ,K,IN,IOUT) CHARACTER*200 FNAME DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C @@ -558,7 +559,6 @@ SUBROUTINE U1DREL(A,ANAME,JJ,K,IN,IOUT) LOCAT=NUNOPN WRITE(IOUT,15) LOCAT,FNAME 15 FORMAT(1X,/1X,'OPENING FILE ON UNIT ',I4,':',/1X,A) - OPEN(UNIT=LOCAT,FILE=FNAME,ACTION=ACTION(1)) ICLOSE=1 ELSE C @@ -572,160 +572,52 @@ SUBROUTINE U1DREL(A,ANAME,JJ,K,IN,IOUT) C3------FOR FREE FORMAT CONTROL RECORD, READ REMAINING FIELDS. IF(IFREE.NE.0) THEN CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,3,N,CNSTNT,IOUT,IN) - IF(LOCAT.GT.0) THEN + IF(LOCAT.NE.0) THEN CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,1,N,R,IOUT,IN) FMTIN=CNTRL(ISTART:ISTOP) + IF(ICLOSE.NE.0) THEN + IF(FMTIN.EQ.'(BINARY)') THEN + OPEN(UNIT=LOCAT,FILE=FNAME,FORM=FORM,ACCESS=ACCESS, + & ACTION=ACTION(1)) + ELSE + OPEN(UNIT=LOCAT,FILE=FNAME,ACTION=ACTION(1)) + END IF + END IF + IF(LOCAT.GT.0 .AND. FMTIN.EQ.'(BINARY)') LOCAT=-LOCAT CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,2,IPRN,R,IOUT,IN) END IF END IF C C4------TEST LOCAT TO SEE HOW TO DEFINE ARRAY VALUES. - IF(LOCAT.GE.0) GO TO 71 -C-------LOCAT <0 READ BINARY FILE -C4C-----LOCAT<0; READ UNFORMATTED ARRAY VALUES. - LOCAT=-LOCAT + IF(LOCAT.EQ.0) THEN +C +C4A-----LOCAT=0; SET ALL ARRAY VALUES EQUAL TO CNSTNT. RETURN. + DO 80 J=1,JJ + 80 A(J)=CNSTNT + IF(K.GT.0) WRITE(IOUT,2) ANAME,CNSTNT,K + 2 FORMAT(1X,/1X,A,' =',1P,G14.6,' FOR LAYER',I4) + IF(K.LE.0) WRITE(IOUT,3) ANAME,CNSTNT + 3 FORMAT(1X,/1X,A,' =',1P,G14.6) + RETURN + ELSE IF(LOCAT.GT.0) THEN +C +C4B-----LOCAT>0; READ FORMATTED RECORDS USING FORMAT FMTIN. IF(K.GT.0) THEN - WRITE(IOUT,201) ANAME,K,LOCAT - 201 FORMAT(1X,///11X,A,' FOR LAYER',I4,/ - 1 1X,'READING BINARY ON UNIT ',I4) + WRITE(IOUT,94) ANAME,K,LOCAT,FMTIN + 94 FORMAT(1X,///11X,A,' FOR LAYER',I4,/ + 1 1X,'READING ON UNIT ',I4,' WITH FORMAT: ',A) ELSE IF(K.EQ.0) THEN - WRITE(IOUT,202) ANAME,LOCAT - 202 FORMAT(1X,///1X,A,/ - 1 1X,'READING BINARY ON UNIT ',I4) + WRITE(IOUT,95) ANAME,LOCAT,FMTIN + 95 FORMAT(1X,///11X,A,/ + 1 1X,'READING ON UNIT ',I4,' WITH FORMAT: ',A) + END IF + IF(FMTIN.EQ.'(FREE)') THEN + READ(LOCAT,*) (A(J),J=1,JJ) ELSE - WRITE(IOUT,203) ANAME,LOCAT - 203 FORMAT(1X,///1X,A,' FOR CROSS SECTION',/ - 1 1X,'READING BINARY ON UNIT ',I4) + READ(LOCAT,FMTIN) (A(J),J=1,JJ) END IF - READ(LOCAT) KSTP,KPER,PERTIM,TOTIM,TEXT,NSTRT,NNDLAY,ILAY - READ(LOCAT) (A(J),J=1,JJ) - RETURN - -71 IF(LOCAT.GT.0) GO TO 90 -C -C4A-----LOCAT =0; SET ALL ARRAY VALUES EQUAL TO CNSTNT. RETURN. - DO 80 J=1,JJ - 80 A(J)=CNSTNT - IF(K.GT.0.OR.K.LT.0) WRITE(IOUT,2) ANAME,CNSTNT,K - 2 FORMAT(1X,/1X,A,' =',1P,G14.6,' FOR LAYER',I4) - IF(K.EQ.0) WRITE(IOUT,3) ANAME,CNSTNT - 3 FORMAT(1X,/1X,A,' =',1P,G14.6) - RETURN -C -C4B-----LOCAT>0; READ FORMATTED RECORDS USING FORMAT FMTIN. - 90 CONTINUE - IF(K.GT.0) WRITE(IOUT,4) ANAME,K,LOCAT,FMTIN - 4 FORMAT(1X,///11X,A,' FOR LAYER',I4,/ - 1 1X,'READING ON UNIT ',I4,' WITH FORMAT: ',A20) - IF(K.EQ.0) WRITE(IOUT,5) ANAME,LOCAT,FMTIN - 5 FORMAT(1X,///11X,A,/ - 1 1X,'READING ON UNIT ',I4,' WITH FORMAT: ',A20) - IF(FMTIN.EQ.'(FREE)') THEN - READ(LOCAT,*) (A(J),J=1,JJ) ELSE - READ(LOCAT,FMTIN) (A(J),J=1,JJ) - END IF - IF(ICLOSE.NE.0) CLOSE(UNIT=LOCAT) -C -C5------IF CNSTNT NOT ZERO THEN MULTIPLY ARRAY VALUES BY CNSTNT. - ZERO=0. - IF(CNSTNT.EQ.ZERO) GO TO 120 - DO 100 J=1,JJ - 100 A(J)=A(J)*CNSTNT -C -C6------IF PRINT CODE (IPRN) =0 OR >0 THEN PRINT ARRAY VALUES. -120 CONTINUE - IF(IPRN.EQ.0) THEN - WRITE(IOUT,1001) (A(J),J=1,JJ) -1001 FORMAT((1X,1PG12.5,9(1X,G12.5))) - ELSE IF(IPRN.GT.0) THEN - WRITE(IOUT,1002) (A(J),J=1,JJ) -1002 FORMAT((1X,1PG12.5,4(1X,G12.5))) - END IF -C -C7------RETURN - RETURN -C -C8------CONTROL RECORD ERROR. -500 WRITE(IOUT,502) ANAME -502 FORMAT(1X,/1X,'ERROR READING ARRAY CONTROL RECORD FOR ',A,':') - WRITE(IOUT,'(1X,A)') CNTRL - CALL USTOP(' ') - END - SUBROUTINE U1DREL8(A,ANAME,JJ,K,IN,IOUT) -C ****************************************************************** -C ROUTINE TO INPUT 1-D REAL DATA MATRICES -C A IS ARRAY TO INPUT -C ANAME IS 24 CHARACTER DESCRIPTION OF A -C JJ IS NO. OF ELEMENTS -C IN IS INPUT UNIT -C IOUT IS OUTPUT UNIT -C ****************************************************************** C -C SPECIFICATIONS: -C ------------------------------------------------------------------ - CHARACTER*16 TEXT - CHARACTER*24 ANAME - DOUBLE PRECISION A(JJ) - CHARACTER*20 FMTIN - CHARACTER*200 CNTRL - CHARACTER*200 FNAME - DATA NUNOPN/99/ -C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' - CHARACTER*20 ACCESS,FORM,ACTION(2) - DATA ACCESS/'STREAM'/ - DATA FORM/'UNFORMATTED'/ - DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ -C -C ------------------------------------------------------------------ -C -C1------READ ARRAY CONTROL RECORD AS CHARACTER DATA. - READ(IN,'(A)') CNTRL -C -C2------LOOK FOR ALPHABETIC WORD THAT INDICATES THAT THE RECORD IS FREE -C2------FORMAT. SET A FLAG SPECIFYING IF FREE FORMAT OR FIXED FORMAT. - ICLOSE=0 - IFREE=1 - ICOL=1 - CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,1,N,R,IOUT,IN) - IF (CNTRL(ISTART:ISTOP).EQ.'CONSTANT') THEN - LOCAT=0 - ELSE IF(CNTRL(ISTART:ISTOP).EQ.'INTERNAL') THEN - LOCAT=IN - ELSE IF(CNTRL(ISTART:ISTOP).EQ.'EXTERNAL') THEN - CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,2,LOCAT,R,IOUT,IN) - ELSE IF(CNTRL(ISTART:ISTOP).EQ.'OPEN/CLOSE') THEN - CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,0,N,R,IOUT,IN) - FNAME=CNTRL(ISTART:ISTOP) - LOCAT=NUNOPN - WRITE(IOUT,15) LOCAT,FNAME - 15 FORMAT(1X,/1X,'OPENING FILE ON UNIT ',I4,':',/1X,A) - OPEN(UNIT=LOCAT,FILE=FNAME,ACTION=ACTION(1)) - ICLOSE=1 - ELSE -C -C2A-----DID NOT FIND A RECOGNIZED WORD, SO NOT USING FREE FORMAT. -C2A-----READ THE CONTROL RECORD THE ORIGINAL WAY. - IFREE=0 - READ(CNTRL,1,ERR=500) LOCAT,CNSTNT,FMTIN,IPRN - 1 FORMAT(I10,F10.0,A20,I10) - END IF -C -C3------FOR FREE FORMAT CONTROL RECORD, READ REMAINING FIELDS. - IF(IFREE.NE.0) THEN - CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,3,N,CNSTNT,IOUT,IN) - IF(LOCAT.GT.0) THEN - CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,1,N,R,IOUT,IN) - FMTIN=CNTRL(ISTART:ISTOP) - CALL URWORD(CNTRL,ICOL,ISTART,ISTOP,2,IPRN,R,IOUT,IN) - END IF - END IF -C -C4------TEST LOCAT TO SEE HOW TO DEFINE ARRAY VALUES. - IF(LOCAT.GE.0) GO TO 71 -C-------LOCAT <0 READ BINARY FILE C4C-----LOCAT<0; READ UNFORMATTED ARRAY VALUES. LOCAT=-LOCAT IF(K.GT.0) THEN @@ -735,49 +627,22 @@ SUBROUTINE U1DREL8(A,ANAME,JJ,K,IN,IOUT) ELSE IF(K.EQ.0) THEN WRITE(IOUT,202) ANAME,LOCAT 202 FORMAT(1X,///1X,A,/ - 1 1X,'READING BINARY ON UNIT ',I4) - ELSE - WRITE(IOUT,203) ANAME,LOCAT - 203 FORMAT(1X,///1X,A,' FOR CROSS SECTION',/ 1 1X,'READING BINARY ON UNIT ',I4) END IF - READ(LOCAT) KSTP,KPER,PERTIM,TOTIM,TEXT,NSTRT,NNDLAY,ILAY - READ(LOCAT) (A(J),J=1,JJ) - RETURN - 71 IF(LOCAT.GT.0) GO TO 90 -C -C4A-----LOCAT <0 OR =0; SET ALL ARRAY VALUES EQUAL TO CNSTNT. RETURN. - DO 80 J=1,JJ - 80 A(J)=CNSTNT - IF(K.GT.0) WRITE(IOUT,2) ANAME,CNSTNT,K - 2 FORMAT(1X,/1X,A,' =',1P,G14.6,' FOR LAYER',I4) - IF(K.LE.0) WRITE(IOUT,3) ANAME,CNSTNT - 3 FORMAT(1X,/1X,A,' =',1P,G14.6) - RETURN -C -C4B-----LOCAT>0; READ FORMATTED RECORDS USING FORMAT FMTIN. - 90 CONTINUE - IF(K.GT.0) WRITE(IOUT,4) ANAME,K,LOCAT,FMTIN - 4 FORMAT(1X,///11X,A,' FOR LAYER',I4,/ - 1 1X,'READING ON UNIT ',I4,' WITH FORMAT: ',A20) - IF(K.EQ.0) WRITE(IOUT,5) ANAME,LOCAT,FMTIN - 5 FORMAT(1X,///11X,A,/ - 1 1X,'READING ON UNIT ',I4,' WITH FORMAT: ',A20) - IF(FMTIN.EQ.'(FREE)') THEN - READ(LOCAT,*) (A(J),J=1,JJ) - ELSE - READ(LOCAT,FMTIN) (A(J),J=1,JJ) + READ(LOCAT) KSTP,KPER,PERTIM,TOTIM,TEXT,NCOL,NROW,ILAY + READ(LOCAT) A END IF - IF(ICLOSE.NE.0) CLOSE(UNIT=LOCAT) C C5------IF CNSTNT NOT ZERO THEN MULTIPLY ARRAY VALUES BY CNSTNT. + IF(ICLOSE.NE.0) CLOSE(UNIT=LOCAT) ZERO=0. - IF(CNSTNT.EQ.ZERO) GO TO 120 - DO 100 J=1,JJ - 100 A(J)=A(J)*CNSTNT + IF(CNSTNT.EQ.ZERO) GO TO 320 + DO 310 J=1,JJ + A(J)=A(J)*CNSTNT + 310 CONTINUE C C6------IF PRINT CODE (IPRN) =0 OR >0 THEN PRINT ARRAY VALUES. -120 CONTINUE +320 CONTINUE IF(IPRN.EQ.0) THEN WRITE(IOUT,1001) (A(J),J=1,JJ) 1001 FORMAT((1X,1PG12.5,9(1X,G12.5))) @@ -790,8 +655,14 @@ SUBROUTINE U1DREL8(A,ANAME,JJ,K,IN,IOUT) RETURN C C8------CONTROL RECORD ERROR. -500 WRITE(IOUT,502) ANAME -502 FORMAT(1X,/1X,'ERROR READING ARRAY CONTROL RECORD FOR ',A,':') + 500 IF(K.GT.0) THEN + WRITE(IOUT,501) ANAME,K + 501 FORMAT(1X,/1X,'ERROR READING ARRAY CONTROL RECORD FOR ',A, + 1 ' FOR LAYER',I4,':') + ELSE + WRITE(IOUT,502) ANAME + 502 FORMAT(1X,/1X,'ERROR READING ARRAY CONTROL RECORD FOR ',A,':') + END IF WRITE(IOUT,'(1X,A)') CNTRL CALL USTOP(' ') END @@ -814,12 +685,12 @@ SUBROUTINE U1DINT(IA,ANAME,JJ,K,IN,IOUT) CHARACTER*200 FNAME DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C @@ -943,12 +814,12 @@ SUBROUTINE U2DINT(IA,ANAME,II,JJ,K,IN,IOUT) CHARACTER*200 FNAME DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C @@ -1180,12 +1051,12 @@ SUBROUTINE U2DREL(A,ANAME,II,JJ,K,IN,IOUT) REAL PERTIMRD,TOTIMRD DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C @@ -1347,12 +1218,12 @@ SUBROUTINE U2DREL8(A,ANAME,II,JJ,K,IN,IOUT) CHARACTER*200 FNAME DATA NUNOPN/99/ C -C jfisher 2015-02-23: remove dependency on 'openspec.inc' -C INCLUDE 'openspec.inc' +C jfisher 2016-10-20: remove dependency on 'openspec.inc', contents included here. CHARACTER*20 ACCESS,FORM,ACTION(2) DATA ACCESS/'STREAM'/ DATA FORM/'UNFORMATTED'/ DATA (ACTION(I),I=1,2)/'READ','READWRITE'/ +C INCLUDE 'openspec.inc' C C ------------------------------------------------------------------ C diff --git a/src/xmd.f b/src/xmd.f index 9177ef2..28fbfe0 100644 --- a/src/xmd.f +++ b/src/xmd.f @@ -61,6 +61,7 @@ MODULE XMDMODULE IMPLICIT NONE LOGICAL, SAVE, POINTER :: REDSYS + LOGICAL, SAVE, POINTER :: ILUREUSE DOUBLE PRECISION, SAVE, POINTER :: EPSRN,RRCTOL DOUBLE PRECISION, SAVE, DIMENSION(:),ALLOCATABLE::DGSCAL INTEGER, SAVE, DIMENSION(:), ALLOCATABLE :: LORDER @@ -118,6 +119,7 @@ SUBROUTINE XMD7U1AR(IN,IFDPARAM) ALLOCATE (IACL,NORDER,LEVEL,NORTH,IDROPTOL,IERR,IDSCALE) ALLOCATE (EPSRN,RRCTOL) ALLOCATE (REDSYS) + ALLOCATE (ILUREUSE) cmi @@ -232,6 +234,12 @@ SUBROUTINE XMD7U1AR(IN,IFDPARAM) call xmdcheck(ia, ja, neqs, nja, ierr) +c --------------------------------------------------- +c SET ILUREUSE SO THAT DROP TOLERANCE IS USED WHEN +c INITIALLY FORMULATING THE ILU PRECONDITIONER +c --------------------------------------------------- + ILUREUSE = .FALSE. + c --------------------------------------------------- c PERFORM SYMBOLIC FACTORIZATION FOR LEVEL BASED PRECONDITIONING diff --git a/src/xmdlib_2.f b/src/xmdlib_2.f index ef5e91c..9e9b327 100644 --- a/src/xmdlib_2.f +++ b/src/xmdlib_2.f @@ -70,7 +70,7 @@ end module xmdalloc - module xmdcmn + module xmdcmn c c miunit unit number for output c miout switch for information message @@ -895,7 +895,7 @@ subroutine xmdcgstb(a, b, x, af, soln, [ ia, ja, iaf, jaf, idiagf, RBorder, nblack, [ nred, n, nja, njaf, nitmax, north, ierr) - + use xmdcmn implicit none double precision :: a(nja), b(n), af(njaf), x(n), soln(nblack), [ ctol, rrctol @@ -1063,6 +1063,12 @@ subroutine xmdcgstb(a, b, x, af, soln, res(i) = b( RBorder(i) ) - qb(i) enddo endif + + if(miout.ge.1)then + write(miunit,691) iter, omega, temp1, resmax + 691 format (10x,1p,'iter = ',i5,2x,'omega = ',d12.5, + * 2x,'absolute = ',d12.5,2x,'rms = ',d12.5) + endif enddo @@ -1080,7 +1086,7 @@ subroutine xmdcnjgd(a, b, x, af, soln, [ ia, ja, iaf, jaf, idiagf, RBorder, nblack, [ nred, n, nja, njaf, nitmax, ierr) - + use xmdcmn implicit none double precision :: a(nja), b(n), af(njaf), x(n), soln(nblack), [ ctol, rrctol @@ -1192,7 +1198,13 @@ subroutine xmdcnjgd(a, b, x, af, soln, resmax = dsqrt(resmax) conv = temp < ctol conv = conv.or.(resmax < rrctol*res0) - + + if(miout.ge.1)then + write(miunit,691) iter, omega, temp, resmax + 691 format (10x,1p,'iter = ',i5,2x,'omega = ',d12.5, + * 2x,'absolute = ',d12.5,2x,'rms = ',d12.5) + endif + if (conv) then nitmax = iter+1 deallocate ( avk, q, aq, res, v ) @@ -1541,7 +1553,7 @@ subroutine xmdorthmn(a, b, x, af, soln, [ nblack, nred, n, nja, njaf, north, nitmax, [ ierr) - + use xmdcmn implicit none double precision :: a(nja), b(n), x(n), af(njaf), [ soln(nblack), ctol, rrctol @@ -1682,7 +1694,13 @@ subroutine xmdorthmn(a, b, x, af, soln, conv = temp < ctol conv = conv.or.(resmax < rrctol*res0) - + + if(miout.ge.1)then + write(miunit,691) iter, omega, temp, resmax + 691 format (10x,1p,'iter = ',i5,2x,'omega = ',d12.5, + * 2x,'absolute = ',d12.5,2x,'rms = ',d12.5) + endif + if (conv) then nitmax = iter+1 deallocate ( avk, aqaq, q, aq, res ) @@ -3563,7 +3581,7 @@ subroutine mdu(n, mmax, ek,dmin, v,l, head,last,next, mark) c 11 return end - +C SUBROUTINE xmdlibda use xmdcmn use xmdmatrix diff --git a/vignettes/sir20165080.Rnw b/vignettes/sir20165080.Rnw index 59f2e3f..ba09680 100644 --- a/vignettes/sir20165080.Rnw +++ b/vignettes/sir20165080.Rnw @@ -4,7 +4,7 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} % ========================================================================= diff --git a/vignettes/sir20165080_AppendixA.Rnw b/vignettes/sir20165080_AppendixA.Rnw index 5ef0a19..98a43c6 100644 --- a/vignettes/sir20165080_AppendixA.Rnw +++ b/vignettes/sir20165080_AppendixA.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{A\arabic{figure}} \renewcommand{\thetable}{A\arabic{table}} \renewcommand{\thepage}{A\arabic{page}} @@ -91,7 +93,7 @@ help(package = "wrv") @ MODFLOW-USG is a computer program for simulating three-dimensional, steady-state and transient groundwater flow using a control volume finite-difference formulation \citep{Panday2013}. -Source code and executable files for MODFLOW-USG (version 1.2) are provided in the \textbf{wrv} package. +Source code and executable files for MODFLOW-USG (version 1.3) are provided in the \textbf{wrv} package. PEST is a software suite that allows model-independent parameter estimation, sensitivity analysis, and uncertainty estimation, developed by \citet{Doherty2005}. If PEST (version $\geq$ 13.0) is not already installed on your computer, download and install the latest binary distribution and enable it to run from the command line. @@ -250,7 +252,7 @@ and pumping demands (appendix G). Many of the parameters adjusted during model calibration (such as the horizontal hydraulic conductivity) are contained within MODFLOW input files (including data reference files [`.ref'] read by MODFLOW). At the end of each PEST iteration the newly updated parameter values are written to these model input files. The exception to this method of directly updating parameter values in the model input files occurs when the calibrated parameter values are used as input for a pre-processing program that generates a model input file(s). -For example, in this study, the \texttt{UpdateWaterBudget} function (appendix B, p. B67-B69) is used to create the MODFLOW well file (`.wel'), an input file containing specified flow boundary conditions. +For example, in this study, the \texttt{UpdateWaterBudget} function (appendix B, p. B46-B48) is used to create the MODFLOW well file (`.wel'), an input file containing specified flow boundary conditions. Input parameters for this function include, but are not limited to, the following: irrigation efficiency, tributary-underflow control parameters, and horizontal hydraulic conductivity---all of which are varied during the model-calibration process. @@ -264,7 +266,7 @@ and output quality-assurance tables for the water-budget calculation: <>= help("UpdateWaterBudget") # open help documentation for function call -UpdateWaterBudget(file.path(getwd(), "model/model1"), "wrv_mfusg", qa.tables = "english") +UpdateWaterBudget("model/model1", "wrv_mfusg", qa.tables = "english") @ \begin{figure} @@ -289,7 +291,7 @@ v <- c(paste("Diagram showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nc \label{fig:flowchart_update} \end{figure} -The general processing steps for model calibration are shown in \hyperref[fig:flowchart_calibrate]{Figure~\ref{fig:flowchart_calibrate}}. +The general processing steps for model calibration are shown in \hyperref[fig:flowchart_calibrate]{figure~\ref{fig:flowchart_calibrate}}. Notice that the processing steps are represented in a linear workflow. This is an oversimplification of the approach taken for model calibration; in reality, the workflow was very non-linear because a new PEST run was required following any change in model conceptualization. diff --git a/vignettes/sir20165080_AppendixB.Rnw b/vignettes/sir20165080_AppendixB.Rnw index c98d074..58fc657 100644 --- a/vignettes/sir20165080_AppendixB.Rnw +++ b/vignettes/sir20165080_AppendixB.Rnw @@ -61,7 +61,7 @@ This vignette is a reference manual for functions and datasets in the \textbf{wr A short description and \R{} usage information (such as examples of how to use a function) are given for all functions and datasets. Dataset documentation include sections describing the format of a dataset (such as a vector or matrix) and details on the original or secondary data source. Functions and datasets are named according to the following conventions. -The form for function names is no separator between words and initial capital letters (such as \code{AddScaleBar}); +The form for function names is no separator between words and initial capital letters (such as \code{GetSeasonalMult}); dataset names have words separated with dots and all lower case letters (such as \code{alluvium.extent}). \vspace{10 mm} @@ -72,9 +72,6 @@ dataset names have words separated with dots and all lower case letters (such as % ========================================================================= -% Create Rd2.tex from the command line: -% R CMD Rd2pdf --no-clean --force "./wrv" - <>= f <- "Rd2.tex" p <- ifelse(file.exists(f), f, system.file("misc", f, package="wrv")) diff --git a/vignettes/sir20165080_AppendixC.Rnw b/vignettes/sir20165080_AppendixC.Rnw index 4f7d26b..d791424 100644 --- a/vignettes/sir20165080_AppendixC.Rnw +++ b/vignettes/sir20165080_AppendixC.Rnw @@ -4,7 +4,9 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} + +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} \renewcommand{\thefigure}{C\arabic{figure}} \renewcommand{\thetable}{C\arabic{table}} @@ -35,12 +37,7 @@ fin.cs <- c(7.16, 5.39) fin.cs.0 <- c(7.16, 4.73) # Extreme coordinates of plotting region (x1, x2, y1, y2) -usr.map <- c(2451504, 2497815, 1342484, 1402354) -usr.map.s <- c(2472304, 2497015, 1343284, 1358838) -usr.map.n.1 <- c(2463000, 2475356, 1386500, 1398856) -usr.map.n.2 <- c(2467500, 2479856, 1376500, 1388856) -usr.map.n.3 <- c(2466696, 2479052, 1366501, 1378857) -usr.map.n.4 <- c(2471500, 2483856, 1356482, 1368838) +usr.map <- c(2451504, 2497815, 1342484, 1402354) # Map credit credit <- paste("Base derived from U.S. Geological Survey National Elevation Dataset 10-meter digital elevation model.", @@ -88,14 +85,11 @@ It is assumed that the reader of this vignette is familiar with the \R{}-program \section{R Environment} -Load the following user-contributed packages into the current \R{} session: +Load the following packages into the current \R{} session: <>= -library("rgdal") # bindings for the geospatial data abstraction library -library("raster") # gridded spatial data toolkit -loadNamespace("rgeos") # interface to geometry engine -loadNamespace("dplyr") # tool for working with data frame like objects -loadNamespace("wrv") # processor for groundwater-flow model +library("rgdal") # bindings for the geospatial data abstraction library +library("raster") # gridded spatial data toolkit @ \noindent Set a \textbf{raster} package option to prevent the standardization of raster names: @@ -110,28 +104,38 @@ rasterOptions(standardnames = FALSE) \section{Input/Output Paths} -Package datasets are primarily created from unprocessed data files located on \href{https://github.com/USGS-R/wrv}{GitHub}, a web-based distributed revision control system. -The top-level uniform resource locator (URL) for these files is specified as: +Package datasets are primarily created from unprocessed data files located on \href{https://github.com/USGS-R/wrv}{GitHub}, +a web-based distributed revision control system. +Download these files to a temporary directory and uncompress the ZIP files. -<<>>= -url.git <- "https://raw.githubusercontent.com/USGS-R/wrv/master/inst/extdata/" +<>= +url <- "https://github.com/USGS-R/wrv.git" +path <- file.path(tempdir(), basename(tools::file_path_sans_ext(url))) +git2r::clone(url, path, progress = FALSE) +dir.in <- file.path(path, "inst/extdata") +files <- list.files(dir.in, pattern = "*.zip$", full.names = TRUE, recursive = TRUE) +for (i in files) unzip(i, exdir = dirname(i)) @ \noindent The data file containing land-surface elevations was deemed too large in file size (about 500 megabytes) to be placed in the package repository. These elevations are part of the National Elevation Dataset (\href{http://ned.usgs.gov/}{NED}) $\sfrac{1}{3}$-arc-second raster and available in a ArcGRID file format. -The File Transfer Protocol (FTP) for this compressed file is specified as: +Download the ZIP file to a temporary directory and uncompress. -<<>>= -ftp.ned <- paste0("ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/", - "13/ArcGrid/n44w115.zip") +<>= +ftp <- "ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/NED/13/ArcGrid/n44w115.zip" +file <- file.path(tempdir(), basename(ftp)) +download.file(ftp, file) +unzip(file, exdir = dir.in) @ \noindent Output from this vignette is placed in the current working directory. -<<>>= -dir.create(dir.dat <- file.path(getwd(), "data"), showWarnings = FALSE) +<>= +dir.create(dir.out <- "data", showWarnings = FALSE) @ +\newpage + % ========================================================================= \section{Space-Time Grid Scale} @@ -139,7 +143,7 @@ dir.create(dir.dat <- file.path(getwd(), "data"), showWarnings = FALSE) The length and time dimensions for datasets are in units of meters and days, respectively. Conversion factors are listed with an explanation of how they are used: -<<>>= +<>= in.to.m <- 0.0254 # inches to meters ft.to.m <- 0.3048 # feet to meters mm.to.m <- 0.001 # millimeters to meters @@ -150,28 +154,34 @@ af.per.y.to.m3.per.d <- 3.377 # acre-feet per year to cubic meters per cfs.to.m3.per.d <- 2446.57555 # cubic feet per second to cubic meters per day @ -\newpage - \noindent The common coordinate reference system (CRS) applied to all spatial datasets is the Idaho Transverse Mercator projection (\href{https://www.idwr.idaho.gov/GIS/IDTM/}{IDTM83}). \href{http://trac.osgeo.org/proj/}{PROJ.4} projection arguments are used to specify a CRS in R. The CRS that all unprocessed data are converted into is specified as: -<<>>= +<>= crs <- CRS(paste("+proj=tmerc +lat_0=42 +lon_0=-114 +k=0.9996 +x_0=2500000 +y_0=1200000", "+datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0")) @ \noindent The common spatial grid applied to all gridded datasets is composed of 565 rows and 429 columns, and has a constant cell size of 100 meters by 100 meters. -<<>>= +<>= ext <- extent(2453200, 2496100, 1344139, 1400639) # xmin, xmax, ymin, ymax in IDTM spatial.grid <- raster(crs = crs, ext = ext, resolution = 100) @ +\noindent Gridded data are available at a higher resolution (smaller cells) than the resolution of the model grid. +Projecting the higher resolution data into the model grid first requires the projection of this data into a high resolution spatial grid of comparable cell size. +The high resolution spatial grid is defined using a constant cell size of 20 meters by 20 meters. + +<>= +high.res.spatial.grid <- disaggregate(spatial.grid, fact = 5L) +@ + \noindent The transient model simulates groundwater flow from 1995 through 2010, using monthly stress periods. -<<>>= +<>= tr.interval <- as.Date(c("1995-01-01", "2011-01-01"), tz = "MST") tr.stress.periods <- seq(tr.interval[1] , tr.interval[2], "1 month") yr.mo <- format(head(tr.stress.periods, -1), "%Y%m") @@ -179,6 +189,8 @@ yr.mo.irr <- yr.mo[months(head(tr.stress.periods, -1), abbreviate = TRUE) %in% c("Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct")] @ +\newpage + % ========================================================================= \section{Level 1 Data} @@ -198,10 +210,10 @@ Variable names, for the most part, are maintained between unprocessed and proces Canal seepage as a fraction of diversions for irrigation entities in the Wood River Valley (WRV). -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "canal/canal.seep.csv")) +<>= +file <- file.path(dir.in, "canal/canal.seep.csv") canal.seep <- read.csv(file, strip.white = TRUE) -save(canal.seep, file = file.path(dir.dat, "canal.seep.rda"), compress = "xz") +save(canal.seep, file = file.path(dir.out, "canal.seep.rda"), compress = "xz") @ <>= @@ -214,12 +226,12 @@ CheckStatus("canal.seep") Supplemental groundwater rights and associated surface-water rights. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/comb.sw.irr.csv")) +<>= +file <- file.path(dir.in, "div/comb.sw.irr.csv") comb.sw.irr <- read.csv(file, strip.white = TRUE) comb.sw.irr$Pdate <- as.Date(comb.sw.irr$Pdate, format = "%m/%d/%Y") comb.sw.irr$MaxDivRate <- comb.sw.irr$MaxDivRate * cfs.to.m3.per.d -save(comb.sw.irr, file = file.path(dir.dat, "comb.sw.irr.rda"), compress = "xz") +save(comb.sw.irr, file = file.path(dir.out, "comb.sw.irr.rda"), compress = "xz") @ <>= @@ -232,11 +244,11 @@ CheckStatus("comb.sw.irr") Methods used to calculate monthly distributions of evapotranspiration rate. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "et/et.method.csv")) +<>= +file <- file.path(dir.in, "et/et.method.csv") et.method <- read.csv(file, strip.white = TRUE) et.method$YearMonth <- as.character(et.method$YearMonth) -save(et.method, file = file.path(dir.dat, "et.method.rda"), compress = "xz") +save(et.method, file = file.path(dir.out, "et.method.rda"), compress = "xz") @ <>= @@ -250,14 +262,14 @@ CheckStatus("et.method") Groundwater diversions recorded by Water District 37 or municipal water providers. Groundwater is diverted from the aquifer by means of either pumping wells or flowing artesian wells. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/div.gw.csv")) +<>= +file <- file.path(dir.in, "div/div.gw.csv") div.gw <- read.csv(file, strip.white = TRUE) div.gw$YearMonth <- as.factor(div.gw$YearMonth) div.gw$GWDiv <- div.gw$GWDiv_af * af.to.m3 div.gw$GWDiv_af <- NULL div.gw[is.na(div.gw$GWDiv), "GWDiv"] <- 0 -save(div.gw, file = file.path(dir.dat, "div.gw.rda"), compress = "xz") +save(div.gw, file = file.path(dir.out, "div.gw.rda"), compress = "xz") @ <>= @@ -270,10 +282,10 @@ CheckStatus("div.gw") Irrigation efficiency for irrigation entities. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "irr/efficiency.csv")) +<>= +file <- file.path(dir.in, "irr/efficiency.csv") efficiency <- read.csv(file, strip.white = TRUE) -save(efficiency, file = file.path(dir.dat, "efficiency.rda"), compress = "xz") +save(efficiency, file = file.path(dir.out, "efficiency.rda"), compress = "xz") @ <>= @@ -287,10 +299,10 @@ CheckStatus("efficiency") The annual land classification for irrigation practices is only available for select years. For missing years, this dataset provides substitute years when land-classification was available. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "irr/irr.lands.year.csv")) +<>= +file <- file.path(dir.in, "irr/irr.lands.year.csv") irr.lands.year <- read.csv(file, strip.white = TRUE, colClasses = "character") -save(irr.lands.year, file = file.path(dir.dat, "irr.lands.year.rda"), compress = "xz") +save(irr.lands.year, file = file.path(dir.out, "irr.lands.year.rda"), compress = "xz") @ <>= @@ -303,16 +315,16 @@ CheckStatus("irr.lands.year") Average daily snow water equivalent (SWE) at weather stations in the WRV and surrounding areas. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.choco.csv")) +<>= +file <- file.path(dir.in, "precip/swe.choco.csv") swe.choco <- read.csv(file, strip.white = TRUE) swe.choco$MonthDay <- format(as.Date(swe.choco$Date, "%m/%d/%Y"), "%m%d") swe.choco$SWE <- swe.choco$SWE_in * in.to.m -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.hailey.csv")) +file <- file.path(dir.in, "precip/swe.hailey.csv") swe.hailey <- read.csv(file, strip.white = TRUE) swe.hailey$MonthDay <- format(as.Date(swe.hailey$Date, "%m/%d/%Y"), "%m%d") swe.hailey$SWE <- swe.hailey$SWE_in * in.to.m -file <- wrv::DownloadFile(paste0(url.git, "precip/swe.picabo.csv")) +file <- file.path(dir.in, "precip/swe.picabo.csv") swe.picabo <- read.csv(file, strip.white = TRUE) swe.picabo$MonthDay <- format(as.Date(swe.picabo$Date, "%m/%d/%Y"), "%m%d") swe.picabo$SWE <- swe.picabo$SWE_in * in.to.m @@ -320,7 +332,7 @@ swe.picabo$SWE <- swe.picabo$SWE_in * in.to.m \noindent Aggregate SWE data by day in a year: -<<>>= +<>= swe.choco <- aggregate(swe.choco$SWE, list(swe.choco$MonthDay), mean) swe.hailey <- aggregate(swe.hailey$SWE, list(swe.hailey$MonthDay), mean) swe.picabo <- aggregate(swe.picabo$SWE, list(swe.picabo$MonthDay), mean) @@ -328,26 +340,28 @@ swe.picabo <- aggregate(swe.picabo$SWE, list(swe.picabo$MonthDay), mean) \noindent Combine datasets and write to disk: -<<>>= +<>= swe <- swe.choco[order(swe.choco[[1]]), ] swe <- dplyr::left_join(swe, swe.hailey, by = "Group.1") swe <- dplyr::left_join(swe, swe.picabo, by = "Group.1") names(swe) <- c("MonthDay", "Choco", "Hailey", "Picabo") -save(swe, file = file.path(dir.dat, "swe.rda"), compress = "xz") +save(swe, file = file.path(dir.out, "swe.rda"), compress = "xz") @ <>= CheckStatus("swe") @ +\newpage + % ========================================================================= \subsubsection{Precipitation Rate (precipitation)} Precipitation rates in the WRV and surrounding areas. Combine precipitation records into a single data table: -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "precip/precip.csv")) +<>= +file <- file.path(dir.in, "precip/precip.csv") d <- read.csv(file, strip.white = TRUE) d$Ketchum <- d$Ketchum_ft * ft.to.m d$Hailey <- d$Hailey_ft * ft.to.m @@ -360,7 +374,7 @@ d$Picabo_ft <- NULL \noindent Create a linear regression model between the average of the precipitation depth recorded at the Picabo and Ketchum weather stations, and the precipitation depth recorded at the Hailey weather station: -<<>>= +<>= x <- apply(d[, c("Picabo", "Ketchum")], 1, mean) y <- d$Hailey LM <- lm(y ~ x) @@ -369,7 +383,7 @@ LM <- lm(y ~ x) \noindent A strong positive correlation (R-squared of \Sexpr{format(summary(LM)$r.squared, digits=3)}) indicates that the regression model may be used to estimate missing data at the Hailey weather station (\hyperref[fig:graph_precip_hailey]{fig.~\ref{fig:graph_precip_hailey}}). -<<>>= +<>= is.na.hailey <- is.na(y) d$Hailey[is.na.hailey] <- predict(LM, data.frame(x))[is.na.hailey] precipitation <- d @@ -389,20 +403,19 @@ d2 <- d[ is.na.hailey, ] cols <- "#327CCB" ylab <- paste("Monthly precipitation, in", c("meters", "feet")) ltys <- c(1, 2) -wrv::PlotGraph(d, xlim=tr.interval, ylab=ylab, col=cols, lty=0, - conversion.factor=1 / ft.to.m, center.date.labels=TRUE) +inlmisc::PlotGraph(d, xlim=tr.interval, ylab=ylab, col=cols, lty=0, + conversion.factor=1 / ft.to.m, center.date.labels=TRUE) lines(d1, lty=ltys[1], col=cols, type="s") lines(d2, lty=ltys[2], col=cols, type="s") legend("topright", c("Measured", "Estimated"), col=cols, lty=ltys, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ \newpage \noindent Use a monthly precipitation redistribution model to account for frozen precipitation (snow): -<<>>= +<>= d <- precipitation mo <- month.abb[as.integer(substr(precipitation$YearMonth, 5, 6))] for (i in seq_along(mo)) { @@ -433,14 +446,14 @@ names(precipitation) <- c("YearMonth", paste0(sites, ".raw"), sites) \noindent Remove precipitation records that occurred outside the model simulation period: -<<>>= +<>= date.time <- as.Date(paste0(precipitation[, "YearMonth"], "01"), "%Y%m%d") precipitation <- precipitation[date.time >= tr.interval[1] & date.time < tr.interval[2], ] @ \noindent Add precipitation zone meta data: -<<>>= +<>= d <- data.frame(YearMonth = as.factor(rep(as.character(precipitation$YearMonth), 3)), PrecipZone = rep(sites, each = nrow(precipitation)), Precip = NA, Precip.raw = NA) @@ -451,9 +464,9 @@ d[d$PrecipZone == "Picabo", 3:4] <- precipitation[, c("Picabo", "Picabo.raw")] \noindent Save the dataset to disk: -<<>>= +<>= precipitation <- d -save(precipitation, file = file.path(dir.dat, "precipitation.rda"), compress = "xz") +save(precipitation, file = file.path(dir.out, "precipitation.rda"), compress = "xz") @ <>= @@ -466,13 +479,13 @@ CheckStatus("precipitation") Priority cut dates applied to Big Wood River above Magic Reservoir and Silver Creek by Water District 37 and 37M at the end of each month. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/priority.cuts.csv")) +<>= +file <- file.path(dir.in, "div/priority.cuts.csv") priority.cuts <- read.csv(file, strip.white = TRUE) priority.cuts$YearMonth <- as.factor(priority.cuts$YearMonth) priority.cuts$Pdate_BWR <- as.Date(priority.cuts$Pdate_BWR, format = "%m/%d/%Y") priority.cuts$Pdate_SC <- as.Date(priority.cuts$Pdate_SC, format = "%m/%d/%Y") -save(priority.cuts, file = file.path(dir.dat, "priority.cuts.rda"), compress = "xz") +save(priority.cuts, file = file.path(dir.out, "priority.cuts.rda"), compress = "xz") @ <>= @@ -485,14 +498,14 @@ CheckStatus("priority.cuts") Surface-water diversions recorded by Water District 37 or municipal water providers. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/div.sw.csv")) +<>= +file <- file.path(dir.in, "div/div.sw.csv") div.sw <- read.csv(file, strip.white = TRUE) div.sw$YearMonth <- as.factor(div.sw$YearMonth) div.sw$SWDiv <- div.sw$SWDiv_af * af.to.m3 div.sw$SWDiv_af <- NULL div.sw[is.na(div.sw$SWDiv), "SWDiv"] <- 0 -save(div.sw, file = file.path(dir.dat, "div.sw.rda"), compress = "xz") +save(div.sw, file = file.path(dir.out, "div.sw.rda"), compress = "xz") @ <>= @@ -505,14 +518,14 @@ CheckStatus("div.sw") Discharge from wastewater treatment plants. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/div.ww.csv")) +<>= +file <- file.path(dir.in, "div/div.ww.csv") div.ww <- read.csv(file, strip.white = TRUE) div.ww$YearMonth <- as.factor(div.ww$YearMonth) div.ww$WWDiv <- div.ww$WWTP_af * af.to.m3 div.ww$WWTP_af <- NULL div.ww[is.na(div.ww$WWDiv), "WWDiv"] <- 0 -save(div.ww, file = file.path(dir.dat, "div.ww.rda"), compress = "xz") +save(div.ww, file = file.path(dir.out, "div.ww.rda"), compress = "xz") @ <>= @@ -528,9 +541,9 @@ Big Wood River near Ketchum, Idaho (13135500); Big Wood River at Hailey, Idaho (13139510); and Big Wood River at Stanton Crossing near Bellevue, Idaho (13140800). -<<>>= +<>= FUN <- function(i) { - file <- wrv::DownloadFile(paste0(url.git, "gage/", i)) + file <- file.path(dir.in, "gage", i) d <- read.csv(file, colClasses = "character", strip.white = TRUE) d$Date <- as.Date(d$Date, format = "%Y-%m-%d") d$Disch <- suppressWarnings(as.numeric(d$Disch_cfs)) * cfs.to.m3.per.d @@ -543,7 +556,7 @@ gage.13140800.disch <- FUN("gage.13140800.disch.csv") \noindent Combine discharge records into a single data table: -<<>>= +<>= dlim <- range(c(gage.13135500.disch$Date, gage.13139510.disch$Date, gage.13140800.disch$Date)) d <- data.frame(Date=seq(dlim[1], dlim[2], by = "day")) @@ -552,7 +565,7 @@ d <- dplyr::left_join(d, gage.13139510.disch, by = "Date") d <- dplyr::left_join(d, gage.13140800.disch, by = "Date") colnames(d) <- c("Date", "13135500", "13139510", "13140800") gage.disch <- d -save(gage.disch, file = file.path(dir.dat, "gage.disch.rda"), compress = "xz") +save(gage.disch, file = file.path(dir.out, "gage.disch.rda"), compress = "xz") @ <>= @@ -570,9 +583,9 @@ Big Wood River near Ketchum, Idaho (13135500); Big Wood River at Hailey, Idaho (13139510); and Big Wood River at Stanton Crossing near Bellevue, Idaho (13140800) (\hyperref[fig:graph_gage_height]{fig.~\ref{fig:graph_gage_height}}). -<<>>= +<>= FUN <- function(i) { - file <- wrv::DownloadFile(paste0(url.git, "gage/", i)) + file <- file.path(dir.in, "gage", i) d <- read.csv(file, colClasses = "character", strip.white = TRUE) d$DateTime <- strptime(d$DateTime, "%Y-%m-%d %H:%M", tz = "MST") d$Date <- as.Date(d$DateTime) @@ -589,7 +602,7 @@ gage.13140800.height <- FUN("gage.13140800.height.csv") \noindent Combine gage-height records into a single data table: -<<>>= +<>= dlim <- range(c(gage.13135500.height$Date, gage.13139510.height$Date, gage.13140800.height$Date)) d <- data.frame(Date=seq(dlim[1], dlim[2], by = "day")) @@ -601,13 +614,13 @@ colnames(d) <- c("Date", "13135500", "13139510", "13140800") \noindent Remove negative values of gage height (n = \Sexpr{length(which(d < 0))}): -<<>>= +<>= d[d < 0] <- NA @ \noindent Create a linear regression model between gage-height data recorded at the Hailey gage and Near Ketchum gage: -<<>>= +<>= x <- d[["13139510"]] y <- d[["13135500"]] LM <- lm(y ~ x) @@ -616,7 +629,7 @@ LM <- lm(y ~ x) \noindent A strong positive correlation (R-squared of \Sexpr{format(summary(LM)$r.squared, digits=3)}) indicates that the regression model may be used to estimate missing data at the Near Ketchum gage. -<<>>= +<>= is.na.13135500 <- is.na(y) d[["13135500"]][is.na.13135500] <- predict(LM, data.frame(x))[is.na.13135500] @ @@ -624,7 +637,7 @@ d[["13135500"]][is.na.13135500] <- predict(LM, data.frame(x))[is.na.13135500] \noindent Missing data at the Stanton Crossing near Bellevue gage are replaced with average gage-height values recorded at this gage. Substantial seepage losses and surface-water diversions between the Hailey gage and Stanton Crossing near Bellevue gage make regression inappropriate. -<<>>= +<>= jday <- as.integer(julian(as.Date(paste0("1900-", format(d$Date, "%m-%d"))), origin = as.Date("1899-12-31"))) m <- cbind(jday, height = d[["13140800"]]) @@ -641,9 +654,9 @@ d[["13140800"]][is.na.13140800] <- ave.heights[is.na.13140800] \noindent Save the dataset to disk: -<<>>= +<>= gage.height <- d -save(gage.height, file = file.path(dir.dat, "gage.height.rda"), compress = "xz") +save(gage.height, file = file.path(dir.out, "gage.height.rda"), compress = "xz") @ <>= @@ -666,13 +679,12 @@ x <- merge(d1, d2, by = "Date")[d$Date >= tr.interval[1] & d$Date < tr.interval[ cols <- rep(c("#1B9E77", "#D95F02", "#7570B3"), 2) ltys <- c(rep(1, 3), rep(3, 3)) ylab <- paste("Gage height, in", c("meters", "feet")) -wrv::PlotGraph(x, ylab=ylab, col=cols, lty=ltys, conversion.factor=1 / ft.to.m, - center.date.labels=TRUE) +inlmisc::PlotGraph(x, ylab=ylab, col=cols, lty=ltys, conversion.factor=1 / ft.to.m, + center.date.labels=TRUE) leg <- c(sprintf("%s measured", names(d)[-1]), sprintf("%s estimated", names(d)[-1])) legend("topright", leg, col=cols, lty=ltys, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= @@ -681,14 +693,14 @@ invisible(dev.off()) Points of diversion for groundwater. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "div/pod.gw.csv")) +<>= +file <- file.path(dir.in, "div/pod.gw.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$Pdate <- as.Date(d$PriorityDa, format = "%m/%d/%Y") d$IrrRate <- d$IRRcfs * cfs.to.m3.per.d columns <- c("WMISNumber", "WaterRight", "EntityName", "EntitySrce", "Pdate", "IrrRate") pod.gw <- d[, columns] -save(pod.gw, file = file.path(dir.dat, "pod.gw.rda"), compress = "xz") +save(pod.gw, file = file.path(dir.out, "pod.gw.rda"), compress = "xz") @ <>= @@ -701,8 +713,8 @@ CheckStatus("pod.gw") Recharge from miscellaneous seepage sites. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "misc.seepage.csv")) +<>= +file <- file.path(dir.in, "misc.seepage.csv") d <- read.csv(file, strip.white = TRUE) d$Rech <- d$Rech_af * af.to.m3 FUN <- function(i) { @@ -712,7 +724,7 @@ FUN <- function(i) { } l <- lapply(yr.mo, FUN) misc.seepage <- Reduce(function(x, y) merge(x, y, all = TRUE, by = "RechSite"), l) -save(misc.seepage, file = file.path(dir.dat, "misc.seepage.rda"), compress = "xz") +save(misc.seepage, file = file.path(dir.out, "misc.seepage.rda"), compress = "xz") @ <>= @@ -725,15 +737,15 @@ CheckStatus("misc.seepage") Hydraulic properties for each hydrogeologic zone. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "zone.properties.csv")) +<>= +file <- file.path(dir.in, "zone.properties.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$hk <- d$hk_ft.per.d * ft.to.m d$hk_ft.per.d <- NULL d$ss <- d$ss_per.ft / ft.to.m d$ss_per.ft <- NULL zone.properties <- d -save(zone.properties, file = file.path(dir.dat, "zone.properties.rda"), compress = "xz") +save(zone.properties, file = file.path(dir.out, "zone.properties.rda"), compress = "xz") @ <>= @@ -747,8 +759,8 @@ CheckStatus("zone.properties") Spring fed creek conditions are specified for select stream reaches. The mathematical representation of spring fed creeks using the MODFLOW river package is identical to the mathematical representation for a dry stream bed. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "perennial.reaches.csv")) +<>= +file <- file.path(dir.in, "perennial.reaches.csv") perennial.reaches <- read.csv(file, colClasses = "character", strip.white = TRUE)[, 1] drybed <- as.data.frame(matrix(NA, nrow = length(perennial.reaches), ncol = length(yr.mo))) colnames(drybed) <- yr.mo @@ -763,8 +775,8 @@ Between Wood River Ranch and Stanton Crossing, the Big Wood River gains water fr thus this reach acts as a spring fed creek when dry bed conditions are specified between Glendale and Wood River Ranch and there is no return flow from the Bypass Canal to the Big Wood River. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "canal/bypass.canal.op.csv")) +<>= +file <- file.path(dir.in, "canal/bypass.canal.op.csv") d <- read.csv(file, colClasses = "character", strip.white = TRUE) date1 <- as.Date(d$StartDate, tz = "MST") date2 <- as.Date(d$EndDate, tz = "MST") @@ -791,17 +803,17 @@ for (i in episodic.reaches) drybed[i, ] <- is.drybed \noindent During the month of October the water district stops monitoring diversions and much of the water diverted into the Bypass Canal is returned to the Big Wood River at Wood River Ranch. Therefore, flows in the Big Wood, Wood River Ranch to Stanton Crossing reach are accounted for in the model. -<<>>= +<>= drybed["Big Wood, Wood River Ranch to Stanton Crossing", substr(colnames(drybed), 5, 6) == "10"] <- FALSE @ \noindent Save the dataset to disk: -<<>>= +<>= drybed <- data.frame(Reach = rownames(drybed), drybed, check.names = FALSE, row.names = NULL, stringsAsFactors = FALSE) -save(drybed, file = file.path(dir.dat, "drybed.rda"), compress = "xz") +save(drybed, file = file.path(dir.out, "drybed.rda"), compress = "xz") @ <>= @@ -815,14 +827,14 @@ CheckStatus("drybed") Groundwater-level measurements recorded in observation wells in the WRV. Values used as observations in parameter estimation. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "opt/obs.wells.head.csv")) +<>= +file <- file.path(dir.in, "opt/obs.wells.head.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$DateTime <- as.POSIXct(d$DateTime, tz = "MST", format = "%Y-%m-%d %H:%M:%S") d$Head <- as.numeric(d$Head_m) d$Head_m <- NULL obs.wells.head <- d -save(obs.wells.head, file = file.path(dir.dat, "obs.wells.head.rda"), compress = "xz") +save(obs.wells.head, file = file.path(dir.out, "obs.wells.head.rda"), compress = "xz") @ <>= @@ -836,8 +848,8 @@ CheckStatus("obs.wells.head") Stream-aquifer flow exchange along river reaches specified as aquifer recharge. Values used as observations in parameter estimation. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "opt/reach.recharge.csv")) +<>= +file <- file.path(dir.in, "opt/reach.recharge.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d$YearMonth <- as.character(d$YearMonth) d$nKet_Hai <- d$nKet_Hai_cfs * cfs.to.m3.per.d @@ -851,7 +863,7 @@ d$SilverAbv_cfs <- NULL d$SilverBlw <- d$SilverBlw_cfs * cfs.to.m3.per.d d$SilverBlw_cfs <- NULL reach.recharge <- d -save(reach.recharge, file = file.path(dir.dat, "reach.recharge.rda"), compress = "xz") +save(reach.recharge, file = file.path(dir.out, "reach.recharge.rda"), compress = "xz") @ <>= @@ -865,15 +877,15 @@ CheckStatus("reach.recharge") Stream-aquifer flow exchange along river subreaches specified as aquifer recharge. Values used as observations in parameter estimation. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "opt/subreach.recharge.csv")) +<>= +file <- file.path(dir.in, "opt/subreach.recharge.csv") d <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) d[, c("Aug", "Oct", "Mar")] <- d[, c("Aug_cfs", "Oct_cfs", "Mar_cfs")] * cfs.to.m3.per.d d$Aug_cfs <- NULL d$Oct_cfs <- NULL d$Mar_cfs <- NULL subreach.recharge <- d -save(subreach.recharge, file = file.path(dir.dat, "subreach.recharge.rda"), +save(subreach.recharge, file = file.path(dir.out, "subreach.recharge.rda"), compress = "xz") @ @@ -887,8 +899,8 @@ CheckStatus("subreach.recharge") Calibrated parameter values and composite sensitivities generated by PEST during its last iteration. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "opt/sensitivity.csv")) +<>= +file <- file.path(dir.in, "opt/sensitivity.csv") sensitivity <- read.csv(file, strip.white = TRUE) sensitivity$parameter.name <- as.character(sensitivity$parameter.name) rel <- with(sensitivity, comp.sens * abs(value)) # Realtive Composite Sensitivity @@ -898,7 +910,7 @@ is.log <- sensitivity$parameter.desc %in% c("Horizontal hydraulic conductivity", "Drain conductance") rel[is.log] <- with(sensitivity, comp.sens * abs(log10(value)))[is.log] sensitivity$rel.comp.sens <- rel -save(sensitivity, file = file.path(dir.dat, "sensitivity.rda"), compress = "xz") +save(sensitivity, file = file.path(dir.out, "sensitivity.rda"), compress = "xz") @ <>= @@ -915,13 +927,12 @@ CheckStatus("sensitivity") Cities and towns in the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/cities.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -cities <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +cities <- readOGR(dsn = path, layer = "cities", verbose = FALSE) cities <- spTransform(cities, crs) cities <- cities[cities@data$FEATURE_NA != "Elkhorn Village", ] -save(cities, file = file.path(dir.dat, "cities.rda"), compress = "xz") +save(cities, file = file.path(dir.out, "cities.rda"), compress = "xz") @ <>= @@ -934,15 +945,15 @@ CheckStatus("cities") Map labels in the WRV and surrounding areas. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "decorative/map.labels.csv")) +<>= +file <- file.path(dir.in, "decorative/map.labels.csv") map.labels <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) map.labels$label <- sub("\\\\n", "\\\n", map.labels$label) coordinates(map.labels) <- 1:2 colnames(map.labels@coords) <- c("x", "y") proj4string(map.labels) <- CRS("+init=epsg:4326") map.labels <- spTransform(map.labels, crs) -save(map.labels, file = file.path(dir.dat, "map.labels.rda"), compress = "xz") +save(map.labels, file = file.path(dir.out, "map.labels.rda"), compress = "xz") @ <>= @@ -955,15 +966,15 @@ CheckStatus("map.labels") Miscellaneous locations in the Bellevue triangle area. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "decorative/misc.locations.csv")) +<>= +file <- file.path(dir.in, "decorative/misc.locations.csv") misc.locations <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) misc.locations$label <- sub("\\\\n", "\\\n", misc.locations$label) coordinates(misc.locations) <- 1:2 colnames(misc.locations@coords) <- c("x", "y") proj4string(misc.locations) <- CRS("+init=epsg:4326") misc.locations <- spTransform(misc.locations, crs) -save(misc.locations, file = file.path(dir.dat, "misc.locations.rda"), compress = "xz") +save(misc.locations, file = file.path(dir.out, "misc.locations.rda"), compress = "xz") @ <>= @@ -978,8 +989,8 @@ CheckStatus("misc.locations") Weather stations in the WRV and surrounding areas. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "precip/weather.stations.csv")) +<>= +file <- file.path(dir.in, "precip/weather.stations.csv") weather.stations <- read.csv(file, strip.white = TRUE, stringsAsFactors = FALSE) weather.stations$elevation <- weather.stations$elevation_ft * ft.to.m weather.stations$elevation_ft <- NULL @@ -988,7 +999,7 @@ coordinates(weather.stations) <- 1:2 colnames(weather.stations@coords) <- c("x", "y") proj4string(weather.stations) <- CRS("+init=epsg:4326") weather.stations <- spTransform(weather.stations, crs) -save(weather.stations, file = file.path(dir.dat, "weather.stations.rda"), compress = "xz") +save(weather.stations, file = file.path(dir.out, "weather.stations.rda"), compress = "xz") @ <>= @@ -1001,10 +1012,9 @@ CheckStatus("weather.stations") Well completions for pumping wells in the WRV aquifer system. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "div/pod.wells.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -pod.wells <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "div") +pod.wells <- readOGR(dsn = path, layer = "pod.wells", verbose = FALSE) pod.wells <- spTransform(pod.wells, crs) d <- pod.wells@data columns <- c("TopOpen1", "BotOpen1", "TopOpen2", "BotOpen2") @@ -1015,7 +1025,7 @@ d[d$TopOpen2 == 0 | d$BotOpen2 == 0, c("TopOpen2", "BotOpen2")] <- NA \noindent A missing well completion is assumed identical to the completion of its nearest-neighbor well. -<>= +<>= is.pred <- is.na(d$TopOpen1) dists <- as.matrix(dist(coordinates(pod.wells))) dists <- dists[!is.pred & d$WellUse %in% "Irrigation", ] @@ -1024,7 +1034,7 @@ d$TopOpen1[is.pred] <- d$TopOpen1[nearest.well[is.pred]] d$BotOpen1[is.pred] <- d$BotOpen1[nearest.well[is.pred]] columns <- c("WMISNumber", "WellUse", "TopOpen1", "BotOpen1", "TopOpen2", "BotOpen2") pod.wells@data <- d[, columns] -save(pod.wells, file = file.path(dir.dat, "pod.wells.rda"), compress = "xz") +save(pod.wells, file = file.path(dir.out, "pod.wells.rda"), compress = "xz") @ \noindent There are a total of \Sexpr{format(nrow(d), big.mark=",")} pumping wells; @@ -1037,9 +1047,9 @@ v <- c(paste("Map showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, nchar( @ <>= -wrv::PlotMap(crs, xlim=usr.map[1:2], ylim=usr.map[3:4], bg.image=wrv::hill.shading, - dms.tick=TRUE, bg.image.alpha=0.6, rivers=list(x=wrv::streams.rivers), - lakes=list(x=wrv::lakes), credit=credit) +inlmisc::PlotMap(crs, xlim=usr.map[1:2], ylim=usr.map[3:4], bg.image=wrv::hill.shading, + dms.tick=TRUE, bg.image.alpha=0.6, rivers=list(x=wrv::streams.rivers), + lakes=list(x=wrv::lakes), credit=credit) plot(wrv::alluvium.extent, border="#FFFFFFCC", add=TRUE) cols <- c("#9061C2D9", "#FBB829D9") pchs <- c(24, 21) @@ -1051,7 +1061,6 @@ text(wrv::cities, labels=wrv::cities@data$FEATURE_NA, col="#333333", cex=0.5, po leg <- paste(c("Estimated", "Measured"), "well completion") legend("topright", leg, col=NA, pt.bg=cols, pch=pchs, pt.cex=pt.cexs, pt.lwd=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ <>= @@ -1064,12 +1073,11 @@ CheckStatus("pod.wells") Select streamgages in the WRV. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "gage/streamgages.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -streamgages <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "gage") +streamgages <- readOGR(dsn = path, layer = "streamgages", verbose = FALSE) streamgages <- spTransform(streamgages, crs) -save(streamgages, file = file.path(dir.dat, "streamgages.rda"), compress = "xz") +save(streamgages, file = file.path(dir.out, "streamgages.rda"), compress = "xz") @ <>= @@ -1084,10 +1092,9 @@ CheckStatus("streamgages") Observation wells in the WRV. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/obs.wells.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -obs.wells <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE, +<>= +path <- file.path(dir.in, "opt") +obs.wells <- readOGR(dsn = path, layer = "obs.wells", verbose = FALSE, stringsAsFactors = FALSE) obs.wells <- spTransform(obs.wells, crs) d <- obs.wells@data @@ -1104,7 +1111,7 @@ d$BotOpen2 <- NA \noindent A missing well completion is assumed identical to the completion of its nearest-neighbor well. -<<>>= +<>= is.pred <- is.na(d$TopOpen1) dists <- as.matrix(dist(coordinates(obs.wells)))[!is.pred, ] nearest.well <- as.integer(apply(dists, 2, function(i) names(which.min(i)))) @@ -1119,8 +1126,8 @@ are missing well completions. Well completion depths are not relevant in the northern portion of the model area where only model layer 1 is active. Well completion data were not compiled for this area. -<<>>= -save(obs.wells, file = file.path(dir.dat, "obs.wells.rda"), compress = "xz") +<>= +save(obs.wells, file = file.path(dir.out, "obs.wells.rda"), compress = "xz") @ <>= @@ -1133,10 +1140,9 @@ CheckStatus("obs.wells") A Wood River Valley stream seepage study with streamflow measurements made during the months of August 2012, October 2012, and March 2013. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/seepage.study.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -seepage.study <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "opt") +seepage.study <- readOGR(dsn = path, layer = "seepage.study", verbose = FALSE) seepage.study <- spTransform(seepage.study, crs) d <- seepage.study@data d$Aug <- d$Aug_cfs * cfs.to.m3.per.d @@ -1146,27 +1152,24 @@ d$Aug_cfs <- NULL d$Oct_cfs <- NULL d$Mar_cfs <- NULL seepage.study@data <- d -save(seepage.study, file = file.path(dir.dat, "seepage.study.rda"), compress = "xz") +save(seepage.study, file = file.path(dir.out, "seepage.study.rda"), compress = "xz") @ <>= CheckStatus("seepage.study") @ -\newpage - % ========================================================================= \subsubsection{Diversions, returns, and exchange wells (div.ret.exch)} Location of streamflow diversions, irrigation canal or pond returns, and exchange well returns. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/div.ret.exch.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -div.ret.exch <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "opt") +div.ret.exch <- readOGR(dsn = path, layer = "div.ret.exch", verbose = FALSE) div.ret.exch <- spTransform(div.ret.exch, crs) -save(div.ret.exch, file = file.path(dir.dat, "div.ret.exch.rda"), compress = "xz") +save(div.ret.exch, file = file.path(dir.out, "div.ret.exch.rda"), compress = "xz") @ <>= @@ -1179,12 +1182,11 @@ CheckStatus("div.ret.exch") Location of pilot points in the model domain. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/pilot.points.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -pilot.points <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "opt") +pilot.points <- readOGR(dsn = path, layer = "pilot.points", verbose = FALSE) pilot.points <- spTransform(pilot.points, crs) -save(pilot.points, file = file.path(dir.dat, "pilot.points.rda"), compress = "xz") +save(pilot.points, file = file.path(dir.out, "pilot.points.rda"), compress = "xz") @ <>= @@ -1201,14 +1203,13 @@ CheckStatus("pilot.points") Canal systems in the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "canal/canals.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -canals <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "canal") +canals <- readOGR(dsn = path, layer = "canals", verbose = FALSE) canals <- spTransform(canals, crs) canals@data$Name <- as.character(canals@data$NAME) canals@data <- canals@data[, c("EntityName", "Name")] -save(canals, file = file.path(dir.dat, "canals.rda"), compress = "xz") +save(canals, file = file.path(dir.out, "canals.rda"), compress = "xz") @ <>= @@ -1221,10 +1222,8 @@ CheckStatus("canals") Stream reaches of the Big Wood River and Silver Creek. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "river.reaches.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -river.reaches <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +river.reaches <- readOGR(dsn = dir.in, layer = "river.reaches", verbose = FALSE) river.reaches <- spTransform(river.reaches, crs) d <- river.reaches@data d$RchAvg <- d$RchAvg_cfs * cfs.to.m3.per.d @@ -1234,27 +1233,24 @@ d$BedThk <- d$BedThk_ft * ft.to.m columns <- c("Reach", "BigReach", "DrainRiver", "RchAvg", "BigRAv", "ReachNo", "Depth", "BedThk") river.reaches@data <- d[, columns] -save(river.reaches, file = file.path(dir.dat, "river.reaches.rda"), compress = "xz") +save(river.reaches, file = file.path(dir.out, "river.reaches.rda"), compress = "xz") @ <>= CheckStatus("river.reaches") @ -\newpage - % ========================================================================= \subsubsection{Streams and rivers (streams.rivers)} Streams and rivers of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/rivers.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -streams.rivers <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +streams.rivers <- readOGR(dsn = path, layer = "rivers", verbose = FALSE) streams.rivers <- spTransform(streams.rivers, crs) -save(streams.rivers, file = file.path(dir.dat, "streams.rivers.rda"), compress = "xz") +save(streams.rivers, file = file.path(dir.out, "streams.rivers.rda"), compress = "xz") @ <>= @@ -1267,12 +1263,11 @@ CheckStatus("streams.rivers") Tributary streams of the upper WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/tributary.streams.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -tributary.streams <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +tributary.streams <- readOGR(dsn = path, layer = "tributary.streams", verbose = FALSE) tributary.streams <- spTransform(tributary.streams, crs) -save(tributary.streams, file = file.path(dir.dat, "tributary.streams.rda"), +save(tributary.streams, file = file.path(dir.out, "tributary.streams.rda"), compress = "xz") @ @@ -1286,13 +1281,12 @@ CheckStatus("tributary.streams") The location of the Bypass Canal. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "canal/bypass.canal.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -bypass.canal <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "canal") +bypass.canal <- readOGR(dsn = path, layer = "bypass.canal", verbose = FALSE) bypass.canal <- spTransform(bypass.canal, crs) bypass.canal <- as(bypass.canal, "SpatialLines") -save(bypass.canal, file = file.path(dir.dat, "bypass.canal.rda"), compress = "xz") +save(bypass.canal, file = file.path(dir.out, "bypass.canal.rda"), compress = "xz") @ <>= @@ -1305,13 +1299,11 @@ CheckStatus("bypass.canal") Groundwater-level contours for the unconfined aquifer in the Wood River Valley, south-central Idaho, representing conditions during October 2006. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "wl.200610.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -wl.200610 <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +wl.200610 <- readOGR(dsn = dir.in, layer = "wl.200610", verbose = FALSE) wl.200610 <- spTransform(wl.200610, crs) wl.200610@data$CONTOUR <- wl.200610@data$CONTOUR * ft.to.m -save(wl.200610, file = file.path(dir.dat, "wl.200610.rda"), compress = "xz") +save(wl.200610, file = file.path(dir.out, "wl.200610.rda"), compress = "xz") @ <>= @@ -1324,12 +1316,11 @@ CheckStatus("wl.200610") Major roads in the Wood River Valley and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/major.roads.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -major.roads <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +major.roads <- readOGR(dsn = path, layer = "major.roads", verbose = FALSE) major.roads <- spTransform(major.roads, crs) -save(major.roads, file = file.path(dir.dat, "major.roads.rda"), compress = "xz") +save(major.roads, file = file.path(dir.out, "major.roads.rda"), compress = "xz") @ <>= @@ -1346,12 +1337,11 @@ CheckStatus("major.roads") The estimated extent of the WRV aquifer system. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "extent/alluvium.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -alluvium.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "extent") +alluvium.extent <- readOGR(dsn = path, layer = "alluvium.extent", verbose = FALSE) alluvium.extent <- spTransform(alluvium.extent, crs) -save(alluvium.extent, file = file.path(dir.dat, "alluvium.extent.rda"), compress = "xz") +save(alluvium.extent, file = file.path(dir.out, "alluvium.extent.rda"), compress = "xz") @ <>= @@ -1364,12 +1354,11 @@ CheckStatus("alluvium.extent") The estimated extent of the confining hydrogeologic clay unit (aquitard) separating the unconfined aquifer from the underlying confined aquifer in the WRV. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "extent/clay.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -clay.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "extent") +clay.extent <- readOGR(dsn = path, layer = "clay.extent", verbose = FALSE) clay.extent <- spTransform(clay.extent, crs) -save(clay.extent, file = file.path(dir.dat, "clay.extent.rda"), compress = "xz") +save(clay.extent, file = file.path(dir.out, "clay.extent.rda"), compress = "xz") @ <>= @@ -1382,12 +1371,11 @@ CheckStatus("clay.extent") The estimated extent of the basalt hydrogeologic unit underlying the alluvial WRV aquifer system. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "extent/basalt.extent.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -basalt.extent <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "extent") +basalt.extent <- readOGR(dsn = path, layer = "basalt.extent", verbose = FALSE) basalt.extent <- spTransform(basalt.extent, crs) -save(basalt.extent, file = file.path(dir.dat, "basalt.extent.rda"), compress = "xz") +save(basalt.extent, file = file.path(dir.out, "basalt.extent.rda"), compress = "xz") @ <>= @@ -1401,24 +1389,22 @@ CheckStatus("basalt.extent") Polygons used to define the location of drain boundary conditions in the model domain. The polygons clip the line segments along the aquifer boundary (see alluvium.extent), and model cells intersecting these clipped-line segments are defined as boundary cells. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "drains.kml")) +<>= +file <- file.path(dir.in, "drains.kml") p <- suppressWarnings(readOGR(file, basename(file), verbose = FALSE)) p@data$Description <- NULL -file <- wrv::DownloadFile(paste0(url.git, "drains.csv")) +file <- file.path(dir.in, "drains.csv") d <- read.csv(file, strip.white = TRUE) p@data <- dplyr::left_join(p@data, d, by = "Name") p <- spTransform(p, crs) drains <- p -save(drains, file = file.path(dir.dat, "drains.rda"), compress = "xz") +save(drains, file = file.path(dir.out, "drains.rda"), compress = "xz") @ <>= CheckStatus("drains") @ -\newpage - % ========================================================================= \subsubsection{Tributary basin underflow (tributaries)} @@ -1426,8 +1412,8 @@ CheckStatus("drains") Data that describe the location and average flow conditions for model boundaries in the major tributary canyons of the WRV. Spatial polygons are used to define the boundary locations in the study area. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "tributaries.kml")) +<>= +file <- file.path(dir.in, "tributaries.kml") p <- suppressWarnings(readOGR(file, basename(file), verbose = FALSE)) p <- spTransform(p, crs) p@data$Description <- NULL @@ -1436,8 +1422,8 @@ p@data$Description <- NULL \noindent For each tributary canyon, the mean rate of tributary basin underflow is first estimated using a \href{http://en.wikipedia.org/wiki/Darcy_law}{Darcian} analysis. The lower-half of an ellipse is used to describe the geometry of the saturated cross-sectional area. -<<>>= -file <- wrv::DownloadFile(paste0(url.git, "tributaries.csv")) +<>= +file <- file.path(dir.in, "tributaries.csv") d <- read.csv(file, strip.white = TRUE) names(d) <- sub("_m$", "", names(d)) d$K <- d$K_ft.per.d * ft.to.m @@ -1451,7 +1437,7 @@ Smaller basins were identified by plotting basin areas for each tributary canyon A natural break was found at about 26 square-kilometers (10 square-miles) and tributary basins less than this break were designated as ``small'', and all others were designated as ``big''. -<<>>= +<>= d$BasinArea <- d$BasinArea_mi2 * mi2.to.m2 d$BasinArea_mi2 <- NULL natural.basin.area.break <- 2.59e+7 # 10 square-miles @@ -1461,7 +1447,7 @@ d$BasinAreaType <- as.factor(c("big", "small")[is.small + 1L]) \noindent Multiplying a basin's average rate of precipitation by its drainage area gives a secondary estimate of the mean volumetric flow rate at the boundary. -<<>>= +<>= d$PrecipRate <- d$PrecipRate_in.per.yr * in.per.y.to.m.per.d d$PrecipRate_in.per.yr <- NULL d$PrecipFlow <- d$BasinArea * d$PrecipRate @@ -1469,31 +1455,31 @@ d$PrecipFlow <- d$BasinArea * d$PrecipRate \noindent The ratio of Darcy to precipitation volumetric flow rate estimates is then calculated. -<<>>= +<>= d$FlowRatio <- d$DarcyFlow / d$PrecipFlow @ +\newpage + \noindent Finally, the mean volumetric flow rate of a small tributary canyon is calculated by multiplying its precipitation flow rate estimate by the average flow rate ratio for the larger tributary canyons. -<<>>= +<>= d$Flow <- d$DarcyFlow d$Flow[is.small] <- d$PrecipFlow[is.small] * mean(d$FlowRatio[!is.small]) @ \noindent Save the dataset to disk: -<<>>= +<>= p@data <- dplyr::left_join(p@data, d, by = "Name") tributaries <- p -save(tributaries, file = file.path(dir.dat, "tributaries.rda"), compress = "xz") +save(tributaries, file = file.path(dir.out, "tributaries.rda"), compress = "xz") @ <>= CheckStatus("tributaries") @ -\newpage - % ========================================================================= \subsubsection{Precipitation zones (precip.zones)} @@ -1501,7 +1487,7 @@ CheckStatus("tributaries") Precipitation zones of the WRV and surrounding areas. Northing coordinate of zone separators is based on the northing midpoint between weather stations. -<<>>= +<>= ids <- c("Ketchum", "Hailey", "Picabo") y <- coordinates(weather.stations)[match(rev(ids), weather.stations@data$id), "y"] s <- c(mean(y[1:2]), mean(y[2:3])) # northing zone separators @@ -1515,7 +1501,7 @@ p3 <- Polygons(list(Polygon(rbind(p3, p3[1, ]))), ID = 3) p <- SpatialPolygons(list(p1, p2, p3), proj4string = crs) p <- SpatialPolygonsDataFrame(p, data.frame(ID = 1:3, PrecipZone = ids)) precip.zones <- p -save(precip.zones, file = file.path(dir.dat, "precip.zones.rda"), compress = "xz") +save(precip.zones, file = file.path(dir.out, "precip.zones.rda"), compress = "xz") @ <>= @@ -1528,37 +1514,37 @@ CheckStatus("precip.zones") Irrigation entities of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "irr/irr.entities.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -irr.entities <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "irr") +irr.entities <- readOGR(dsn = path, layer = "irr.entities", verbose = FALSE) irr.entities <- spTransform(irr.entities, crs) irr.entities <- rgeos::gBuffer(irr.entities, width = 0, byid = TRUE) d <- irr.entities@data d$EntitySrce <- as.factor(paste(d$EntityName, d$Source)) d$PrecipZone <- over(rgeos::gCentroid(irr.entities, byid = TRUE), precip.zones)$PrecipZone irr.entities@data <- d[, c("EntityName", "Source", "EntitySrce", "PrecipZone")] -save(irr.entities, file = file.path(dir.dat, "irr.entities.rda"), compress = "xz") +save(irr.entities, file = file.path(dir.out, "irr.entities.rda"), compress = "xz") @ <>= CheckStatus("irr.entities") @ +\newpage + % ========================================================================= \subsubsection{Irrigation lands (irr.lands)} Irrigated and semi-irrigated lands of the WRV. -<<>>= +<>= +path <- file.path(dir.in, "irr") yr <- c(1996, 2000, 2002, 2006, 2008, 2009, 2010) -urls <- paste0(url.git, "irr/irr.lands.", yr, ".zip") +files <- paste0("irr.lands.", yr) irr.lands <- list() -for (i in seq_along(urls)) { - files <- wrv::DownloadFile(urls[i]) - layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) - p <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +for (i in seq_along(files)) { + p <- readOGR(dsn = path, layer = files[i], verbose = FALSE) p <- spTransform(p, crs) p@data <- p@data[, paste0("STATUS_", substr(yr[i], 1, 3)), drop = FALSE] names(p@data) <- "Status" @@ -1568,7 +1554,7 @@ for (i in seq_along(urls)) { irr.lands[[i]] <- p } names(irr.lands) <- as.character(yr) -save(irr.lands, file = file.path(dir.dat, "irr.lands.rda"), compress = "xz") +save(irr.lands, file = file.path(dir.out, "irr.lands.rda"), compress = "xz") @ <>= @@ -1581,12 +1567,11 @@ CheckStatus("irr.lands") Lakes and reservoirs of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/lakes.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -lakes <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +lakes <- readOGR(dsn = path, layer = "lakes", verbose = FALSE) lakes <- spTransform(lakes, crs) -save(lakes, file = file.path(dir.dat, "lakes.rda"), compress = "xz") +save(lakes, file = file.path(dir.out, "lakes.rda"), compress = "xz") @ <>= @@ -1599,13 +1584,11 @@ CheckStatus("lakes") Non-irrigated public land parcels for areas north of Bellevue. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "public.parcels.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -public.parcels <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +public.parcels <- readOGR(dsn = dir.in, layer = "public.parcels", verbose = FALSE) public.parcels <- spTransform(public.parcels, crs) public.parcels <- as(public.parcels, "SpatialPolygons") -save(public.parcels, file = file.path(dir.dat, "public.parcels.rda"), compress = "xz") +save(public.parcels, file = file.path(dir.out, "public.parcels.rda"), compress = "xz") @ <>= @@ -1618,14 +1601,12 @@ CheckStatus("public.parcels") Soil units of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "soils.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -soils <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +soils <- readOGR(dsn = dir.in, layer = "soils", verbose = FALSE) soils <- spTransform(soils, crs) soils@data <- soils@data[, c("GroupSym", "SoilLayer")] names(soils@data)[1] <- "GroupSymbol" -file <- wrv::DownloadFile(paste0(url.git, "soils.csv")) +file <- file.path(dir.in, "soils.csv") d <- read.csv(file, strip.white = TRUE) d$MinRate <- d$MinRate_ft.per.mo * ft.to.m d$MaxRate <- d$MaxRate_ft.per.mo * ft.to.m @@ -1635,7 +1616,7 @@ d <- suppressWarnings(dplyr::left_join(soils@data, d, by = "GroupSymbol")) d$GroupSymbol <- as.factor(d$GroupSymbol) d$PercolationRate[is.na(d$PercolationRate)] <- 0 soils@data <- d -save(soils, file = file.path(dir.dat, "soils.rda"), compress = "xz") +save(soils, file = file.path(dir.out, "soils.rda"), compress = "xz") @ <>= @@ -1648,34 +1629,29 @@ CheckStatus("soils") Wetlands of the WRV and surrounding areas. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "wetlands.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -wetlands <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +wetlands <- readOGR(dsn = dir.in, layer = "wetlands", verbose = FALSE) wetlands <- spTransform(wetlands, crs) wetlands <- as(wetlands, "SpatialPolygons") -save(wetlands, file = file.path(dir.dat, "wetlands.rda"), compress = "xz") +save(wetlands, file = file.path(dir.out, "wetlands.rda"), compress = "xz") @ <>= CheckStatus("wetlands") @ -\newpage - % ========================================================================= \subsubsection{Bellevue WWTP ponds (bellevue.wwtp.ponds)} Bellevue Waste Water Treatment Plant ponds. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "bellevue.wwtp.ponds.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -bellevue.wwtp.ponds <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +bellevue.wwtp.ponds <- readOGR(dsn = dir.in, layer = "bellevue.wwtp.ponds", + verbose = FALSE) bellevue.wwtp.ponds <- spTransform(bellevue.wwtp.ponds, crs) bellevue.wwtp.ponds <- as(bellevue.wwtp.ponds, "SpatialPolygons") -save(bellevue.wwtp.ponds, file = file.path(dir.dat, "bellevue.wwtp.ponds.rda"), +save(bellevue.wwtp.ponds, file = file.path(dir.out, "bellevue.wwtp.ponds.rda"), compress = "xz") @ @@ -1689,12 +1665,11 @@ CheckStatus("bellevue.wwtp.ponds") Kriging zones used in parameter estimation. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "opt/kriging.zones.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -kriging.zones <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "opt") +kriging.zones <- readOGR(dsn = path, layer = "kriging.zones", verbose = FALSE) kriging.zones <- spTransform(kriging.zones, crs) -save(kriging.zones, file = file.path(dir.dat, "kriging.zones.rda"), compress = "xz") +save(kriging.zones, file = file.path(dir.out, "kriging.zones.rda"), compress = "xz") @ <>= @@ -1707,13 +1682,12 @@ CheckStatus("kriging.zones") Boundary of the U.S. state of Idaho. -<<>>= -files <- wrv::DownloadFile(paste0(url.git, "decorative/idaho.zip")) -layer <- sub(".shp$", "", basename(files[grep("*.shp$", files)])) -idaho <- readOGR(dsn = tempdir(), layer = layer, verbose = FALSE) +<>= +path <- file.path(dir.in, "decorative") +idaho <- readOGR(dsn = path, layer = "idaho", verbose = FALSE) idaho <- as(idaho, "SpatialPolygons") idaho <- spTransform(idaho, crs) -save(idaho, file = file.path(dir.dat, "idaho.rda"), compress = "xz") +save(idaho, file = file.path(dir.out, "idaho.rda"), compress = "xz") @ <>= @@ -1724,26 +1698,19 @@ CheckStatus("idaho") \subsection{Grids} -Raster data are available at a higher resolution (smaller cells) than the resolution of the model grid. -Projecting the raster data into the model grid first requires the projection of raster data into a high resolution spatial grid of comparable cell size. -The high resolution spatial grid is defined using a constant cell size of 20 meters by 20 meters. -<<>>= -high.res.spatial.grid <- disaggregate(spatial.grid, fact = 5L) -@ - % ========================================================================= \subsubsection{Thickness of the quaternary sediment (alluvium.thickness)} The estimated thickness of the Quaternary sediment in the WRV aquifer system. -<>= -file <- wrv::DownloadFile(paste0(url.git, "alluvium.thickness.tif")) +<>= +file <- file.path(dir.in, "alluvium.thickness.tif") alluvium.thickness <- readGDAL(file, band = 1, silent = TRUE) alluvium.thickness <- projectRaster(raster(alluvium.thickness), high.res.spatial.grid) alluvium.thickness <- aggregate(alluvium.thickness, fact = 5L, fun = median) names(alluvium.thickness) <- "alluvium.thickness" -save(alluvium.thickness, file = file.path(dir.dat, "alluvium.thickness.rda"), +save(alluvium.thickness, file = file.path(dir.out, "alluvium.thickness.rda"), compress = "xz") @ @@ -1759,15 +1726,14 @@ CheckStatus("alluvium.thickness") The topography of the land surface in the WRV and vicinity. -<>= -wrv::DownloadFile(ftp.ned) -file <- file.path(tempdir(), "grdn44w115_13") -r <- raster(readGDAL(file, band = 1, silent = TRUE)) +<>= +path <- file.path(dir.in, "grdn44w115_13") +r <- raster(readGDAL(path, band = 1, silent = TRUE)) land.surface <- projectRaster(r, high.res.spatial.grid) land.surface <- aggregate(land.surface, fact = 5L, fun = median) land.surface[is.na(alluvium.thickness)] <- NA names(land.surface) <- "land.surface" -save(land.surface, file = file.path(dir.dat, "land.surface.rda"), compress = "xz") +save(land.surface, file = file.path(dir.out, "land.surface.rda"), compress = "xz") @ <>= @@ -1776,7 +1742,7 @@ CheckStatus("land.surface") \noindent Hillshading based on the slope and aspect of land-surface elevations. -<>= +<>= ext <- extent(spatial.grid) ext <- extent(c(extendrange(c(ext@xmin, ext@xmax), f = 0.05), extendrange(c(ext@ymin, ext@ymax), f = 0.05))) @@ -1789,7 +1755,7 @@ r.range <- range(r[], na.rm = TRUE) r[] <- findInterval(r[], seq(r.range[1], r.range[2], length.out = 255)) / 255 r[] <- round(r[], digits = 6) hill.shading <- r -save(hill.shading, file = file.path(dir.dat, "hill.shading.rda"), compress = "xz") +save(hill.shading, file = file.path(dir.out, "hill.shading.rda"), compress = "xz") @ <>= @@ -1803,21 +1769,20 @@ rm(hill.shading) Average monthly evapotranspiration in the WRV and surrounding areas. -<<>>= -urls <- paste0(url.git, "et/et.", yr.mo, ".tif") +<>= +files <- file.path(dir.in, "et", paste0("et.", yr.mo, ".tif")) FUN <- function(i) { - file <- wrv::DownloadFile(urls[i]) - r <- readGDAL(file, band = 1, silent = TRUE) + r <- readGDAL(files[i], band = 1, silent = TRUE) r[[1]] <- r[[1]] * mm.to.m return(r) } -et.raw <- lapply(seq_along(urls), FUN) +et.raw <- lapply(seq_along(files), FUN) names(et.raw) <- as.character(yr.mo) @ \noindent Project the raster data into the model grid, and place an upper and lower limit on evapotranspiration that is 3 standard deviations from the mean value. -<<>>= +<>= is.missing <- is.na(alluvium.thickness) FUN <- function(i) { r <- aggregate(projectRaster(raster(i), high.res.spatial.grid), fact = 5L) @@ -1828,7 +1793,7 @@ FUN <- function(i) { } et <- stack(lapply(et.raw, FUN), quick = TRUE) names(et) <- as.character(yr.mo) -save(et, file = file.path(dir.dat, "et.rda"), compress = "xz") +save(et, file = file.path(dir.out, "et.rda"), compress = "xz") @ <>= @@ -1856,11 +1821,11 @@ An irrigation entity is defined as an area served by a group of surface-water an Start with the spatial polygon representing the irrigated lands and remove those areas that are designated as wetlands or public parcels. Intersect the resulting polygon with the irrigation entities and calculate the area for each entity. -<<>>= +<>= p <- irr.lands -p <- lapply(p, function(i) wrv::SetPolygons(i, wetlands, "gDifference", 0.001)) -p <- lapply(p, function(i) wrv::SetPolygons(i, public.parcels, "gDifference", 0.001)) -p <- lapply(p, function(i) wrv::SetPolygons(irr.entities, i, "gIntersection", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(i, wetlands, "gDifference", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(i, public.parcels, "gDifference", 0.001)) +p <- lapply(p, function(i) inlmisc::SetPolygons(irr.entities, i, "gIntersection", 0.001)) for (i in seq_along(p)) p[[i]]@data$area <- rgeos::gArea(p[[i]], byid = TRUE) irr.by.entity <- p @ @@ -1872,7 +1837,7 @@ rm(list=c("irr.lands", "wetlands", "public.parcels")) \noindent Irrigation entities are subdivided by water source; that is, ``surface-water only'', ``groundwater only'', or ``mixed source''. Aggregate irrigation entities by water source and calculate their area. -<<>>= +<>= FUN <- function(i) { d <- aggregate(i@data$area, by = list(i@data$EntitySrce), sum, na.rm = TRUE) names(d) <- c("EntitySrce", "area") @@ -1883,11 +1848,9 @@ FUN <- function(i) { area.by.entity <- lapply(irr.by.entity, FUN) @ -\newpage - \noindent Calculate the volumetric components of evapotranspiration, precipitation, and crop irrigation requirement for each irrigation entity and water source. -<<>>= +<>= FUN <- function(i) { yr <- irr.lands.year$IL_Year[irr.lands.year$Year %in% substr(i, 1, 4)] p <- irr.by.entity[[yr]] @@ -1916,7 +1879,7 @@ FUN <- function(i) { } entity.components <- lapply(yr.mo, FUN) names(entity.components) <- yr.mo -save(entity.components, file = file.path(dir.dat, "entity.components.rda"), +save(entity.components, file = file.path(dir.out, "entity.components.rda"), compress = "xz") @ @@ -1935,29 +1898,27 @@ rm(et.raw) Rasterize canals on model grid. -<<>>= +<>= r <- rasterize(canals, land.surface, "EntityName", silent = TRUE) r <- ratify(r, count = TRUE) d <- levels(r)[[1]] d$EntityName <- levels(canals@data$EntityName)[d$ID] levels(r) <- d r.canals <- r -save(r.canals, file = file.path(dir.dat, "r.canals.rda"), compress = "xz") +save(r.canals, file = file.path(dir.out, "r.canals.rda"), compress = "xz") @ <>= CheckStatus("r.canals") @ -\newpage - % ========================================================================= \subsubsection{Rasterized monthly irrigation entities (rs.entities)} Rasterize monthly irrigation entities on model grid. -<<>>= +<>= FUN <- function(i) { r <- rasterize(entity.components[[i]], land.surface, "EntityName", silent = TRUE) r <- ratify(r, count = TRUE) @@ -1968,20 +1929,22 @@ FUN <- function(i) { } rs.entities <- stack(lapply(yr.mo, FUN), quick = TRUE) names(rs.entities) <- yr.mo -save(rs.entities, file = file.path(dir.dat, "rs.entities.rda"), compress = "xz") +save(rs.entities, file = file.path(dir.out, "rs.entities.rda"), compress = "xz") @ <>= CheckStatus("rs.entities") @ +\newpage + % ========================================================================= \subsubsection{Rasterized monthly recharge on non-irrigated lands (rs.rech.non.irr)} Calculate rasterized monthly volumetric flow rates of areal recharge beneath non-irrigated lands. -<<>>= +<>= r.zones <- ratify(rasterize(precip.zones, land.surface, "ID", silent = TRUE)) levels(r.zones) <- cbind(levels(r.zones)[[1]], att = precip.zones@data$PrecipZone) r.soils <- rasterize(soils, land.surface, "PercolationRate", silent = TRUE) @@ -2002,7 +1965,7 @@ FUN <- function(i) { } rs.rech.non.irr <- stack(lapply(yr.mo, FUN), quick = TRUE) names(rs.rech.non.irr) <- yr.mo -save(rs.rech.non.irr, file = file.path(dir.dat, "rs.rech.non.irr.rda"), compress = "xz") +save(rs.rech.non.irr, file = file.path(dir.out, "rs.rech.non.irr.rda"), compress = "xz") @ <>= diff --git a/vignettes/sir20165080_AppendixD.Rnw b/vignettes/sir20165080_AppendixD.Rnw index fc8fb05..5f21ce3 100644 --- a/vignettes/sir20165080_AppendixD.Rnw +++ b/vignettes/sir20165080_AppendixD.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{D\arabic{figure}} \renewcommand{\thetable}{D\arabic{table}} \renewcommand{\thepage}{D\arabic{page}} @@ -22,8 +24,6 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) options(preferRaster=TRUE, scipen=0, digits=2) -loadNamespace("xtable") -loadNamespace("sfsmisc") # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -132,10 +132,12 @@ Flow in the WRV aquifer system is simulated using \href{http://water.usgs.gov/og \section{R Environment} -Load the \textbf{wrv} package in the current \R{} session: +Load the following user-contributed packages into the current \R{} session: <>= -library("wrv") +library("wrv") # processor for groundwater-flow model +library("raster") # gridded spatial data toolkit +library("inlmisc") # miscellaneous functions for the USGS INL project office @ \noindent The memory requirement for running \R{} code in this vignette is about 5 gigabytes. @@ -198,7 +200,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) @ \noindent The elevation of the pre-Quaternary bedrock surface and top of Quaternary basalt is calculated by subtracting the thickness of the Quaternary sediments from land-surface elevations. @@ -250,9 +251,8 @@ text(misc.locations, labels=misc.locations@data$label, pos=c(3, 2, 2), cex=0.5, offset=0.3) legend("topright", "Basalt unit", fill=col, border=NA, inset=c(0.02, 0.55), cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0, -9)), - sub.label=list("Map area", adj=c(1.9, 0.5)), loc="topright") -invisible(dev.off()) +AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0.25, -9)), + sub.label=list("Map area", adj=c(1.65, 0.5)), loc="topright") @ Basalt underlies the Quaternary sediments; however, very little data are available to describe the unit thickness of basalt. @@ -289,7 +289,6 @@ PlotMap(r, breaks=pretty(range(r[], na.rm=TRUE), n=12), xlim=usr.map.s[1:2], yli rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ \newpage @@ -319,7 +318,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) legend("topright", "Clay confining unit", fill=col, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ \noindent Well-driller reports and geophysical surveys describe the clay confining unit as about 5 m (16 ft) thick, and generally lying at a depth of about 30 m (98 ft) below land surface. @@ -362,7 +360,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=range(pretty(r[])), rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ \noindent The total number of vertically adjusted cells is \Sexpr{format(length(adj.cells), big.mark=",")}, or \Sexpr{round(length(adj.cells) / length(cells) * 100)} percent of active cells, @@ -414,7 +411,6 @@ text(getSpatialLinesMidPoints(trib.lines), labels=rownames(trib.lines@data), leg <- as.character(levels(r)[[1]]$att) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ The presence of the clay confining unit significantly influences groundwater-level responses, necessitating a multi-layer model. @@ -520,7 +516,7 @@ A summary of the structured model grid attributes is shown in \hyperref[table_mo The model domain covers \Sexpr{round(active.lay1.area)} square kilometers (\Sexpr{round(active.lay1.area * km2.to.mi2)} square miles), or \Sexpr{percent.of.study.area} percent of the WRV aquifer system area. -<<>>= +<>= rs.model <- stack(crop(rs.model, extent(trim(rs.model[["lay1.top"]])))) @ @@ -703,7 +699,7 @@ rs.model[["lay3.zones"]] <- r <>= transect <- SpatialLines(list(Lines(list(Line(transect.coords)), ID="Transect")), - proj4string=CRS("+proj=longlat +datum=WGS84")) + proj4string=CRS("+init=epsg:4326")) transect <- spTransform(transect, crs(hill.shading)) verticies <- as(transect, "SpatialPoints") transect.ends <- verticies[c(1, length(verticies)), ] @@ -758,7 +754,6 @@ FUN <- function(i) { \caption{Model layer 3 \label{fig:map_zones_c}} <>= FUN("lay3.zones") - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -775,7 +770,6 @@ PlotCrossSection(transect, rs.model, geo.lays, val.lays, asp=80, col=cols, is.categorical=TRUE, draw.key=FALSE) legend("topright", paste("Zone", 1:4), fill=cols, ncol=1, border=NA, inset=c(0.02, 0), cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ Hydraulic properties assigned to each hydrogeologic zone (zone) are given in \hyperref[table_zones]{table~\ref{table_zones}}. @@ -875,7 +869,6 @@ leg <- format(match(colnames(d)[-1], make.names(tributaries@data$Name))) legend("topright", leg, lwd=1, col=cols, ncol=2, pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD", title=expression(bold("Tributary"))) -invisible(dev.off()) @ \noindent Steady-state volumetric flow rates are calculated for each boundary by averaging flows over time. @@ -1007,7 +1000,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=3, offse leg <- as.character(levels(r)[[1]]$Name) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ \noindent The drain boundary conditions are bundled into a single data table. @@ -1138,7 +1130,6 @@ text(misc.locations, labels=misc.locations@data$label, pos=c(3, 2, 2), cex=0.5, offset=0.3) legend("topright", "Streamgage", pch=17, col="#333333", pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ If the head in a model cell that contains a river subreach falls below the bottom of the riverbed, @@ -1249,7 +1240,7 @@ Normalization is done by subtracting the median of the monthly mean gage-height <<>>= d <- gage.height -d <- d[d$Date >= tr.interval[1] & d$Date < tr.interval[2], ] +d <- d[d$Date >= tr.stress.periods[1] & d$Date < tail(tr.stress.periods, 1), ] d <- data.frame(Date = format(d$Date, "%Y%m"), d[, -1], check.names = FALSE) d <- aggregate(d[, -1], by = list(YearMonth = d$Date), mean, na.rm = TRUE) d[, -1] <- apply(d[, -1], 2, function(x) x - median(x, na.rm = TRUE)) @@ -1311,7 +1302,6 @@ cols <- c("#1B9E77", "#D95F02", "#7570B3") PlotGraph(x, y, ylab=ylab, col=cols, conversion.factor=m.to.ft, center.date.labels=TRUE) legend("topright", colnames(y), lwd=c(1, 1, 1), col=cols, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD", title=expression(bold("Streamgages"))) -invisible(dev.off()) @ \noindent The northing-distance to the cell center is calculated for each of the river-boundary cells composing the Big Wood River. @@ -1402,9 +1392,16 @@ Areal recharge and pumping demand are specified for each month in the model simu (\hyperref[fig:graph_areal_rech]{figs.~\ref{fig:graph_areal_rech}} and \ref{fig:graph_wells}). The steady-state areal recharge is shown in \hyperref[fig:map_areal_rech]{figure~\ref{fig:map_areal_rech}}. -<<>>= -l <- RunWaterBalance(tr.stress.periods, rs.model[["lay1.bot"]], efficiency, - canal.seep, ss.stress.periods) +<>= +l <- RunWaterBalance(rs.model[["lay1.bot"]], tr.stress.periods, + ss.stress.periods, canal.seep = canal.seep, + comb.sw.irr = comb.sw.irr, div.gw = div.gw, + div.sw = div.sw, div.ww = div.ww, efficiency = efficiency, + entity.components = entity.components, et = et, + irr.entities = irr.entities, land.surface = land.surface, + pod.gw = pod.gw, priority.cuts = priority.cuts, + r.canals = r.canals, rs.entities = rs.entities, + rs.rech.non.irr = rs.rech.non.irr) cells <- which(!is.na(l[["areal.rech"]][[1]][])) rc <- rowColFromCell(l[["areal.rech"]], cells) rech <- cbind(lay = 1, row = rc[, 1], col = rc[, 2], l[["areal.rech"]][cells]) @@ -1441,7 +1438,6 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) legend("topright", "Pumping well", pch=21, col=NA, pt.bg=col, pt.cex=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ <>= @@ -1462,7 +1458,6 @@ PlotGraph(d, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) legend("topright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ <>= @@ -1478,7 +1473,6 @@ ylab <- paste("Total withdrawals from wells, in", c("cubic meters per day", "acr col <- "#C80C0B" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) -invisible(dev.off()) @ <>= @@ -1507,7 +1501,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=zlim, bg.image=hill.shadin rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ Seepage beneath the Bypass Canal and Bellevue Wastewater Treatment Plant Ponds (Bellevue WWTP Ponds) (locations shown in \hyperref[fig:map_basalt_extent]{fig.~\ref{fig:map_basalt_extent}}) @@ -1553,7 +1546,6 @@ ylab <- paste("Seepage rate, in", c("cubic meters per day", "acre-feet per year" col <- "#67A9CF" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) @ <>= @@ -1570,7 +1562,6 @@ ylab <- paste("Seepage rate, in", c("cubic meters per day", "acre-feet per year" col <- "#67A9CF" PlotGraph(x, y, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=FALSE, center.date.labels=TRUE) -invisible(dev.off()) @ \noindent Steady-state volumetric flow rates are calculated by averaging flows over time. @@ -1607,9 +1598,9 @@ Groundwater flow in the WRV aquifer system is simulated using the MODFLOW-USG nu This model was chosen for its ability to solve complex unconfined groundwater flow simulations. The model-input files are written to disk. -<<>>= +<>= id <- "wrv_mfusg" # model run identifier -dir.run <- file.path(getwd(), "model/model1") +dir.run <- "model/model1" WriteModflowInput(rs.model, rech, well, trib, misc, river, drain, id, dir.run, is.convertible = FALSE, tr.stress.periods = tr.stress.periods, ntime.steps = ntime.steps, verbose = FALSE) @@ -1627,7 +1618,7 @@ invisible(file.copy(file.exe, dir.run, copy.date = TRUE)) \noindent Create and execute a `batch file' containing commands that run MODFLOW-USG: <<>>= -file.bat <- file.path(dir.run, "RunModflow.bat") +file.bat <- file.path(getwd(), dir.run, "RunModflow.bat") cmd <- paste(sub("\\.exe$", "", basename(file.exe)), shQuote(paste0(id, ".nam"))) cat(cmd, file = file.bat) Sys.chmod(file.bat, mode = "755") @@ -1653,14 +1644,14 @@ Water budget components are as follows: (4) groundwater discharge at the Stanton Crossing and Silver Creek outlet boundaries. \hyperref[fig:graph_budget]{Figure~\ref{fig:graph_budget}} shows the annual water budget components and change in aquifer system storage during the uncalibrated model simulation period (1995--2010). -<<>>= +<>= file.bud <- file.path(dir.run, paste0(id, ".bud")) budget <- ReadModflowBinary(file.bud, "flow", rm.totim.0 = TRUE) budget <- SummariseBudget(budget) -budget <- dplyr::mutate(budget, totim.date = as.Date(totim, origin = tr.interval[1])) +budget <- dplyr::mutate(budget, totim.date = as.Date(totim, origin = tr.stress.periods[1])) @ -<>= +<>= b <- budget[, c("desc", "id", "flow.dir", "totim.date")] b$flow <- budget$flow.sum @@ -1674,7 +1665,7 @@ d.river <- d d <- b[b$desc == "drains" & b$flow.dir == "out", ] d$id <- as.factor(d$id) -levels(d$id) <- levels(rs.model[["drains"]])[[1]]$Name +levels(d$id) <- drains@data$Name d.drain.1 <- d[d$id == "Stanton Crossing", c("totim.date", "flow")] d.drain.2 <- d[d$id == "Silver Creek", c("totim.date", "flow")] @@ -1700,7 +1691,7 @@ v <- c(paste("Graph showing", paste0(tolower(substr(v, 1, 1)), substr(v, 2, ncha @ <>= -cols <- format(seq(tr.interval[1], tr.interval[2] - 1, "year"), "%Y") +cols <- format(seq(tr.stress.periods[1], tail(tr.stress.periods, 1) - 1, "year"), "%Y") rows <- c("Areal recharge", "Streamflow losses", "Tributary bain underflow", "Areal discharge", "Streamflow gains", "Well pumping", "Outlet boundaries") m <- matrix(NA, nrow=length(rows), ncol=length(cols), dimnames=list(rows, cols)) @@ -1748,21 +1739,18 @@ idxs <- c(rev(pos.idxs), neg.idxs) legend("topright", rows[idxs], fill=cols[idxs], inset=0.02, cex=cex, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Component"))) box(lwd=0.5) -invisible(dev.off()) @ <>= -sdate <- as.Date("1995-01-01", tz="MST") -is.date <- colnames(m) >= format(sdate, "%Y") -flow <- c("Water-table recharge" = as.integer(mean(d.rech$flow.in[is.date])), - "Streamflow losses" = as.integer(mean(d.river$flow.in[is.date])), - "Tributary basin underflow" = as.integer(mean(d.trib$flow[is.date])), +flow <- c("Water-table recharge" = as.integer(mean(d.rech$flow.in)), + "Streamflow losses" = as.integer(mean(d.river$flow.in)), + "Tributary basin underflow" = as.integer(mean(d.trib$flow)), " " = NA, - "Water-table discharge" = as.integer(abs(mean(d.rech$flow.out[is.date]))), - "Streamflow gains" = as.integer(abs(mean(d.river$flow.out[is.date]))), - "Production well pumping" = as.integer(abs(mean(d.well$flow[is.date]))), - "Stanton Crossing outlet boundary" = as.integer(abs(mean(d.drain.1$flow[is.date]))), - "Silver Creek outlet boundary" = as.integer(abs(mean(d.drain.2$flow[is.date]))), + "Water-table discharge" = as.integer(abs(mean(d.rech$flow.out))), + "Streamflow gains" = as.integer(abs(mean(d.river$flow.out))), + "Production well pumping" = as.integer(abs(mean(d.well$flow))), + "Stanton Crossing outlet boundary" = as.integer(abs(mean(d.drain.1$flow))), + "Silver Creek outlet boundary" = as.integer(abs(mean(d.drain.2$flow))), " " = NA, "Change in aquifer storage" = NA) flow[11] <- sum(flow[1:3]) - sum(flow[5:9]) @@ -1807,9 +1795,9 @@ print(tbl, include.rownames=FALSE, caption.placement="top", booktabs=TRUE, The simulated hydraulic head values are read for each of the 193 monthly model stress periods and placed in a raster stack. Recall that the model simulates head distributions for an initial steady-state stress period followed by 768 weekly time steps (4 time steps per stress period) during the 1995 through 2010 time period. -<<>>= +<>= heads <- ReadModflowBinary(file.path(dir.run, paste0(id, ".hds"))) -dates <- as.Date(vapply(heads, function(i) i$totim, 0), origin = tr.interval[1]) +dates <- as.Date(vapply(heads, function(i) i$totim, 0), origin = tr.stress.periods[1]) layer <- vapply(heads, function(i) i$ilay, 0L) FUN <- function(i) {return(setValues(raster(rs.model), i$d))} rs.heads.lay1 <- mask(stack(lapply(heads[layer == 1L], FUN)), rs.model[["lay1.bot"]]) @@ -1826,7 +1814,7 @@ and should be considered an overprediction of head because land surface is the t The simulated water table is represented using model layer 1 head values bounded by the land-surface elevation; that is, head values that are above land surface are specified at land surface. -<<>>= +<>= land <- mask(crop(rs.data[["land.surface"]], raster(rs.model)), rs.heads.lay1[[1]]) FUN <- function(i) { r <- rs.heads.lay1[[i]] @@ -1872,7 +1860,6 @@ PlotMap(r, xlim=usr.map[1:2], ylim=usr.map[3:4], zlim=zlim, bg.image=hill.shadin rivers=list(x=streams.rivers), lakes=list(x=lakes), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ <>= @@ -1903,7 +1890,6 @@ leg <- c("Inset areas, fig. D23", "Line of cross section, fig. D24") legend("topright", leg, lwd=c(NA, 1), pch=c(22, NA), col=c("#000000", "#1F1F1F"), pt.bg=c(NA, NA), pt.cex=c(1.5, NA), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ <>= @@ -1952,7 +1938,6 @@ FUN <- function(usr, credit=NULL, max.dev.dim=c(21, 56), add.legend=FALSE) { \caption{South of Hailey and north of Bellevue \label{fig:map_wt_d}} <>= FUN(usr.map.n.4) - invisible(dev.off()) @ \end{subfigure} @@ -1970,7 +1955,6 @@ FUN <- function(usr, credit=NULL, max.dev.dim=c(21, 56), add.legend=FALSE) { \caption{South of Bellevue \label{fig:map_wt_e}} <>= FUN(usr.map.s, credit, max.dev.dim=c(43, 56), add.legend=TRUE) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -1993,7 +1977,6 @@ PlotCrossSection(transect, rs, geo.lays, val.lays, wt.lay, asp=80, leg <- c("Head contour", "Water table") legend("bottomleft", leg, col=c("#1F1F1F", "#3B80F4"), lty=c(1, 1), lwd=c(0.5, 1), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ \clearpage @@ -2044,7 +2027,6 @@ text(locs, labels=labs, cex=0.5, pos=1, offset=0.1, col=cols[2]) leg <- c("Simulated contour", "Measured contour (interpolated)", "Measured contour (extrapolated)") legend("topright", leg, col=c(cols, cols[2]), lwd=1, lty=c(1, 1, 2), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ <>= @@ -2195,7 +2177,6 @@ FUN <- function(desc) { \caption{SVWSD and TNC wells \label{fig:graph_res_sim_d}} <>= FUN(c("Sun Valley Water and Sewer well", "Nature Conservancy well")) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2282,7 +2263,6 @@ points(pp[3:6, ], pch=18) text(pp[3:6, ], labels=well.labs[3:6], col="#333333", cex=0.6, pos=c(4, 4, 2, 2), offset=0.4) legend("topleft", "Wells in figs. D32 and D33", pch=18, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFCD") -invisible(dev.off()) @ Comparisons between simulated and measured groundwater levels over time are made for selected wells in the WRV @@ -2379,7 +2359,6 @@ FUN <- function(idx, add.legend=FALSE) { \caption{\Sexpr{paste("Well No.", well.labs[6])} \label{fig:graph_wells_tnc_b}} <>= FUN(6) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2420,7 +2399,6 @@ PlotGraph(d, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) legend("bottomright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFCD") -invisible(dev.off()) @ % === @@ -2543,7 +2521,6 @@ FUN(d3, TRUE) \caption{Silver Creek, Sportsman Access to near Picabo river reach \label{fig:graph_reaches_sc_b}} <>= FUN(d5) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2615,7 +2592,6 @@ FUN <- function(d, add.legend=FALSE) { legend("center", leg, pch=c(20, 15), col=cols, pt.cex=c(1, 1.5), pt.lwd=0.5, inset=0.02, cex=0.7, bty="n", xpd=NA, bg="#FFFFFFCD", title=expression(bold("EXPLANATION"))) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2638,7 +2614,6 @@ FUN <- function(d, add.legend=FALSE) { \caption{Sportsman Access to near Picabo \label{fig:graph_exch_e}} <>= FUN(d5) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -2757,7 +2732,6 @@ FUN <- function(mo) { legend("center", leg, pch=c(20, 18, 15), col=cols, pt.cex=c(1, 1, 1.5), pt.lwd=0.5, inset=0.02, cex=0.7, bty="n", xpd=NA, bg="#FFFFFFCD", title=expression(bold("EXPLANATION"))) - invisible(dev.off()) @ \end{subfigure} <>= @@ -2791,7 +2765,6 @@ ylab <- paste("Groundwater discharge, in", c("cubic meters per day", "acre-feet col <- "#C80C0B" PlotGraph(d.drain.1, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=FALSE, center.date.labels=TRUE) -invisible(dev.off()) @ <>= @@ -2804,7 +2777,6 @@ ylab <- paste("Groundwater discharge, in", c("cubic meters per day", "acre-feet col <- "#C80C0B" PlotGraph(d.drain.2, ylab=ylab, col=col, fill=paste0(col, "66"), conversion.factor=m3.per.d.to.af.per.yr, scientific=TRUE, center.date.labels=TRUE) -invisible(dev.off()) @ % ========================================================================= @@ -2841,7 +2813,7 @@ if (file.exists(file.path(dir.run, "sy1.ref"))) { } # write raster stacks -path <- file.path(getwd(), "ancillary", "uncalibrated") +path <- "ancillary/uncalibrated" ExportRasterStack(rs.data, file.path(path, "data")) ExportRasterStack(rs.model, file.path(path, "model")) @@ -2897,7 +2869,7 @@ animation::saveHTML({ setwd(wd) # write model domain shapefile -path <- file.path(getwd(), "georef") +path <- "georef" dir.create(path, showWarnings=FALSE, recursive=TRUE) p1 <- as(extent(rs.model), "SpatialPolygons") r <- is.na(rs.model[["lay1.bot"]]) @@ -2913,11 +2885,11 @@ p <- SpatialPolygons(list(p1=p1@polygons[[1]], p2=p2@polygons[[1]], p3=p3@polygo d <- data.frame(Area=c("maximum model extent", "active model domain", "inactive model domain"), row.names=sapply(slot(p, "polygons"), function(x) slot(x, "ID"))) p <- SpatialPolygonsDataFrame(p, d) -writeOGR(p, dsn=path, layer="sir2016_5080", driver="ESRI Shapefile", - overwrite_layer=TRUE, encoding="UTF-8") +rgdal::writeOGR(p, dsn=path, layer="sir2016_5080", driver="ESRI Shapefile", + overwrite_layer=TRUE, encoding="UTF-8") # write model grid shapefile -path <- file.path(getwd(), "ancillary/modelgrid") +path <- "ancillary/modelgrid" dir.create(path, showWarnings=FALSE, recursive=TRUE) r <- raster(rs.model) r[] <- seq_len(ncell(r)) @@ -2928,18 +2900,17 @@ p@data <- cbind(p@data, rowColFromCell(r, p@data$cell), lay1.bot=rs.model[["lay1.bot"]][p@data$cell], lay2.bot=rs.model[["lay2.bot"]][p@data$cell], lay3.bot=rs.model[["lay3.bot"]][p@data$cell]) -writeOGR(p, dsn=path, layer="grid", driver="ESRI Shapefile", - overwrite_layer=TRUE, encoding="UTF-8") +rgdal::writeOGR(p, dsn=path, layer="grid", driver="ESRI Shapefile", + overwrite_layer=TRUE, encoding="UTF-8") # write modelgeoref file -path <- getwd() r <- raster(rs.model) e <- rs.model@extent pts <- rbind(nw=c(e@xmin, e@ymax), ne=c(e@xmax, e@ymax), se=c(e@xmax, e@ymin), sw=c(e@xmin, e@ymin)) corners <- c("upper_left", "upper_right", "lower_right", "lower_left") pts.xy <- SpatialPoints(pts, proj4string=crs(r)) -crs.ll <- CRS("+proj=longlat +datum=WGS84") +crs.ll <- CRS("+init=epsg:4326") pts.ll <- spTransform(pts.xy, crs.ll) lng <- coordinates(pts.ll)[, 1] lat <- coordinates(pts.ll)[, 2] @@ -2949,11 +2920,9 @@ ll <- paste(ll, collapse="\n") replacement <- list(ll=ll, crs.ll=crs.ll@projargs) file <- system.file("misc", "modelgeoref-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "modelgeoref.txt") -cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") +cat(ReplaceInTemplate(text, replacement), file="modelgeoref.txt", sep="\n") # write readme file -path <- getwd() desc <- packageDescription("wrv") fields <- c("Depends", "Imports", "Suggests") FUN <- function(i) strsplit(gsub("\n", " ", desc[[i]]), ", ")[[1]] @@ -2963,47 +2932,43 @@ pkgs <- paste(pkgs, collapse="\n ") replacement <- list(pkgs=pkgs, id=id) file <- system.file("misc", "readme-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "readme.txt") options(width=70) -cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") +cat(ReplaceInTemplate(text, replacement), file="readme.txt", sep="\n") options(width=80) # write usgs.model.reference file -path <- file.path(getwd(), "model/model1") replacement <- list(xul=coordinates(pts)["ne", 1], yul=coordinates(pts)["ne", 2], - start_date=format(sdate, "%m/%d/%Y"), + start_date=format(tr.stress.periods[1], "%m/%d/%Y"), model="modflow-usg", proj4=proj4string(rs.model)) file <- system.file("misc", "usgs.model.ref-template.txt", package="wrv") text <- readLines(file, warn=FALSE) -file <- file.path(path, "usgs.model.reference") +file <- "model/model1/usgs.model.reference" cat(ReplaceInTemplate(text, replacement), file=file, sep="\n") # remove temporary files -path <- file.path(getwd(), "model/model1") -file <- file.path(path, "fort.6") +file <- "model/model1/fort.6" if (file.exists(file)) invisible(file.remove(file)) # move modflow output files -path <- file.path(getwd(), "output/output.model1") +path <- "output/output.model1" dir.create(path, showWarnings=FALSE, recursive=TRUE) file.names <- paste(id, c("bud", "hds", "lst"), sep=".") -invisible(file.rename(file.path(getwd(), "model/model1", file.names), +invisible(file.rename(file.path("model/model1", file.names), file.path(path, file.names))) # move modflow executable file -path <- file.path(getwd(), "bin") +path <- "bin" dir.create(path=path, showWarnings=FALSE, recursive=TRUE) -invisible(file.rename(file.path(getwd(), "model/model1/mfusg.exe"), +invisible(file.rename(file.path("model/model1/mfusg.exe"), file.path(path, "mfusg.exe"))) # create source directory -path <- file.path(getwd(), "source") -dir.create(path=path, showWarnings=FALSE, recursive=TRUE) +dir.create(path="source", showWarnings=FALSE, recursive=TRUE) # write xml metadata and thumbnail image -path <- file.path(getwd(), "webrelease") +path <- "webrelease" dir.create(path, showWarnings=FALSE, recursive=TRUE) file <- system.file("misc", "sir2016-5080_usgsdatarelease.xml", package="wrv") @@ -3050,7 +3015,6 @@ axis(1, at=xat, tcl=tcl, lwd=-1, lwd.ticks=0.3, labels=FALSE, mgp=mgp) axis(4, at=yat, tcl=tcl, lwd=-1, lwd.ticks=0.3, labels=FALSE, mgp=mgp) mtext("Columns", side=3, line=1, cex=cex, font=2) mtext("Rows", side=2, line=1, cex=cex, font=2) -invisible(dev.off()) @ % ========================================================================= diff --git a/vignettes/sir20165080_AppendixE.Rnw b/vignettes/sir20165080_AppendixE.Rnw index c6212f2..541469e 100644 --- a/vignettes/sir20165080_AppendixE.Rnw +++ b/vignettes/sir20165080_AppendixE.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{E\arabic{figure}} \renewcommand{\thetable}{E\arabic{table}} \renewcommand{\thepage}{E\arabic{page}} @@ -21,9 +23,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -182,7 +185,6 @@ legend("topleft", leg, pch=c(15, 17, 22, NA), lwd=c(NA, NA, NA, 1), col=cols, box.lwd=0.5, bg="#FFFFFFE7", seg.len=1.4) AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) @ \begin{landscape} @@ -333,7 +335,6 @@ RotateLine <- function(m, ang=90) { legend("topleft", leg, lwd=c(2, 2, 1), col=cols, pt.bg="#33333366", inset=0.02, cex=0.7, box.lty=1, box.lwd=0.3, bg="#FFFFFFE7", seg.len=1) - invisible(dev.off()) @ \end{subfigure}% \begin{subfigure}{0.5\textwidth} @@ -368,7 +369,6 @@ RotateLine <- function(m, ang=90) { text(xlim[2], ylim[2], "B'", cex=0.7, pos=3, font=4) text(xlim[2], ylim[2], "B'", cex=0.7, pos=3, font=4) text(mean(xlim), ylim[2], "LAND SURFACE", cex=0.7, pos=3) - invisible(dev.off()) @ \end{subfigure} @@ -467,7 +467,6 @@ text(seq_along(x[, 1]), x[, 2], x[, 1], pos=pos, offset=0.3, cex=0.6, srt=90) xlim <- par("usr")[1:2] text(xlim[2] - diff(xlim) * 0.15, natural.basin.area.break, "Natural break in basin areas", col=col, cex=0.7, pos=1, offset=0.2) -invisible(dev.off()) @ <>= @@ -486,7 +485,6 @@ axis(1, at=at, labels=labs, cex.axis=0.7, tcl=tcl, lwd=0.5) labs <- paste("Basin size is", c("'big'", "'small'")) legend("topright", labs, fill=cols, border=cols, inset=0.05, cex=0.7, pt.cex=1, box.lwd=NA, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= @@ -757,7 +755,6 @@ PlotGraph(d, ylab=ylab, col=cols, fill=fill, conversion.factor=m3.per.d.to.af.pe center.date.labels=TRUE, scientific=c(FALSE, FALSE, FALSE)) legend("topright", labs, col=cols, lty=1, inset=0.02, cex=0.7, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= diff --git a/vignettes/sir20165080_AppendixF.Rnw b/vignettes/sir20165080_AppendixF.Rnw index 0b6c6a5..cd3c440 100644 --- a/vignettes/sir20165080_AppendixF.Rnw +++ b/vignettes/sir20165080_AppendixF.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{F\arabic{figure}} \renewcommand{\thetable}{F\arabic{table}} \renewcommand{\thepage}{F\arabic{page}} @@ -21,9 +23,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -237,7 +240,6 @@ legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, leg <- "Weather stations" legend("topleft", leg, pch=23, pt.bg="#333333", pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ Colder winter temperatures during the months of November through March result in frozen precipitation (snow). @@ -274,7 +276,6 @@ axis.Date(1, at=at, tcl=0, cex.axis=0.6, lwd=-1, labels=xlabs, padj=1.5) leg <- c("Chocolate Gulch SNOTEL", "Hailey HADS", "Picabo AgriMet") legend("topright", leg, col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ \newpage @@ -394,7 +395,6 @@ FUN <- function(i, col) { \caption{Picabo \label{fig:graph_precip_c}} <>= FUN("Picabo", "#7570B3") - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -444,7 +444,6 @@ legend(mean(par("usr")[1:2]), 1, levels(y)[idxs], fill=cols[idxs], horiz=TRUE, cex=0.7, bty="n", xpd=TRUE, xjust=0.5, yjust=0, border=c("#333333", cols[idxs][-1])) box(lwd=0.5) -invisible(dev.off()) @ % ========================================================================= @@ -854,7 +853,6 @@ FUN <- function(i) { \caption{August 2008 \label{fig:map_et_b}} <>= FUN(et[["200808"]]) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -920,7 +918,6 @@ FUN <- function(xlim) { \caption{2007 through 2010 \label{fig:graph_et_d}} <>= FUN(c("2007-01-01", "2011-01-01")) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -968,7 +965,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse leg <- as.character(levels(polys@data$GroupSymbol)) legend("topright", leg, fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Soil Types"))) -invisible(dev.off()) @ <>= @@ -1016,7 +1012,6 @@ PlotMap(r, breaks=breaks, xlim=usr.map[1:2], ylim=usr.map[3:4], labels=list(at=at, labels=labels), credit=credit) plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offset=0.4) -invisible(dev.off()) @ % ========================================================================= @@ -1081,7 +1076,6 @@ FUN <- function(i) { \caption{August 2008 \label{fig:map_rate_b}} <>= FUN(rs[["200808"]]) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -1147,7 +1141,6 @@ FUN <- function(xlim) { \caption{2007 through 2010 \label{fig:graph_rate_d}} <>= FUN(c("2007-01-01", "2011-01-01")) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} diff --git a/vignettes/sir20165080_AppendixG.Rnw b/vignettes/sir20165080_AppendixG.Rnw index 2486ba2..4466614 100644 --- a/vignettes/sir20165080_AppendixG.Rnw +++ b/vignettes/sir20165080_AppendixG.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{G\arabic{figure}} \renewcommand{\thetable}{G\arabic{table}} \renewcommand{\thepage}{G\arabic{page}} @@ -21,9 +23,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -315,7 +318,6 @@ legend("topleft", leg, pch=c(22, NA, 22), lwd=c(NA, 1, NA), col=cols, box.lwd=0.5, bg="#FFFFFFE7") AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topright") -invisible(dev.off()) @ <>= @@ -376,7 +378,6 @@ FUN <- function(usr, credit=NULL, pos=1, max.dev.dim=c(43, 56)) { \caption{South of Hailey and north of Bellevue \label{fig:map_canals_d}} <>= FUN(usr.map.n.4, pos=3, max.dev.dim=c(21, 56)) - invisible(dev.off()) @ \end{subfigure} <>= @@ -393,7 +394,6 @@ FUN <- function(usr, credit=NULL, pos=1, max.dev.dim=c(43, 56)) { \caption{South of Bellevue \label{fig:map_canals_e}} <>= FUN(usr.map.s, credit) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -453,7 +453,6 @@ text(suppressWarnings(getSpatialPolygonsLabelPoints(bellevue.wwtp.ponds)), labels="Bellevue WWTP Ponds", cex=0.5, col="#333333", font=1, pos=2) legend("topright", as.character(levels(r)[[1]]$RechSite), fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= @@ -580,7 +579,6 @@ FUN <- function(i) { \caption{2010 \label{fig:map_land_use_g}} <>= FUN("2010") - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -602,7 +600,6 @@ legend("topright", c("Wetlands", "Public parcels"), fill=c("#59A80F", "#CDBB99C0 border=c(NA, "#755C3BC0"), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") box(lwd=0.5) -invisible(dev.off()) @ \newpage @@ -747,7 +744,6 @@ FUN <- function(usr) { \caption{South of Hailey and north of Bellevue \label{fig:map_entities_d}} <>= FUN(usr.map.n.4) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -759,7 +755,6 @@ FUN <- function(usr) { \caption{South of Bellevue \label{fig:map_entities_e}} <>= FUN(usr.map.s) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -789,7 +784,6 @@ ids <- unique(crop(r, extent(usr.map.s))) legend("topright", as.character(ids), fill=cols[ids], ncol=2, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Irrigation Entity"))) -invisible(dev.off()) @ Irrigation entities are further subdivided by the irrigation water source type; @@ -815,7 +809,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse legend("topright", levels(polys@data$Source), fill=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Source"))) -invisible(dev.off()) @ \clearpage @@ -1047,7 +1040,6 @@ points(pod.wells[ is.obs, ], pch=pchs[2], cex=pt.cexs[2], lwd=0.5, col=NA, bg=co leg <- paste(c("Unmeasured", "Measured"), "groundwater diversion") legend("topright", leg, col=NA, pt.bg=cols, pch=pchs, pt.cex=pt.cexs, pt.lwd=0.5, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ % ========================================================================= diff --git a/vignettes/sir20165080_AppendixH.Rnw b/vignettes/sir20165080_AppendixH.Rnw index c7504d9..55a5c8f 100644 --- a/vignettes/sir20165080_AppendixH.Rnw +++ b/vignettes/sir20165080_AppendixH.Rnw @@ -4,9 +4,11 @@ \documentclass[twoside]{article} -\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="wrv"))}} +\input{\Sexpr{shQuote(system.file("misc", "preamble.tex", package="inlmisc"))}} \addbibresource{\Sexpr{system.file("misc", "references.bib", package="wrv")}} +\fancyhead[LE]{\normalfont\bfseries\sffamily \thepage \quad Groundwater-Flow Model for the Wood River Valley Aquifer System, South-Central Idaho} + \renewcommand{\thefigure}{H\arabic{figure}} \renewcommand{\thetable}{H\arabic{table}} \renewcommand{\thepage}{H\arabic{page}} @@ -21,9 +23,10 @@ t0 <- Sys.time() try(knitr::opts_chunk$set(tidy=FALSE, comment="#", fig.align="center"), silent=TRUE) grDevices::pdf.options(useDingbats=FALSE) -options(preferRaster=TRUE, scipen=0, digits=2) library(wrv) -loadNamespace("xtable") +library(inlmisc) +library(raster) +options(preferRaster=TRUE, scipen=0, digits=2) # Device dimension in inches (width, height) fin.graph <- c(7.16, 7.16) @@ -326,7 +329,6 @@ legend("topright", leg, pch=21, col=col, pt.bg=bg, pt.lwd=0.25, pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") AddInsetMap(idaho, width=1, main.label=list("IDAHO", adj=c(-0.4, -4.9)), sub.label=list("Map area", adj=c(0.5, 2.5)), loc="topleft") -invisible(dev.off()) @ <>= @@ -354,7 +356,6 @@ leg <- c(paste("Geolocated driller well", no.1), legend("topright", leg, pch=pch, col=col, pt.bg=bg, pt.cex=cex, pt.lwd=0.25, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ <>= @@ -381,7 +382,6 @@ text(p.2, labels=p.2@data$id, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- c("SVWSD well", "TNC well") legend("topright", leg, pch=pch, col=col, pt.bg=col, pt.cex=cex, pt.lwd=0.25, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ \clearpage @@ -434,8 +434,6 @@ leg <- c("Rivers and streams", "Streamgage with continuous record", legend("topright", leg, pch=c(NA, 24, 24), lwd=c(1, NA, NA), col=c("#3399CC", "#A40802", "#A40802"), pt.bg=c(NA, "#A40802", "#FDFDFD"), pt.cex=0.8, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") - -invisible(dev.off()) @ % ========================================================================= @@ -602,7 +600,6 @@ text(p, labels=p@data$ret.no, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- c("Irrigation canal or pond return", "Exchange-well return") legend("topright", leg, pch=c(23, 21), lwd=NA, col=cols, pt.bg=cols, pt.cex=0.7, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ <>= @@ -665,7 +662,6 @@ text(p.div, labels=lab, col="#333333", cex=0.6, pos=pos, offset=0.3) leg <- "Stream diversion" legend("topright", leg, pch=22, lwd=NA, col="#F98C64", pt.bg="#F98C64", pt.cex=0.7, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ <>= @@ -779,7 +775,6 @@ points(sites[sites@data$SiteNo %in% ids, ], pch=24, cex=0.7, legend("topright", format(unique(reach.numbers)), lwd=1, col=unique(cols), pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", title=expression(bold("Reach"))) -invisible(dev.off()) @ <>= @@ -871,7 +866,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) @ % Big Wood River, Hailey to Stanton Crossing reach @@ -906,7 +900,6 @@ PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) legend("bottomright", c("Recharge", "Discharge"), col=col, lty=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7") -invisible(dev.off()) @ % Willow Creek reach @@ -937,7 +930,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) @ % Silver Creek above Sportsman Access reach @@ -969,7 +961,6 @@ col <- "#C80C0B" PlotGraph(d, ylab=ylab, xlim=xlim, col=col, fill=paste0(col, "66"), conversion.factor=1 / cfs.to.m3.per.d, scientific=c(FALSE, TRUE, FALSE), center.date.labels=TRUE) -invisible(dev.off()) @ % Silver Creek, Sportsman Access to near Picabo @@ -1076,8 +1067,6 @@ leg <- format(reach.numbers[order(reach.numbers)]) legend("topright", leg, lwd=1, col=cols[order(reach.numbers)], ncol=2, pt.cex=1, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", title=expression(bold("Subreach"))) - -invisible(dev.off()) @ <>= @@ -1318,9 +1307,8 @@ plot(cities, pch=15, cex=0.8, col="#333333", add=TRUE) text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=3, offset=0.4) legend("topleft", leg, lwd=2, col=cols, border=NA, inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7", title=expression(bold("Outlet Boundaries"))) -AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0, -9)), - sub.label=list("Map area", adj=c(1.9, 0.5)), loc="topright") -invisible(dev.off()) +AddInsetMap(alluvium.extent, width=1, main.label=list("AQUIFER", adj=c(0.25, -9)), + sub.label=list("Map area", adj=c(1.65, 0.5)), loc="topright") @ % ========================================================================= @@ -1466,7 +1454,6 @@ FUN <- function(layer) { \caption{Model layer 3 \label{fig:map_pilot_c}} <>= FUN(3L) - invisible(dev.off()) @ \end{subfigure} \caption{---Continued} @@ -1629,7 +1616,6 @@ leg <- c("Underflow boundaries", "Aquifer extent") legend("topright", leg, pch=c(15, 22), lwd=NA, col=cols, pt.bg="#33333366", pt.cex=c(0.7, 1.5), inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, bg="#FFFFFFE7", seg.len=1.4) -invisible(dev.off()) @ % === @@ -1663,7 +1649,6 @@ text(cities, labels=cities@data$FEATURE_NA, col="#333333", cex=0.5, pos=1, offse leg <- c("Irrigation entity", "Irrigation entity with possible natural sub-irrigation") legend("topright", leg, fill=cols, border="#FFFFFFCC", inset=0.02, cex=0.7, box.lty=1, box.lwd=0.5, xpd=NA, bg="#FFFFFFE7") -invisible(dev.off()) @ % =========================================================================