Skip to content

Commit

Permalink
Merge pull request #474 from nmfs-stock-synthesis/466-allow-late-recd…
Browse files Browse the repository at this point in the history
…evs-to-be-expected-value-for-an-index

implement changes and warnings for recr surveys
  • Loading branch information
Rick-Methot-NOAA authored Jul 17, 2023
2 parents a9ce5a7 + 2a42a9d commit 98229c8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 67 deletions.
70 changes: 3 additions & 67 deletions SS_expval.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -334,38 +334,17 @@ FUNCTION void Get_expected_values(const int y, const int t);
}
case 31: // exp(recruitment deviation) #31
{
if (y >= recdev_start && y <= recdev_end)
{
vbio = mfexp(recdev(y));
}
else
{
vbio = 1.0;
}
vbio = mfexp(recdev(y));
break;
}
case 36: // recruitment deviation #36
{
if (y >= recdev_start && y <= recdev_end)
{
vbio = recdev(y);
}
else
{
vbio = 0.0;
}
vbio = recdev(y);
break;
}
case 32: // recruitment without density-dependence (for pre-recruit survey) #32
{
if (y >= recdev_start && y <= recdev_end)
{
vbio = SSB_current * mfexp(recdev(y));
}
else
{
vbio = SSB_current;
}
vbio = SSB_current * mfexp(recdev(y));
break;
}
case 33: // recruitment #33
Expand Down Expand Up @@ -439,49 +418,6 @@ FUNCTION void Get_expected_values(const int y, const int t);
}

// SS_Label_Info_46.1.1 #note order of operations, vbio raised to a power, then constant is added, then later multiplied by Q. Needs work
/*
// old code here
switch (Q_setup(f,1)) // switch is based on the link type: (1=simple q; 2=mirror; 3=q and power; 4=mirror with offset in q)
{
case 2:
{
// no break, so do same as case 1
}
case 4:
{
// no break, so do same as case 1
}
case 1:
{
if(Q_setup(f,5)==1 && y<=endyr) // float Q will be calculated and applied in objfun section, so temporarily store vbio in svy_est.
// note that if y is in forecast, then Q has already been calculated so can be applied in the else clause here
{
if(Svy_errtype(f)>=0) // lognormal or T-distribution
{Svy_est(f,j)=log(vbio+0.000001);}
else
{Svy_est(f,j)=vbio;}
}
else // Q based on parameters, or in forecast so Q has already been calculated through float approach in the objfun
{
if(Svy_errtype(f)>=0) // lognormal or T-distribution
{Svy_est(f,j)=log(vbio+0.000001)+Svy_log_q(f,j);}
else
{Svy_est(f,j)=vbio*Svy_q(f,j);}
}
break;
}
case 3: // link is power function
{
vbio=pow(vbio,1.0+Q_parm(Q_setup_parms(f,1)+1)); // raise vbio to a power
if(Svy_errtype(f)>=0) // lognormal or T-distribution
{Svy_est(f,j)=log(vbio+0.000001)+Svy_log_q(f,j);}
else
{Svy_est(f,j)=vbio*Svy_q(f,j);}
break;
}
}
*/

if (Q_setup(f, 1) == 3) // link is power function
{
vbio = pow(vbio, 1.0 + Q_parm(Q_setup_parms(f, 1) + 1));
Expand Down
15 changes: 15 additions & 0 deletions SS_readcontrol_330.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,21 @@
ParmLabel += "Impl_err_" + onenum + CRLF(1);
}
}

// check recdev start and end against survey year start and end
for (f = 1; f <=Nfleet; f++) {
if (Svy_units(f) == 31 || Svy_units(f) == 32 || Svy_units(f) == 33 || Svy_units(f) == 36) { // select just recruitment surveys
if (Svy_styr(f) < recdev_first) {
warnstream << "Recruitment survey: " << f << " has data in: " << Svy_styr(f) << ", which is before first early recdev: " << recdev_first << ". Suggest start recdevs earlier";
write_message (SUGGEST, 0);
}
if (Svy_endyr(f) > recdev_end && Fcast_recr_PH_rd <=0 ) {
warnstream << "Recruitment survey: " << f << " has data in: " << Svy_endyr(f) << ", which is after last main recdev: " << recdev_end << ". Suggest extend recdev_end, or use pos. phase for fore_recruitments: " << Fcast_recr_PH_rd;
write_message (SUGGEST, 0);
}
}
}

}

biasadj_full.initialize();
Expand Down
2 changes: 2 additions & 0 deletions SS_readdata_330.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,8 @@
Svy_styr(f) = y; // for dimensioning survey q devs
if (Svy_endyr(f) == 0 || (y <= endyr && y > Svy_endyr(f)))
Svy_endyr(f) = y; // for dimensioning survey q devs

// Svy_styr and Svy_endyr for recruitment surveys will be checked against recdev start and end in readcontrol
if (y >= styr && Svy_data[i](3) > 0)
{
Svy_minval(f) = min(Svy_minval(f), Svy_obs(f, j));
Expand Down

0 comments on commit 98229c8

Please sign in to comment.