40m QIL Cryo_Lab CTN SUS_Lab TCS_Lab OMC_Lab CRIME_Lab FEA ENG_Labs OptContFac Mariner WBEEShop
  40m Log  Not logged in ELOG logo
Message ID: 13077     Entry time: Fri Jun 23 02:43:43 2017
Author: Kaustubh 
Type: HowTo 
Category: Computer Scripts / Programs 
Subject: Taking Measurements From AG4395A 


I have written a code(a basic one which needs a lot of improvements, but still does the job) for taking multiple measurements from the AG4395A. I have also written a separate code for plotting the data taken from the previoius code along with the error bars upto 1 standard deviation.


Details on How To Operate AG4395A:

  1. Under 'Measurement' tab, press the 'Meas' button and select the Analyzer Type (Network Analyzer or Spectrum Analyzer).
  2. Then under the same options select which 'ratio' needs to be measured (A/R, B/R or A/B).
  3. Then press the 'Format' button to select what needs to be measured (Eg - Log|Mag|, Phase, etc.).
  4. In order to measure and see two channels at the same time (Eg - Log|Mag| and Phase), press the 'Display' button and select 'Dual Channel'.
  5. Using the 'Scale' button we can set the scale/div or use autoscale and also set the attenuator values of the different channels.
  6. The 'Bw/Avg' option gives us an averaging option which averages few sets of data to produce the result. In doing this we lose quiet a lot of data and the resulting plot isn't able to give us the information on the statistical errors.
  7. This option also allows us to set the 'Intermediate Frequency' Bandwidth. This basically dictates the sampling rate of the Analyzer. The lower the IF bw, the higher is lesser is the noise (due to less uncertainty in Frequency).
  8. The 'Cal' button helps us calibrate the Analyzer to the current connections and signals. This is done because there is usually a difference in the 'cable lengths' for the two channels which introduces an extra phase term depnding upon the rf frequency. The calibration can be simply done by removing the Device Under Test (DUT) and diectly connecting the coaxial cables to the channels. After this the 'Calibrate Menu' allows us to calibrate the response using the short, open and thru methods.
  9. Now, under the 'Sweep' tab, the 'Sweep' button allows us to select various sweep options such as 'Sweep Time' (Auto, or set a time), 'Number of Points' (b/w 201-801) and 'Sweep Type' (Linear, Log, List Freq. etc.).
  10. Using the 'Source' button we can set the source power in dBm units (Usually kept as -20 to -10 dBm).
  11. The Scan Range can be set in a few ways such as using the start and end points or using the center and span range/width.
  12. After setting up all of the above, we can take the measurement either from the analyzer itself or using one of the control PCs. The command to download the data from AG4395A is netgpibdata -i -d AG4395A -a 10 -f [filename].


Brief Details on How the 'AGmeasure' command works:

AGmeasure is a python script developed by some of the people who work at 40m. It is set as a global command and can be used from within any directory. The source code is in the scripts folder on the network, or else it can also be found in Eric Quintero's git repository. This command accepts at the very least a parameter file. This is supposed to be a .yml file. A template (TFAG4395Atemplate.yml) can be found in the scripts folder or in Eric's repo. There are some other options that can be passed to this command, see the help for more details.


The Multi_Measurement Script:

This script calls the 'AGmeasure' command repetitively and keeps storing the data files in a folder. Right now, the script needs to be fed in th template file manually at prompt.


The Test_Plotting Script:

This script plots the a set of data files obtained from the above mentioned script and produces a plot along with the errors bands upto 1 standard deviation of the data. The format (names) and total number of text files need to be explicitly known, for now at least.



  1. The output test files and the two scripts.
  2. This is the 'Bode Plot' for a data set made using the above two scripts.


To Do:

  • Improve upon the two scripts to be as compatible as the AGmeasure function itself.
  • Try and incorporate the whole script into AGmeasure itself along with improving upon the templates.
  • The above details, with some edits perhaps, can go into the 40m wiki too(?).


Update: Increased the font size in the plot. Added a few comments to the two scripts

To Do: Need to consider the transfer function as a single physical quantity (both the magnitude and phase) and then take the averages and calculate the standard deviation and then plot these results. 



The attachment with the test files and the code now also contains a pdf with all the relations/equations I have used to calculate the averages and errors.

Attachment 1: Test_Files_and_Code.zip  212 kB  Uploaded Mon Jun 26 18:16:50 2017
Attachment 2: Bode_Plot_with_Error_Bands.pdf  60 kB  Uploaded Mon Jun 26 18:17:03 2017  | Hide | Hide all
ELOG V3.1.3-