netGPIB is a collection of python modules and scripts for communicating with GPIB devices over TCP/IP networks. This page explains the usage of the package.

Table of Contents

Where is it ?

On the 40m martian machines, the package is installed in /opt/rtcds/caltech/c1/scripts/general/netgpibdata/. This directory is included in $PATH by default.

The latest version of the package is in the 40m svn repository ( https://nodus.ligo.caltech.edu:30889/svn/trunk/getgpibdata/netgpibdata/ ), or on git.ligo.org (https://git.ligo.org/40m/netgpibdata). Actually, /opt/caltech/scripts/general/netgpibdata/ is a working copy of the repository. So you can type svn up to synchronize the directory with the repository.

What can I do with it

Here is the list of commands included in the package.

Command

Description

netgpibdata.py

Download and save data from a GPIB device. Optionally, it can plot the downloaded data.

plotgpibdata.py

Plot the data downloaded by netgpibdata.py

TFSR785.py

Perform a transfer function measurement with an SR785. Then download the results from it.

SPSR785.py

Perform a spectral measurement with an SR785. Then download the results from it.

resetSR785.py

Remotely reset an SR785.

AG4395A_Run.py

Perform network analyzer measurements using the AG4395. Then download the results from it.

Note: (circa 2014) for the current version on the 40mSVN TFSR785.py, SPSR785.py, resetSR785.py are now all handled by SRmeasure(.py).

Type

SRmeasure --help

for list of options.

Typical usage

SRmeasure SPSR785template.yml

This calls on config file SPSR785template.yml to provide list of settings to send to SR785.

To reset unit

SRmeasure -i 10.0.0.xxx --reset

Where 10.0.0.xx is whatever IP address the unit has.

Here is the list of modules provided by the package.

Module name

Description

netgpib.py

Provide a class to access a network-GPIB converter.

gpibplot.py

Provide parsing of the parameter files and plot functions.

SR785.py

A module containing SR785 specific functions for downloading data.

AG4395A.py

A module containing AG4395A specific functions for downloading data.

termstatus.py

A small utility class for showing status information on a terminal.

Installation

If you want to install the package in your computer, just copy or check-out the netgpibdata directory into somewhere. You may want to add this directory to your $PATH environmental variable. Of course you need to have python installed in your system. The minimum version of python confirmed to work is v2.4. If you want to plot the downloaded data, you need matplotlib and numpy modules installed. In most cases, these modules are available from your distribution's package system.

Usage

For all the commands listed above, you can get a quick help by invoking them with -h option. This will show a list of available options with some descriptions.

netgpibdata.py

Usage: netgpibdata.py [options]

Options:
  -h, --help            show this help message and exit
  -f FILENAME, --file=FILENAME
                        Output file name without an extension
  -d DEVICENAME, --device=DEVICENAME
                        A GPIB device name. Default = SR785.
  -a GPIBADDRESS, --address=GPIBADDRESS
                        GPIB device address
  -i IPADDRESS, --ip=IPADDRESS
                        IP address/Host name
  --plot                Plot the downloaded data.
  --xlin                Plot with linear x axis
  --ylin                Plot with linear y axis
  --xlog                Plot with logarithmic x axis
  --ylog                Plot with logarithmic y axis

This command will connect and download data from a network-GPIB conversion box specified by -i option.
The IPADDRESS can be either numerical ip address or a host name.
The GPIB address of the device connected to the network-GPIB box is specified by -a option.[[BR}} -f FILENAME specifies the name of a file (without extension) to which the retrieved data should be saved.
The downloaded data will be saved to FILENAME.dat and the measurement parameters will be saved to FILENAME.par.
-d option specifies the type of the device connected to the network-GPIB box. Currently supported options are SR785 or AG4395A.

--plot option tells the command to plot the retrieved data. This option currently only works with SR785. You need matplotlib and numpy installed for this option to work.
--xlin, --ylin, --xlog, --ylog options specify the scaling of plot axes. --ylog option will be ignored if the data contain negative values.

plotgpibdata.py

Usage: plotgpibdata.py [options]
Plot the data downloaded by netgpibdata.py.
Data is read from FILENAME.dat and the associated parameters are read from FILENAME.par.
You can start an ipython session after a plot is generated. This enables one to change annotations/appearance of the plot.


Options:
  -h, --help            show this help message and exit
  -f FILENAME, --file=FILENAME
                        Filename without an extension from which the data and
                        parameters are read.
  -i, --ipython         Invoke ipython to interactively change the plot
  --xlin                Plot with linear x axis
  --ylin                Plot with linear y axis
  --xlog                Plot with logarithmic x axis
  --ylog                Plot with logarithmic y axis

This command is used to quickly plot the downloaded data, read from FILENAME.dat.
By using -i option, you can run an ipython session after a plot is generated. In this ipython session, a list object ax is available. Members of the list is matplotlib.axes objects of the created plot. The matplotlib.figure object for the generated plot is available as fig.
For example, you can change the title of the first axes by

ax[0].set_title('New title')

After you change properties of the figure, you have to refresh the figure window by

fig.show()

TFSR785.py

Usage: TFSR785.py [options]

This program executes a transfer function measurement using SR785.
Various measurement conditions can be set using options.
The measurement result will be saved in FILENAME.dat and the measurement parameters in FILENAME.par.
Optionally, it can plot the retrieved data. You need matplotlib and numpy modules to plot the data.


Options:
  -h, --help            show this help message and exit
  -f FILENAME, --file=FILENAME
                        Output file name without an extension
  -i IPADDRESS, --ip=IPADDRESS
                        IP address/Host name
  -a GPIBADDRESS, --address=GPIBADDRESS
                        GPIB device address
  -s STARTFREQ, --startfreq=STARTFREQ
                        Start frequency. Units can be mHz, Hz or kHz.
  -e STOPFREQ, --stopfreq=STOPFREQ
                        Stop frequency. Units can be mHz, Hz or kHz.
  -n NUMOFPOINTS, --numpoints=NUMOFPOINTS
                        Number of frequency points
  --sweep=SWEEPTYPE     Sweep type: Log or Linear
  -x EXCAMP, --excamp=EXCAMP
                        Excitation amplitude
  -c SETTLECYCLES, --settlecycle=SETTLECYCLES
                        Settle cycles
  -t INTCYCLES, --intcycle=INTCYCLES
                        Integration cycles
  --ic1=INPUTCOUPLING1  CH1 input coupling. DC or AC
  --ic2=INPUTCOUPLING2  CH2 input coupling. DC or AC
  --ig1=INPUTGND1       CH1 input grounding. Float or Ground
  --ig2=INPUTGND2       CH2 input grounding. Float or Ground
  --armode=ARMODE       Auto range mode: UpOnly or Tracking
  --plot                Plot the downloaded data.

This command remotely executes a transfer function measurement using an SR785 analyzer. For example, the next command will execute a transfer function measurement with an SR785 connect to a network-GPIB box named teofila (hostname of the box).

TFSR785.py -f TF1 -i crocetta -a 10 -s 50kHz -e 100Hz -n 100 --sweep Log -x 100mV -c 10 -t 50 --ic1 AC --ic2 DC --ig1 Float --ig2 GND --armode UpOnly --plot

In this example, the GPIB address of the SR785 is 10. The downloaded data will be saved to TF1.dat and the measurement parameters will be saved to TF1.par.
The measurement will be logarithmic sweep from 50kHz down to 100Hz at 100 points with an excitation amplitude 100mV.
At each frequency point, the analyzer waits for 10 cycles for settling of the DUT (device under test) and integrates for 50 cycles.
The input coupling of CH1 is AC and CH2 is DC. The grounding is "Float" for CH1 and "Grounded" for CH2. The auto range mode is "up only".
After the measurement is done, the result will be plotted.

SPSR785.py

Usage: SPSR785.py [options]

This program remotely executes a spectrum measurement using SR785.
Various measurement conditions can be set using options.
The measurement result will be saved in FILENAME.dat and the measurement parameters in FILENAME.par.
Optionally, it can plot the retrieved data. You need matplotlib and numpy modules to plot the data.


Options:
  -h, --help            show this help message and exit
  -f FILENAME, --file=FILENAME
                        Output file name without an extension
  -i IPADDRESS, --ip=IPADDRESS
                        IP address/Host name
  -a GPIBADDRESS, --address=GPIBADDRESS
                        GPIB device address
  -b BANDWIDTH, --bandwidth=BANDWIDTH
                        Bandwidth. You can use mHz,Hz or kHz units.
  -n NUMOFPOINTS, --numpoints=NUMOFPOINTS
                        Number of frequency points
  -v NUMAVG, --averaging=NUMAVG
                        Number of averages
  --avgmode=AVGMODE     Averaging mode: None, Vector, RMS or PeakHold
  -d, --dualchannel     Set to the dual channel mode.
  --ic1=INPUTCOUPLING1  CH1 input coupling. DC or AC
  --ic2=INPUTCOUPLING2  CH2 input coupling. DC or AC
  --ig1=INPUTGND1       CH1 input grounding. Float or Ground
  --ig2=INPUTGND2       CH2 input grounding. Float or Ground
  -w WINDOWFUNC, --window=WINDOWFUNC
                        Window function: Uniform, Flattop, Hanning, BMH,
                        Kaiser, Force/Exponential, User, [-T/2,T/2],[0,T/2] or
                        [-T/4,T/4]
  --plot                Plot the downloaded data.
  --xlin                Plot with linear x axis
  --ylin                Plot with linear y axis
  --xlog                Plot with logarithmic x axis
  --ylog                Plot with logarithmic y axis

This command performs spectrum measurements with a network connected SR785 analyzer.
For example, the following command will perform dual channel spectral measurement using an SR785 connected to a network-GPIB box named teofila (hostname).

SPSR785.py -f SP1 -i crocetta -a 10 -b 10kHz -n 400 -v 30 --avgmode RMS -d --ic1 AC --ic2 DC --ig1 Float --ig2 GND -w Hanning --plot

In this example, the GPIB address of the SR785 is 10. The downloaded data will be saved to SP1.dat and the measurement parameters will be saved to SP1.par.
The analyzer will measure the power spectral density of both channels with 10kHz bandwidth with the frequency resolution of 10kHz/400.
It will perform 30 (RMS) averages. The Hanning window will be used to calculate the spectra.
The input coupling of CH1 is AC and CH2 is DC. The grounding is "Float" for CH1 and "Grounded" for CH2. The auto range mode is "up only".
After the measurement is done, the result will be plotted.

resetSR785.py

Usage: resetSR785.py [options]

Options:
  -h, --help            show this help message and exit
  -a GPIBADDRESS, --address=GPIBADDRESS
                        GPIB device address
  -i IPADDRESS, --ip=IPADDRESS
                        IP address/Host name

This command will remotely reset a network connected SR785.
Sometimes, SR785 gets into a weired state and GPIB commands return wrong answers. If the commands explained above fail constantly, use this command to reset the analyzer.

AG4395A_Run.py

usage: AG4395A_Run.py [options]

This command will run a scan on the AG4395 Network Analyzer and download the result(s) as a (series of) .dat files.  This can be used to increase the effective resolution of the NA and to perform a scan with variable resolution over different frequency ranges.


options:
  -h, --help            show this help message and exit
  -s STARTF, --startFreq=STARTF
                        Start Frequency of the scan
  -e ENDF, --endFreq=ENDF
                        End Frequency of the scan
  -c CHUNKS, --chunkSize=CHUNKS
                        size of the individual sweeps in the range
  -f FILESTEM, --fileStem=FILESTEM
                        Base name for file containing individual scan results
  -a AVER, --averages=AVER
                        Number of averages (1=no averaging)
  -d DIR, --directory=DIR
                        Specify a destination directory for the data files
  -b BATCHFILE, --batch=BATCHFILE
                        Enables batch scan mode (supercedes all other options
                        except filestem).  File format must be csv with
                        columns: Start Freq, Stop Freq, (Chunk Size),
                        (Averages).  If Chunk Size and/or Averages is omitted,
                        it will be reused from the previous line (they must be
                        included on the first line).

This command performs a sweep on the AG4395 Network Analyzer. Currently this measures only A/R or B/R with a log sweep frequency; more options will be added soon. It has two modes of operation, single sweep mode and batch mode:

This will perform sequential 800 point sweeps starting at the specified start frequency and moving up to the stop frequency in steps specified by the chunk size. For instance, if the start is at 100Hz, the stop is at 200Hz and the chunk size is 10Hz, it will perform 10 800 point sweeps: the first from 100Hz - 110Hz, the second from 110Hz to 120Hz, etc. up to 190-200Hz. The results from these sweeps will be saved sequentially, and can be concatenated as needed.

In this mode, a file is passed to the function, which contains the parameters of a series of sweeps to be done in sequence. For instance, if one wants a wide band sweep in coarse detail to get the overall shape of a response, and then to zoom in on fine features at increased resolution. The format of this batch file is a csv with 4 columns: start freq, stop freq, chunk size, number of averages. Each line specifies a different sweep, and comments can be included by pre-pending a '#' to the beginning of the line. A sample batch file has been put in the cvs directory with the script.

Tips

First check if you supplied a correct ip address or hostname to -i option. If so, try running the command again.
Sometimes, these commands cannot connect to the network-GPIB box. Just running the command again usually fix it.
If the problem persists, check that the network-GPIB box is powered on, the cable is ok, the ethernet-wireless converter is ok and so on.

Probably some network trouble. Just run the script again.

Independetly by which unites are displayed by the A4395 spectrum analyzer on the screen, the data is saved in Watts/rtHz

The data relative to transfer function measurements are saved in the format with real and imaginary aprt in two separated columns.

matplotlib trick on CentOS

On CentOS5, the default installation of matplotlib does not work properly.
You have to edit /usr/lib64/python2.4/site-packages/matplotlib/mpl-data/matplotlibrc and change the backend to TkAgg.

netGPIB (last edited 2019-07-30 23:05:51 by NathanhollandATligoDOTorg)