Exemple #1
0
def fly_scan(params):

    tic =  time.time()
    global_PVs = aps2bm.init_general_PVs(params)
    aps2bm.user_info_params_update_from_pv(global_PVs, params)

    try: 
        detector_sn = global_PVs['Cam1_SerialNumber'].get()
        if ((detector_sn == None) or (detector_sn == 'Unknown')):
            log.info('*** The Point Grey Camera with EPICS IOC prefix %s is down' % params.camera_ioc_prefix)
            log.info('  *** Failed!')
        else:
            log.info('*** The Point Grey Camera with EPICS IOC prefix %s and serial number %s is on' \
                        % (params.camera_ioc_prefix, detector_sn))
            
            # calling global_PVs['Cam1_AcquireTime'] to replace the default 'ExposureTime' with the one set in the camera
            params.exposure_time = global_PVs['Cam1_AcquireTime'].get()
            # calling calc_blur_pixel() to replace the default 'SlewSpeed' 
            rot_speed = calc_blur_pixel(global_PVs, params)
            params.slew_speed = rot_speed

            # init camera
            flir.init(global_PVs, params)

            log.info(' ')
            log.info("  *** Running %d sleep scans" % params.sleep_steps)
            for i in np.arange(0, params.sleep_steps, 1):
                tic_01 =  time.time()
                # set sample file name
                #fname = str('{:03}'.format(global_PVs['HDF1_FileNumber'].get())) + '_' + global_PVs['Sample_Name'].get(as_string=True)
                params.scan_counter = global_PVs['HDF1_FileNumber'].get()
                params.file_path = global_PVs['HDF1_FilePath'].get(as_string=True)
                params.file_name = str('{:03}'.format(global_PVs['HDF1_FileNumber'].get())) + '_' + global_PVs['Sample_Name'].get(as_string=True)
                log.info(' ')
                log.info('  *** Start scan %d/%d' % (i, (params.sleep_steps -1)))
                tomo_fly_scan(global_PVs, params)
                if ((i+1)!= params.sleep_steps):
                    log.warning('  *** Wait (s): %s ' % str(params.sleep_time))
                    time.sleep(params.sleep_time) 

                log.info(' ')
                log.info('  *** Data file: %s' % global_PVs['HDF1_FullFileName_RBV'].get(as_string=True))
                log.info('  *** Total scan time: %s minutes' % str((time.time() - tic_01)/60.))
                log.info('  *** Scan Done!')
    
                dm.scp(global_PVs, params)

            log.info('  *** Total loop scan time: %s minutes' % str((time.time() - tic)/60.))
 
            log.info('  *** Moving rotary stage to start position')
            global_PVs["Motor_SampleRot"].put(params.sample_rotation_start, wait=True, timeout=600.0)
            log.info('  *** Moving rotary stage to start position: Done!')

            global_PVs['Cam1_ImageMode'].put('Continuous')
 
            log.info('  *** Done!')

    except  KeyError:
        log.error('  *** Some PV assignment failed!')
        pass
Exemple #2
0
def stop_scan(global_PVs, params):
        log.info(' ')
        log.error('  *** Stopping the scan: PLEASE WAIT')
        global_PVs['Motor_SampleRot_Stop'].put(1)
        global_PVs['HDF1_Capture'].put(0)
        aps2bm.wait_pv(global_PVs['HDF1_Capture'], 0)
        flir.init(global_PVs, params)
        log.error('  *** Stopping scan: Done!')
Exemple #3
0
def adjust(params):

    global_PVs = aps2bm.init_general_PVs(params)

    params.file_name = None  # so we don't run the flir._setup_hdf_writer

    try:
        detector_sn = global_PVs['Cam1_SerialNumber'].get()
        if ((detector_sn == None) or (detector_sn == 'Unknown')):
            log.info(
                '*** The Point Grey Camera with EPICS IOC prefix %s is down' %
                params.camera_ioc_prefix)
            log.info('  *** Failed!')
        else:
            log.info('*** The Point Grey Camera with EPICS IOC prefix %s and serial number %s is on' \
                        % (params.camera_ioc_prefix, detector_sn))

            flir.init(global_PVs, params)
            flir.set(global_PVs, params)

            dark_field, white_field = flir.take_dark_and_white(
                global_PVs, params)

            if (params.resolution == True):
                find_resolution(params,
                                dark_field,
                                white_field,
                                angle_shift=-0.7)

            if (params.image_resolution == None):
                log.error(
                    '  *** Detector resolution is not determined. Please run tomo adjust --resolution first!'
                )
                exit()
            else:
                if (params.focus == True):
                    adjust_focus(params)
                if (params.center == True):
                    adjust_center(params, dark_field, white_field)
                if (params.roll == True):
                    adjust_roll(params,
                                dark_field,
                                white_field,
                                angle_shift=-0.7)
                if (params.pitch == True):
                    adjust_pitch(params,
                                 dark_field,
                                 white_field,
                                 angle_shift=-0.7)
                if (params.roll == True or params.pitch == True):
                    # align center again for higher accuracy
                    adjust_center(params, dark_field, white_field)

                config.update_sphere(params)

    except KeyError:
        log.error('  *** Some PV assignment failed!')
        pass
Exemple #4
0
def fly_scan_mosaic(params):

    tic =  time.time()
    global_PVs = aps2bm.init_general_PVs(params)
    aps2bm.user_info_params_update_from_pv(global_PVs, params)

    try: 
        detector_sn = global_PVs['Cam1_SerialNumber'].get()
        if ((detector_sn == None) or (detector_sn == 'Unknown')):
            log.info('*** The Point Grey Camera with EPICS IOC prefix %s is down' % params.camera_ioc_prefix)
            log.info('  *** Failed!')
        else:
            log.info('*** The Point Grey Camera with EPICS IOC prefix %s and serial number %s is on' \
                        % (params.camera_ioc_prefix, detector_sn))
            
            # calling global_PVs['Cam1_AcquireTime'] to replace the default 'ExposureTime' with the one set in the camera
            params.exposure_time = global_PVs['Cam1_AcquireTime'].get()
            # calling calc_blur_pixel() to replace the default 'SlewSpeed' 
            rot_speed = calc_blur_pixel(global_PVs, params)
            params.slew_speed = rot_speed

            start_y = params.vertical_scan_start
            end_y = params.vertical_scan_end
            step_size_y = params.vertical_scan_step_size


            start_x = params.horizontal_scan_start
            end_x = params.horizontal_scan_end
            step_size_x = params.horizontal_scan_step_size

            # set scan stop so also ends are included
            stop_x = end_x + step_size_x
            stop_y = end_y + step_size_y

            # init camera
            flir.init(global_PVs, params)

            log.info(' ')
            log.info("  *** Running %d sleep scans" % params.sleep_steps)
            for ii in np.arange(0, params.sleep_steps, 1):
                tic_01 =  time.time()

                log.info(' ')
                log.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.info(' ')
                log.info('  *** Horizontal Positions (mm): %s' % np.arange(start_x, stop_x, step_size_x))
                log.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.info(' ')
                    log.error('  *** 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.error('  *** The sample horizontal position is at %s mm' % (j))
                        params.sample_in_position = j
                        params.scan_counter = global_PVs['HDF1_FileNumber'].get()
                        # set sample file name
                        params.file_path = global_PVs['HDF1_FilePath'].get(as_string=True)
                        params.file_name = str('{:03}'.format(global_PVs['HDF1_FileNumber'].get())) + '_' + global_PVs['Sample_Name'].get(as_string=True) + '_y' + str(v) + '_x' + str(h)
                        tomo_fly_scan(global_PVs, params)
                        h = h + 1
                        dm.scp(global_PVs, params)
                    log.info(' ')
                    log.info('  *** Total scan time: %s minutes' % str((time.time() - tic)/60.))
                    log.info('  *** Data file: %s' % global_PVs['HDF1_FullFileName_RBV'].get(as_string=True))
                    v = v + 1
                    h = 0

                log.info('  *** Moving vertical stage to start position')
                global_PVs['Motor_SampleY'].put(start_y, wait=True, timeout=1000.0)

                log.info('  *** Moving horizontal stage to start position')
                global_PVs['Motor_SampleX'].put(start_x, wait=True, timeout=1000.0)

                log.info('  *** Moving rotary stage to start position')
                global_PVs["Motor_SampleRot"].put(params.sample_rotation_start, wait=True, timeout=600.0)
                log.info('  *** Moving rotary stage to start position: Done!')

                if ((ii+1)!=params.sleep_steps):
                    log.warning('  *** Wait (s): %s ' % str(params.sleep_time))
                    time.sleep(params.sleep_time) 

                global_PVs['Cam1_ImageMode'].put('Continuous')

                log.info('  *** Done!')

    except  KeyError:
        log.error('  *** Some PV assignment failed!')
        pass