def muf(alpha_log10=3, c=13, g1_log10=1.3, kxmax_log10=3, p50=-2.5,
        T=T, I=I, D=D, ps=ps, day_len=day_len,\
        ca=400, Kc=460, q=0.3, R=8.314, z1=0.9, z2=0.9999, a=1.6, L=1,
        Jmax=122, Vcmax=61):
    alpha, g1, kxmax = 10**alpha_log10, 10**g1_log10,\
                          10**kxmax_log10
    sapflow_modeled = []
    for i in range(len(T)):
        Ti, Ii, Di, psi = T.iloc[i], I.iloc[i], D.iloc[i], ps.iloc[i]
        dayi = day_len.iloc[i]
        # px
        pxmin = pxminf(psi, p50)
        pxmax = optimize.minimize_scalar(pxf2, bounds=(pxmin, psi),\
                                         method='bounded',\
                                         args=(Ti, Ii, Di, psi, Kc, Vcmax, ca,\
                                               q, Jmax, z1, z2, R, g1, c,\
                                               kxmax, p50, a, L))
        px1 = pxf2(pxmin, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2, R,\
                   g1, c, kxmax, p50, a, L)
        px2 = pxf2(pxmax.x, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2,\
                   R, g1, c, kxmax, p50, a, L)
        if px1 * px2 < 0:
            px = optimize.brentq(pxf2, pxmin, pxmax.x, args=(Ti, Ii, Di, psi,\
                                                             Kc, Vcmax, ca, q,\
                                                             Jmax, z1, z2, R,\
                                                             g1, c, kxmax,\
                                                             p50, a, L))
            sapflow_modeled.append(kxf(px, kxmax, p50)*(psi-px)*30*60*18/\
                                   1000000/alpha*dayi)
        else:
            sapflow_modeled.append(np.nan)
    return sapflow_modeled
示例#2
0
def testf(X,
          env,
          Vcmax=60,
          Jmax=120,
          ca=400,
          Kc=460,
          q=0.3,
          R=8.314,
          z1=0.9,
          z2=0.9999,
          a=1.6,
          L=1):
    alpha_log10, c_log10, g1_log10, kxmax_log10, p50, ps = X
    c, g1, kxmax = 10**c_log10, 10**g1_log10, 10**kxmax_log10
    T, I, D, dayi = env
    pxmin = pxminf(ps, p50)
    pxmax = optimize.minimize_scalar(pxf2,
                                     bounds=(pxmin, ps),
                                     method='bounded',
                                     args=(T, I, D, ps, Kc, Vcmax, ca, q, Jmax,
                                           z1, z2, R, g1, c, kxmax, p50, a, L))
    px1 = pxf2(pxmin, T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1, z2, R, g1, c,
               kxmax, p50, a, L)
    px2 = pxf2(pxmax.x, T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1, z2, R, g1, c,
               kxmax, p50, a, L)
    return px1 * px2
def muf(X, T, I, D, ps, Vcmax, Jmax,\
        ca=400, Kc=460, q=0.3, R=8.314, z1=0.9, z2=0.9999, a=1.6, rho=997000,\
        L=1):
    alpha_log10, c, g1, kxmax_log10, p50 = X
    alpha, kxmax = 10**alpha_log10, 10**kxmax_log10
    sapflow_modeled, gs_closure, PLC = [], [], []
    f1 = lambda x: np.exp(-x * c)
    for i in range(len(T)):
        Ti, Ii, Di, psi = T.iloc[i], I.iloc[i], D.iloc[i], ps.iloc[i]
        # px
        pxmin = pxminf(psi, p50)
        pxmax = optimize.minimize_scalar(pxf2, bounds=(pxmin, psi),\
                                         method='bounded',\
                                         args=(Ti, Ii, Di, psi, Kc, Vcmax,\
                                               ca, q, Jmax, z1, z2, R, g1, c,\
                                               kxmax, p50, a, L))
        px1 = pxf2(pxmin, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2, R,\
                   g1, c, kxmax, p50, a, L)
        px2 = pxf2(pxmax.x, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2,\
                   R, g1, c, kxmax, p50, a, L)
        if px1 * px2 < 0:
            px = optimize.brentq(pxf2, pxmin, pxmax.x, args=(Ti, Ii, Di, psi,\
                                                             Kc, Vcmax, ca,\
                                                             q, Jmax, z1, z2,\
                                                             R, g1, c, kxmax,\
                                                             p50, a, L))
            sapflow_modeled.append(kxf(px, kxmax, p50)*(psi-px)*18/1000000/\
                                   1000*rho/alpha)
            PLC.append(PLCf(px, p50))
            gs_closure.append((f1(PLCf(px, p50)) - f1(1)) / (f1(0) - f1(1)))
        else:
            sapflow_modeled.append(np.nan)
            PLC.append(np.nan)
            gs_closure.append(np.nan)
    return sapflow_modeled, PLC, gs_closure
def muf(X, T, I, D, ps, Vcmax, Jmax,\
        ca=400, Kc=460, q=0.3, R=8.314, z1=0.9, z2=0.9999, a=1.6, L=1):
    alpha_log10, c, g1_log10, kxmax_log10, p50 = X
    g1, kxmax = 10**g1_log10, 10**kxmax_log10
    A = []
    for i in range(len(T)):
        Ti, Ii, Di, psi = T.iloc[i], I.iloc[i], D.iloc[i], ps.iloc[i]
        # px
        pxmin = pxminf(psi, p50)
        pxmax = optimize.minimize_scalar(pxf2, bounds=(pxmin, psi),\
                                         method='bounded',\
                                         args=(Ti, Ii, Di, psi, Kc, Vcmax,\
                                               ca, q, Jmax, z1, z2, R, g1, c,\
                                               kxmax, p50, a, L))
        px1 = pxf2(pxmin, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2, R,\
                   g1, c, kxmax, p50, a, L)
        px2 = pxf2(pxmax.x, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2,\
                   R, g1, c, kxmax, p50, a, L)
        if px1 * px2 < 0:
            px = optimize.brentq(pxf2, pxmin, pxmax.x, args=(Ti, Ii, Di, psi,\
                                                             Kc, Vcmax, ca,\
                                                             q, Jmax, z1, z2,\
                                                             R, g1, c, kxmax,\
                                                             p50, a, L))
            gs = kxf(px, kxmax, p50) * (psi - px) / (1000 * a * Di * L)
            A_gs = Af(gs, Ti, Ii, Kc, Vcmax, ca, q, Jmax, z1, z2, R)
            A_max = Af(1000, Ti, Ii, Kc, Vcmax, ca, q, Jmax, z1, z2, R)
            A.append(A_gs / A_max)
        else:
            A.append(np.nan)
    return A
示例#5
0
def muf(X, T, I, D, ps, Vcmax, Jmax,\
        ca=400, Kc=460, q=0.3, R=8.314, z1=0.9, z2=0.9999, a=1.6, rho=997000,\
        L=1):
    _, c, g1, kxmax_log10, p50 = X
    kxmax = 10**kxmax_log10
    res = []
    for i in range(len(T)):
        Ti, Ii, Di, psi = T.iloc[i], I.iloc[i], D.iloc[i], ps.iloc[i]
        # px
        pxmin = pxminf(psi, p50)
        pxmax = optimize.minimize_scalar(pxf2, bounds=(pxmin, psi),\
                                         method='bounded',\
                                         args=(Ti, Ii, Di, psi, Kc, Vcmax,\
                                               ca, q, Jmax, z1, z2, R, g1, c,\
                                               kxmax, p50, a, L))
        px1 = pxf2(pxmin, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2, R,\
                   g1, c, kxmax, p50, a, L)
        px2 = pxf2(pxmax.x, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2,\
                   R, g1, c, kxmax, p50, a, L)
        if px1 * px2 < 0:
            px = optimize.brentq(pxf2, pxmin, pxmax.x, args=(Ti, Ii, Di, psi,\
                                                             Kc, Vcmax, ca,\
                                                             q, Jmax, z1, z2,\
                                                             R, g1, c, kxmax,\
                                                             p50, a, L))
            PLC = PLCf(px, p50)
            gs = kxf(px, kxmax, p50) * (psi - px) / (1000 * a * Di * L)
            res.append([PLC, gs])
        else:
            res.append([np.nan, np.nan])
    return res
示例#6
0
def muf(alpha_log10=1,
        c_log10=0,
        g1_log10=1,
        kxmax_log10=3,
        p50=-1,
        ps=-0.5,
        ca=400,
        Kc=460,
        q=0.3,
        R=8.314,
        Jmax=80,
        Vcmax=30,
        z1=0.9,
        z2=0.9999,
        a=1.6,
        L=1):
    alpha, c, g1, kxmax = 10**alpha_log10, 10**c_log10, 10**g1_log10, 10**kxmax_log10
    sapflow_modeled = []
    for i in range(len(vn)):
        # Environmental conditions
        Ti, Ii, Di = T.iloc[i], I.iloc[i], D.iloc[i]
        # px
        pxmin = pxminf(ps, p50)
        if pxmin < ps:
            pxmax = optimize.minimize_scalar(pxf2,
                                             bounds=(pxmin, ps),
                                             method='bounded',
                                             args=(Ti, Ii, Di, ps, Kc, Vcmax,
                                                   ca, q, Jmax, z1, z2, R, g1,
                                                   c, kxmax, p50, a, L))
            px1 = pxf2(pxmin, Ti, Ii, Di, ps, Kc, Vcmax, ca, q, Jmax, z1, z2,
                       R, g1, c, kxmax, p50, a, L)
            px2 = pxf2(pxmax.x, Ti, Ii, Di, ps, Kc, Vcmax, ca, q, Jmax, z1, z2,
                       R, g1, c, kxmax, p50, a, L)
            if px1 * px2 < 0:
                px = optimize.brentq(pxf2,
                                     pxmin,
                                     pxmax.x,
                                     args=(Ti, Ii, Di, ps, Kc, Vcmax, ca, q,
                                           Jmax, z1, z2, R, g1, c, kxmax, p50,
                                           a, L))
                sapflow_modeled.append(
                    kxf(px, kxmax, p50) * (ps - px) * 30 * 60 * 18 / 1000000 /
                    vn_max / alpha)
            else:
                if abs(px1) < abs(px2):
                    sapflow_modeled.append(1)
                else:
                    sapflow_modeled.append(0)
        else:
            print('pxmin > ps')
            sapflow_modeled.append(0)
    return sapflow_modeled
def muf(alpha_log10=-2,
        c=6,
        g1=0.5,
        kxmax_log10=2,
        p50=-1,
        ca=400,
        Kc=460,
        q=0.3,
        R=8.314,
        Vcmax=Vcmax,
        Jmax=Jmax,
        z1=0.9,
        z2=0.9999,
        a=1.6,
        rho=997000,
        L=1):
    alpha, kxmax = 10**alpha_log10, 10**kxmax_log10
    sapflow_modeled = []
    for i in range(len(vn)):
        # Environmental conditions
        Ti, Ii, Di, psi = T.iloc[i], I.iloc[i], D.iloc[i], ps.iloc[i]
        # px
        pxmin = pxminf(psi, p50)
        if pxmin < psi:
            pxmax = optimize.minimize_scalar(pxf2,
                                             bounds=(pxmin, psi),
                                             method='bounded',
                                             args=(Ti, Ii, Di, psi, Kc, Vcmax,
                                                   ca, q, Jmax, z1, z2, R, g1,
                                                   c, kxmax, p50, a, L))
            px1 = pxf2(pxmin, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2,
                       R, g1, c, kxmax, p50, a, L)
            px2 = pxf2(pxmax.x, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1,
                       z2, R, g1, c, kxmax, p50, a, L)
            if px1 * px2 < 0:
                px = optimize.brentq(pxf2,
                                     pxmin,
                                     pxmax.x,
                                     args=(Ti, Ii, Di, psi, Kc, Vcmax, ca, q,
                                           Jmax, z1, z2, R, g1, c, kxmax, p50,
                                           a, L))
                sapflow_modeled.append(
                    kxf(px, kxmax, p50) * (psi - px) * 18 / 1000000 / 1000 *
                    rho / alpha)
            else:
                sapflow_modeled.append(np.nan)
        else:
            sapflow_modeled.append(np.nan)
        print(kxf(px, kxmax, p50) * (psi - px) / (1000 * a * Di))
    return sapflow_modeled
def muf(X,
        T,
        I,
        D,
        ps,
        Jmax,
        Vcmax,
        ca=400,
        Kc=460,
        q=0.3,
        R=8.314,
        z1=0.9,
        z2=0.9999,
        a=1.6):
    alpha, c, p50, kxmax, g1, L = X
    gs = []
    for i in range(len(T)):
        Ti, Ii, Di, psi = T.iloc[i], I.iloc[i], D.iloc[i], ps.iloc[i]
        # px
        pxmin = pxminf(psi, p50)
        pxmax = optimize.minimize_scalar(pxf2,
                                         bounds=(pxmin, psi),
                                         method='bounded',
                                         args=(Ti, Ii, Di, psi, Kc, Vcmax, ca,
                                               q, Jmax, z1, z2, R, g1, c,
                                               kxmax, p50, a, L))
        px1 = pxf2(pxmin, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2, R,
                   g1, c, kxmax, p50, a, L)
        px2 = pxf2(pxmax.x, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2, R,
                   g1, c, kxmax, p50, a, L)
        if px1 * px2 < 0:
            px = optimize.brentq(pxf2,
                                 pxmin,
                                 pxmax.x,
                                 args=(Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax,
                                       z1, z2, R, g1, c, kxmax, p50, a, L))
            PLC = PLCf(px, p50)
            f1 = lambda x: np.exp(-x * c)
            f2 = lambda x: (f1(x) - f1(1)) / (f1(0) - f1(1))
            gs.append(f2(PLC))
        else:
            if abs(px1) < abs(px2):
                gs.append(1)
            else:
                gs.append(0)
    return gs
示例#9
0
def muf(X,
        T,
        I,
        D,
        ps,
        Jmax,
        Vcmax,
        ca=400,
        Kc=460,
        q=0.3,
        R=8.314,
        z1=0.9,
        z2=0.9999,
        a=1.6,
        l=1.8 * 10**(-5),
        u=48240):
    alpha, c, p50, kxmax, g1, L = X
    sapflow_modeled = []
    for i in range(len(T)):
        Ti, Ii, Di, psi = T.iloc[i], I.iloc[i], D.iloc[i], ps.iloc[i]
        # px
        pxmin = pxminf(psi, p50)
        pxmax = optimize.minimize_scalar(pxf2,
                                         bounds=(pxmin, psi),
                                         method='bounded',
                                         args=(Ti, Ii, Di, psi, Kc, Vcmax, ca,
                                               q, Jmax, z1, z2, R, g1, c,
                                               kxmax, p50, a, L))
        px1 = pxf2(pxmin, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2, R,
                   g1, c, kxmax, p50, a, L)
        px2 = pxf2(pxmax.x, Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax, z1, z2, R,
                   g1, c, kxmax, p50, a, L)
        if px1 * px2 < 0:
            px = optimize.brentq(pxf2,
                                 pxmin,
                                 pxmax.x,
                                 args=(Ti, Ii, Di, psi, Kc, Vcmax, ca, q, Jmax,
                                       z1, z2, R, g1, c, kxmax, p50, a, L))
            sapflow_modeled.append(l * u * kxf(px, kxmax, p50) * (psi - px) /
                                   1000 / alpha)
        else:
            if abs(px1) < abs(px2):
                sapflow_modeled.append(1)
            else:
                sapflow_modeled.append(0)
    return sapflow_modeled
示例#10
0
def muf(X, env, Jmax=100, Vcmax=50,
        ca=400, Kc=460, q=0.3, R=8.314, z1=0.9, z2=0.9999,
        a=1.6, l=1.8*10**(-5), u=48240,
        alpha=0.013):
    c, g1, kxmax, p50, L, ps = X
    T, I, D = env
    pxmin = pxminf(ps, p50)
    pxmax = optimize.minimize_scalar(pxf2, bounds=(pxmin, ps), method='bounded', args=(T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1, z2, R, g1, c, kxmax, p50, a, L))
    px1 = pxf2(pxmin, T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1, z2, R, g1, c, kxmax, p50, a, L)
    px2 = pxf2(pxmax.x, T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1, z2, R, g1, c, kxmax, p50, a, L)
    if px1*px2 < 0:
        px = optimize.brentq(pxf2, pxmin, pxmax.x, args=(T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1, z2, R, g1, c, kxmax, p50, a, L))
        return l*u*kxf(px, kxmax, p50)*(ps-px)/1000/alpha
    else:
        if abs(px1) < abs(px2):
            return 1
        else:
            return 0
示例#11
0
def muf(c, p50, T, I, D, ps, day_len,
        g1_log10=1, kxmax_log10=3,
        Vcmax=60, Jmax=120, ca=400, Kc=460, q=0.3, R=8.314, z1=0.9, z2=0.9999,\
        a=1.6, L=1):
    g1, kxmax = 10**g1_log10, 10**kxmax_log10
    pxmin = pxminf(ps, p50)
    pxmax = optimize.minimize_scalar(pxf2, bounds=(pxmin, ps),\
                                     method='bounded',\
                                     args=(T, I, D, ps, Kc, Vcmax, ca, q,\
                                           Jmax, z1, z2, R, g1, c, kxmax, p50,\
                                           a, L)).x
    px1 = pxf2(pxmin, T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1, z2, R, g1, c,\
               kxmax, p50, a, L)
    px2 = pxf2(pxmax, T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1, z2, R, g1, c,\
               kxmax, p50, a, L)
    if px1 * px2 < 0:
        px = optimize.brentq(pxf2, pxmin, pxmax,\
                             args=(T, I, D, ps, Kc, Vcmax, ca, q, Jmax, z1,\
                                   z2, R, g1, c, kxmax, p50, a, L))
        return kxf(px, kxmax, p50) * (ps - px) * day_len
    return np.nan