Skip to content

Commit

Permalink
Merge pull request #54 from sylvainschmitt/main
Browse files Browse the repository at this point in the history
0.1.1
  • Loading branch information
sylvainschmitt authored Sep 30, 2024
2 parents 51961a7 + b136f55 commit 30008dd
Show file tree
Hide file tree
Showing 90 changed files with 2,085 additions and 975 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ inst/figures/lidr_fig.R
inst/gsl
LICENSE.md
.covrignore
.vscode
.lintr
1 change: 0 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
matrix:
config:
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: '3.6'}
- {os: macos-latest, r: 'release'}

env:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: lint

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::lintr, local::.
needs: lint

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ config.status
simulations
supplementary.html
inst/gsl
*.las
2 changes: 2 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
linters: linters_with_defaults() # see vignette("lintr")
encoding: "UTF-8"
24 changes: 24 additions & 0 deletions .vscode/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
LD_LIBRARY_PATH=/usr/lib/R/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/default-java/lib/server
R_ARCH=
R_BROWSER=xdg-open
R_BZIPCMD=/bin/bzip2
R_DOC_DIR=/usr/share/R/doc
R_GZIPCMD=/bin/gzip -n
R_HOME=/usr/lib/R
R_INCLUDE_DIR=/usr/share/R/include
R_LIBS_SITE=/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
R_LIBS_USER=~/R/x86_64-pc-linux-gnu-library/4.1
R_PAPERSIZE=letter
R_PAPERSIZE_USER=a4
R_PDFVIEWER=/usr/bin/xdg-open
R_PLATFORM=x86_64-pc-linux-gnu
R_PRINTCMD=/usr/bin/lpr
R_RD4PDF=times,inconsolata,hyper
R_SESSION_TMPDIR=/tmp/RtmpKdLxpi
R_SHARE_DIR=/usr/share/R/share
R_STRIP_SHARED_LIB=strip --strip-unneeded
R_STRIP_STATIC_LIB=strip --strip-debug
R_SYSTEM_ABI=linux,gcc,gxx,gfortran,gfortran
R_TEXI2DVICMD=/usr/bin/texi2dvi
R_UNZIPCMD=/usr/bin/unzip
R_ZIPCMD=/usr/bin/zip
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${env:HOME}/R/x86_64-pc-linux-gnu-library/4.1/Rcpp/include",
"/usr/share/R/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
9 changes: 9 additions & 0 deletions .vscode/debug.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
env <- Sys.getenv()
envnames <- names(env)
rnames <- envnames[startsWith(envnames, "R_")]
cached_names <- rnames
ld_lib_path <- Sys.getenv("LD_LIBRARY_PATH")
if (ld_lib_path != "") {
cached_names <- c("LD_LIBRARY_PATH", rnames)
}
writeLines(paste0(cached_names, "=", env[cached_names]), ".vscode/.env")
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/usr/lib/R/bin/exec/R",
"args": [
"--vanilla",
"-e",
"devtools::test(filter = 'cpp')"
],
"stopAtEntry": false,
"envFile": "${workspaceFolder}/.vscode/.env",
"cwd": "${workspaceFolder}",
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "debug"
}
]
}
14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "debug",
"type": "shell",
"command": "Rscript ${workspaceFolder}/.vscode/debug.R",
"problemMatcher": []
}
]
}

6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rcontroll
Type: Package
Title: Individual-Based Forest Growth Simulator 'TROLL'
Version: 0.1.0
Version: 0.1.1
Authors@R: c(
person("Sylvain", "Schmitt", email="[email protected]", role=c("aut", "cre"), comment = c(ORCID = "0000-0001-7759-7106")),
person("Guillaume", "Salzet", email="[email protected]", role="aut", comment = c(ORCID = "0000-0003-4548-5673")),
Expand Down Expand Up @@ -52,6 +52,7 @@ Suggests:
rmarkdown,
testthat,
covr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Collate:
'RcppExports.R'
Expand All @@ -75,12 +76,13 @@ Collate:
'generate_lidar.R'
'generate_parameters.R'
'get_forest.trollsim.R'
'get_log.trollsim.R'
'load_stack.R'
'load_sim.trollsim.R'
'print.trollsim.R'
'rcontroll-package.R'
'rcontroll.R'
'stack.R'
'summary.trollsim.R'
'update_parameters.trollsim.R'
VignetteBuilder: knitr
Depends:
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export(generate_lidar)
export(generate_parameters)
export(get_chm)
export(get_forest)
export(get_log)
export(load_output)
export(load_sim)
export(load_stack)
export(stack)
export(troll)
Expand All @@ -21,6 +23,8 @@ exportClasses(trollstack)
exportMethods(autoplot)
exportMethods(get_chm)
exportMethods(get_forest)
exportMethods(get_log)
exportMethods(load_sim)
exportMethods(print)
exportMethods(show)
exportMethods(summary)
Expand Down
28 changes: 28 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# 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

# rcontroll 0.1.1.9002

- lidr fig

# rcontroll 0.1.1.9001

- extended documentation following review

# rcontroll 0.1.0.9065

- new stack in tmp fix & TROLLV3_output update

# rcontroll 0.1.0.9064

- improving memory usage

# rcontroll 0.1.0.9063

- fixed stack with batch foreach

# rcontroll 0.1.0.9062

- fixes after CRAN 3rd submission (see cran-comments.md)
Expand Down
33 changes: 20 additions & 13 deletions R/TROLLv3_climatedaytime12.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#' TROLL climate parameters over months
#' `TROLL` climate parameters over months
#'
#' Climate parameters used by TROLL model over months.
#' Climate parameters used by `TROLL` model over months.
#'
#' @format A data frame with 12 rows and 12 variables: \describe{
#' \item{Temperature}{temperature (degree C)}
#' \item{DaytimeMeanTemperature}{mean day temperature (degree C)}
#' \item{NightTemperature}{night temperature (degree C)}
#' \item{Rainfall}{rainfall (mm)} \item{WindSpeed}{wind speed (km/h)}
#' \item{DaytimeMeanIrradiance}{daytime mean irradiance}
#' \item{MeanIrradiance}{mean irradiance}
#' \item{SaturatedVapourPressure}{saturated vapour pressure (Pa)}
#' \item{VapourPressure}{vapour pressure (Pa)}
#' \item{VaporPressureDeficit}{vapour pressure deficit (VPD, Pa)}
#' \item{DayTimeVapourPressureDeficitVPDbasic}{daytime basic VPD (Pa)}
#' \item{DaytimeMeanVapourPressureDeficit}{daytime mean VPF (Pa)} }
#' \item{Temperature}{monthly average of temperature (degree C)}
#' \item{DaytimeMeanTemperature}{the monthly average of daytime temperature
#' (degree C, 7am-7pm)} \item{NightTemperature}{the monthly average of
#' temperature at night (degree C, 8pm-6am)} \item{Rainfall}{monthly average
#' of cumulative rainfall (cm)} \item{WindSpeed}{monthly average of wind speed
#' (m/s)} \item{DaytimeMeanIrradiance}{monthly average of cumulative solar
#' irradiance averaged over one day (W/m2, 7am-7pm)}
#' \item{MeanIrradiance}{monthly average of cumulative solar irradiance over
#' 24 hours (W/m2)} \item{SaturatedVapourPressure}{monthly average of
#' saturation vapour pressure (hPa)} \item{VapourPressure}{monthly average of
#' vapour pressur (hPa)} \item{VaporPressureDeficit}{monthly average of vapour
#' pressure deficit (VPD, hPa)}
#' \item{DayTimeVapourPressureDeficitVPDbasic}{monthly average of daytime
#' vapour pressure deficit (7am-7pm) according to basic formula (hPa)}
#' \item{DaytimeMeanVapourPressureDeficit}{monthly average of daytime vapour
#' pressure deficit (7am-7pm) according to advanced formula (hPa)} }
#'
#' @seealso [generate_climate()], [TROLLv3_daytimevar]
#'
"TROLLv3_climatedaytime12"
13 changes: 8 additions & 5 deletions R/TROLLv3_daytimevar.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#' TROLL daytime variation parameters
#' `TROLL` daytime variation parameters
#'
#' Daytime variation parameters used by TROLL models.
#' Daytime variation parameters used by `TROLL`s models.
#'
#' @format A data frame with 24 rows and 5 variables: \describe{
#' \item{starttime}{starting time} \item{endtime}{ending time}
#' \item{vardaytime_light}{daytime variation in light}
#' \item{vardaytime_vpd}{daytime variation in vapour pressure deficit}
#' \item{vardaytime_T}{daytime variation in temperature}}
#' \item{vardaytime_light}{daily variation in irradiance relative to the mean
#' value of the day} \item{vardaytime_vpd}{daily variation in vapour pressure
#' deficit relative to the mean value of the day} \item{vardaytime_T}{daily
#' variation in temperature relative to the mean value of the day}}
#'
#' @seealso [generate_climate()], [TROLLv3_climatedaytime12]
#'
"TROLLv3_daytimevar"
10 changes: 6 additions & 4 deletions R/TROLLv3_input.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#' TROLL global parameters
#' `TROLL` global parameters
#'
#' Global parameters definition used by TROLL model.
#' Global parameters definition used by `TROLL` model.
#'
#' @format A data frame with 61 rows and 3 variables: \describe{
#' \item{param}{global parameter} \item{value}{value of the parameter}
#' \item{description}{description of the parameter} }
#'
#' @seealso [generate_parameters()]
#'
"TROLLv3_input"

# TROLLv3_input <- readr::read_tsv("inst/extdata/TROLLv3_input.txt")
# usethis::use_data(TROLLv3_input, overwrite = T)
# TROLLv3_input <- readr::read_tsv("inst/extdata/TROLLv3_input.txt") # nolint
# usethis::use_data(TROLLv3_input, overwrite = T) # nolint
13 changes: 9 additions & 4 deletions R/TROLLv3_output.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#' TROLL output
#' `TROLL` output
#'
#' TROLL outputs from a 100-year simulation on a 100x100 grid with the other
#' `TROLL` outputs from a 100-year simulation on a 100x100 grid with the other
#' default parameters and using TROLLv3_species, TROLLv3_climatedaytime12, and
#' TROLLv3_daytimevar for use in tests and examples. Ecosystem level output has
#' been thinned and species output has been removed to save disk space.
#'
#' @format A trollsim object.
#' @format A [trollsim()] object.
#'
#' @seealso [TROLLv3_species()], [TROLLv3_climatedaytime12()],
#' [TROLLv3_daytimevar()], [troll()]
#'
"TROLLv3_output"

# nolint start
# data("TROLLv3_species")
# data("TROLLv3_climatedaytime12")
# data("TROLLv3_daytimevar")
# TROLLv3_output <- troll(name = "test",
# path = "/home/sylvain/Documents/ECOFOG/",
# path = "/home/sschmitt/Documents/",
# global = generate_parameters(
# rows = 100,
# cols = 100,
Expand All @@ -30,3 +34,4 @@
# forest <- TROLLv3_output@forest
# autoplot(TROLLv3_output, "temporal")
# usethis::use_data(TROLLv3_output, overwrite = T)
# nolint end
12 changes: 7 additions & 5 deletions R/TROLLv3_pointcloud.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#' TROLL lidar parameters
#' `TROLL` lidar parameters
#'
#' Lidar parameters definition used by TROLL model for lidar simulations.
#' Lidar parameters definition used by `TROLL` for lidar simulations.
#'
#' @format A data frame with 5 rows and 3 variables: \describe{
#' \item{param}{global parameter} \item{value}{value of the parameter}
#' \item{param}{lidar parameter} \item{value}{value of the parameter}
#' \item{description}{description of the parameter} }
#'
#' @seealso [generate_lidar()]
#'
"TROLLv3_pointcloud"

# TROLLv3_pointcloud <- readr::read_tsv("inst/extdata/TROLLv3_pointcloud.txt")
# usethis::use_data(TROLLv3_pointcloud, overwrite = T)
# TROLLv3_pointcloud <- readr::read_tsv("inst/extdata/TROLLv3_pointcloud.txt") # nolint
# usethis::use_data(TROLLv3_pointcloud, overwrite = T) # nolint
6 changes: 4 additions & 2 deletions R/TROLLv3_species.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' TROLL species parameters
#' `TROLL` species parameters
#'
#' Functional traits used by TROLL model for 45 species in French Guiana.
#' Functional traits used by `TROLL` model for 45 species in French Guiana.
#'
#' @format A data frame with 45 rows and 12 variables: \describe{
#' \item{s_name}{Species name genus_species} \item{s_LMA}{leaf mass per area}
Expand All @@ -10,4 +10,6 @@
#' coefficient} \item{s_regionalfreq}{regional frequency} \item{s_tlp}{Turgor
#' loss point} \item{s_drymass}{leaf dry mass} \item{s_seedmass}{seed mass} }
#'
#' @seealso [troll()], [stack()]
#'
"TROLLv3_species"
Loading

0 comments on commit 30008dd

Please sign in to comment.