# Analysis

This is the analysis sub-package of the pctools package.

### Features

- Analysis tools for practical understanding and design of conventional and advanced control schemes.
- Package content (mainly classes):
- plant
- loop

## Plant

potential names for class (plantmatrix, matrix, PVs,

**plant**)- cross-correlation matrix (see ideas below) - note that this is probably the only analysis in a "matrix" form
- calculate multiple parameters for each pairing (max corr, delay, 2nd peak info)
- 2nd peak might be helpful for where there is an obvious controller in the loop causing initial correl, but want the likely process peak)
- try matplotlib or ?-tree to show ordered list of strong correlations (or just a list!) - a matrix may not really be useful?

- calculate multiple parameters for each pairing (max corr, delay, 2nd peak info)
- common frequency detection (most dominant frequency, amplitude in each PV (sorted order))
- PCA (how to interpret?, how many PCs explain 95%, perhaps low number or high % for two implies abnormal plant stability?)

## Loop

Class name **Loop**

### Assess

- auto-determination of "in-control" periods in data (to handle saturation, constraint control tracking, etc. situations)
- CO flat-line detection
- use "max cross-correlation" analysis between error and CO (over windows of short duration; note that CO must be the ultimate CO, e.g. after a constraint controller select block)

- standard analysis data (for quantitative measures) with optional graphics
- impulse response
- input-output regression (what exactly does this give me?) - note: due to correlation between independent variables, PCA or ICA should probably be used first! (MDP package in pythonxy)
- autocorrelation (known to give a closed-loop FIR approximation)

- frequency content (bandwidth) of controller error (i.e. what is the roll-off frequency (high-pass) of the control correction)
- resonant frequency, PID tuning estimation, cycling estimation of P vs I action
- normalised plot of PV vs CO (shows phase lag in controller, valve stiction)
- performance compared with minimum-variance control (including projected best achievable SD with MV control)

- impulse response
- tabular measures
- Standard Error (in % of setpoint value)
- average phase difference PV to CO (how? cross-corr? need to know resonant frequency first!)
- resonant frequency of loop
- auto-estimation of existing PID tuning parameters (perhaps need to know if Proportional action is on error or PV for a servo loop)
- should be able to derive the parameters from the coefficients of a linear regression (dCO = f(Error,dError,ddError)) rather than simulation and fitting using the dynsim.control.PID class.

- table of max cross-correlations between a set of signals

- analyses dependent on data available
- PV only
- autocorrelation / impulse response (stability analysis)
- cross-correlation analysis with other PVs etc.

- +SP
- SD
- +estimated deadtime
- minimum variance comparison

- +CO
- estimate PID parameters
- determine periods of active feedback control
- cross-correlation analysis (CO to PV) - ?

- +FF
- multivariable MV assessment (i.e. value of adding FF to loop)

- PV only
- misc
- data preprocessing tools (resampling, period selection, basic statistics, FFT, HP/LP filtering/filtfilt, ...)
- statistical tools?
- Principal Component Analysis (using PCA (and similar) to assist with process control analysis, not just the algorithm)

- fit a statistical distribution to a histogram
- monte-carlo tools
- random variates from a histogram (concatenate count x (equal bin values) for each bin, then select a value using a uniform dist)
- multiple correlated variates (i.e. with a correlation matrix)

- filtering utilities
- cutoff frequency to/from timeconstant conversion for first order filters.
- ?

### Fit

- controller ID
- PID parameters
- do first to help with plant ID? or
- combined PID and plant ID?

- plant ID
- 1-input, 1-output at a time or multi-input-one-output
- impulse response (from step-response or PRBS data)
- deadtime estimation (using FOPDT assumption below?)
- FOPDT model (more likely to be local minima involved! - use initial deadtime estimate)
- for FF as well as plant (multivariable!)
- need to be able to simulate multivariable FIRs in dynsim!

### Tune

- PID tuning program (everything needed for loop tuning, bundling above capability)
- analysis (of loop data)
- identification (impulse, FOPDT etc., from step-test or PRBS results)
- tuning optimisation
- utility
- conversion between PID formulations (parallel, ideal, ...)
- standard tuning formulae (from guidance note?)

- FF tuning (FOPDT)
- by optimisation (could be calculated but would often need a predictor resulting in more complex design)