view plotss.py @ 85:60ad91b4c67c default tip

Add 'quick' option to use a faster sweep time with no averaging. Useful for testing the hardware is setup correctly without having to wait 3 minutes.
author Daniel O'Connor <doconnor@gsoft.com.au>
date Mon, 21 Oct 2024 14:12:50 +1030
parents 91b476ebc0f2
children
line wrap: on
line source

#!/usr/bin/env python

import datafile
import exceptions
import numpy
import pylab
import sys

def doplot(fname):
    dfile = datafile.DataFile(fname)
    
    xdata = dfile.freqs / 1e6
    ydata = dfile.powers
    pylab.title("Tag \'" + dfile['TAG'] + "\' at " + dfile['TIMESTAMP'])
    pylab.xlabel("Frequency (MHz)")
    pylab.ylabel("Level (dBm)")
    annstr = "FStart: %.2f MHz\nFStop: %.2f MHz\nPoints: %d" % (
        float(dfile['FSTART']) / 1e6,
        float(dfile['FSTOP']) / 1e6,
        len(xdata))
    pylab.annotate(annstr, xy=(5, -40),  xycoords='axes points')

    annstr = "Video BW: %.1f kHz\nResol. BW: %.1f kHz\nAttenuation: %.1f dB\nRef Level: %.1f dBm" % (
        float(dfile['VIDBW']) / 1e3,
        float(dfile['RESBW']) / 1e3,
        float(dfile['ATTEN']),
        float(dfile['REFLEV']))        
    pylab.annotate(annstr, xy=(-140, -55),  xycoords='axes points')
    pylab.grid(True)
    pylab.plot(xdata, ydata, linestyle='solid', marker='.')
    pylab.show()
    
if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Need at least one file to plot")
        sys.exit(1)

    for fn in sys.argv[1:]:
        doplot(fn)