def cvscan(c_energy, start, stop, step, *args): ''' cvscan that checks if there is enough time to collect data before topup when 'checkbeamcv' is used. ''' wfs = [] dwell = [] others = [] beam_checker = None newargs = [c_energy, start, stop, step] try: for arg in args: if isinstance(arg, WaveformChannelScannable): wfs.append(arg) elif isinstance(arg, Number): dwell.append(arg) elif isinstance(arg, ZiePassthroughScannableDecorator): beam_checker = arg else: others.append(arg) if not checkContentEqual(dwell): raise ValueError( "dwell time specified must be equal for all detectors!") for each in wfs: newargs.append(each) newargs.append( dwell[0] ) #the pull stream code require every channel have dwell time even they are on the same EPICS scaler if c_energy.getName() == "egy_g": for each in wfs: each.setHardwareTriggerProvider( cemc_g ) # switch to ContinuousPgmGratingEnergyMoveController id_energy_follower = getEnergyFollower4CurrentSmodePolarisation() if id_energy_follower is not None: newargs.append( id_energy_follower) # add the ID energy follower elif c_energy.getName() == "egy": for each in wfs: each.setHardwareTriggerProvider( cemc) #switch to ContinuousPgmEnergyMoveController id_energy_follower = getEnergyFollower4CurrentSmodePolarisation() if id_energy_follower is not None: newargs.append( id_energy_follower) # add the ID energy follower for other in others: newargs.append(other) if beam_checker is not None: #check if there is enough time for the cvscan before topup scanTime = abs((stop - start) / step * dwell[0]) topup_checker = beam_checker.getDelegate().getGroupMember( "checktopup_time_cv") topup_checker.minimumThreshold = scanTime + 5 # print "topup_checker.minimumThreshold = %r" % (topup_checker.minimumThreshold) newargs.append(beam_checker) trajectory_controller_helper.energy = c_energy trajectory_controller_helper.wfs = wfs cvscan_traj([e for e in newargs]) except: localStation_exception(sys.exc_info(), "cvscan exits with Error.")
def cvscan(c_energy, start, stop, step, *args): ''' cvscan that checks if there is enough time to collect data before topup when 'checkbeam' is used. ''' wfs = [] dwell = [] others = [] beam_checker = None newargs = [c_energy, start, stop, step] try: for arg in args: if isinstance(arg, WaveformChannelScannable): wfs.append(arg) if c_energy.getName() == 'jenergy': arg.setHardwareTriggerProvider(jenergy_move_controller) elif c_energy.getName() == 'ienergy': arg.setHardwareTriggerProvider(ienergy_move_controller) else: raise RuntimeError( "cvscan only works with 'ienergy' or 'jenergy' for continuous energy moving scan!" ) elif isinstance(arg, Number): dwell.append(arg) elif arg.getName() == "checkbeam": beam_checker = arg else: others.append(arg) if not check_content_equal(dwell): raise RuntimeError( "dwell time specified must be equal for all detectors!") for each in wfs: newargs.append(each) newargs.append( dwell[0] ) #the pull stream code require every channel have dwell time even they are on the same EPICS scaler for other in others: newargs.append(other) if beam_checker is not None: #check if there is enough time for the cvscan before top_up scan_time = abs((stop - start) / step * dwell[0]) topup_checker = beam_checker.getGroupMember("checktopup_time") topup_checker.setOperatingContinuously( True) #only check at scan start topup_checker.minimumThreshold = scan_time + 5 newargs.append(beam_checker) cvscan_traj([e for e in newargs]) except: localStation_exception(sys.exc_info(), "cvscan exits with Error.")
''' Created on 16 Apr 2018 @author: fy65 ''' from gdaserver import shtr1, gv12 from utils.ExceptionLogs import localStation_exception import sys print "-" * 100 print "Creating short hand command for shutter 1 and gate vale 12 controls: 'shtropen', 'shtrclose', 'gv12open', and 'gv12close'" try: shtropen = shtr1.moveTo("Open") shtrclose = shtr1.moveTo("Close") gv12open = gv12.moveTo("Open") gv12close = gv12.moveTo("Close") except: localStation_exception(sys.exc_info(), "creating shutter & valve objects")
import sys print "-" * 100 print "Creating scannables for High Field Magnet control using EPICS PV directly:" print " 1. 'ips_field' - the demand field" print " 2. 'ips_sweeprate' - the sweep rate" print " 3. 'itc2' - the temperature controller" print " 4. 'magj1yrot_off' - the rotation offset" try: from high_field_magnet.scannable.intelligentPowerSupply import IntelligentPowerSupplyFieldScannable, IntelligentPowerSupplySweepRateScannable from dls_scripts.scannable.CryojetScannable import CryojetScannable ips_field = IntelligentPowerSupplyFieldScannable('ips_field', 'BL10J-EA-SMC-01:', field_tolerance=0.01) ips_sweeprate = IntelligentPowerSupplySweepRateScannable( 'ips_sweeprate', 'BL10J-EA-SMC-01:', sweeprate_tolerance=0.01) itc2 = CryojetScannable('itc2', pvroot='BL10J-EA-TCTRL-02:', temp_tolerance=1, stable_time_sec=60) ips_field.setLevel(6) ips_sweeprate.setLevel(6) itc2.setLevel(6) magj1yrot_off = EpicsReadWritePVClass('magj1yrot_off', 'BL10J-EA-MAG-01:INSERT:ROTY.OFF', 'deg', '%.6f') except: localStation_exception(sys.exc_info(), "initialising high field magnet")
def cvscan2(c_energy, start, stop, step, *args): ''' cvscan that applies dwell time to all instances of WaveformChannelScannable. This will make sure all the waveform channel scannable data are polled at the same rate. ''' wfs = [] dwell = [] others = [] beam_checker = None newargs = [c_energy, start, stop, step] try: for arg in args: if isinstance(arg, WaveformChannelScannable): wfs.append(arg) elif isinstance(arg, Number): dwell.append(arg) elif isinstance(arg, ZiePassthroughScannableDecorator): beam_checker = arg else: others.append(arg) if not checkContentEqual(dwell): raise Exception( "dwell time specified must be equal for all detectors!") for each in wfs: newargs.append(each) newargs.append(dwell) if c_energy.getName() == "egy_g" or c_energy.getName() == "egy": #set dwell time to embedded instances of WaveformChannelScannable if binpointGrtPitch_g not in wfs: newargs.append(binpointGrtPitch_g) newargs.append(dwell) if binpointMirPitch_g not in wfs: newargs.append(binpointMirPitch_g) newargs.append(dwell) if binpointPgmEnergy_g not in wfs: newargs.append(binpointPgmEnergy_g) newargs.append(dwell) if c_energy.getName() == "egy_g": for each in wfs: each.setHardwareTriggerProvider( cemc_g ) # switch to ContinuousPgmGratingEnergyMoveController id_energy_follower = getEnergyFollower4CurrentSmodePolarisation() if id_energy_follower is not None: newargs.append( id_energy_follower) # add the ID energy follower elif c_energy.getName() == "egy": for each in wfs: each.setHardwareTriggerProvider( cemc) #switch to ContinuousPgmEnergyMoveController id_energy_follower = getEnergyFollower4CurrentSmodePolarisation() if id_energy_follower is not None: newargs.append( id_energy_follower) # add the ID energy follower for other in others: newargs.append(other) if beam_checker is not None: #check if there is enough time for the cvscan before topup scanTime = abs((stop - start) / step * dwell[0]) topup_checker = beam_checker.getDelegate().getGroupMember( "checktopup_time_cv") topup_checker.minimumThreshold = scanTime newargs.append(beam_checker) trajectory_controller_helper.energy = c_energy trajectory_controller_helper.wfs = wfs cvscan_traj = trajscans.CvScan( [scan_processor, trajectory_controller_helper]) cvscan_traj([e for e in newargs]) except: localStation_exception(sys.exc_info(), "cvscan2 exits with Error.")
"BL10I-OP-FOCS-01:X.STOP", 0.002, "mm", "%.3f") m4_y = PositionCompareMotorClass("m4_y", "BL10I-OP-FOCS-01:Y.VAL", "BL10I-OP-FOCS-01:Y.RBV", "BL10I-OP-FOCS-01:Y.STOP", 0.002, "mm", "%.3f") m4_z = PositionCompareMotorClass("m4_z", "BL10I-OP-FOCS-01:Z.VAL", "BL10I-OP-FOCS-01:Z.RBV", "BL10I-OP-FOCS-01:Z.STOP", 0.002, "mm", "%.3f") m4_yaw = PositionCompareMotorClass("m4_yaw", "BL10I-OP-FOCS-01:YAW.VAL", "BL10I-OP-FOCS-01:YAW.RBV", "BL10I-OP-FOCS-01:YAW.STOP", 0.002, "urad", "%.3f") m4_pitch = PositionCompareMotorClass("m4_pitch", "BL10I-OP-FOCS-01:PITCH.VAL", "BL10I-OP-FOCS-01:PITCH.RBV", "BL10I-OP-FOCS-01:PITCH.STOP", 0.002, "urad", "%.3f") m4_roll = PositionCompareMotorClass("m4_roll", "BL10I-OP-FOCS-01:ROLL.VAL", "BL10I-OP-FOCS-01:ROLL.RBV", "BL10I-OP-FOCS-01:ROLL.STOP", 0.002, "urad", "%.3f") m4fpitch = SingleEpicsPositionerNoStatusClassDeadbandOrStop( 'm4fpitch', 'BL10I-OP-FOCS-01:FPITCH:DMD:AO', 'BL10I-OP-FOCS-01:FPITCH:RBV:AI', 'V', '%.3f', 0.001) m4 = ScannableGroup( "m4", [m4_x, m4_y, m4_z, m4_yaw, m4_pitch, m4_roll, m4fpitch]) except: localStation_exception(sys.exc_info(), "initialising m4 hexapod and fpitch scannables")
andorGV12 = SwitchableHardwareTriggerableProcessingDetectorWrapper( 'andorGV12', andor1GV12det, None, andor1GV12det_for_snaps, [], panel_name=None, panel_name_rcp='Plot 1', toreplace=None, replacement=None, iFileLoader=TIFFImageLoader, fileLoadTimout=15, returnPathAsImageNumberOnly=True) def andorGV12openDelay(t_seconds=None): """Get or set the shutter close delay (in seconds) for the andor""" if t_seconds == None: return andor1GV12det.getCollectionStrategy().getShutterOpenDelay() andor1GV12det.getCollectionStrategy().setShutterOpenDelay(t_seconds) def andorGV12closeDelay(t_seconds=None): """Get or set the shutter close delay (in seconds) for the andor""" if t_seconds == None: return andor1GV12det.getCollectionStrategy().getShutterCloseDelay() andor1GV12det.getCollectionStrategy().setShutterCloseDelay(t_seconds) alias('andorGV12openDelay') alias('andorGV12closeDelay') except: localStation_exception(sys.exc_info(), "creating andor & andorGV12 objects")
from gdaserver import pgm_energy, thp, ttp, py, pz from utils.ExceptionLogs import localStation_exception from gda.jython.commands.GeneralCommands import alias import sys print "-" * 100 print "Creating Multilayer Analyser example objects:" print " 1. 'ml' - define multilayer object using (name, d_spacing (A), start_energy(eV), stop_energy(eV), thp_offset(deg), pos_z(mm), pos_y(mm))" print " 2. 'mss' - define multilayer selector scannable using (name, multilayer_list, pz_scannable, py_scannable)" print " 3. 'pa' - define polarisation analyser scannable using (name, thp_scannable, ttp_scannable, multilayer_selector_scannable, energy_scannable)" try: from rasor.scannable.polarisationAnalyser import Multilayer, MultilayerSelectorScannable, PolarisationAnalyser # name, d_spacing (A), start_energy(eV), stop_energy(eV), thp_offset(deg), pos_z(mm), pos_y(mm) ml = [ Multilayer("mn", 13.7, 600, 700, 1.17, -14.5, 1.5), Multilayer("o", 16.2, 510, 550, 0, 0, 1.5) ] # name, multilayer_list, pz_scannable, py_scannable mss = MultilayerSelectorScannable("mss", ml, pz, py) # name, thp_scannable, ttp_scannable, multilayer_selector_scannable, energy_scannable pa = PolarisationAnalyser("pa", thp, ttp, mss, pgm_energy) print "Usage: pos mss to find out which MSS you are on" print "Usage: pos mss <num> to select MSS by number" print "Usage: pos mss 'string' to select MSS by name" print "Usage: pos pa to find out which PA you are on" print "Usage: pos pa <num> to set pa for a given energy in eV" print "Usage: pos pa 0 to set pa for a the energy in configured energy scannable" alias("pa") except: localStation_exception(sys.exc_info(), "initialising polarisation analyser")
print " To manually switch off scan processor, run 'scan_processing_off()' function on Jython Terminal." from gdascripts.scan.installStandardScansWithProcessing import * # @UnusedWildImport scan_processor.rootNamespaceDict = globals() import gdascripts gdascripts.scan.concurrentScanWrapper.ROOT_NAMESPACE_DICT = globals( ) # @UndefinedVariable scan_processor_normal_processes = scan_processor.processors scan_processor_empty_processes = [] def scan_processing_on(): scan_processor.processors = scan_processor_normal_processes def scan_processing_off(): scan_processor.processors = scan_processor_empty_processes print print "*" * 80 #DiffCalc print "import DIFFCALC support for I06-1" try: from startup.i06 import * # @UnusedWildImport except: localStation_exception(sys.exc_info(), "import diffcalc error.") print "===================================================================" print " End of i06-1 localStation.py"
"%s%s" % (lookup_tables_dir, "/idd_lin_ver_energy2gap.csv")) idd_lin_ver_energy = EnergyScannableLookup( 'idd_lin_ver_energy', idd_gap, idd_rowphase1, idd_rowphase2, idd_rowphase3, idd_rowphase4, idd_jawphase, pgm_energy, gap=dict(zip(idd_lin_ver_table['energy'], idd_lin_ver_table['idgap'])), rowphase1=24, rowphase2=0, rowphase3=24, rowphase4=0, jawphase_lookup=0) idd_lin_ver_energy_maximum = max(idd_lin_ver_table['energy']) idd_lin_ver_energy_minimum = min(idd_lin_ver_table['energy']) idd_lin_ver_energy_follower = SilentFollowerScannable( 'idd_lin_ver_energy_follower', followed_scannable=pgm_energy, follower_scannable=idd_lin_ver_energy, follower_tolerance=0.35) idd_lin_ver_energy.concurrentRowphaseMoves = True idd_lin_ver_energy.energyMode = True except: localStation_exception(sys.exc_info(), "initialising idd gap energy followers") print "==== idd GAP energy scannables done.==== "
''' Created on 10 Apr 2018 @author: fy65 ''' from gdascripts.pd.epics_pds import DisplayEpicsPVClass import gda from utils.ExceptionLogs import localStation_exception import sys print "-"*100 print "Creating scannables for Front End Beam Monitor - 'xbpm'" try: xbpm1_x = DisplayEpicsPVClass('xbpm1_x', 'FE10I-DI-PBPM-01:BEAMX', 'nm', '%f') xbpm1_y = DisplayEpicsPVClass('xbpm1_y', 'FE10I-DI-PBPM-01:BEAMY', 'nm', '%f') xbpm2_x = DisplayEpicsPVClass('xbpm2_x', 'FE10I-DI-PBPM-02:BEAMX', 'nm', '%f') xbpm2_y = DisplayEpicsPVClass('xbpm2_y', 'FE10I-DI-PBPM-02:BEAMY', 'nm', '%f') xbpm_anglex = DisplayEpicsPVClass('xbpm_anglex', 'FE10I-DI-BEAM-01:RM:ANGLEX', 'rad', '%f') xbpm_angley = DisplayEpicsPVClass('xbpm_angley', 'FE10I-DI-BEAM-01:RM:ANGLEY', 'rad', '%f') xbpm_anglex_urad = DisplayEpicsPVClass('xbpm_anglex_urad', 'FE10I-DI-BEAM-01:X:ANGLE', 'urad', '%f') xbpm_angley_urad = DisplayEpicsPVClass('xbpm_angley_urad', 'FE10I-DI-BEAM-01:Y:ANGLE', 'urad', '%f') xbpm=gda.device.scannable.scannablegroup.ScannableGroup('xbpm', [ xbpm1_x, xbpm1_y, xbpm2_x, xbpm2_y, xbpm_anglex, xbpm_angley, xbpm_anglex_urad, xbpm_angley_urad]) except: localStation_exception(sys.exc_info(), "initialising front end xbpm's")
''' Created on 3 Dec 2018 @author: fy65 ''' from utils.ExceptionLogs import localStation_exception, localStation_exceptions from datetime import date, datetime #undulator/pgm/energy try: pos smode idd except: localStation_exception(sys.exc_info(), "test - 'pos smode idd'") try: pos pol pc except: localStation_exception(sys.exc_info(), "test - 'pos pol pc'") try: pos energy 400 except: localStation_exception(sys.exc_info(), "test - 'pos energy 400' in 'idd' and 'pc' mode") try: pos smode idu except: localStation_exception(sys.exc_info(), "test - 'pos smode idu'") try: pos pol nc except: localStation_exception(sys.exc_info(), "test - 'pos pol nc'") try:
'checktopup_time_cv', topup_time, 5, secondsBetweenChecks=1, secondsToWaitAfterBeamBackUp=5) checktopup_time_cv.setOperatingContinuously(True) checkfe_cv = WaitForScannableState('checkfe_cv', frontend, secondsBetweenChecks=1, secondsToWaitAfterBeamBackUp=60) checkfe_cv.setOperatingContinuously(True) checkbeam_cv = ScannableGroup('checkbeam_cv', [checkrc_cv, checkfe_cv, checktopup_time_cv]) checkbeam_cv.configure() except: localStation_exception(sys.exc_info(), "creating checkbeam objects") try: print "Adding checkbeamcv device (add to cvscan to get checkbeam functionality)" from gda.device.scannable import PassthroughScannableDecorator class ZiePassthroughScannableDecorator(PassthroughScannableDecorator): def __init__(self, delegate): PassthroughScannableDecorator.__init__( self, delegate) # @UndefinedVariable def getInputNames(self): return [] def getExtraNames(self):
from scannable.continuous.FollowerScannable import SilentFollowerScannable print "-"*100 try: print "Creating idu energy and energy follower scannables for Linear Arbitrary polarisation mode:" print " 'idu_lin_arbitrary_energy', 'idu_lin_arbitrary_energy_follower', 'idu_lin_arbitrary_angle' - IDD Linear Arbitrary polarisation energy and follower, and angle" idu_lin_arbitrary_table=loadCVSTable("%s%s" % (lookup_tables_dir, "/idu_lin_arbitrary_energy.csv")) idu_lin_arbitrary_energy = EnergyScannableLinearArbitrary('idu_lin_arbitrary_energy', idu_gap, idu_rowphase1, idu_rowphase2, idu_rowphase3, idu_rowphase4, idu_jawphase, pgm_energy, 'idu_lin_arbitrary_angle', angle_min_Deg=0., angle_max_Deg=180., angle_threshold_Deg=30., energy_min_eV=612.2, energy_max_eV=1001.0, rowphase1_from_energy=dict(zip(idu_lin_arbitrary_table['energy'], idu_lin_arbitrary_table['rowphase1'])), rowphase2_from_energy=0., rowphase3_from_energy=dict(zip(idu_lin_arbitrary_table['energy'], idu_lin_arbitrary_table['rowphase3'])), rowphase4_from_energy=0., gap_from_energy=dict(zip(idu_lin_arbitrary_table['energy'], idu_lin_arbitrary_table['idgap'])), #jawphase = ( alpha_real - 120. ) / 7.5 jawphase_from_angle=Poly([-120./7.5, 1./7.5], power0first=True)) idu_lin_arbitrary_energy_maximum=max(idu_lin_arbitrary_table['energy']) idu_lin_arbitrary_energy_minimum=min(idu_lin_arbitrary_table['energy']) idu_lin_arbitrary_energy_follower = SilentFollowerScannable('idu_circ_pos_energy_follower', followed_scannable=pgm_energy, follower_scannable=idu_lin_arbitrary_energy, follower_tolerance=0.35) idu_lin_arbitrary_energy.concurrentRowphaseMoves=True idu_lin_arbitrary_energy.energyMode=True idu_lin_arbitrary_angle = PolarisationAngleScannable('idu_lin_arbitrary_angle', idu_lin_arbitrary_energy) except: localStation_exception(sys.exc_info(), "initialising idu linear arbitrary energy followers") print "==== idu Linear Arbitrary energy scannable done.==== "
idu_sepphase, pgm_grat_pitch, pgm_m2_pitch,pgm_energy from utils.ExceptionLogs import localStation_exception import sys from gda.factory import Finder try: print '-' * 80 print "Define metadata list for data collection:" iddmetadatascannables = (idd_gap, idd_rowphase1, idd_rowphase2, idd_rowphase3, idd_rowphase4, idd_jawphase, idd_sepphase) idumetadatascannables = (idu_gap, idu_rowphase1, idu_rowphase2, idu_rowphase3, idu_rowphase4, idu_jawphase, idu_sepphase) pgmmetadatascannables = (pgm_energy, pgm_grat_pitch, pgm_m2_pitch) stdmetadatascannables = iddmetadatascannables + idumetadatascannables + pgmmetadatascannables #Nexus file print "-" * 50 print "Nexus file metadata commands:" print " 'meta_add' - add a scannable or scannables to the scan metadata" print " 'meta_ll' - list the items and their values to be put into the scan metadata" print " 'meta_ls' - list only the items to be put into the scan metadata" print " 'meta_rm' - remove a scannable or scannables from the scan metadata" from metashop import * # @UnusedWildImport for each in stdmetadatascannables: meta_add(each) except: localStation_exception(sys.exc_info(), "creating metadata objects")
iFileLoader=TIFFImageLoader, fileLoadTimout=15, returnPathAsImageNumberOnly=True) pimteSMPV.display_image = True #pimteSMPV.processors=[DetectorDataProcessorWithRoi('max', pimte1det, [SumMaxPositionAndValue()], False)] pimteSMPV.processors = [ DetectorDataProcessor('max', pimte1det, [SumMaxPositionAndValue()], False) ] pimte2d = SwitchableHardwareTriggerableProcessingDetectorWrapper( 'pimte2d', pimte1det, None, pimte1det_for_snaps, panel_name=None, panel_name_rcp='Plot 1', toreplace=None, replacement=None, iFileLoader=TIFFImageLoader, fileLoadTimout=15, returnPathAsImageNumberOnly=True) pimte2d.display_image = True #pimteSMPV.processors=[DetectorDataProcessorWithRoi('max', pimte1det, [TwodGaussianPeak()], False)] pimte2d.processors = [ DetectorDataProcessor('max', pimte1det, [TwodGaussianPeak()], False) ] except: localStation_exception(sys.exc_info(), "creating pimte objects")
'idu_lin_hor3_jaw_energy', idu_gap, idu_rowphase1, idu_rowphase2, idu_rowphase3, idu_rowphase4, idu_jawphase, pgm_energy, gap=16, rowphase1=0, rowphase2=0, rowphase3=0, rowphase4=0, jawphase_lookup=dict( zip(idu_lin_hor3_jaw_table['energy'], idu_lin_hor3_jaw_table['jawphase']))) idu_lin_hor3_jaw_energy_maximum = max(idu_lin_hor3_jaw_table['energy']) idu_lin_hor3_jaw_energy_minimum = min(idu_lin_hor3_jaw_table['energy']) idu_lin_hor3_jaw_energy_follower = SilentFollowerScannable( 'idu_lin_hor3_jaw_energy_follower', followed_scannable=pgm_energy, follower_scannable=idu_lin_hor3_jaw_energy, follower_tolerance=0.35) idu_lin_hor3_jaw_energy.concurrentRowphaseMoves = True idu_lin_hor3_jaw_energy.energyMode = False #using jaw pahase (default) except: localStation_exception(sys.exc_info(), "initialising idu jawphase energy followers") print "==== idu JAW phase energy scannables done.==== "