Skip to content

Commit aac9fa2

Browse files
more adjustments to season duration usage
1 parent c19da3c commit aac9fa2

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

SS_biofxn.tpl

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ FUNCTION void get_growth2(const int y)
457457
// SS_Label_Info_16.2.4.1.1 #if y=styr, get size-at-age in first subseason of first season of this first year
458458
// VBK_seas(0) is the sum of all the season durations * seasonal K adjustments. Normally it has a value of 1.0
459459
// but for seasons-as-years, it will be the value equal to the selected duration of the single season
460-
// Ave_Size(styr, 1, g)(0, first_grow_age(g)) = Lmin(gp);
461460
if (y == styr)
462461
{
463462
switch (Grow_type)
@@ -509,7 +508,6 @@ FUNCTION void get_growth2(const int y)
509508
// L0 (mean length at age 0)
510509
// Linf (asymptotic mean length)
511510
// k (steepness of the logistic function that models the reduction in the growth increment) = Richards
512-
// Ave_Size(styr, 1, g)(0, first_grow_age(g)) = Lmin(gp); //assume first_grow_age(g) = 0
513511
for (a = 0; a <= nages; a++)
514512
{
515513
Ave_Size(styr, 1, g, a) = Lmin(gp) + -VBK_work * VBK_seas(0) * ((log(exp(-Richards(gp) * t50) + 1) - log(exp(Richards(gp) * (real_age(g, 1, a) - AFIX - t50)) + 1)) / Richards(gp) + real_age(g, 1, a) - AFIX);
@@ -588,7 +586,7 @@ FUNCTION void get_growth2(const int y)
588586
add_age = 0; // advance age or not
589587
// growth to next season
590588
VBK_by_seas = (mfexp(VBK_work * VBK_seas(s) * seasdur(s) ) - 1.0); // for use inside the growth equation
591-
if (do_once == 1) echoinput<<"ready to update growth by season " << y << " VBK_w " << VBK_work << " seas " << VBK_seas(s) << " byseas " << VBK_by_seas << endl << " lingrow " <<lin_grow << endl;
589+
// if (do_once == 1) echoinput<<"ready to update growth by season " << y << " s " << s << endl;
592590
switch (Grow_type)
593591
{
594592
case 1: // standard von Bertallanfy - seasonal growth
@@ -626,13 +624,16 @@ FUNCTION void get_growth2(const int y)
626624
}
627625
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
628626
{
629-
Ave_Size(t + 1, 1, g, k2) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK_work * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
630-
echoinput<<" age: "<<k2<<" Lmin "<<Cohort_Lmin(gp, y, a)<<" time: "<<real_age(g, ALK_idx2, k2) - AFIX << " " <<Ave_Size(t + 1, 1, g, k2) <<endl;
627+
Ave_Size(t + 1, 1, g, k2) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK_work * sumseas_yr * VBK_seas(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
631628
}
632629
else // in linear phase
633630
{
634631
Ave_Size(t + 1, 1, g, k2) = len_bins(1) + lin_grow(g, ALK_idx, a) * (Cohort_Lmin(gp, y, a) - len_bins(1));
635632
}
633+
// if (a < 4 && g == 1 && y <= styr+1) warning << y << " s: " << s <<" ALKidx: " << ALK_idx <<" "<<ALK_idx2<< " a: " << a <<" real_a: "<<real_age(g, ALK_idx2, k2)<< " lin: " << lin_grow(g, ALK_idx, a) << " "<< Ave_Size(t, 1, g, a) <<
634+
// " first " << Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK_work * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a)<<
635+
// " grow " << Ave_Size(t, 1, g, a) + VBK_by_seas * t2 * Cohort_Growth(y, a) <<
636+
// " new " << Ave_Size(t + 1, 1, g, k2)<< endl;
636637
} // done ageloop
637638
break;
638639
}
@@ -660,7 +661,7 @@ FUNCTION void get_growth2(const int y)
660661
}
661662
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
662663
{
663-
temp = LminR + (LminR - LinfR) * (mfexp(VBK_work * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
664+
temp = LminR + (LminR - LinfR) * (mfexp(VBK_work * sumseas_yr * VBK_seas(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
664665
Ave_Size(t + 1, 1, g, k2) = pow(temp, inv_Richards);
665666
}
666667
else // in linear phase for subseas
@@ -726,7 +727,7 @@ FUNCTION void get_growth2(const int y)
726727
}
727728
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
728729
{
729-
Ave_Size(t + 1, 1, g, k2) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, a) * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
730+
Ave_Size(t + 1, 1, g, k2) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, a) * sumseas_yr * VBK_seas(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
730731
}
731732
else // in linear phase
732733
{
@@ -744,32 +745,30 @@ FUNCTION void get_growth2(const int y)
744745
if (plusgroupsize_update == 0) // Linf_decay == -998.
745746
{
746747
Ave_Size(t + 1, 1, g, nages) = Ave_Size(t, 1, g, nages);
747-
if (do_once == 1 && timevary_MG_firstyr == y)
748+
if (do_once == 999 && timevary_MG_firstyr == y)
748749
{
749750
warnstream << "plus group mean size is carried forward and NOT being updated for time-varying growth for sex: " << sx(g) << ". Suggest setting Linf_decay = -997, or to a pos. value that approximates Z in the initial year for the plus group";
750751
write_message (WARN, 0);
751752
}
752753
}
753754
else // Linf_decay == -997 or a positive Linf_decay is used in initial year growth
754755
{
755-
if (do_once == 1 && timevary_MG_firstyr == y && g == 1)
756+
if (do_once == 999 && timevary_MG_firstyr == y && g == 1)
756757
{
757758
warnstream << "plus group mean size is updated in years with time-vary growth beginning in: " << y << "; can turn this off with Linf_decay = -998";
758759
write_message (NOTE, 0);
759760
}
760761
temp = ((natage(t, 1, g, nages - 1) + 0.01) * Ave_Size(t + 1, 1, g, nages) + (natage(t, 1, g, nages) + 0.01) * plusgroupsize) / (natage(t, 1, g, nages - 1) + natage(t, 1, g, nages) + 0.02);
761-
if (do_once == 1 && g == 1) // show calculation once
762+
if (do_once == 999 && g == 1) // show calculation once
762763
echoinput << " Year: " << y << " +group calc: "
763764
<< " N _entering: " << natage(t, 1, g, nages - 1) << " N_in_+group: " << natage(t, 1, g, nages) << " size in: " << Ave_Size(t + 1, 1, g, nages) << " old +size: " << plusgroupsize << " "
764765
<< " new_+size " << temp << endl;
765766
Ave_Size(t + 1, 1, g, nages) = temp;
766767
}
767768
}
768769
769-
#ifdef DO_ONCE
770770
if (do_once == 1)
771-
echoinput << " seas: " << s << " size@t+1: " << Ave_Size(t + 1, 1, g)(0, min(6, nages)) << " plusgroup: " << Ave_Size(t + 1, 1, g, nages) << endl;
772-
#endif
771+
echoinput << y << " G2+ seas.sub: " << s << "." << 1 <<" g:" << g <<" size: " << Ave_Size(t + 1, 1, g)(0, min(6, nages)) << " plusgroup: " << Ave_Size(t + 1, 1, g, nages) << endl;
773772
} // end of season
774773
775774
/*
@@ -842,7 +841,7 @@ FUNCTION void get_growth3(const int y, const int t, const int s, const int subse
842841
// NOTE: there is no seasonal interpolation, age-specific K uses calendar age, not real age. Maybe someday....
843842
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
844843
{
845-
Ave_Size(t, subseas, g, a) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, 0) * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx, a) - AFIX)) - 1.0) * Cohort_Growth(y, a);
844+
Ave_Size(t, subseas, g, a) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, 0) * sumseas_yr * VBK_seas(s) * (real_age(g, ALK_idx, a) - AFIX)) - 1.0) * Cohort_Growth(y, a);
846845
}
847846
}
848847
break;
@@ -873,7 +872,7 @@ FUNCTION void get_growth3(const int y, const int t, const int s, const int subse
873872
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
874873
{
875874
// temp=Cohort_Lmin(gp,y,a) + (Cohort_Lmin(gp,y,a)-LinfR)*
876-
temp = LminR + (LminR - LinfR) * (mfexp(VBK(gp, 0) * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx, a) - AFIX)) - 1.0) * Cohort_Growth(y, a);
875+
temp = LminR + (LminR - LinfR) * (mfexp(VBK(gp, 0) * sumseas_yr * VBK_seas(s) * (real_age(g, ALK_idx, a) - AFIX)) - 1.0) * Cohort_Growth(y, a);
877876
Ave_Size(t, subseas, g, a) = pow(temp, inv_Richards);
878877
}
879878
} // done ageloop
@@ -923,16 +922,14 @@ FUNCTION void get_growth3(const int y, const int t, const int s, const int subse
923922
// NOTE: there is no seasonal interpolation, age-specific K uses calendar age, not real age. Maybe someday....
924923
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
925924
{
926-
Ave_Size(t, subseas, g, a) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, a) * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx, a) - AFIX) ) - 1.0) * Cohort_Growth(y, a);
925+
Ave_Size(t, subseas, g, a) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, a) * sumseas_yr * VBK_seas(s) * (real_age(g, ALK_idx, a) - AFIX) ) - 1.0) * Cohort_Growth(y, a);
927926
}
928927
}
929928
break;
930929
}
931930
} // done switch
932-
#ifdef DO_ONCE
933-
if (do_once == 1)
934-
echoinput << " seas.subseas: " << s << "." << subseas <<" g:" << g <<" size: " << Ave_Size(t, subseas, g)(0, min(6, nages)) << " plusgroup: " << Ave_Size(t + 1, 1, g, nages) << endl;
935-
#endif
931+
if (do_once == 1)
932+
echoinput << y << " G3 seas.sub: " << s << "." << subseas <<" g:" << g <<" size: " << Ave_Size(t, subseas, g)(0, min(6, nages)) << " plusgroup: " << Ave_Size(t + 1, 1, g, nages) << endl;
936933
} // end need this platoon
937934
} // done platoon
938935
} // end calc size-at-age at a particular subseason

SS_readcontrol_330.tpl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,6 @@
896896
// SO! there needs to be an additional option to update the plus group mean size even if growth is not time-varying
897897
// but this should be implemented in popdyn, not in biofxn to avoid having to update calculations for all ages
898898
int do_ageK;
899-
ivector first_grow_age(1,gmorph);
900-
!! first_grow_age.initialize();
901899
!! k=0;
902900
!! do_ageK=0;
903901
!! if(Grow_type<=2 || Grow_type==8) {k=4;} // AFIX and AFIX2
@@ -981,7 +979,7 @@
981979
N_M_Grow_parms = N_natMparms + N_growparms;
982980
lin_grow.initialize();
983981

984-
echoinput << "g a seas subseas ALK_idx real_age calen_age lin_grow first_grow_age setfirstgrow" << endl;
982+
echoinput << "g a seas subseas ALK_idx real_age calen_age lin_grow" << endl;
985983
for (g = 1; g <= gmorph; g++)
986984
if (use_morph(g) > 0)
987985
{
@@ -1006,7 +1004,6 @@
10061004
{
10071005
lin_grow(g, ALK_idx, a) = -1.0; // flag for first age on growth curve beyond AFIX
10081006
if (subseas == N_subseas) {
1009-
first_grow_age(g) = a;
10101007
setfirstgrowage = a;
10111008
} // so that lingrow will be -1 for rest of this season
10121009
}
@@ -1016,7 +1013,7 @@
10161013
} // flag for being in growth curve
10171014

10181015
if (a < 4) echoinput << g << " " << a << " " << s << " " << subseas << " " << ALK_idx << " " << real_age(g, ALK_idx, a)
1019-
<< " " << calen_age(g, ALK_idx, a) << " " << lin_grow(g, ALK_idx, a) << " " << first_grow_age(g) << " " << setfirstgrowage << endl;
1016+
<< " " << calen_age(g, ALK_idx, a) << " " << lin_grow(g, ALK_idx, a) << endl;
10201017
}
10211018
}
10221019
}

SS_readdata_330.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
int eq_yr;
9393
int bio_yr;
9494
number sumseas;
95+
number sumseas_yr; // sum of season durations in nits of years.
9596

9697
// SS_Label_Info_2.1.3 #Set up seasons
9798
vector seasdur_half(1,nseas); // half a season
@@ -107,12 +108,14 @@
107108
seasdur /= sumseas;
108109
seas_as_year = 0;
109110
sumseas = 12.0; // to be sure it is exactly 12.
111+
sumseas_yr = 1.0;
110112
}
111113
else
112114
{
113115
seasdur /= 12.;
114116
seas_as_year = 1;
115-
// sumseas will now be used as the duration of the pseudo-year, rather than assuming year has 12 months;
117+
sumseas_yr = sumseas / 12.;
118+
// sumseas_yr will now be used as the duration of the pseudo-year, rather than assuming year has 12 months;
116119
if (nseas > 1)
117120
{
118121
warnstream << "Error. Can only have 1 season when during seasons as psuedo-years.";

SS_write_ssnew.tpl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,10 +1908,12 @@ FUNCTION void write_nucontrol()
19081908
{
19091909
report4 << AFIX << " #_Age(post-settlement) for L1 (aka Amin); first growth parameter is size at this age; linear growth below this" << endl
19101910
<< AFIX2 << " #_Age(post-settlement) for L2 (aka Amax); 999 to treat as Linf" << endl
1911-
<< Linf_decay << " #_exponential decay for growth within plus group and control for time-varying plus group size "
1912-
<< " (value should approx initial Z; -999 replicates 3.24 (Z=0.2); -998 or -997 to not allow growth within plus group)" << endl
1913-
<< " #_ -998 also disables time-varying changes in plus group; -997 allows updating time-varying plus group" << endl
1914-
<< " #_ best option is to provide a value for initial Z" << endl;
1911+
<< Linf_decay << " #_exponential decay for growth within plus group and control for time-varying plus group size " << endl
1912+
<< "#_only important when growth does not get near Linf by maxage" << endl
1913+
<< "#_value should approx initial Z; or use a code: -999 replicates 3.24 (with Z=0.2 and numbers weighted updating in years with time-varying growth)" << endl
1914+
<< "#_-998 ignores growth within plus group in initial year and disables time-varying changes in plus group mean size" << endl
1915+
<< "#_-997 ignores growth within plus group in initial year and enables updating time-varying plus group" << endl
1916+
<< "#" << endl;
19151917
19161918
report4 << "0 #_placeholder for future growth feature" << endl;
19171919
if (Grow_type >= 3 && Grow_type <= 5)

0 commit comments

Comments
 (0)