nmfs-ost / ss3-source-code

The source code for Stock Synthesis (SS3).
https://nmfs-ost.github.io/ss3-website/
Creative Commons Zero v1.0 Universal
36 stars 16 forks source link

add warning when addtocomp is not > 0 #555

Closed iantaylor-NOAA closed 6 months ago

iantaylor-NOAA commented 7 months ago

Concisely describe what has been changed/addressed in the pull request.

A "nan" likelihood in model shared by @akatan999 took some time to debug (traced to age comp likelihoood, then to rows with zero observations for some bins, then to 0 values for addtocomp settings). It's hard to imagine anyone wanting the addtocomp to be zero, so adding a warning when this occurs will make debugging this easier.

What tests have been done?

Compiled and run on the model that was shared which now produces these warnings:

Warning 1 : addtocomp input for age comps fleet 1 is 0 but should be > 0 to avoid log(0) in likelihood
Warning 2 : addtocomp input for age comps fleet 2 is 0 but should be > 0 to avoid log(0) in likelihood

What tests/review still need to be done?

Review by @Rick-Methot-NOAA to confirm that this was done correction and should be a warning and not an stop. Also, it could be possible to only warn if there are zero values in the observed or expected comps after addition of addtocomp but that would be more challenging to implement. Lastly, I'm not clear on the second argument to write_message(WARN, 0), so would be good to get confirmation that this shouldn't be write_message(WARN, 1) instead.

Is there an input change for users to Stock Synthesis?

e-perl-NOAA commented 6 months ago

See PR #215 in ss3-doc repo.

e-perl-NOAA commented 6 months ago

@iantaylor-NOAA do you mind if I go ahead and merge this?

iantaylor-NOAA commented 6 months ago

Thanks @e-perl-NOAA, I forgot that we have often been having the creator of the PR do the merging.