Skip to content

Commit

Permalink
rosettaPTF 0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed May 28, 2024
1 parent 752b026 commit 8e81f4e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rosettaPTF
Title: R Frontend for Rosetta Pedotransfer Functions
Version: 0.1.4
Version: 0.1.5
Author: Soil and Plant Science Division Staff
Maintainer: Andrew G. Brown <andrew.g.brown@usda.gov>
Description: Access Python rosetta-soil pedotransfer functions in an R environment. Rosetta is a neural network-based model for predicting unsaturated soil hydraulic parameters from basic soil characterization data. The model predicts parameters for the van Genuchten unsaturated soil hydraulic properties model, using sand, silt, and clay, bulk density and water content. The codebase is now maintained by Dr. Todd Skaggs and other U.S. Department of Agriculture employees. This R package is intended to provide for use cases that involve many thousands of calls to the pedotransfer function. Less demanding use cases are encouraged to use the web interface or API endpoint. There are additional wrappers of the API endpoints provided by the soilDB R package `ROSETTA()` method.
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# rosettaPTF 0.1.5

* Fix check logic for whether input SpatRaster is in memory

# rosettaPTF 0.1.4

* Added arguments to `install_rosetta()`

* `system` argument for installing to user site packages with `--user` flag

* `upgrade` argument for forcing upgrade of rosetta-soil module

# rosettaPTF 0.1.3

* Fixes for recent changes in {reticulate} (>= 1.29)
Expand Down
8 changes: 4 additions & 4 deletions R/find_python.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ find_python <- function(envname = NULL,
}

if (is.null(pypath_before)) {
pypath <- try(.find_python(envname = envname, pypath = pypath_before, arcpy_path = arcpy_path))
pypath <- try(.find_python(envname = envname, pypath = pypath_before, arcpy_path = arcpy_path), silent = TRUE)

if (!inherits(pypath, 'try-error')) {
options(rosettaPTF.python_path = pypath)
Expand Down Expand Up @@ -77,7 +77,7 @@ find_python <- function(envname = NULL,
y
})
idx <- which.max(order(as.character(xxx)))
res <- try(reticulate::use_python(x$python_versions[idx]))
res <- try(reticulate::use_python(x$python_versions[idx]), silent = TRUE)
}

# otherwise find newest python installation
Expand All @@ -90,7 +90,7 @@ find_python <- function(envname = NULL,
y
})
idx <- which.max(order(as.character(xxx)))
res <- try(reticulate::use_python(x$python_versions[idx]))
res <- try(reticulate::use_python(x$python_versions[idx]), silent = TRUE)
}
}
}
Expand Down Expand Up @@ -134,6 +134,6 @@ find_python <- function(envname = NULL,
stop(res, call. = FALSE)
}

try(reticulate::py_config())
try(reticulate::py_config(), silent = TRUE)
res
}
4 changes: 2 additions & 2 deletions R/run_rosetta.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ run_rosetta.SpatRaster <- function(soildata,
nrows = nrow(soildata) / (terra::ncell(soildata) / core_thresh),
overwrite = TRUE) {

if (!terra::inMemory(soildata)) {
if (any(!terra::inMemory(soildata))) {
terra::readStart(soildata)
on.exit({
try({
Expand Down Expand Up @@ -227,7 +227,7 @@ run_rosetta.SpatRaster <- function(soildata,

# parallel within-block processing
n <- floor(length(ids) / core_thresh / cores) + 1
X <- split(blockdata, rep(seq(from = 1, to = n, each = n)))[1:length(ids)]
X <- split(blockdata, rep(seq(from = 1, to = n)))[1:length(ids)]
r <- do.call('rbind', parallel::clusterApply(cls, X, function(x) rosettaPTF::run_rosetta(x,
vars = vars,
rosetta_version = rosetta_version)))
Expand Down

0 comments on commit 8e81f4e

Please sign in to comment.