Title: | Interface to the 'Java Newhall Simulation Model' (jNSM) "A Traditional Soil Climate Simulation Model" |
---|---|
Description: | Provides methods to create input, read output, and run the routines from the legacy Java Newhall Simulation Model (jNSM) for soil climate. Currently this package uses a modified version of the jNSM v1.6.1 which is available for download here: <https://www.nrcs.usda.gov/wps/portal/nrcs/detail/?cid=nrcs142p2_053559> and the source code found here <https://github.com/drww/newhall/>. 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) which is a core dependency in this package. Several more recent modifications to the Newhall JAR file allow for higher throughput and more efficient batching of many simulations allowing for larger-than-memory raster-based inputs and outputs. |
Authors: | Soil and Plant Science Division Staff |
Maintainer: | Andrew G. Brown <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 0.3.1 |
Built: | 2024-11-19 06:12:45 UTC |
Source: | https://github.com/ncss-tech/jNSMR |
Create an instance of BASICSimulationModel
BASICSimulationModel()
BASICSimulationModel()
an instance of BASICSimulationModel class
Create an instance of CSVFileParser
CSVFileParser(pathname)
CSVFileParser(pathname)
pathname |
character containing |
an instance of CSVFileParser class
Create an instance of CSVResultsExporter
CSVResultsExporter(results, pathname)
CSVResultsExporter(results, pathname)
results |
NewhallResults |
pathname |
a character containing pathname |
an instance of CSVResultsExporter class
newhall_batch()
provides an interface to multiple runs of the jNSM BASICSimulationModel()
for the CSV batch file input format used in jNSM 1.6.0, plus the SpatRaster
and RasterStack
R object types.
newhall_batch(<character>)
- one or more paths to jNSM Comma-Separated Value '.csv' batch files; see details for required column names
newhall_batch(<SpatRaster>)
- a SpatRaster
object, containing the required column names as layers
newhall_batch(<RasterStack>)
- a RasterStack
object, containing the required column names as layers
## Default S3 method: newhall_batch( .data = NULL, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = NULL, core_thresh = NULL, file = NULL, nrows = NULL, overwrite = NULL ) newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = nrow(.data), overwrite = TRUE ) ## S3 method for class 'character' newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = nrow(.data), overwrite = TRUE ) ## S3 method for class 'SpatRaster' newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = FALSE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = nrow(.data)/(terra::ncell(.data)/core_thresh), overwrite = TRUE ) ## S3 method for class 'RasterBrick' newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = ifelse(ncol(.data) * nrow(.data) < core_thresh, nrow(.data), floor(ncol(.data) * nrow(.data)/(core_thresh * cores))), overwrite = TRUE ) ## S3 method for class 'RasterStack' newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = ifelse(ncol(.data) * nrow(.data) < core_thresh, nrow(.data), floor(ncol(.data) * nrow(.data)/(core_thresh * cores))), overwrite = TRUE )
## Default S3 method: newhall_batch( .data = NULL, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = NULL, core_thresh = NULL, file = NULL, nrows = NULL, overwrite = NULL ) newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = nrow(.data), overwrite = TRUE ) ## S3 method for class 'character' newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = nrow(.data), overwrite = TRUE ) ## S3 method for class 'SpatRaster' newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = FALSE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = nrow(.data)/(terra::ncell(.data)/core_thresh), overwrite = TRUE ) ## S3 method for class 'RasterBrick' newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = ifelse(ncol(.data) * nrow(.data) < core_thresh, nrow(.data), floor(ncol(.data) * nrow(.data)/(core_thresh * cores))), overwrite = TRUE ) ## S3 method for class 'RasterStack' newhall_batch( .data, unitSystem = "metric", soilAirOffset = ifelse(unitSystem %in% c("in", "english"), 4.5, 2.5), amplitude = 0.66, hasOHorizon = FALSE, isSaturated = FALSE, verbose = TRUE, toString = TRUE, checkargs = TRUE, cores = 1, core_thresh = 25000L, file = paste0(tempfile(), ".tif"), nrows = ifelse(ncol(.data) * nrow(.data) < core_thresh, nrow(.data), floor(ncol(.data) * nrow(.data)/(core_thresh * cores))), overwrite = TRUE )
.data |
a data.frame or character vector of paths to CSV files; or a SpatRaster or RasterStack containing the same data elements and names as included in the batch |
unitSystem |
Default: |
soilAirOffset |
air-soil temperature offset. Conventionally for jNSM: |
amplitude |
difference in amplitude between soil and air temperature sine waves. Default |
hasOHorizon |
Used for cryic soil temperature regime criteria. Default: |
isSaturated |
Used for cryic soil temperature regime and aquic soil moisture regime mask. Default: |
verbose |
print message about number of simulations and elapsed time |
toString |
call |
checkargs |
logical; check argument length and data types for each run? Default: |
cores |
integer. Number of cores; used only for processing SpatRaster or Raster* input. Default: |
core_thresh |
integer. Approximate number of cells to target per core and batch; used to calculate default value for |
file |
character. Path to write incremental raster processing output for large inputs that do not fit in memory; passed to |
nrows |
integer. Number of rows to use per block; passed to |
overwrite |
logical. Overwrite |
The main inputs to the model are monthly precipitation and air temperature for each site, the location, the soil available water storage, and the elevation.
The following columns and names are required in the input data/object:
Latitude and Longitude in WGS84 Decimal Degrees: "latDD", "lonDD"
Monthly Air Temperature (degrees C or F): "tJan", "tFeb", "tMar", "tApr", "tMay", "tJun", "tJul", "tAug", "tSep", "tOct", "tNov", "tDec"
Monthly Precipitation (millimeters or inches of rain): "pJan", "pFeb", "pMar", "pApr", "pMay", "pJun", "pJul", "pAug", "pSep", "pOct", "pNov", "pDec"
Profile Available Water Storage (millimeters; Default 200
): "awc"
Elevation (meters or feet): "elev"
The concept of "dry" versus "moist" is expressed semi-quantitatively in the Newhall model with three different categories of moisture being recognized: "moist", "moist/dry" and "dry."
Of interest to the classification of climate regimes of a soil are not only when/where the soil is dry but how that moisture or lack thereof corresponds with prevailing temperature conditions.
"annualRainfall"
- sum of monthly precipitation values over the year
"waterHoldingCapacity"
- total water storage of soil profile in units of length (mm
). Default: 200
millimeters (8 inches) of water storage. This is approximately the average water storage when calculated using SSURGO available water capacities and depths for the soils in CONUS.
"annualWaterBalance"
- sum of difference of precipitation and estimated mean potential evapotranspiration (Thornthwaite, 1948) by month
"annualPotentialEvapotranspiration"
- sum of mean monthly potential evapotranspiration (Thornthwaite, 1948)
"summerWaterBalance"
- sum of (summer months only) difference of precipitation and estimated mean potential evapotranspiration by month
"dryDaysAfterSummerSolstice"
- number of days "dry" after June 21; used in definition of Xeric moisture regime
"moistDaysAfterWinterSolstice"
- number of days "moist" after December 21; used in definition of Xeric moisture regime
"numCumulativeDaysDry"
- cumulative number of "dry" days per year
"numCumulativeDaysMoistDry"
- cumulative number of days "intermediate between moist and dry" per year
"numCumulativeDaysMoist"
- cumulative number of days "moist" per year
"numCumulativeDaysDryOver5C"
- cumulative number of days "dry" per year when the soil temperature is over 5 degrees C
"numCumulativeDaysMoistDryOver5C"
- cumulative number of days "intermediate between moist and dry" per year when the soil temperature is over 5 degrees C
"numCumulativeDaysMoistOver5C"
- cumulative number of days "moist" per year when the soil temperature is over 5 degrees C
"numConsecutiveDaysMoistInSomeParts"
- maximum number of consecutive days per year where some parts of the profile are "moist"
"numConsecutiveDaysMoistInSomePartsOver8C"
- maximum number of consecutive days per year where some parts of the profile are "moist" and the soil temperature is over 8 degrees C
"temperatureRegime"
- estimated Soil Temperature Regime; one of "Pergelic", "Cryic", "Frigid", "Mesic", "Thermic", "Hyperthermic", "Isofrigid", "Isomesic", "Isothermic", or "Isohyperthermic"
"moistureRegime"
- estimated Soil Moisture Regime; one of "Aridic", "Ustic", "Xeric", "Udic", "Perudic", or "Undefined"
"regimeSubdivision1"
- estimated "Moisture Regime Subdivision #1"; one of "Typic", "Weak", "Wet", "Dry", "Extreme", "Xeric", "Udic", "Aridic", or " " (See van Wambecke et al., 1981)
"regimeSubdivision2"
- estimated "Moisture Regime subdivision #2"; one of "Aridic", "Tempustic", "Tropustic", "Tempudic", "Xeric", "Udic", "Tropudic", "Undefined", or " " (See van Wambecke et al., 1981)
"Years" are based on uniform 12 months with 30 days each for a total of 360 days (no leap years).
The following elements have a many:1 relationship with model runs and are not (yet) included in the standard output, but can be accessed using an rJava object reference to a NewhallResults
class.
"meanPotentialEvapotranspiration"
- estimated mean monthly potential evapotranspiration (Thornthwaite, 1948)
"temperatureCalendar"
- compressed (360 day) grid "calendar" showing days above 5 and 8 degrees C
"moistureCalendar"
- compressed (360 day) grid "calendar" showing "moist", "moist/dry" and "dry" days.
When input is a data.frame or character vector of paths to CSV files, result is a a data.frame with key model outputs (see details) containing list columns with Java Objects for NewhallDataset, NewhallResults. If toString=TRUE
the column output
is a character containing the toString()
output from NewhallResults
For SpatRaster
input returns a SpatRaster
containing numeric and categorical model outputs. RasterBrick
inputs are first converted to SpatRaster
, and a SpatRaster
is returned
van Wambeke, A. and Newhall, F. and United States Soil Management Support Services (1981) Calculated Soil Moisture and Temperature Regimes of South America: A Compilation of Soil Climatic Regimes calculated by using a mathematical model developed by F. Newhall (Soil Conservation Service, USDA, 1972). SMSS : Technical Monograph : Soil management support services. New York State College of Agriculture and Life Sciences, Cornell University, Department of Agronomy. Available online: https://books.google.com/books?id=jwtIAAAAYAAJ
Thornthwaite, C. W. (1948). An Approach toward a Rational Classification of Climate. Geographical Review, 38(1), 55–94. https://doi.org/10.2307/210739
Newhall, F., Berdanier, C. (1996) Calculation of soil moisture regimes from the climatic record. National Soil Survey Center, Natural Resources Conservation Service, U.S. Dept. of Agriculture. Available online: https://www.nrcs.usda.gov/Internet/FSE_DOCUMENTS/nrcs142p2_052248.pdf
BASICSimulationModel()
: create an instance of the Java Newhall Simulation Model
newhall_simulation()
: run a single Newhall model instance, return NewhallResults
object
library(terra) x <- terra::rast(system.file("extdata", "prism_issr800_sample.tif", package="jNSMR")) ## optional: make larger extent (requires full cache) # x <- c(newhall_prism_extent(ext(x) * 4), newhall_issr800_extent(ext(x) * 4)) x$elev <- 0 # elevation is not currently used by the model directly # reduce resolution (for fast example) x2 <- aggregate(x, 10, na.rm = TRUE) # calculate winter, summer and annual average temperatures d <- as.data.frame(x2) x2$mwst <- rowMeans(d[, c("tDec","tJan","tFeb")]) x2$msst <- rowMeans(d[, c("tJun","tJul","tAug")]) x2$mast <- rowMeans(d[, paste0("t", month.abb)]) x2$dif <- x2$msst - x2$mwst plot(x2$dif) ## 1/10th resolution system.time({ y <- newhall_batch(x2) }) ## ~1/3 resolution # system.time({ y <- newhall_batch(aggregate(x, 3)) }) ## full resolution # system.time({ y <- newhall_batch(x) }) par(mfrow=c(2, 1)) terra::plot(y$annualWaterBalance, main = "Annual Water Balance (P-PET)") terra::plot(y$waterHoldingCapacity, 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))
library(terra) x <- terra::rast(system.file("extdata", "prism_issr800_sample.tif", package="jNSMR")) ## optional: make larger extent (requires full cache) # x <- c(newhall_prism_extent(ext(x) * 4), newhall_issr800_extent(ext(x) * 4)) x$elev <- 0 # elevation is not currently used by the model directly # reduce resolution (for fast example) x2 <- aggregate(x, 10, na.rm = TRUE) # calculate winter, summer and annual average temperatures d <- as.data.frame(x2) x2$mwst <- rowMeans(d[, c("tDec","tJan","tFeb")]) x2$msst <- rowMeans(d[, c("tJun","tJul","tAug")]) x2$mast <- rowMeans(d[, paste0("t", month.abb)]) x2$dif <- x2$msst - x2$mwst plot(x2$dif) ## 1/10th resolution system.time({ y <- newhall_batch(x2) }) ## ~1/3 resolution # system.time({ y <- newhall_batch(aggregate(x, 3)) }) ## full resolution # system.time({ y <- newhall_batch(x) }) par(mfrow=c(2, 1)) terra::plot(y$annualWaterBalance, main = "Annual Water Balance (P-PET)") terra::plot(y$waterHoldingCapacity, 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))
newhall_cmip6_cache()
: Uses the geodata package to download and cache data at the specified resolution.
newhall_cmip6_rast()
: Create a SpatRaster object. This object contains temperature and precipitation data for the specified data set, at the specified resolution, using the standard jNSM column naming scheme.
newhall_cmip6_subset():
Used to create a subset of the CMIP6 data corresponding to the extent of an input spatial object x
.
newhall_cmip6_cache( model, ssp, time, resolution = "10m", version = "2.1", overwrite = FALSE, CMIP6_PATH = file.path(newhall_data_dir("cache"), "CMIP6") ) newhall_cmip6_rast( model, ssp, time, resolution = "10m", version = "2.1", CMIP6_PATH = file.path(newhall_data_dir("cache"), "CMIP6"), tiffile = list.files(file.path(CMIP6_PATH, paste0("wc", version, "_", resolution)), pattern = "\\.tif$", recursive = TRUE) ) newhall_cmip6_subset( x, model, ssp, time, resolution = "10m", template = "EPSG:4326", CMIP6_PATH = file.path(newhall_data_dir("cache"), "CMIP6") )
newhall_cmip6_cache( model, ssp, time, resolution = "10m", version = "2.1", overwrite = FALSE, CMIP6_PATH = file.path(newhall_data_dir("cache"), "CMIP6") ) newhall_cmip6_rast( model, ssp, time, resolution = "10m", version = "2.1", CMIP6_PATH = file.path(newhall_data_dir("cache"), "CMIP6"), tiffile = list.files(file.path(CMIP6_PATH, paste0("wc", version, "_", resolution)), pattern = "\\.tif$", recursive = TRUE) ) newhall_cmip6_subset( x, model, ssp, time, resolution = "10m", template = "EPSG:4326", CMIP6_PATH = file.path(newhall_data_dir("cache"), "CMIP6") )
model |
character. Climate model abbrevation. One of "ACCESS-CM2", "ACCESS-ESM1-5", "AWI-CM-1-1-MR", "BCC-CSM2-MR", "CanESM5", "CanESM5-CanOE", "CMCC-ESM2", "CNRM-CM6-1", "CNRM-CM6-1-HR", "CNRM-ESM2-1", "EC-Earth3-Veg", "EC-Earth3-Veg-LR", "FIO-ESM-2-0", "GFDL-ESM4", "GISS-E2-1-G", "GISS-E2-1-H", "HadGEM3-GC31-LL", "INM-CM4-8", "INM-CM5-0", "IPSL-CM6A-LR", "MIROC-ES2L", "MIROC6", "MPI-ESM1-2-HR", "MPI-ESM1-2-LR", "MRI-ESM2-0", "UKESM1-0-LL" |
ssp |
character. A valid Shared Socio-economic Pathway code: "126", "245", "370" or "585" |
time |
character. A valid time period. One of "2021-2040", "2041-2060", or "2061-2080" |
resolution |
character. Either |
version |
character. Version number. Default: |
overwrite |
Force download of new cache files? Default: |
CMIP6_PATH |
Default: |
tiffile |
Optional: custom vector of paths to files to use to build raster. Defaults to all .TIF files in the specified cache directory and resolution. |
x |
A SpatVector, SpatRaster, SpatExtent, or any other object type suitable to use with |
template |
Template SpatRaster or target CRS specification for re-projection. Default: |
character. Vector of file paths (to CMIP6 .TIF files).
Eyring, V., Bony, S., Meehl, G. A., Senior, C. A., Stevens, B., Stouffer, R. J., and Taylor, K. E.: Overview of the Coupled Model Intercomparison Project Phase 6 (CMIP6) experimental design and organization, Geosci. Model Dev., 9, 1937-1958, doi:10.5194/gmd-9-1937-2016, 2016.
Detailed and up-to-date description of the CMIP6 experiments protocol: https://search.es-doc.org/?project=cmip6&
Export Newhall Results, Data and Metadata to CSV file with CSVResultsExporter
newhall_CSVResultsExporter(results, pathname)
newhall_CSVResultsExporter(results, pathname)
results |
NewhallResults |
pathname |
output CSV file path; default: |
a CSV file written to specified path
Returns a platform-specific user-level directory where data, configuration and cache files may be stored.
newhall_data_dir(which = c("data", "config", "cache"))
newhall_data_dir(which = c("data", "config", "cache"))
which |
One of: |
character. Directory path.
newhall_daymet_subset():
Used to create a subset of the DAYMET data corresponding to the extent of an input spatial object x
.
newhall_daymet_subset( x, start_year = 1991, end_year = 2020, force = FALSE, DAYMET_PATH = tempdir() )
newhall_daymet_subset( x, start_year = 1991, end_year = 2020, force = FALSE, DAYMET_PATH = tempdir() )
x |
A SpatVector, SpatRaster, SpatExtent, or any other object type suitable to use with |
start_year |
integer. First year in range to download |
end_year |
integer. Last year in range to download. |
force |
logical. Force download when files exist in |
DAYMET_PATH |
Default: |
A SpatRaster object
Thornton, M.M., R. Shrestha, Y. Wei, P.E. Thornton, S-C. Kao, and B.E. Wilson. 2022. Daymet: Monthly Climate Summaries on a 1-km Grid for North America, Version 4 R1. ORNL DAAC, Oak Ridge, Tennessee, USA. doi:10.3334/ORNLDAAC/2131
This function must be called interactively.
newhall_GUI(command_only = FALSE)
newhall_GUI(command_only = FALSE)
command_only |
If |
See documentation for system()
return result for limitations on line length, error conditions, etc.
If intern=TRUE
(default), the output of the command, one line per character string. 0
if successful. If the command could not be run for any reason, the value is 127 and a warning is issued.
Currently the only ISSR-800 data are only available for the contiguous (lower 48) United States. The only property cached for use in the Newhall model is the "available water holding capacity" (sum of storage for the whole profile, in millimeters). For consistency with PRISM grid the values are reprojected from "EPSG:5070"
to "EPSG:4269"
(see newhall_nad83_template()
)
newhall_issr800_subset():
Used to create a subset of the ISSR-800 soil available water storage data corresponding to the extent of an input spatial object x
.
newhall_issr800_rast()
: Create a SpatRaster object. This object contains Available Water Capacity (Storage) for at 800 meter resolution using the standard jNSM column naming scheme.
newhall_issr800_cache( ISSR800_PATH = file.path(newhall_data_dir("cache"), "SoilWeb", "800m"), template = newhall_nad83_template(), overwrite = FALSE ) newhall_issr800_subset( x, template = newhall_nad83_template(), ISSR800_PATH = file.path(newhall_data_dir("cache"), "SoilWeb", "800m") ) newhall_issr800_rast( ISSR800_PATH = file.path(newhall_data_dir("cache"), "SoilWeb", "800m"), tiffile = list.files(ISSR800_PATH, "\\.tif$", full.names = TRUE) )
newhall_issr800_cache( ISSR800_PATH = file.path(newhall_data_dir("cache"), "SoilWeb", "800m"), template = newhall_nad83_template(), overwrite = FALSE ) newhall_issr800_subset( x, template = newhall_nad83_template(), ISSR800_PATH = file.path(newhall_data_dir("cache"), "SoilWeb", "800m") ) newhall_issr800_rast( ISSR800_PATH = file.path(newhall_data_dir("cache"), "SoilWeb", "800m"), tiffile = list.files(ISSR800_PATH, "\\.tif$", full.names = TRUE) )
ISSR800_PATH |
Default: |
template |
Template SpatRaster or target CRS specification for reprojection. Default: |
overwrite |
Force download of new cache files? Default: |
x |
A SpatVector, SpatRaster, SpatExtent, or any other object type suitable to use with |
tiffile |
Optional: custom vector of paths to files to use to build raster. Defaults to all .TIF files in the specified cache directory and resolution. |
The data are stored in centimeters on the SoilWeb server. When newhall_issr800_cache()
saves the file the data are converted to millimeters, which is required for the Newhall model.
character. Path to cached water storage GeoTIFF.
Walkinshaw, Mike, A.T. O'Geen, D.E. Beaudette. "Soil Properties." California Soil Resource Lab, 1 Oct. 2022, https://casoilresource.lawr.ucdavis.edu/soil-properties/.
newhall_prism_cache()
: Uses the prism package to download and cache data at the specified resolution. At this time only monthly grids for 30 year Normals (1991-2020) are supported.
newhall_prism_rast()
: Create a SpatRaster object. This object contains temperature and precipitation data for the specified data set, at the specified resolution, using the standard jNSM column naming scheme.
newhall_prism_subset():
Used to create a subset of the PRISM data corresponding to the extent of an input spatial object x
.
newhall_nad83_template()
: Empty SpatRaster
corresponding to the lower 48 United States PRISM data/extent at the specified resolution.
newhall_prism_cache( resolution = "800m", overwrite = FALSE, PRISM_PATH = file.path(newhall_data_dir("cache"), "PRISM") ) newhall_prism_rast( resolution = "800m", PRISM_PATH = file.path(newhall_data_dir("cache"), "PRISM"), bilfile = list.files(file.path(PRISM_PATH, resolution), "\\.bil$", recursive = TRUE) ) newhall_prism_subset( x, resolution = "800m", template = newhall_nad83_template(resolution = resolution), PRISM_PATH = file.path(newhall_data_dir("cache"), "PRISM") ) newhall_nad83_template(resolution = "800m")
newhall_prism_cache( resolution = "800m", overwrite = FALSE, PRISM_PATH = file.path(newhall_data_dir("cache"), "PRISM") ) newhall_prism_rast( resolution = "800m", PRISM_PATH = file.path(newhall_data_dir("cache"), "PRISM"), bilfile = list.files(file.path(PRISM_PATH, resolution), "\\.bil$", recursive = TRUE) ) newhall_prism_subset( x, resolution = "800m", template = newhall_nad83_template(resolution = resolution), PRISM_PATH = file.path(newhall_data_dir("cache"), "PRISM") ) newhall_nad83_template(resolution = "800m")
resolution |
character. Either |
overwrite |
Force download of new cache files? Default: |
PRISM_PATH |
Default: |
bilfile |
Optional: custom vector of paths to files to use to build raster. Defaults to all .BIL files in the specified cache directory and resolution. |
x |
A SpatVector, SpatRaster, SpatExtent, or any other object type suitable to use with |
template |
Template SpatRaster or target CRS specification for re-projection. Default: |
Currently used only for matching the ISSR800 source to PRISM.
character. Vector of file paths (to PRISM .BIL files).
PRISM Climate Group, Oregon State University, https://prism.oregonstate.edu, data created 4 Feb 2014, accessed 22 Jul 2023.
newhall_issr800_cache()
newhall_issr800_rast()
newhall_issr800_rast()
newhall_nad83_template() newhall_nad83_template("4km")
newhall_nad83_template() newhall_nad83_template("4km")
Run Newhall BASICSimulationModel simulation
newhall_simulation( dataset, smcsawc = 200, soilAirOffset = 2.5, amplitude = 0.66, bsm = BASICSimulationModel(), toString = FALSE )
newhall_simulation( dataset, smcsawc = 200, soilAirOffset = 2.5, amplitude = 0.66, bsm = BASICSimulationModel(), toString = FALSE )
dataset |
a NewhallDataset |
smcsawc |
Default: |
soilAirOffset |
air-soil temperature offset. Conventionally for jNSM: |
amplitude |
Default: |
bsm |
|
toString |
logical; return NewhallResults (Default: |
NewhallResults jobjRef
Get Java Newhall JAR file version
newhall_version()
newhall_version()
This is a wrapper around accessing the public string field NSM_VERSION
stored within the main Newhall class of the JAR file.
character containing version number of Newhall JAR file
newhall_worldclim_cache()
: Uses the geodata package to download and cache data at the specified resolution.
newhall_worldclim_rast()
: Create a SpatRaster object. This object contains temperature and precipitation data for the specified data set, at the specified resolution, using the standard jNSM column naming scheme.
newhall_worldclim_subset():
Used to create a subset of the WorldClim data corresponding to the extent of an input spatial object x
.
newhall_worldclim_cache( resolution = "10m", version = "2.1", overwrite = FALSE, WORLDCLIM_PATH = file.path(newhall_data_dir("cache"), "WorldClim") ) newhall_worldclim_rast( resolution = "10m", version = "2.1", WORLDCLIM_PATH = file.path(newhall_data_dir("cache"), "WorldClim"), tiffile = list.files(file.path(WORLDCLIM_PATH, paste0("wc", version, "_", resolution)), pattern = "\\.tif$", recursive = TRUE) ) newhall_worldclim_subset( x, resolution = "10m", template = "EPSG:4326", WORLDCLIM_PATH = file.path(newhall_data_dir("cache"), "WorldClim") )
newhall_worldclim_cache( resolution = "10m", version = "2.1", overwrite = FALSE, WORLDCLIM_PATH = file.path(newhall_data_dir("cache"), "WorldClim") ) newhall_worldclim_rast( resolution = "10m", version = "2.1", WORLDCLIM_PATH = file.path(newhall_data_dir("cache"), "WorldClim"), tiffile = list.files(file.path(WORLDCLIM_PATH, paste0("wc", version, "_", resolution)), pattern = "\\.tif$", recursive = TRUE) ) newhall_worldclim_subset( x, resolution = "10m", template = "EPSG:4326", WORLDCLIM_PATH = file.path(newhall_data_dir("cache"), "WorldClim") )
resolution |
character. Either |
version |
character. Version number. Default: |
overwrite |
Force download of new cache files? Default: |
WORLDCLIM_PATH |
Default: |
tiffile |
Optional: custom vector of paths to files to use to build raster. Defaults to all .TIF files in the specified cache directory and resolution. |
x |
A SpatVector, SpatRaster, SpatExtent, or any other object type suitable to use with |
template |
Template SpatRaster or target CRS specification for re-projection. Default: |
character. Vector of file paths (to WorldClim .TIF files).
Fick, S.E. and R.J. Hijmans, 2017. WorldClim 2: new 1km spatial resolution climate surfaces for global land areas. International Journal of Climatology 37 (12): 4302-4315. https://www.worldclim.org/data/worldclim21.html
Export Newhall Results, Data and Metadata to XML file with XMLResultsExporter
newhall_XMLResultsExporter(dataset, results, pathname)
newhall_XMLResultsExporter(dataset, results, pathname)
dataset |
NewhallDataset |
results |
NewhallResults |
pathname |
output XML file path |
an XML file written to pathname
Export Newhall Results, Data and Metadata to XML string with XMLStringResultsExporter
newhall_XMLStringResultsExporter(dataset, results)
newhall_XMLStringResultsExporter(dataset, results)
dataset |
NewhallDataset |
results |
NewhallResults |
character containing XML string
Create an instance of NewhallDataset
NewhallDataset( stationName, country, latDD, lonDD, elev, allPrecipsDbl, allAirTempsDbl, pdbegin, pdend, smcsawc, checkargs = TRUE )
NewhallDataset( stationName, country, latDD, lonDD, elev, allPrecipsDbl, allAirTempsDbl, pdbegin, pdend, smcsawc, checkargs = TRUE )
stationName |
character; station name |
country |
character; country |
latDD |
double; latitude decimal degrees |
lonDD |
double; longitude decimal degrees |
elev |
double; station elevation |
allPrecipsDbl |
double; length |
allAirTempsDbl |
double; length |
pdbegin |
integer; beginning year |
pdend |
integer; ending year |
smcsawc |
double; soil moisture control section available water capacity (millimeters) |
checkargs |
logical; check argument length and data types? Default: |
an instance of NewhallDataset
input_direct <- NewhallDataset( stationName = "WILLIAMSPORT", country = "US", latDD = 41.24, lonDD = -76.92, elev = 158.0, allPrecipsDbl = c(44.2, 40.39, 113.54, 96.77, 95, 98.55, 66.04, 13.46, 54.86, 6.35, 17.53, 56.39), allAirTempsDbl = c(-2.17, 0.89, 3.72, 9.11, 16.28, 21.11, 22.83, 21.94, 19.78, 10.5, 5.33, -1.06), pdbegin = 1930, pdend = 1930, smcsawc = 200.0 )
input_direct <- NewhallDataset( stationName = "WILLIAMSPORT", country = "US", latDD = 41.24, lonDD = -76.92, elev = 158.0, allPrecipsDbl = c(44.2, 40.39, 113.54, 96.77, 95, 98.55, 66.04, 13.46, 54.86, 6.35, 17.53, 56.39), allAirTempsDbl = c(-2.17, 0.89, 3.72, 9.11, 16.28, 21.11, 22.83, 21.94, 19.78, 10.5, 5.33, -1.06), pdbegin = 1930, pdend = 1930, smcsawc = 200.0 )
Create an instance of NewhallDataset from XML or CSV file
NewhallDatasetFromPath(pathname, .parser = XMLFileParser) xml_NewhallDataset(pathname) csv_NewhallDataset(pathname)
NewhallDatasetFromPath(pathname, .parser = XMLFileParser) xml_NewhallDataset(pathname) csv_NewhallDataset(pathname)
pathname |
character containing |
.parser |
either |
Create an instance of NewhallDatasetMetadata
NewhallDatasetMetadata( stationName, stationId = character(length(stationName)), elev = numeric(length(stationName)), stationStateProvidence = character(length(stationName)), stationCountry = character(length(stationName)), mlraName = character(length(stationName)), mlraId = numeric(length(stationName)), contribFirstName = character(length(stationName)), contribLastName = character(length(stationName)), contribTitle = character(length(stationName)), contribOrg = character(length(stationName)), contribAddress = character(length(stationName)), contribCity = character(length(stationName)), contribStateProvidence = character(length(stationName)), contribPostal = character(length(stationName)), contribCountry = character(length(stationName)), contribEmail = character(length(stationName)), contribPhone = character(length(stationName)), notes = numeric(length(stationName)), runDate = rep(Sys.Date(), length(stationName)), modelVersion = rep(newhall_version(), length(stationName)), unitSystem = rep("metric", length(stationName)), soilAirOffset = rep(1.2, length(stationName)), amplitude = rep(0.66, length(stationName)), network = character(length(stationName)) )
NewhallDatasetMetadata( stationName, stationId = character(length(stationName)), elev = numeric(length(stationName)), stationStateProvidence = character(length(stationName)), stationCountry = character(length(stationName)), mlraName = character(length(stationName)), mlraId = numeric(length(stationName)), contribFirstName = character(length(stationName)), contribLastName = character(length(stationName)), contribTitle = character(length(stationName)), contribOrg = character(length(stationName)), contribAddress = character(length(stationName)), contribCity = character(length(stationName)), contribStateProvidence = character(length(stationName)), contribPostal = character(length(stationName)), contribCountry = character(length(stationName)), contribEmail = character(length(stationName)), contribPhone = character(length(stationName)), notes = numeric(length(stationName)), runDate = rep(Sys.Date(), length(stationName)), modelVersion = rep(newhall_version(), length(stationName)), unitSystem = rep("metric", length(stationName)), soilAirOffset = rep(1.2, length(stationName)), amplitude = rep(0.66, length(stationName)), network = character(length(stationName)) )
stationName |
character; station name |
stationId |
character; station ID |
elev |
double; station elevation |
stationStateProvidence |
character; station state / providence |
stationCountry |
character; station country |
mlraName |
character; Major Land Resource Area (MLRA) name |
mlraId |
integer; Major Land Resource Area ID |
contribFirstName |
character; contributor first name |
contribLastName |
character; contributor last name |
contribTitle |
character; contributor title |
contribOrg |
character; contributor organization |
contribAddress |
character; contributor address |
contribCity |
character; contributor city |
contribStateProvidence |
character; contributor state / providence |
contribPostal |
character; contributor postal code |
contribCountry |
character; contributor country |
contribEmail |
character; contributor email |
contribPhone |
character; contributor phone |
notes |
character (may have length >1); notes |
runDate |
character; run date |
modelVersion |
character; model version |
unitSystem |
character; unit system either "cm" or "in" |
soilAirOffset |
double; soil-air temperature offset |
amplitude |
double; soil-air temperature amplitude |
network |
character; network |
an instance of NewhallDatasetMetadata
This function is a simple wrapper around terra:writeRaster()
that makes it easier
to separate the individual layers of an input or output grid as separate files.
writeRasterLayers(x, output_dir = NULL, ...)
writeRasterLayers(x, output_dir = NULL, ...)
x |
character. Path to raster file(s) to split by layer. |
output_dir |
character. Default: |
... |
Additional arguments to |
New directories are created in output_dir
(or current working directory) based on each input file x
.
library(terra) x <- writeRaster(rast(list(a = rast(matrix(1)), b = rast(matrix(2)))), "test.tif") writeRasterLayers("test.tif", "test") unlink(c("test.tif", "test"), recursive=TRUE)
library(terra) x <- writeRaster(rast(list(a = rast(matrix(1)), b = rast(matrix(2)))), "test.tif") writeRasterLayers("test.tif", "test") unlink(c("test.tif", "test"), recursive=TRUE)
Create an instance of XMLFileParser
XMLFileParser(pathname)
XMLFileParser(pathname)
pathname |
character containing |
an instance of XMLFileParser class
Create an instance of XMLResultsExporter
XMLResultsExporter(pathname)
XMLResultsExporter(pathname)
pathname |
character; output path |
an instance of XMLResultsExporter class
Create an instance of XMLStringResultsExporter
XMLStringResultsExporter()
XMLStringResultsExporter()
an instance of XMLStringResultsExporter class