Skip to content

Commit

Permalink
Merge pull request #101 from NOAA-EDAB/operation_phoenix
Browse files Browse the repository at this point in the history
book enhancements
  • Loading branch information
BBeltz1 authored Feb 20, 2024
2 parents 83599bb + 52f3b53 commit c097f13
Show file tree
Hide file tree
Showing 84 changed files with 5,168 additions and 644 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bookdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- operation_phoenix
pull_request:
branches:
- master
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

# local files/folders
_book
_bookdown_files
_bookdown_files
docs
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Depends:
Suggests:
downlit
Remotes:
NOAA-EDAB/ecodata
NOAA-EDAB/ecodata@dev

2 changes: 2 additions & 0 deletions R/find_dataset_submissions.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#'
#' @return character vector

source(here::here("R/parse_issue.r"))

find_dataset_submissions <- function(){

issueData <- readRDS(here::here("data-raw/submissionIssueNumbers.rds"))
Expand Down
2 changes: 1 addition & 1 deletion R/find_rmds_not_in_book.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ find_rmds_not_in_book <- function(){
# find the rmdfiles not referenced in the yml
missingrmds <- setdiff(rmdfiles,rmdrefs)
message("The following rmds are not found in the _bookdown.yml")
print(missingrmds)
#print(missingrmds)

return(missingrmds)

Expand Down
44 changes: 25 additions & 19 deletions R/make_rmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ make_rmd <- function(listobject){
# start to create the Rmd
#cat(paste0("# ",stringr::str_to_title(indicator_name)),append=T,fill=T,file=con)
### DESCRIPTION, CONTRIBUTORS, AFFILIATION, FAMILY
# cat(paste0("# ",listobject$dataname," {#",listobject$indicatorname,"}"),append=T,fill=T,file=con)
cat(paste0("# ",listobject$dataname),append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space
cat(paste0("**Description**: ",listobject$description),append=T,fill=T,file=con)
Expand Down Expand Up @@ -59,7 +60,8 @@ make_rmd <- function(listobject){
at <- attributes(eval(parse(text=paste0("ecodata::plot_",listobject$indicatorname))))

functionArgs <- names(formals(eval(parse(text=paste0("ecodata::plot_",listobject$indicatorname)))))
if (length(functionArgs) == 2) {

if (length(functionArgs) == 2 | ((length(functionArgs) == 3) & (any(c("year","scale") %in% functionArgs)))) {
# this is standard shadedRegion and report
# check to see how many EPUs are listed in data object and/or they are "All" (shelfwide)
indicatorData <- eval(parse(text=paste0("ecodata::",listobject$indicatorname)))
Expand All @@ -69,7 +71,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,"MAB}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report='MidAtlantic')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space
} else {
Expand All @@ -81,7 +83,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,"MAB}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report='MidAtlantic')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space
}
Expand All @@ -92,7 +94,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,"NE}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report='NewEngland')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space
}
Expand All @@ -105,7 +107,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,"MAB}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report='MidAtlantic')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space

Expand All @@ -115,7 +117,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,"NEGB}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report='NewEngland',EPU='GB')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space

Expand All @@ -125,7 +127,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,"NEGOM}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report='NewEngland',EPU='GOM')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space

Expand All @@ -143,7 +145,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,arep,avarws,"}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report= '",arep,"', varName= '",avar,"')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space
}
Expand All @@ -162,7 +164,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,arep,avarws,"}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report= '",arep,"', plottype= '",avar,"')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space

Expand Down Expand Up @@ -195,7 +197,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,arep,avarws,aval,"}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report= '",arep,"', varName= '",avar,"' ,",newV,"= '",aval,"')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space

Expand All @@ -216,7 +218,7 @@ make_rmd <- function(listobject){
cat(paste0("```{r plot_",listobject$indicatorname,arep,avarws,atype,"}"),append=T,fill=T,file=con)
cat("# Plot indicator",append=T,fill=T,file=con)
cat(paste0("ggplotObject <- ecodata::plot_",listobject$indicatorname,"(report= '",arep,"', varName= '",avar,"', plottype = '",atype,"')"),append=T,fill=T,file=con)
cat("print(ggplotObject)",append=T,fill=T,file=con)
cat("ggplotObject",append=T,fill=T,file=con)
cat("```",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space

Expand Down Expand Up @@ -326,15 +328,19 @@ make_rmd <- function(listobject){
cat("",append=T,fill=T,file=con) # add space


cat("**tech-doc link**",append=T,fill=T,file=con)

cat(paste0("<https://noaa-edab.github.io/tech-doc/",listobject$indicatorname,".html>"),append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space


cat("## References",append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space
# write catalog link if ecodata data is present
if (exists(paste0(listobject$indicatorname))) {
cat("**tech-doc link**",append=T,fill=T,file=con)

cat(paste0("<https://noaa-edab.github.io/tech-doc/",listobject$indicatorname,".html>"),append=T,fill=T,file=con)
cat("",append=T,fill=T,file=con) # add space

} else {
# No link since this is a synthesis type of page
}

# References are generated automatically


#close the connection
close(con)
Expand Down
8 changes: 5 additions & 3 deletions R/parse_issue.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,24 @@ parse_issue <- function(issueData,issueNum){
body <- issueData$issues[id,]$body
}

headings <- unlist(stringr::str_extract_all(body,"###\\s+[a-zA-Z (.)\"\\?,]+"))
headings <- unlist(stringr::str_extract_all(body,"\n###\\s+[a-zA-Z (.)\"\\?,]+"))

for (ahead in headings) {
modifiedHead <- gsub("\\","",ahead,fixed=T)
modifiedHead <- gsub("(","\\(",modifiedHead,fixed=T)
modifiedHead <- gsub(")","\\)",modifiedHead,fixed=T)
modifiedHead <- gsub("?","\\?",modifiedHead,fixed=T)
byhead <- unlist(strsplit(body,modifiedHead))[2]
res <- unlist(strsplit(byhead,"###"))[1]
res <- unlist(strsplit(byhead,"\n### "))[1]
# remove beginning and trailing \n (line feed) and \r (carriage return)
modifiedRes <- trimws(res)
# modifiedRes <- sub("\\n+$","",modifiedRes)
# modifiedRes <- sub("^\\r\\n+","",modifiedRes)
# modifiedRes <- sub("\\r\\n+$","",modifiedRes)
ahead <- trimws(ahead)
objectList[ahead] <- modifiedRes
}

return(objectList)

}
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
---
editor_options:
markdown:
wrap: 72
---

# [Synthetic Indicator Catalog](https://noaa-edab.github.io/catalog/)

![gitleaks](https://github.com/NOAA-EDAB/catalog/workflows/gitleaks/badge.svg)
[![build-book](https://github.com/NOAA-EDAB/catalog/actions/workflows/bookdown.yaml/badge.svg)](https://github.com/NOAA-EDAB/catalog/actions/workflows/bookdown.yaml)
[![gitleaks](https://github.com/NOAA-EDAB/catalog/actions/workflows/secretScan.yml/badge.svg)](https://github.com/NOAA-EDAB/catalog/actions/workflows/secretScan.yml)

Catalog of indicators used in the State of the Ecosystem reports and
other ecosystem assessment products.
Expand Down
100 changes: 55 additions & 45 deletions _bookdown.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,59 @@
book_filename: "catalog"
rmd_files:
- "index.Rmd"
#- "chapters/introduction.rmd"


#################### LOWER TROPHIC ##################
- "chapters/sectionHeaders/ltl.rmd"
- "chapters/ches_bay_wq.rmd"
- "chapters/chl_pp.rmd"
- "chapters/ches_bay_wq.rmd"
- "chapters/chl_pp.rmd"
- "chapters/phyto_size.rmd"
#- "chapters/annual_chl_pp.rmd"
- "chapters/habs.rmd"
- "chapters/SAV.rmd"
- "chapters/calanus_variation.rmd"
- "chapters/wbts_mesozooplankton.rmd"


#################### MEGAFAUNA ##################
- "chapters/sectionHeaders/megafauna.rmd"
- "chapters/aggregate_biomass.rmd"
- "chapters/mab_inshore_survey.rmd"
- "chapters/condition.rmd"
- "chapters/energy_density.rmd"
- "chapters/habs.rmd"
- "chapters/SAV.rmd"
- "chapters/calanus_variation.rmd"
- "chapters/wbts_mesozooplankton.rmd"
- "chapters/zoo_abundance_anom.rmd"
- "chapters/zoo_diversity.rmd"
#
#
# #################### MEGAFAUNA ##################
- "chapters/sectionHeaders/megafauna.rmd"
- "chapters/aggregate_biomass.rmd"
- "chapters/mab_inshore_survey.rmd"
- "chapters/mass_inshore_survey.rmd"
- "chapters/ne_inshore_survey.rmd"
- "chapters/osw_survey_impact.rmd"
- "chapters/condition.rmd"
- "chapters/habitat_diversity.rmd"
- "chapters/species_dist.rmd"
- "chapters/energy_density.rmd"
- "chapters/spawn_timing.rmd"
- "chapters/exp_n.rmd"
- "chapters/forage_index.rmd"
- "chapters/harborporpoise.rmd"
- "chapters/hms_cpue.rmd"
- "chapters/hms_landings.rmd"
- "chapters/hms_stock_status.rmd"
- "chapters/HMS_species_distribution.rmd"
- "chapters/narw.rmd"
- "chapters/productivity_anomaly.rmd"
- "chapters/seal_pups.rmd"
- "chapters/gom_salmon.rmd"
- "chapters/grayseal.rmd"
- "chapters/seabird_ne.rmd"
- "chapters/species_groupings.rmd"


#################### OCEANOGRAPHIC ##################
- "chapters/exp_n.rmd"
- "chapters/forage_index.rmd"
- "chapters/harborporpoise.rmd"
- "chapters/hms_cpue.rmd"
- "chapters/hms_landings.rmd"
- "chapters/hms_stock_status.rmd"
- "chapters/HMS_species_distribution.rmd"
- "chapters/narw.rmd"
- "chapters/productivity_anomaly.rmd"
- "chapters/seal_pups.rmd"
- "chapters/gom_salmon.rmd"
- "chapters/grayseal.rmd"
- "chapters/seabird_ne.rmd"
- "chapters/species_groupings.rmd"
#
#
# #################### OCEANOGRAPHIC ##################
- "chapters/sectionHeaders/oceanographic.rmd"
- "chapters/bottom_temp.rmd"
- "chapters/bottom_temp.rmd"
- "chapters/bottom_temp_comp.rmd"
#- "chapters/bottom_temp_glorys.rmd"
- "chapters/bottom_temp_seasonal_gridded.rmd"
- "chapters/bottom_temp_seasonal_gridded.rmd"
- "chapters/seasonal_sst_anomaly_gridded.rmd"
- "chapters/seasonal_oisst_anom.rmd"
- "chapters/trans_dates.rmd"
- "chapters/trans_dates.rmd"
- "chapters/long_term_sst.rmd"
- "chapters/cold_pool.rmd"
- "chapters/gsi.rmd"
Expand All @@ -54,18 +62,20 @@ rmd_files:
- "chapters/wcr.rmd"
- "chapters/thermal_habitat_area.rmd"
- "chapters/thermal_habitat_persistence.rmd"
- "chapters/ch_bay_sal.rmd"
- "chapters/ch_bay_temp.rmd"
- "chapters/ches_bay_sst.rmd"
- "chapters/ches_bay_synthesis.rmd"
- "chapters/heatwave.rmd"
- "chapters/heatwave_year.rmd"
- "chapters/ch_bay_sal.rmd"
- "chapters/ch_bay_temp.rmd"
- "chapters/ches_bay_sst.rmd"
- "chapters/ches_bay_synthesis.rmd"
- "chapters/heatwave.rmd"
- "chapters/heatwave_year.rmd"
- "chapters/timing_shifts.rmd"
- "chapters/observation_synthesis.rmd"
- "chapters/ocean_acidification.rmd"


######################## ECONOMIC ##################
#
#
# ######################## ECONOMIC ##################
- "chapters/sectionHeaders/economic.rmd"
- "chapters/comdat.rmd"
- "chapters/comdat.rmd"
- "chapters/commercial_div.rmd"
- "chapters/ppr.rmd"
- "chapters/recdat.rmd"
Expand Down
1 change: 1 addition & 0 deletions _output.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bookdown::bs4_book:
split_bib: true
css: style.css
theme:
primary: "#4D6F8D"
Expand Down
Loading

0 comments on commit c097f13

Please sign in to comment.