-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Smith
authored and
Smith
committed
Oct 1, 2024
1 parent
878b153
commit 3e054b7
Showing
12 changed files
with
300 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
library(bbsBayes2) | ||
library(tidyverse) | ||
|
||
species <- "Scissor-tailed Flycatcher" | ||
species <- "Arctic Warbler" | ||
|
||
# extract the unique numerical identifier for this species in the BBS database | ||
species_number <- search_species(species) %>% | ||
select(aou) %>% | ||
unlist() | ||
|
||
s <- stratify("bbs_usgs", | ||
species = species) %>% | ||
prepare_data() | ||
|
||
for(j in 1:nrow(bbs_models)){ | ||
|
||
mod <- as.character(bbs_models[j,"model"]) | ||
var <- as.character(bbs_models[j,"variant"]) | ||
|
||
if(var == "spatial"){ | ||
p <- prepare_spatial(s, strata_map = load_map("bbs_usgs")) %>% | ||
prepare_model(model = mod, model_variant = var) | ||
}else{ | ||
p <- prepare_model(s,model = mod, | ||
model_variant = var) | ||
} | ||
|
||
m <- paste0("output/", | ||
species_number, | ||
"_", | ||
mod, | ||
"_", | ||
var) | ||
m2 <- run_model(p, | ||
output_basename = m, | ||
output_dir = "vignettes/articles") | ||
|
||
} | ||
|
||
|
||
# latlong fits ------------------------------------------------------------ | ||
|
||
|
||
|
||
s <- stratify("latlong", | ||
species = species) %>% | ||
prepare_data(min_n_routes = 1) | ||
|
||
for(j in 3){ | ||
|
||
mod <- as.character(bbs_models[j,"model"]) | ||
var <- as.character(bbs_models[j,"variant"]) | ||
|
||
if(var == "spatial"){ | ||
p <- prepare_spatial(s, strata_map = load_map("latlong")) %>% | ||
prepare_model(model = mod, model_variant = var) | ||
}else{ | ||
p <- prepare_model(s,model = mod, | ||
model_variant = var) | ||
} | ||
|
||
m <- paste0("output/", | ||
species_number, | ||
"_latlong_", | ||
mod, | ||
"_", | ||
var) | ||
m2 <- run_model(p, | ||
output_basename = m, | ||
output_dir = "vignettes/articles") | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
library(DiagrammeR) | ||
gri <- grViz("digraph functions { | ||
# a 'graph' statement | ||
graph [overlap = true, fontsize = 10 compound = true, ranksep = 0.5] | ||
# several 'node' statements | ||
node [shape = rectangle, fontname = 'Courier New', | ||
fixedsize = false, style=filled, fillcolor=white] | ||
fetch [label = 'fetch_bbs_data()', fillcolor=lightblue] | ||
remove [label = 'remove_cache()', fillcolor=orange] | ||
loadbbs [label = 'load_bbs_data()', fillcolor=lightblue] | ||
search [label = 'search_species()', fillcolor=orange] | ||
strat [label = 'stratify()', fillcolor=lightpink] | ||
prepdata [label = 'prepare_data()', fillcolor=lightpink] | ||
prepspatial [label = 'prepare_spatial()', fillcolor=lightpink] | ||
prepmodel [label = 'prepare_model()', fillcolor=darkolivegreen3] | ||
loadmap [label = 'load_map()', fillcolor=orange] | ||
assign_ps [label = 'assign_prov_state()', fillcolor=orange] | ||
runmodel [label = 'run_model()', fillcolor=darkolivegreen3] | ||
modelfile [label = 'copy_model_file()', fillcolor=darkolivegreen3] | ||
conv[label = 'save_model_run()\nget_convergence()\nget_model_vars()\nget_summary()', fillcolor=darkolivegreen3] | ||
genind [label = 'generate_indices()', fillcolor=thistle] | ||
gentre [label = 'generate_trends()', fillcolor=thistle] | ||
geo [label = 'plot_geofacet()', fillcolor=thistle] | ||
plotind [label = 'plot_indices()', fillcolor=thistle] | ||
genmap [label = 'plot_map()', fillcolor=thistle] | ||
# several 'edge' statements | ||
edge [] | ||
fetch->remove [style=dashed] | ||
fetch->loadbbs [style=dashed] | ||
fetch->strat [style=dashed] | ||
runmodel->remove [style=dashed] | ||
modelfile->prepmodel [style=dashed] | ||
search->strat [style=dashed] | ||
strat->prepdata | ||
prepdata->prepspatial | ||
prepdata->prepmodel [color=grey50] | ||
prepspatial->prepmodel [color=grey50] | ||
prepmodel->runmodel | ||
runmodel->conv | ||
runmodel->genind | ||
genind->gentre | ||
loadmap->assign_ps [style=dashed] | ||
loadmap->genind [style=dashed] | ||
loadmap->prepspatial [style=dashed] | ||
loadmap->strat [style=dashed] | ||
genind->plotind | ||
genind->geo | ||
gentre->geo [color=grey50] | ||
gentre->genmap | ||
# Invisible edges for arranging | ||
prepspatial->conv [style=invis] | ||
}") | ||
|
||
|
||
export_graph(file_name = "flow_diagram.png", | ||
graph = gri, | ||
file_type = "png", | ||
width = 1200,height = 1400) | ||
print(gri) | ||
dev.off() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
aou,minimum_year,warning | ||
4661,1978,Alder and Willow Flycatcher were considered a single species until 1973. It is likely that they are not accurately separated by BBS observers until at least some years after that split. | ||
4660,1978,Alder and Willow Flycatcher were considered a single species until 1973. It is likely that they are not accurately separated by BBS observers until at least some years after that split. | ||
10,1990,Clark's and Western Grebe were considered a single species until 1985. It is likely that they are not accurately separated by BBS observers until at least some years after that split. | ||
10,1990,Clark's and Western Grebe were considered a single species until 1985. It is likely that they are not accurately separated by BBS observers until at least some years after that split. | ||
22860,1990,Eurasian Collared Dove was introduced into North America in the 1980s. 1990 is the first year that the species was observed on at least 3 BBS routes. | ||
6121,1985,Cave Swallows were relatively rare in the areas surveyed by BBS before 1980. There are only two observations during BBS before 1980. | ||
english,french,aou,minimum_year,warning | ||
Alder Flycatcher,Moucherolle des aulnes,4661,1978,Alder and Willow Flycatcher were considered a single species until 1973. It is likely that they are not accurately separated by BBS observers until at least some years after that split. | ||
Willow Flycatcher,Moucherolle des saules,4660,1978,Alder and Willow Flycatcher were considered a single species until 1973. It is likely that they are not accurately separated by BBS observers until at least some years after that split. | ||
Clark's Grebe,Gr�be � face blanche,11,1990,Clark's and Western Grebe were considered a single species until 1985. It is likely that they are not accurately separated by BBS observers until at least some years after that split. | ||
Western Grebe,Gr�be �l�gant,10,1990,Clark's and Western Grebe were considered a single species until 1985. It is likely that they are not accurately separated by BBS observers until at least some years after that split. | ||
Eurasian Collared-Dove,Tourterelle turque,22860,1990,Eurasian Collared Dove was introduced into North America in the 1980s. 1990 is the first year that the species was observed on at least 3 BBS routes. | ||
Cave Swallow,Hirondelle � front brun,6121,1985,Cave Swallows were relatively rare in the areas surveyed by BBS before 1980. There are only two observations during BBS before 1980. |
Binary file not shown.
Oops, something went wrong.