Skip to content

Commit 12f7e60

Browse files
Merge branch 'develop' into quarto-ensemble-sensivity
2 parents 846dd5a + c271e36 commit 12f7e60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1292
-239
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ All notable changes are kept in this file. All changes made should be added to t
33
`Unreleased`. Once a new release is made this file will be updated to create a new `Unreleased`
44
section for the next release.
55

6-
For more information about this file see also [Keep a Changelog](http://keepachangelog.com/) .
6+
For more information about this file see also [Keep a Changelog](http://keepachangelog.com/) .
7+
8+
## Unreleased
9+
10+
### Added
11+
12+
* Add function `clip_and_save_raster_file()` for subsetting rasters to match a polygon of interest (#3537).
13+
714

815
## [1.9.0] - 2025-05-25
916

@@ -16,6 +23,9 @@ For more information about this file see also [Keep a Changelog](http://keepacha
1623
- Added automated pkgdown documentation for all PEcAn packages (@divine7022, #3482):
1724
- Compiled pages are live at https://pecanproject.github.io/package-documentation and inside Docker at `pecan.localhost/pkgdocs/`, and these are automatically updated each time a PR to the source packages is merged.
1825
- You can compile all pkgdown pages locally at any time with `make pkgdocs`.
26+
- Included all relevant carbon pools (`ROOT_BIOMASS`, `AG_BIOMASS`, `SOIL_STOCK`, `LIT_BIOMASS`) in BADM-based IC extraction; excluded non-pool variables like `SOIL_CHEM`.
27+
- Added explicit support for `LIT_BIOMASS` to fully utilize **BADM** biomass capabilities.
28+
- Added `test-IC_BADM_Utilities.R` to validate BADM initial condition extraction and processing
1929
- The ERA5 NC extraction function can now handle multi-site instead of one.
2030
- New Quarto notebook tutorial for PEcAn uncertainty analysis (`documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertainty.qmd`) (#3570)
2131
- Complete workflow demonstration for ensemble and sensitivity analysis using PEcAn's programmatic interface
@@ -24,6 +34,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
2434
- Model result visualization with run ID identification and ensemble analysis capabilities
2535
- Session information for reproducibility and clear documentation of PEcAn's uncertainty analysis outputs
2636
- Added function for merging images from the same tiling system (MODIS, GLANCE, ICESat-2, HLS, etc.).
37+
- Added function for converting images towards the GDAL-supported formats (H5, NetCDF, HDF4, GeoTIFF, etc .).
2738

2839
### Fixed
2940
- api to correctly use x_var from request in plotResults #3528
@@ -34,6 +45,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
3445
- updated github action to build docker images
3546
- PEcAn.SIPNET now accepts relative paths in its input XML (#3418). Previously all files referenced in the autogenerated `job.sh` needed to be specified as absolute paths.
3647
- R version 4.4 installs Python 3.12 which wants to leverage os managed packages instead, install python3-pika using apt.
48+
- Fixed a bugs and BADM now process both single-site and multi-site settings, detecting the input structure and processing each site independently to generate the correct number of ensemble members per site.
3749

3850
### Changed
3951

base/logger/DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: PEcAn.logger
22
Title: Logger Functions for 'PEcAn'
3-
Version: 1.8.3
3+
Version: 1.8.4
44
Authors@R: c(person("Rob", "Kooper", role = c("aut", "cre"),
55
email = "[email protected]"),
66
person("Alexey", "Shiklomanov", role = c("aut"),

base/logger/NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# PEcAn.logger 1.8.4 (unreleased)
2+
3+
- All `logger.set*` functions now invisibly return the previously set value. This can be handy for restoring settings after a temporary change.
4+
- Multipart logger messages passed in `...` now get a more robust conversion to string before concatenating, hopefully giving nicer results for nontext objects such as dates and lists.
5+
16
# PEcAn.logger 1.8.3
27

38
- Maintenance release with no user-visible changes.

base/logger/R/logger.R

Lines changed: 96 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
.utils.logger$stderr <- TRUE
55
.utils.logger$quit <- FALSE
66
.utils.logger$level <- 0
7-
.utils.logger$width <- ifelse(getOption("width") < 10,
8-
getOption("width"),
7+
.utils.logger$width <- ifelse(getOption("width") < 10,
8+
getOption("width"),
99
getOption("width") - 5)
1010

1111
##' Prints a debug message.
12-
##'
12+
##'
1313
##' This function will print a debug message.
1414
##'
1515
##' @param msg the message that should be printed.
@@ -26,7 +26,7 @@ logger.debug <- function(msg, ...) {
2626

2727

2828
##' Prints an informational message.
29-
##'
29+
##'
3030
##' This function will print an informational message.
3131
##'
3232
##' @param msg the message that should be printed.
@@ -43,7 +43,7 @@ logger.info <- function(msg, ...) {
4343

4444

4545
##' Prints a warning message.
46-
##'
46+
##'
4747
##' This function will print a warning message.
4848
##'
4949
##' @param msg the message that should be printed.
@@ -60,7 +60,7 @@ logger.warn <- function(msg, ...) {
6060

6161

6262
##' Prints an error message.
63-
##'
63+
##'
6464
##' This function will print an error message.
6565
##'
6666
##' @param msg the message that should be printed.
@@ -76,14 +76,13 @@ logger.error <- function(msg, ...) {
7676
} # logger.error
7777

7878

79-
##' Prints an severe message and stops execution.
80-
##'
79+
##' Prints a severe message and stops execution.
80+
##'
8181
##' This function will print a message and stop execution of the code. This
8282
##' should only be used if the application should terminate.
83-
##'
84-
##' set \code{\link{logger.setQuitOnSevere}(FALSE)} to avoid terminating
85-
##' the session. This is set by default to TRUE if interactive or running
86-
##' inside Rstudio.
83+
##'
84+
##' Set \code{\link{logger.setQuitOnSevere}(FALSE)} to avoid terminating
85+
##' the session. The default is to not quit if running interactively.
8786
##'
8887
##' @param msg the message that should be printed.
8988
##' @param ... any additional text that should be printed.
@@ -96,13 +95,13 @@ logger.error <- function(msg, ...) {
9695
##' }
9796
logger.severe <- function(msg, ..., wrap = TRUE) {
9897
logger.message("SEVERE", msg, ...)
99-
98+
10099
# run option
101100
error <- getOption("error")
102101
if (!is.null(error)) {
103102
eval(error)
104103
}
105-
104+
106105
# quit if not interactive, otherwise use stop
107106
if (.utils.logger$quit) {
108107
quit(save = "no", status = 1)
@@ -113,11 +112,13 @@ logger.severe <- function(msg, ..., wrap = TRUE) {
113112

114113

115114
##' Prints a message at a certain log level.
116-
##'
117-
##' This function will print a message. This is the function that is responsible for
118-
##' the actual printing of the message.
119115
##'
120-
##' This is a place holder and will be later filled in with a more complex logging set
116+
##' This function will print a message. This is the function that is responsible
117+
##' for the actual printing of the message.
118+
##'
119+
##' This is a place holder and will be later filled in with a more complex
120+
##' logging set
121+
##'
121122
##' @param level the level of the message (DEBUG, INFO, WARN, ERROR)
122123
##' @param msg the message that should be printed.
123124
##' @param ... any additional text that should be printed.
@@ -138,24 +139,28 @@ logger.message <- function(level, msg, ..., wrap = TRUE) {
138139
if (length(func) == 0) {
139140
func <- "console"
140141
}
141-
142+
142143
stamp.text <- sprintf("%s %-6s [%s] :", Sys.time(), level, func)
143-
long.msg <- stringi::stri_trans_general(paste(c(msg, ...), collapse = " "), "latin-ascii")
144+
args <- sapply(list(...), FUN = toString)
145+
long.msg <- stringi::stri_trans_general(
146+
paste(c(msg, args), collapse = " "),
147+
"latin-ascii"
148+
)
144149
if (nchar(long.msg) > 20 && wrap) {
145-
new.msg <- paste("\n", strwrap(long.msg, width = .utils.logger$width,
150+
new.msg <- paste("\n", strwrap(long.msg, width = .utils.logger$width,
146151
indent = 2, exdent = 2), collapse = " ")
147152
} else {
148153
new.msg <- long.msg
149154
}
150155
text <- paste(stamp.text, new.msg, "\n")
151-
156+
152157
if (.utils.logger$console) {
153158
if (.utils.logger$stderr) {
154159
cat(text, file = stderr())
155160
} else {
156161
cat(text, file = stdout())
157162
}
158-
163+
159164
}
160165
if (!is.na(.utils.logger$filename)) {
161166
cat(text, file = .utils.logger$filename, append = TRUE)
@@ -165,35 +170,56 @@ logger.message <- function(level, msg, ..., wrap = TRUE) {
165170

166171

167172
##' Configure logging level.
168-
##'
173+
##'
169174
##' This will configure the logger level. This allows to turn DEBUG, INFO,
170-
##' WARN and ERROR messages on and off.
175+
##' WARN, ERROR, and SEVERE messages on and off.
176+
##'
177+
##' Note that this controls _printing_ of messages and does not change other behavior.
178+
##' In particular, suppressing SEVERE by setting the level to "OFF" does not prevent
179+
##' logger.severe() from signaling an error (and terminating the program if
180+
##' `logger.setQuitOnSevere(TRUE)`).
181+
##'
182+
##' @param level the level of the message. One of "ALL", "DEBUG", "INFO", "WARN",
183+
##' "ERROR", "SEVERE", or "OFF".
171184
##'
172-
##' @param level the level of the message (ALL, DEBUG, INFO, WARN, ERROR, OFF)
173185
##' @export
174186
##' @return When logger level is set, the previous level is returned invisibly.
175187
##' This can be passed to `logger.setLevel()` to restore the previous level.
176188
##' @author Rob Kooper
177189
##' @examples
178190
##' \dontrun{
179191
##' logger.setLevel('DEBUG')
192+
##'
193+
##' # Temporarily turn logger off
194+
##' old_logger_level <- logger.setLevel("OFF")
195+
##' # code here
196+
##' logger.setLevel(old_logger_level)
180197
##' }
181198
logger.setLevel <- function(level) {
182199
original_level <- logger.getLevel()
183200
.utils.logger$level <- logger.getLevelNumber(level)
201+
184202
invisible(original_level)
185203
} # logger.setLevel
186204

187205

188206
## Given the string representation this will return the numeric value
189-
## DEBUG = 10
190-
## INFO = 20
191-
## WARN = 30
192-
## ERROR = 40
193-
## ALL = 99
194207
##
195-
##@return level the level of the message
196-
##@author Rob Kooper
208+
## Supported levels
209+
## ALL = 0
210+
## DEBUG = 10
211+
## INFO = 20
212+
## WARN = 30
213+
## ERROR = 40
214+
## SEVERE = 50
215+
## OFF = 60
216+
##
217+
## SEVERE is treated as more serious than ERROR,
218+
## and will terminate the session if `logger.setQuitOnSevere(TRUE)`
219+
## or call stop() otherwise
220+
##
221+
## @return level the level of the message
222+
## @author Rob Kooper
197223
logger.getLevelNumber <- function(level) {
198224
if (toupper(level) == "ALL") {
199225
return(0)
@@ -206,7 +232,7 @@ logger.getLevelNumber <- function(level) {
206232
} else if (toupper(level) == "ERROR") {
207233
return(40)
208234
} else if (toupper(level) == "SEVERE") {
209-
return(40)
235+
return(50)
210236
} else if (toupper(level) == "OFF") {
211237
return(60)
212238
} else {
@@ -217,10 +243,15 @@ logger.getLevelNumber <- function(level) {
217243

218244

219245
##' Get configured logging level.
246+
##'
247+
##' This will return the current level configured of the logging messages.
220248
##'
221-
##' This will return the current level configured of the logging messages
249+
##' Note that `logger.setLevel()` invisibly returns current level, so
250+
##' `logger.getLevel()` is not required to restore the level after a
251+
##' temporary change.
222252
##'
223-
##' @return level the level of the message (ALL, DEBUG, INFO, WARN, ERROR, OFF)
253+
##' @return A string giving the lowest message level that will be reported, one of
254+
##' "ALL", "DEBUG", "INFO", "WARN", "ERROR", "SEVERE", or "OFF".
224255
##' @export
225256
##' @author Rob Kooper
226257
##' @examples
@@ -247,54 +278,70 @@ logger.getLevel <- function() {
247278

248279

249280
##' Configure logging to console.
250-
##'
281+
##'
251282
##' Should the logging to be printed to the console or not.
252283
##'
253284
##' @param console set to true to print logging to console.
254-
##' @param stderr set to true (default) to use stderr instead of stdout for logging
285+
##' @param stderr set to true (default) to log to stderr instead of stdout
286+
##' @return Invisibly, a list of the previously set values of `console`
287+
##' and `stderr`. This can be used to restore the previous settings after a
288+
##' temporary change.
255289
##' @export
256290
##' @author Rob Kooper
257291
##' @examples
258292
##' \dontrun{
259293
##' logger.setUseConsole(TRUE)
260294
##' }
261295
logger.setUseConsole <- function(console, stderr = TRUE) {
296+
old <- list(console = .utils.logger$console, stderr = .utils.logger$stderr)
262297
.utils.logger$console <- console
263298
.utils.logger$stderr <- stderr
299+
300+
invisible(old)
264301
} # logger.setUseConsole
265302

266303

267304
##' Configure logging output filename.
268-
##'
305+
##'
269306
##' The name of the file where the logging information should be written to.
270307
##'
271-
##' @param filename the file to send the log messages to (or NA to not write to file)
308+
##' @param filename the file to send the log messages to
309+
##' (or NA to not write to file)
310+
##' @return Invisibly, the previously set filename.
311+
##' This can be used to restore settings after a temporary change.
272312
##' @export
273313
##' @author Rob Kooper
274314
##' @examples
275315
##' \dontrun{
276316
##' logger.setOutputFile('pecan.log')
277317
##' }
278318
logger.setOutputFile <- function(filename) {
319+
old <- .utils.logger$filename
279320
.utils.logger$filename <- filename
321+
322+
invisible(old)
280323
} # logger.setOutputFile
281324

282325

283326
##' Configure whether severe should quit.
284-
##'
285-
##' The default is for a non-interactive session to quit. Setting this to false is
286-
##' especially useful for running tests when placed in \code{inst/tests/test.<fn>.R},
287-
##' but is not passed from \code{tests/run.all.R}.
327+
##'
328+
##' The default is for a non-interactive session to quit.
329+
##' Setting this to false is especially useful for running tests.
288330
##'
289331
##' @param severeQuits should R quit on a severe error.
290332
##' @export
333+
##' @return invisibly, the previous value of `severeQuits`.
334+
##' This can be used to restore settings after a temporary change.
291335
##' @author Rob Kooper
292336
##' @examples
293337
##' \dontrun{
294338
##' logger.setQuitOnSevere(FALSE)
295339
##' }
296340
logger.setQuitOnSevere <- function(severeQuits) {
341+
old <- .utils.logger$quit
297342
.utils.logger$quit <- severeQuits
343+
344+
invisible(old)
298345
} # logger.setQuitOnSevere
299346

300347

@@ -304,12 +351,17 @@ logger.setQuitOnSevere <- function(severeQuits) {
304351
##' wrap the line when printing a message at that many chars.
305352
##'
306353
##' @param width number of chars to print before wrapping to next line.
354+
##' @return Invisibly, the previously set width.
355+
##' This can be used to restore settings after a temporary change.
307356
##' @export
308357
##' @author David LeBauer
309358
##' @examples
310359
##' \dontrun{
311360
##' logger.setWidth(70)
312361
##' }
313362
logger.setWidth <- function(width) {
363+
old <- .utils.logger$width
314364
.utils.logger$width <- width
365+
366+
invisible(old)
315367
} # logger.setWidth

base/logger/man/logger.getLevel.Rd

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)