Skip to content

Commit

Permalink
Add alt text to figures; glossary; formatting; R function for local c…
Browse files Browse the repository at this point in the history
…ompile (#232)

* add alt text to all images/figures
* add glossary terms
* add words to dictionary
* add r script to run locally without having to comment out lines yourself
* subscript fixes; SB to SSB; equation notation; virgin spawning biomass; unit abbreviations; add mg to glossary
  • Loading branch information
e-perl-NOAA authored Jul 25, 2024
1 parent 207cf45 commit c9cbe37
Show file tree
Hide file tree
Showing 21 changed files with 1,000 additions and 889 deletions.
53 changes: 53 additions & 0 deletions .github/r_code/pdflatex_local_manual.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#' Comment out lines that prevent pdf from being generated locally and produce pdf
#'
#' Reads the tex file and comments out lines that prevent pdf from being
#' generated locally and produces pdf using tinytex::pdflatex() and then changes
#' the tex file back. Please see issue #135 in the ss3-doc repository
#' (https://github.com/nmfs-ost/ss3-doc/issues/135) for more information on the
#' lines that prevent the pdf from being generated locally.
#'
#' @param manual_file A string providing the name of the manual tex file. The default is
#' "SS330_User_Manual.tex" with the assumption that this file is in your working directory.
#' @param dir A string providing the path to the directory where `manual_file` is located.
#' The default is [getwd()].
#' @author Elizabeth F. Perl
#' @return Results from tinytex::pdflatex().
#' @examples
#' pdflatex_local_manual()
pdflatex_local_manual <- function(manual_file = "SS330_User_Manual.tex", dir = getwd())
{
manual <- readLines(file.path(dir,"SS330_User_Manual.tex"))
manual[3] <- gsub("\\\\","%\\\\",manual[3])
manual[4] <- gsub("\\\\","%\\\\",manual[4])
manual[6] <- gsub("\\\\","%\\\\",manual[6])
manual[7] <- gsub("\\\\","%\\\\",manual[7])
manual[8] <- gsub("\\\\","%\\\\",manual[8])
manual[9] <- gsub("\\\\","%\\\\",manual[9])
writeLines(manual, "SS330_User_Manual.tex")

result <- tryCatch(
expr = {
message(tinytex::pdflatex("SS330_User_Manual.tex"))
message("Successfully created SS330_User_Manual.pdf")
},
error = function(e){
message('Caught an error!')
print(e)
},
warning = function(w){
message('Caught a warning!')
print(w)
}
)

manual[3] <- gsub("%\\\\", "\\\\",manual[3])
manual[4] <- gsub("%\\\\", "\\\\",manual[4])
manual[6] <- gsub("%\\\\", "\\\\",manual[6])
manual[7] <- gsub("%\\\\", "\\\\",manual[7])
manual[8] <- gsub("%\\\\", "\\\\",manual[8])
manual[9] <- gsub("%\\\\", "\\\\",manual[9])
writeLines(manual, "SS330_User_Manual.tex")

return(result)
}

2 changes: 1 addition & 1 deletion .github/workflows/build-ss3-manual-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ jobs:
- name: Throw error if spellcheck warnings exist
# If the number of warnings goes up (in the previous step) and cannot be rectified, you can change
# the number below and increase the number of warnings that will trigger the action to fail
if: ${{ steps.spellcheck.outputs.num_warnings > 593 }}
if: ${{ steps.spellcheck.outputs.num_warnings > 750 }}
run: 'echo "::error file=main.tex::num_warnings: ${{ steps.spellcheck.outputs.num_warnings }}"; exit 1;'
2 changes: 1 addition & 1 deletion 10optional_inputs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
\subsection[\texttt{profilevalues.ss}]{\protect\hyperlink{profilevalues}{\texttt{profilevalues.ss}}}
This file contains information for changing the value of selected parameters for each run in a batch. In the control file, each parameter that will be subject to modification by \texttt{profilevalues.ss} is designated by setting its phase to -9999.

The first value in \texttt{profilevalues.ss} is the number of parameters to be batched. This value MUST match the number of parameters with phase set equal to -9999 in the control file. The program performs no checks for this equality. If the value is zero in the first field, then nothing else will be read. Otherwise, the model will read runnumber * Nparameters values and use the last Nparameters of these to replace the initial values of parameters designated with phase = --9999 in the control file.
The first value in \texttt{profilevalues.ss} is the number of parameters to be batched. This value MUST match the number of parameters with phase set equal to -9999 in the control file. The program performs no checks for this equality. If the value is zero in the first field, then nothing else will be read. Otherwise, the model will read runnumber * Nparameters values and use the last Nparameters of these to replace the initial values of parameters designated with phase = -9999 in the control file.

Usage Note: If one of the batch runs crashes before saving the updated value of \texttt{runnumber.ss}, then the processing of the \verb|profilevalues.ss| will not proceed as expected. Check the output carefully until a more robust procedure is developed. Also, this options was created before use of R became widespread. You probably can create a more flexible approach using R today.

Expand Down
4 changes: 2 additions & 2 deletions 11likelihoods.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
\hline
Index & Source & Data/Parameter & Error structure \Tstrut\Bstrut\\
\hline
$i$ & fishery/survey $f$ & CPUE or Abundance index & user choice \Tstrut\\
$i$ & fishery/survey $f$ & \gls{cpue} or Abundance index & user choice \Tstrut\\
$i$ & fishery $f$ & Discard Biomass & user choice \Tstrut\\
$i$ & fishery/survey $f$ & Mean body W or L (all ages) & normal \Tstrut\\
$i$ & fishery/survey $f$ & Generalized size (W or L) composition & multinomial or Dirichlet-multinomial \Tstrut\\
Expand All @@ -34,7 +34,7 @@
$R$ & & Recruitment Deviations & log-normal \Tstrut\\
$P$ & & Random parameter devs & normal \Tstrut\\
$\theta$ & & Parameter priors & user choice \Tstrut\\
$F_B$ & & F ballpark penalty & \Tstrut\\
$F_B$ & & $F$ ballpark penalty & \Tstrut\\
$C_P$ & & Crash Penalty & \Tstrut\Bstrut\\
\hline
\end{longtable}
Expand Down
Loading

0 comments on commit c9cbe37

Please sign in to comment.