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

Change how unsexed and sexed fish are included for biomass apportionment #183

Closed
brandynlucca opened this issue Feb 26, 2024 · 5 comments · Fixed by #241
Closed

Change how unsexed and sexed fish are included for biomass apportionment #183

brandynlucca opened this issue Feb 26, 2024 · 5 comments · Fixed by #241
Assignees
Labels
bug_in_python Something in the Python implementation does not match what's in Matlab documentation Improvements or additions to documentation high_priority tracking_issue

Comments

@brandynlucca
Copy link
Collaborator

When calculating the sex proportions of fish from stations 1 and 2, the current main branch sums the sexed (i.e. male and female) fish from station 2 and all fish from station 1 (i.e. male, female, and unsexed).

https://github.com/uw-echospace/EchoPro/blob/93f0dcfea5cab6949c7d110eb0016014fbbcfcd0/EchoPro/computation/transect_results.py#L420-L426

This implementation did not seem to be correct. However, there were some ambiguities in the Matlab source code that made discerning the correct implementation difficult. After meeting with Chu, we have gained some clarity on both the Matlab implementation as well as the intention/rationale behind the calculation. Consequently, the updated working branch implementation may be incorrect.

https://github.com/uw-echospace/EchoPro/blob/2157de885498f6b6d951ccee85ed7a6dfb8818ba/EchoPro/survey.py#L646-L652

Notably, the intent of this processing is to:

  1. Calculate male-to-female ratio
  2. Calculate the sexed-to-unsexed ratio
  3. Sum the total biomass across indices (e.g. stratum_num)
  4. Apply male-to-female sex ratio to the total unsexed biomass
  5. Apportion the total sexed biomass into male and female

Therefore, changes are likely required for the initial sex proportion calculations:

https://github.com/uw-echospace/EchoPro/blob/2157de885498f6b6d951ccee85ed7a6dfb8818ba/EchoPro/survey.py#L591-L764

This then may necessitate changes in how the sexed and unsexed proportioned biomasses are calculated:

https://github.com/uw-echospace/EchoPro/blob/2157de885498f6b6d951ccee85ed7a6dfb8818ba/EchoPro/survey.py#L870-L1007

Lastly, the appropriate documentation explaining both the scientific rationale/context and mathematical equations (i.e. within the related ReadTheDocs) will provide clarity on what the software is specifically doing at this step.

@brandynlucca brandynlucca added bug_in_python Something in the Python implementation does not match what's in Matlab documentation Improvements or additions to documentation high_priority tracking_issue labels Feb 26, 2024
@brandynlucca brandynlucca self-assigned this Feb 26, 2024
@leewujung leewujung self-assigned this Mar 31, 2024
@leewujung
Copy link
Member

I think after the last couple weeks we've resolved this issue fully with the new doc page on biomass apportioning.

@brandynlucca : let me know if you think we should keep this open for any reason. I think we should treat abundance apportioning as a separate issue, since it's tracked in #217.

@brandynlucca
Copy link
Collaborator Author

@leewujung: I need to comb through the transect analysis portion of the code to make a few adjustments (and validate) toward how unsexed fish are handled. This is a parallel issue, I suppose, with both the transect analysis and kriging apportionment. Now that we have a better grasp of the intent and calculations, this should be a pretty quick read-through and change that I can incorporate into a separate PR.

@leewujung
Copy link
Member

Sounds good. Thanks!

@brandynlucca
Copy link
Collaborator Author

As discussed with PR #215, documentation is needed to make it clear where unsexed fish are relevant (e.g. calculating the length-weight regressions).

@brandynlucca brandynlucca moved this from Ready to In review in Echopop May 23, 2024
@brandynlucca
Copy link
Collaborator Author

The main thinking behind this issue can be attributed to some confusion arising from how the EchoPro code was originally written and trying to identify why average weights per stratum (for each sex and overall) and length/age bins were difference between EchoPro and echopop.

After discussions with FEAT and the updated implementation in PR #241, the treatment of male/female/unsexed fish from both stations (1: unaged; 2: aged) has been updated to match the original EchoPro code concerning the calculation of the normalized weight fractions. The result is that the sex-specific echopop average stratum weights (and average weights per length and age bin) are not identical to those from EchoPro due to differences in how the length-weight regressions are derived for each sex. In EchoPro, unsexed fish are included alongside females for the female-specific length-weight linear relationship while only males are included for the male-specific relationship. The echopop implementation does not include unsexed fish when fitting the length-weight regressions for male and female fish.

This can be closed once PR #241 is closed.

@github-project-automation github-project-automation bot moved this from In review to Done in Echopop Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug_in_python Something in the Python implementation does not match what's in Matlab documentation Improvements or additions to documentation high_priority tracking_issue
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants