def warmupInstrument(): """ simply runs just epics flyscan in a loop, with delays between scans. run as: RE(warmupInstrument()) to stop, simply do ctrl-C ctrol-C and then RE.abort() this should return BS to idle... reload by : %run -m warmup """ while True: try: logger.info(f"Starting '{usaxs_flyscan.busy.pvname}'") yield from bps.mv(usaxs_flyscan.busy, "Busy") logger.info(f"completed '{usaxs_flyscan.busy.pvname}'") except Exception as exc: logger.error(f"caught {exc}") yield from bps.sleep(900)
def inner(): y_signal = peaky.calculated_value x_signal = mot ps = PeakStats(x_signal.name, y_signal.name) RE.subscribe(ps) # collects data during scan # FIXME: trouble here yield from bp.scan([y_signal, calc.calculated_value], x_signal, -2, 0, 41, md=md) tbl = pyRestTable.Table() tbl.labels = "PeakStats value".split() tbl.rows = [[k, ps.__getattribute__(k)] for k in sorted("min max cen com fwhm".split())] h = db[-1] logger.info(f"scan_id={RE.md['scan_id']}") logger.info(f"uid={h.start['uid']}") logger.info(tbl) calc.reset()
""" Install a NeXus file writer for uascan raw data files See ``instrument.utils.setup_new_user.newFile()`` to replace ``instrument.framework.callbacks.newSpecFile()`` """ __all__ = [ "nxwriter", ] # from ..session_logs import logger from instrument.session_logs import logger logger.info(__file__) from .nxwriter_usaxs import NXWriterUascan from ..framework import RE, callback_db nxwriter = NXWriterUascan() callback_db['nxwriter'] = RE.subscribe(nxwriter.receiver)
def myLinkamPlan(pos_X, pos_Y, thickness, scan_title, temp1, rate1, delay1, temp2, rate2, md={}): """ collect RT USAXS/SAXS/WAXS change temperature T to temp1 with rate1 collect USAXS/SAXS/WAXS while heating when temp1 reached, hold for delay1 seconds, collecting data repeatedly change T to temp2 with rate2 collect USAXS/SAXS/WAXS while heating when temp2 reached, hold for delay2 seconds, collecting data repeatedly collect final data and it will end here... reload by # %run -m linkam """ def setSampleName(): return f"{scan_title}_{linkam.value:.0f}C_{(time.time()-t0)/60:.0f}min" def collectAllThree(debug=False): sampleMod = setSampleName() if debug: #for testing purposes, set debug=True print(sampleMod) yield from bps.sleep(20) else: md["title"] = sampleMod yield from USAXSscan(pos_X, pos_Y, thickness, sampleMod, md={}) sampleMod = setSampleName() md["title"] = sampleMod yield from SAXS(pos_X, pos_Y, thickness, sampleMod, md={}) sampleMod = setSampleName() md["title"] = sampleMod yield from WAXS(pos_X, pos_Y, thickness, sampleMod, md={}) #linkam = linkam_tc1 linkam = linkam_ci94 logger.info(f"Linkam controller PV prefix={linkam.prefix}") t0 = time.time() yield from collectAllThree() yield from bps.mv(linkam.rate, rate1) #sets the rate of next ramp yield from linkam.set_target(temp1, wait=False) #sets the temp of next ramp logger.info(f"Ramping temperature to {temp1} C") while not linkam.settled: #runs data collection until next temp yield from collectAllThree() logger.info( f"Reached temperature, now collecting data for {delay1} seconds") t1 = time.time() while time.time() - t1 < delay1: # collects data for delay1 seconds yield from collectAllThree() logger.info( f"waited for {delay1} seconds, now ramping temperature to {temp2} C") yield from bps.mv(linkam.rate, rate2) #sets the rate of next ramp yield from linkam.set_target(temp2, wait=False) #sets the temp of next ramp while not linkam.settled: #runs data collection until next temp yield from collectAllThree() logger.info(f"reached {temp2} C") yield from collectAllThree() logger.info(f"finished")
def pete(): yield from bps.null() logger.info("Pete wishes you well")
""" Turn on dynamic time in uascan. Command line:: %run -i user/uascan_dynamic_time_on.py In a command file:: run_python user/uascan_dynamic_time_on.py """ from instrument.session_logs import logger logger.info(__file__) from instrument.devices import terms terms.USAXS.useDynamicTime.put(True) logger.info("terms.USAXS.useDynamicTime = %s", terms.USAXS.useDynamicTime.get())
def fzLinkamPlan(pos_X, pos_Y, thickness, scan_title, temp1, rate1, delay1_min, temp2, rate2, md={}): """ collect RT USAXS/SAXS/WAXS change temperature T to temp1 with rate1 collect USAXS/SAXS/WAXS while heating when temp1 reached, hold for delay1 min, collecting data repeatedly change T to temp2 with rate2 collect USAXS/SAXS/WAXS while heating when temp2 reached, hold for delay2 seconds, collecting data repeatedly collect final data and it will end here... reload by # %run -m linkam """ def setSampleName(): return (f"{scan_title}" f"_{linkam.value+0.5:.0f}C" f"_{(time.time()-t0)/60:.0f}min") def collectAllThree(debug=False): sampleMod = setSampleName() if debug: #for testing purposes, set debug=True print(sampleMod) yield from bps.sleep(20) else: try: md["title"] = sampleMod yield from USAXSscan(pos_X, pos_Y, thickness, sampleMod, md={}) except Exception as exc: logger.error(exc) yield from reset_USAXS() try: sampleMod = setSampleName() md["title"] = sampleMod yield from SAXS(pos_X, pos_Y, thickness, sampleMod, md={}) except Exception as exc: logger.error(exc) try: sampleMod = setSampleName() md["title"] = sampleMod yield from WAXS(pos_X, pos_Y, thickness, sampleMod, md={}) except Exception as exc: logger.error(exc) summary = ( "Linkam USAXS/SAXS/WAXS heating sequence\n" f"fzLinkamPlan(pos_X={pos_X}, pos_Y={pos_Y},thickness={thickness}," f"sample_name={scan_title}, temp1={temp1},rate1={rate1})" f"delay1_min={delay1_min}, temp2={temp2},rate2={rate2})") instrument_archive(summary) # Linkam device choice linkam = linkam_tc1 # Linkam T96, 600, 1500V, 350V #linkam = linkam_ci94 # Linkam 1500 using old controller. logger.info(f"Linkam controller PV prefix={linkam.prefix}") # this runs start of scan code... yield from before_command_list(md={}) # go to 40C and measure all data there as baseline... yield from bps.mv(linkam.rate, 50) #sets the rate of next ramp yield from linkam.set_target(40, wait=True) #sets the temp of next ramp t0 = time.time() yield from collectAllThree() #yield from mode_USAXS() # here is start of heating rmap up. yield from bps.mv(linkam.rate, rate1) #sets the rate of next ramp yield from linkam.set_target(temp1, wait=True) #sets the temp of next ramp logger.info(f"Ramping temperature to {temp1} C") #enable is want to collect data as heating up... #while not linkam.settled: #runs data collection until next temp # yield from collectAllThree() #at temperature stuff goes here... logger.info( f"Reached temperature, now collecting data for {delay1_min} minutes") t1 = time.time() t0 = time.time() # this is main loop where we collect data at temeprature. while time.time( ) - t1 < delay1_min * 60: # collects data for delay1 seconds yield from collectAllThree() logger.info( f"waited for {delay1_min} min, now changing temperature to {temp2} C") #done with main loop, we will cool next. t0 = time.time() yield from bps.mv(linkam.rate, rate2) #sets the rate of next ramp yield from linkam.set_target(temp2, wait=False) #sets the temp of next ramp # collecting data on cooling while not linkam.settled: #runs data collection until next temp yield from collectAllThree() logger.info(f"reached {temp2} C") #cooling finished, get one more data set at final temperature. yield from collectAllThree() # run endof scan code. yield from after_command_list() # done... logger.info(f"finished")
def jamesLinkamPlan( pos_X, pos_Y, thickness, scan_title, md={}): """ collect RT USAXS/SAXS/WAXS change temperature T to temp1 with rate1 collect USAXS/SAXS/WAXS while heating reload by # %run -i -m linkam """ def myTitleFunction(title): return f"{title}_{linkam.value:.0f}C_{(time.time()-t1)/60:.0f}min" def collectAllThree(debug=False): if debug: #for testing purposes, set debug=True sampleMod = myTitleFunction(scan_title) print(sampleMod) yield from bps.sleep(20) else: yield from USAXSscan(pos_X, pos_Y, thickness, scan_title, md={}) yield from SAXS(pos_X, pos_Y, thickness, scan_title, md={}) yield from WAXS(pos_X, pos_Y, thickness, scan_title, md={}) summary = ( "Linkam USAXS/SAXS/WAXS heating sequence\n" f"james_LinkamPlan(pos_X={pos_X}, pos_Y={pos_Y},thickness={thickness}," f"sample_name={scan_title}" ) instrument_archive(summary) setSampleTitleFunction(myTitleFunction) yield from sync_order_numbers() # resync order numbers since we run only SAXs above. # Linkam device choice #linkam = linkam_tc1 # Linkam T96, 600, 1500V, 350V linkam = linkam_ci94 # Linkam 1500 using old controller. logger.info(f"Linkam controller PV prefix={linkam.prefix}") # this runs start of scan code... yield from before_command_list(md={}) # Room temp measurement 30C t0 = time.time() t1 = time.time() yield from bps.mv(linkam.rate, 150) #sets the rate of next ramp yield from linkam.set_target(30, wait=False) #sets the temp of next ramp #TODO here: start Linkam somehow, if it is off, it stays off... yield from collectAllThree() # Heat to 400 @150C/min. Measure at 400C one USAXS/SAXS/WAXS. logger.info(f"Ramping temperature to {400} C") yield from bps.mv(linkam.rate, 150) # sets the rate of next ramp yield from linkam.set_target(400, wait=False) # sets the temp of next ramp yield from preUSAXStune() while not linkam.settled: # runs data collection until next temp yield from bps.sleep(2) # sleep until settled t0 = time.time() t1 = time.time() yield from collectAllThree() #measure at 400C # “Resetting the sample” from initial condition, precipitation of fine gamma-prime # Heat to 1060C at 10C/min. Recording SAXS/WAXS/USAXS [60 minutes] yield from bps.mv(linkam.rate, 10) # sets the rate of next ramp yield from linkam.set_target(1170, wait=False) # temp measuremnt t0 = time.time() t1 = time.time() logger.info(f"Ramping temperature to {1170} C") while not linkam.settled: #runs data collection until next temp yield from collectAllThree() # Hold at 1060C for 30min. Recording SAXS only [30 minutes] logger.info(f"Hold at temperature {1170} C") t0 = time.time() t1 = time.time() while time.time()-t0 < 30*60 : # collects data for 30 minutes yield from SAXS(pos_X, pos_Y, thickness, scan_title, md={}) yield from sync_order_numbers() # resync order numbers since we run only SAXs above. # Cool to 400C at 20C/min. Recording SAXS only [30 minutes] yield from bps.mv(linkam.rate, 20) # sets the rate of next ramp yield from linkam.set_target(400, wait=False) # temp measuremnt t0 = time.time() t1 = time.time() logger.info(f"Cooling temperature to {400} C") while not linkam.settled: #runs data collection until next temp yield from SAXS(pos_X, pos_Y, thickness, scan_title, md={}) yield from sync_order_numbers() # resync order numbers since we run only SAXs above. # USAXS/SAXS/WAXS one measurement at 400C yield from collectAllThree() # Coarsening kinetics # Heat to 750C at 10C/min. Recording USAXS/SAXS/WAXS [30 minutes] yield from bps.mv(linkam.rate, 10) # sets the rate of next ramp yield from linkam.set_target(772, wait=False) # temp measuremnt t0 = time.time() t1 = time.time() logger.info(f"Ramping temperature to {750} C") while not linkam.settled: #runs data collection until next temp yield from collectAllThree() # Hold at 750 C for 5 hours, USAXS/SAXS/WAXS [300 minutes] logger.info(f"Hold at temperature {750} C") t0 = time.time() t1 = time.time() while time.time()-t0 < 5*60*60 : # collects data for 5 hours minutes yield from collectAllThree() # Heat to 1060C at 10C/min. Recording USAXS/SAXS/WAXS [30 minutes] yield from bps.mv(linkam.rate, 10) # sets the rate of next ramp yield from linkam.set_target(1170, wait=False) # temp measuremnt t0 = time.time() t1 = time.time() logger.info(f"Ramping temperature to {1170} C") while not linkam.settled: #runs data collection until next temp yield from collectAllThree() # Hold at 1060C for 30mins. Recording SAXS only [30 minutes] logger.info(f"Hold at temperature {1170} C") t0 = time.time() t1 = time.time() while time.time()-t0 < 30*60 : # collects data for 30 minutes yield from SAXS(pos_X, pos_Y, thickness, scan_title, md={}) yield from sync_order_numbers() # resync order numbers since we run only SAXs above. # Cool to 400C at 20C/min. Recording USAXS only [30 minutes] yield from bps.mv(linkam.rate, 20) # sets the rate of next ramp yield from linkam.set_target(400, wait=False) # temp measuremnt t0 = time.time() t1 = time.time() logger.info(f"Cooling temperature to {400} C") while not linkam.settled: #runs data collection until next temp yield from USAXSscan(pos_X, pos_Y, thickness, scan_title, md={}) yield from sync_order_numbers() # resync order numbers since we run only SAXs above. # Heat to 850C at 10C/min. Recording USAXS/SAXS/WAXS [40 minutes] yield from bps.mv(linkam.rate, 10) # sets the rate of next ramp yield from linkam.set_target(889, wait=False) # temp measuremnt t0 = time.time() t1 = time.time() logger.info(f"Ramping temperature to {850} C") while not linkam.settled: #runs data collection until next temp yield from collectAllThree() # Hold at 850 C for 4 hours, USAXS/SAXS/WAXS [240 minutes] logger.info(f"Hold at temperature {850} C") t0 = time.time() t1 = time.time() while time.time()-t0 < 4*60*60 : # collects data for 5 hours minutes yield from collectAllThree() # Cool to 400C at 20C/min. Recording SAXS only [20 minutes] yield from bps.mv(linkam.rate, 20) # sets the rate of next ramp yield from linkam.set_target(400, wait=False) # temp measuremnt t0 = time.time() t1 = time.time() logger.info(f"Cooling temperature to {400} C") while not linkam.settled: #runs data collection until next temp yield from SAXS(pos_X, pos_Y, thickness, scan_title, md={}) yield from sync_order_numbers() # resync order numbers since we run only SAXs above. # Cool to RT at 150C/min. yield from bps.mv(linkam.rate, 150) # sets the rate of next ramp yield from linkam.set_target(40, wait=False) # temp measuremnt #done with main loop, we will cool next. t0 = time.time() t1 = time.time() # collecting data on cooling while not linkam.settled: #runs data collection until next temp yield from collectAllThree() logger.info(f"reached {40} C") #cooling finished, get one more data set at final temperature. yield from collectAllThree() # run endof scan code. yield from after_command_list() resetSampleTitleFunction() # done... logger.info(f"finished")
def jamesLinkamPlan( pos_X, pos_Y, thickness, scan_title, md={}): """ collect RT USAXS/SAXS/WAXS change temperature T to temp1 with rate1 collect USAXS/SAXS/WAXS while heating reload by # %run -i -m linkam """ def myTitleFunction(title): return f"{title}_{linkam.value:.0f}C_{(time.time()-t1)/60:.0f}min" def collectAllThree(debug=False): if debug: #for testing purposes, set debug=True sampleMod = myTitleFunction(scan_title) print(sampleMod) yield from bps.sleep(20) else: yield from USAXSscan(pos_X, pos_Y, thickness, scan_title, md={}) yield from SAXS(pos_X, pos_Y, thickness, scan_title, md={}) yield from WAXS(pos_X, pos_Y, thickness, scan_title, md={}) summary = ( "Linkam USAXS/SAXS/WAXS heating sequence\n" f"james_LinkamPlan(pos_X={pos_X}, pos_Y={pos_Y},thickness={thickness}," f"sample_name={scan_title}" ) instrument_archive(summary) setSampleTitleFunction(myTitleFunction) yield from sync_order_numbers() # resync order numbers since we run only SAXs above. # Linkam device choice #linkam = linkam_tc1 # Linkam T96, 600, 1500V, 350V linkam = linkam_ci94 # Linkam 1500 using old controller. logger.info(f"Linkam controller PV prefix={linkam.prefix}") # this runs start of scan code... yield from before_command_list(md={}) # Room temp measurement 30C t0 = time.time() t1 = time.time() yield from bps.mv(linkam.rate, 150) #sets the rate of next ramp yield from linkam.set_target(30, wait=False) #sets the temp of next ramp #TODO here: start Linkam somehow, if it is off, it stays off... yield from collectAllThree() #yield from mode_USAXS() # Heat to 560C @150C/min. Measure at 550C one USAXS/SAXS/WAXS. logger.info(f"Ramping temperature to {566} C") yield from bps.mv(linkam.rate, 150) #sets the rate of next ramp yield from linkam.set_target(566, wait=False) #sets the temp of next ramp while not linkam.settled: #runs data collection until next temp yield from bps.sleep(2) # sleep until settled t0 = time.time() t1 = time.time() yield from collectAllThree() #measure at 250C # Heat to 1060C @ 150C/min with 1 USAXS/SAXS/WAXS measurement, then wait to achieve temp # Hold at 1060C/20 minutes (solutionize). Measure USAXS/SAXS/WAXS yield from bps.mv(linkam.rate, 150) #sets the rate of next ramp yield from linkam.set_target(1170, wait=False) # temp measuremnt t1 = time.time() logger.info(f"Ramping temperature to {1170} C") yield from collectAllThree() #measure on heating while not linkam.settled: #runs data collection until next temp yield from bps.sleep(2) # sleep until settled t0 = time.time() t1 = time.time() # this is solutionize. logger.info(f"Solutionize at temperature {1170} C") while time.time()-t0 < 20*60 : # collects data for 20 minutes yield from collectAllThree() #done with solutionize # Cool at 20 C/min to 566C, with continuous in-situ SAXS ONLY yield from bps.mv(linkam.rate, 20) # sets the rate of next ramp yield from linkam.set_target(566, wait=False) # temp measuremnt t1 = time.time() logger.info(f"Cooling at 20deg/C temperature to {566} C") while not linkam.settled: #runs data collection until next temp yield from SAXS(pos_X, pos_Y, thickness, scan_title, md={}) yield from sync_order_numbers() # resync order numbers since we run only SAXs above. yield from collectAllThree() for rate in (20, 10, 5, 2): # Heat to 1060C @ 150C/min with 1 USAXS/SAXS/WAXS measurement, then wait to achieve temp # Hold at 1060C/20 minutes (solutionize). Measure USAXS/SAXS/WAXS yield from bps.mv(linkam.rate, 150) # sets the rate of next ramp yield from linkam.set_target(1170, wait=False) # set temperature t1 = time.time() logger.info(f"Ramping temperature to {1170} C") yield from collectAllThree() # measure while ramping to 1060C while not linkam.settled: # runs data collection until next temp yield from bps.sleep(2) # sleep until settled t0 = time.time() t1 = time.time() # this is solutionize. logger.info(f"Solutionize at temperature {1170} C") while time.time()-t0 < 20*60 : # collects data for 20 minutes yield from collectAllThree() # Cool at rate C/min to 560C, with continuous data collection yield from bps.mv(linkam.rate, rate) # sets the rate of next ramp yield from linkam.set_target(566, wait=False) # temp measuremnt t1 = time.time() logger.info(f"Cooling at {rate} deg/C temperature to {566} C") while not linkam.settled: # runs data collection until next temp yield from collectAllThree() yield from collectAllThree() # last scan at 560C #now the annealing at different tremperatuers for temp in (772, 830, 889, 950): # Heat to 1060C @ 150C/min with 1 USAXS/SAXS/WAXS measurement, then wait to achieve temp # Hold at 1060C/20 minutes (solutionize). Measure USAXS/SAXS/WAXS yield from bps.mv(linkam.rate, 150) # sets the rate of next ramp yield from linkam.set_target(1170, wait=False) # set temperature t1 = time.time() logger.info(f"Ramping temperature to {1170} C") yield from collectAllThree() # measure while ramping to 1060C while not linkam.settled: # runs data collection until next temp yield from bps.sleep(2) # sleep until settled t0 = time.time() t1 = time.time() # this is solutionize. logger.info(f"Solutionize at temperature {1170} C") while time.time()-t0 < 20*60 : # collects data for 20 minutes yield from collectAllThree() # Cool at 20 C/min to 560C, with continuous data collection yield from bps.mv(linkam.rate, 20) # sets the rate of next ramp yield from linkam.set_target(566, wait=False) # temp measuremnt t1 = time.time() logger.info(f"Cooling at {20} deg/C temperature to {566} C") while not linkam.settled: # runs data collection until next temp yield from collectAllThree() yield from collectAllThree() # last scan at 560C ## one temp block... yield from bps.mv(linkam.rate, 150) #sets the rate of next ramp yield from linkam.set_target(temp, wait=False) # temp measuremnt t1 = time.time() logger.info(f"Ramping temperature to {temp} C") while not linkam.settled: #runs data collection until next temp yield from bps.sleep(2) # sleep until settled t0 = time.time() t1 = time.time() # this is main loop where we collect data at temperature temp. while time.time()-t0 < 2*60*60 : # collects data for 2 hours yield from collectAllThree() #done with main loop, we will cool next. t0 = time.time() t1 = time.time() yield from linkam.set_target(50, wait=False) #sets the temp of next ramp # collecting data on cooling while not linkam.settled: #runs data collection until next temp yield from collectAllThree() logger.info(f"reached {50} C") #cooling finished, get one more data set at final temperature. yield from collectAllThree() # run endof scan code. yield from after_command_list() resetSampleTitleFunction() # done... logger.info(f"finished")