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

possible bug in readFLSss3 with new version of SS (3.30.19) #7

Open
hgerritsen opened this issue May 2, 2022 · 12 comments
Open

possible bug in readFLSss3 with new version of SS (3.30.19) #7

hgerritsen opened this issue May 2, 2022 · 12 comments

Comments

@hgerritsen
Copy link

Hi
I upgraded to SS v 3.30.19.
When i used readFLSss3 i found that the catch.wt was incorrect in the FLStock object. I changed the argument wtatage to TRUE, which fixed the catch.wt problem but introduced a new problem with the m slot. Neither of them give a warning or an error. This problem did not occur with the previous version of SS.
My SS model has 1 season, 1 area, 2 commercial fleets and 2 sexes; I can provide the model files if it helps.

@iagomosqueira
Copy link
Member

Yes, getting the files would help. What version of r4ss is installed?

@kellijohnson-NOAA
Copy link
Collaborator

SS version 3.30.17.01 changed the parameter label from "NatM_p_1_Fem_GP_1" to "NatM_uniform_Fem_GP_1" which might be causing problems.

@iagomosqueira
Copy link
Member

Has r4ss changed to reflect this? ss3om takes it from SS_output$endgrowth.

@kellijohnson-NOAA
Copy link
Collaborator

Looks like endgrowth takes realized natural mortality, i.e., "Natural_Mortality", from the table of natural mortality values rather than the "parameter" so I think everything should be fine with respect to endgrowth.

@hgerritsen
Copy link
Author

Apologies, the problem is with maturity, not natural mortality. My bad. Will send my ss files tomorrow.

@hgerritsen
Copy link
Author

CheckreadLFSss3.zip
Attached are two sets of SS files, same model run in 30.3.18 and 30.3.19
Also a short script to compare the two.
I am using:
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2012 R2 x64 (build 9600)
ss3om_0.5.0 r4ss_1.43.0 FLCore_2.6.18

@hgerritsen
Copy link
Author

I think the wtatage argument might be a red herring. It does change the maturity slot but it does this consistently between versions of SS.
The immediate issue is the difference in catch.wt, landings.wt and discard.wt between SS versions when wtatage=FALSE (default value)

@iagomosqueira
Copy link
Member

Using current r4ss from github, the Mat_F_Natage column of the endgrowth data.frame comes up as character with some strange values when loading from version 19

s19<-r4ss::SS_output('SSv19/')
s19$endgrowth[, 'Mat_F_Natage']

shows

 [1] "9.14165e-050.5"    "0.0004234360.5"    "0.00284120.500309" "0.01628550.500413"

while it is loaded correctly for version 18.

All columns after this one are incorrect. Could it be some separator not being written properly?

I noticed the version 19 data.frame has an extra column, sex ratio, could this be causing it? Also, Is this column containing the sex ratio at birth?

@iagomosqueira
Copy link
Member

iagomosqueira commented May 4, 2022

There is no separation from row 2 between Mat_F_natage and sexratio, so rather than

9.14165e-05 0.5

it has

9.14165e-050.5

@kellijohnson-NOAA are you able to check if this is a problem in the writing section of the TPL?

Still looking if this is the reason for the ss3om error.

@kellijohnson-NOAA
Copy link
Collaborator

@iagomosqueira it very well could be a bug in SS3 I am compiling a new version now, which I will then use to run SS3 using the provided files to see if it fixes the output.

I also recommend reading the change log. Issues #136 and #283 might be relevant.

@iagomosqueira
Copy link
Member

Thanks, will check.

The error in catch.wt comes from the difference in endgrowth, the sel_wt columns are wrong in the version 19 run.

The difference in SSB comes from maturity when loading from wtatage. readFLSss3 substitutes maturity from Report.sso with the result of dividing fleet -2 in wtatage.ss with fleet -1. This is to be done only when a wtatage.ss file has been used, as determined by looking at SS_output$wtatage_switch. This might not be correct in this case when we force it to read it by calling readFLSss3 with wtatage=TRUE.

@iagomosqueira
Copy link
Member

Fixing the issue with sex ratio column separator, as in Report.sso.zip, makes the SS 19 FLStock equal to the SS 18, if loaded using wtatage=FALSE.

The difference in maturity when using wtwtage=TRUE comes from the disparity between what is taken from endgrowth when Maturity_option equals 1

data.table(ss19$endgrowth)[Sex == 1, `Mat*Fecund` / Wt_Beg]

and what is computed from wtatage.ss_new

wtage <- data.table(SS_readwtatage('SSv19/wtatage.ss_new'))

wtage[Sex == 1 & Yr == 1950 & Fleet==-2, 7:22] /
  wtage[Sex == 1 & Yr == 1950 & Fleet==-1, 7:22]

Happy to hear which one of the two is really correct. Should readFLSss3 always use wtatage.ss_new if available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants