-
Notifications
You must be signed in to change notification settings - Fork 6
/
print.trollsim.R
executable file
·73 lines (69 loc) · 1.75 KB
/
print.trollsim.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#' @import methods
NULL
#' Print a summary
#'
#' `print()` prints a summary of TROLL simulation or stack of simulations
#' outputs.
#'
#' @param x trollsim or trollstack.
#' @param object trollsim or trollstack.
#' @param ... unused argument.
#'
#' @return Print or show in console.
#'
#' @seealso [troll()], [stack()], [trollsim()], [trollstack()]
#'
#' @examples
#'
#' data("TROLLv3_output")
#' print(TROLLv3_output)
#'
#' @name print.trollsim
NULL
#' @export
#' @rdname print.trollsim
setMethod("print", "trollsim", function(x, ...) {
# tidyverse
iter <- NULL
cat("Object of class :", class(x)[1], "\n")
cat("Name :", x@name, "\n")
cat("Path :", x@path, "\n")
cat("In memory :", x@mem, "\n")
if (inherits(x, "trollstack")) {
cat(
"Number of simulations :",
length(unique(x@inputs$global$simulation)), "\n"
)
}
cat("Extended :", as.logical(x@parameters["_OUTPUT_extended"]), "\n")
cat("From data :", nrow(filter(x@forest, iter == 0)) > 0, "\n")
cat("Lidar simulation :", length(x@las) > 0, "\n")
cat("Random :", !as.logical(x@parameters["_NONRANDOM"]), "\n\n")
cat(
"2D discrete network: horizontal step = ",
x@parameters["NV"], "m, one tree per 1 m^2 \n"
)
cat(
"Number of sites : ", x@parameters["cols"],
"x", x@parameters["rows"], "\n"
)
cat("Number of iterations : ", x@parameters["nbiter"], "\n")
cat(
"Duration of timestep : ",
1 / x@parameters["iterperyear"] * 365, "days \n"
)
cat(
"Number of Species : ",
length(unique(x@inputs$species$s_name)), "\n\n"
)
})
#' @export
#' @rdname print.trollsim
setMethod("show", "trollsim", function(object) {
print(object)
})
#' @export
#' @rdname print.trollsim
setMethod("summary", "trollsim", function(object, ...) {
print(object)
})