I have a Python Gekko application to estimate and control disturbances to an industrial polymer manufacturing process (UNIPOL polyethylene). The approach is to update the unknown catalyst activity to minimize the difference between the measured and predicted production rate. The catalyst activity is then used in production control. The predicted production rate is based on heat exchanged with cooling water. The problem that I'm running into is that sometimes the production rate measurements are not good because of intermittent issues associated with the measurements (flow meter, temperatures) and calculations during large transients. The distributed control system (Honeywell Experion with TDC3000) has appropriate protections against bad measurements and reports a value but with bad status. How can I use the available good measurements but ignore the intermittent bad measurements in Python Gekko? I don't have example code that I can share due to proprietary issues, but it is similar to this TCLab exercise.
for i in range(1,n):
# Read temperatures in Celsius
T1m[i] = a.T1
T2m[i] = a.T2
# Insert measurements
TC1.MEAS = T1m[i]
TC2.MEAS = T2m[i]
Q1.MEAS = Q1s[i-1]
Q2.MEAS = Q2s[i-1]
# Predict Parameters and Temperatures with MHE
m.solve(disp=True)
Can I use np.nan
(NaN) as the measurement or is there another way to deal with bad data?