function [prdData, info] = predict_Pogona_barbata(par, data, auxData)
% file generated by prt_predict

% unpack par, data, auxData
cPar = parscomp_st(par); vars_pull(par);
v2struct(par); v2struct(cPar); v2struct(data); v2struct(auxData);

% compute temperature correction factors
pars_T = T_A;
TC_am = tempcorr(temp.am, T_ref, pars_T);
TC_Ri = tempcorr(temp.Ri, T_ref, pars_T);
TC_ab = tempcorr(temp.ab, T_ref, pars_T);
TC_tp = tempcorr(temp.tp, T_ref, pars_T);
TC_tR = tempcorr(temp.tR, T_ref, pars_T);
TC_tL = tempcorr(temp.tL, T_ref, pars_T);
TC_tWw = tempcorr(temp.tWw, T_ref, pars_T);
TC_LN = tempcorr(temp.LN, T_ref, pars_T);

% life cycle
pars_tR = [g; k; l_T; v_Hb; v_Hx; v_Hp; t_N * k_M * TC_am];  % compose parameter vector
[tau_R, tau_p, tau_x, tau_b, l_R, l_p, l_x, l_b, info] = get_tR(pars_tR, f); % -, scaled times & lengths

if info == 0
  prdData = []; return;
end

% initial
pars_UE0 = [V_Hb; g; k_J; k_M; v]; % compose parameter vector
U_E0 = initial_scaled_reserve(f, pars_UE0); % d.cm^2, initial scaled reserve
E_0 = p_Am * U_E0; % J, initial reserve

% birth
L_b = L_m * l_b;                  % cm, structural length at birth
a_b = t_0 + tau_b/ k_M/ TC_ab;    % d, age at birth
Lw_b = L_b/ del_M;                % cm, physical length at birth
Ww_b = L_b^3 * (1 + f * ome);     % g, wet weight at birth

% puberty
L_p = L_m * l_p; % cm, structural length at puberty
t_p = (tau_p - tau_b)/ k_M/ TC_tp; % d, time since birth at puberty
Lw_p = L_p/ del_M; % cm, physical length at puberty
Ww_p = L_p^3 * (1 + f * ome); % g, wet weight at puberty

% ultimate
l_i = f - l_T; % -, scaled ultimate length
L_i = L_m * l_i; % cm, ultimate structural length
Lw_i = f * L_m/ del_M; % cm, ultimate physical length
Ww_i = L_i^3 * (1 + f * ome); % g, ultimate wet weight 

% reproduction
pars_R = [kap; kap_R; g; k_J; k_M; L_T; v; U_Hb; U_Hp]; % compose parameter vector
R_i = TC_Ri * reprod_rate(L_i, f, pars_R); % #/d, ultimate reproduction rate
t_R = (tau_R - tau_b)/ k_M/ TC_tR; % d, time since birth at 1st brood

% life span
pars_tm = [g; l_T; h_a/ k_M^2; s_G]; % compose parameter vector
tau_m = get_tm_s(pars_tm, f, l_b); % -, scaled mean life span
a_m = tau_m/ k_M/ TC_am; % d, mean life span

% pack to output
prdData.ab = a_b;
prdData.tp = t_p;
prdData.am = a_m;
prdData.Lb = Lw_b;
prdData.Lp = Lw_p;
prdData.Li = Lw_i;
prdData.Wwb = Ww_b;
prdData.Wwp = Ww_p;
prdData.Wwi = Ww_i;
prdData.Ri = R_i;
prdData.tR = t_R;
prdData.E0 = E_0;

% length - wet weight
LWw = (LWw(:,1) * del_M).^3 * (1 + f_LWw * ome); % g, wet weight

% time - length
L_b = L_m * get_lb([g, k, v_Hb], f_tL); L_i = L_m * f_tL; % cm, structural lengths
rT_B = TC_tL * k_M/ 3/ (1 + f_tL/ g); % 1/d, von Bert growth rate
tL = (L_i - (L_i - L_b) * exp( - rT_B * tL(:,1)))/ del_M; % cm, physical length

% time - wet weight
L_b = L_m * get_lb([g; k; v_Hb], f_tWw); L_i = f_tWw * L_m; % cm, structural lengths
r_B = TC_tWw * k_M/ 3/ (1 + f_tWw/ g); % 1/d, von Bertalanffy growth rate
L = L_i - (L_i - L_b) * exp( - r_B * tWw(:,1)); % cm, structural length
tWw = L.^3 * (1 + f_tWw * ome); % g, wet weight

% length - yearly fecundity
pars_R = [kap; kap_R; g; k_J; k_M; L_T; v; U_Hb; U_Hp]; % compose parameter vector
LN = TC_LN * 365 * reprod_rate(LN(:,1) * del_M, f_LN, pars_R); % #, yearly fecundity

% pack to output
prdData.LWw = LWw;
prdData.tL = tL;
prdData.tWw = tWw;
prdData.LN = LN;

