Package: pyrga
pyrgapyrgais a Python 3 library for communicating withSRS RGA (Residual Gas Analyzer from Stanford Research Systems). If you're reading this, you probably know what it is.DISCLAIMERTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.WARNINGSRead thelicensebefore using the code.Always make sure that you have good vacuum before turning on the filament.Think twice before pushing a button. Your RGA is an expensive piece of equipment.Follow required safety precautions. Your life is quite valuable too.This software comes with no warranties of any kind whatsoever, and may not be useful for anything. Use it at your own risk.What is RGARGA, or Residual Gas Analyzer is a spectrometer that allows measuring chemical composition of gases present in a low-pressure environment. RGA ionizes various components of the gas mixture creating ions, accelerates and mass-filters ions based on their mass-to-charge ratio and measures these ion currents effectively determining partial pressures of various gases. SeeStandford Research Systemspage for more info, datasheets and user manuals.Purpose of this libraryThis library is an attempt to put together a minimal set of self-explanatory functions to allow single mass measurements and spectrum scans (histograms are not supported). It is built with as many sanity checks as I could think of.That doesn't mean that you should use this library without reading the manual and understanding principles of RGA operation.Most of the functionality is spread over a dozen of getters and setters, making this python library look and feel like Java. This is partly due to specifics of RGA communication protocol, and partly due to my poor taste.Why not just use the official app?While official RGA app from SRS is well built and time tested, I found these limitations to be a show stopper for my applications:windows onlyno API (RS232 communication protocolisthe API)when running in "pressure vs time" mode for a few weeks, GUI gets slow and unresponsiveSome of our RGAs run 24/7 for nine months per year, and the official app isn't ideal for such applications.InstallationUse the package managerpipto installpyrga.python3-mpipinstallpyrgaUsageSingle mass scanimportpyrgaif__name__=="__main__":# initialize client with non-default noise floor settingRGA=pyrga.RGAClient("/dev/ttyUSB0",noise_floor=0)# check filament status and turn it on if necessaryifnotRGA.get_filament_status():RGA.turn_on_filament()# read partial pressures of air constituentMASSES={18:"H2O",28:"N2",32:"O2",40:"Ar",}form,iinMASSES.items():print("partial pressure of element{}is{}Torr".format(i,RGA.read_mass(m)))output:INFO:pyrga.driver:Opening serial interface /dev/ttyUSB0...
INFO:pyrga.driver:Querying device ID...
INFO:pyrga.driver:Connected to RGA model SRSRGA100 on port /dev/ttyUSB0, id SRSRGA100...
INFO:pyrga.driver:Querying CDEM presence...
INFO:pyrga.driver:Querying filament status...
INFO:pyrga.driver:Querying filament current...
INFO:pyrga.driver:Setting CEDM voltage to 0...
INFO:pyrga.driver:Querying CDEM voltage...
INFO:pyrga.driver:Setting electron energy to default...
INFO:pyrga.driver:Querying electron energy...
INFO:pyrga.driver:Setting ion energy to default...
INFO:pyrga.driver:Setting focus plate voltage to default...
INFO:pyrga.driver:Querying focus plate voltage...
INFO:pyrga.driver:Setting emission current to default...
INFO:pyrga.driver:Setting noise floor to 0... (0 - max averaging, 7 - min averaging)
INFO:pyrga.driver:Querying noise floor setting...
INFO:pyrga.driver:Setting partial pressure sensitivity factor to default...
INFO:pyrga.driver:Querying partial pressure sensitivity factor stored in RGA...
INFO:pyrga.driver:Setting total pressure sensitivity factor to default...
INFO:pyrga.driver:Querying total pressure sensitivity factor stored in RGA...
INFO:pyrga.driver:Zeroing ion detector and applying temperature compensation factors...
INFO:pyrga.driver:Querying filament status...
INFO:pyrga.driver:Querying filament current...
INFO:pyrga.driver:Reading a single scan of amu mass number 18
partial pressure of element H2O is 1.0502660300136425e-07 Torr
INFO:pyrga.driver:Reading a single scan of amu mass number 28
partial pressure of element N2 is 8.462960436562073e-08 Torr
INFO:pyrga.driver:Reading a single scan of amu mass number 32
partial pressure of element O2 is 1.6347885402455663e-08 Torr
INFO:pyrga.driver:Reading a single scan of amu mass number 40
partial pressure of element Ar is 1.4222373806275579e-09 TorrSpectrum scanimportloggingimportmatplotlib.pyplotaspltimportpyrga# turn off logginglogging.getLogger('pyrga').setLevel(logging.CRITICAL)if__name__=="__main__":# initialize client with default settingsRGA=pyrga.RGAClient("/dev/ttyUSB0")# check filament status and turn it on if necessaryifnotRGA.get_filament_status():RGA.turn_on_filament()# read analog scan of 1-50 mass range with max resolution of 25 steps per amumasses,pressures,total=RGA.read_spectrum(1,50,25)plt.plot(masses,pressures)plt.yscale('log')plt.ylim(1e-9,1e-6)plt.show()output:APIThis can hardly be called "documentation". Use at your own risk.Note: I use the term "amu" willy-nilly and interchangeably with "mass-to-charge ratio". Yes, I know this is incorrect.Public functionscalibrate_all()turn_on_filament()turn_off_filament()read_spectrum(amu_min,amu_max,amu_res)read_mass(amu)Public getters/settersget_device_id()get_cdem_presence()set_partial_sens(partial_sens_mA_per_Torr)get_partial_sens()set_total_sens(total_sens_mA_per_Torr)get_total_sens()set_electron_energy(electron_energy_eV)get_electron_energy()set_ion_energy(ion_energy_eV)get_ion_energy()set_plate_voltage(plate_voltage_V)get_plate_voltage()set_spectrogram_params(amu_min,amu_max,amu_res)get_spectrogram_params()# this does not turn on/off the filament, use turn_on_filament() and turn_off_filament()set_emission_current(emission_current_mA)get_emission_current()get_filament_status()set_cdem_voltage(cedm_voltage_V)get_cdem_voltage()set_noise_floor(noise_floor)get_noise_floor()LoggingSet the logging level viasetLevel:importloggingimportpyrgalogging.getLogger('pyrga').setLevel(logging.DEBUG)if__name__=='__main__':RGA=pyrga.RGAClient('/dev/ttyUSB0')...Testing?SeeContributing.ContributingDocumentation is clearly lacking. Tests are non-existent. Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.See alsoPyrga, Larnacais a village in the Larnaca District of Cyprus, located on 4 km east of Kornos.