cshs-cwra / cshshydrology Goto Github PK
View Code? Open in Web Editor NEWMain package
License: GNU Affero General Public License v3.0
Main package
License: GNU Affero General Public License v3.0
RC to do
License components with restrictions and base license permitting such:
AGPL-3 | file LICENSE
The license file is only needed in case of attribution requirements or
other possible restrictions.
Hence please omit it.
You write information messages to the console that cannot be easily
suppressed.
It is more R like to generate objects that can be used to extract the
information a user is interested in, and then print() that object.
Instead of print()/cat() rather use message()/warning() or
if(verbose)cat(..) (or maybe stop()) if you really have to write text to
the console.
(except for print, summary, interactive functions
\dontrun{} should only be used if the example really cannot be executed
(e.g. because of missing additional software, missing API keys, ...) by
the user. That's why wrapping examples in \dontrun{} adds the comment
("# Not run:") as a warning for the user.
Does not seem necessary in all cases.
Please unwrap the examples if they are executable in < 5 sec, or replace
\dontrun{} with \donttest{}.
Please put functions which download data in \donttest{}.
Several examples are being flagged in the check --as-cran as taking excessively long to execute
Examples with CPU (user + system) or elapsed time > 5s
user system elapsed
ch_flow_raster_trend 9.152 0.428 9.584
ch_regime_plot 8.354 0.375 8.730
ch_polar_plot 8.150 0.371 8.528
We should probably try using them with smaller data sets.
You have examples for unexported functions.
ch_decades_plot() in:
ch_decades_plot.Rd
Please either omit these examples or export the functions
Please do not modify the user's global environment or the user's home
filespace in your examples or vignettes by deleting objects
rm(list = ls())
Please write TRUE and FALSE instead of T and F. (Please don't use 'T' or
'F' as vector names.), e.g.:
man/ch_hydrograph_plot.Rd
setting value
version R version 3.4.4 (2018-03-15)
system x86_64, linux-gnu
ui RStudio (1.1.453)
language (EN)
collate en_CA.UTF-8
tz America/Regina
date 2018-06-12
Packages -------------------------------------------------------------------------------------------------------------------------------
package * version date source
base * 3.4.4 2018-03-16 local
compiler 3.4.4 2018-03-16 local
datasets * 3.4.4 2018-03-16 local
devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
graphics * 3.4.4 2018-03-16 local
grDevices * 3.4.4 2018-03-16 local
memoise 1.1.0 2017-04-21 CRAN (R 3.4.1)
methods * 3.4.4 2018-03-16 local
stats * 3.4.4 2018-03-16 local
tools 3.4.4 2018-03-16 local
utils * 3.4.4 2018-03-16 local
withr 2.1.2 2018-03-15 CRAN (R 3.4.4)
yaml 2.1.18 2018-03-08 CRAN (R 3.4.3)
There are a couple of issues:
hydrograph.plot: no visible global function definition for ‘par’
hydrograph.plot: no visible global function definition for ‘plot’
hydrograph.plot: no visible global function definition for ‘grid’
hydrograph.plot: no visible global function definition for ‘polygon’
hydrograph.plot: no visible global function definition for ‘lines’
hydrograph.plot: no visible global function definition for ‘axis’
hydrograph.plot: no visible global function definition for ‘mtext’
hydrograph.plot: no visible global function definition for ‘legend’
Undefined global functions or variables:
axis grid legend lines mtext par plot polygon
Consider adding
importFrom("graphics", "axis", "grid", "legend", "lines", "mtext",
"par", "plot", "polygon")
to your NAMESPACE file.
You can add the functions to NAMESPACE, by adding statements to hydrology-package.R
, i.e.
#' @import (timeDate)
#' @import (raster)
#' @import (Kendall)
#' @import (fields)
The functions called from other packages all need to be specified using the :: notation, specifying the name of the package, as in graphics::axis()
etc.
Please add \value to .Rd files regarding exported methods and explain
the functions results in the documentation. Please write about the
structure of the output (class) and also what the output means. (If a
function does not return a value, please document that too, e.g.
\value{No return value, called for side effects} or similar)
Missing Rd-tags:
ch_axis_doy.Rd: \value
wd <- "C:/cshshydrology/spatial_functions/working"
Also there is a commented out one in ShannonFalls_spatialhydrology vignette
# dem <- raster::raster("c:/Research/Shannon Falls/Map/cdem_dem_151108_134502_tif/cdem_dem_151108_134502.tif")
There were 15 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: replacing previous import ‘lubridate::intersect’ by ‘raster::intersect’ when loading ‘CSHShydRology’
2: replacing previous import ‘lubridate::origin’ by ‘raster::origin’ when loading ‘CSHShydRology’
3: replacing previous import ‘lubridate::union’ by ‘raster::union’ when loading ‘CSHShydRology’
4: replacing previous import ‘raster::density’ by ‘stats::density’ when loading ‘CSHShydRology’
5: replacing previous import ‘raster::weighted.mean’ by ‘stats::weighted.mean’ when loading ‘CSHShydRology’
6: replacing previous import ‘raster::predict’ by ‘stats::predict’ when loading ‘CSHShydRology’
7: replacing previous import ‘raster::aggregate’ by ‘stats::aggregate’ when loading ‘CSHShydRology’
8: replacing previous import ‘raster::quantile’ by ‘stats::quantile’ when loading ‘CSHShydRology’
9: replacing previous import ‘raster::update’ by ‘stats::update’ when loading ‘CSHShydRology’
10: replacing previous import ‘raster::tail’ by ‘utils::tail’ when loading ‘CSHShydRology’
11: replacing previous import ‘raster::stack’ by ‘utils::stack’ when loading ‘CSHShydRology’
12: replacing previous import ‘raster::unstack’ by ‘utils::unstack’ when loading ‘CSHShydRology’
13: replacing previous import ‘raster::head’ by ‘utils::head’ when loading ‘CSHShydRology’
14: replacing previous import ‘raster::image’ by ‘graphics::image’ when loading ‘CSHShydRology’
15: replacing previous import ‘raster::plot’ by ‘graphics::plot’ when loading ‘CSHShydRology’
There are a couple of ways of getting around this.
The best way is to avoid the conflicts
The library()
function has some options, including:
exclude,include.only character vector of names of objects to exclude or include in the attached frame. Only one of these arguments may be used in a call to library or require
We can use this to only include the functions that we need.
Alternatively (and this is definitely poorer style), the library()
function also has the option
warn.conflicts logical. If TRUE, warnings are printed about conflicts from attaching the new package. A conflict is a function masking a function, or a non-function masking a non-function. The default is TRUE unless specified as FALSE in the conflicts.policy option.
If we have to, we could set this to FALSE, but that's not my preference
Session info --------------------------------------------------------------------------------------------------------------------------
setting value
version R version 3.4.4 (2018-03-15)
system x86_64, linux-gnu
ui RStudio (1.1.423)
language (EN)
collate en_CA.UTF-8
tz America/Regina
date 2018-05-23
Packages ------------------------------------------------------------------------------------------------------------------------------
package * version date source
backports 1.1.2 2017-12-13 cran (@1.1.2)
base * 3.4.4 2018-03-16 local
compiler 3.4.4 2018-03-16 local
CSHShydRology * 0.0.1 2018-05-23 local
datasets * 3.4.4 2018-03-16 local
devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
evaluate 0.10.1 2017-06-24 CRAN (R 3.4.1)
graphics * 3.4.4 2018-03-16 local
grDevices * 3.4.4 2018-03-16 local
htmltools 0.3.6 2017-04-28 CRAN (R 3.4.1)
knitr 1.20 2018-02-20 CRAN (R 3.4.3)
lubridate 1.7.3 2018-02-27 CRAN (R 3.4.3)
magrittr 1.5 2014-11-22 CRAN (R 3.4.1)
memoise 1.1.0 2017-04-21 CRAN (R 3.4.1)
methods * 3.4.4 2018-03-16 local
Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4)
rmarkdown 1.9 2018-03-01 CRAN (R 3.4.3)
rprojroot 1.3-2 2018-01-03 cran (@1.3-2)
rsconnect 0.8.8 2018-03-09 CRAN (R 3.4.3)
stats * 3.4.4 2018-03-16 local
stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)
stringr 1.3.0 2018-02-19 CRAN (R 3.4.3)
tools 3.4.4 2018-03-16 local
utils * 3.4.4 2018-03-16 local
withr 2.1.2 2018-03-15 CRAN (R 3.4.4)
yaml 2.1.18 2018-03-08 CRAN (R 3.4.3)
A function to basically isolate rainfall events from precipitation data would be helpful, and has been requested for usage in groundwater event modelling in particular.
First cut of this could use some first order derivative criteria to detect a rate of change in precip to capture rise and fall in precip intensity (?). Would likely require hourly or higher resolution data
The function names in the Whitfield branch all begin with a lower-case letter, which is contradicted by the Google code standards at https://google.github.io/styleguide/Rguide.xml#identifiers:
I got the following errors when running check()
checking dependencies in R code ... WARNING
'::' or ':::' imports not declared from:
‘Graphics’ ‘Kendall’ ‘fields’ ‘raster’ ‘timeDate’
...
ocumented arguments not in \usage in documentation object 'HYDAT_list':
‘stnID’ ‘stn’
Undocumented arguments in documentation object 'doys'
‘Date’
Documented arguments not in \usage in documentation object 'doys':
‘{Date}’
Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
Please make sure that you do not change the user's options, par or
working directory. If you really have to do so within functions, please
ensure with an immediate call of on.exit() that the settings are reset
when the function is exited. e.g.:
...
oldpar <- par(no.readonly = TRUE) # code line i
on.exit(par(oldpar)) # code line i + 1
...
par(mfrow=c(2,2)) # somewhere after
...
...
old <- options() # code line i
on.exit(options(old)) # code line i+1
...
options(scipen = 999)
...
e.g.:
If you're not familiar with the function, please check ?on.exit. This
function makes it possible to restore options before exiting a function
even if the function breaks. Therefore it needs to be called immediately
after the option change within a function.
Please always make sure to reset to user's options(), working directory
or par() after you changed it in examples and vignettes and demos.
e.g.: inst/doc/hydrograph_plot.R
oldpar <- par(mgp = c(2.5, 1, 0))
...
par(oldpar)
I will appreciate if the following routine tasks performed by most hydrologists are added to the package:
-Time series gap infilling
-Flow naturalization
-Streamflow data extension
-Flow transfer to an ungauged site
-Annual and seasonal autocorrelations and cross-correlations
-ARIMA models for stochastic time series recreation, or at least AR models, both univariate and multivariate. It must have a -module for data analysis, a module for fitting a model and a module for generate series using the fitted model. ( I am sure this tools already exist in R, but the idea would be to included them in the CWRA package and linked with the Canada dataset.)
-Spatial and temporal disaggregation methods….including flow disaggregation methods
-Statistics related to storage, drought and surplus
-Scaling and standardization
Found this dead link while taking a look through the package to find areas I can clean up/contribute.
The link to the CSHS page at the end of the "What is CSHS Hydrology?" section of the README 404s.
Link is currently http://www.cwra.org/en/branches/affiliates/cshs-a
Would submit a PR but not sure where this link should actually point.
Love this function, but the catchment.shp export at the end is actually the channel data. Thankfully the catchment.tif is correct so I've been converting that to .shp.
My reproducible example is the help example (one day I"ll learn to make reprex).
Cheers
library(raster)
test_raster <- ch_volcano_raster()
dem_raster_file <- tempfile(fileext = c(".tif"))
writeRaster(test_raster, dem_raster_file, format = "GTiff")
wd <- tempdir()
pourpoint_file <- tempfile("volcano_pourpoints", fileext = ".shp")
pourpoints <- ch_volcano_pourpoints(pourpoint_file)
catchment <- ch_wbt_catchment_onestep(wd = wd, in_dem = dem_raster_file,
pp_sf = pourpoints, sink_method = "fill", threshold = 1, snap_dist = 10)
> devtools::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.2.0 (2022-04-22 ucrt)
os Windows 10 x64 (build 19045)
system x86_64, mingw32
ui RStudio
language (EN)
collate English_Canada.utf8
ctype English_Canada.utf8
tz America/Los_Angeles
date 2023-03-02
rstudio 2022.12.0+353 Elsbeth Geranium (desktop)
pandoc 2.12 @ C:\\Users\\jmorris\\ANACON~1\\Scripts\\pandoc.exe
─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.2.0)
boot 1.3-28 2021-05-03 [2] CRAN (R 4.2.0)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.2.0)
callr 3.7.3 2022-11-02 [1] CRAN (R 4.2.2)
circular 0.4-95 2022-04-26 [1] CRAN (R 4.2.2)
class 7.3-20 2022-01-16 [2] CRAN (R 4.2.0)
classInt 0.4-8 2022-09-29 [1] CRAN (R 4.2.2)
cli 3.4.1 2022-09-23 [1] CRAN (R 4.2.1)
codetools 0.2-18 2020-11-04 [2] CRAN (R 4.2.0)
colorspace 2.0-3 2022-02-21 [1] CRAN (R 4.2.0)
crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.2)
CSHShydRology * 1.3.0 2022-11-16 [1] CRAN (R 4.2.0)
DBI 1.1.3 2022-06-18 [1] CRAN (R 4.2.2)
devtools 2.4.5 2022-10-11 [1] CRAN (R 4.2.2)
digest 0.6.30 2022-10-18 [1] CRAN (R 4.2.2)
dotCall64 1.0-2 2022-10-03 [1] CRAN (R 4.2.2)
dplyr 1.0.10 2022-09-01 [1] CRAN (R 4.2.2)
e1071 1.7-12 2022-10-24 [1] CRAN (R 4.2.2)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.0)
fansi 1.0.3 2022-03-24 [1] CRAN (R 4.2.0)
farver 2.1.1 2022-07-06 [1] CRAN (R 4.2.2)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.0)
fields 14.1 2022-08-12 [1] CRAN (R 4.2.2)
fs 1.5.2 2021-12-08 [1] CRAN (R 4.2.0)
generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.2)
ggplot2 3.4.0 2022-11-04 [1] CRAN (R 4.2.2)
ggspatial 1.1.6 2022-07-08 [1] CRAN (R 4.2.2)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.2.0)
gtable 0.3.1 2022-09-01 [1] CRAN (R 4.2.2)
here * 1.0.1 2020-12-13 [1] CRAN (R 4.2.0)
htmltools 0.5.3 2022-07-18 [1] CRAN (R 4.2.2)
htmlwidgets 1.5.4 2021-09-08 [1] CRAN (R 4.2.0)
httpuv 1.6.6 2022-09-08 [1] CRAN (R 4.2.2)
httr 1.4.4 2022-08-17 [1] CRAN (R 4.2.2)
Kendall 2.2.1 2022-03-20 [1] CRAN (R 4.2.0)
KernSmooth 2.23-20 2021-05-03 [2] CRAN (R 4.2.0)
later 1.3.0 2021-08-18 [1] CRAN (R 4.2.0)
lattice 0.20-45 2021-09-22 [2] CRAN (R 4.2.0)
lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.1)
lubridate 1.9.0 2022-11-06 [1] CRAN (R 4.2.2)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0)
maps 3.4.1 2022-10-30 [1] CRAN (R 4.2.2)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.2.0)
mime 0.12 2021-09-28 [1] CRAN (R 4.2.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.2.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.0)
mvtnorm 1.1-3 2021-10-08 [1] CRAN (R 4.2.0)
pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.2)
pkgbuild 1.3.1 2021-12-20 [1] CRAN (R 4.2.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.0)
pkgload 1.3.2 2022-11-16 [1] CRAN (R 4.2.0)
plotrix 3.8-2 2021-09-08 [1] CRAN (R 4.2.0)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.0)
processx 3.8.0 2022-10-26 [1] CRAN (R 4.2.2)
profvis 0.3.7 2020-11-02 [1] CRAN (R 4.2.2)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.2.0)
proxy 0.4-27 2022-06-09 [1] CRAN (R 4.2.2)
ps 1.7.2 2022-10-26 [1] CRAN (R 4.2.2)
purrr 0.3.5 2022-10-06 [1] CRAN (R 4.2.2)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0)
raster 3.6-3 2022-09-18 [1] CRAN (R 4.2.2)
Rcpp 1.0.9 2022-07-08 [1] CRAN (R 4.2.2)
remotes 2.4.2 2021-11-30 [1] CRAN (R 4.2.1)
rgdal 1.6-2 2022-11-09 [1] CRAN (R 4.2.2)
rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.1)
rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.2.0)
rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.2)
scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.2)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0)
sf 1.0-9 2022-11-08 [1] CRAN (R 4.2.2)
shiny 1.7.3 2022-10-25 [1] CRAN (R 4.2.2)
sp 1.5-1 2022-11-07 [1] CRAN (R 4.2.2)
spam 2.9-1 2022-08-07 [1] CRAN (R 4.2.2)
stringi 1.7.8 2022-07-11 [1] CRAN (R 4.2.1)
stringr 1.4.1 2022-08-20 [1] CRAN (R 4.2.2)
terra 1.6-17 2022-09-10 [1] CRAN (R 4.2.1)
tibble 3.1.8 2022-07-22 [1] CRAN (R 4.2.2)
tidyhydat 0.5.7 2022-10-16 [1] CRAN (R 4.2.2)
tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.2.1)
timechange 0.1.1 2022-11-04 [1] CRAN (R 4.2.2)
timeDate 4021.106 2022-09-30 [1] CRAN (R 4.2.1)
units 0.8-0 2022-02-05 [1] CRAN (R 4.2.0)
urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.2.2)
usethis 2.1.6 2022-05-25 [1] CRAN (R 4.2.2)
utf8 1.2.2 2021-07-24 [1] CRAN (R 4.2.0)
vctrs 0.5.1 2022-11-16 [1] CRAN (R 4.2.2)
viridis 0.6.2 2021-10-13 [1] CRAN (R 4.2.0)
viridisLite 0.4.1 2022-08-22 [1] CRAN (R 4.2.2)
whitebox 2.2.0 2022-10-27 [1] CRAN (R 4.2.2)
withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.2.0)
[1] C:/Users/jmorris/AppData/Local/R/win-library/4.2
[2] C:/Program Files/R/R-4.2.0/library
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.