def main(): ofname = "fitting_results_%s.csv" % ("Mercado") results_dir = "results" data_dir = "data" plot_dir = "plots" # Normal way model = FarquharC3(peaked_Jmax=True, peaked_Vcmax=True, model_Q10=True) F = FitJmaxVcmaxRd(model, ofname, results_dir, data_dir, plot_dir) F.main(print_to_screen=True) # Using Rdark measurement, assuming Rd = Rdark * 0.6 ofname = "fitting_results_%s.csv" % ("Mercado_Rdark") model = FarquharC3(peaked_Jmax=True, peaked_Vcmax=True) F = FitJmaxVcmaxKnownRdark(model, ofname, results_dir, data_dir, plot_dir) F.main(print_to_screen=True)
def main(): # ## Generate some data to estimate V_hat_cmax from # deg2kelvin = 273.15 model = FarquharC3(peaked_Jmax=True, peaked_Vcmax=True, model_Q10=True) Ci = np.arange(0, 1500, 150) curve = 1 Tleaf = 25.0 Tleaf += deg2kelvin Jmax25 = 150.0 Vcmax25 = Jmax25 / 1.6 Rd25 = 2.0 Eaj = 30000.0 Eav = 60000.0 deltaSj = 650.0 deltaSv = 650.0 Hdv = 200000.0 Hdj = 200000.0 Q10 = 2.0 (An, Acn, Ajn) = model.calc_photosynthesis(Ci=Ci, Tleaf=Tleaf, Par=None, Jmax=None, Vcmax=None, Jmax25=Jmax25, Vcmax25=Vcmax25, Rd=None, Q10=Q10, Eaj=Eaj, Eav=Eav, deltaSj=deltaSj, deltaSv=deltaSv, Rd25=Rd25, Hdv=Hdv, Hdj=Hdj) Rd = model.calc_resp(Tleaf, Q10, Rd25, Tref=25.0) # ## Use Ci at 300 # V = OnePointVcmax() Vcmax_est = V.est_vcmax(model, An[2], Rd, Ci[2], Tleaf) print(Vcmax25, Vcmax_est)
print(fname) data = np.recfromcsv(fname, delimiter=delimiter, names=True, case_sensitive=True) return data ############################## # Fit Eaj, Eav, delSj + delSv ############################## infname = "results/normalised_results.csv" ofname = "ea_results.csv" results_dir = "results" data_dir = "data" model = FarquharC3() peaked = True ############################ # Need to add the groupby column...(JUST FOR THE EXAMPLE!) data = read_data(infname) header = ["Jmax", "Vcmax", "Jnorm", "Vnorm", "Rd", "Tav", \ "Tarrh", "R2", "n", "Species", "Leaf", "Curve", \ "Filename", "Season", "fitgroup"] if os.path.isfile(infname): os.remove(infname) fp = open(infname, 'w') wr = csv.writer(fp, delimiter=',', quoting=csv.QUOTE_NONE, escapechar=' ') wr.writerow(header) for row in data: new_row = []
import os import sys import glob import numpy as np import matplotlib.pyplot as plt import csv from fit_farquhar_model.farquhar_model import FarquharC3 fname = "data2/example2.csv" fp = open(fname, "wb") wr = csv.writer(fp, delimiter=',', quoting=csv.QUOTE_NONE, escapechar=' ') wr.writerow( ["Curve", "Tleaf", "Ci", "Photo", "Par", "Species", "Season", "Leaf"]) deg2kelvin = 273.15 model = FarquharC3(peaked_Jmax=True, peaked_Vcmax=True) Ci = np.arange(0, 1500, 150) Par = np.ones(len(Ci)) * 1500. curve = 1 for Tleaf in np.arange(15.0, 40.0, 5.0): Tleaf += deg2kelvin Jmax25 = 150.0 Vcmax25 = Jmax25 / 1.6 r25 = 0.5 Eaj = 30000.0 Eav = 60000.0 deltaSj = 650.0 deltaSv = 650.0 Hdv = 200000.0 Hdj = 200000.0
f = open("/Users/mdekauwe/Desktop/synthetic_data.csv", "w") print >> f, "Species,Leaf,Curve,Photo,Ci,Tleaf,Season,fitgroup" for curve_num in np.unique(df["Curve"]): curve_df = df[df["Curve"] == curve_num] curve_df = curve_df.sort(['Ci'], ascending=True) curve_df.index = range(len(curve_df)) # need to reindex slice #print curve_df["Leaf"][0] leaf_index = curve_df["Leaf"][0] - 1 Vcmax25 = Vvals[leaf_index] Jmax25 = Vvals[leaf_index] * Jfac Rd25 = Vvals[leaf_index] * Rdfac model = FarquharC3(peaked_Jmax=True, peaked_Vcmax=True, model_Q10=False) (An, Anc, Anj) = model.calc_photosynthesis(Ci=curve_df["Ci"], Tleaf=curve_df["Tleaf"], Par=None, Jmax=None, Vcmax=None, Jmax25=Jmax25, Vcmax25=Vcmax25, Rd=None, Q10=None, Eaj=Eaj, Eav=Eav, deltaSj=delSj, deltaSv=delSv, Rd25=Rd25, Ear=Ear,
Example fit to some synthetic data... That's all folks. """ __author__ = "Martin De Kauwe" __version__ = "1.0 (13.08.2012)" __email__ = "*****@*****.**" import os import sys import glob import numpy as np from fit_farquhar_model.farquhar_model import FarquharC3 from fit_farquhar_model.fit_model import FitJmaxVcmaxRd ############################## # Fit Jmax, Vcmax + Rd ############################## ofname = "fitting_results.csv" results_dir = "results" data_dir = "data2" plot_dir = "plots" Egamma = 37830.0 model = FarquharC3(peaked_Jmax=True, peaked_Vcmax=True, Egamma=Egamma) ############################## F = FitJmaxVcmaxRd(model, ofname, results_dir, data_dir, plot_dir) F.main(print_to_screen=False)