Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • develop
  • feature_Level_4_exception
  • mapping-tool
  • mapping-tool-bacteria
  • mapping_add_livestock
  • master
6 results

Target

Select target project
  • glowpa/glowpa-model
1 result
Select Git revision
  • develop
  • feature_Level_4_exception
  • mapping-tool
  • mapping-tool-bacteria
  • mapping_add_livestock
  • master
6 results
Show changes
Commits on Source (7)
source("renv/activate.R")
library(rgdal)
library(sp) library(sp)
library(khroma) library(khroma)
......
...@@ -16,15 +16,6 @@ git clone https://git.wur.nl/glowpa/glowpa-model.git ...@@ -16,15 +16,6 @@ git clone https://git.wur.nl/glowpa/glowpa-model.git
git checkout mapping-tool git checkout mapping-tool
``` ```
dependencies for model:
```R
install.packages("raster","sf","sp","rgdal","logger","dplyr","tictoc","parallel","khroma")
```
additional dependencies for api:
```R
install.packages("jsonlite","plumber","rnaturalearth","rnaturalearthdata")
```
The mapping tool branch comes with the following submodules: The mapping tool branch comes with the following submodules:
* pathogenflows R package (https://git.wur.nl/glowpa/pathogenflows.git forked from https://github.com/mverbyla/pathogenflows) * pathogenflows R package (https://git.wur.nl/glowpa/pathogenflows.git forked from https://github.com/mverbyla/pathogenflows)
...@@ -36,7 +27,27 @@ git submodule update ...@@ -36,7 +27,27 @@ git submodule update
``` ```
The git repository of the submodule is now cloned in the submodule directory. Now open the GloWPa.Rproj file R studio. The git repository of the submodule is now cloned in the submodule directory. Now open the GloWPa.Rproj file R studio.
Install the folowing R packages from the R console: `devtools::install_local('./libs/pathogenflows')` We use `renv` to install the project dependencies. The required packages to run the model will be downloaded and installed from CRAN. The only exception is the pathogenflows package which will be installed from the ./libs/pathogenflows path. Make sure you have followed the previous instructions regarding the git submodules. The renv lockfile does not contain dependencies to run the plumber API.
```R
renv::restore()
```
Note that the raster package is deprecated since October 2023, but can be installed in R 4.3.3 on Windows systems.
In case you want to install the required packages without using renv. First install the following required packages from CRAN:
```R
install.packages("raster","sf","sp","logger","dplyr","tictoc","parallel","khroma","jsonlite")
```
Finally, install the pathogenflows package from the source code in the `libs/pathogenflows` directory:
```R
install.packages("./libs/pathogenflows", repos = NULL, type = "source")
```
Additional dependencies to run the Plumber API:
```R
install.packages("jsonlite","plumber","rnaturalearth","rnaturalearthdata")
```
## Updating code in submodules ## Updating code in submodules
In case anything needs to be changed in the submodule code make sure you make changes in the repository of the submodule. So: In case anything needs to be changed in the submodule code make sure you make changes in the repository of the submodule. So:
...@@ -62,11 +73,12 @@ In case anything needs to be changed in the submodule code make sure you make ch ...@@ -62,11 +73,12 @@ In case anything needs to be changed in the submodule code make sure you make ch
1. Commit code. 1. Commit code.
2. Push code. 2. Push code.
3. Go to GloWPa git 3. Go to GloWPa git
4. Update submodule: `git submodule update` 4. Go to libs/pathogenflows
5. Update the R library locally. `devtools::install_local("libs/pathogenflows/", force = T)` 5. Run `git pull`.
6. Test if everything works 6. Update the R library locally. `devtools::install_local("libs/pathogenflows/", force = T)`
7. Now the submodule reference code has been updated and needs to be committed to the GloWPa repository: `git commit -a -m "Updated submodule"` 7. Test if everything works
8. Push to origin. `git push` 8. Now the submodule reference code has been updated and needs to be committed to the GloWPa repository: `git commit -a -m "Updated submodule"`
9. Push to origin. `git push`
## Running the model ## Running the model
Set enviroment variables in local_env.R Set enviroment variables in local_env.R
......
Subproject commit bb6bf662eff9bd4fa909412462cebeddbdeea66c Subproject commit 9c9cc9da1bfa829e3c138e7f47ca1d9087db5236
# SET LOCAL SETTINGS # SET LOCAL SETTINGS
model_dir <- "/home/nauta/Data/Software/GloWPa/" model_dir <- "C:/Users/nauta008/Data/Software/glowpa_fix/glowpa-model"
model_input_dir <- "/home/nauta/Data/Projects/2020/K2P/02_Experiment/02_Runs/Run0/Input/kla_online/" model_input_dir <- "C:/Users/nauta008/Data/Data/glowpa/mapping_tool_fix"
model_output_dir <- "/home/nauta/Data/Projects/2020/K2P/02_Experiment/02_Runs/Run0/Output/" model_output_dir <- "C:/Users/nauta008/Data/Data/glowpa/mapping_tool_fix/output"
csv_sep <- ";" csv_sep <- ";"
# ---- # ----
#' This script can be used to run the model in an R or Rstudio environment using the overall_inputs file to startup the model #' This script can be used to run the model in an R or Rstudio environment using the overall_inputs file to startup the model
#' #'
rm(list = ls()) rm(list = ls())
# SET your local settings in local_env.R # SET your local settings in local_env.R
source("./Model scripts/readers.R") source("./Model scripts/readers.R")
source("./Model scripts/GloWPa.R") source("./Model scripts/GloWPa.R")
scenarios <- read.csv(file.path(model_input_dir,"overall_inputs.csv"),sep = ENV$csv_sep, stringsAsFactors = F) scenarios <- read.csv(file.path(model_input_dir,"overall_inputs.csv"),sep = ENV$csv_sep, stringsAsFactors = F)
browser() browser()
for(i in 1:dim(scenarios)[1]){ for(i in 1:dim(scenarios)[1]){
scenario <- scenarios[i,] scenario <- scenarios[i,]
# set loadings_module to 1; human_emissions if not specified # set loadings_module to 1; human_emissions if not specified
if(!"loadings_module" %in% colnames(scenario)){ if(!"loadings_module" %in% colnames(scenario)){
scenario$loadings_module <- 2 scenario$loadings_module <- 2
} }
if(!"model_input" %in% colnames(scenario)){ if(!"model_input" %in% colnames(scenario)){
scenario$model_input <- model_input_dir scenario$model_input <- model_input_dir
} }
if(!"model_output" %in% colnames(scenario)){ if(!"model_output" %in% colnames(scenario)){
scenario$model_output <- model_output_dir scenario$model_output <- model_output_dir
} }
human_data_fname <- sprintf("%s.csv",scenario$HumanData_filename) human_data_fname <- sprintf("%s.csv",scenario$HumanData_filename)
human_data <- read.csv(file.path(model_input_dir,human_data_fname), sep= ENV$csv_sep, stringsAsFactors = F) human_data <- read.csv(file.path(model_input_dir,human_data_fname), sep= ENV$csv_sep, stringsAsFactors = F)
human_data <- human_data[order(human_data$iso),] human_data <- human_data[order(human_data$iso),]
popurban_grid <- readers.read.raster(file.path(scenario$model_input,scenario$population_urban_filename)) popurban_grid <- readers.read.raster(file.path(scenario$model_input,scenario$population_urban_filename))
poprural_grid <- readers.read.raster(file.path(scenario$model_input,scenario$population_rural_filename)) poprural_grid <- readers.read.raster(file.path(scenario$model_input,scenario$population_rural_filename))
isoraster <- readers.read.raster(file.path(scenario$model_input,scenario$isoraster_filename)) isoraster <- readers.read.raster(file.path(scenario$model_input,scenario$isoraster_filename))
if(!is.na(scenario$WWTPData_filename)){ if(!is.na(scenario$WWTPData_filename)){
wwtp_inputs <- readers.read.wwtp(file.path(scenario$model_input,scenario$WWTPData_filename)) wwtp_inputs <- readers.read.wwtp(file.path(scenario$model_input,scenario$WWTPData_filename))
} }
output <- glowpa.run(scenario,human_data,isoraster,popurban_grid,poprural_grid,wwtp_inputs) output <- glowpa.run(scenario,human_data,isoraster,popurban_grid,poprural_grid,wwtp_inputs)
} }
{
"R": {
"Version": "4.3.3",
"Repositories": [
{
"Name": "CRAN",
"URL": "https://cloud.r-project.org"
}
]
},
"Packages": {
"DBI": {
"Package": "DBI",
"Version": "1.2.2",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"methods"
],
"Hash": "164809cd72e1d5160b4cb3aa57f510fe"
},
"KernSmooth": {
"Package": "KernSmooth",
"Version": "2.23-22",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"stats"
],
"Hash": "2fecebc3047322fa5930f74fae5de70f"
},
"MASS": {
"Package": "MASS",
"Version": "7.3-60.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"grDevices",
"graphics",
"methods",
"stats",
"utils"
],
"Hash": "b765b28387acc8ec9e9c1530713cb19c"
},
"R6": {
"Package": "R6",
"Version": "2.5.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R"
],
"Hash": "470851b6d5d0ac559e9d01bb352b4021"
},
"Rcpp": {
"Package": "Rcpp",
"Version": "1.0.12",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"methods",
"utils"
],
"Hash": "5ea2700d21e038ace58269ecdbeb9ec0"
},
"class": {
"Package": "class",
"Version": "7.3-22",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"MASS",
"R",
"stats",
"utils"
],
"Hash": "f91f6b29f38b8c280f2b9477787d4bb2"
},
"classInt": {
"Package": "classInt",
"Version": "0.4-10",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"KernSmooth",
"R",
"class",
"e1071",
"grDevices",
"graphics",
"stats"
],
"Hash": "f5a40793b1ae463a7ffb3902a95bf864"
},
"cli": {
"Package": "cli",
"Version": "3.6.2",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"utils"
],
"Hash": "1216ac65ac55ec0058a6f75d7ca0fd52"
},
"dplyr": {
"Package": "dplyr",
"Version": "1.1.4",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"R6",
"cli",
"generics",
"glue",
"lifecycle",
"magrittr",
"methods",
"pillar",
"rlang",
"tibble",
"tidyselect",
"utils",
"vctrs"
],
"Hash": "fedd9d00c2944ff00a0e2696ccf048ec"
},
"e1071": {
"Package": "e1071",
"Version": "1.7-14",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"class",
"grDevices",
"graphics",
"methods",
"proxy",
"stats",
"utils"
],
"Hash": "4ef372b716824753719a8a38b258442d"
},
"fansi": {
"Package": "fansi",
"Version": "1.0.6",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"grDevices",
"utils"
],
"Hash": "962174cf2aeb5b9eea581522286a911f"
},
"generics": {
"Package": "generics",
"Version": "0.1.3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"methods"
],
"Hash": "15e9634c0fcd294799e9b2e929ed1b86"
},
"glue": {
"Package": "glue",
"Version": "1.7.0",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"methods"
],
"Hash": "e0b3a53876554bd45879e596cdb10a52"
},
"jsonlite": {
"Package": "jsonlite",
"Version": "1.8.8",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"methods"
],
"Hash": "e1b9c55281c5adc4dd113652d9e26768"
},
"khroma": {
"Package": "khroma",
"Version": "1.12.0",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"grDevices",
"graphics",
"grid",
"stats",
"utils"
],
"Hash": "ecdd8d5727c62a414ceb3bb2cd315742"
},
"lattice": {
"Package": "lattice",
"Version": "0.22-5",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"grDevices",
"graphics",
"grid",
"stats",
"utils"
],
"Hash": "7c5e89f04e72d6611c77451f6331a091"
},
"lifecycle": {
"Package": "lifecycle",
"Version": "1.0.4",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"cli",
"glue",
"rlang"
],
"Hash": "b8552d117e1b808b09a832f589b79035"
},
"logger": {
"Package": "logger",
"Version": "0.3.0",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"utils"
],
"Hash": "c145edf05cc128e6ffcfa5d872c46329"
},
"magrittr": {
"Package": "magrittr",
"Version": "2.0.3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R"
],
"Hash": "7ce2733a9826b3aeb1775d56fd305472"
},
"pathogenflows": {
"Package": "pathogenflows",
"Version": "0.0.0.91",
"Source": "Local",
"RemoteType": "local",
"RemoteUrl": "./libs/pathogenflows",
"Requirements": [
"jsonlite"
],
"Hash": "6a7c431d8ecd25e14375084e012e9996"
},
"pillar": {
"Package": "pillar",
"Version": "1.9.0",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"cli",
"fansi",
"glue",
"lifecycle",
"rlang",
"utf8",
"utils",
"vctrs"
],
"Hash": "15da5a8412f317beeee6175fbc76f4bb"
},
"pkgconfig": {
"Package": "pkgconfig",
"Version": "2.0.3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"utils"
],
"Hash": "01f28d4278f15c76cddbea05899c5d6f"
},
"proxy": {
"Package": "proxy",
"Version": "0.4-27",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"stats",
"utils"
],
"Hash": "e0ef355c12942cf7a6b91a6cfaea8b3e"
},
"raster": {
"Package": "raster",
"Version": "3.6-26",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"Rcpp",
"methods",
"sp",
"terra"
],
"Hash": "7d6eda494f34a644420ac1bfd2a8023a"
},
"renv": {
"Package": "renv",
"Version": "1.0.3",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"utils"
],
"Hash": "41b847654f567341725473431dd0d5ab"
},
"rlang": {
"Package": "rlang",
"Version": "1.1.3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"utils"
],
"Hash": "42548638fae05fd9a9b5f3f437fbbbe2"
},
"s2": {
"Package": "s2",
"Version": "1.1.6",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"Rcpp",
"wk"
],
"Hash": "32f7b1a15bb01ae809022960abad5363"
},
"sf": {
"Package": "sf",
"Version": "1.0-16",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"DBI",
"R",
"Rcpp",
"classInt",
"grDevices",
"graphics",
"grid",
"magrittr",
"methods",
"s2",
"stats",
"tools",
"units",
"utils"
],
"Hash": "ad57b543f7c3fca05213ba78ff63df9b"
},
"sp": {
"Package": "sp",
"Version": "2.1-3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"grDevices",
"graphics",
"grid",
"lattice",
"methods",
"stats",
"utils"
],
"Hash": "1a0cc0cec2915700e63fd0921085cf6a"
},
"terra": {
"Package": "terra",
"Version": "1.7-71",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"Rcpp",
"methods"
],
"Hash": "e8611881ab70a4fb7a1f629b31e6fcff"
},
"tibble": {
"Package": "tibble",
"Version": "3.2.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"fansi",
"lifecycle",
"magrittr",
"methods",
"pillar",
"pkgconfig",
"rlang",
"utils",
"vctrs"
],
"Hash": "a84e2cc86d07289b3b6f5069df7a004c"
},
"tictoc": {
"Package": "tictoc",
"Version": "1.2.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"methods"
],
"Hash": "646895a33d57984ce7534249bd9adf64"
},
"tidyselect": {
"Package": "tidyselect",
"Version": "1.2.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"cli",
"glue",
"lifecycle",
"rlang",
"vctrs",
"withr"
],
"Hash": "829f27b9c4919c16b593794a6344d6c0"
},
"units": {
"Package": "units",
"Version": "0.8-5",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"Rcpp"
],
"Hash": "119d19da480e873f72241ff6962ffd83"
},
"utf8": {
"Package": "utf8",
"Version": "1.2.4",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R"
],
"Hash": "62b65c52671e6665f803ff02954446e9"
},
"vctrs": {
"Package": "vctrs",
"Version": "0.6.5",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"cli",
"glue",
"lifecycle",
"rlang"
],
"Hash": "c03fa420630029418f7e6da3667aac4a"
},
"withr": {
"Package": "withr",
"Version": "3.0.0",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"grDevices",
"graphics"
],
"Hash": "d31b6c62c10dcf11ec530ca6b0dd5d35"
},
"wk": {
"Package": "wk",
"Version": "0.9.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R"
],
"Hash": "5d4545e140e36476f35f20d0ca87963e"
}
}
}
library/
local/
cellar/
lock/
python/
sandbox/
staging/
This diff is collapsed.
{
"bioconductor.version": null,
"external.libraries": [],
"ignored.packages": [],
"package.dependency.fields": [
"Imports",
"Depends",
"LinkingTo"
],
"ppm.enabled": null,
"ppm.ignored.urls": [],
"r.version": null,
"snapshot.type": "implicit",
"use.cache": true,
"vcs.ignore.cellar": true,
"vcs.ignore.library": true,
"vcs.ignore.local": true,
"vcs.manage.ignores": true
}