rSFSW2
rSFSW2: A R package to create soil water balance simulation experiment
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
8 of 17 committers (47.1%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.8%) to scientific vocabulary
Keywords
Repository
rSFSW2: A R package to create soil water balance simulation experiment
Basic Info
Statistics
- Stars: 8
- Watchers: 7
- Forks: 7
- Open Issues: 89
- Releases: 67
Topics
Metadata Files
README.md
| Unix | Windows | Release | License | Coverage | Downloads |
| :---- | :---- | :---- | :---- | :---- | :---- |
|
|
|
|
|
|
rSFSW2: A R package to create soil water balance simulation experiment
Please cite the package if you publish results based on simulations carried
out with our package, see citation("rSFSW2"), and we would like to hear
about your publication.
Some other references
- Bradford, J. B., D. R. Schlaepfer, and W. K. Lauenroth. 2014. Ecohydrology of adjacent sagebrush and lodgepole pine ecosystems: The consequences of climate change and disturbance. Ecosystems 17:590-605.
- Palmquist, K.A., Schlaepfer, D.R., Bradford, J.B., and Lauenroth, W.K. 2016. Mid-latitude shrub steppe plant communities: climate change consequences for soil water resources. Ecology 97:2342-2354.
- Schlaepfer, D. R., W. K. Lauenroth, and J. B. Bradford. 2012. Ecohydrological niche of sagebrush ecosystems. Ecohydrology 5:453-466.
Obtain the source package
There are several options:
Download the package zip file via your web browser.
Use git to clone
git clone -b master --single-branch https://github.com/DrylandEcology/rSFSW2.git rSFSW2Use git to clone step by step
git clone https://github.com/DrylandEcology/rSFSW2.git rSFSW2 cd rSFSW2/ git checkout master
Installation
'rSFSW2' will compile some c code via 'Rcpp'. Your computer must be set up adequately. - If you use a Windows OS, then you need the Rtools installed that match your R version; please find further information for instance here. - If you use a macOS, then you need Xcode and its command-line tools installed; please find further information for instance here.
After you downloaded the source package, run
R CMD INSTALL rSFSW2
Or do all at once from within R:
{r}
system2(command = "git", args = "clone -b master --single-branch https://github.com/DrylandEcology/rSFSW2.git rSFSW2")
tools::Rcmd(args = paste("INSTALL rSFSW2"))
Binary package version
If you want a binary version of the 'rSFSW2' package (e.g., to distribute to someone without development tools) for a platform to which you do not have access, then you may consider using one of the cloud services (no endorsements): - r-hub offers different Linux, Windows, and mac OS flavors as targets - win-builder offers Windows OS as target
Alternatively, you may access the previous binary package version for Windows OS from our CI appveyor service if the build was successful and an artifact was generated for the binary package (this would be named 'rSWSF2_X.Y.Z.zip' with version number X.Y.Z) from here. If the latest build should have failed, then you may want to check out the 'History' tab for binaries of older versions.
Use rSFSW2 for your simulation project
Familiarize yourself with the demos and information at package?rSFSW2
as well as FAQs with vignette("rSFSW2_FAQs", package = "rSFSW2").
Setup a new simulation project: 1) Install and attach 'rSFSW2' if not already done so (Note: required version of rSOILWAT2 must already be present) 2) Create a skeleton project `setuprSFSW2projectinfrastructure(dirprj = "path/to/projectfolder") - This function will copy a default version of '1Input' and the three demo R files to your directory 3) Work your way through 'SFSW2projectcode.R', i.e., define paths and actions, and provide simulation project description in 'SFSW2projectdescriptions.R' and run settings in 'SFSW2projectsettings.R'
How to contribute
You can contribute to this project in different ways:
- Reporting issues
- Contributing code following our protocols/guidelines and sending a pull request
Code development: Tests, documentation, and code form a trinity
Code style
- Use code style that passes our
lintrunit tests which basically reflect Hadley's style recommendation. Note: we requirelintr v1.0.2.900or later. - Use 2-spaces instead of tabs and indent code hierarchically
- Note, many function and variable names are "ancient" (too long; combine snake and camel-case)
- Use code style that passes our
Updates to input files and/or demo code
- If
SOILWAT2andrSOILWAT2change theirdefaultinputs, thenrSFSW2will automatically experience these changes through functionread_SOILWAT2_DefaultInputs. This function may need to be updated accordingly to provide suitabledefaultsforrSFSW2runs. - If you change 'input files' in
data-raw/1_Input(e.g., added a new column to experimental/design treatment file) then update theR/sysdata.rdaobject by running the Rscript from terminal./data-raw/prepare_default_project_infrastructure.R. The fileR/sysdata.rdais used to setup a new simulation project. - Additionally, if 'input files' and/or 'demo code' in
demo/changes, then update the unit test 'test project'tests/test_data/TestPrj4/by running the Rscript from terminal./data-raw/update_test_project_infrastructure.Rand make any necessary additional changes by hand.
- If
Interactive code development
- Use (a copy of)
tests/test_data/TestPrj4/as basis to interact with code and a real simulation project, for instance: ```{r} library("devtools") loadall() setwd("rSFSW2/tests/testdata/TestPrj4/")
Adjust inputs if necessary and insert break points (e.g., calls to
browser()orstop()) if neededsource("SFSW2projectcode.R") # run
TestPrj4and stop where you need itDevelop/debug code
e.g., compare output with reference as if running
tests():comparetwodbOutput("../0ReferenceOutput/dbOutputTestPrj4v2.7.4.sqlite3", "4Simulation/dbOutput.sqlite3")
Clean up
TestPrj4/deletetestoutput(dir_test = ".") ``
* *Do not* commit, please: * Any changes to settings/inputs etc. in your local copy unless those changes are a feature of your coding task * Do not comment/turn-off any tests and/or checks * Print statements for local debugging purposes * Package bundles or binaries (e.g., as fromR CMD build) * Package check reports (e.g., as fromR CMD check`) * Built vignettes * etc- Use (a copy of)
Code documentation
- Read the section 'Object documentation' in Wickham's book 'R packages'
- Use roxygen2 to write inline code documentation
- Update help pages and NAMESPACE with the command
devtools::document(); note: you may need to compile dynamic libraries first withpkgbuild::compile_dll(). - Ideally, add examples to function documentation and check these examples
with the command
devtools::run_examples(). Note: "devtools" v2.0.1 mixed up the logic for "dontrun" examples (see https://github.com/r-lib/devtools/issues/2003); until this is fixed, usedevtools::run_examples(run = FALSE). - Ideally, expand and/or add vignettes.
Code tests
- Notes:
- Our code coverage is incomplete as of now at
; thus, any change may introduce bugs that may not be detected by our testing framework.
- Please be careful and considerate and strive to write tests for any new feature.
- Our tests behave differently depending on several run-time conditions:
1) Level of verbosity is determined by interactive/non-interactive status
whether or not simulations are run in parallel (non-interactive) or
sequentially (interactive),
2) Simulation runs are processed in parallel if session is
non-interactive, not on travis-ci, not on appveyor-ci, and not on CRAN
whereas they are processed sequentially if session is interactive,
on travis-ci, on appveyor-ci, or on CRAN
3) Live access to the internet is required by some unit tests, e.g.,
tests/testthat/test_netCDF_functions.Randtests/testthat/test_WeatherDB_DayMet.R4) Some unit tests are skipped if on CRAN, and/or on travis-ci, and/or on appveyor-ci, e.g.,test/testthat/test_rSFSW2_Spelling.Randtest/testthat/test_rSFSW2_CodeStylePractices.R - Test code locally during code development:
- Interactive execution and exploration
- Interactive execution of individual expectations
expect_*and/ortest_that()statements; write new expectations at the same time as writing and developing code. Run tests from an individual test file with
testthat::test_file()- You may likely need to first load the latest code version with
devtools::load_all()for R code, and withdevtools::load_all(recompile = TRUE)if your changes include C code - Most likely, this will run tests as if on CRAN (depending on your
specific setup), i.e., it will skip several of our tests:
- it is set as
NOT_CRAN="true"if run with:devtools::test()unlessNOT_CRANwas previously setdevtools::check(cran = FALSE)R CMD check *tar.gz
- it is set as
NOT_CRAN="false"(i.e, behaving as if run on CRAN) if run with:Sys.setenv(NOT_CRAN = "false"); devtools::test()devtools::check(cran = TRUE)R CMD check *tar.gz --as-cran
- it is set as
- If you don't like the output format of the tests (which differs
depending on whether you run R interactively or not, whether you run
R via RStudio or not, etc.), then chose a testthat-'reporter'
explicitly, e.g.,
testthat::test_file(reporter = SummaryReporter)
- You may likely need to first load the latest code version with
Run all tests together with
testthat::test(), but it is a waste of time and resources to re-run tests again and again during development that are not affected by your code changesCurrently defunct: Ideally, run test projects in repository rSFSW2_tools and add a new test project, if necessary due to new features.
Run the following steps locally in order to prepare a pull-request or commit that will be reviewed. Fix any problem and repeat as necessary.
1. Make sure that the anticipated version of `rSOILWAT2` is indeed
installed, e.g.,
```{r}
packageVersion("rSOILWAT2")
```
1. Make sure that the documentation is up-to-date with:
```{r}
pkgbuild::compile_dll()
devtools::document()
```
1. Run and check the code from the examples and vignettes:
```{r}
devtools::run_examples()
```
Note: "devtools" v2.0.1 mixed up the logic for "dontrun" examples (see
https://github.com/r-lib/devtools/issues/2003); until this is fixed,
use `devtools::run_examples(run = FALSE)`.
1. Run tests as if not on CRAN, in an interactive R session,
and with a sequential schedule.
```{r}
# Run in R.app, RStudio, or in an R terminal-session:
Sys.setenv(NOT_CRAN = "true")
devtools::test()
```
Notes:
- Make sure that no test is skipped. Investigate if any is skipped.
- Investigate if any warning is reported.
- This combines unit tests, documentation and code-style checks,
and integration tests (e.g., `TestPrj4`); the latter two take a
substantial amount of time to complete.
The environmental variable `RSFSW2_ALLTESTS` determines whether or not
long-running expectations/unit-tests are skipped; the default is "true",
i.e., run all expectations/unit-tests. You may decide to run tests
while temporary skipping time-intensive tests, e.g.,
- `Sys.setenv(RSFSW2_ALLTESTS = "false"); devtools::test()`
- `RSFSW2_ALLTESTS="false" R CMD check *tar.gz`
1. Run tests as if not on CRAN, in an non-interactive session,
and with a parallel schedule.
```{bash}
# Run via shell in the terminal:
R CMD INSTALL .
Rscript -e 'Sys.setenv(NOT_CRAN = "true"); devtools::test()'
```
Notes:
- Parallel workers will load the package `rSFSW2` "normally", i.e.,
from the R library path. Thus, the workers do not see the development
version. Therefore, we need to install the current version before
running tests in parallel.
You can convince yourself of this by first removing `rSFSW2` with
`remove.packages("rSFSW2")` and then run above command -- the tests
will fail with errors such as `object 'SFSW2_glovars' not found` or
`all(tp[["res"]][, "has_run"]) isn't true`.
- Make sure that the integration test (e.g., `TestPrj4`) was indeed run
in parallel (output reports on the number of workers).
1. The environmental variable `RSFSW2_SAVETESTS` determines whether or not
the otherwise invisible internal `testthat` results are saved to file
which can be useful for debugging; the default is "true" in
non-interactive mode, i.e., save results, and "false" in interactive
mode.
To set it to true, e.g.,
* `Sys.setenv(RSFSW2_SAVETESTS = "true"); devtools::test()`
* `RSFSW2_SAVETESTS="true" R CMD check *tar.gz`
To illustrate how to read in such reporter output and display
its content (note: you may need to adjust the file path):
```{r}
utres <- readRDS(file.path("rSFSW2.Rcheck", "tests", "testthat_results.rds"))
r <- ListReporter$new()
r$start_reporter()
force(utres) # print test results with `ListReporter`
r$end_reporter()
utres[[1]] # explore results of first set of tests
```
1. Run R package-level checks as if on CRAN.
```{r}
# Run in R.app, RStudio, or in an R terminal-session:
Sys.setenv(NOT_CRAN = "false")
devtools::check(cran = TRUE)
```
Notes:
- Avoid adding new `R CMD check` warnings and/or notes; see, milestone
[Clean code](https://github.com/DrylandEcology/rSFSW2/milestone/2)
__Notes__: The above steps can also be executed with different commands
and there are more combinations that could be tested. For instance, you
could use `R CMD` instead of `devtools::check`, e.g., see
[Writing R Extensions](https://cran.r-project.org/doc/manuals/R-exts.html).
As an example, R-package level checks could also be run with:
```{bash}
R CMD build . && R CMD check *tar.gz
```
Unless the build-step fails due to latex-troubles while building the
vignette and/or help pages, then maybe:
```{bash}
R CMD build --no-build-vignettes --no-manual .
R CMD check *tar.gz --ignore-vignettes --no-manual
```
You could also pass the argument `--as-cran` to `R CMD check` to simulate
checks as if on CRAN.
1. Fix any problem and repeat.
On github:
- The command-line checks which include our unit tests will be run on the continuous integration frameworks 'travis' and 'appveyor'
- Development/feature branches can only be merged into master if they pass all checks
- Ideally, each pull-request will include fully-tested changes, at least they should be as thoroughly tested as master so that overall code coverage after merging into master does not decrease.
- Please, don't use the CIs for debugging -- debug locally
We use the framework of testthat for unit testing and other tests for the package
Read the section 'Testing' in Wickham's book 'R packages' for additional information
Code of conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Funding
Work on this package has been supported by various funds managed by Dr. Bill Lauenroth (Yale University), Dr. John Bradford (USGS), and Dr. Daniel Schlaepfer.
License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Notes
Organization renamed from Burke-Lauenroth-Lab to DrylandEcology on Dec 22, 2017
All existing information should
automatically be redirected to the new name.
Contributors are encouraged, however, to update local clones to point to the new URL, i.e.,
git remote set-url origin https://github.com/DrylandEcology/rSFSW2.git
Repository renamed from SoilWatRWrapper to rSFSW2 on Feb 23, 2017
All existing information should automatically be redirected to the new name.
Contributors are encouraged, however, to update local clones to point to the new URL, i.e.,
git remote set-url origin https://github.com/DrylandEcology/rSFSW2.git
Owner
- Name: Dryland Ecology
- Login: DrylandEcology
- Kind: organization
- Repositories: 27
- Profile: https://github.com/DrylandEcology
GitHub Events
Total
- Push event: 5
Last Year
- Push event: 5
Committers
Last synced: 6 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| dschlaep | d****r@a****h | 723 |
| dschlaep | d****r@u****h | 555 |
| dschlaep | d****h@g****m | 250 |
| Ryan Murphy | r****f@g****m | 137 |
| Zachary Kramer | k****u@g****m | 73 |
| candrews | c****s@u****v | 46 |
| dschlaep | d****p@u****u | 40 |
| charlieduso | d****s@h****m | 35 |
| Alexander Reeder | a****r@b****h | 24 |
| [CaitlinA] | [****s@u****] | 22 |
| nip5 | n****5@n****u | 21 |
| BrendenBe1 | b****1@g****m | 2 |
| Ryan Murphy | r****n@A****) | 2 |
| CaitlinA | c****s@I****t | 1 |
| Kyle Taylor | k****r@g****m | 1 |
| daniel | d****p@u****m | 1 |
| kpalmqui | k****u@e****u | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 277
- Total pull requests: 113
- Average time to close issues: about 2 months
- Average time to close pull requests: 14 days
- Total issue authors: 5
- Total pull request authors: 6
- Average comments per issue: 1.34
- Average comments per pull request: 1.57
- Merged pull requests: 104
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- dschlaep (213)
- Zachary-Kramer (32)
- CaitlinA (27)
- nip5 (4)
- hrdawson (1)
Pull Request Authors
- dschlaep (90)
- CaitlinA (12)
- nip5 (3)
- Zachary-Kramer (3)
- gopherchucks (3)
- alexreeder (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- R >= 3.5.0 depends
- rSOILWAT2 >= 4.0.0 depends
- rSW2funs * depends
- rSW2utils * depends
- RSQLite >= 2.1.1 imports
- methods * imports
- raster >= 2.5.8 imports
- sp >= 1.2.3 imports
- Hmisc >= 4.0 suggests
- RCurl >= 1.95.4.8 suggests
- Rmpi >= 0.6 suggests
- SPEI >= 1.6 suggests
- covr * suggests
- daymetr >= 1.3.1 suggests
- dplyr * suggests
- fastmatch >= 1.0.4 suggests
- goodpractice * suggests
- hunspell >= 2.9 suggests
- iotools >= 0.1 suggests
- knitr * suggests
- lintr >= 2.0.0 suggests
- lubridate * suggests
- ncdf4 >= 1.15 suggests
- parallel * suggests
- pkgload * suggests
- qmap >= 1.0.4 suggests
- rgdal >= 1.1.10 suggests
- rgeos >= 0.3.19 suggests
- rmarkdown * suggests
- spelling >= 1.1 suggests
- testthat >= 2.0.0 suggests
- weathergen >= 0.1.2 suggests
- zoo * suggests