From 67521ceefe31764fdeeb605fdc0df0bb1116bb10 Mon Sep 17 00:00:00 2001 From: Schiano-NOAA Date: Tue, 5 Nov 2024 16:49:11 -0500 Subject: [PATCH 1/9] fix(write_captions): changes to function to integrate with asar - Added link to data as well as other extractions for key quanitites - Updated documentation --- R/write_captions.R | 19 +++++++++++++------ man/write_captions.Rd | 6 +++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/R/write_captions.R b/R/write_captions.R index 6433d60..d5f6380 100644 --- a/R/write_captions.R +++ b/R/write_captions.R @@ -3,7 +3,9 @@ #' Function to create captions and alternative text that contain #' key quantities from the model results file. #' -#' @inheritParams plot_recruitment +#' @inheritParams plot_spawning_biomass +#' @param dir Directory where the output captions and alt text file should be saved +#' @param year the last year of the data or the current year this function is being performed #' #' @return Exports .csv with captions and alt text for figures and tables #' that contain key quantities (e.g., an assessment's start year) that @@ -11,8 +13,9 @@ #' #' @export -write_captions <- function(dat # converted model output object - ){ +write_captions <- function(dat, # converted model output object + dir = NULL, + year = NULL){ # import pre-written captions and alt text that include placeholders # for key quantities (e.g., 'start_year' is the placeholder for the @@ -22,8 +25,12 @@ write_captions <- function(dat # converted model output object ) # extract key quantities (these are examples and are not accurate) - start_year <- as.numeric(dat[3,3]) - Fend <- as.numeric(dat$estimate[2]) + start_year <- min(as.numeric(dat$year[dat$year!="S/Rcurve" | dat$year!="Virg" | dat$year!="Init"]), na.rm = TRUE) + # as.numeric(dat[3,3]) + Fend_df <- dat |> + dplyr::filter(label == "fishing_mortality" & year == year | label == "F_terminal") + Fend <- as.numeric(Fend_df$estimate) + # as.numeric(dat$estimate[2]) # add in more quantities here, and update the quantities above # substitute quantity placeholders in the captions/alt text with @@ -41,7 +48,7 @@ write_captions <- function(dat # converted model output object # export df with substituted captions and alt text to csv write.csv(x = caps_alttext_subbed, - file = file.path(here::here(), + file = file.path(dir, "captions_alt_text.csv"), row.names=FALSE) diff --git a/man/write_captions.Rd b/man/write_captions.Rd index f33d96a..2ccc2b8 100644 --- a/man/write_captions.Rd +++ b/man/write_captions.Rd @@ -4,10 +4,14 @@ \alias{write_captions} \title{Write captions and alternative text} \usage{ -write_captions(dat) +write_captions(dat, dir = NULL, year = NULL) } \arguments{ \item{dat}{A data frame returned from `asar::convert_output()`.} + +\item{dir}{Directory where the output captions and alt text file should be saved} + +\item{year}{the last year of the data or the current year this function is being performed} } \value{ Exports .csv with captions and alt text for figures and tables From 15668e6e1b5e0677b6b77ecf4d0ba13fa816a708 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 14 Nov 2024 10:17:45 -0500 Subject: [PATCH 2/9] added csv with basic alt text/caption placeholders; minor change to git.ignore --- .gitignore | 1 + inst/resources/captions_alttext.csv | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 inst/resources/captions_alttext.csv diff --git a/.gitignore b/.gitignore index 5b6a065..9c4a923 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .Rhistory .RData .Ruserdata +petrale_convert_output.csv diff --git a/inst/resources/captions_alttext.csv b/inst/resources/captions_alttext.csv new file mode 100644 index 0000000..6979662 --- /dev/null +++ b/inst/resources/captions_alttext.csv @@ -0,0 +1,8 @@ +label,type,caption,alt_text +recruitment,figure,recruitment figure caption here. Starts in start_year.,recruitment alt text here +spawning_biomass,figure,spawning biomass figure caption here. ,spawning biomass alt text here. The F(end) = Fend +landings,figure,recruitment figure caption here. Starts in start_year.,landings alt text here +biomass,figure,biomass fig cap here,biomass alt text here +recruitment,table,recruitment table caption here, +spawning_biomass,table,spawning biomass table caption here, +indices,table,indices table caption here, From f2992f18fb9d1efa250bee1accc39d0654bf23e3 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 14 Nov 2024 10:21:43 -0500 Subject: [PATCH 3/9] trying to fix local vs. remote syncing differences --- R/exp_fig_accessible.R | 69 +++++++++++++++++++++++++++++++++++++++ R/write_captions.R | 55 +++++++++++++++++++++++++++++++ man/exp_fig_accessible.Rd | 47 ++++++++++++++++++++++++++ man/write_captions.Rd | 24 ++++++++++++++ 4 files changed, 195 insertions(+) create mode 100644 R/exp_fig_accessible.R create mode 100644 R/write_captions.R create mode 100644 man/exp_fig_accessible.Rd create mode 100644 man/write_captions.Rd diff --git a/R/exp_fig_accessible.R b/R/exp_fig_accessible.R new file mode 100644 index 0000000..fa1ca3c --- /dev/null +++ b/R/exp_fig_accessible.R @@ -0,0 +1,69 @@ +#' Export figure and alternative text +#' +#' Function to export a specified plot object, and its alternative +#' text, from the R environment. +#' +#' @param figure Plot object in the R environment to export. +#' @param alt_text Alternative text for the figure. +#' @param path Directory in which "exported" folder should be saved. +#' @param width Plot width, in units (see argument below). Default +#' is 5. +#' @param height Plot height, in units (see argument below). Default +#' is 5. +#' @param units Plot size units (options: "in", "cm", "mm", "px"). +#' Default is "cm". + +#' @return A folder containing exported plots and associated +#' alternative text as .png and .csv objects, respectively. +#' +#' @export +#' +#' @examples +#' \dontrun{ +#' model_data <- read.csv(here::here("data/Petrale_sole_std_res_2023.csv")) +#' +#' fig1 <- satf::plot_spawning_biomass(model_data) +#' +#' exp_fig_accessible(figure = fig1, +#' alt_text = "my alt text", +#' path = here::here(), +#' width = 5, +#' height = 5, +#' units = "cm") +#' +#' } + +exp_fig_accessible <- function(figure, + alt_text, + path, + width = 5, + height = 5, + units = "cm"){ + + # turn figure name into a character string so it can be + # pasted into filepath + fig_name_deparsed <- sprintf(deparse(substitute(figure))) + + # create new "exported" folder + new_path <- paste0(path, "/", "exported") + dir.create(path = new_path) + + # export figure to png + ggplot2::ggsave(filename = paste0(fig_name_deparsed, ".png"), + plot = figure, + path = new_path, + width = width, + height = height, + units = units + ) + + # make template csv to store alt text + alt_text_df <- data.frame("Figure" = as.character(fig_name_deparsed), + "Alt_text" = as.character(alt_text)) + + # export alt text csv + write.csv(x = alt_text_df, + file = paste0(new_path, "/", fig_name_deparsed, "_alt_text.csv"), + row.names=FALSE) + +} diff --git a/R/write_captions.R b/R/write_captions.R new file mode 100644 index 0000000..d5f6380 --- /dev/null +++ b/R/write_captions.R @@ -0,0 +1,55 @@ +#' Write captions and alternative text +#' +#' Function to create captions and alternative text that contain +#' key quantities from the model results file. +#' +#' @inheritParams plot_spawning_biomass +#' @param dir Directory where the output captions and alt text file should be saved +#' @param year the last year of the data or the current year this function is being performed +#' +#' @return Exports .csv with captions and alt text for figures and tables +#' that contain key quantities (e.g., an assessment's start year) that +#' are automatically extracted from the converted model results file. +#' +#' @export + +write_captions <- function(dat, # converted model output object + dir = NULL, + year = NULL){ + + # import pre-written captions and alt text that include placeholders + # for key quantities (e.g., 'start_year' is the placeholder for the + # assessment's start year) + caps_alttext <- utils::read.csv( + system.file("resources", "captions_alttext.csv", package = "satf") + ) + + # extract key quantities (these are examples and are not accurate) + start_year <- min(as.numeric(dat$year[dat$year!="S/Rcurve" | dat$year!="Virg" | dat$year!="Init"]), na.rm = TRUE) + # as.numeric(dat[3,3]) + Fend_df <- dat |> + dplyr::filter(label == "fishing_mortality" & year == year | label == "F_terminal") + Fend <- as.numeric(Fend_df$estimate) + # as.numeric(dat$estimate[2]) + # add in more quantities here, and update the quantities above + + # substitute quantity placeholders in the captions/alt text with + # the real values, extracted above + caps_alttext_subbed <- caps_alttext |> + dplyr::mutate_if(is.character, + stringr::str_replace_all, + pattern = c("Fend"), + replacement = c(as.character(Fend)))|> + dplyr::mutate_if(is.character, + stringr::str_replace_all, + pattern = c("start_year"), + replacement = c(as.character(start_year))) + + + # export df with substituted captions and alt text to csv + write.csv(x = caps_alttext_subbed, + file = file.path(dir, + "captions_alt_text.csv"), + row.names=FALSE) + +} diff --git a/man/exp_fig_accessible.Rd b/man/exp_fig_accessible.Rd new file mode 100644 index 0000000..d5fa5a9 --- /dev/null +++ b/man/exp_fig_accessible.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/exp_fig_accessible.R +\name{exp_fig_accessible} +\alias{exp_fig_accessible} +\title{Export figure and alternative text} +\usage{ +exp_fig_accessible(figure, alt_text, path, width = 5, height = 5, units = "cm") +} +\arguments{ +\item{figure}{Plot object in the R environment to export.} + +\item{alt_text}{Alternative text for the figure.} + +\item{path}{Directory in which "exported" folder should be saved.} + +\item{width}{Plot width, in units (see argument below). Default +is 5.} + +\item{height}{Plot height, in units (see argument below). Default +is 5.} + +\item{units}{Plot size units (options: "in", "cm", "mm", "px"). +Default is "cm".} +} +\value{ +A folder containing exported plots and associated + alternative text as .png and .csv objects, respectively. +} +\description{ +Function to export a specified plot object, and its alternative +text, from the R environment. +} +\examples{ +\dontrun{ +model_data <- read.csv(here::here("data/Petrale_sole_std_res_2023.csv")) + +fig1 <- satf::plot_spawning_biomass(model_data) + +exp_fig_accessible(figure = fig1, + alt_text = "my alt text", + path = here::here(), + width = 5, + height = 5, + units = "cm") + +} +} diff --git a/man/write_captions.Rd b/man/write_captions.Rd new file mode 100644 index 0000000..2ccc2b8 --- /dev/null +++ b/man/write_captions.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/write_captions.R +\name{write_captions} +\alias{write_captions} +\title{Write captions and alternative text} +\usage{ +write_captions(dat, dir = NULL, year = NULL) +} +\arguments{ +\item{dat}{A data frame returned from `asar::convert_output()`.} + +\item{dir}{Directory where the output captions and alt text file should be saved} + +\item{year}{the last year of the data or the current year this function is being performed} +} +\value{ +Exports .csv with captions and alt text for figures and tables +that contain key quantities (e.g., an assessment's start year) that +are automatically extracted from the converted model results file. +} +\description{ +Function to create captions and alternative text that contain +key quantities from the model results file. +} From f126c46b21ec4d6acdc8685c2b0cb12248a28017 Mon Sep 17 00:00:00 2001 From: Sam Schiano <125507018+Schiano-NOAA@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:07:02 -0500 Subject: [PATCH 4/9] Update README.md Add option to install package using pak due to errors from remotes --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 7f88e59..8f1f0a9 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,13 @@ install.packages("remotes") remotes::install_github("nmfs-ost/satf") ``` +Occassionally, the package can not be installed using the `remotes` package. If this is the case for you and the other two installation options don't work please try: + +```r +install.packages("pak") +pak::pak("nmfs-ost/satf") +``` + ## Example This is a basic example which shows you how to solve a common problem: From 318658ef9dab11d665f95251260874701d8dd0f8 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 14 Nov 2024 11:37:27 -0500 Subject: [PATCH 5/9] build: updated alt text/captions csv to include caption and alt text for kobe plot. Also updated the key quantities section of create_template to include the variables to be extracted from the model results file in order to substitute placeholders in csv. --- R/write_captions.R | 44 +++++++++++++++++++++++++++-- inst/resources/captions_alttext.csv | 1 + 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/R/write_captions.R b/R/write_captions.R index d5f6380..5e394c6 100644 --- a/R/write_captions.R +++ b/R/write_captions.R @@ -25,12 +25,52 @@ write_captions <- function(dat, # converted model output object ) # extract key quantities (these are examples and are not accurate) + # REMINDER: the variable names must exactly match those in the captions/alt text csv. + ## quantities applicable to multiple plots start_year <- min(as.numeric(dat$year[dat$year!="S/Rcurve" | dat$year!="Virg" | dat$year!="Init"]), na.rm = TRUE) - # as.numeric(dat[3,3]) + + # end_year + + + ## quantities for individual plots + ### kobe plot + # B_div_BMSY_min <- # (= minimum value of B/B(MSY)) + # B_div_BMSY_max <- # (= maximum value of B/B(MSY)) + # F_div_FMSY_min <- # (= minimum value of F/F(MSY)) + # F_div_FMSY_max <- # (= maximum value of F/F(MSY)) + # B_div_BMSY_end_yr <- # (= value of B/B(MSY) at the end year) + # F_div_FMSY_end_yr <- # (= value of F/F(MSY) at the end year) + # overfished_status_is_isnot <- # object that should be "is" or "is not" and answers the question, "the stock overfishing status ___ overfished" + # overfishing_status_is_isnot <- # object that should be "is" or "is not" and answers the question, "the stock ___ experiencing overfishing" + + ### F Fend_df <- dat |> dplyr::filter(label == "fishing_mortality" & year == year | label == "F_terminal") Fend <- as.numeric(Fend_df$estimate) - # as.numeric(dat$estimate[2]) + + # Ftarg <- + # F_Ftarg <- + + ### B + # Bend <- + # Btarg <- + # Bmsy <- + + + ### SB + # SBmsy <- + # fSB <- + # sbtarg <- + + ### Other + # tot_catch <- + # M <- + # steep <- + # R0 <- + + + + # add in more quantities here, and update the quantities above # substitute quantity placeholders in the captions/alt text with diff --git a/inst/resources/captions_alttext.csv b/inst/resources/captions_alttext.csv index 6979662..0a8fc53 100644 --- a/inst/resources/captions_alttext.csv +++ b/inst/resources/captions_alttext.csv @@ -1,4 +1,5 @@ label,type,caption,alt_text +kobe,figure,"Kobe plot showing stock status. Triangles delineate start and end years. Horizontal and vertical dashed lines delineate reference points for overfishing (i.e., F/FMSY>1) and overfished status (i.e., B/BMSY <1) where MSY represents either actual maximum sustainable yield or a proxy for MSY.","A Kobe plot showing stock status from start year to end year. The x axis, showing overfished status (i.e., B/BMSY), spans from B_div_BMSY_min to B_div_BMSY_max and the y axis, showing overfishing (i.e., F/FMSY), spans from F_div_FMSY_min to F_div_FMSY_max. The B/BMSY and F/FMSY for end year were B_div_BMSY_end_yr and F_div_FMSY_end_yr, respectively, indicating that the stock overfished_status_is_isnot overfished and overfishing_status_is_is_not experiencing overfishing." recruitment,figure,recruitment figure caption here. Starts in start_year.,recruitment alt text here spawning_biomass,figure,spawning biomass figure caption here. ,spawning biomass alt text here. The F(end) = Fend landings,figure,recruitment figure caption here. Starts in start_year.,landings alt text here From 18d605629027ed8ee17b128933b8bdc4ecadbe0c Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 14 Nov 2024 14:22:36 -0500 Subject: [PATCH 6/9] build: updated alt text/captions csv to include caption and alt text for biomass and F plots. Also updated write_captions.R to include plot-specific placeholders. --- R/write_captions.R | 42 +++++++++++++++++++---------- inst/resources/captions_alttext.csv | 6 +++-- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/R/write_captions.R b/R/write_captions.R index 5e394c6..46f594d 100644 --- a/R/write_captions.R +++ b/R/write_captions.R @@ -26,14 +26,11 @@ write_captions <- function(dat, # converted model output object # extract key quantities (these are examples and are not accurate) # REMINDER: the variable names must exactly match those in the captions/alt text csv. - ## quantities applicable to multiple plots - start_year <- min(as.numeric(dat$year[dat$year!="S/Rcurve" | dat$year!="Virg" | dat$year!="Init"]), na.rm = TRUE) + # + # This start_year was written previously. Is it usable for any plots, below? + # start_year <- min(as.numeric(dat$year[dat$year!="S/Rcurve" | dat$year!="Virg" | dat$year!="Init"]), na.rm = TRUE) - # end_year - - - ## quantities for individual plots - ### kobe plot + ## kobe plot # B_div_BMSY_min <- # (= minimum value of B/B(MSY)) # B_div_BMSY_max <- # (= maximum value of B/B(MSY)) # F_div_FMSY_min <- # (= minimum value of F/F(MSY)) @@ -42,8 +39,29 @@ write_captions <- function(dat, # converted model output object # F_div_FMSY_end_yr <- # (= value of F/F(MSY) at the end year) # overfished_status_is_isnot <- # object that should be "is" or "is not" and answers the question, "the stock overfishing status ___ overfished" # overfishing_status_is_isnot <- # object that should be "is" or "is not" and answers the question, "the stock ___ experiencing overfishing" + # start_year_kobe <- # start year of kobe plot + # end_year_kobe <- # end year of kobe plot + + ## Biomass plot + # B_ref_pt <- # biomass reference point + # B_ref_pt_unit <- # biomass reference point unit + # B_start_year_ <- # start year of biomass plot + # B_end_year <- # start year of biomass plot + # B_units <- # units of B (plural) + # B_min <- # minimum B + # B_max <- # maximum B + # Bend <- + # Btarg <- + # Bmsy <- - ### F + ## mortality (F) plot + # F_ref_pt <- # F reference point + # F_ref_pt_unit <- # F reference point unit + # F_start_year_ <- # start year of F plot + # F_end_year <- # start year of F plot + # F_units <- # units of F (plural) + # F_min <- # minimum F + # F_max <- # maximum F Fend_df <- dat |> dplyr::filter(label == "fishing_mortality" & year == year | label == "F_terminal") Fend <- as.numeric(Fend_df$estimate) @@ -51,18 +69,14 @@ write_captions <- function(dat, # converted model output object # Ftarg <- # F_Ftarg <- - ### B - # Bend <- - # Btarg <- - # Bmsy <- - ### SB + ## SB # SBmsy <- # fSB <- # sbtarg <- - ### Other + ## Other # tot_catch <- # M <- # steep <- diff --git a/inst/resources/captions_alttext.csv b/inst/resources/captions_alttext.csv index 0a8fc53..e663054 100644 --- a/inst/resources/captions_alttext.csv +++ b/inst/resources/captions_alttext.csv @@ -1,9 +1,11 @@ label,type,caption,alt_text -kobe,figure,"Kobe plot showing stock status. Triangles delineate start and end years. Horizontal and vertical dashed lines delineate reference points for overfishing (i.e., F/FMSY>1) and overfished status (i.e., B/BMSY <1) where MSY represents either actual maximum sustainable yield or a proxy for MSY.","A Kobe plot showing stock status from start year to end year. The x axis, showing overfished status (i.e., B/BMSY), spans from B_div_BMSY_min to B_div_BMSY_max and the y axis, showing overfishing (i.e., F/FMSY), spans from F_div_FMSY_min to F_div_FMSY_max. The B/BMSY and F/FMSY for end year were B_div_BMSY_end_yr and F_div_FMSY_end_yr, respectively, indicating that the stock overfished_status_is_isnot overfished and overfishing_status_is_is_not experiencing overfishing." +kobe,figure,"Kobe plot showing stock status. Triangles delineate start and end years. Horizontal and vertical dashed lines delineate reference points for overfishing (i.e., F/FMSY>1) and overfished status (i.e., B/BMSY <1) where MSY represents either actual maximum sustainable yield or a proxy for MSY.","A Kobe plot showing stock status from start_year_kobe to end_year_kobe. The x axis, showing overfished status (i.e., B/BMSY), spans from B_div_BMSY_min to B_div_BMSY_max and the y axis, showing overfishing (i.e., F/FMSY), spans from F_div_FMSY_min to F_div_FMSY_max. The B/BMSY and F/FMSY for end_year_kobe were B_div_BMSY_end_yr and F_div_FMSY_end_yr, respectively, indicating that the stock overfished_status_is_isnot overfished and overfishing_status_is_is_not experiencing overfishing." +biomass,figure,Biomass time series. The horizontal dashed line represents the limit reference point (B_ref_pt B_ref_pt_unit).,"Line graph showing biomass time series from B_start_year to B_end_year. The x axis, showing the year, spans from B_start_year to B_end_year and the y axis, showing biomass in B_units (i.e., B), spans from B_min to B_max. The limit reference point is (B_ref_pt B_ref_pt_unit)." +mortality,figure,Fishing mortality (F) over time. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit).,"Line graph showing fishing mortality over time from F_start_year to F_end_year . The x axis, showing the year, spans from F_start_year to F_end_year and the y axis, showing fishing mortality in F_units (i.e., F), spans from F_min to F_max. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit)." recruitment,figure,recruitment figure caption here. Starts in start_year.,recruitment alt text here spawning_biomass,figure,spawning biomass figure caption here. ,spawning biomass alt text here. The F(end) = Fend landings,figure,recruitment figure caption here. Starts in start_year.,landings alt text here -biomass,figure,biomass fig cap here,biomass alt text here +,,, recruitment,table,recruitment table caption here, spawning_biomass,table,spawning biomass table caption here, indices,table,indices table caption here, From 0b3e23511b986870a7daf95409c7aef170b6aab5 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 14 Nov 2024 16:01:11 -0500 Subject: [PATCH 7/9] build: updated alt text/captions csv to include caption and alt text for landings and length type conversion plots. Also updated write_captions.R to include plot-specific placeholders. --- R/write_captions.R | 16 ++++++++++++++-- inst/resources/captions_alttext.csv | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/R/write_captions.R b/R/write_captions.R index 46f594d..6cec5e0 100644 --- a/R/write_captions.R +++ b/R/write_captions.R @@ -65,11 +65,23 @@ write_captions <- function(dat, # converted model output object Fend_df <- dat |> dplyr::filter(label == "fishing_mortality" & year == year | label == "F_terminal") Fend <- as.numeric(Fend_df$estimate) - # Ftarg <- # F_Ftarg <- - + ## landings plot + # landings_start_year <- # start year of landings plot + # landings_end_year <- # end year of landings plot + # landings_units <- # units of landings (plural) + # landings_min <- # minimum landings + # landings_max <- # maximum landings + + ## length type conversion plot + # total_length_units <- # total length units (plural) + # total_length_min <- # minimum total length + # total_length_max <- # maximum total length + # fork_length_units <- # fork length units (plural) + # fork_length_min <- # minimum fork length + # fork_length_max <- # maximum fork length ## SB # SBmsy <- diff --git a/inst/resources/captions_alttext.csv b/inst/resources/captions_alttext.csv index e663054..906a8a7 100644 --- a/inst/resources/captions_alttext.csv +++ b/inst/resources/captions_alttext.csv @@ -2,9 +2,11 @@ label,type,caption,alt_text kobe,figure,"Kobe plot showing stock status. Triangles delineate start and end years. Horizontal and vertical dashed lines delineate reference points for overfishing (i.e., F/FMSY>1) and overfished status (i.e., B/BMSY <1) where MSY represents either actual maximum sustainable yield or a proxy for MSY.","A Kobe plot showing stock status from start_year_kobe to end_year_kobe. The x axis, showing overfished status (i.e., B/BMSY), spans from B_div_BMSY_min to B_div_BMSY_max and the y axis, showing overfishing (i.e., F/FMSY), spans from F_div_FMSY_min to F_div_FMSY_max. The B/BMSY and F/FMSY for end_year_kobe were B_div_BMSY_end_yr and F_div_FMSY_end_yr, respectively, indicating that the stock overfished_status_is_isnot overfished and overfishing_status_is_is_not experiencing overfishing." biomass,figure,Biomass time series. The horizontal dashed line represents the limit reference point (B_ref_pt B_ref_pt_unit).,"Line graph showing biomass time series from B_start_year to B_end_year. The x axis, showing the year, spans from B_start_year to B_end_year and the y axis, showing biomass in B_units (i.e., B), spans from B_min to B_max. The limit reference point is (B_ref_pt B_ref_pt_unit)." mortality,figure,Fishing mortality (F) over time. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit).,"Line graph showing fishing mortality over time from F_start_year to F_end_year . The x axis, showing the year, spans from F_start_year to F_end_year and the y axis, showing fishing mortality in F_units (i.e., F), spans from F_min to F_max. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit)." +landings,figure,Historical landings by fleet.,"Cumulative area plot showing historical landings from landings_start_year to landings_end_year. The x axis, showing the year, spans from landings_start_year to landings_end_year and the y axis, showing landings in landings_units, spans from landings_min to landings_max." +length_type_conversion,figure,Length measuring type conversion relationship between total and fork length where points represent individual fish length measurement observations and the line is the fitted relationship. ,"Point and line graph showing observations of measured fork length and measured total length from the same fish for conversion purposes as points, and a linear fit through those points as a line. The x axis, showing total length in total_length_units, spans from total_length_min to total_length_max and the y axis, showing fork length in fork_length_units, spans from fork_length_min to fork_length_max." recruitment,figure,recruitment figure caption here. Starts in start_year.,recruitment alt text here spawning_biomass,figure,spawning biomass figure caption here. ,spawning biomass alt text here. The F(end) = Fend -landings,figure,recruitment figure caption here. Starts in start_year.,landings alt text here +,,, ,,, recruitment,table,recruitment table caption here, spawning_biomass,table,spawning biomass table caption here, From 23bef020b176abe02f283141204a5bacd38b67ed Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 14 Nov 2024 16:27:51 -0500 Subject: [PATCH 8/9] build: updated alt text/captions csv to include caption and alt text for weight-length conversion and CPUE indices plots. Also updated write_captions.R to include plot-specific placeholders. --- R/write_captions.R | 17 ++++++++++++++++- inst/resources/captions_alttext.csv | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/R/write_captions.R b/R/write_captions.R index 6cec5e0..65e4081 100644 --- a/R/write_captions.R +++ b/R/write_captions.R @@ -75,7 +75,7 @@ write_captions <- function(dat, # converted model output object # landings_min <- # minimum landings # landings_max <- # maximum landings - ## length type conversion plot + ## length-type conversion plot # total_length_units <- # total length units (plural) # total_length_min <- # minimum total length # total_length_max <- # maximum total length @@ -83,6 +83,21 @@ write_captions <- function(dat, # converted model output object # fork_length_min <- # minimum fork length # fork_length_max <- # maximum fork length + ## weight-length conversion plot + # wl_length_units <- # length units (plural) + # wl_length_min <- # minimum length + # wl_length_max <- # maximum length + # wl_weight_units, <- # weight units (plural) + # wl_weight_min <- # minimum weight + # wl_weight_max <- # maximum weight + + ## CPUE indices plot + # cpue_start_year <- # start year of CPUE indices plot + # cpue_end_year <- # end year of CPUE indices plot + # cpue_units <- # CPUE units (plural) + # cpue_min <- # minimum CPUE + # cpue_max <- # maximum CPUE + ## SB # SBmsy <- # fSB <- diff --git a/inst/resources/captions_alttext.csv b/inst/resources/captions_alttext.csv index 906a8a7..ce66c77 100644 --- a/inst/resources/captions_alttext.csv +++ b/inst/resources/captions_alttext.csv @@ -3,7 +3,9 @@ kobe,figure,"Kobe plot showing stock status. Triangles delineate start and end y biomass,figure,Biomass time series. The horizontal dashed line represents the limit reference point (B_ref_pt B_ref_pt_unit).,"Line graph showing biomass time series from B_start_year to B_end_year. The x axis, showing the year, spans from B_start_year to B_end_year and the y axis, showing biomass in B_units (i.e., B), spans from B_min to B_max. The limit reference point is (B_ref_pt B_ref_pt_unit)." mortality,figure,Fishing mortality (F) over time. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit).,"Line graph showing fishing mortality over time from F_start_year to F_end_year . The x axis, showing the year, spans from F_start_year to F_end_year and the y axis, showing fishing mortality in F_units (i.e., F), spans from F_min to F_max. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit)." landings,figure,Historical landings by fleet.,"Cumulative area plot showing historical landings from landings_start_year to landings_end_year. The x axis, showing the year, spans from landings_start_year to landings_end_year and the y axis, showing landings in landings_units, spans from landings_min to landings_max." -length_type_conversion,figure,Length measuring type conversion relationship between total and fork length where points represent individual fish length measurement observations and the line is the fitted relationship. ,"Point and line graph showing observations of measured fork length and measured total length from the same fish for conversion purposes as points, and a linear fit through those points as a line. The x axis, showing total length in total_length_units, spans from total_length_min to total_length_max and the y axis, showing fork length in fork_length_units, spans from fork_length_min to fork_length_max." +length_type_conversion,figure,Length-type conversion relationship between total and fork length where points represent individual fish length measurement observations and the line is the fitted relationship. ,"Point and line graph showing observations of measured fork length and measured total length from the same fish for conversion purposes as points, and a linear fit through those points as a line. The x axis, showing total length in total_length_units, spans from total_length_min to total_length_max and the y axis, showing fork length in fork_length_units, spans from fork_length_min to fork_length_max." +weight_length_converstion,figure,Weight-length conversion relationship where the points represent individual fish observations and the line is the fitted relationship. ,"Point and line graph showing observations of measured length and measured weight from the same fish for conversion purposes as points, and an exponential fit through those points as a line. The x axis, showing length in wl_length_units, spans from wl_length_min to wl_length_max and the y axis, showing weight in wl_weight_units, spans from wl_weight_min to wl_weight_max." +CPUE_indices,figure,Catch per unit effort (CPUE) over time for fleet or survey. 95% confidence intervals are shown for each survey/fleet.,"Line graph showing catch per unit effort (CPUE) over time for fleet or survey from cpue_start_year to cpue_end_year, stratified by survey/fleet. The x axis, showing the year, spans from cpue_start_year to cpue_end_year and the y axis, showing CPUE in cpue_units, spans from cpue_min to cpue_max." recruitment,figure,recruitment figure caption here. Starts in start_year.,recruitment alt text here spawning_biomass,figure,spawning biomass figure caption here. ,spawning biomass alt text here. The F(end) = Fend ,,, From 02e68edb09e1af50ffc8b5ed2ae4412333a31371 Mon Sep 17 00:00:00 2001 From: sbreitbart-NOAA Date: Thu, 14 Nov 2024 16:51:59 -0500 Subject: [PATCH 9/9] build: updated alt text/captions csv to include caption and alt text for natural mortality plot. Also updated write_captions.R to include plot-specific placeholders. --- R/write_captions.R | 7 +++++++ inst/resources/captions_alttext.csv | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/R/write_captions.R b/R/write_captions.R index 65e4081..854a9af 100644 --- a/R/write_captions.R +++ b/R/write_captions.R @@ -75,6 +75,13 @@ write_captions <- function(dat, # converted model output object # landings_min <- # minimum landings # landings_max <- # maximum landings + ## natural mortality (M) + # M_age_min <- # minimum age of M + # M_age_max <- # maximum age of M + # M_units <- # units of M (plural) + # M_rate_min <- # minimum M rate + # M_rate_max <- # maximum M rate + ## length-type conversion plot # total_length_units <- # total length units (plural) # total_length_min <- # minimum total length diff --git a/inst/resources/captions_alttext.csv b/inst/resources/captions_alttext.csv index ce66c77..3f17bfa 100644 --- a/inst/resources/captions_alttext.csv +++ b/inst/resources/captions_alttext.csv @@ -1,8 +1,9 @@ label,type,caption,alt_text kobe,figure,"Kobe plot showing stock status. Triangles delineate start and end years. Horizontal and vertical dashed lines delineate reference points for overfishing (i.e., F/FMSY>1) and overfished status (i.e., B/BMSY <1) where MSY represents either actual maximum sustainable yield or a proxy for MSY.","A Kobe plot showing stock status from start_year_kobe to end_year_kobe. The x axis, showing overfished status (i.e., B/BMSY), spans from B_div_BMSY_min to B_div_BMSY_max and the y axis, showing overfishing (i.e., F/FMSY), spans from F_div_FMSY_min to F_div_FMSY_max. The B/BMSY and F/FMSY for end_year_kobe were B_div_BMSY_end_yr and F_div_FMSY_end_yr, respectively, indicating that the stock overfished_status_is_isnot overfished and overfishing_status_is_is_not experiencing overfishing." -biomass,figure,Biomass time series. The horizontal dashed line represents the limit reference point (B_ref_pt B_ref_pt_unit).,"Line graph showing biomass time series from B_start_year to B_end_year. The x axis, showing the year, spans from B_start_year to B_end_year and the y axis, showing biomass in B_units (i.e., B), spans from B_min to B_max. The limit reference point is (B_ref_pt B_ref_pt_unit)." -mortality,figure,Fishing mortality (F) over time. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit).,"Line graph showing fishing mortality over time from F_start_year to F_end_year . The x axis, showing the year, spans from F_start_year to F_end_year and the y axis, showing fishing mortality in F_units (i.e., F), spans from F_min to F_max. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit)." +biomass,figure,Biomass (B) time series. The horizontal dashed line represents the limit reference point (B_ref_pt B_ref_pt_unit).,"Line graph showing biomass time series from B_start_year to B_end_year. The x axis, showing the year, spans from B_start_year to B_end_year and the y axis, showing biomass in B_units, spans from B_min to B_max. The limit reference point is (B_ref_pt B_ref_pt_unit)." +fishing_mortality,figure,Fishing mortality (F) over time. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit).,"Line graph showing fishing mortality over time from F_start_year to F_end_year . The x axis, showing the year, spans from F_start_year to F_end_year and the y axis, showing fishing mortality in F_units (i.e., F), spans from F_min to F_max. The horizontal dashed line represents the target reference point (F_ref_pt F_ref_pt_unit)." landings,figure,Historical landings by fleet.,"Cumulative area plot showing historical landings from landings_start_year to landings_end_year. The x axis, showing the year, spans from landings_start_year to landings_end_year and the y axis, showing landings in landings_units, spans from landings_min to landings_max." +natural_mortality,figure,Natural mortality (M) for each age. ,"Line graph showing natural mortality from M_age_min to M_age_max. The x axis, showing age in M_units, spans from M_age_min to M_age_max and the y axis, showing the natural mortality rate per year, spans from M_rate_min to M_rate_max." length_type_conversion,figure,Length-type conversion relationship between total and fork length where points represent individual fish length measurement observations and the line is the fitted relationship. ,"Point and line graph showing observations of measured fork length and measured total length from the same fish for conversion purposes as points, and a linear fit through those points as a line. The x axis, showing total length in total_length_units, spans from total_length_min to total_length_max and the y axis, showing fork length in fork_length_units, spans from fork_length_min to fork_length_max." weight_length_converstion,figure,Weight-length conversion relationship where the points represent individual fish observations and the line is the fitted relationship. ,"Point and line graph showing observations of measured length and measured weight from the same fish for conversion purposes as points, and an exponential fit through those points as a line. The x axis, showing length in wl_length_units, spans from wl_length_min to wl_length_max and the y axis, showing weight in wl_weight_units, spans from wl_weight_min to wl_weight_max." CPUE_indices,figure,Catch per unit effort (CPUE) over time for fleet or survey. 95% confidence intervals are shown for each survey/fleet.,"Line graph showing catch per unit effort (CPUE) over time for fleet or survey from cpue_start_year to cpue_end_year, stratified by survey/fleet. The x axis, showing the year, spans from cpue_start_year to cpue_end_year and the y axis, showing CPUE in cpue_units, spans from cpue_min to cpue_max."