thefaylab / hydra_sim

Code-base for the hydra multispecies simulation model
2 stars 0 forks source link

changes to .dat & .pin files for selectivity #20

Open gavinfay opened 2 years ago

gavinfay commented 2 years ago

@sgaichas there are some new changes to the .dat & .pin files as a result of implementing selectivity estimation for both fishing fleets and surveys.

.dat

  1. Selectivity parameter vectors removed (fishsel_c & fishseld_d)
  2. Phase inputs added for estimation of selectivity (fsphase = fishery sel, ssphase = survey selectivity)

.pin

  1. added fishery selectivity parameter matrix fishsel_pars(1,2,1,Nfleets). The first dimension corresponds to the implemented 'c' & 'd' parameters for each fleet for the logistic selectivity at length.
  2. added survey selectivity parameter matrix survey_selpars(1,2,1,Nsurveys). The first dimension corresponds to the 'c' & 'd' parameters for each survey for the logistic selectivity at length. (implemented the same way as Andy had coded for fishery selectivity)

The implemented changes can be viewed in the current hydra_sim_NOBA.dat and nu.pin files.

sgaichas commented 2 years ago

@gavinfay I am writing out the structure of new .dat and .pin files as specified. See functions hydradata::create_RData_mskeyrun() and updated hydradata::create_datpin_files.R

One question: Is it correct that the current values in nu.pin for ln_fishery_q and ln_survey_q are from a previous estimation run? My current code starts them off as 0s for the pin file.

Related question: I currently calculate an input ln_avgF by summing all the input catches and dividing by the sum of input biomass across the species in each fleet. This results in slightly different values than in the current nu.pin. I could instead just hardcode the current values in.

I will generate separate files so I don't overwrite values in nu.pin. If these are not from a previous estimation run but are derived from a combination of inputs, please let me know what you used and I can code that up.

New input files will appear first on the sarah branch, with filenames indicating the number of bins--all else will be the same between them.

Edit: new files are there now and currently testing to fix matrix out of bounds errors etc...

gavinfay commented 2 years ago

@sgaichas Thanks! nu.pin was created from a .par file, so none of it was based on combos of inputs. Mainly just so I had something that was the right format. ln_avgF would be the log of the average F for the primary species for each fleet, so an initial value of. -log(1-u) where u = catch / biomass averaged over stocks makes sense as a starting point to me, given that the other species are modeled as offsets to the primary.

sgaichas commented 2 years ago

Was hoping to close this, but only halfway there.

The 5 bin and 10 bin .dat, -ts.dat, and .pin files generated by hydradata all result in completed model runs. On branch sarah I have these inputs, results of these runs saved in results/05bin and results/10bin folders. The hydradatalist files corresponding to these inputs are in the folder inputRdatalists. I haven't had a chance to compare any results yet, just happy they completed the runs. :-)

Note that these inputs differ from the ones we had before in using Atlantis-derived stomach weight matrices rather than GB values mapped to NOBA species.

I also generated 15 and 20 bin inputs, which did not complete runs. Both have an issue in the catch portion. Console output is pasted here just so I remember it:

NECLNASARAHMAC:hydra_sim sarah.gaichas$ sh run-hydra.sh
q par map
7
 1 7
 1 2 1
 1 3 1
 1 4 1
 1 6 1
 1 8 1
 1 10 1
 1 11 1
1701
completed predicted values for surveys
starting commercial catch nll
Error: Invalid index 25389 used for array range [1, 1] in "prevariable& dvar4_array::operator() (int i, int j, int k)".
hslice index out of bounds

q par map
7
 1 7
 1 2 1
 1 3 1
 1 4 1
 1 6 1
 1 8 1
 1 10 1
 1 11 1
1701
completed predicted values for surveys
starting commercial catch nll
Error: Invalid index 25389 used for array range [1, 1] in "prevariable& dvar4_array::operator() (int i, int j, int k)".
hslice index out of bounds

Will diagnose as possible tomorrow...