[FRPythoneers] CITIfile decoding (fwd)

J. Wayde Allen wallen at its.bldrdoc.gov
Wed Jun 6 12:01:40 MDT 2001

Since I've been talking about Python in the laboratory I figured I'd
try to put a little bit of my money where my mouth is so to speak.  

The CITIfile is a file type created by automatic network analyzers
(ANA's), and the following is an announcement I sent out to the RF
measurement community at large.  If anyone wants to see this, and maybe
improve on it I'd be happy to make it generally available.

- Wayde
  (wallen at its.bldrdoc.gov)

---------- Forwarded message ----------
Date: Tue, 5 Jun 2001 15:00:53 -0600 (MDT)
From: J. Wayde Allen <wallen at its.bldrdoc.gov>
To: "List: RF Measurement" <rfmeas at tigger.boulder.nist.gov>
Cc: William A. Kissick <billk at its.bldrdoc.gov>
Subject: CITIfile decoding 

Don't know how much interest there might be for this, but I've recently 
developed a Python object class for decoding CITIfiles.  If you want to
try it out I'd be happy to share the source code.

You'll need to install the Python interpreter.  (Yes it does run under
windows, as well as Linux, Unix, MacOS, OS2 ...)  The interpreter/compiler
can be downloaded from <http://www.python.org/>, and the install for
windows is roughly four mouse clicks.  Documentation for the Python
language can be found at <http://web.pydoc.org/>.

What I've tried creating is an object class that makes it possible
to access the CITIfile internals without having to write special code or
to convert the file to something that you can work with more easily.  By
instantiating the CITIfile object, you create a series of data arrays that
contain the contents of the CITIfile, and can access these directly.  For
example, if you instantiate the object as mydata:

     mydata = citifile('citifile_to_read')

you now have access to:

   - The number of packages in the CITIfile as

        number_of_packages = len(mydata.packages)

   - The names of the data packages

        package_name = mydata.packages[packagenumber]

   - Any stored constants

        constants = mydata.constants[packagenumber]

   - The number of measured parameters

        numparams = len(mydata.params[packagenumber])

   - The names of the actual parameters

        paramname = mydata.params[packagenumber][parameterindex]

   - The data for each parameter

        datavalue = mydata.data[packagenumber][parmeterindex][valueindex]

   - Test instrument specific information such as the instrument making
     the measurement and its recorded settings

        instrumentdata = mydata.instrmnt[packagenumber]

This hopefully will make it easier to develop software that makes use of
the ANA data.

An example is a piece of code I cobbled together for testing the routine.  
This is a simple minded CITIfile converter that extracts CITIfile data
into row/column form.  Using this object only required the following lines
of code, most of which are simply print lines:

   #!/usr/bin/env python

   import string, sys
   from calfiles import citifile   #calfiles is the physical file
                                   #on my hard drive that contains the 
                                   #code for the citifile object

   #Get the filename from the command line argument
   myfile = sys.argv[1]
   mydata = citifile(myfile)

   for packages in range(len(mydata.packages)):
      print 'CITIfile Package Name:  ',mydata.packages[packages]

      for numparams in range(len(mydata.params[packages])):
         print mydata.params[packages][numparams][0] + '\t',

      for items in range(len(mydata.data[packages][0])):
         for numparams in range(len(mydata.params[packages])):
            print mydata.data[packages][numparams][items],
      print '-' * 80

- Wayde
  (wallen at its.bldrdoc.gov)

More information about the FRPythoneers mailing list