References: ----------- * Medlyn et al. 2002, PCE, 25, 1167-1179. """ return k25 * np.exp((Ea * (Tk - 298.15)) / (298.15 * c.RGAS * Tk)) if __name__ == "__main__": from get_days_met_forcing import get_met_data # ## Met data ... # doy = 180. (par, tair, vpd) = get_met_data(p.lat, p.lon, doy) #par = np.mean(par.reshape(-1, 2), axis=1) #par *= 1800.0/par.max() #* c.SEC_TO_HR #tair = np.mean(tair.reshape(-1, 2), axis=1) #tair = np.ones(len(par)) * 25. # convert atmospheric CO2 from umol mol-1 --> Pa co2 = 400.0 * p.patm * c.CO2_CONV # Ratio of intercellular to ambient partial pressure of CO2 lambdax = p.lambda_max # Convert Vcmax mol m-2 s-1 vm = 60. * c.UMOL_TO_MOL
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(): 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)
#scalex[c.SHADED] = lai * (1.0 - exp(-kn)) / kn - scalex[c.SUNLIT] return scalex if __name__ == "__main__": from get_days_met_forcing import get_met_data 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 # ## Parameters # g0 = 0.001 g1 = 4.0 D0 = 1.5 # kpa Vcmax25 = 60.0 Jmax25 = Vcmax25 * 1.67 Rd25 = 2.0 Eaj = 30000.0 Eav = 60000.0
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)