Skip to content

Commit 307e0ea

Browse files
Align g_n display/diagnostics with preTP boundary convention
1 parent 92d93bf commit 307e0ea

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

ogcore/output_tables.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,11 @@ def model_fit_table(
11391139
omega_t = params.omega[t]
11401140
model_val = omega_t[idx_65:].sum() / omega_t.sum()
11411141
elif target_desc == r"Pop growth rate":
1142-
model_val = params.g_n[t]
1142+
# g_n[t] is now growth from period t to t+1; the boundary
1143+
# growth into period 0 lives in g_n_preTP. Report the growth
1144+
# into period t so this stays calendar-aligned with the
1145+
# omega[t]-based moments above.
1146+
model_val = params.g_n_preTP if t == 0 else params.g_n[t - 1]
11431147
else:
11441148
model_val = np.nan
11451149

ogcore/parameter_plots.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ def plot_pop_growth(
147147
year_vec = np.arange(start_year, start_year + num_years_to_plot)
148148
start_index = start_year - p.start_year
149149
fig, ax = plt.subplots()
150-
plt.plot(year_vec, p.g_n[start_index : start_index + num_years_to_plot])
150+
# g_n stores the pre-time-path boundary growth separately in
151+
# g_n_preTP; prepend it to recover the year-aligned growth path.
152+
g_n_full = np.append(p.g_n_preTP, p.g_n)
153+
plt.plot(
154+
year_vec,
155+
g_n_full[start_index : start_index + num_years_to_plot],
156+
)
151157
plt.xlabel(r"Year $t$")
152158
plt.ylabel(r"Population Growth Rate $g_{n, t}$")
153159
ticks_loc = ax.get_yticks().tolist()
@@ -500,7 +506,11 @@ def plot_g_n(p_list, label_list=[""], include_title=False, path=None):
500506
years = np.arange(p0.start_year, p0.start_year + p0.T)
501507
fig, ax = plt.subplots()
502508
for i, p in enumerate(p_list):
503-
plt.plot(years, p.g_n[: p.T], label=label_list[i])
509+
plt.plot(
510+
years,
511+
np.append(p.g_n_preTP, p.g_n[: p.T - 1]),
512+
label=label_list[i],
513+
)
504514
plt.xlabel(r"Year $s$ (model periods)")
505515
plt.ylabel(r"Population Growth Rate $g_{n,t}$")
506516
if label_list[0] != "":

0 commit comments

Comments
 (0)