#!/usr/bin/env python import os import sys import time import numpy as np sys.path.append('/opt/rtcds/caltech/c1/scripts/pylibs/') import pyezcalib as ca sys.path.append('/opt/rtcds/caltech/c1/scripts/general/netgpibdata/') import netgpib import AG4395A def measure(gpib, path): freq = '3E6' avgs = 40 gpib.command('SA') gpib.command('STOP %s' % freq) gpib.query('STOP?') gpib.command('TRGS INT') #gpib.command('SING') gpib.command('AVER ON') gpib.command('AVERFACT %d' % avgs) gpib.query('AVER?') gpib.query('AVERFACT?') gpib.command('NUMG %d' % avgs) while int(gpib.query('HOLD?')) != 1: time.sleep(1) path = '%s_%s' % (path, freq) dfile = open(path+'.dat','w') pfile = open(path+'.par','w') AG4395A.getdata(gpib, dfile, pfile) dfile.close() pfile.close() ip = '192.168.113.108' addr = '10' gpib = netgpib.netGPIB(ip, addr, '\004', 0, log=True) odir = sys.argv[1] if not os.path.exists(odir): os.makedirs(odir) #cgains = np.arange(7, 13, .5) cgains = [13.0] #cgains = [10.5] #fgains = np.arange(23, 26, .5) fgains = [23.5] for cgain in cgains: for fgain in fgains: print print '#######################################' ca.cawrite('C1:PSL-FSS_MGAIN', cgain) ca.cawrite('C1:PSL-FSS_FASTGAIN', fgain) path = '%s/%s_%s' % (odir, cgain, fgain) print path time.sleep(2) measure(gpib, path) gpib.close()