pyopticon.majumdar_lab_widgets.mks_ftir_widget

class pyopticon.majumdar_lab_widgets.mks_ftir_widget.MKSFTIRWidget(parent_dashboard, name, nickname, gas_labels, gas_columns, calibration_functions=None, default_logfile_path=None)

Bases: GenericWidget

A widget representing an MKS multi-gas 2000 FTIR.

This widget doesn’t communicate with the FTIR via serial. The FTIR is controlled by MKS software, which logs data to a .prn (tab-delimited) file. This widget watches one of those files and reads the gas concentrations in the last line in the file.

One can make this widget extract several gases’ data from the logfile. The gases’ names are passed as one argument. A .prn contains many columns, so you pass the respective column indices as another argument.

You can pass in a list of calibration functions for the respective gases to adjust the FTIR’s raw readings. It probably makes sense to define the calibration functions using Numpy’s interp function to interpolate between a range of calibration points, e.g. ‘ch4_cal_function_lo = lambda x: np.interp(x,[0,514,1024,1430],[0,20,40,60])’.

An example initialization is as follows: ftir1 = mlw.MKSFTIRWidget(parent_dashboard=dashboard,name=’MKS FTIR’,nickname=’FTIR’,

gas_labels=(‘CH4 (ppm)’,’CO2 (ppm)’,’H2O (%)’,’CO (ppm)’), gas_columns=(3,15,30,12))

dashboard.add_widget(ftir1,row=2,column=1)

Parameters:
  • parent_dashboard (richardview.dashboard.RichardViewDashboard) – The dashboard object to which this device will be added

  • name (str) – The name that the widget will be labeled with, and under which its data will be logged, e.g. “Methane Mass Flow Controller”

  • nickname (str) – A shortened nickname that can be used to identify the widget in automation scripts, e.g. “CH4 MFC”

  • gas_labels (list) – The labels of the different gases to be logged. You may want to include units, e.g. ‘CO2 (ppm)’

  • gas_columns (list) – The indices of the columns corresponding to the gases’ concentrations in the logfile

  • calibration_functions (list) – A list specifying calibration functions for each gas; see the description above. If None, just keeps the values in the file.

  • default_logfile_path (str, optional) – The default path of the FTIR logfile. Can be used to avoid clicking through the file location choosing dialog every time.

on_failed_serial_open()

If the device initialized unsuccessfully, set its readout to ‘No Reading’

disable_button()
on_handshake()

This function gets called whenever the widget is initialized. If the widget uses a Serial connection, you can assume that the serial connection was already initialized successfully. If not, you’ll need to initialize whatever objects are needed to update the widget in this method (say, an OEM Python driver).

By default, it just calls on_update(), assuming that the handshake was successful if (and only if) no exception was raised.

on_update()

“Read from the file and populate the fields.

on_serial_close()

When serial is closed, set all readouts to ‘No Reading’.

_update_file_to_watch()

Prompt the user to select a new file to watch.

construct_serial_emulator()

No serial emulator is needed for this device, since its normal operation doesn’t assume any hardware is present. Returns None.

Returns:

None

Return type:

NoneType