def main(): # create logger # # python 3.5+ # home = str(pathlib.Path.home()) home = os.path.expanduser("~") logs_home = home + '/logs/' # make sure logs directory exists if not os.path.exists(logs_home): os.makedirs(logs_home) lfname = logs_home + datetime.strftime(datetime.now(), "%Y-%m-%d_%H:%M:%S") + '.log' log_lib.setup_logger(lfname) tic = time.time() aps32id_lib.update_variable_dict(variableDict) aps32id_lib.init_general_PVs(global_PVs, variableDict) FileName = global_PVs['HDF1_FileName'].get(as_string=True) nLoops = variableDict['nLoops'] # global_PVs['HDF1_NextFile'].put(0) for iLoop in range(0, nLoops): log_lib.info(' ') log_lib.info(' *** Starting step scan #%i' % (iLoop + 1)) global_PVs['Motor_SampleRot'].put(variableDict['SampleStart_Rot'], wait=True, timeout=600.0) scan_lib.tomo_step_scan(variableDict, global_PVs, FileName) dm_lib.scp(global_PVs, variableDict) log_lib.info(' ') log_lib.info(' *** Total scan time: %.2f minutes' % ((time.time() - tic) / 60.))
def main(): # create logger # # python 3.5+ # home = str(pathlib.Path.home()) home = os.path.expanduser("~") logs_home = home + '/logs/' # make sure logs directory exists if not os.path.exists(logs_home): os.makedirs(logs_home) lfname = logs_home + datetime.strftime(datetime.now(), "%Y-%m-%d_%H:%M:%S") + '.log' log_lib.setup_logger(lfname) aps32id_lib.update_variable_dict(variableDict) aps32id_lib.init_general_PVs(global_PVs, variableDict) FileName = global_PVs['TIFF1_FileName'].get(as_string=True) log_lib.info(' ') log_lib.info(' *** Starting tiff stack acq.') scan_lib.tiff_2Dscan(variableDict, global_PVs, FileName) dm_lib.scp(global_PVs, variableDict)
def main(): # create logger # # python 3.5+ # home = str(pathlib.Path.home()) home = os.path.expanduser("~") logs_home = home + '/logs/' # make sure logs directory exists if not os.path.exists(logs_home): os.makedirs(logs_home) lfname = logs_home + datetime.strftime(datetime.now(), "%Y-%m-%d_%H:%M:%S") + '.log' log_lib.setup_logger(lfname) tic = time.time() aps2bm_lib.update_variable_dict(variableDict) aps2bm_lib.init_general_PVs(global_PVs, variableDict) try: detector_sn = global_PVs['Cam1_SerialNumber'].get() if ((detector_sn == None) or (detector_sn == 'Unknown')): log_lib.error('*** The Point Grey Camera with EPICS IOC prefix %s is down' % variableDict['IOC_Prefix']) log_lib.error(' *** Failed!') else: log_lib.info('*** The Point Grey Camera with EPICS IOC prefix %s and serial number %s is on' \ % (variableDict['IOC_Prefix'], detector_sn)) # calling global_PVs['Cam1_AcquireTime'] to replace the default 'ExposureTime' with the one set in the camera variableDict['ExposureTime'] = global_PVs['Cam1_AcquireTime'].get() # calling calc_blur_pixel() to replace the default 'SlewSpeed' blur_pixel, rot_speed, scan_time = aps2bm_lib.calc_blur_pixel(global_PVs, variableDict) variableDict['SlewSpeed'] = rot_speed # start = variableDict['SleepStart'] # end = variableDict['SleepEnd'] # step_size = variableDict['SleepStep'] start = 0 end = variableDict['SleepStep'] step_size = 1 # init camera aps2bm_lib.pgInit(global_PVs, variableDict) log_lib.info(' ') log_lib.info(" *** Running %d scans" % len(np.arange(start, end, step_size))) for i in np.arange(start, end, step_size): tic_01 = time.time() fname = str('{:03}'.format(global_PVs['HDF1_FileNumber'].get())) + '_' + global_PVs['Sample_Name'].get(as_string=True) log_lib.info(' ') log_lib.info(' *** Start scan %d' % i) scan_lib.tomo_fly_scan(global_PVs, variableDict, fname) if ((i+1)!=end): log_lib.warning(' *** Wait (s): %s ' % str(variableDict['SleepTime_s'])) time.sleep(variableDict['SleepTime_s']) log_lib.info(' ') log_lib.info(' *** Data file: %s' % global_PVs['HDF1_FullFileName_RBV'].get(as_string=True)) log_lib.info(' *** Total scan time: %s minutes' % str((time.time() - tic_01)/60.)) log_lib.info(' *** Scan Done!') dm_lib.scp(global_PVs, variableDict) log_lib.info(' *** Total loop scan time: %s minutes' % str((time.time() - tic)/60.)) log_lib.info(' *** Moving rotary stage to start position') global_PVs["Motor_SampleRot"].put(0, wait=True, timeout=600.0) log_lib.info(' *** Moving rotary stage to start position: Done!') global_PVs['Cam1_ImageMode'].put('Continuous') log_lib.info(' *** Done!') except KeyError: log_lib.error(' *** Some PV assignment failed!') pass
def main(): # create logger # # python 3.5+ # home = str(pathlib.Path.home()) home = os.path.expanduser("~") logs_home = home + '/logs/' # make sure logs directory exists if not os.path.exists(logs_home): os.makedirs(logs_home) lfname = logs_home + datetime.strftime(datetime.now(), "%Y-%m-%d_%H:%M:%S") + '.log' log_lib.setup_logger(lfname) tic = time.time() aps2bm_lib.update_variable_dict(variableDict) aps2bm_lib.init_general_PVs(global_PVs, variableDict) try: detector_sn = global_PVs['Cam1_SerialNumber'].get() if ((detector_sn == None) or (detector_sn == 'Unknown')): log_lib.info( '*** The Point Grey Camera with EPICS IOC prefix %s is down' % variableDict['IOC_Prefix']) log_lib.info(' *** Failed!') else: log_lib.info('*** The Point Grey Camera with EPICS IOC prefix %s and serial number %s is on' \ % (variableDict['IOC_Prefix'], detector_sn)) # calling global_PVs['Cam1_AcquireTime'] to replace the default 'ExposureTime' with the one set in the camera variableDict['ExposureTime'] = global_PVs['Cam1_AcquireTime'].get() # calling calc_blur_pixel() to replace the default 'SlewSpeed' blur_pixel, rot_speed, scan_time = aps2bm_lib.calc_blur_pixel( global_PVs, variableDict) variableDict['SlewSpeed'] = rot_speed start_y = variableDict['StartY'] end_y = variableDict['EndY'] step_size_y = variableDict['StepSizeY'] start_x = variableDict['StartX'] end_x = variableDict['EndX'] step_size_x = variableDict['StepSizeX'] # set scan stop so also ends are included stop_x = end_x + step_size_x stop_y = end_y + step_size_y # init camera aps2bm_lib.pgInit(global_PVs, variableDict) start = variableDict['SleepStart'] end = variableDict['SleepEnd'] step_size = variableDict['SleepStep'] log_lib.info(' ') log_lib.info(" *** Running %d sleep scans" % len(np.arange(start, end, step_size))) for ii in np.arange(start, end, step_size): tic_01 = time.time() log_lib.info(' ') log_lib.info(" *** Running %d mosaic scans" % (len(np.arange(start_x, stop_x, step_size_x)) * len(np.arange(start_y, stop_y, step_size_y)))) log_lib.info(' ') log_lib.info(' *** Horizontal Positions (mm): %s' % np.arange(start_x, stop_x, step_size_x)) log_lib.info(' *** Vertical Positions (mm): %s' % np.arange(start_y, stop_y, step_size_y)) h = 0 v = 0 for i in np.arange(start_y, stop_y, step_size_y): log_lib.info(' ') log_lib.info( ' *** The sample vertical position is at %s mm' % (i)) global_PVs['Motor_SampleY'].put(i, wait=True) for j in np.arange(start_x, stop_x, step_size_x): log_lib.info( ' *** The sample horizontal position is at %s mm' % (j)) variableDict['SampleXIn'] = j fname = str('{:03}'.format( global_PVs['HDF1_FileNumber'].get( ))) + '_' + global_PVs['Sample_Name'].get( as_string=True) + '_y' + str(v) + '_x' + str(h) scan_lib.tomo_fly_scan(global_PVs, variableDict, fname) h = h + 1 dm_lib.scp(global_PVs, variableDict) log_lib.info(' ') log_lib.info(' *** Total scan time: %s minutes' % str( (time.time() - tic) / 60.)) log_lib.info(' *** Data file: %s' % global_PVs['HDF1_FullFileName_RBV'].get( as_string=True)) v = v + 1 h = 0 log_lib.info(' *** Moving rotary stage to start position') global_PVs["Motor_SampleRot"].put(0, wait=True, timeout=600.0) log_lib.info( ' *** Moving rotary stage to start position: Done!') if ((ii + 1) != end): log_lib.warning(' *** Wait (s): %s ' % str(variableDict['SleepTime'])) time.sleep(variableDict['SleepTime']) global_PVs['Cam1_ImageMode'].put('Continuous') log_lib.info(' *** Done!') except KeyError: log_lib.error(' *** Some PV assignment failed!') pass