Example: Formulae file

An example a formulae file lives at tests/Example_Config_Formulae/Processing_formulae.csv.

Here, this file will be read and the columns their expected values and use will be discussed. This is done using only the first row, which takes the mean of the three thermocouples, having labels DuctTC1, DuctTC2, DuctTC3. These three thermocouples are the data obtained during acquisition, and correspond to the config file Label. Check out config file example.

import polars as pl
import numpy as np
import matplotlib.pyplot as plt

formulae_file_path = "../tests/Example_Config_Formulae/Processing_formulae.csv"
formulae_df = pl.read_csv(formulae_file_path)
formulae_df.columns = [i.strip() for i in formulae_df.columns]

with pl.Config() as cfg:
    cfg.set_tbl_cols(formulae_df.shape[1])
    cfg.set_tbl_rows(formulae_df.shape[0])
    cfg.set_fmt_str_lengths(100)
    cfg.set_float_precision(3)
    cfg.set_tbl_formatting("UTF8_FULL")
    # cfg.set_tbl_hide_column_data_types(True)
    cfg.set_tbl_hide_dataframe_shape(True)
    pl_cfg_json = cfg.save()
    print(formulae_df)
┌───────────────┬───────────────┬──────────────┬───────────────┬────────┬──────────┬───────────────┐
│ Label         ┆ RHS           ┆ Chart        ┆ Legend        ┆ Layout ┆ Position ┆ Processed_Uni │
│ ---           ┆ ---           ┆ ---          ┆ ---           ┆ ---    ┆ ---      ┆ t             │
│ str           ┆ str           ┆ str          ┆ str           ┆ i64    ┆ i64      ┆ ---           │
│               ┆               ┆              ┆               ┆        ┆          ┆ str           │
╞═══════════════╪═══════════════╪══════════════╪═══════════════╪════════╪══════════╪═══════════════╡
│ Tmean         ┆ (DuctTC1 +    ┆  DuctTC      ┆ Mean gas temp ┆ 2      ┆ 2        ┆ K             │
│               ┆ DuctTC2 +     ┆              ┆               ┆        ┆          ┆               │
│               ┆ DuctTC3)/3    ┆              ┆               ┆        ┆          ┆               │
│               ┆ +273.15       ┆              ┆               ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ KRosemont     ┆ 0.6033        ┆  Constant    ┆ Avg pitot     ┆ 0      ┆ 0        ┆ -             │
│               ┆               ┆              ┆ tube          ┆        ┆          ┆               │
│               ┆               ┆              ┆ coefficient   ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ KDwyer        ┆ 0.81          ┆  Constant    ┆ Dwyer flow    ┆ 0      ┆ 0        ┆ -             │
│               ┆               ┆              ┆ coefficient   ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ rho_e         ┆ 101325*0.0289 ┆ Intermediate ┆ Air density   ┆ 0      ┆ 0        ┆ kg/m^3        │
│               ┆ 6/(8.314*Tmea ┆              ┆ based on      ┆        ┆          ┆               │
│               ┆ n)            ┆              ┆ ideal gas law ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ ID            ┆ 17.8*0.0254   ┆ Intermediate ┆ Internal      ┆ 0      ┆ 0        ┆ m             │
│               ┆               ┆              ┆ diameter of   ┆        ┆          ┆               │
│               ┆               ┆              ┆ the duct in   ┆        ┆          ┆               │
│               ┆               ┆              ┆ inches        ┆        ┆          ┆               │
│               ┆               ┆              ┆ multiplied by ┆        ┆          ┆               │
│               ┆               ┆              ┆ m/inch factor ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ A_duct        ┆ pi*(ID**2)/4  ┆ Intermediate ┆  Duct area    ┆ 0      ┆ 0        ┆ m^2           │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ vel_e         ┆ KRosemont*sqr ┆  DuctFlow    ┆ Avg. Velocity ┆ 3      ┆ 1        ┆ m/s           │
│               ┆ t(2*dPDuctAvg ┆              ┆ (m/s)         ┆        ┆          ┆               │
│               ┆ /rho_e)       ┆              ┆               ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ m_e           ┆ vel_e*A_duct* ┆  DuctFlow    ┆ Avg. mass     ┆ 3      ┆ 2        ┆ kg/s          │
│               ┆ rho_e         ┆              ┆ flow (kg/s)   ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ vel_dwyer     ┆ KDwyer*sqrt(2 ┆  DuctFlow    ┆ Local         ┆ 3      ┆ 1        ┆ m/s           │
│               ┆ *dPDuctDwyer/ ┆              ┆ Velocity      ┆        ┆          ┆               │
│               ┆ rho_e)        ┆              ┆ (m/s)         ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ m_dwyer       ┆ vel_dwyer*A_d ┆  DuctFlow    ┆ Local mass    ┆ 3      ┆ 2        ┆ kg/s          │
│               ┆ uct*rho_e     ┆              ┆ flow (kg/s)   ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ volAvg_e      ┆ vel_e*A_duct  ┆  DuctFlow    ┆ Avg. Vol.     ┆ 3      ┆ 3        ┆ m^3/s         │
│               ┆               ┆              ┆ Flow (m^3/s)  ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ volDwyer      ┆ vel_dwyer*A_d ┆  DuctFlow    ┆ Local. Vol.   ┆ 3      ┆ 3        ┆ m^3/s         │
│               ┆ uct           ┆              ┆ Flow (m^3/s)  ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ E             ┆ 13100         ┆ Constant     ┆ kJ per kg of  ┆ 0      ┆ 0        ┆ kJ/kg         │
│               ┆               ┆              ┆ oxygen        ┆        ┆          ┆               │
│               ┆               ┆              ┆ consumed      ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ O2Base        ┆ mean(DuctO2[: ┆ Intermediate ┆ Baseline O2   ┆ 0      ┆ 0        ┆ -             │
│               ┆ min(50*10,len ┆              ┆ before        ┆        ┆          ┆               │
│               ┆ (DuctO2))])   ┆              ┆ ignition      ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ CO2Base       ┆ mean(DuctCO2[ ┆ Intermediate ┆ Baseline CO2  ┆ 0      ┆ 0        ┆ -             │
│               ┆ :min(50*10,le ┆              ┆ before        ┆        ┆          ┆               │
│               ┆ n(DuctCO2))]) ┆              ┆ ignition      ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ COBase        ┆ mean(DuctCO[: ┆ Intermediate ┆ Baseline CO   ┆ 0      ┆ 0        ┆ -             │
│               ┆ min(50*10,len ┆              ┆ before        ┆        ┆          ┆               │
│               ┆ (DuctCO))])   ┆              ┆ ignition      ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ O2Depletion   ┆ abs((O2Base-  ┆ Intermediate ┆ O2 depletion  ┆ 0      ┆ 0        ┆ -             │
│               ┆ DuctO2)/(1.10 ┆              ┆               ┆        ┆          ┆               │
│               ┆ 5 -           ┆              ┆               ┆        ┆          ┆               │
│               ┆ 1.5*DuctO2))  ┆              ┆               ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ C_factor      ┆ 1             ┆ Constant     ┆ Correction    ┆ 0      ┆ 0        ┆ -             │
│               ┆               ┆              ┆ factor        ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ HRR           ┆ E*C_factor*1. ┆ HRR          ┆ O2_Based HRR  ┆ 1      ┆ 1        ┆ kW            │
│               ┆ 10*m_e*O2Depl ┆              ┆               ┆        ┆          ┆               │
│               ┆ etion         ┆              ┆               ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ O2DepletionCO ┆ (O2Base*(1-Du ┆ Intermediate ┆ O2 depletion  ┆ 0      ┆ 0        ┆ -             │
│ CO2           ┆ ctCO2-DuctCO) ┆              ┆ for CO CO2    ┆        ┆          ┆               │
│               ┆ - DuctO2*(1-C ┆              ┆ measurement   ┆        ┆          ┆               │
│               ┆ O2Base))/(O2B ┆              ┆               ┆        ┆          ┆               │
│               ┆ ase*(1-DuctCO ┆              ┆               ┆        ┆          ┆               │
│               ┆ 2 - DuctCO -  ┆              ┆               ┆        ┆          ┆               │
│               ┆ DuctO2))      ┆              ┆               ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ O2Mult        ┆ abs(O2Base*(O ┆ Intermediate ┆ O2_mult       ┆ 0      ┆ 0        ┆ -             │
│               ┆ 2DepletionCOC ┆              ┆               ┆        ┆          ┆               │
│               ┆ O2 - 0.172*(1 ┆              ┆               ┆        ┆          ┆               │
│               ┆ -O2DepletionC ┆              ┆               ┆        ┆          ┆               │
│               ┆ OCO2)*DuctCO2 ┆              ┆               ┆        ┆          ┆               │
│               ┆ /DuctO2)/(1-O ┆              ┆               ┆        ┆          ┆               │
│               ┆ 2Base+1.105*O ┆              ┆               ┆        ┆          ┆               │
│               ┆ 2Depletio…    ┆              ┆               ┆        ┆          ┆               │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ HRR_COCO2     ┆ E*C_factor*1. ┆ HRR          ┆ O2_CO2_CO     ┆ 1      ┆ 1        ┆ kW            │
│               ┆ 10*m_e*O2Mult ┆              ┆ based HRR     ┆        ┆          ┆               │
└───────────────┴───────────────┴──────────────┴───────────────┴────────┴──────────┴───────────────┘

Formulae file columns

  1. Label : str

    • A unique label for each row.

    • This label indicates the left-hand-side of the equation to be processed.

    • A variable by this name will be created during post-processing.

  2. RHS : str

    • The right-hand-side part of the equation.

    • Must be a string that can be executed in python. For example, DuctTC1**2 is DuctTC1 raise to the exponent 2. If you use sqrt(DuctTC1) will replace sqrt to np.sqrt to get the square root of DuctTC1. This is done in accordance to a dictionary that maps custom variable to numpy mathematical functions. See note below.

    • Equation of the form Label = RHS is executed during post-processing.

    • See built-in python exec function for additional details.

    • Note: Can contain formulae that use numpy mathemetical functions on 1D array. A Formulae_dict (a dictionary) in DAQUtils documentation indicates the currently acceptable variables that maps to a numpy function. You can add your custom variable: function map to this dictionary following the example given in the DAQUtils documentation.

  3. Chart: str

    • String indicating the chart where this channel’s post processed data will be displayed.

    • This can be None, Intermediate, or Constant is you do not want to see this channel in the dashboard plots.

    • It is recommended to use Constant in the Chart column for row which is a constant used in post-processing. (Example: KRosemont and KWeyer labels in the above example formulae file.)

    • It is recommended to use Constant in the Chart column for row which is a constant used in post-processing. (Example: rho_e and ID labels in the above example.

  4. Layout: str/num

    • Same columns as that used in the config file

    • Must be in the form that can be converted into a natural number (1, 2, 3)

    • The type of layout corresponding to the Chart parameter.

    • All channels which are have the same Chart parameter must have the same Layout value.

    • This will generate a figure in the dashboard that will have #Layout rows in vertical direction.

    • It is recommended to keep this value to a maximum of 3 for better visualization in the dashboard.

  5. Position: str/num

    • Same columns as that used in the config file

    • Must be in the form that can be converted into a natural number (1, 2, 3)

    • Indicates the position in the Chart where this channel data will be displayed.

    • This value must be less than or equal to the Layout number.

  6. Processed_Unit: str

    • Same columns as that used in the config file

    • The unit of the channel data once it is scaled according to AI and Scale minimum and maximum values.

    • This will be the y-axis label for the row.

  7. Legend: str

    • Same columns as that used in the config file

    • Legend for the channel.

    • This will be displayed on the outside right of the plot in the dashboard.

Please visit Post processing example to see how the Tmean and other labels are processed.