hesseflux.functions.fit_functions

Module defines common functions that are used in curve_fit or fmin parameter estimations.

For all fit functions, it defines the functions in two forms (ex. of 3 params):

func(x, p1, p2, p3)

func_p(x, p) with p[0:3]

The first form can be used, for example, with scipy.optimize.curve_fit (ex. function f1x=a+b/x):

p, cov = scipy.optimize.curve_fit(functions.f1x, x, y, p0=[p0,p1])

It also defines two cost functions along with the fit functions, one with the absolute sum, one with the squared sum of the deviations:

cost_func sum(abs(obs-func))

cost2_func sum((obs-func)**2)

These cost functions can be used, for example, with scipy.optimize.minimize:

p = scipy.optimize.minimize(jams.functions.cost_f1x, np.array([p1,p2]), args=(x,y), method=’Nelder-Mead’, options={‘disp’:False})

Note the different argument orders:

curvefit needs f(x,*args) with the independent variable as the first argument and the parameters to fit as separate remaining arguments.

minimize is a general minimiser with respect to the first argument, i.e. func(p,*args).

The module provides also two common cost functions (absolute and squared deviations) where any function in the form func(x, p) can be used as second argument:

cost_abs(p, func, x, y)

cost_square(p, func, x, y)

This means, for example cost_f1x(p, x, y) is the same as cost_abs(p, functions.f1x_p, x, y). For example:

p = scipy.optimize.minimize(jams.functions.cost_abs, np.array([p1,p2]), args=(functions.f1x_p,x,y), method=’Nelder-Mead’, options={‘disp’:False})

The current functions are (the functions have the name in the first column. The seond form has a ‘_p’ appended to the name. The cost functions, which have ‘cost_’ and ‘cost2_’ prepended to the name.):

arrhenius 1 param: Arrhenius temperature dependence of biochemical rates: exp((T-TC25)*E/(T25*R*(T+T0))), parameter: E

f1x 2 params: General 1/x function: a + b/x

fexp 3 params: General exponential function: a + b * exp(c*x)

gauss 2 params: Gauss function: 1/(sig*sqrt(2*pi)) *exp(-(x-mu)**2/(2*sig**2)), parameter: mu, sig

lasslop 6 params: Lasslop et al. (2010) a rectangular, hyperbolic light-response GPP with Lloyd & Taylor (1994) respiration and the maximum canopy uptake rate at light saturation decreases exponentially with VPD as in Koerner (1995)

line0 1 params: Straight line: a*x

line 2 params: Straight line: a + b*x

lloyd_fix 2 params: Lloyd & Taylor (1994) Arrhenius type with T0=-46.02 degC and Tref=10 degC

lloyd_only_rref 1 param: Lloyd & Taylor (1994) Arrhenius type with fixed exponential term

logistic 3 params: Logistic function: a/(1+exp(-b(x-c)))

logistic_offset 4 params: Logistic function with offset: a/(1+exp(-b(x-c))) + d

logistic2_offset 7 params: Double logistic function with offset L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a

poly n params: General polynomial: c0 + c1*x + c2*x**2 + … + cn*x**n

sabx 2 params: sqrt(f1x), i.e. general sqrt(1/x) function: sqrt(a + b/x)

see 3 params: Sequential Elementary Effects fitting function: a*(x-b)**c

This module was written by Matthias Cuntz while at Department of Computational Hydrosystems, Helmholtz Centre for Environmental Research - UFZ, Leipzig, Germany, and continued while at Institut National de Recherche pour l’Agriculture, l’Alimentation et l’Environnement (INRAE), Nancy, France.

Copyright (c) 2012-2020 Matthias Cuntz - mc (at) macu (dot) de Released under the MIT License; see LICENSE file for details.

  • Written Dec 2012 by Matthias Cuntz (mc (at) macu (dot) de)
  • Ported to Python 3, Feb 2013, Matthias Cuntz
  • Added general cost functions cost_abs and cost_square, May 2013, Matthias Cuntz
  • Added line0, Feb 2014, Matthias Cuntz
  • Removed multiline_p, May 2020, Matthias Cuntz
  • Changed to Sphinx docstring and numpydoc, May 2020, Matthias Cuntz

The following functions are provided:

cost_abs(p, func, x, y) General cost function for robust optimising func(x,p) vs.
cost_square(p, func, x, y) General cost function for optimising func(x,p) vs.
arrhenius(T, E) Arrhenius temperature dependence of rates.
arrhenius_p(T, p) Arrhenius temperature dependence of rates.
cost_arrhenius(p, T, rate) Sum of absolute deviations of obs and arrhenius function.
cost2_arrhenius(p, T, rate) Sum of squared deviations of obs and arrhenius.
f1x(x, a, b) General 1/x function: a + b/x
f1x_p(x, p) General 1/x function: a + b/x
cost_f1x(p, x, y) Sum of absolute deviations of obs and general 1/x function: a + b/x
cost2_f1x(p, x, y) Sum of squared deviations of obs and general 1/x function: a + b/x
fexp(x, a, b, c) General exponential function: a + b * exp(c*x)
fexp_p(x, p) General exponential function: a + b * exp(c*x)
cost_fexp(p, x, y) Sum of absolute deviations of obs and general exponential function: a + b * exp(c*x)
cost2_fexp(p, x, y) Sum of squared deviations of obs and general exponential function: a + b * exp(c*x)
gauss(x, mu, sig) Gauss function: 1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )
gauss_p(x, p) Gauss function: 1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )
cost_gauss(p, x, y) Sum of absolute deviations of obs and Gauss function: 1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )
cost2_gauss(p, x, y) Sum of squared deviations of obs and Gauss function: 1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )
lasslop(Rg, et, VPD, alpha, beta0, k, Rref) Lasslop et al.
lasslop_p(Rg, et, VPD, p) Lasslop et al.
cost_lasslop(p, Rg, et, VPD, NEE) Sum of absolute deviations of obs and Lasslop.
cost2_lasslop(p, Rg, et, VPD, NEE) Sum of squared deviations of obs and Lasslop.
line(x, a, b) Straight line: a + b*x
line_p(x, p) Straight line: a + b*x
cost_line(p, x, y) Sum of absolute deviations of obs and straight line: a + b*x
cost2_line(p, x, y) Sum of squared deviations of obs and straight line: a + b*x
line0(x, a) Straight line through origin: a*x
line0_p(x, p) Straight line through origin: a*x
cost_line0(p, x, y) Sum of absolute deviations of obs and straight line through origin: a*x
cost2_line0(p, x, y) Sum of squared deviations of obs and straight line through origin: a*x
lloyd_fix(T, Rref, E0) Lloyd & Taylor (1994) Arrhenius type with T0=-46.02 degC and Tref=10 degC
lloyd_fix_p(T, p) Lloyd & Taylor (1994) Arrhenius type with T0=-46.02 degC and Tref=10 degC
cost_lloyd_fix(p, T, resp) Sum of absolute deviations of obs and Lloyd & Taylor (1994) Arrhenius type.
cost2_lloyd_fix(p, T, resp) Sum of squared deviations of obs and Lloyd & Taylor (1994) Arrhenius type.
lloyd_only_rref(et, Rref) If E0 is know in Lloyd & Taylor (1994) then one can calc the exponential term outside the routine and the fitting becomes linear.
lloyd_only_rref_p(et, p) If E0 is know in Lloyd & Taylor (1994) then one can calc the exponential term outside the routine and the fitting becomes linear.
cost_lloyd_only_rref(p, et, resp) Sum of absolute deviations of obs and Lloyd & Taylor with known exponential term.
cost2_lloyd_only_rref(p, et, resp) Sum of squared deviations of obs and Lloyd & Taylor with known exponential term.
sabx(x, a, b) Square root of general 1/x function: sqrt(a + b/x)
sabx_p(x, p) Square root of general 1/x function: sqrt(a + b/x)
cost_sabx(p, x, y) Sum of absolute deviations of obs and square root of general 1/x function: sqrt(a + b/x)
cost2_sabx(p, x, y) Sum of squared deviations of obs and square root of general 1/x function: sqrt(a + b/x)
poly(x, *args) General polynomial: c0 + c1*x + c2*x**2 + …
poly_p(x, p) General polynomial: c0 + c1*x + c2*x**2 + …
cost_poly(p, x, y) Sum of absolute deviations of obs and general polynomial: c0 + c1*x + c2*x**2 + …
cost2_poly(p, x, y) Sum of squared deviations of obs and general polynomial: c0 + c1*x + c2*x**2 + …
cost_logistic(p, x, y) Sum of absolute deviations of obs and logistic function L/(1+exp(-k(x-x0)))
cost2_logistic(p, x, y) Sum of squared deviations of obs and logistic function L/(1+exp(-k(x-x0)))
cost_logistic_offset(p, x, y) Sum of absolute deviations of obs and logistic function 1/x function: L/(1+exp(-k(x-x0))) + a
cost2_logistic_offset(p, x, y) Sum of squared deviations of obs and logistic function 1/x function: L/(1+exp(-k(x-x0))) + a
cost_logistic2_offset(p, x, y) Sum of absolute deviations of obs and double logistic function with offset: L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a
cost2_logistic2_offset(p, x, y) Sum of squared deviations of obs and double logistic function with offset: L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a
see(x, a, b, c) Fit function of Sequential Elementary Effects: a * (x-b)**c
see_p(x, p) Fit function of Sequential Elementary Effects: a * (x-b)**c
cost_see(p, x, y) Sum of absolute deviations of obs and fit function of Sequential Elementary Effects: a * (x-b)**c
cost2_see(p, x, y) Sum of squared deviations of obs and fit function of Sequential Elementary Effects: a * (x-b)**c
cost_abs(p, func, x, y)[source]

General cost function for robust optimising func(x,p) vs. y with sum of absolute deviations.

Parameters:
  • p (iterable of floats) – parameters
  • func (callable) – fun(x,p) -> float
  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost_square(p, func, x, y)[source]

General cost function for optimising func(x,p) vs. y with sum of square deviations.

Parameters:
  • p (iterable of floats) – parameters
  • func (callable) – fun(x,p) -> float
  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

arrhenius(T, E)[source]

Arrhenius temperature dependence of rates.

Parameters:
  • T (float or array_like of floats) – temperature [degC]
  • E (float) – activation energy [J]
Returns:

function value(s)

Return type:

float

arrhenius_p(T, p)[source]

Arrhenius temperature dependence of rates.

Parameters:
  • T (float or array_like of floats) – temperature [degC]
  • p (iterable) – p[0] is activation energy [J]
Returns:

function value(s)

Return type:

float

cost_arrhenius(p, T, rate)[source]

Sum of absolute deviations of obs and arrhenius function.

Parameters:
  • p (iterable of floats) – p[0] is activation energy [J]
  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_arrhenius(p, T, rate)[source]

Sum of squared deviations of obs and arrhenius.

Parameters:
  • p (iterable of floats) – p[0] is activation energy [J]
  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

f1x(x, a, b)[source]

General 1/x function: a + b/x

Parameters:
  • x (float or array_like of floats) – independent variable
  • a (float) – first parameter
  • b (float) – second parameter
Returns:

function value(s)

Return type:

float

f1x_p(x, p)[source]

General 1/x function: a + b/x

Parameters:
  • x (float or array_like of floats) – independent variable
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

Returns:

function value(s)

Return type:

float

cost_f1x(p, x, y)[source]

Sum of absolute deviations of obs and general 1/x function: a + b/x

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_f1x(p, x, y)[source]

Sum of squared deviations of obs and general 1/x function: a + b/x

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

fexp(x, a, b, c)[source]

General exponential function: a + b * exp(c*x)

Parameters:
  • x (float or array_like of floats) – independent variable
  • a (float) – first parameter
  • b (float) – second parameter
  • c (float) – third parameter
Returns:

function value(s)

Return type:

float

fexp_p(x, p)[source]

General exponential function: a + b * exp(c*x)

Parameters:
  • x (float or array_like of floats) – independent variable
  • p (iterable of floats) –

    parameters (len(p)=3)

    p[0] a

    p[1] b

    p[2] c

Returns:

function value(s)

Return type:

float

cost_fexp(p, x, y)[source]

Sum of absolute deviations of obs and general exponential function: a + b * exp(c*x)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)

    p[0] a

    p[1] b

    p[2] c

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_fexp(p, x, y)[source]

Sum of squared deviations of obs and general exponential function: a + b * exp(c*x)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)

    p[0] a

    p[1] b

    p[2] c

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

gauss(x, mu, sig)[source]

Gauss function: 1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )

Parameters:
  • x (float or array_like of floats) – independent variable
  • mu (float) – mean
  • sig (float) – width
Returns:

function value(s)

Return type:

float

gauss_p(x, p)[source]

Gauss function: 1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )

Parameters:
  • x (float or array_like of floats) – independent variable
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] mean

    p[1] width

Returns:

function value(s)

Return type:

float

cost_gauss(p, x, y)[source]

Sum of absolute deviations of obs and Gauss function: 1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] mean

    p[1] width

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_gauss(p, x, y)[source]

Sum of squared deviations of obs and Gauss function: 1 / (sqrt(2*pi)*sig) * exp( -(x-mu)**2 / (2*sig**2) )

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] mean

    p[1] width

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

lasslop(Rg, et, VPD, alpha, beta0, k, Rref)[source]

Lasslop et al. (2010) is the rectangular, hyperbolic light-response of NEE as by Falge et al. (2001), where the respiration is calculated with Lloyd & Taylor (1994), and the maximum canopy uptake rate at light saturation decreases exponentially with VPD as in Koerner (1995).

Parameters:
  • Rg (float or array_like of floats) – Global radiation [W m-2]
  • et (float or array_like of floats) – Exponential in Lloyd & Taylor: np.exp(E0*(1./(Tref-T0)-1./(T-T0))) []
  • VPD (float or array_like of floats) – Vapour Pressure Deficit [Pa]
  • alpha (float) – Light use efficiency, i.e. initial slope of light response curve [umol(C) J-1]
  • beta0 (float) – Maximum CO2 uptake rate at VPD0=10 hPa [umol(C) m-2 s-1]
  • k (float) – e-folding of exponential decrease of maximum CO2 uptake with VPD increase [Pa-1]
  • Rref (float) – Respiration at Tref (10 degC) [umol(C) m-2 s-1]
Returns:

net ecosystem exchange [umol(CO2) m-2 s-1]

Return type:

float

lasslop_p(Rg, et, VPD, p)[source]

Lasslop et al. (2010) is the rectangular, hyperbolic light-response of NEE as by Falge et al. (2001), where the respiration is calculated with Lloyd & Taylor (1994), and the maximum canopy uptake rate at light saturation decreases exponentially with VPD as in Koerner (1995).

Parameters:
  • Rg (float or array_like of floats) – Global radiation [W m-2]
  • et (float or array_like of floats) – Exponential in Lloyd & Taylor: np.exp(E0*(1./(Tref-T0)-1./(T-T0))) []
  • VPD (float or array_like of floats) – Vapour Pressure Deficit [Pa]
  • p (iterable of floats) –

    parameters (len(p)=4)

    p[0] Light use efficiency, i.e. initial slope of light response curve [umol(C) J-1]

    p[1] Maximum CO2 uptake rate at VPD0=10 hPa [umol(C) m-2 s-1]

    p[2] e-folding of exponential decrease of maximum CO2 uptake with VPD increase [Pa-1]

    p[3] Respiration at Tref (10 degC) [umol(C) m-2 s-1]

Returns:

net ecosystem exchange [umol(CO2) m-2 s-1]

Return type:

float

cost_lasslop(p, Rg, et, VPD, NEE)[source]

Sum of absolute deviations of obs and Lasslop.

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=4)

    p[0] Light use efficiency, i.e. initial slope of light response curve [umol(C) J-1]

    p[1] Maximum CO2 uptake rate at VPD0=10 hPa [umol(C) m-2 s-1]

    p[2] e-folding of exponential decrease of maximum CO2 uptake with VPD increase [Pa-1]

    p[3] Respiration at Tref (10 degC) [umol(C) m-2 s-1]

  • Rg (float or array_like of floats) – Global radiation [W m-2]
  • et (float or array_like of floats) – Exponential in Lloyd & Taylor: np.exp(E0*(1./(Tref-T0)-1./(T-T0))) []
  • VPD (float or array_like of floats) – Vapour Pressure Deficit [Pa]
  • NEE (float or array_like of floats) – Observed net ecosystem exchange [umol(CO2) m-2 s-1]
Returns:

sum of absolute deviations

Return type:

float

cost2_lasslop(p, Rg, et, VPD, NEE)[source]

Sum of squared deviations of obs and Lasslop.

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=4)

    p[0] Light use efficiency, i.e. initial slope of light response curve [umol(C) J-1]

    p[1] Maximum CO2 uptake rate at VPD0=10 hPa [umol(C) m-2 s-1]

    p[2] e-folding of exponential decrease of maximum CO2 uptake with VPD increase [Pa-1]

    p[3] Respiration at Tref (10 degC) [umol(C) m-2 s-1]

  • Rg (float or array_like of floats) – Global radiation [W m-2]
  • et (float or array_like of floats) – Exponential in Lloyd & Taylor: np.exp(E0*(1./(Tref-T0)-1./(T-T0))) []
  • VPD (float or array_like of floats) – Vapour Pressure Deficit [Pa]
  • NEE (float or array_like of floats) – Observed net ecosystem exchange [umol(CO2) m-2 s-1]
Returns:

sum of squared deviations

Return type:

float

line(x, a, b)[source]

Straight line: a + b*x

Parameters:
  • x (float or array_like of floats) – independent variable
  • a (float) – first parameter
  • b (float) – second parameter
Returns:

function value(s)

Return type:

float

line_p(x, p)[source]

Straight line: a + b*x

Parameters:
  • x (float or array_like of floats) – independent variable
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

Returns:

function value(s)

Return type:

float

cost_line(p, x, y)[source]

Sum of absolute deviations of obs and straight line: a + b*x

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_line(p, x, y)[source]

Sum of squared deviations of obs and straight line: a + b*x

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

line0(x, a)[source]

Straight line through origin: a*x

Parameters:
  • x (float or array_like of floats) – independent variable
  • a (float) – first parameter
Returns:

function value(s)

Return type:

float

line0_p(x, p)[source]

Straight line through origin: a*x

Parameters:
  • x (float or array_like of floats) – independent variable
  • p (iterable of floats) – p[0] is a
Returns:

function value(s)

Return type:

float

cost_line0(p, x, y)[source]

Sum of absolute deviations of obs and straight line through origin: a*x

Parameters:
  • p (iterable of floats) – p[0] is a
  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_line0(p, x, y)[source]

Sum of squared deviations of obs and straight line through origin: a*x

Parameters:
  • p (iterable of floats) – p[0] is a
  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

lloyd_fix(T, Rref, E0)[source]

Lloyd & Taylor (1994) Arrhenius type with T0=-46.02 degC and Tref=10 degC

Parameters:
  • T (float or array_like of floats) – Temperature [K]
  • Rref (float) – Respiration at Tref=10 degC [umol(C) m-2 s-1]
  • E0 (float) – Activation energy [K]
Returns:

Respiration [umol(C) m-2 s-1]

Return type:

float

lloyd_fix_p(T, p)[source]

Lloyd & Taylor (1994) Arrhenius type with T0=-46.02 degC and Tref=10 degC

Parameters:
  • T (float or array_like of floats) – Temperature [K]
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] Respiration at Tref=10 degC [umol(C) m-2 s-1]

    p[1] Activation energy [K]

Returns:

Respiration [umol(C) m-2 s-1]

Return type:

float

cost_lloyd_fix(p, T, resp)[source]

Sum of absolute deviations of obs and Lloyd & Taylor (1994) Arrhenius type.

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] Respiration at Tref=10 degC [umol(C) m-2 s-1]

    p[1] Activation energy [K]

  • T (float or array_like of floats) – Temperature [K]
  • resp (float or array_like of floats) – Observed respiration [umol(C) m-2 s-1]
Returns:

sum of absolute deviations

Return type:

float

cost2_lloyd_fix(p, T, resp)[source]

Sum of squared deviations of obs and Lloyd & Taylor (1994) Arrhenius type.

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] Respiration at Tref=10 degC [umol(C) m-2 s-1]

    p[1] Activation energy [K]

  • T (float or array_like of floats) – Temperature [K]
  • resp (float or array_like of floats) – Observed respiration [umol(C) m-2 s-1]
Returns:

sum of squared deviations

Return type:

float

lloyd_only_rref(et, Rref)[source]

If E0 is know in Lloyd & Taylor (1994) then one can calc the exponential term outside the routine and the fitting becomes linear. One could also use functions.line0.

Parameters:
  • et (float or array_like of floats) – exp-term in Lloyd & Taylor
  • Rref (float) – Respiration at Tref=10 degC [umol(C) m-2 s-1]
Returns:

Respiration [umol(C) m-2 s-1]

Return type:

float

lloyd_only_rref_p(et, p)[source]

If E0 is know in Lloyd & Taylor (1994) then one can calc the exponential term outside the routine and the fitting becomes linear. One could also use functions.line0.

Parameters:
  • et (float or array_like of floats) – exp-term in Lloyd & Taylor
  • p (iterable of floats) – p[0] is respiration at Tref=10 degC [umol(C) m-2 s-1]
Returns:

Respiration [umol(C) m-2 s-1]

Return type:

float

cost_lloyd_only_rref(p, et, resp)[source]

Sum of absolute deviations of obs and Lloyd & Taylor with known exponential term.

Parameters:
  • p (iterable of floats) – p[0] is respiration at Tref=10 degC [umol(C) m-2 s-1]
  • et (float or array_like of floats) – exp-term in Lloyd & Taylor
  • resp (float or array_like of floats) – Observed respiration [umol(C) m-2 s-1]
Returns:

sum of absolute deviations

Return type:

float

cost2_lloyd_only_rref(p, et, resp)[source]

Sum of squared deviations of obs and Lloyd & Taylor with known exponential term.

Parameters:
  • p (iterable of floats) – p[0] is respiration at Tref=10 degC [umol(C) m-2 s-1]
  • et (float or array_like of floats) – exp-term in Lloyd & Taylor
  • resp (float or array_like of floats) – Observed respiration [umol(C) m-2 s-1]
Returns:

sum of squared deviations

Return type:

float

sabx(x, a, b)[source]

Square root of general 1/x function: sqrt(a + b/x)

Parameters:
  • x (float or array_like of floats) – independent variable
  • a (float) – first parameter
  • b (float) – second parameter
Returns:

function value(s)

Return type:

float

sabx_p(x, p)[source]

Square root of general 1/x function: sqrt(a + b/x)

Parameters:
  • x (float or array_like of floats) – independent variable
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

Returns:

function value(s)

Return type:

float

cost_sabx(p, x, y)[source]

Sum of absolute deviations of obs and square root of general 1/x function: sqrt(a + b/x)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_sabx(p, x, y)[source]

Sum of squared deviations of obs and square root of general 1/x function: sqrt(a + b/x)

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=2)

    p[0] a

    p[1] b

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

poly(x, *args)[source]

General polynomial: c0 + c1*x + c2*x**2 + … + cn*x**n

Parameters:
  • x (float or array_like of floats) – independent variable
  • *args (float) – parameters len(args)=n+1
Returns:

function value(s)

Return type:

float

poly_p(x, p)[source]

General polynomial: c0 + c1*x + c2*x**2 + … + cn*x**n

Parameters:
  • x (float or array_like of floats) – independent variable
  • p (iterable of floats) – parameters (len(p)=n+1)
Returns:

function value(s)

Return type:

float

cost_poly(p, x, y)[source]

Sum of absolute deviations of obs and general polynomial: c0 + c1*x + c2*x**2 + … + cn*x**n

Parameters:
  • p (iterable of floats) – parameters (len(p)=n+1)
  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_poly(p, x, y)[source]

Sum of squared deviations of obs and general polynomial: c0 + c1*x + c2*x**2 + … + cn*x**n

Parameters:
  • p (iterable of floats) – parameters (len(p)=n+1)
  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

cost_logistic(p, x, y)[source]

Sum of absolute deviations of obs and logistic function L/(1+exp(-k(x-x0)))

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)

    p[0] L - Maximum of logistic function

    p[1] k - Steepness of logistic function

    p[2] x0 - Inflection point of logistic function

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_logistic(p, x, y)[source]

Sum of squared deviations of obs and logistic function L/(1+exp(-k(x-x0)))

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)

    p[0] L - Maximum of logistic function

    p[1] k - Steepness of logistic function

    p[2] x0 - Inflection point of logistic function

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

cost_logistic_offset(p, x, y)[source]

Sum of absolute deviations of obs and logistic function 1/x function: L/(1+exp(-k(x-x0))) + a

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=4)

    p[0] L - Maximum of logistic function

    p[1] k - Steepness of logistic function

    p[2] x0 - Inflection point of logistic function

    p[3] a - Offset of logistic function

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_logistic_offset(p, x, y)[source]

Sum of squared deviations of obs and logistic function 1/x function: L/(1+exp(-k(x-x0))) + a

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=4)

    p[0] L - Maximum of logistic function

    p[1] k - Steepness of logistic function

    p[2] x0 - Inflection point of logistic function

    p[3] a - Offset of logistic function

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

cost_logistic2_offset(p, x, y)[source]

Sum of absolute deviations of obs and double logistic function with offset: L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=7)

    p[0] L1 - Maximum of first logistic function

    p[1] k1 - Steepness of first logistic function

    p[2] x01 - Inflection point of first logistic function

    p[3] L2 - Maximum of second logistic function

    p[4] k2 - Steepness of second logistic function

    p[5] x02 - Inflection point of second logistic function

    p[6] a - Offset of double logistic function

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_logistic2_offset(p, x, y)[source]

Sum of squared deviations of obs and double logistic function with offset: L1/(1+exp(-k1(x-x01))) - L2/(1+exp(-k2(x-x02))) + a

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=7)

    p[0] L1 - Maximum of first logistic function

    p[1] k1 - Steepness of first logistic function

    p[2] x01 - Inflection point of first logistic function

    p[3] L2 - Maximum of second logistic function

    p[4] k2 - Steepness of second logistic function

    p[5] x02 - Inflection point of second logistic function

    p[6] a - Offset of double logistic function

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float

see(x, a, b, c)[source]

Fit function of Sequential Elementary Effects: a * (x-b)**c

Parameters:
  • x (float or array_like of floats) – independent variable
  • a (float) – first parameter
  • b (float) – second parameter
  • c (float) – third parameter
Returns:

function value(s)

Return type:

float

see_p(x, p)[source]

Fit function of Sequential Elementary Effects: a * (x-b)**c

Parameters:
  • x (float or array_like of floats) – independent variable
  • p (iterable of floats) –

    parameters (len(p)=3)

    p[0] a

    p[1] b

    p[2] c

Returns:

function value(s)

Return type:

float

cost_see(p, x, y)[source]

Sum of absolute deviations of obs and fit function of Sequential Elementary Effects: a * (x-b)**c

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)

    p[0] a

    p[1] b

    p[2] c

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of absolute deviations

Return type:

float

cost2_see(p, x, y)[source]

Sum of squared deviations of obs and fit function of Sequential Elementary Effects: a * (x-b)**c

Parameters:
  • p (iterable of floats) –

    parameters (len(p)=3)

    p[0] a

    p[1] b

    p[2] c

  • x (float or array_like of floats) – independent variable
  • y (float or array_like of floats) – dependent variable, observations
Returns:

sum of squared deviations

Return type:

float