law#

Define a length law of LRs using equal amplitudes method from measured data.

Created on Tue Feb 17 12:56:51 2015

@author: ndour

openalea.hydroroot.law.discretize(x, y, size=0.05)[source]#

Discretize by intervals of size size by using equal amplitudes method

Parameters:
  • x – (float list) - abscissa

  • y – (float list)

  • size – bins size (Default value = 5e-2)

openalea.hydroroot.law.expovariate_law(data_xy, size=0.05, scale_x=0.01, scale_y=1000.0, plot=False)[source]#

Fit a spline law from measured data by adding stochasticity.

To compute the law, data are first sampled using equal amplitude method. Then, a mean is computed on each sample. Then, an expovariate distribution is simulated from the mean of each sample. Finally a spline is interpolated based on the simulated data.

Parameters:
  • data_xy – the data to fit

  • size – the sample size (Default value = 5e-2)

  • scale_x – a scaling factor on x array (Default value = 1e-2)

  • scale_y – a scaling factor on x array (Default value = 1e3)

  • plot – True plot the law (Default value = False)

  • Example

>>> filename = 'lr_length_law_data.csv'
    >>> xy = readCSVFile(filename)
    >>> law = fit_law(data_xy=xy, size=5e-2)
openalea.hydroroot.law.histo_relative_law(x, y, size=0.05, scale_x=1.0, scale_y=0.001, scale=0.0001, plot=False, uniform=False)[source]#

Return a function return_law(position, scale=scale) that compute a value from y values (see below) binned according to x divided in bins of size size.

Parameters:
  • x – (list of float)

  • y – (list of float)

  • size – (float) - bins size (Default value = 5e-2)

  • scale_x – (float) - a factor that multiplies x values (Default value = 1.)

  • scale_y – (float) - a factor that multiplies y values (Default value = 1e-3)

  • scale – (float) - a number that divides the length given by the function (Default value = 1e-4)

  • plot – unused (Default value = False)

  • uniform – (string or boolean) - ‘expo’, True or False see below (Default value = False)

Returns:

  • return_law

Algorithm:
  • First, discretize the x values in different intervals of size size.

  • Compute the mean of the set of points included in each interval.

  • Return a function that computes for a given interval at position position : - if uniform=’expo’, randomly a value from an exponential distribution with mean equals to <y> in this interval - if uniform=False, randomly one of the y values in the interval - if uniform=True, a value randomly chosen between min(y) and max(y) in the interval

openalea.hydroroot.law.length_law(pd, scale_x=0.01, scale_y=1.0, scale=0.0001, uniform='expo', size=5)[source]#

Build the function giving the lateral length according to its position on the parent branch

Parameters:
  • pd – DataFrame

  • scale_x – (float) - a factor that multiplies size and x values (Default value = 1 / 100.)

  • scale_y – (float) - a factor that multiplies y values (Default value = 1.)

  • scale – (float) number that will divide the given length, so for instance it used to divide the returned length (by histo_relative_law) by the segment length to get it in number of segment (Default value = 1e-4)

  • uniform – boolean or string (Default value = ‘expo’) see histo_relative_law()

  • size – (Default value = 5)

Returns:

  • a function giving the lateral length according to its position

Remark: This is specific to the length law files:

  • 1st col: “LR_length_mm(mm)” lateral lengths in mm

  • 2nd col: “relative_distance_to_tip” relative distance to tip in % so between 0 and 100.

openalea.hydroroot.law.multi_law(x, y, size=0.05, scale_x=0.0016, scale_y=0.001, plot=False)[source]#

deprecated :param x: :param y: :param size: the bin size (Default value = 5e-2) :param scale_x: (Default value = 0.16/100.) :param scale_y: (Default value = 1e-3) :param plot: (Default value = False)

openalea.hydroroot.law.reference_relative_law(x, y, size=0.05, scale_x=1.0, scale_y=0.001)[source]#

Return a spline that interpolates the binned mean of y, see below for the calculation.

Parameters:
  • x – (list of float)

  • y – (list of float)

  • size – (float) - bins size (Default value = 5e-2)

  • scale_x – (float) - a factor that multiplies x values (Default value = 1.)

  • scale_y – (float) - a factor that multiplies y values (Default value = 1e-3)

Returns:

  • spline

Algorithm:
  • First, discretize the X values in different intervals of size size.

  • Compute the mean of the set of points included in each interval.

  • interpolate with a spline y(x)

Download the source file ../../src/openalea/hydroroot/law.py.