Exemple #1
0
    def initialize(self, cxn, context, ident):
        p = self.parameters.IonsOnCamera
        #print int(p.ion_number)
        self.fitter = ion_state_detector(int(p.ion_number))
        self.ident = ident
        self.camera = cxn.andor_server
        self.pulser = cxn.pulser
        self.pv = cxn.parametervault

        #self.oven_control = cxn.agilent_e3633a

        repetitions = self.parameters.IonsAutoLoad.repetition_ion_detection
        self.pv.set_parameter('StateReadout', 'repeat_each_measurement',
                              repetitions)

        self.image_region = image_region = [
            int(p.horizontal_bin),
            int(p.vertical_bin),
            int(p.horizontal_min),
            int(p.horizontal_max),
            int(p.vertical_min),
            int(p.vertical_max),
        ]
        self.camera.abort_acquisition()
        self.initial_exposure = self.camera.get_exposure_time()
        self.parameters.StateReadout.state_readout_duration = self.parameters.StateReadout.camera_readout_duration
        self.camera.set_exposure_time(
            self.parameters.StateReadout.state_readout_duration)
        self.initial_region = self.camera.get_image_region()
        self.initial_mode = self.camera.get_acquisition_mode()
        self.initial_trigger_mode = self.camera.get_trigger_mode()

        self.camera.set_acquisition_mode('Kinetics')
        self.camera.set_image_region(*image_region)
        self.camera.set_trigger_mode('External')
        #self.camera.set_trigger_mode
        self.exposures = int(p.reference_exposure_factor) * int(
            self.parameters.StateReadout.repeat_each_measurement)
        self.camera.set_number_kinetics(self.exposures)
        #generate the pulse sequence
        self.parameters.StateReadout.use_camera_for_readout = True
        start_time = WithUnit(
            20, 'ms'
        )  #do nothing in the beginning to let the camera transfer each image
        self.sequence = pulse_sequence(self.parameters, start=start_time)
        self.sequence.required_subsequences = [state_readout, turn_off_all]
        self.sequence.addSequence(turn_off_all)
        self.sequence.addSequence(state_readout)
    def initialize(self, cxn, context, ident):
        p = self.parameters.IonsOnCamera
        #print int(p.ion_number)
        self.fitter = ion_state_detector(int(p.ion_number))
        self.ident = ident
        self.camera = cxn.andor_server
        self.pulser = cxn.pulser
        self.pv = cxn.parametervault

        self.oven_control = cxn.agilent_e3633a

        repetitions = self.parameters.IonsAutoLoad.repetition_ion_detection
        self.pv.set_parameter('StateReadout','repeat_each_measurement', repetitions)

        self.image_region = image_region = [
                             int(p.horizontal_bin),
                             int(p.vertical_bin),
                             int(p.horizontal_min),
                             int(p.horizontal_max),
                             int(p.vertical_min),
                             int(p.vertical_max),
                             ]
        self.camera.abort_acquisition()
        self.initial_exposure = self.camera.get_exposure_time()
        self.parameters.StateReadout.state_readout_duration = self.parameters.StateReadout.camera_readout_duration
        self.camera.set_exposure_time(self.parameters.StateReadout.state_readout_duration)
        self.initial_region = self.camera.get_image_region()
        self.initial_mode = self.camera.get_acquisition_mode()
        self.initial_trigger_mode = self.camera.get_trigger_mode()
        
        
        self.camera.set_acquisition_mode('Kinetics')
        self.camera.set_image_region(*image_region)
        self.camera.set_trigger_mode('External')
        #self.camera.set_trigger_mode
        self.exposures = int(p.reference_exposure_factor) * int(self.parameters.StateReadout.repeat_each_measurement)
        self.camera.set_number_kinetics(self.exposures)
        #generate the pulse sequence
        self.parameters.StateReadout.use_camera_for_readout = True
        start_time = WithUnit(20, 'ms') #do nothing in the beginning to let the camera transfer each image
        self.sequence = pulse_sequence(self.parameters, start = start_time)
        self.sequence.required_subsequences = [state_readout, turn_off_all]
        self.sequence.addSequence(turn_off_all)
        self.sequence.addSequence(state_readout)
Exemple #3
0
#load the full image and truncate it to to test image procesing of a partial image
# image = np.load('single.npy')

image = np.load('chain.npy')
image = np.reshape(image, (496, 658))
image = image[242:255, 310:390]

x_axis = np.arange(310,390)
y_axis = np.arange(242,255)
xx,yy = np.meshgrid(x_axis, y_axis)


shaped_image = image.reshape((1,13,80))
series_of_images = np.repeat(shaped_image, 1, axis = 0)

detector = ion_state_detector(8)
result, params = detector.guess_parameters_and_fit(xx, yy, image)

detector.report(params)
detector.graph(x_axis, y_axis, image, params, result)


best_states, confidences = detector.state_detection(image)
excitation_probability = 1 - best_states.mean(axis = 0)
print excitation_probability, confidences

left_ion_dark_image = np.array(image)
left_ion_dark_image[:,0:10] = 793
detector.graph(x_axis, y_axis, left_ion_dark_image, params, result)
best_states, confidences = detector.state_detection(left_ion_dark_image)
excitation_probability = 1 - best_states.mean(axis = 0)
Exemple #4
0
# image = np.load('single.npy')

image = np.load('chain.npy')
image = np.reshape(image, (496, 658))
image = image[242:255, 310:390]
print image.min(), image.max()

x_axis = np.arange(310,390)
y_axis = np.arange(242,255)
xx,yy = np.meshgrid(x_axis, y_axis)


shaped_image = image.reshape((1,13,80))
series_of_images = np.repeat(shaped_image, 1, axis = 0)

detector = ion_state_detector(8)
result, params = detector.guess_parameters_and_fit(xx, yy, image)

detector.report(params)
detector.graph(x_axis, y_axis, image, params, result)


best_states, confidences = detector.state_detection(image)
excitation_probability = 1 - best_states.mean(axis = 0)
print excitation_probability, confidences

left_ion_dark_image = np.array(image)
left_ion_dark_image[:,0:10] = 793
print left_ion_dark_image.min()
detector.graph(x_axis, y_axis, left_ion_dark_image, params, result)
best_states, confidences = detector.state_detection(left_ion_dark_image)
Exemple #5
0
def camera_ion_probabilities(images, repetitions, p, readout_mode = 'camera'):
    """
    Method for analyzing camera images. For an
    N-ion chain, returns an N element list
    indicating the probability that each
    ion is excited.
    """
    from lmfit import Parameters as lmfit_Parameters
    
    fitter = ion_state_detector(int(p.ion_number))

    image_region = [
                             int(p.horizontal_bin),
                             int(p.vertical_bin),
                             int(p.horizontal_min),
                             int(p.horizontal_max),
                             int(p.vertical_min),
                             int(p.vertical_max),
                             ]
    
    fit_parameters = lmfit_Parameters()
    fit_parameters.add('ion_number', value = int(p.ion_number))
    fit_parameters.add('background_level', value = p.fit_background_level)
    fit_parameters.add('amplitude', value = p.fit_amplitude)
    fit_parameters.add('rotation_angle', p.fit_rotation_angle)
    fit_parameters.add('center_x', value = p.fit_center_horizontal)
    fit_parameters.add('center_y', value = p.fit_center_vertical)
    fit_parameters.add('spacing', value = p.fit_spacing)
    fit_parameters.add('sigma', value = p.fit_sigma)
    x_axis = np.arange(image_region[2], image_region[3] + 1, image_region[0])
    y_axis = np.arange(image_region[4], image_region[5] + 1, image_region[1])
    xx,yy = np.meshgrid(x_axis, y_axis)
    fitter.set_fitted_parameters(fit_parameters, xx, yy)
   
    x_pixels = int( (image_region[3] - image_region[2] + 1.) / (image_region[0]) )
    y_pixels = int( (image_region[5] - image_region[4] + 1.) / (image_region[1]) )
    #print "inside the camera readout"
    #print "x_pixels {}".format(x_pixels)
    #print "y_pixels {}".format(y_pixels)
    #print images
    #np.save('37ions_global', images)
    #print "repetitions{}".format(repetitions)
    
    images = np.reshape(images, (repetitions, y_pixels, x_pixels))
    readouts, confidences = fitter.state_detection(images)
    
    ion_state = 1 - readouts.mean(axis = 0)
    #np.save('temp_camera_ion_state', ion_state)
    #np.save('temp_camera_readout', readouts)
    
    
    if readout_mode == 'camera_states':
        ion_state=get_states_camera(readouts,int(p.ion_number))
        
    if readout_mode == 'camera_parity':
        ion_state=get_states_camera(readouts,int(p.ion_number))
        parity= Calc_parity(ion_state)
        ion_state=np.append(ion_state,[parity])
    
#     print "555"
#     print "readout_mode", readout_mode
#     print "ion_stste", ion_state
#         
    return ion_state, readouts, confidences