コード例 #1
0
ファイル: reference_image.py プロジェクト: HaeffnerLab/cct
    def fit_and_plot(self, image):
        print "fit and plot"
        p = self.parameters.IonsOnCamera
        x_axis = np.arange(p.horizontal_min, p.horizontal_max + 1, self.image_region[0])
        y_axis = np.arange(p.vertical_min, p.vertical_max + 1, self.image_region[1])
        xx, yy = np.meshgrid(x_axis, y_axis)
        #import IPython
        #IPython.embed()

        #self.fitter.report(params)
        #ideally graphing should be done by saving to data vault and using the grapher
        #p = Process(target = self.fitter.graph, args = (x_axis, y_axis, image, params, result))
        #p.start()

        pylab.imshow(image)
        positions = pylab.ginput(0)
        positions = [x + np.min(x_axis) for x,y in positions]
        self.fitter = ion_state_detector(positions)
        result, params = self.fitter.guess_parameters_and_fit(xx, yy, image)
        self.fitter.graph(x_axis, y_axis, image, params, result)
        position_list = []

        try:
            i = 0
            while(True):
                position_list.append(params['pos'+str(i)].value)
                i += 1
        except KeyError:
            pass

        self.pv.set_parameter('IonsOnCamera','fit_background_level', params['background_level'].value)
        self.pv.set_parameter('IonsOnCamera','fit_amplitude', params['amplitude'].value)
        self.pv.set_parameter('IonsOnCamera','ion_positions', position_list) #TODO ?? FIXME
        self.pv.set_parameter('IonsOnCamera','ion_number', len(position_list)) #TODO ?? FIXME
        self.pv.set_parameter('IonsOnCamera','fit_sigma', params['sigma'].value)
コード例 #2
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)

pylab.imshow(image)
positions = pylab.ginput(0)
positions = [x+np.min(x_axis) for x,y in positions]
detector = ion_state_detector(positions)

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