Skip to content

Commit

Permalink
se agrego paquete
Browse files Browse the repository at this point in the history
Se agrego mvtnorm en el step de camptrap_format
  • Loading branch information
biorey committed Oct 23, 2024
1 parent 608c376 commit 1a52522
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ runner.env
**/.cache
**/.config
.server
<<<<<<< Updated upstream
/output/
/scripts/00_auk_filter/input/original/
scripts/00_auk_filter_v2/input/original/
scripts/00_auk_filter_v2/input/original/
=======
>>>>>>> Stashed changes
50 changes: 50 additions & 0 deletions runners/conda-dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM condaforge/mambaforge

ADD ./r-environment.yml /data/r-environment.yml

WORKDIR /data

RUN mamba init

# Since we are using the user from the client computer to run the scripts,
# we need to create and open the permissions of a few files/directories.
RUN chmod a+w /data

COPY .condarc /.condarc
RUN chmod 777 /.condarc

# Conda cache and environments folder will be replaced by a virtual volume, but we want them to be writable by the runtime user.
# Permissions cannot be defined at mount time, hence we create empty folder with the appropriate permissions.
RUN mkdir /.cache && mkdir /.cache/conda && chmod a+w /.cache/conda
RUN mkdir /.conda && chmod a+w /.conda
RUN mkdir /r-libs-user && chmod a+w /r-libs-user
RUN mkdir /conda-env-yml && chmod a+w /conda-env-yml

# Initialize mamba when logging in with bash
RUN echo 'eval "$(conda shell.bash hook)"; source /opt/conda/etc/profile.d/mamba.sh' > /.bashrc && chmod a+x /.bashrc

# Allow to read bashrc to execute mamba init when using docker exec
# See https://stackoverflow.com/a/74017557/3519951
RUN sed -e '/[ -z "$PS1" ] && return/s/^/#/g' -i /root/.bashrc

RUN mamba env create -f /data/r-environment.yml

# Hide "error libmamba Could not open lockfile '/opt/conda/pkgs/cache/cache.lock'" when installing manually with non-root user
# That error would not prevent the correct installation, but it looked like it to the user.
RUN chmod -R 777 /opt/conda/pkgs/cache


# These packages are not in conda-forge
# ADD CRAN PACKAGES HERE
RUN bash --login -c "mamba activate rbase; R -e 'install.packages(c(\"CoordinateCleaner\", \
\"geodata\", \
\"OpenStreetMap\"\
), repos=\"https://cloud.r-project.org/\")'"



# ADD GITHUB PACKAGES HERE
RUN bash --login -c "mamba activate rbase; R -e 'devtools::install_github(\"ReseauBiodiversiteQuebec/stac-catalogue\")'"
RUN bash --login -c "mamba activate rbase; R -e 'devtools::install_github(\"connectscape/Makurhini\")'"

RUN date +"%Y-%m-%d %R" > /version.txt
34 changes: 34 additions & 0 deletions runners/r-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: rbase
channels:
- conda-forge
- r
dependencies:
- conda-build
- libgdal
- r-abind
- r-base
- r-curl
- r-devtools
- r-dismo
- r-downloader
- r-enmeval
- r-essentials
- r-gdalcubes
- r-gdalutilities
- r-gdalutils
- r-ggsci
- r-rjava
- r-jpeg
- r-landscapemetrics
- r-png
- r-rcurl
- r-rgbif
- r-rjson
- r-rredlist
- r-rstac
- r-sf
- r-stars
- r-terra
- r-tidyselect
- r-unmarked
- r-magrittr
2 changes: 1 addition & 1 deletion scripts/CamTrap_format2/CamTrap_format2.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Install necessary libraries - packages
packagesPrev<- installed.packages()[,"Package"] # Check and get a list of installed packages in this machine and R version
packagesNeed<- c("magrittr", "data.table", "terra", "raster", "sf", "pbapply", "this.path", "rjson", "tools", "unmarked", "reshape2", "Rcpp" , "RcppEigen", "RcppParallel", "RcppNumerical", "secr", "camtrapR") # Define the list of required packages to run the script
packagesNeed<- c("magrittr", "data.table", "terra", "raster", "sf", "pbapply", "this.path", "rjson", "tools", "unmarked", "reshape2", "Rcpp" , "RcppEigen", "RcppParallel", "RcppNumerical", "secr", "camtrapR", "mvtnorm") # Define the list of required packages to run the script
new.packages <- packagesNeed[!(packagesNeed %in% packagesPrev)]; if(length(new.packages)) {install.packages(new.packages, binary=T, force=T, dependencies = F, repos= "https://packagemanager.posit.co/cran/__linux__/jammy/latest")} # Check and install required packages that are not previously installed

# Load libraries
Expand Down
15 changes: 15 additions & 0 deletions scripts/SHI/scpSHI_Jetz_complete.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ v_time_steps <- seq(t_0,t_n,time_step)

#credentials
token <- Sys.getenv("IUCN_TOKEN")
<<<<<<< Updated upstream
print(token)
=======
>>>>>>> Stashed changes

#Filter source for land cover, global or colombia
# LC_source <- input$lc_source
Expand Down Expand Up @@ -205,7 +208,11 @@ print("========== Map of suitable area generated ==========")
#3.1 GFW data-------------------------------------------------------------------
#forest base map
cube_GFW_TC <-
<<<<<<< Updated upstream
load_cube(stac_path = "https://io.biodiversite-quebec.ca/stac/",
=======
load_cube(stac_path = "https://stac.geobon.org/",
>>>>>>> Stashed changes
limit = 1000,
collections = c("gfw-treecover2000"),
bbox = sf_ext_srs,
Expand All @@ -232,7 +239,11 @@ print("========== Base forest layer downloaded ==========")

# Download forest loss maps and create different layers for each year to remove from forest
cube_GFW_loss <-
<<<<<<< Updated upstream
load_cube(stac_path = "https://io.biodiversite-quebec.ca/stac/",
=======
load_cube(stac_path = "https://stac.geobon.org/",
>>>>>>> Stashed changes
limit = 1000,
collections = c("gfw-lossyear"),
bbox = sf_ext_srs,
Expand Down Expand Up @@ -262,7 +273,11 @@ if(t_0!=2000){
r_year_loss_mask_plot <- terra::classify(s_year_loss_mask[[length(l_r_year_loss)]],rcl=cbind(0,NA)) # turn 0 to NA

cube_GFW_gain <-
<<<<<<< Updated upstream
load_cube(stac_path = "https://io.biodiversite-quebec.ca/stac",
=======
load_cube(stac_path = "https://stac.geobon.org/",
>>>>>>> Stashed changes
limit = 1000,
collections = c("gfw-gain"),
bbox = sf_ext_srs,
Expand Down
15 changes: 15 additions & 0 deletions scripts/data/loadFromStac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@ outputs:
label: Weight matrix with layers
description: Weight matrix used for Bon optimization. Vector of layer linkes followed by weights.
type: text
<<<<<<< Updated upstream
=======
conda:
channels:
- r
- conda-forge
dependencies:
- libgdal
- proj
- r-proj
- r-gdalcubes
- r-rstac
- r-dplyr
- r-rcurl
>>>>>>> Stashed changes

0 comments on commit 1a52522

Please sign in to comment.