https://github.com/ncss-tech/jnsmr
R frontend for the Java Newhall Simulation Model (jNSM) -- "A Traditional Soil Climate Simulation Model"
https://github.com/ncss-tech/jnsmr
climate java jnsm model newhall r simulation soil
Last synced: 3 months ago
JSON representation
R frontend for the Java Newhall Simulation Model (jNSM) -- "A Traditional Soil Climate Simulation Model"
- Host: GitHub
- URL: https://github.com/ncss-tech/jnsmr
- Owner: ncss-tech
- License: bsd-3-clause
- Created: 2021-05-31T23:38:42.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-19T17:21:48.000Z (about 1 year ago)
- Last Synced: 2025-01-13T00:43:44.735Z (4 months ago)
- Topics: climate, java, jnsm, model, newhall, r, simulation, soil
- Language: Java
- Homepage: https://ncss-tech.github.io/jNSMR
- Size: 14.3 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: md_document
---[](https://github.com/ncss-tech/jNSMR/actions)
[](https://codecov.io/gh/ncss-tech/jNSMR?branch=main)
[](https://ncss-tech.github.io/jNSMR/)```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# {jNSMR}
R interface for the 'Java Newhall Simulation Model' (jNSM) -- "A Traditional Soil Climate Simulation Model"
Provides methods to create input, read output, and run the routines from the legacy Java Newhall Simulation Model (jNSM).
## Install {jNSMR}
First, install the development version of the R package. This will install the latest version of the Java Newhall model JAR (in the {jNSMR} folder of your package library).
```{r, eval = FALSE}
# install.packages('remotes')
remotes::install_github('ncss-tech/jNSMR')
```## Run batches of models
The jNSM has a defined CSV (comma-separated value) batch file format. Examples of batch inputs are included in the [official download](https://www.nrcs.usda.gov/resources/education-and-teaching-materials/java-newhall-simulation-model-jnsm). The main function for running multiple instances of the model is `newhall_batch()`.
`newhall_batch()` takes either a character vector of CSV batch file paths, a data.frame, a SpatRaster or RasterStack/Brick object as input.
### GeoTIFF/SpatRaster Input
```{r, spatraster-ex}
library(jNSMR)
library(terra)x <- terra::rast(system.file("extdata", "prism_issr800_sample.tif",
package = "jNSMR"))
x$elev <- 0 # elevation is not currently used by the model directlyy <- newhall_batch(x) ## full resolution
par(mfrow = c(1, 2))
terra::plot(y$annualWaterBalance,
cex.main = 0.9, main = "Annual Water Balance (P-PET)")
terra::plot(y$waterHoldingCapacity,
cex.main = 0.9, main = "Water Holding Capacity")terra::plot(y$temperatureRegime, main = "Temperature Regime")
terra::plot(y$moistureRegime, main = "Moisture Regime")terra::plot(y$numCumulativeDaysDryOver5C,
cex.main = 0.75, main = "# Cumulative Days Dry over 5 degrees C")
terra::plot(y$numConsecutiveDaysMoistInSomePartsOver8C,
cex.main = 0.75, main = "# Consecutive Days Moist\nin some parts over 8 degrees C")par(mfrow = c(1, 1))
```Now let's try again with 'Daymet' monthly climate data at 1 km resolution. 'Daymet' takes a different approach to prediction of temperature and precipitation so we may expect to see some differences--but ideally we have good general agreement between the two models.
```{r, spatraster-ex-daymet}
library(jNSMR)
library(terra)x2 <- terra::rast(system.file("extdata", "daymet_issr800_sample.tif",
package = "jNSMR"))
x2$elev <- 0 # elevation is not currently used by the model directlyy2 <- newhall_batch(x2) ## full resolution
par(mfrow = c(1, 2))
terra::plot(y2$annualWaterBalance, range = c(-750, 1500),
cex.main = 0.9, main = "Annual Water Balance (P-PET)")
terra::plot(y2$waterHoldingCapacity,
cex.main = 0.9, main = "Water Holding Capacity")terra::plot(y2$temperatureRegime, main = "Temperature Regime")
terra::plot(y2$moistureRegime, main = "Moisture Regime")terra::plot(y2$numCumulativeDaysDryOver5C,
cex.main = 0.75, main = "# Cumulative Days Dry over 5 degrees C")
terra::plot(y2$numConsecutiveDaysMoistInSomePartsOver8C,
cex.main = 0.75, main = "# Consecutive Days Moist\nin some parts over 8 degrees C")par(mfrow = c(1, 1))
```### CSV File Input
Selected example input files have been included in `inst/extdata` directory of this package.
```{r}
pathname <- system.file("extdata/All_PA_jNSM_Example_Batch_Metric.csv", package = "jNSMR")[1]res <- data.table::data.table(newhall_batch(pathname, toString = FALSE, verbose = FALSE))
head(res)
```## License information
**This package uses a modified version of the Newhall model v1.6.1 (released 2016/02/10) of the jNSM (official download here: https://www.nrcs.usda.gov/resources/education-and-teaching-materials/java-newhall-simulation-model-jnsm)**. The compiled JAR and source code are distributed in this R package under the "New" (3-Clause) BSD License. See _LICENSE_ for more information. Modifications to the JAR relative to legacy version facilitate higher throughput and access to additional data elements.
## System requirements
The system requirements of the extraction and installation tools (Windows .EXE archive) at the official download link may not be met on your system, but the core Java class files are stored in a platform-independent format (a Java JAR file e.g _newhall-1.6.1.jar_)--a core dependency in this package.
As long as you have a modern Java Runtime Environment (you probably do), you will be able to run jNSM with only minimal setup.