Interpolation tables visualization

Old style - Deprecated:
You can visualize a list of numbers as a graph of an interpolation table, where x and y entries are alternating \(x_1 \quad y_1 \quad x_2 \quad y_2 \quad ... \quad x_n \quad y_n\). This is the way the FST-origined sim components (Lintul, Gecros ...) handle interpolation tables (implementing the FST-Function AFGEN).

New style:
You can give x and y entries by two arrays with \(x_1 \quad x_2 \quad ... \quad x_n\) and \(y_1 \quad y_2 \quad ... \quad y_n\).
Please enter the numbers separated by comma or space.

New style
X-values:
Y-values:

Old style
X|Y-values:

Formula

Given the numbers \(x_1 \quad y_1 \quad x_2 \quad y_2 \quad ... \quad x_n \quad y_n\) with \(x_1 \lt x_2 \lt ... \lt x_n \), the interpolation algorithm defines a piecewise linear function \[ f(x) := \begin{cases} y_1 & \text{for} & x \lt x_1 & \text{(extrapol.)}\\ \\ \dfrac{y_{k+1} - y_{k}}{x_{k+1} -x_{k}} (x-x_{k}) + y_{k} & \text{for} & x_k \leq x \lt x_{k+1}, \quad k=1 ... n-1 & \text{(interpol.)}\\ \\ y_n & \text{for} & x_n \leq x & \text{(extrapol.)} \end{cases} \]

Example pitfalls

Here you see some possible pitfalls when using interpolation tables. Click on the small graph icon to visualize the graph. Red number sets represent wrong interpolation tables, green ones represent correct tables.

Isolated events (irrigation, fertilizer tables, other look-up tables)

If you want to irrigate only on DOY 12 and 31, then providing the values only for these days in the table might give you unexpected results: for the other days values are interpolated, giving you irrigation on all days.
12 61 31 28

You have to provide y-values of 0 for the preceding and following days, as you can see here:
11 0 12 61 13 0 30 0 31 28 32 0

Notice: If x values are real numbers and not integer, then you might add 0 y-values to \(x_k - \delta \) and \(x_k + \delta \), with \(0 \lt \delta \ll 1\) (i. e. \(\delta\) is small positive number).
1.39999 0 1.4 61 1.40001 0 3.4999 0 3.5 28 3.50001 0

Unordered x-Values in interpolation table

The table has to be sorted by x-values. See what happens if not:
30 0 31 28 32 0 11 0 12 61 13 0
It is not a graph of a function anymore, so interpolation is not well defined (for days 12 and 31 you have 2 possible values!). Interpolated results might be arbitrary and not what you expect.

Adding some jitter on the y-values make the problem even more obvious
30 0 31 28 32 2 11 2 12 61 13 4

Ordering the table by x-values gives a proper graph where unambigous interpolation is possible
11 0 12 61 13 0 30 0 31 28 32 0

Repeated x-values

x-values have to be different - providing two y-values to same x-value makes the interpolation at this point ambigous:
0 5 1 2 1 3 2 4

If your function has "jumps", then just change one of the repeated x-value by a small amount
0 5 1 2 1.05 3 2 4

It could be a really small amount
0 5 1 2 1.000000000001 3 2 4

Wrong shaped tables

The number of entries has to be even (as many x- as y-values). Otherwise the last entry is discarded.
0 10 2 7 3 8 4

If you provide only y-values, then interpolation will for sure not do what you expect, e.g. LUE dependend on DVS:
Right: 0 3.2 1 3.1 1.5 3.15 2.0 3.03
Wrong: 3.2 3.1 3.15 3.03

Interpolation tables in Simplace

New style

An interpolation table is provided as two SimVariables of datatype DOUBLEARRAY.

The naming of the two SimVariables follows the scheme VariablenameTableXVariable VariablenameTableYVariable.

Example: cLeavesPartitioningTableDVS and cLeavesPartitioningTableFraction define the interpolation table for leaves partitioning. From the description of the second variable "Fraction of above-ground dry matter to leaves as function of DVS" one can see that Fraction depends on DVS, so DVS is the X value and Fraction the Y value.

Notice: for backward compatibility, most of the older SimComponents support both styles. That means one could use either one variable with alternating values, or a pair of variables. The description of the new variables indicates which is the old (alternating) variable. However, you should not use both styles at the same time, as one may get confused. If you set old and new variables at the same time, then the new ones will be used.

   <parameter id="crop_key" datatype="CHAR">wheat</parameter>
   <parameter id="cLeavesPartitioningTableDVS" datatype="DOUBLEARRAY">
     <value>0</value> 
     <value>1</value> 
     <value>1.1</value> 
     <value>2</value> 
   </parameter>
   <parameter id="cLeavesPartitioningTableFraction" datatype="DOUBLEARRAY">
     <value>.4</value> 
     <value>.3</value>
     <value>.0</value> 
     <value>.0</value> 
   </parameter>
 

In CSV files, you can provide the table in long format:

crop_keycLeavesPartitioningTableDVScLeavesPartitioningTableFraction
wheat0.4
wheat1.3
wheat1.1.0
wheat2.0
barley0.33
barley1.2
barley2.0

Old style - DEPRECATED

An interpolation table is provided as a SimVariable of datatype DOUBLEARRAY. You can use CSV files as well as XML files to provide the table.

Although you can write the values in the XML file in any shape (linebreaks, spaces etc.), I recommend to put always two values side by side, so that the reader can quickly recognize the x/y-value pairs:

   <parameter id="crop_key" datatype="CHAR">wheat</parameter>
   <parameter id="Irrigation" datatype="DOUBLEARRAY">
     <value>12</value> <value>0</value>
     <value>13</value> <value>61</value>
     <value>14</value> <value>0</value>
   </parameter>
 

In CSV files, you can provide the table in long format:

crop_keyIrrigTable
wheat12
wheat0
wheat13
wheat61
wheat14
wheat0
barley11
barley0
barley12
barley38
barley13
barley0
barley33
barley0
barley34
barley20
barley35
barley0

If the tables for all crops (resource keys) have same length, then you can use the more compact wide format:

crop_keyIrrigTable_1IrrigTable_2IrrigTable_3IrrigTable_4IrrigTable_5IrrigTable_6
wheat 12 0 13 61 14 0
barley 11 0 12 38 13 0