Skip to content

Commit

Permalink
rcontroll 0.1.0.9004: merging and cleaning before CRAN fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainschmitt committed Sep 30, 2024
1 parent 28c1a70 commit b136f55
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 80 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rcontroll 0.1.0.9004

- merging and cleaning before CRAN fix

# rcontroll 0.1.0.9003

- TROLL version 3.1.8 following discussion with IM, updating treefall time normalisation and carbon starvation to match TROLL4, a clean merge with main and dev will be needed
Expand Down
23 changes: 10 additions & 13 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,17 @@
#'
#' @examples
#' \dontrun{
#' trollCpp(
#' global_file = "test/test_input_global.txt",
#' climate_file = "test/test_input_climate.txt",
#' species_file = "test/test_input_species.txt",
#' day_file = "test/test_input_daily.txt",
#' lidar_file = "",
#' forest_file = "",
#' output_file = "test"
#' )
#' trollCpp(global_file = "test/test_input_global.txt",
#' climate_file = "test/test_input_climate.txt",
#' species_file = "test/test_input_species.txt",
#' day_file = "test/test_input_daily.txt",
#' lidar_file = "",
#' forest_file = "",
#' output_file = "test")
#' }
#'
#' @export
trollCpp <- function(global_file, climate_file, species_file, #nolint
day_file, lidar_file, forest_file, output_file) {
invisible(.Call(`_rcontroll_trollCpp`, global_file, climate_file,
species_file, day_file, lidar_file, forest_file, output_file))
trollCpp <- function(global_file, climate_file, species_file, day_file, lidar_file, forest_file, output_file) {
invisible(.Call(`_rcontroll_trollCpp`, global_file, climate_file, species_file, day_file, lidar_file, forest_file, output_file))
}

3 changes: 1 addition & 2 deletions R/autoplot.troll.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ setMethod("autoplot", "trollsim", function(object, # nolint
}
# prep table
tab <- mutate(tab,
iter = as.numeric(iter /
object@parameters["iterperyear"])
iter = as.numeric(iter / object@parameters["iterperyear"])
)
if (!("simulation" %in% names(tab))) {
tab$simulation <- "sim"
Expand Down
10 changes: 4 additions & 6 deletions R/generate_climate.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,8 @@ generate_climate <- function(x, y, tz,
gather(variable, value) %>%
group_by(variable) %>%
do(decompose(ts(.$value, frequency = 24),
type = "additive"
)[c("seasonal", "trend", "random")] %>%
as.data.frame()) %>%
type = "additive")[c("seasonal", "trend", "random")] %>%
as.data.frame()) %>%
group_by(variable) %>%
mutate(M = mean(trend, na.rm = TRUE)) %>%
slice(1:24) %>%
Expand Down Expand Up @@ -380,9 +379,8 @@ generate_climate <- function(x, y, tz,
gather(variable, value) %>%
group_by(variable) %>%
do(decompose(ts(.$value, frequency = 12),
type = "additive"
)[c("seasonal", "trend", "random")] %>%
as.data.frame()) %>%
type = "additive")[c("seasonal", "trend", "random")] %>%
as.data.frame()) %>%
mutate(value = (seasonal + mean(trend + random, na.rm = TRUE))) %>%
slice(1:12) %>%
select(-seasonal, -trend, -random) %>%
Expand Down
15 changes: 9 additions & 6 deletions R/update_parameters.trollsim.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ setMethod("update_parameters", "trollsim", function(sim, ...) {
V1 <- description <- newvalue <- oldvalue <- param <- value <- NULL # nolint
sim@inputs$global %>%
rename(oldvalue = value) %>%
left_join(list(...) %>%
as.data.frame() %>%
t() %>%
as.data.frame() %>%
rownames_to_column("param") %>%
rename(newvalue = V1), by = "param") %>%
left_join(
list(...) %>%
as.data.frame() %>%
t() %>%
as.data.frame() %>%
rownames_to_column("param") %>%
rename(newvalue = V1),
by = "param"
) %>%
mutate(value = ifelse(is.na(newvalue), oldvalue, newvalue)) %>%
select(param, value, description)
})
31 changes: 2 additions & 29 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,7 @@
## Resubmission

This is a resubmission. In this version I have:

* Written software names single quotes
* Omitted the redundant "Package for" at the start of the title
* Extended the description of the package in the field description to one paragraph
* Added \value to pipe.Rd, trollsim.Rd and trollstack.Rd
* Replaced \dontrun by \donttest in troll.Rd

I have not added a reference for the method because we are waiting for CRAN acceptance
before submitting it to Methods in Ecology and Evolution.
But I will add a reference as soon as a paper describing the method is accepted.

I have included all the people concerned in the Authors@R field
and included everyone as authors.
Indeed, J. Chave, I. Maréchaux and F. Fischer developed the C++ code in src,
and S. Schmitt and G. Salzet developed the R code.

\dontrun is only used for the trollCpp, load_output, load_stack and autogif functions
due to the use of external files or additional software.
But we have used \donttest in the troll and stack functions
which are executable in more than 5 seconds.

The functions in the examples and vignettes do not write to the users' folders
but only to the temporary directories.
The last chunk of the climate vignette uses the write_tsv function
but is not evaluated and is only an example for a user who would like to save the resulting climate data.

All examples and vignettes used only one core
except for the stack function example, and the lidar and workflow vignettes which use no more than two cores.
This is a resubmission. In this version I have avoided downloading gsl
at installation time following Tomas Kalibera pull request.

## Test environments

Expand Down
6 changes: 4 additions & 2 deletions inst/figures/lidr_fig.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ sim <- troll(
fake <- readLAS("inst/figures/lidar/lidar_0.las")
plot(fake, bg = "white", axis = TRUE, size = 1, legend = TRUE)
nouragues <- readLAS("inst/figures/nouragues_clipped.las")
plot(nouragues, bg = "white", axis = TRUE, size = 2,
legend = TRUE, backend = "rgl")
plot(nouragues,
bg = "white", axis = TRUE, size = 2,
legend = TRUE, backend = "rgl"
)
# currently manual capture
16 changes: 0 additions & 16 deletions tools/winlibs.R

This file was deleted.

10 changes: 4 additions & 6 deletions vignettes/climate.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ you can then convert the coordinates into the desired request format with `gsub`

```{r, eval=FALSE}
(coords <- gsub(",", "/", getbb("French Guiana",
format_out = "string", limit = 1
)))
format_out = "string", limit = 1)))
```

You need two types of product: (1) monthly averages by hour of day and (2) monthly averages at 00:00.
Expand Down Expand Up @@ -231,17 +230,16 @@ geo_lite_sf("Réserve naturelle des nouragues, 97301, Régina") %>%
leaflet() %>%
addTiles() %>%
addPolygons(data = getbb("French Guiana",
format_out = "sf_polygon",
limit = 1
)$multipolygon) %>%
format_out = "sf_polygon",
limit = 1)$multipolygon) %>%
addCircleMarkers(col = "red")
```

You can extract corresponding coordinates using `st_coordinates` from `sf`:

```{r, eval=FALSE}
(coords <- geo_lite_sf("Réserve naturelle des nouragues, 97301, Régina") %>%
st_coordinates())
st_coordinates())
```

You will also need the corresponding time zone for time correction as ERA5-land is giving us time in UTC.
Expand Down

0 comments on commit b136f55

Please sign in to comment.