Add gear argument to getYieldVsF() and plotYieldVsF() - #72
Open
gustavdelius wants to merge 1 commit into
Open
Conversation
When several gears catch the target species, `gear` selects the one whose fishing mortality is varied. Only that gear's catchability for the species is zeroed and taken over by the temporary gear whose effort is swept, so the fishing mortality that the other gears exert on the species is kept fixed and the returned `F` values refer to the selected gear alone. Without a `gear` the previous behaviour is retained (the fishing mortality from all gears on the species is replaced), but a message now points at the new argument when more than one gear catches the species. The species and gear checks now happen before the initial projection to steady state so that invalid arguments fail fast. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getYieldVsF()andplotYieldVsF()gain agearargument (defaultNULL) that selects which gear's fishing mortality is varied when several gears catch the target species. The fishing mortality that the other gears exert on that species is kept fixed, and theFvalues in the result then refer to the selected gear alone.Both functions already worked by adding a temporary gear whose effort is swept over
F_range; the change is in which gear-params rows get zeroed:geargiven: only the row for that gear/species pair is selected. Its catchability is set to 0 and the temporary gear inherits that gear's selectivity, so all other gears keep fishing the species unchanged.current_FMort, which decides whether the sweep works up or down from the current state, is that gear's contribution only.gear = NULL: unchanged behaviour (all gears catching the species are replaced), but a message now points at the new argument when more than one gear catches the species.Invalid gears and multi-element
gearvalues error out, and the species/gear checks were moved ahead of the initialprojectToSteady()call so bad arguments fail immediately rather than after a projection.plotYieldVsF()labels the x-axis "Fishing mortality from<gear>(1/yr)" when a gear is selected.Verification
Setting the temporary gear's effort to the selected gear's current F reproduces
getFMort(params)exactly (max abs difference 0), and doubling it changes only the target species' F — including when the selected gear also catches other species.New
tests/testthat/test-getYieldVsF.Rcovers the error paths, the multiple-gear message, and thatF = 0on one gear still gives a positive yield whileF = 0without a gear selection gives zero yield. 7 passing, ~11s. The one failure in the full suite (test-manipulateParams.R:68) is pre-existing onmaster.Note
getYieldVsF()is called withgearas the third positional argument now. A positional numericF_rangein third position raises a clear error rather than being silently misread.Unrelated pre-existing bug spotted but not touched:
yieldCalculator()indexesy[(ft - 30):ft, ]on non-convergence, which errors for smallt_max.🤖 Generated with Claude Code