Skip to content
Snippets Groups Projects
Commit b7bb71dd authored by jmcchesn's avatar jmcchesn
Browse files

vortex updated

parent 33a77679
No related branches found
No related tags found
No related merge requests found
......@@ -139,15 +139,26 @@ resolution => gives the resolution for the current settings
scaler_cts => sets the scaler counter for the current endstation
#scanRecord: functions and class for handling the scanRecord
saveData_get_all => returns dictions of fileSystem,subDir,scanNumber,baseName
ScanRecord => class for handling scanRecord_user
scan_fillin => same as iex.BL.mda.fillin
scan_fillin_table => same as iex.BL.mda.fillin_table
scan_go => same as iex.BL.mda.go
.trigger_get
.trigger_set
.trigger_clear
.detectors_set
detectors_clear => clears all
.fileNum
.lastFileNum
.filepath
.prefix
.current_run
.user_name
.empty_scan => scan with no positioners
.time_scan => scan with positioner readback as time and detector settling as minutes
.lastFileNum
#Scienta: base functions for taking spectra, called by electron_analyzer
......
......@@ -5,7 +5,6 @@ import time
from epics import caget, caput, PV
import iexcode.instruments.cfg as iex
from iexcode.instruments.utilities import dateandtime, print_warning_message
from iexcode.instruments.userCalcs import userStringSeq_pvs,userStringSeq_clear
from iexcode.instruments.shutters import shutter_check
......@@ -535,13 +534,22 @@ class ScanRecord:
Clear all scan detectors triggers
trigger_dictionary = {trigger_num:pv}
Previously: Clear_Scan_Triggers
"""
scan_pv = self.ioc+"scan"+str(scan_dim)
if len(trigger_dictionary.keys())>0:
for tigger_num in trigger_dictionary.keys():
caput(scan_pv+".T"+str(tigger_num)+"PV",trigger_dictionary[tigger_num])
def triggers_get(self,scan_dim):
"""
returns a dictionary of the current scan striggers for scan_dim
"""
scan_pv = self.ioc+"scan"+str(scan_dim)
scan_trigger = {}
for tigger_num in range(1,5):
scan_trigger.update({tigger_num:caget(scan_pv+".T"+str(tigger_num)+"PV")})
def triggers_clear(self,scan_dim,trigger_dictionary,verbose=True):
"""
Clear all scan detectors triggers
......
from this import d
from epics import caput, caget
import iexcode.instruments.cfg as iex
from iexcode.instruments.scanRecord import saveData_get_all
vortex_pv = "29idVORTEX:"
scaler_pv = '29idMZ0:scaler1.TP'
calc_pv = '29idKappa:userCalcOut3.A'
vortex_power_pv = '29idd:Unidig1Bo1'
transform_pv = '29idd:userTran1'
#Define caput with wait function
def caputw(PVname,PVinput):
return caput(PVname,PVinput,wait=True,timeout = 100000)
def vortex(energy):
'''Sets the energy window for the vortex'''
cen, wid = vortex_Ecal(energy)
set_roi1(cen,wid)
caput('29idKappa:userCalcOut3.A',energy)
def set_roi1(cen,wid):
caput('29idVORTEX:mca1.R0LO',round(cen-wid/2))
caput('29idVORTEX:mca1.R0HI',round(cen+wid/2))
def set_roi2(cen,wid):
caput('29idVORTEX:mca1.R1LO',round(cen-wid/2))
caput('29idVORTEX:mca1.R1HI',round(cen+wid/2))
def vortex_Ecal(energy):
cen = 12.8 + 0.72*energy
wid = 120
return cen, wid
def mca_energy(energy):
'''
Sets the energy window for the vortex
'''
#energy window calc
center = 12.8 + 0.72*energy
width = 120
#set hi and low
caput(vortex_pv+'mca1.R0LO',round(center-width/2))
caput(vortex_pv+'mca1.R0HI',round(center-width/2))
#pv to store energy set point
caput(calc_pv,energy)
def mcacounttime(t):
'''Sets acquisition time for vortex and SRS to t(s)'''
caput('29idVORTEX:mca1.PRTM',t)
caput('29idMZ0:scaler1.TP',t)
def mca_scaler(time_sec):
'''
Sets acquisition time for vortex and SRS to time_sec
'''
caput(vortex_pv+'mca1.PRTM',time_sec)
caput(scaler_pv,time_sec)
def runmca(t):
caput('29idVORTEX:mca1.PRTM',t)
def mca_run(time_sec):
caput(vortex_pv+'mca1.PRTM',time_sec)
sleep(0.1)
caputw('29idVORTEX:mca1EraseStart',1)
caput(vortex_pv'mca1EraseStart',1,wait=True,timeout = 100000)
def mcaoff():
def mca_off():
'''Power vortex OFF'''
caput('29idd:Unidig1Bo1',1)
caput(vortex_power_pv,1)
print('Vortex power OFF')
def mcaon():
def mca_on():
'''Power vortex ON'''
caput('29idd:Unidig1Bo1',0)
caput(vortex_power_pv,0)
print('Vortex power ON')
def _mca_file_setup():
mda_saveData=saveData_get_all(iex.BL.mda.ioc)
caput(vortex_pv+'saveData_fileSystem',mda_saveData[fileSystem])
caput(vortex_pv+'saveData_subDir', '/'+ mda_saveData['subDir']+'/S'+str(mda_saveData['scanNumber']))
caput(vortex_pv+'saveData_scanNumber',1)
def mcascan(add_vortex=True,save_image=False):
def _vortex_detector_dictionary(add_mca):
d = {
16:vortex_pv+":mca1.R0",
17:vortex_pv+":mca1.R1",
49:transform_pv+".D",
50:transform_pv+".E",
}
if add_mca == False:
for key in d.keys():
d[key]=''
return d
def _vortex_trigger_dictionary(save_image,trig_num=2):
if save_image:
d = {trig_num:vortex_pv+'scanH.EXSC'}
else:
d = {trig_num:vortex_pv+'mca1EraseStart'}
return d
def scanmca(add_mca=True,save_image=False,**kwargs):
'''
add_vortex=True (default): set up scan to save vortex as a detector
add_vortex=False: remove the vortex from the scan detector
save_image=True: save the individual mca files
**kwargs:
trig_num
'''
def scan_num():
scan = caget('29idKappa:saveData_message')
loc = scan.find('.')
if (loc==-1):
scannum=0
else:
scannum =int(scan[loc-4:loc])
return scannum
def mcafileinit():
# mainpath = '/net/s4data/export/sector4/4idc/mda'
scanrecpath = caget('29idKappa:saveData_subDir')
scan = scan_num()+1
caput('29idVORTEX:saveData_subDir', '/'+ scanrecpath+'/S'+str(scan))
caput('29idVORTEX:saveData_scanNumber',1)
if add_vortex:
if trig_num in kwargs:
trig_num = kwargs['trig_num']
else:
trig_num = 2
if add_mca:
#add trigger and detectors
iex.BL.mda.triggers_set(_vortex_trigger_dictionary(save_image,trig_num))
iex.BL.mda.detectors_set(_vortex_detector_dictionary(add_mca))
sleep(1)
if save_image:
mcafileinit()
_mca_file_setup()
chkmcasave()
caput('29idKappa:scan1.T2PV','29idVORTEX:scanH.EXSC')
caput('29idKappa:scan1.D16PV','29idVORTEX:mca1.R0')
caput('29idKappa:scan1.D17PV','29idVORTEX:mca1.R1')
caput('29idKappa:scan1.D49PV','29idd:userTran1.D')
caput('29idKappa:scan1.D50PV','29idd:userTran1.E')
sleep(1)
else:
caput('29idKappa:scan1.T2PV','29idVORTEX:mca1EraseStart')
caput('29idKappa:scan1.D16PV','29idVORTEX:mca1.R0')
caput('29idKappa:scan1.D17PV','29idVORTEX:mca1.R1')
caput('29idKappa:scan1.D49PV','29idd:userTran1.D')
caput('29idKappa:scan1.D50PV','29idd:userTran1.E')
sleep(1)
else:
caput('29idKappa:scan1.T2PV','')
caput('29idKappa:scan1.D16PV','')
caput('29idKappa:scan1.D17PV','')
caput('29idKappa:scan1.D49PV','')
caput('29idKappa:scan1.D50PV','')
#remove vortex trigger and detectors
iex.BL.mda.triggers_clear()
iex.BL.mda.detectors_set(_vortex_detector_dictionary(add_mca))
sleep(1)
def chkmcasave():
if (caget('29idKappa:scan1.T2PV')=='29idVORTEX:scanH.EXSC'):
def mca_check_save(**kwargs):
"""
checks if vortex is being triggered
**kwargs:
scan_dim => 1 default
trig_num => 2 default
"""
kwargs.setdefault('scan_dim',1)
kwargs.setdefault('trig_num',2)
d=iex.BL.mda.triggers_get(kwargs['scan_dim'])
if d[kwargs['trig_num']] == vortex_pv+'scanH.EXSC':
print('Saving mca files')
mcafileinit()
_mca_file_setup()
# def savemca():
# caput('29idKappa:scan1.T2PV','29idVORTEX:scanH.EXSC')
# caput('29idKappa:scan1.D16PV','29idVORTEX:mca1.R0')
# caput('29idKappa:scan1.D17PV','29idVORTEX:mca1.R1')
# caput('29idKappa:scan1.D49PV','29idd:userTran1.D')
# caput('29idKappa:scan1.D50PV','29idd:userTran1.E')
# sleep(1)
# def nosavemca():
# caput('29idKappa:scan1.T2PV','29idVORTEX:mca1EraseStart')
# caput('29idKappa:scan1.D16PV','29idVORTEX:mca1.R0')
# caput('29idKappa:scan1.D17PV','29idVORTEX:mca1.R1')
# caput('29idKappa:scan1.D49PV','29idd:userTran1.D')
# caput('29idKappa:scan1.D50PV','29idd:userTran1.E')
# sleep(1)
# def nomca():
# caput('29idKappa:scan1.T2PV','')
# caput('29idKappa:scan1.D16PV','')
# caput('29idKappa:scan1.D17PV','')
# caput('29idKappa:scan1.D49PV','')
# caput('29idKappa:scan1.D50PV','')
# sleep(1)
# def scan_num():
# scan = caget('29idKappa:saveData_message')
# loc = scan.find('.')
# if (loc==-1):
# scannum=0
# else:
# scannum =int(scan[loc-4:loc])
# return scannum
# def mcafileinit():
# # mainpath = '/net/s4data/export/sector4/4idc/mda'
# scanrecpath = caget('29idKappa:saveData_subDir')
# scan = scan_num()+1
# caput('29idVORTEX:saveData_subDir', '/'+ scanrecpath+'/S'+str(scan))
# caput('29idVORTEX:saveData_scanNumber',1)
# def chkmcasave():
# if (caget('29idKappa:scan1.T2PV')=='29idVORTEX:scanH.EXSC'):
# print('Saving mca files')
# mcafileinit()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment