Пример #1
0
def test_jet_detect():
    port_names = {'ROI_port': 'ROI1',
                  'ROI_stats_port': 'Stats1',
                  'ROI_image_port': 'IMAGE1'}
    SC1_questar = devices.Questar(**port_names,
                                  prefix='CXI:SC1:INLINE',
                                  name='SC1_questar')

    return cam_utils.jet_detect(SC1_questar.image.image)
Пример #2
0
def test_get_jet_roll():
    camroll_pxsize, imgs = test_get_camroll_pxsize()
    params = {'cam_roll': camroll_pxsize[0]}
  
    port_names = {'ROI_port': 'ROI1',
                  'ROI_stats_port': 'Stats1',
                  'ROI_image_port': 'IMAGE1'}
    SC1_questar = devices.Questar(**port_names,
                                  prefix='CXI:SC1:INLINE',
                                  name='SC1_questar')
    rho, theta = cam_utils.jet_detect(SC1_questar.image.image)
    
    return cam_utils.get_jet_roll(theta, params)
Пример #3
0
def calibrate(injector, camera, params):
    '''
    Calibrate the camera 

    Parameters
    ----------
    injector : Injector
        sample injector
    camera : Questar
        camera looking at sample jet and x-rays
    params : Parameters
        EPICS PVs used for recording jet tracking data
    '''
    from time import sleep
    from cxi import cam_utils

    # find jet in camera ROI
    ROI_image = get_burst_avg(20, camera.ROI_image)
    rho, theta = cam_utils.jet_detect(ROI_image)

    # collect images and motor positions to calculate pxsize and cam_roll
    imgs = []
    positions = []
    start_pos = injector.coarseX.get()
    for i in range(2):
        image = get_burst_avg(20, camera.image)
        imgs.append(image)
        positions.append(injector.coarseX.get())
        injector.coarseX.put(injector.coarseX.get() - 0.1)
        sleep(3)
    injector.coarseX.put(start_pos)
    sleep(3)

    cam_roll, pxsize = cam_utils.get_cam_roll_pxsize(imgs, positions)
    params.pxsize.put(pxsize)
    params.cam_roll.put(cam_roll)

    beamX_px = params.beam_x_px.get()
    beamY_px = params.beam_y_px.get()
    camX, camY = cam_utils.get_cam_coords(beamX_px, beamY_px, params)
    params.cam_x.put(camX)
    params.cam_y.put(camY)

    jet_roll = cam_utils.get_jet_roll(theta, params)
    params.jet_roll.put(jet_roll)

    return
Пример #4
0
def jet_calculate(camera, params):
    '''
    Track the sample jet and calculate the distance to the x-ray beam

    Parameters
    ----------
    injector : Injector
        sample injector
    camera : Questar
        camera looking at the sample jet and x-ray beam
    params : Parameters
        EPICS PVs used for recording jet tracking data
    '''
    from cxi import cam_utils

    # track jet position
    print('Running...')
    while True:
        try:
            # detect the jet in the camera ROI
            ROI_image = get_burst_avg(20, camera.ROI_image)
            rho, theta = cam_utils.jet_detect(ROI_image)

            # update x-ray beam position
            beamX_px = params.beam_x_px.get()
            beamY_px = params.beam_y_px.get()
            camX, camY = cam_utils.get_cam_coords(beamX_px, beamY_px, params)
            params.cam_x.put(camX)
            params.cam_y.put(camY)

            # find distance from jet to x-rays
            ROIx = camera.ROI.min_xyz.min_x.get()
            ROIy = camera.ROI.min_xyz.min_y.get()
            jetX = cam_utils.get_jet_x(rho, theta, ROIx, ROIy, params)
            params.jet_x.put(jetX)
        except KeyboardInterrupt:
            print('Stopped.')
            return
Пример #5
0
def test_get_jet_x():
    port_names = {'ROI_port': 'ROI1',
                  'ROI_stats_port': 'Stats1',
                  'ROI_image_port': 'IMAGE1'}
    SC1_questar = devices.Questar(**port_names,
                                  prefix='CXI:SC1:INLINE',
                                  name='SC1_questar')
    rho, theta = cam_utils.jet_detect(SC1_questar.image.image)
    
    camroll_pxsize, imgs = test_get_camroll_pxsize()
    cam_y, cam_x = test_get_cam_coords()

    params = {'cam_roll': camroll_pxsize[0],
              'pxsize': camroll_pxsize[1],
              'cam_x': cam_x,
              'cam_y': cam_y}
    '''
    NEED BEAM_X, BEAM_Y
    return cam_utils.get_jet_x(rho, theta,
                               SC1_questar.ROI,
                               SC1_questar.ROI,
                               params) '''
    return 0