def main(): lat = -23.575001 lon = 152.524994 doy = 180.0 # ## Met data ... # (par, tair, vpd) = get_met_data(lat, lon, doy) wind = 2.5 pressure = 101325.0 Ca = 400.0 lat = 61.8474 lon = 24.2948 fpath = "/Users/mdekauwe/Downloads/" fname = "Hyytiala_met_and_plant_data_drought_2003.csv" fn = os.path.join(fpath, fname) df = pd.read_csv(fn, skiprows=range(1, 2)) dox = int(doy) * 48 par = df.PPFD.iloc[dox:dox + 48].values tair = df.Tair.iloc[dox:dox + 48].values vpd = df.VPD.iloc[dox:dox + 48].values wind = 2.5 pressure = 101325.0 Ca = 400.0 LAI = df.LAI[dox] # ## Parameters # g0 = 1E-09 g1 = df.g1[0] D0 = 1.5 # kpa Vcmax25 = df.Vmax25[0] #g0 = 0.001 #g1 = 2.0 #D0 = 1.5 # kpa #Vcmax25 = 60.0 Jmax25 = Vcmax25 * 1.67 Rd25 = 2.0 Eaj = 30000.0 Eav = 60000.0 deltaSj = 650.0 deltaSv = 650.0 Hdv = 200000.0 Hdj = 200000.0 Q10 = 2.0 gamma = 0.0 leaf_width = 0.02 LAI = 1.5 # Cambell & Norman, 11.5, pg 178 # The solar absorptivities of leaves (-0.5) from Table 11.4 (Gates, 1980) # with canopies (~0.8) from Table 11.2 reveals a surprising difference. # The higher absorptivityof canopies arises because of multiple reflections # among leaves in a canopy and depends on the architecture of the canopy. SW_abs = 0.8 # use canopy absorptance of solar radiation ## ### Run Big-leaf ## B = BigLeaf(g0, g1, D0, gamma, Vcmax25, Jmax25, Rd25, Eaj, Eav, deltaSj, deltaSv, Hdv, Hdj, Q10, leaf_width, SW_abs, gs_model="medlyn") An_bl = np.zeros(48) gsw_bl = np.zeros(48) et_bl = np.zeros(48) tcan_bl = np.zeros(48) hod = 0 for i in range(len(par)): (An_bl[i], gsw_bl[i], et_bl[i], tcan_bl[i]) = B.main(tair[i], par[i], vpd[i], wind, pressure, Ca, doy, hod, lat, lon, LAI) hod += 1 ## ### Run 2-leaf ## T = TwoLeaf(g0, g1, D0, gamma, Vcmax25, Jmax25, Rd25, Eaj, Eav, deltaSj, deltaSv, Hdv, Hdj, Q10, leaf_width, SW_abs, gs_model="medlyn") An_tl = np.zeros(48) gsw_tl = np.zeros(48) et_tl = np.zeros(48) tcan_tl = np.zeros(48) hod = 0 for i in range(len(par)): (An_tl[i], gsw_tl[i], et_tl[i], tcan_tl[i]) = T.main(tair[i], par[i], vpd[i], wind, pressure, Ca, doy, hod, lat, lon, LAI) hod += 1 fig = plt.figure(figsize=(16, 4)) fig.subplots_adjust(hspace=0.1) fig.subplots_adjust(wspace=0.2) plt.rcParams['text.usetex'] = False plt.rcParams['font.family'] = "sans-serif" plt.rcParams['font.sans-serif'] = "Helvetica" plt.rcParams['axes.labelsize'] = 14 plt.rcParams['font.size'] = 14 plt.rcParams['legend.fontsize'] = 10 plt.rcParams['xtick.labelsize'] = 14 plt.rcParams['ytick.labelsize'] = 14 almost_black = '#262626' # change the tick colors also to the almost black plt.rcParams['ytick.color'] = almost_black plt.rcParams['xtick.color'] = almost_black # change the text colors also to the almost black plt.rcParams['text.color'] = almost_black # Change the default axis colors from black to a slightly lighter black, # and a little thinner (0.5 instead of 1) plt.rcParams['axes.edgecolor'] = almost_black plt.rcParams['axes.labelcolor'] = almost_black ax1 = fig.add_subplot(131) ax2 = fig.add_subplot(132) ax3 = fig.add_subplot(133) ax1.plot(np.arange(48) / 2., An_bl, label="Big leaf") ax1.plot(np.arange(48) / 2., An_tl, label="Two leaf") ax1.legend(numpoints=1, loc="best") ax1.set_ylabel("$A_{\mathrm{n}}$ ($\mathrm{\mu}$mol m$^{-2}$ s$^{-1}$)") ax2.plot(np.arange(48) / 2., et_bl * c.MOL_TO_MMOL, label="Big leaf") ax2.plot(np.arange(48) / 2., et_tl * c.MOL_TO_MMOL, label="Two leaf") ax2.set_ylabel("E (mmol m$^{-2}$ s$^{-1}$)") ax2.set_xlabel("Hour of day") ax3.plot(np.arange(48) / 2., tcan_bl, label="Tcanopy$_{1leaf}$") ax3.plot(np.arange(48) / 2., tcan_tl, label="Tcanopy$_{2leaf}$") ax3.plot(np.arange(48) / 2., tair, label="Tair") ax3.set_ylabel("Temperature (deg C)") ax3.legend(numpoints=1, loc="best") ax1.locator_params(nbins=6, axis="y") ax2.locator_params(nbins=6, axis="y") plt.show() fig.savefig("/Users/%s/Desktop/A_E_Tcan.pdf" % (os.getlogin()), bbox_inches='tight', pad_inches=0.1)
def main(met_fn, flx_fn, cab_fn, year_to_run, site): #(site) fpath = "/mnt/c/Users/Manon/Documents/CABLE_runs/" fname = "%s_met_and_plant_data_drought_2003.csv" % (site) fn = os.path.join(fpath, fname) df = pd.read_csv(fn, skiprows=range(1, 2)) (df_cab) = read_cable_file(cab_fn) df_cab = df_cab[df_cab.index.year == year_to_run] (df_flx) = read_obs_file(flx_fn) df_flx = df_flx[df_flx.index.year == year_to_run] (df_met, lat, lon) = read_met_file(met_fn) df_met = df_met[df_met.index.year == year_to_run] par = df_met.PAR tair = df_met.Tair vpd = df_met.vpd wind = df_met.Wind pressure = df_met.PSurf Ca = 400.0 #LAI = 3.0 LAI = df.LAI # ## Parameters # g0 = 1E-09 g1 = df.g1[0] #4.12 D0 = 1.5 # kpa Vcmax25 = df.Vmax25[0] Jmax25 = Vcmax25 * 1.67 Rd25 = 2.0 Eaj = 30000.0 Eav = 60000.0 deltaSj = 650.0 deltaSv = 650.0 Hdv = 200000.0 Hdj = 200000.0 Q10 = 2.0 leaf_width = 0.02 gamma = 0 # doesn't do anything # Cambell & Norman, 11.5, pg 178 # The solar absorptivities of leaves (-0.5) from Table 11.4 (Gates, 1980) # with canopies (~0.8) from Table 11.2 reveals a surprising difference. # The higher absorptivityof canopies arises because of multiple reflections # among leaves in a canopy and depends on the architecture of the canopy. SW_abs = 0.8 # use canopy absorptance of solar radiation ## ### Run 2-leaf ## T = TwoLeaf(g0, g1, D0, gamma, Vcmax25, Jmax25, Rd25, Eaj, Eav, deltaSj, deltaSv, Hdv, Hdj, Q10, leaf_width, SW_abs, gs_model="medlyn") ndays = int(len(df_met) / 48) Anc_store = np.zeros(ndays) Ec_store = np.zeros(ndays) LAI_store = np.zeros(ndays) An_store = np.zeros(ndays) An_sun_store = np.zeros(ndays) An_sha_store = np.zeros(ndays) par_sun_store = np.zeros(ndays) par_sha_store = np.zeros(ndays) lai_sun_store = np.zeros(ndays) lai_sha_store = np.zeros(ndays) E_store = np.zeros(ndays) Anc_store = np.zeros(ndays) Anc_sun_store = np.zeros(ndays) Anc_sha_store = np.zeros(ndays) parc_sun_store = np.zeros(ndays) parc_sha_store = np.zeros(ndays) laic_sun_store = np.zeros(ndays) laic_sha_store = np.zeros(ndays) Ec_store = np.zeros(ndays) gpp_obs = np.zeros(ndays) e_obs = np.zeros(ndays) lai_obs = np.zeros(ndays) et_conv = c.MOL_WATER_2_G_WATER * c.G_TO_KG * 1800. an_conv = c.UMOL_TO_MOL * c.MOL_C_TO_GRAMS_C * 1800. cnt = 0 for doy in range(ndays): Anx = 0.0 Ex = 0.0 anxsun = 0.0 anxsha = 0.0 parxsun = 0.0 parxsha = 0.0 laixsun = 0.0 laixsha = 0.0 Anc = 0.0 Ec = 0.0 Acabx = 0.0 Ecabx = 0.0 Lcabx = 0.0 ancsun = 0.0 ancsha = 0.0 parcsun = 0.0 parcsha = 0.0 laicsun = 0.0 laicsha = 0.0 Aobsx = 0.0 Eobsx = 0.0 Lobsx = 0.0 for i in range(48): if doy < 364: laix = LAI[cnt] else: laix = LAI[cnt - 1] #if doy == 164: # print(laix) #elif doy== 165: # sys.exit() hod = float(i) / 2. + 1800. / 3600. / 2. (An, gsw, et, tcan, an_sun, an_sha, par_sun, par_sha, lai_sun, lai_sha) = T.main(tair[cnt], par[cnt], vpd[cnt], wind[cnt], pressure[cnt], Ca, doy + 1, hod, lat, lon, laix) lambda_et = (c.H2OLV0 - 2.365E3 * tair[cnt]) * c.H2OMW Anx += An * an_conv anxsun += an_sun * an_conv anxsha += an_sha * an_conv parxsun += par_sun / c.UMOLPERJ / c.MJ_TO_J * 1800.0 parxsha += par_sha / c.UMOLPERJ / c.MJ_TO_J * 1800.0 # MJ m-2 d-1 laixsun += lai_sun laixsha += lai_sha Lobsx += laix Ex += et * et_conv #if not np.isclose(df_cab.LAI_shaded[cnt], lai_sha): # print(cnt, df_cab.LAI_shaded[cnt], lai_sha) # print(df_cab.LAI_shaded[cnt] + df_cab.LAI_sunlit[cnt], lai_sha + lai_sun) # print(laix - (df_cab.LAI_shaded[cnt] + df_cab.LAI_sunlit[cnt]), laix - (lai_sha + lai_sun)) Anc += df_cab.GPP[cnt] * an_conv ancsun += df_cab.GPP_sunlit[cnt] * an_conv ancsha += df_cab.GPP_shaded[cnt] * an_conv parcsun += df_cab.PAR_sunlit[cnt] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 parcsha += df_cab.PAR_shaded[ cnt] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 # MJ m-2 d-1 laicsun += df_cab.LAI_sunlit[cnt] laicsha += df_cab.LAI_shaded[cnt] Lcabx += df_cab.LAI[cnt] Ec += et * et_conv Aobsx += df_flx.GPP[cnt] * an_conv Eobsx += df_flx.Qle[cnt] / lambda_et * et_conv if cnt < LAI.index[-1]: cnt += 1 else: break An_store[doy] = Anx An_sun_store[doy] = anxsun An_sha_store[doy] = anxsha par_sun_store[doy] = parxsun par_sha_store[doy] = parxsha lai_sun_store[doy] = laixsun / 48. lai_sha_store[doy] = laixsha / 48. E_store[doy] = Ex Anc_store[doy] = Anc Anc_sun_store[doy] = ancsun Anc_sha_store[doy] = ancsha parc_sun_store[doy] = parcsun parc_sha_store[doy] = parcsha laic_sun_store[doy] = laicsun / 48. laic_sha_store[doy] = laicsha / 48. Ec_store[doy] = Ec gpp_obs[doy] = Aobsx e_obs[doy] = Eobsx lai_obs[doy] = Lobsx / 48 #print(lai_sha_store - laic_sha_store) window = 3 An_store = moving_average(An_store, n=window) An_sun_store = moving_average(An_sun_store, n=window) An_sha_store = moving_average(An_sha_store, n=window) par_sun_store = moving_average(par_sun_store, n=window) par_sha_store = moving_average(par_sha_store, n=window) lai_sun_store = moving_average(lai_sun_store, n=window) lai_sha_store = moving_average(lai_sha_store, n=window) E_store = moving_average(E_store, n=window) Anc_store = moving_average(Anc_store, n=window) Anc_sun_store = moving_average(Anc_sun_store, n=window) Anc_sha_store = moving_average(Anc_sha_store, n=window) parc_sun_store = moving_average(parc_sun_store, n=window) parc_sha_store = moving_average(parc_sha_store, n=window) laic_sun_store = moving_average(laic_sun_store, n=window) laic_sha_store = moving_average(laic_sha_store, n=window) Ec_store = moving_average(Ec_store, n=window) gpp_obs = moving_average(gpp_obs, n=window) e_obs = moving_average(e_obs, n=window) lai_obs = moving_average(lai_obs, n=window) fig = plt.figure(figsize=(14, 8)) fig.subplots_adjust(hspace=0.1) fig.subplots_adjust(wspace=0.1) plt.rcParams['text.usetex'] = False plt.rcParams['font.family'] = "sans-serif" plt.rcParams['font.sans-serif'] = "Helvetica" plt.rcParams['axes.labelsize'] = 14 plt.rcParams['font.size'] = 14 plt.rcParams['legend.fontsize'] = 14 plt.rcParams['xtick.labelsize'] = 14 plt.rcParams['ytick.labelsize'] = 14 ax1 = fig.add_subplot(321) ax2 = fig.add_subplot(322) ax3 = fig.add_subplot(323) ax4 = fig.add_subplot(324) ax5 = fig.add_subplot(325) ax6 = fig.add_subplot(326) #ax1.plot(An_store, label="2-leaf - Sun") #ax1.plot(Anc_store, label="2-leaf - CABLE") ax1.plot(An_sun_store, label="Me") ax1.plot(Anc_sun_store, label="CABLE") ax1.set_title("Sun") ax2.set_title("Shade") ax1.set_ylabel("GPP (g C m$^{-2}$ d$^{-1}$)") ax1.legend(numpoints=1, loc="best") ax2.plot(An_sha_store) ax2.plot(Anc_sha_store) ax3.plot(par_sun_store) ax3.plot(parc_sun_store) ax3.set_ylabel("PAR (MJ m$^{-2}$ d$^{-1}$)") ax4.plot(par_sha_store) ax4.plot(parc_sha_store) ax5.plot(lai_sun_store) ax5.plot(laic_sun_store) ax5.set_ylabel("LAI (m$^{2}$ m$^{-2}$)") ax6.plot(lai_sha_store) ax6.plot(laic_sha_store) ax1.locator_params(nbins=6, axis="y") ax2.locator_params(nbins=6, axis="y") ax3.locator_params(nbins=6, axis="y") ax4.locator_params(nbins=6, axis="y") ax5.locator_params(nbins=6, axis="y") ax6.locator_params(nbins=6, axis="y") plt.setp(ax1.get_xticklabels(), visible=False) plt.setp(ax2.get_xticklabels(), visible=False) plt.setp(ax3.get_xticklabels(), visible=False) plt.setp(ax4.get_xticklabels(), visible=False) plt.show()
def main(met_fn, flx_fn, cab_fn, year_to_run, site): fpath = "/Users/mdekauwe/Downloads/" fname = "%s_met_and_plant_data_drought_2003.csv" % (site) fn = os.path.join(fpath, fname) df = pd.read_csv(fn, skiprows=range(1, 2)) (df_cab, p.lat, p.lon) = read_cable_file(cab_fn) df_cab = df_cab[df_cab.index.year == year_to_run] (df_flx) = read_obs_file(flx_fn) df_flx = df_flx[df_flx.index.year == year_to_run] (df_met, lat, lon) = read_met_file(met_fn) df_met = df_met[df_met.index.year == year_to_run] par = df_met.PAR tair = df_met.Tair vpd = df_met.vpd wind = df_met.Wind pressure = df_met.PSurf Ca = 400.0 #LAI = 3.0 LAI = df.LAI # ## Parameters # p.g0 = 1E-09 p.g1 = df.g1[0] #4.12 p.D0 = 1.5 # kpa p.Vcmax25 = df.Vmax25[0] p.Jmax25 = p.Vcmax25 * 1.67 p.Rd25 = None # Vcmax * 0.015 #p.Eaj = 30000.0 #p.Eav = 60000.0 #p.deltaSj = 650.0 #p.deltaSv = 650.0 #p.Hdv = 200000.0 #p.Hdj = 200000.0 p.Eaj = 50300.0 p.Eav = 73637.0 p.deltaSj = 495.0 p.deltaSv = 486.0 p.Hdv = 149252.0 p.Hdj = 152044.0 ## ### Run 2-leaf ## T = TwoLeaf(p, gs_model="medlyn") ndays = int(len(df_met) / 48) Anc_store = np.zeros(ndays) Ec_store = np.zeros(ndays) LAI_store = np.zeros(ndays) An_store = np.zeros(ndays) An_sun_store = np.zeros(ndays) An_sha_store = np.zeros(ndays) par_sun_store = np.zeros(ndays) par_sha_store = np.zeros(ndays) lai_sun_store = np.zeros(ndays) lai_sha_store = np.zeros(ndays) E_store = np.zeros(ndays) Anc_store = np.zeros(ndays) Anc_sun_store = np.zeros(ndays) Anc_sha_store = np.zeros(ndays) parc_sun_store = np.zeros(ndays) parc_sha_store = np.zeros(ndays) laic_sun_store = np.zeros(ndays) laic_sha_store = np.zeros(ndays) Ec_store = np.zeros(ndays) gpp_obs = np.zeros(ndays) e_obs = np.zeros(ndays) lai_obs = np.zeros(ndays) et_conv = c.MOL_WATER_2_G_WATER * c.G_TO_KG * 1800. an_conv = c.UMOL_TO_MOL * c.MOL_C_TO_GRAMS_C * 1800. cnt = 0 for doy in range(ndays - 1): Anx = 0.0 Ex = 0.0 anxsun = 0.0 anxsha = 0.0 parxsun = 0.0 parxsha = 0.0 laixsun = 0.0 laixsha = 0.0 Anc = 0.0 Ec = 0.0 Acabx = 0.0 Ecabx = 0.0 Lcabx = 0.0 ancsun = 0.0 ancsha = 0.0 parcsun = 0.0 parcsha = 0.0 laicsun = 0.0 laicsha = 0.0 Aobsx = 0.0 Eobsx = 0.0 Lobsx = 0.0 for i in range(48): if doy < 364: laix = LAI[cnt] else: #print(cnt, len(LAI), LAI[17518]) laix = LAI[17518] hod = float(i) / 2. + 1800. / 3600. / 2. (An, et, Tcan, apar, lai_leaf) = T.main(tair[cnt], par[cnt], vpd[cnt], wind[cnt], pressure[cnt], Ca, doy + 1, hod, laix) lambda_et = (c.H2OLV0 - 2.365E3 * tair[cnt]) * c.H2OMW Anx += np.sum(An) * an_conv anxsun += An[c.SUNLIT] * an_conv anxsha += An[c.SHADED] * an_conv parxsun += apar[c.SUNLIT] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 parxsha += apar[ c.SHADED] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 # MJ m-2 d-1 laixsun += lai_leaf[c.SUNLIT] laixsha += lai_leaf[c.SHADED] Lobsx += laix Ex += np.sum(et) * et_conv Anc += df_cab.GPP[cnt] * an_conv ancsun += df_cab.GPP_sunlit[cnt] * an_conv ancsha += df_cab.GPP_shaded[cnt] * an_conv parcsun += df_cab.PAR_sunlit[cnt] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 parcsha += df_cab.PAR_shaded[ cnt] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 # MJ m-2 d-1 laicsun += df_cab.LAI_sunlit[cnt] laicsha += df_cab.LAI_shaded[cnt] Lcabx += df_cab.LAI[cnt] #Ec += et * et_conv Aobsx += df_flx.GPP[cnt] * an_conv Eobsx += df_flx.Qle[cnt] / lambda_et * et_conv cnt += 1 An_store[doy] = Anx An_sun_store[doy] = anxsun An_sha_store[doy] = anxsha par_sun_store[doy] = parxsun par_sha_store[doy] = parxsha lai_sun_store[doy] = laixsun / 48. lai_sha_store[doy] = laixsha / 48. E_store[doy] = Ex Anc_store[doy] = Anc Anc_sun_store[doy] = ancsun Anc_sha_store[doy] = ancsha parc_sun_store[doy] = parcsun parc_sha_store[doy] = parcsha laic_sun_store[doy] = laicsun / 48. laic_sha_store[doy] = laicsha / 48. Ec_store[doy] = Ec gpp_obs[doy] = Aobsx e_obs[doy] = Eobsx lai_obs[doy] = Lobsx / 48 window = 3 An_store = moving_average(An_store, n=window) An_sun_store = moving_average(An_sun_store, n=window) An_sha_store = moving_average(An_sha_store, n=window) par_sun_store = moving_average(par_sun_store, n=window) par_sha_store = moving_average(par_sha_store, n=window) lai_sun_store = moving_average(lai_sun_store, n=window) lai_sha_store = moving_average(lai_sha_store, n=window) E_store = moving_average(E_store, n=window) Anc_store = moving_average(Anc_store, n=window) Anc_sun_store = moving_average(Anc_sun_store, n=window) Anc_sha_store = moving_average(Anc_sha_store, n=window) parc_sun_store = moving_average(parc_sun_store, n=window) parc_sha_store = moving_average(parc_sha_store, n=window) laic_sun_store = moving_average(laic_sun_store, n=window) laic_sha_store = moving_average(laic_sha_store, n=window) Ec_store = moving_average(Ec_store, n=window) gpp_obs = moving_average(gpp_obs, n=window) e_obs = moving_average(e_obs, n=window) lai_obs = moving_average(lai_obs, n=window) fig = plt.figure(figsize=(14, 8)) fig.subplots_adjust(hspace=0.1) fig.subplots_adjust(wspace=0.1) plt.rcParams['text.usetex'] = False plt.rcParams['font.family'] = "sans-serif" plt.rcParams['font.sans-serif'] = "Helvetica" plt.rcParams['axes.labelsize'] = 14 plt.rcParams['font.size'] = 14 plt.rcParams['legend.fontsize'] = 14 plt.rcParams['xtick.labelsize'] = 14 plt.rcParams['ytick.labelsize'] = 14 ax1 = fig.add_subplot(321) ax2 = fig.add_subplot(322) ax3 = fig.add_subplot(323) ax4 = fig.add_subplot(324) ax5 = fig.add_subplot(325) ax6 = fig.add_subplot(326) #ax1.plot(An_store, label="2-leaf - Sun") #ax1.plot(Anc_store, label="2-leaf - CABLE") ax1.plot(An_sun_store, label="Me") ax1.plot(Anc_sun_store, label="CABLE") # ax1.set_title("Sun") ax2.set_title("Shade") ax1.set_ylabel("GPP (g C m$^{-2}$ d$^{-1}$)") ax1.legend(numpoints=1, loc="best") ax2.plot(An_sha_store) ax2.plot(Anc_sha_store) ax3.plot(par_sun_store) ax3.plot(parc_sun_store) ax3.set_ylabel("PAR (MJ m$^{-2}$ d$^{-1}$)") ax4.plot(par_sha_store) ax4.plot(parc_sha_store) ax5.plot(lai_sun_store) ax5.plot(laic_sun_store) ax5.set_ylabel("LAI (m$^{2}$ m$^{-2}$)") ax6.plot(lai_sha_store) ax6.plot(laic_sha_store) ax1.locator_params(nbins=6, axis="y") ax2.locator_params(nbins=6, axis="y") ax3.locator_params(nbins=6, axis="y") ax4.locator_params(nbins=6, axis="y") ax5.locator_params(nbins=6, axis="y") ax6.locator_params(nbins=6, axis="y") plt.setp(ax1.get_xticklabels(), visible=False) plt.setp(ax2.get_xticklabels(), visible=False) plt.setp(ax3.get_xticklabels(), visible=False) plt.setp(ax4.get_xticklabels(), visible=False) plt.show()
def main(met_fn, flx_fn, cab_fn, year_to_run, site): fpath = "/Users/mdekauwe/Downloads/" fname = "%s_met_and_plant_data_drought_2003.csv" % (site) fn = os.path.join(fpath, fname) df = pd.read_csv(fn, skiprows=range(1, 2)) (df_flx) = read_obs_file(flx_fn) df_flx = df_flx[df_flx.index.year == year_to_run] (df_met, lat, lon) = read_met_file(met_fn) df_met = df_met[df_met.index.year == year_to_run] par = df_met.PAR tair = df_met.Tair vpd = df_met.vpd wind = df_met.Wind pressure = df_met.PSurf Ca = 400.0 #LAI = 3.0 LAI = df.LAI # ## Parameters # p.g0 = 1E-09 p.g1 = df.g1[0] #4.12 p.D0 = 1.5 # kpa p.Vcmax25 = df.Vmax25[0] p.Jmax25 = p.Vcmax25 * 1.67 p.Rd25 = None # Vcmax * 0.015 p.Eaj = 30000.0 p.Eav = 60000.0 p.deltaSj = 650.0 p.deltaSv = 650.0 p.Hdv = 200000.0 p.Hdj = 200000.0 ## ### Run 2-leaf ## T = TwoLeaf(p, gs_model="medlyn") C = TwoLeafCable(p, gs_model="medlyn") ndays = int(len(df_met) / 48) Anc_store = np.zeros(ndays) Ec_store = np.zeros(ndays) An_store = np.zeros(ndays) An_sun_store = np.zeros(ndays) An_sha_store = np.zeros(ndays) par_sun_store = np.zeros(ndays) par_sha_store = np.zeros(ndays) lai_sun_store = np.zeros(ndays) lai_sha_store = np.zeros(ndays) E_store = np.zeros(ndays) Tcan_store = np.zeros(ndays) Anc_store = np.zeros(ndays) Anc_sun_store = np.zeros(ndays) Anc_sha_store = np.zeros(ndays) parc_sun_store = np.zeros(ndays) parc_sha_store = np.zeros(ndays) laic_sun_store = np.zeros(ndays) laic_sha_store = np.zeros(ndays) Ec_store = np.zeros(ndays) Tcanc_store = np.zeros(ndays) Sunc_store = np.zeros(ndays) Shac_store = np.zeros(ndays) gpp_obs = np.zeros(ndays) e_obs = np.zeros(ndays) lai_obs = np.zeros(ndays) et_conv = c.MOL_WATER_2_G_WATER * c.G_TO_KG * 1800. an_conv = c.UMOL_TO_MOL * c.MOL_C_TO_GRAMS_C * 1800. cnt = 0 for doy in range(ndays - 1): Anx = 0.0 Ex = 0.0 anxsun = 0.0 anxsha = 0.0 parxsun = 0.0 parxsha = 0.0 laixsun = 0.0 laixsha = 0.0 Tcanx = 0.0 Anc = 0.0 Ec = 0.0 Acabx = 0.0 Ecabx = 0.0 Lcabx = 0.0 ancsun = 0.0 ancsha = 0.0 parcsun = 0.0 parcsha = 0.0 laicsun = 0.0 laicsha = 0.0 Tcancx = 0.0 Aobsx = 0.0 Eobsx = 0.0 Lobsx = 0.0 Sun_fracC = 0.0 Sha_fracC = 0.0 if doy == 0: tsoil = np.mean(tair[cnt:cnt + 48]) else: tsoil = np.mean(tair[cnt - 48:cnt]) hr_cnt = 0 for i in range(48): if doy < 364: laix = LAI[cnt] else: #print(cnt, len(LAI), LAI[17518]) laix = LAI[17518] hod = float(i) / 2. + 1800. / 3600. / 2. (An, et, Tcan, apar, lai_leaf) = T.main(tair[cnt], par[cnt], vpd[cnt], wind[cnt], pressure[cnt], Ca, doy + 1, hod, laix, tsoil) lambda_et = (c.H2OLV0 - 2.365E3 * tair[cnt]) * c.H2OMW Anx += np.sum(An) * an_conv anxsun += An[c.SUNLIT] * an_conv anxsha += An[c.SHADED] * an_conv parxsun += apar[c.SUNLIT] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 parxsha += apar[ c.SHADED] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 # MJ m-2 d-1 laixsun += lai_leaf[c.SUNLIT] laixsha += lai_leaf[c.SHADED] sun_frac = lai_leaf[c.SUNLIT] / np.sum(lai_leaf) sha_frac = lai_leaf[c.SHADED] / np.sum(lai_leaf) if par[cnt] > 0.0: Tcanx += (Tcan[c.SUNLIT] * sun_frac) + (Tcan[c.SHADED] * sha_frac) Lobsx += laix Ex += np.sum(et) * et_conv (An, et, Tcan, apar, lai_leaf) = C.main(tair[cnt], par[cnt], vpd[cnt], wind[cnt], pressure[cnt], Ca, doy + 1, hod, laix, tsoil) Anc += np.sum(An) * an_conv ancsun += An[c.SUNLIT] * an_conv ancsha += An[c.SHADED] * an_conv parcsun += apar[c.SUNLIT] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 parcsha += apar[ c.SHADED] / c.UMOLPERJ / c.MJ_TO_J * 1800.0 # MJ m-2 d-1 laicsun += lai_leaf[c.SUNLIT] laicsha += lai_leaf[c.SHADED] if par[cnt] > 0.0: Tcancx += Tcan Ec += et * et_conv Sun_fracC += sun_frac Sha_fracC += sha_frac Aobsx += df_flx.GPP[cnt] * an_conv Eobsx += df_flx.Qle[cnt] / lambda_et * et_conv cnt += 1 if par[cnt] > 0.0: hr_cnt += 1 An_store[doy] = Anx An_sun_store[doy] = anxsun An_sha_store[doy] = anxsha par_sun_store[doy] = parxsun par_sha_store[doy] = parxsha lai_sun_store[doy] = laixsun / 48. lai_sha_store[doy] = laixsha / 48. E_store[doy] = Ex Tcan_store[doy] = (Tcanx / float(hr_cnt)) Anc_store[doy] = Anc Anc_sun_store[doy] = ancsun Anc_sha_store[doy] = ancsha parc_sun_store[doy] = parcsun parc_sha_store[doy] = parcsha laic_sun_store[doy] = laicsun / 48. laic_sha_store[doy] = laicsha / 48. Ec_store[doy] = Ec Tcanc_store[doy] = (Tcancx / float(hr_cnt)) Sunc_store[doy] = Sun_fracC / 48. Shac_store[doy] = Sha_fracC / 48. gpp_obs[doy] = Aobsx e_obs[doy] = Eobsx lai_obs[doy] = Lobsx / 48 window = 3 An_store = moving_average(An_store, n=window) An_sun_store = moving_average(An_sun_store, n=window) An_sha_store = moving_average(An_sha_store, n=window) par_sun_store = moving_average(par_sun_store, n=window) par_sha_store = moving_average(par_sha_store, n=window) lai_sun_store = moving_average(lai_sun_store, n=window) lai_sha_store = moving_average(lai_sha_store, n=window) E_store = moving_average(E_store, n=window) Tcan_store = moving_average(Tcan_store, n=window) Anc_store = moving_average(Anc_store, n=window) Anc_sun_store = moving_average(Anc_sun_store, n=window) Anc_sha_store = moving_average(Anc_sha_store, n=window) parc_sun_store = moving_average(parc_sun_store, n=window) parc_sha_store = moving_average(parc_sha_store, n=window) laic_sun_store = moving_average(laic_sun_store, n=window) laic_sha_store = moving_average(laic_sha_store, n=window) Ec_store = moving_average(Ec_store, n=window) Sunc_store = moving_average(Sunc_store, n=window) Shac_store = moving_average(Shac_store, n=window) Tcanc_store = moving_average(Tcanc_store, n=window) #gpp_obs = moving_average(gpp_obs, n=window) #e_obs = moving_average(e_obs, n=window) #lai_obs = moving_average(lai_obs, n=window) fig = plt.figure(figsize=(9, 10)) fig.subplots_adjust(hspace=0.3) fig.subplots_adjust(wspace=0.3) plt.rcParams['text.usetex'] = False plt.rcParams['font.family'] = "sans-serif" plt.rcParams['font.sans-serif'] = "Helvetica" plt.rcParams['axes.labelsize'] = 12 plt.rcParams['font.size'] = 12 plt.rcParams['legend.fontsize'] = 12 plt.rcParams['xtick.labelsize'] = 12 plt.rcParams['ytick.labelsize'] = 12 ax1 = fig.add_subplot(411) ax2 = fig.add_subplot(412) ax3 = fig.add_subplot(413) ax4 = fig.add_subplot(414) ax1.plot(An_store, label="2-leaf - Me") ax1.plot(Anc_store, label="2-leaf - CABLE") ax1.set_ylabel("GPP (g C m$^{-2}$ d$^{-1}$)") ax1.legend(numpoints=1, loc="best") ax2.plot(E_store, label="2-leaf - Me") ax2.plot(Ec_store, label="2-leaf - CABLE") ax2.set_ylabel("E (mm d$^{-1}$)") ax3.plot(Tcan_store, label="2-leaf - Me") ax3.plot(Tcanc_store, label="2-leaf - CABLE") ax3.set_ylabel("T$_{canopy}$ (degrees C)") print(np.mean(np.abs(Tcan_store - Tcanc_store))) ax4.plot(Sunc_store, label="Sun") ax4.plot(Shac_store, label="Shade") ax4.set_ylabel("Frac (-)") ax4.legend(numpoints=1, loc="best") ax1.locator_params(nbins=6, axis="y") ax2.locator_params(nbins=6, axis="y") ax3.locator_params(nbins=6, axis="y") ax4.locator_params(nbins=6, axis="y") #plt.setp(ax1.get_xticklabels(), visible=False) #plt.setp(ax2.get_xticklabels(), visible=False) #plt.setp(ax3.get_xticklabels(), visible=False) #plt.setp(ax4.get_xticklabels(), visible=False) plt.show()
def main(): doy = 180. # ## Met data ... # (par, tair, vpd) = get_met_data(p.lat, p.lon, doy) # more realistic VPD rh = 40. esat = calc_esat(tair) ea = rh / 100. * esat vpd = (esat - ea) * c.PA_2_KPA vpd = np.where(vpd < 0.05, 0.05, vpd) # ## Fixed met stuff # wind = 2.5 pressure = 101325.0 Ca = 400.0 LAI = p.LAI ## ### Run Big-leaf ## B = BigLeaf(p, gs_model="medlyn") An_bl = np.zeros(48) gsw_bl = np.zeros(48) et_bl = np.zeros(48) tcan_bl = np.zeros(48) for i in range(len(par)): hod = float(i) / 2. + 1800. / 3600. / 2. (An, gsw, et, Tcan) = B.main(p, tair[i], par[i], vpd[i], wind, pressure, Ca, doy, hod, LAI) An_bl[i] = An et_bl[i] = et tcan_bl[i] = Tcan ## ### Run 2-leaf ## T = TwoLeaf(p, gs_model="medlyn") An_tl = np.zeros(48) et_tl = np.zeros(48) tcan_tl = np.zeros(48) hod = 0 for i in range(len(par)): (An, et, Tcan, apar, lai_leaf) = T.main(p, tair[i], par[i], vpd[i], wind, pressure, Ca, doy, hod / 2., LAI) sun_frac = lai_leaf[c.SUNLIT] / np.sum(lai_leaf) sha_frac = lai_leaf[c.SHADED] / np.sum(lai_leaf) An_tl[i] = np.sum(An) et_tl[i] = np.sum(et) tcan_tl[i] = (Tcan[c.SUNLIT] * sun_frac) + (Tcan[c.SHADED] * sha_frac) hod += 1 fig = plt.figure(figsize=(16, 4)) fig.subplots_adjust(hspace=0.1) fig.subplots_adjust(wspace=0.2) plt.rcParams['text.usetex'] = False plt.rcParams['font.family'] = "sans-serif" plt.rcParams['font.sans-serif'] = "Helvetica" plt.rcParams['axes.labelsize'] = 14 plt.rcParams['font.size'] = 14 plt.rcParams['legend.fontsize'] = 10 plt.rcParams['xtick.labelsize'] = 14 plt.rcParams['ytick.labelsize'] = 14 almost_black = '#262626' # change the tick colors also to the almost black plt.rcParams['ytick.color'] = almost_black plt.rcParams['xtick.color'] = almost_black # change the text colors also to the almost black plt.rcParams['text.color'] = almost_black # Change the default axis colors from black to a slightly lighter black, # and a little thinner (0.5 instead of 1) plt.rcParams['axes.edgecolor'] = almost_black plt.rcParams['axes.labelcolor'] = almost_black ax1 = fig.add_subplot(131) ax2 = fig.add_subplot(132) ax3 = fig.add_subplot(133) ax1.plot(np.arange(48) / 2., An_bl, label="Big leaf") ax1.plot(np.arange(48) / 2., An_tl, label="Two leaf") ax1.legend(numpoints=1, loc="best") ax1.set_ylabel("$A_{\mathrm{n}}$ ($\mathrm{\mu}$mol m$^{-2}$ s$^{-1}$)") ax2.plot(np.arange(48) / 2., et_bl * c.MOL_TO_MMOL, label="Big leaf") ax2.plot(np.arange(48) / 2., et_tl * c.MOL_TO_MMOL, label="Two leaf") ax2.set_ylabel("E (mmol m$^{-2}$ s$^{-1}$)") ax2.set_xlabel("Hour of day") ax3.plot(np.arange(48) / 2., tcan_bl, label="Tcanopy$_{1leaf}$") ax3.plot(np.arange(48) / 2., tcan_tl, label="Tcanopy$_{2leaf}$") ax3.plot(np.arange(48) / 2., tair, label="Tair") ax3.set_ylabel("Temperature (deg C)") ax3.legend(numpoints=1, loc="best") ax1.locator_params(nbins=6, axis="y") ax2.locator_params(nbins=6, axis="y") plt.show() fig.savefig("/Users/%s/Desktop/A_E_Tcan.pdf" % (os.getlogin()), bbox_inches='tight', pad_inches=0.1)
fname = "met_constant_forcing_eCO2.csv" fn = os.path.join(fpath, fname) df = pd.read_csv(fn) #df = df.drop(df.columns[0], axis=1) df.index = pd.to_datetime(df.DateTime) # Add an LAI field, i.e. converting from per tree to m2 m-2 df = df.assign(lai=lambda x: x.leafArea / p.footprint) ## Fixed met stuff # #wind = 2.5 #pressure = 101325.0 #Ca = 400.0 T = TwoLeaf(p, gs_model="medlyn") chambers = np.unique(df.chamber) for chamber in chambers: print(chamber) dfx = df[(df.T_treatment == "ambient") & (df.Water_treatment == "control") & (df.chamber == chamber)].copy() (out) = run_treatment(T, dfx, p, vary_vj=False) if not os.path.exists(output_dir): os.mkdir(output_dir) ofname = os.path.join(output_dir, "wtc_two_leaf_%s.csv" % (chamber)) if os.path.isfile(ofname):
def main(): lat = -23.575001 lon = 152.524994 doy = 180.0 # ## Met data ... # (par, tair, vpd) = get_met_data(lat, lon, doy) wind = 2.5 pressure = 101325.0 Ca = 400.0 # more realistic VPD rh = 40. esat = calc_esat(tair) ea = rh / 100. * esat vpd = (esat - ea) * c.PA_2_KPA vpd = np.where(vpd < 0.05, 0.05, vpd) #plt.plot(vpd) #plt.show() #sys.exit() ## Parameters # g0 = 0.001 g1 = 1.5635 # Puechabon D0 = 1.5 # kpa Vcmax25 = 60.0 Jmax25 = Vcmax25 * 1.67 Rd25 = 2.0 Eaj = 30000.0 Eav = 60000.0 deltaSj = 650.0 deltaSv = 650.0 Hdv = 200000.0 Hdj = 200000.0 Q10 = 2.0 gamma = 0.0 leaf_width = 0.02 LAI = 3. # Cambell & Norman, 11.5, pg 178 # The solar absorptivities of leaves (-0.5) from Table 11.4 (Gates, 1980) # with canopies (~0.8) from Table 11.2 reveals a surprising difference. # The higher absorptivityof canopies arises because of multiple reflections # among leaves in a canopy and depends on the architecture of the canopy. SW_abs = 0.8 # use canopy absorptance of solar radiation ## ### Run Big-leaf ## B = BigLeaf(g0, g1, D0, gamma, Vcmax25, Jmax25, Rd25, Eaj, Eav, deltaSj, deltaSv, Hdv, Hdj, Q10, leaf_width, SW_abs, gs_model="medlyn") An_bl = np.zeros(48) gsw_bl = np.zeros(48) et_bl = np.zeros(48) tcan_bl = np.zeros(48) hod = 0 for i in range(len(par)): (An_bl[i], gsw_bl[i], et_bl[i], tcan_bl[i]) = B.main(tair[i], par[i], vpd[i], wind, pressure, Ca, doy, hod, lat, lon, LAI) hod += 1 ## ### Run 2-leaf ## T = TwoLeaf(g0, g1, D0, gamma, Vcmax25, Jmax25, Rd25, Eaj, Eav, deltaSj, deltaSv, Hdv, Hdj, Q10, leaf_width, SW_abs, gs_model="medlyn") An_tl = np.zeros(48) gsw_tl = np.zeros(48) et_tl = np.zeros(48) tcan_tl = np.zeros(48) hod = 0 for i in range(len(par)): (An_tl[i], gsw_tl[i], et_tl[i], tcan_tl[i]) = T.main(tair[i], par[i], vpd[i], wind, pressure, Ca, doy, hod, lat, lon, LAI) hod += 1 ## ### Run 2-leaf opt ## T = TwoLeafOpt(g0, g1, D0, gamma, Vcmax25, Jmax25, Rd25, Eaj, Eav, deltaSj, deltaSv, Hdv, Hdj, Q10, leaf_width, SW_abs, gs_model="medlyn") An_tlo = np.zeros(48) gsw_tlo = np.zeros(48) et_tlo = np.zeros(48) tcan_tlo = np.zeros(48) hod = 0 for i in range(len(par)): (An_tlo[i], gsw_tlo[i], et_tlo[i], tcan_tlo[i]) = T.main(tair[i], par[i], vpd[i], wind, pressure, Ca, doy, hod, lat, lon, LAI) hod += 1 ## ### Run 2-leaf Manon ## Ao = np.zeros(48) gso = np.zeros(48) Eo = np.zeros(48) Aob = np.zeros(48) gsob = np.zeros(48) Eob = np.zeros(48) hod = 0 for i in range(len(par)): cos_zenith = calculate_solar_geometry(doy, hod, lat, lon) zenith_angle = np.rad2deg(np.arccos(cos_zenith)) elevation = 90.0 - zenith_angle if elevation > 0.0 and par[i] > 50.0: p = declared_params() p.PPFD = par[i] p.sw_rad_day = par[i] * c.PAR_2_SW p.LAI = LAI p.coszen = cos_zenith p.VPD = vpd[i] p.precip = 0 p.Tair = tair[i] p.Vmax25 = Vcmax25 p.g1 = g1 p.CO2 = Ca / 1000 * 101.325 p.JV = 1.67 p.Rlref = Rd25 p.Ej = Eaj p.Ev = Eav p.deltaSv = deltaSv p.deltaSj = deltaSj p.max_leaf_width = leaf_width p.gamstar25 = 4.33 # 42.75 / 101.25 umol m-2 s-1 p.Kc25 = 41.0264925 # 404.9 umol m-2 s-1 p.Ko25 = 28208.88 # 278.4 mmol mol-1 p.O2 = 21.27825 # 210 *1000. / 101.25 210 mmol mol-1 p.alpha = 0.3 p.albedo = 0.2 p.Egamstar = 37830.0 p.Ec = 79430.0 p.Eo = 36380.0 p.P50 = 2.02 # Puechabon p.P88 = 4.17 p.kmax = 0.862457122856143 _, _, fscale2can = absorbed_radiation_2_leaves(p) p = p.append(pd.Series([np.nansum(fscale2can)], index=['fscale'])) Eo[i], gso[i], Ao[i], __, __ = solve_std(p, p.fc, photo='Farquhar') #""" try: fstom_opt_psi, Eo[i], gso[i], Ao[i], _, _ = profit_psi( p, photo='Farquhar', res='med', case=2) p = p.append( pd.Series([fstom_opt_psi], index=['fstom_opt_psi'])) except (ValueError, AttributeError): (Eo[i], gso[i], Ao[i]) = (0., 0., 0.) #""" hod += 1 fig = plt.figure(figsize=(16, 4)) fig.subplots_adjust(hspace=0.1) fig.subplots_adjust(wspace=0.2) plt.rcParams['text.usetex'] = False plt.rcParams['font.family'] = "sans-serif" plt.rcParams['font.sans-serif'] = "Helvetica" plt.rcParams['axes.labelsize'] = 14 plt.rcParams['font.size'] = 14 plt.rcParams['legend.fontsize'] = 10 plt.rcParams['xtick.labelsize'] = 14 plt.rcParams['ytick.labelsize'] = 14 almost_black = '#262626' # change the tick colors also to the almost black plt.rcParams['ytick.color'] = almost_black plt.rcParams['xtick.color'] = almost_black # change the text colors also to the almost black plt.rcParams['text.color'] = almost_black # Change the default axis colors from black to a slightly lighter black, # and a little thinner (0.5 instead of 1) plt.rcParams['axes.edgecolor'] = almost_black plt.rcParams['axes.labelcolor'] = almost_black ax1 = fig.add_subplot(131) ax2 = fig.add_subplot(132) ax3 = fig.add_subplot(133) #ax1.plot(np.arange(48)/2., An_bl, label="Big leaf") ax1.plot(np.arange(48) / 2., An_tl, label="Two leaf") ax1.plot(np.arange(48) / 2., An_tlo, label="Two leaf Opt") ax1.plot(np.arange(48) / 2., Ao, label="Two leaf Manon") ax1.legend(numpoints=1, loc="best") ax1.set_ylabel("$A_{\mathrm{n}}$ ($\mathrm{\mu}$mol m$^{-2}$ s$^{-1}$)") #ax2.plot(np.arange(48)/2., et_bl * c.MOL_TO_MMOL, label="Big leaf") ax2.plot(np.arange(48) / 2., et_tl * c.MOL_TO_MMOL, label="Two leaf") ax2.plot(np.arange(48) / 2., et_tlo * c.MOL_TO_MMOL, label="Two leaf opt") ax2.plot(np.arange(48) / 2., Eo, label="Two leaf Manon") ax2.set_ylabel("E (mmol m$^{-2}$ s$^{-1}$)") ax2.set_xlabel("Hour of day") #ax3.plot(np.arange(48)/2., tcan_bl, label="Tcanopy$_{1leaf}$") ax3.plot(np.arange(48) / 2., tcan_tl, label="Tcanopy$_{2leaf}$") ax3.plot(np.arange(48) / 2., tair, label="Tair") ax3.set_ylabel("Temperature (deg C)") ax3.legend(numpoints=1, loc="best") ax1.locator_params(nbins=6, axis="y") ax2.locator_params(nbins=6, axis="y") plt.show() fig.savefig("/Users/%s/Desktop/A_E_Tcan.pdf" % (os.getlogin()), bbox_inches='tight', pad_inches=0.1)
# among leaves in a canopy and depends on the architecture of the canopy. SW_abs = 0.8 # use canopy absorptance of solar radiation ## ### Run 2-leaf ## T = TwoLeaf(g0, g1, D0, gamma, Vcmax25, Jmax25, Rd25, Eaj, Eav, deltaSj, deltaSv, Hdv, Hdj, Q10, leaf_width, SW_abs, gs_model="medlyn") B = BigLeaf(g0, g1, D0, gamma, Vcmax25, Jmax25,
def main(p, met, lai): days = met.doy hod = met.hod ndays = int(len(days) / 24.) nhours = len(met) hours_in_day = int(nhours / float(ndays)) if hours_in_day == 24: met_timestep = 60. else: met_timestep = 30. timestep_sec = 60. * met_timestep T = TwoLeaf(p, gs_model="medlyn") #T = TwoLeaf(p, gs_model="leuning") out, store = setup_output_dataframe(ndays, hours_in_day, p) i = 0 hour_cnt = 1 # hour count day_cnt = 0 while i < len(met): year = met.index.year[i] doy = met.doy[i] hod = met.hod[i] + 1 if day_cnt - 1 == -1: beta = calc_beta(p.theta_sat, p.theta_fc, p.theta_wp) else: beta = calc_beta(out.sw[day_cnt - 1], p.theta_fc, p.theta_wp) #beta = calc_beta(store.sw[hour_cnt-1]) (An, et, Tcan, apar, lai_leaf) = T.main(met.tair[i], met.par[i], met.vpd[i], met.wind[i], met.press[i], met.ca[i], doy, hod, lai[i], beta=beta) if hour_cnt == hours_in_day: # End of the day store_hourly(hour_cnt - 1, An, et, lai_leaf, met.precip[i], store, hours_in_day) store_daily(year, doy, day_cnt, store, beta, out, p) hour_cnt = 1 day_cnt += 1 else: store_hourly(hour_cnt - 1, An, et, lai_leaf, met.precip[i], store, hours_in_day) hour_cnt += 1 i += 1 return (out)