#!/APSshare/anaconda3/x86_64/bin/python import epics from time import sleep import sys arg2 = sys.argv outpath = "/home/8-id-g/2018-3/tsai201810p/device/" outfile = outpath + arg2[1] sweepit = 1 plotit = 0 if sweepit : epics.caput("8ide:2400:ReadArray.PROC", 1) # wait for sweep to complete -- hack with fixed delay. Is there a condition to test so we know when sweep is complete? print('sweep in progress') sleep(20) # close fast shutter epics.caput("8idg:Unidig1Bo13",1) # read in the sweep data indata = epics.caget("8ide:2400:ReadArray"); # read in number of non-zero elements. num2pts = epics.caget("8ide:2400:ReadArray.NORD"); print(num2pts); # development # Why doesn't this agree? For 41 pts (82 values), returns 752. print(sys.getsizeof(indata)) # development print(indata) # development f = open(outfile,"w") counter = 0 for i in indata : #print(i) counter=counter+1; if (counter % 2 == 1): try: VOLT = float(i) except: VOLT = "NaN" print("Error converting string to float./n") else : try: CURR = float(i) except: CURR = "NaN" print("Error converting string to float./n") print("VOLTAGE=",VOLT," CURRENT=",CURR) f.write('{0:>6} {1}\n'.format(VOLT ,CURR)) f.close() print(arg2[1]) if plotit : print("Plot the data here.")