Scripting in eFTIR is done with the Python programming language www.python.org. Python is a very powerful, general purpose programming language that has been widely adopted by the scientific programming community. Most importantly for eFTIR, the Python numerical processing package, named 'numpy', includes a complete Linear Algebra library.
There are a lot of excellent books, on-line documentation and tutorials about Python. This document will not spend any time documenting the Python language, because there are so many resources readily available. Here are links to the official documentation and tutorial:
eFTIR uses Python 2.6.6, and it is this version of eFTIR and numpy that are available to eFTIR scripts. Python 2.6.6 and numpy are embedded within eFTIR, so it is not necessary for eFTIR users to install Python separately. If you want to use other Python modules/packages with eFTIR, such as Scientific Python (www.scipy.org), you need to install Python and the needed packages, and then import them directly into your script.
All scripts for eFTIR must define a 'run' function with this function signature:
def run(listOfFiles=[], **kwargs): pass # do nothing
'listOfFiles' is the actual spectrum objects passed into the script from the User Scripts tool in eFTIR. **kwargs is a list of Python keyword arguments, and is not used at this time.
If the script defines 'exitAfterRun' to be True, eFTIR will exit after the script is done. This is useful when driving eFTIR from the command line or batch files.
exitAfterRun=True def run(listOfFiles=[], **kwargs): pass # do nothing
eFTIR can be sent commands on the command line, often for the purpose of running scripts in a batch mode.
Command line options are preceded by a dash '-'. The options are: -r "scriptname.py" -s -p TCP_port_number -t "tool name" -n -r "path/to/script.py" example: eftir.exe -r "c:/path/folder/scriptfile.py" where the .py file is a python script formatted as per a user script, described in the eftirScripting.html document. If the script contains the line 'exitAfterRun=True', eFTIR will automatically exit after the script returns. for example, here are the contents of an eFTIR script file, 'testExit.py': ---------------------- exitAfterRun=True def run(files=[], **kwargs): eftir.msgBox('goodbye') ---------------------- then, from the the command line, run: eftir -r "testExit.py" If the full path to the script is not specified, eFTIR searches looks for it in the defaults 'scripts' folder, and if it is not found there, looks in the eFTIR program directory. -s start eFTIR with the socket server activated. See the -p option (below) When started with the -s command, eFTIR is placed in a 'server' mode, and will accept the names of eFTIR scripts over a network socket. for example, start eFTIR like this: eftir -s then, from the command line: telnet 127.0.0.1 5001 eftir will respond: Connected to eFTIR on port 5001 Then, type in the name of a script file, for instance, the 'testExit.py' (see below), followed by the Enter key: testUI.py eFTIR will execute the script. (testUI.py is a test script installed with eFTIR) Note that this socket server allows for remote control of eFTIR from any computer on the network. As such, it is a possible security problem. That's why the socket server is not enabled by default. -p portNumber the TCP port to use for the socket server. The default is 5001. '-n' no splash screen -t toolname Start eFTIR with the specified tool example: eFTIR -t "User Library Search" With the introduction of the eFTIR 'Favorites', this option is somewhat obsolete You can also create a desktop shortcut for the script and have it launch automatically when eftir starts. On the windows desktop, right click on the Essential FTIR icon, and click 'Copy'. Then click 'Paste' and you will have a new shortcut named 'Copy of Essential FTIR'. Right click on this icon, and on the General tab, name the shortcut 'QCP' or whatever you like. Then click on the 'Shortcut' tab. In the "Target" field, enter this: "C:\Program Files\EssentialFTIR\eftir.exe" -r "C:\Documents and Settings\All Users\Documents\EFTIR\scripts\QCP_027.py" Be sure to include the quote marks, which are necessary because their are spaces in the file paths. Also, the script filename is case sensitive, the command line must match exactly the name of the .py file. Again, the 'All Users' directory may be named something else on some windows systems. When you click this desktop icon, eFTIR will start and run the script automatically.
Spectrum is a Python class which combines spectral data with properties of that data. eFTIR scripting operates on Spectrum objects. Given an instance of a Spectrum object, called 'spectrum', here are the most important things to know about it.
Member variable | Data type | Description |
firstX | double | The 'X' value of the first point in the spectral data array |
lastX | double | The 'X' of the last point in the spectral data array |
points | 32 bit integer | The number of points in the spectral data array |
deltaX | double | The spacing between points in the spectral data array, in 'X' units. Calculated as:(lastX-firstX)/(points-1) |
data | Array of double | The spectral data array |
title | String | Text information associated with the spectrum |
filename | String | The name of the file on disk |
xDataType | String | The 'X' units of the spectral data array |
yDataType | String | The 'Y' units of the spectral data array |
xDataType is one of these values:
'cm-1' | Wavenumbers |
'nm' | Nanometers |
'um' | Micrometers (microns) |
'points' | Data points |
'raman' | Raman shift |
'?' | Arbitrary units |
yDataType is one of these values:
'abs' | Absorbance |
'trn' | Transmittance |
'sbm' | Sample singlebeam |
'rsb' | Reference (background) singlebeam |
'ifg' | Sample interferogram |
'rif' | Reference (background) singlebeam |
'refl' | Reflectance |
'logir' | Log reflectance |
'drt' | Kubelka Munk |
'counts' | Counts |
'?' | Arbitrary units |
Spectral data in eFTIR is always evenly spaced. If an unevenly spaced array of data is read into memory, it is always interpolated to even spacing. The member variable 'deltaX' is the spacing between every point in the spectral data array. NOTE: if a script does anything to change the point spacing an a data array, deltaX must be recalculated by the scripts using this formula: deltaX = (lastX-first)/(points-1).
Python has the concept of 'namespaces', which is an abstract container that provides a context for the symbols within the namespace. This avoids name collisions with similarly names things elsewhere in a software program. In technical terms, a namespace allows disambiguation of items having the same name but contained in different namespaces.
All the eFTIR-internal functions that eFTIR makes available to scripts are contained with the 'eftir' namespace, and automatically imported by eFTIR into all users scripts before they are run. Typically, in a Python program, code modules that the script uses have to be explicitly imported into the script, but eFTIR does this for all user scripts that are run through eFTIR. For instance, to load a spectrum from disk into memory, there is a function named 'loadSpectrum', but to call it the script writer must refer to this function as 'eftir.loadSpectrum'.
The Python numeric library numpy is automatically imported into all eftir scripts, so there is no need to explicitely import it.
Some of the functions available to scripting are the same as those available to the 'Batch Processor'. These functions are not just functions in the strict sense. They are 'Function Objects', that is, they are code associated with properties and data that pertain to the code. But they are also simply callable as functions. Function objects always operate on spectrum objects, and return modified spectrum objects. All function objects have these member functions:
editOptions() | Allows users to interactively edit the options associated with the function. |
Save(filename) | Save the options to a file |
Load(filename) | Load the options from a file |
optionsToDictionary() | Returns the current options setting as a Python dictionary |
Calling fft.optionsToDictionary() will return a Python dictionary of the option settings:
{'laserSamplingInterval': 1.0, 'phaseCorrection': 'mertz', 'interferogramDirection': 'Automatic Detection', 'normalizeSinglebeam': False, 'zeroFill': 1, 'firstX': 500.0, 'interferogramSymmetry': 'Automatic Detection', 'apodization': 'triangle', 'laserFrequency': 0.63299000000000005, 'lastX': 4500.0 }
Such a dictionary is useful because it can be used as 'keyword arguments' to the function itself, to modify the actions of the function, as in:
fftOptions = fft.optionsToDictionary fftOptions['apodization'] = 'boxcar' Result = eftir.fft(spectrum, fftOptions)
Much more is written about keyword arguments later in this document.
These function objects always modify a spectrum in place, and the return value of the function call is the modified spectrum. For instance, result=fft(spectrum) will modify the spectrum object in place, and return the modified object. In this case, 'result' and 'spectrum' actually are one and the same object. The reason the function objects return the spectrum object is so that functions can be chained together, as in:
result = eftir.trnToAbs(eftir.ratio(eftir.fft(eftir.scan()), reference=background))Which statement does a complete FTIR data acquisition and processing in one line of code! A table of all the 'function objects' is below.
These are straight functions, they are not function objects, and if a spectrum is passed into the function, they do not modify it, they usually so some kind of analysis on the spectrum and report on it. These functions fall into broad categories of loading/saving/collecting spectra, managing windows in eFTIR, and analyzing spectra and returning the results. If arguments are required as inputs to a function, they are provided as 'keyword arguments', about which more is written below.
A table of all the 'functions' is below.
Many of the function signatures in the eftir namespace include '**kwargs'. Kwargs is a python idiom that stands for 'keyword arguments'. For instance, the function signature for 'pickPeaks' is: pickPeaks(spectrum, sens = 100, threshold = 25, interpolate=False) Where the keyword arguments are sensitivity, threshold and interpolate, with the default values as shown. Keyword arguments are usually optional, and only need to be over-ridden when the defaults are not what are needed. In this example, if you wanted to just change the threshold to fifty percent, it would be done like this:
peaks = eftir.pickPeaks(spectrum, threshold=50)Alternatively, the keyword arguments can be supplied as a python dictionary:
peaks = eftir.pickPeaks(spectrum, {'threshold':50, 'sens':90, 'interpolate':True})The reader is encouraged to read one of the beginning Python tutorials for more information about keyword arguments.
For instance, to multiply two spectra together, you would write:
Spectrum1 = spectrum1 * spectrum2 # (alternatively, using 'c' style notation, 'spectrum1 *= spectrum2')Which multiplies spectrum1 by spectrum2 and places the result in spectrum1.
Or, one can supply constants as operands. Here we multiply a spectrum by 2:
Spectrum1 = spectrum1 * 2 (alternatively, spectum1 *= 2)
Note: spectral arrays must be of the same length (and should usually span the same range of X units), or these operators will throw an exception. If they are not the same length, and exception will be thrown by Python. Use the 'match' function to make spectra the same size.
Note: beware of division by zero when dividing one spectrum by another. Division by zero will throw a Python exception.
Filename | Description |
testAutoSubract.py | Sequentially subtracts H2O and CO2 from a contaminated spectrum, revealing the presence of methanol. |
testCompare.py | Load s a file from disk and uses the 'compare' function to compare it to a folder full of spectral data files, displaying the results as a table in the 'Results' tab of the User Scripts tool. |
testFFT.py | FFTs a background and sample interferogram, ratios the singlebeams, and displays the results. |
testFunctions.py | Tests every spectral manipulation function object. |
testHelpers.py | Prompts user for a list of files, displays them in a new workspace, makes copies of them , prompts the user for a directory and saves the files to that directory, then closes the workspace. |
testInputFileList.py | Displays information about the list of spectra passed to the script from the User Scripts tool. |
testMathOperations.py | Shows how to use simple math operations on spectra. |
testOptionSave.py | Shows function object edit, save, and load. |
testPrint.py | Very simple script shows how Python 'print' statements appear in the 'Output' window of the User Scripts tool. |
testReports.py | Loads a canned sample, generates a peak table, puts the table in a report, prints the report, and plots the spectrum. |
testScan.py | Prompts for which instrument to connect to, collects a background and then repeatedly collects samples while doing a noise analysis on them and placing the results into the results table. Shows how to use the data collection functions, and the progress dialog to cancel an otherwise endless loop. |
eftir.absToTrn ( spectrum ) Implements Absorbance to Transmittance Modifies the spectrum object in-place, and returns the modified spectrum object
eftir.atrCorrection ( spectrum, **keywordAguments) Implements ATR Correction Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: angle ( In degrees ) : Floating Point Number Default Value = 45.0 Rs ( Refractive Index of Sample (see help ) : Floating Point Number Default Value = 1.5 Rc ( Refractive Index of Crystal (see help) ) : Floating Point Number Default Value = 2.4 reflections ( Number of reflections ) : Integer number between 1 and 100 inclusive Default Value = 1
eftir.autoBLC ( spectrum, **keywordAguments) Implements Automatic Baseline Correction Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: algorithm ( The algorithm to use to correct the baseline ) : Integer index from this list [ 0 = 'Function Fit', 1 = 'GIFTS Auto-Leveling' ] Default Value = 1 order ( Number of terms in the correction matrix for Function Fit only ) : String value from this list [ 'Offset', 'Linear', 'Quadratic', 'Quintic' ] Default Value = Quadratic normalize ( Offset the data min to 0 after correction ) : Boolean (true/false) value represented by 1 or 0 Default Value = False
eftir.autoSubtract ( spectrum, **keywordAguments) Implements Auto-Subtract Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: regions: List of x-values defining the regions to operate on reference: This function needs a reference file (for instance, ratio needs a background and subtract needs a subtrahend) The reference may be the filename of a spectrum, or an in-memory Spectrum instance
eftir.derivative ( spectrum, **keywordAguments) Implements Derivative Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: order ( The order of the derivative, 1-4 ) : Integer number between 1 and 4 inclusive Default Value = 2 points ( The number of smoothing points, 5-99 ) : Integer number between 5 and 99 inclusive Default Value = 5 method ( How to do the smoothing ) : Integer index from this list [ 0 = 'Quadratic/Cubic Savitsky-Golay', 1 = 'Quartic/Quintic Savitsky-Golay' ] Default Value = 1 tailHandling ( How to handle the end points ) : Integer index from this list [ 0 = 'Use Closest Value', 1 = 'Fill with Zero', 2 = 'Truncate', 3 = 'Extrapolate, then Truncate' ] Default Value = 3
eftir.fft ( spectrum, **keywordAguments) Implements FFT Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: apodization ( The apodization function to use in the FFT ) : String value from this list [ 'triangle', 'boxcar', 'Beer-Norton Med', 'Beer-Norton Weak', 'Beer-Norton Strong', 'Happ-Genzel', 'Bessel', 'Cosine', 'Blackman-Harris 3 Term', 'Blackman-Harris 4 Term', 'Cosine 3' ] Default Value = triangle phaseCorrection ( The phase correction method to use in the FFT ) : String value from this list [ 'mertz', 'magnitude', 'none' ] Default Value = mertz firstX ( From 0 to 31596 wavenumbers. The first wavenumber value to save in the FFT'd data ) : Floating Point Number between 0.0 and 31596.0 inclusive Default Value = 500.0 lastX ( From 0 to 31596 wavenumbers. The last wavenumber value to save in the FFT'd data ) : Floating Point Number between 0.0 and 31596.0 inclusive Default Value = 4500.0 zeroFill ( Increase the resolution of the processed data through zero-filling ) : Integer value from this list [ 1 = '1', 2 = '2', 4 = '4', 8 = '8', 16 = '16' ] Default Value = 1 laserFrequency ( The wavelength of the laser in microns (default 0.63299 for HeNe laser) ) : Floating Point Number Default Value = 0.63299 laserSamplingInterval ( How often samples are taken relative to the laser zero-crossings ) : Floating Point value from this list [ 0.250000,0.500000,1.000000,2.000000,4.000000,8.000000 ] Default Value = 1.0 interferogramDirection ( Is data collected during forward or reverse mirror travel? ) : String value from this list [ 'Automatic Detection', 'Forward', 'Reverse', 'Both' ] Default Value = Automatic Detection interferogramSymmetry ( When the ADC is turned on ) : String value from this list [ 'Automatic Detection', 'Single-Sided', 'Double-Sided' ] Default Value = Automatic Detection normalizeSinglebeam ( After the FFT, scale the singlebeam to normalize it ) : Boolean (true/false) value represented by 1 or 0 Default Value = 0
eftir.fitBaseline ( spectrum, **keywordAguments) Implements Fit Baseline Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: noise ( Gaussian distribution expressed as standard deviation around 0 ) : Floating Point Number Default Value = 0.0 regions: List of x-values defining the regions to operate on
eftir.interpolate ( spectrum, **keywordAguments) Implements Interpolate Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: resolution ( Change the data's digital resolution ) : Floating Point Number between 0.01 and 100.0 inclusive Default Value = 1.0
eftir.kkTransform ( spectrum ) Implements Kramers-Kronig Transform Modifies the spectrum object in-place, and returns the modified spectrum object
eftir.manualBLC ( spectrum ) Implements Manual Baseline Correction Modifies the spectrum object in-place, and returns the modified spectrum object regions: List of x-values defining the regions to operate on
eftir.match ( spectrum, **keywordAguments) Implements Match Spectra Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: firstX ( First X value ) : Floating Point Number Default Value = 400.0 lastX ( Last X value ) : Floating Point Number Default Value = 4000.0 deltaX ( Exact Digital resolution in cm-1 ) : Floating Point Number between 0.03 and 32.0 inclusive Default Value = 0.964 match ( Match start, end cm-1 and resolution ) : unhandled input type ... Default Value =
eftir.normalize ( spectrum, **keywordAguments) Implements Normalize Spectra Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: algorithm ( How to normalize the data ) : String value from this list [ 'Offset', 'Min-Max', 'Vector Normalization' ] Default Value = Min-Max min ( Offset or Miniumum Value ) : Floating Point Number Default Value = 0.0 max ( Maximum Value ) : Floating Point Number Default Value = 1.0
eftir.offsetBy ( spectrum, **keywordAguments) Implements Offset By Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: factor ( Offset the data by this amount ) : Floating Point Number Default Value = 1.0
eftir.offsetTo ( spectrum, **keywordAguments) Implements Offset To Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: factor ( Offset the data so the minumum data value is this number ) : Floating Point Number Default Value = 1.0
eftir.ratio ( spectrum, **keywordAguments) Implements Ratio Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: reference: This function needs a reference file (for instance, ratio needs a background and subtract needs a subtrahend) The reference may be the filename of a spectrum, or an in-memory Spectrum instance
eftir.scaleBy ( spectrum, **keywordAguments) Implements Scale By Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: factor ( Scale the data by this number ) : Floating Point Number Default Value = 1.0
eftir.scaleTo ( spectrum, **keywordAguments) Implements Scale To Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: factor ( Scale the data so this becomes the dynamic range of the data ) : Floating Point Number Default Value = 1.0
eftir.smooth ( spectrum, **keywordAguments) Implements Smoothing Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: points ( The number of smoothing points, 5-99 ) : Integer number between 5 and 99 inclusive Default Value = 5 method ( How to do the smoothing ) : Integer index from this list [ 0 = 'Quadratic/Cubic Savitsky-Golay', 1 = 'Quartic/Quintic Savitsky-Golay', 2 = 'Moving Average', 3 = 'Running Median', 4 = 'Hanning Window', 5 = 'Hamming Window' ] Default Value = 0 fullSpectrumSmooth ( Smooth the entire spectrum ) : Boolean (true/false) value represented by 1 or 0 Default Value = True tailHandling ( How to handle the end points ) : Integer index from this list [ 0 = 'Use Closest Value', 1 = 'Fill with Zero', 2 = 'Truncate', 3 = 'Extrapolate, then Truncate' ] Default Value = 3 regions: List of x-values defining the regions to operate on
eftir.subtract ( spectrum, **keywordAguments) Implements Subtract Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: factor ( Scale the subtrahend by this number ) : Floating Point Number Default Value = 1.0 reference: This function needs a reference file (for instance, ratio needs a background and subtract needs a subtrahend) The reference may be the filename of a spectrum, or an in-memory Spectrum instance
eftir.trnToAbs ( spectrum ) Implements Transmittance to Absorbance Modifies the spectrum object in-place, and returns the modified spectrum object
eftir.truncate ( spectrum ) Implements Truncate Modifies the spectrum object in-place, and returns the modified spectrum object regions: List of x-values defining the regions to operate on
eftir.wavelengthToWavenumbers ( spectrum ) Implements Wavelengths To Wavenumbers Modifies the spectrum object in-place, and returns the modified spectrum object
eftir.wavenumbersToMicrons ( spectrum ) Implements Wavenumbers To Microns Modifies the spectrum object in-place, and returns the modified spectrum object
eftir.wavenumbersToNanometers ( spectrum ) Implements Wavenumbers To Nanometers Modifies the spectrum object in-place, and returns the modified spectrum object
eftir.xShift ( spectrum, **keywordAguments) Implements X-Axis Shift Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: amount ( The amount to shift the x axis ) : Floating Point Number Default Value = -2.0 shiftMode ( How to shift the X Axis ) : Integer index from this list [ 0 = 'Shift Entire Spectrum', 1 = 'Pin Left Side', 2 = 'Pin Right Side', 3 = 'Pin Zero' ] Default Value = 0
eftir.zap ( spectrum, **keywordAguments) Implements Zap Regions Modifies the spectrum object in-place, and returns the modified spectrum object Keyword Options: fill ( What to fill zapped regions with ) : String value from this list [ 'Zero', 'Interpolated Line', 'Mean', 'Left-most value', 'Right-most value' ] Default Value = Interpolated Line noise ( Gaussian distribution expressed as standard deviation around 0 ) : Floating Point Number Default Value = 0.0 regions: List of x-values defining the regions to operate on
eftir.addSpectrumToWorkspace(w, spectrum) add a spectrum to workspace w
eftir.autoscale(w=None) autoscale the workspace given by w. if w is not provided, use the current active workspace
eftir.autoscaleX(w=None) autoscale the workspace given by w along the X axis if w is not provided, use the current active workspace
eftir.autoscaleY(w=None) autoscale the workspace given by w along the Y axis if w is not provided, use the current active workspace
eftir.bkgscan() collect a background spectrum according to the instrument settings see the example 'testScan.py' script
eftir.chooseFromList(prompt, listOfOptions, caption="") listOfOptions is a list of strings to display Displays a dialog with the list of options. Returns the empty string "" if the user clicks Cancel, otherwise it returns the selected string.
eftir.cloneSpectrum(spectrum) returns a copy of the spectrum
eftir.closeAllWindows()
eftir.closeWorkspace(w) close the window w
eftir.compare(spectrum, path, recurse=False) calculate the correlation coefficient using the spectrum object agains all spectra found on the provided path
eftir.correlationCoefficient(spectrum1, spectrum2) returns the correlation coefficient calculated using the two Spectrum objects
eftir.editText(prompt, txt, caption="") Displays a simple dialog with a single text edit control on it. The edit control is intialized with 'txt' Returns the empty string "" if the user clicks Cancel, otherwise it returns the edited string.
eftir.expand(w, x1, x2, y1, y2) expand the display in window w if x1 equals x2, the window will be autoscaled along the x axis. if y1 equals y2, the window will be autoscaled along the y axis.
eftir.getBackgroundWorkspace() return the handle of the background data collection window (the background data collection window is the one that holds the last collected background)
eftir.getCurrentWorkspace() return the handle of the current active data workspace
eftir.getDataCollectionWorkspace() get the data collection window the data collection window holds newly collected data
eftir.getDirectoryFromUser(path) prompt the user to select a directory. returns the chosen directory, or the empty string if user cancels
eftir.getDocPath() return the path to the eFTIR documents folder
eftir.getFilesFromUser(path) prompt the user for a single data files the dialog will be initialzed at the folder 'path' returns the filename, or the empty string if user cancels
eftir.getFilesFromUser(path) prompt the user for multiple data files the dialog will be initialzed at the folder 'path' returns a list of filenames, or the empty list if user cancels
eftir.getInstrumentSettings: Return the current instrument settings as a Python dictionary. This can be modified and used in the call to eftir.initializeInstrument(). This can also be used to store and restore instrument settings back to a known state. see the example 'testScan.py' script
eftir.getNumSubfiles(filename) returns the number of subfiles contained in the file.
eftir.getFilesInWorkspace(w=None) returns a list of all the spectra held in the workspace 'w'. if 'w' is not specified, it uses the current workspace
eftir.initializeInstrument(**kwargs) Set the instrument options to kwargs. see eftir.getInstrumentSettings see the example 'testScan.py' script
eftir.integrate(spectrum, startX, endX, toZero=False) Performs integration over the specified region using the so-called 'composite Simpson Rule' (see 'Numerical Algorithms in C, 2nd Ed.' page 133). if 'toZero' is True, the integration is performed using zero as the baseline, otherwise a baseline between startX and endX is used.
eftir.isKnownFile(filename): returns True if the file extension of filename is recognized by eFTIR otherwise, returns False
eftir.initializeInstrument(**kwargs) Set the instrument options to kwargs. see eftir.getInstrumentSettings see the example 'testScan.py' script
eftir.loadSpectrum(filename, subfile=0) loads the spectrum from disk given the filename. returns a Spectrum object returns None if there was an error
eftir.msgBox(message, caption="") Display a Windows Message Box with the message and caption. The Message Box has a single 'OK' button
eftir.msgBox(message, caption="") Display a Windows Message Box with the message and caption. The Message Box has 'OK' and 'Cancel' buttons. Returns True if the user clicks OK, False if user clicks Cancel
eftir.msgBox(message, caption="") Display a Windows Message Box with the message and caption. The Message Box has 'Yes' and 'No' buttons. Returns True if the user clicks Yes, False if user clicks No
eftir.msgBox(message, caption="") Display a Windows Message Box with the message and caption. The Message Box has 'Yes', 'No', and 'Cancel' buttons. Returns 1 if the user clicks Yes, 0 if user clicks No, or -1 for Cancel
eftir.netA(spectrum, baseline1, baseline2, peakPos) calculate the Net Absorbance of the peak at 'peakPos' to a baseline drawn between the two baseline points
eftir.newDataWorkspace(label) create a new data workspace (tab) and label it. returns the window handle of the new workspace
eftir.overlay(w=None): display the workspace given by w in overlay mode if w is not provided, use the current active workspace
eftir.pagemode(w=None): display the workspace given by w in pagemode mode if w is not provided, use the current active workspace
eftir.peakAt(spectrum, wavenumber) peakAt searches for a peak, as defined by 5 point window with the middle point greater than the 2 on each side. It assumes that (1) wavenumber is close to the peak position, and (2)the data is not very noisy, otherwise it could be thrown off by random noise.
eftir.pickPeaks(spec, sens = 100, threshold = 25, interpolate=False, xLimits=None) returns a table of peaks as a list of lists threshold is expressed as percent of full height. if interpolate is True, the peak position is determined using a cubic spline centered around the nominal peak position.
eftir.plot(w=None, quickPrint = True) print the workspace given by w if 'quickPrint' is True, the 'choose a printer' dialog is not displayed before printing, last used printer is chosen automatically if w is not provided, use the current active workspace
eftir.processUIEvents() Give the eFTIR user interface the chance to update itself. This is useful in tight loops that use a progress dialog. See the 'testProgressDialog.py' example
eftir.progressDialog(prompt, steps) display the a progress dialog created, displays, and returns a progress dialog. The progress dialog has these member functions: setLabelText(text) setProgress(progress) # progress is an integer between 0 and the 'steps' passed in when the progress dialog was created. wasCanceled() # user clicked the 'cancel' button close() # close the progress dialog. NOTE: It is the programmers responsibility to call .close() on the progress dialog when the script is done with it. NOTE: To make sure the progress dialog is updated during tight processing loops, call eftir.processUIEvents() example: see the testProgressDialog example script
eftir.raiseWorkspace(w) make the workspace w the active one
eftir.redraw(w=None) if w is not provided, use the current active workspace
eftir.removeSpectrum(spectrum) removes the spectrum from memory
eftir.removeFileFromWorkspace(w, spectrum) remove the spectrum object from the window w
eftir.report(data, printit = True) Puts data in the 'Results' table in the user script tool in eFTIR data is a list of lists Each list in the list of lists becomes a row in the results table. The list elements can be strings or numbers For instance: [["Wavenumbers", "Absorbance"], [3000, 1.5] ]
eftir.rmsNoise(spectrum, startX, endX) Calculate the Root Mean Square Noise of the spectrum between the two X values. In Mid-IR spectroscopy, the region used for noise analysis is usually 2000 to 2200 wavenumbers.
eftir.saveASCII(spectrum, filename, digits=6, delimiter=',') saves the spectrum in ASCII format 'digits' specifies the number of digits to the right of the decimal point. delimiter specifies the character which separates the x,y pairs. returns true/false
eftir.saveFile(spectrum, filename) saves the spectrum in the file
eftir.saveJCAMP(spectrum, filename) saves the spectrum in JCAMP-DX format returns true/false
eftir.savePE(spectrum, filename) saves the spectrum in Perkin-Elmer .SP ASCII format returns true/false
eftir.scan() collect a sample spectrum according to the instrument settings see the example 'testScan.py' script
eftir.setInstrument(name) Tells the program which instrument to use. Each instrument has a unique name that is part of the data collection plugin for that intrument The instrument settings are set to the defaults, which are those showing in the eFTIR user interface. see the example 'testScan.py' script
eftir.stack(w=None): display the workspace given by w in stack mode if w is not provided, use the current active workspace
eftir.superimpose(w=None): display the workspace given by w in superimpose mode if w is not provided, use the current active workspace
eftir.trace(text) Print the text in the 'Trace' window in the user script tool in eFTIR
eftir.undo(spectrum) undoes the last operation performed on the spectrum