Lookup Tables
For an example outlining how to extract bounds from lookup tables see apply_adjust Scheme Example.
Module for creating lookup tables and lookup table equations.
- exception rtctools_simulation.lookup_table.GridCoordinatesNotFoundError[source]
Error when unable to extract coordinates from a rectangular grid.
- rtctools_simulation.lookup_table.extract_from_multiple_csv(file: Path, data_dir: Path = None, extraction_type='lookup_tables') Dict[source]
Extract a dictionary of information from lookup tables.
- Parameters:
file – CSV File that describes lookup tables. The column names correspond to the parameters of
get_lookup_table_from_csv(). In case of multiple input variables, they should be separated by a whitespace.data_dir – Directory that contains the interpolation data for the lookup tables. By default, the directory of the csv file is used.
extraction_type – str (default: “lookup_tables”) Data to be extracted from lookup tables. Options are “lookup_tables” or “lookup_tables_bounds”
- Returns:
dict of lookup tables.
- rtctools_simulation.lookup_table.get_empty_lookup_table(name: str, var_in: str | list[str], var_out: str) Function[source]
Get a lookup table that always returns zero.
- Parameters:
name – name of the lookup table.
var_in – Input variable(s) of the lookup table.
var_out – Output variable of the lookup table.
- Returns:
lookup table in the form of a Casadi function.
- rtctools_simulation.lookup_table.get_lookup_table_bounds_from_csv(file: Path, var_in: str | list[str], var_out: str) Dict[source]
Get the bounds from a lookup table csv.
- Parameters:
file – CSV file containing data points for different variables.
var_in – Input variable(s) of the lookup table. Should be one of the CSV file columns.
var_out – Output variable of the lookup table. Should be one of the CSV file columns.
- Returns:
a dictionary containing the min and max values for each input and output variable in the lookup table.
- rtctools_simulation.lookup_table.get_lookup_table_data_from_csv(file: Path, var_in: str | list[str], var_out: str)[source]
Get lookup table data from a csv file. The lookup table is reduced if inputs are constant.
- Parameters:
file – CSV file containing data points for different variables.
var_in – Input variable(s) of the lookup table. Should be one of the CSV file columns.
var_out – Output variable of the lookup table. Should be one of the CSV file columns.
- Returns:
The coordinates and values from the reduced lookup table
- rtctools_simulation.lookup_table.get_lookup_table_equations_from_csv(file: Path, lookup_tables: Dict[str, Function], variables: Dict[str, MX], allow_missing_lookup_tables=False) List[MX][source]
Get a list of lookup-table equations described by a csv file.
- Parameters:
file –
CSV File that describes equations involving lookup tables. These equations are of the form var_out = lookup_table(var_in). The csv file consists of the following columns:
lookup_table: Name of the lookup table.
var_in: Input variable(s) of the lookup table. Should be defined in the model. In case of multiple input variables, they should be separated by a whitespace.
var_out: Output variable of the lookup table. Should be defined in the model.
lookup_tables – Dict of lookup tables.
variables – Dict of symbolic variables used in the model.
allow_missing_lookup_tables – If True, replace missing lookup tables with empty tables.
- Returns:
list of equations.
- rtctools_simulation.lookup_table.get_lookup_table_from_csv(name: str, file: Path, var_in: str | list[str], var_out: str) Function[source]
Get a lookup table from a csv file.
- Parameters:
name – name of the lookup table
file – CSV file containing data points for different variables.
var_in – Input variable(s) of the lookup table. Should be one of the CSV file columns.
var_out – Output variable of the lookup table. Should be one of the CSV file columns.
- Returns:
lookup table in the form of a Casadi function.
- rtctools_simulation.lookup_table.get_lookup_tables_bounds_from_csv(file: Path, data_dir: Path = None) Dict[source]
Get a dict of lookup tables bounds described in a csv file.
- Parameters:
file – CSV File that describes lookup tables. The column names correspond to the parameters of
get_lookup_table_from_csv(). In case of multiple input variables, they should be separated by a whitespace.data_dir – Directory that contains the interpolation data for the lookup tables. By default, the directory of the csv file is used.
- Returns:
dict of lookup table bounds.
- rtctools_simulation.lookup_table.get_lookup_tables_from_csv(file: Path, data_dir: Path = None) Dict[str, Function][source]
Get a dict of lookup tables described by a csv file.
- Parameters:
file – CSV File that describes lookup tables. The column names correspond to the parameters of
get_lookup_table_from_csv(). In case of multiple input variables, they should be separated by a whitespace.data_dir – Directory that contains the interpolation data for the lookup tables. By default, the directory of the csv file is used.
- Returns:
dict of lookup tables.