Skip to content
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

Merged
merged 56 commits into from
Jan 27, 2025
Merged

Extracting more key quantities #42

merged 56 commits into from
Jan 27, 2025

Conversation

sbreitbart-NOAA
Copy link
Collaborator

@sbreitbart-NOAA sbreitbart-NOAA commented Jan 13, 2025

  • Extracting more key quantities
  • Updating the captions/alt text csv
  • Making a function in utils.R (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.

sbreitbart-NOAA and others added 22 commits January 10, 2025 14:07
…how to extract more key quantities from model results. Some key quantities were deleted. Alt text/caps csv updated in accordance with changes.
…how to extract more key quantities from model results. Some key quantities were deleted. Alt text/caps csv updated in accordance with changes.
…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
pop.naa.baa.end.year <- landings.end.year

# minimum number of fish
pop.naa.baa.fish.min <- dat |>
Copy link
Collaborator Author

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.

Copy link
Collaborator

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

pop.naa.baa.fish.min <- dat |>
dplyr::filter(label == "abundance") |>
dplyr::group_by(year) |>
dplyr::summarize(val = max(estimate)) |>
Copy link
Collaborator

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)

Copy link
Collaborator

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?

Copy link
Collaborator Author

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)
@sbreitbart-NOAA sbreitbart-NOAA marked this pull request as ready for review January 27, 2025 16:04
### 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?,)"),
Copy link
Collaborator

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator

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

vignettes/manual.Rmd Outdated Show resolved Hide resolved
vignettes/manual.Rmd Outdated Show resolved Hide resolved
Copy link
Collaborator

@Schiano-NOAA Schiano-NOAA left a 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.

sbreitbart-NOAA and others added 2 commits January 27, 2025 14:36
@sbreitbart-NOAA
Copy link
Collaborator Author

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.

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.

@sbreitbart-NOAA sbreitbart-NOAA merged commit 0e675fc into master Jan 27, 2025
8 checks passed
@sbreitbart-NOAA sbreitbart-NOAA deleted the key-quants-2 branch January 29, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants