gadget-framework / gadget3

TMB-based gadget implemtation
GNU General Public License v2.0
8 stars 6 forks source link

fleet specification in abundancedistributions #93

Closed willbutler42 closed 1 year ago

willbutler42 commented 1 year ago

Providing a fleet to g3l_abundancedistribution currently leads to an error. However, a fleet can be set up to 'catch' an index of abundance in which case providing a fleet to g3a_abundancedistribution would be required for the comparison with data. For instance, comparing cpue data against the consumption of an effortfleet that catches a very small amount of the total biomass each time step:

survey %>% 
      g3a_predate_fleet(..., catchability_f = g3a_predate_catchability_effortfleet(catchability_fs = ~1e-06, E = ~sum(stock__wgt * stock__num)))

and g3a_abundancedistribution(..., fleets = list(survey), ...)

lentinj commented 1 year ago

A little secret: g3a_abundancedistribution and g3a_catchdistribution are actually the same function:-

https://github.com/gadget-framework/gadget3/blob/7005f13587347c8897988015439002781f1be096/R/likelihood_distribution.R#L415-L416

The only difference is whether you provide fleets or not:-

https://github.com/gadget-framework/gadget3/blob/7005f13587347c8897988015439002781f1be096/R/likelihood_distribution.R#L210-L211

So using g3a_catchdistribution in the above should do exactly what you want. I guess this then makes somewhat non-obvious code, since it's not really catch at all. However, I think this started when we had a survey "fleet".

Maybe what needs to be done here is adding some kind of transform option for g3a_abundancedistribution() to do the work that the survey fleet is currently doing, so you don't need that fleet.

willbutler42 commented 1 year ago

Ah, sorry should have checked the code a bit more thoroughly! Its working as anticipated now.