Lookup tables

class rtctools.optimization.csv_lookup_table_mixin.LookupTable(inputs: List[MX], function: Function, tck: Tuple = None)[source]

Bases: LookupTable

Lookup table.

__call__(*args: float | Iterable | Timeseries) float | ndarray | Timeseries[source]

Evaluate the lookup table.


args (Float, iterable of floats, or Timeseries) – Input values.


Lookup table evaluated at input values.

Example use:

y = lookup_table(1.0)
[y1, y2] = lookup_table([1.0, 2.0])
class rtctools.optimization.csv_lookup_table_mixin.CSVLookupTableMixin(**kwargs)[source]

Bases: OptimizationProblem

Adds lookup tables to your optimization problem.

During preprocessing, the CSV files located inside the lookup_tables subfolder are read. In every CSV file, the first column contains the output of the lookup table. Subsequent columns contain the input variables.

Cubic B-Splines are used to turn the data points into continuous lookup tables.

Optionally, a file curvefit_options.ini may be included inside the lookup_tables folder. This file contains, grouped per lookup table, the following options:

  • monotonicity:
    • is an integer, magnitude is ignored

    • if positive, causes spline to be monotonically increasing

    • if negative, causes spline to be monotonically decreasing

    • if 0, leaves spline monotonicity unconstrained

  • curvature:
    • is an integer, magnitude is ignored

    • if positive, causes spline curvature to be positive (convex)

    • if negative, causes spline curvature to be negative (concave)

    • if 0, leaves spline curvature unconstrained


Currently only one-dimensional lookup tables are fully supported. Support for two- dimensional lookup tables is experimental.

  • csv_delimiter – Column delimiter used in CSV files. Default is ,.

  • csv_lookup_table_debug – Whether to generate plots of the spline fits. Default is False.

  • csv_lookup_table_debug_points – Number of evaluation points for plots. Default is 100.


Returns a dictionary of lookup tables.


ensemble_member – The ensemble member index.


A dictionary of variable names and lookup tables.