Repository navigation
Fix(#87): add box-level discard and rec-catch tracers once per box - #91
Open
jacobkasper wants to merge 1 commit into
Open
jacobkasper wants to merge 1 commit into
jacobkasper wants to merge 1 commit into
Conversation
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.
Justification
Fixes #87.
Problem. Discards in
OutTOTCATCH.nc(Tot_*_Discards) andOutCATCH.nc(*_Discard_FC*) are overstated relative toOutDiscard.txt. In our model, haddock (FHA) discards in the NetCDF output are about 44% too high in every year.Tot_*_RecCatchis built the same way and is affected by the same mechanism. These tracers are output only, so model dynamics are unaffected, but anyone reading discards or recreational catch from the NetCDF files (for example in R post-processing) gets inflated values that don't match the text outputs.Cause.
Harvest_Update_Total_Catch(atHarvest.c) is called once per water-column layer (fromWater_Column_Box) and again fromEpibenthicBox. The catch tracers readbm->Catch[box][sp][nf][layer], which is layer-indexed, so adding them per layer is correct. Butbm->Discards[box][sp][nf]andbm->RecCatch[box][sp][nf]have no layer index: they accumulate as the box's layers are processed, and the running box total is added to the tracers at every layer call. The inflation factor lies between 1 and the number of layers in the box, depending on how discards are distributed vertically.Fix. The tracer loop is split in two:
CaughtByFisheryTracers,totCatchTracer) are still added per layer, exactly as before;DiscardedByFisheryTracers,totDiscardsTracer,totRecCatchTracer) are added once per box: at layer 0 in the water-column call, which is the last layer processed (the existing effort-tracer block relies on the same fact,if (!bm->current_layer && (habitat == WC))), and for epibenthic invertebrates (non-vertebrate,habitatType != WC) in theEPIFAUNAcall.Only output tracers change.
Evidence
OutDiscard.txtis written fromCatchSum[sp][tscodiscard_id], which receives exactly the same increments asbm->Discards(inHarvest_Do_Fishing_And_ByCatchand in the dependent-discards code inatecology.c), so it is a valid reference.FHA,
Tot_FHA_Discardssummed over boxes divided byOutDiscard.txt, 800-day runs ondev(d693861):The "before" run was
devwith #86 applied, which changes only theOutCatchPerFishery.txtaccounting and doesn't touch these tracers. An earlier 10-year run onmain(ab323c7) gave 1.441–1.447 in every year before the change and 1.000 in every year after it. That also confirms layer 0 is processed last in each box; otherwise the ratio would fall below 1.The catch tracers are unaffected: the largest difference between
Tot_*_Catch(summed over boxes) andOutCatch.txt, over all species and years, is 4.7e-7 t in both builds, which is the print precision ofOutCatch.txt.OutCatch.txtandOutDiscard.txtare identical between the two builds.Not tested
Related, not changed here
Avg_Catch_Sze_FC*has the long name "Total effort of fishery ...", copied from the effort variable.OutRecCatch.txtis built frombm->TotCumRecCatch, whichHarvest_Init_Box_Arraysfills withbm->TotCumRecCatch[sp][ij] += bm->RecCatch[ij][sp][ij];inside a loop over fisheriesn, i.e. using the box indexijin both fishery slots. If the second dimension ofTotCumRecCatchis fisheries (as its summation inwriteAnnCatchimplies), then for any recreational fishery this reads and writes out of bounds for boxes ≥K_num_fisheries. Possibly worth its own issue.Types of changes
Further comments
No change to inputs, parameters or intended behaviour; the NetCDF discard and rec-catch output now agrees with the text outputs.
Reviewer instructions:
dev.tstop 800 day, withtoutstart,toutincandtoutfincat365 day.diff <dev_run>/OutCatch.txt <branch_run>/OutCatch.txtand the same forOutDiscard.txtshould both report no differences.Expected:
dev: ratios above 1 for species with discards (about 1.44 for FHA in our model; the factor depends on each species' vertical distribution).Reviewers with a model that has fished invertebrates with discards, or a recreational fishery, could usefully run the same check, since those branches couldn't be tested here.