-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extracting more key quantities #42
Conversation
…ed after replace function is run
…how to extract more key quantities from model results. Some key quantities were deleted. Alt text/caps csv updated in accordance with changes.
…cluding reference points
…how to extract more key quantities from model results. Some key quantities were deleted. Alt text/caps csv updated in accordance with changes.
…cluding reference points
…text/caps template to facilitate regex pattern recognition
…fied in plot_spawn_recruitment, and added add_more_key_quants to plot_spawn_recruitment
…en if some args are NULL -updated write_captions to explain which key quantities will be substituted with add_more_key_quants
… quantities coding in write_captions
R/write_captions.R
Outdated
pop.naa.baa.end.year <- landings.end.year | ||
|
||
# minimum number of fish | ||
pop.naa.baa.fish.min <- dat |> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Schiano-NOAA did I code pop.naa.baa.fish.min and max correctly? Would you mind checking with a ss3 file? I'm going to check all the key quantities with a bam file tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does pop.naa.baa.fish stand for? If you are just looking for the number of fish, then the baa (biomass-at-age?) doesn't need to be added and isn't the correct naming convention.
See my comment for changes to the code
…en if some args are NULL -updated write_captions to explain which key quantities will be substituted with add_more_key_quants
… quantities coding in write_captions
…rror with rebasing?)
R/write_captions.R
Outdated
pop.naa.baa.fish.min <- dat |> | ||
dplyr::filter(label == "abundance") |> | ||
dplyr::group_by(year) |> | ||
dplyr::summarize(val = max(estimate)) |> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is truly "at-age" data then this should be sum(estimate)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbreitbart-NOAA Was this fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah- we discussed this at our team meeting last week and found a solution together
…e model results (SS3 & BAM). Also added code to replace NA values with "NA" so that placeholders in captions and alt text are still updated accurately (instead of the entire caption/alt text being changed to NA)
### this regex preserves the comma after the end year | ||
topic_cap_alt <- topic_cap_alt |> | ||
dplyr::mutate(alt_text = stringr::str_replace_all(alt_text, | ||
stringr::regex("(\\S*end\\.year\\S*)(?=\\s?,)"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever I use the str_replace_all fxn, I haven't identified the regex as one using the regex() function. Have you found this is necessary for the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested another regex option without stringr::regex. Would you recommend something different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I gotcha. I was just curious because I haven't had any issues with just using a regex there without making it explicit through that function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I think we should chat about the manual more and discuss/walkthrough how users would make changes to alt text after already generating them.
Co-authored-by: Sam Schiano <[email protected]>
Co-authored-by: Sam Schiano <[email protected]>
Thanks- will merge. Happy to chat more about the manual and workflow for changing alt text/captions after they're generated- will add to our meeting agenda. |
add_more_key_quants
) that extracts key quantities outside of write_captions, because some variables need to be indicated by the user as arguments in individual plotting functions and can't be extracted from the model results file. Instead, these extra key quantities (some units, end years, and reference points) need to be manipulated with a different process.Since this is a large PR, I'll relegate certain tasks to other PRs (e.g., #44 & #46). Also, some key quantities are proving challenging to extract for both SS3 and BAM, so those will remain commented until they are resolved in the future.