forked from HeritageNetwork/Regional_SDM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0_user_run_SDM.R
99 lines (83 loc) · 4.68 KB
/
0_user_run_SDM.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File: user_run_SDM.r
# Purpose: Run a new, full SDM model (all steps)
library(here)
rm(list=ls())
# Step 1: Setting for the model run
# species code (from lkpSpecies in modelling database. This will be the new folder name containing inputs/ouptuts)
model_species <- "micrmont"
# loc_scripts is your repository. Make sure your git repository is set to correct branch
loc_scripts <- here()
# The main modelling folder for inputs/outputs. All sub-folders are created during the model run (when starting with step 1)
loc_model <- here("_data", "species")
# Modeling database
nm_db_file <- here("_data", "databases", "SDM_lookupAndTracking.sqlite")
# locations file (presence reaches). Provide full path; File is copied to modeling folder and timestamped.
nm_presFile <- here("_data", "occurrence", paste0(model_species, ".shp"))
# env vars location [Terrestrial-only variable]
loc_envVars = here("_data","env_vars","raster")
# bkg points [Terrestrial-only variable]
nm_bkgPts = here("_data","env_vars","background","va_att.shp")
# map reference boundaries
nm_refBoundaries = here("_data","other_spatial","feature", "US_States.shp") # background grey reference lines in map
# map project boundary
nm_studyAreaExtent = here("_data","occurrence","anaxexsu_studyArea.shp") # outline black boundary line for study area in map
# model comment in database
model_comments = "testing master"
# comment printed in PDF metadata
metaData_comments = "bla bla"
# your name
modeller = "David Bucklin"
# list non-standard variables to add to model run
add_vars = NULL
# list standard variables to exclude from model run
remove_vars = NULL
# do you want to stop execution after each modeling step (script)?
prompt = FALSE
# default values for Model Use rubric
# order should be "spdata_dataqual,spdata_abs,spdata_eval,envvar_relevance,envvar_align,process_algo,process_sens,process_rigor,process_perform,process_review,products_mapped,products_support,products_repo,interative,spdata_dataqual,spdata_abs,spdata_eval,envvar_relevance,envvar_align,process_algo,process_sens,process_rigor,process_perform,process_review,products_mapped,products_support,products_repo,interative,spdata_dataqualNotes,spdata_absNotes,spdata_evalNotes,envvar_relevanceNotes,envvar_alignNotes,process_algoNotes,process_sensNotes,process_rigorNotes,process_performNotes,process_reviewNotes,products_mappedNotes,products_supportNotes,products_repoNotes,interativeNotes"
rubric_default = c("I","A","A","A","A","I","A","A","A","I","A","I","A","A","","","","","","","","","","","","","","")
project_blurb = "Models developed for the MoBI project are intended to inform creation of a national map of biodiversity value, and we recommend additional refinement and review before these data are used for more targeted, species-specific decision making. In particular, many MoBI models would benefit from greater consideration of species data and environmental predictor inputs, a more thorough review by species experts, and iteration to address comments received."
# set wd and load function
setwd(loc_scripts)
source(here("helper", "run_SDM.R"))
##############
# End step 1 #
##############
# Step 2: execute a new model
# Usage: For a full, new model run, provide all paths/file names to arguments 'loc_scripts' THROUGH 'modeller'.
# RUN A NEW MODEL (ALL STEPS 1-5)
run_SDM(
model_species = model_species, # species code in DB; new folder to create in loc_model if not existing
loc_scripts = loc_scripts,
nm_presFile = nm_presFile,
nm_db_file = nm_db_file,
loc_model = loc_model,
loc_envVars = loc_envVars,
nm_bkgPts = nm_bkgPts,
nm_refBoundaries = nm_refBoundaries, # background grey refernce lines in map
nm_studyAreaExtent = nm_studyAreaExtent, # outline black boundary line for study area in map
model_comments = model_comments,
metaData_comments = metaData_comments,
modeller = modeller,
add_vars = add_vars,
remove_vars = remove_vars,
rubric_default = rubric_default,
project_blurb = project_blurb,
prompt = prompt
)
##########
##########
##########
# TESTING / DEBUGGING ONLY
library(here)
rm(list=ls())
# Use the lines below for debugging (running line by line) for a certain script
# This loads the variables used in previous model run for the species,
# so you need to have started a run_SDM() run in step 2 first.
# for scripts 1-3, run just the following 3 lines
model_species <- "anaxexsu"
load(here("_data","species",model_species,"runSDM_paths.Rdata"))
for(i in 1:length(fn_args)) assign(names(fn_args)[i], fn_args[[i]])
# if debugging script 4 or later, also load the specific model output rdata file
model_rdata <- max(list.files(here("_data","species",model_species,"outputs","rdata")))
load(here("_data","species",model_species,"outputs","rdata",paste0(model_rdata)))