示例#1
0
文件: MAIN.py 项目: lbusoni/MEDIS
    def __init__(self, image, pos, imparams):
	
	cx=imparams['centerx']
	cy=imparams['centery']
	fwhm = int(imparams['lambdaoverd'])
        angle = imparams['angle']
        speckle_rad = fwhm * 2.5 *3.
        # !!!!! remove factor * 2.5 * 3. for a full aperture !!!!!!!
        aperture_mask = detect_speckles.create_speckle_mask(image, pos, cx, cy, speckle_rad)
	
	# modified attribute
	self.none  = aperture_mask
        
	self.speckleim=np.zeros(image.shape)
        self.moments = cv2.moments(image*aperture_mask)
        self.intensity = self.moments['m00']
        self.intensity_scan = np.zeros(4)
        self.xcentroid = self.moments['m10']/self.intensity
        self.ycentroid = self.moments['m01']/self.intensity
        self.kvec      = DM.convert_pixels_kvecs(self.xcentroid,
                                                 self.ycentroid,
                                                 **imparams)
        self.kvecx     = -self.kvec[0]
        self.kvecy     = self.kvec[1]
        self.krad      = np.linalg.norm((self.kvecx, self.kvecy))

	# new attributes
	self.amplitude = detect_speckles.get_speckle_photometry(image, aperture_mask)
	#self.kxy = detect_speckles.get_speckle_spatial_freq(image, pos, cx, cy, fwhm, angle)
	self.kxy = DM.convert_pixels_kvecs(pos[1],pos[0],**imparams)
        self.kx = -self.kxy[0]
	self.ky = self.kxy[1]
	self.kmod = np.linalg.norm((self.kx, self.ky))
示例#2
0
 def __init__(self, image, xp, yp, config):
     self.imparams = config['IM_PARAMS']
     self.abc = config['INTENSITY_CAL']['abc']
     self.xcentroid = xp
     self.ycentroid = yp
     self.kvec = DM.convert_pixels_kvecs(self.xcentroid, self.ycentroid,
                                         **self.imparams)
     self.kvecx = self.kvec[0]
     self.kvecy = self.kvec[1]
     self.krad = np.linalg.norm((self.kvecx, self.kvecy))
     self.aperture = detect_speckles.create_speckle_aperture(
         image, self.xcentroid, self.ycentroid,
         config['INTENSITY_CAL']['aperture_radius'])
     #Edit to take into account aperture on other side
     #self.aperture = self.aperture + detect_speckles.create_speckle_aperture(
     #        image, 2*self.imparams['centerx']-self.xcentroid,
     #               2*self.imparams['centery']-self.ycentroid,
     #               config['INTENSITY_CAL']['aperture_radius'])
     #Edit to take into account aperture on other side
     self.exclusionzone = detect_speckles.create_speckle_aperture(
         image, self.xcentroid, self.ycentroid,
         1.5 * config['INTENSITY_CAL']['aperture_radius'])
     #self.exclusionzone  = self.exclusionzone + detect_speckles.create_speckle_aperture(
     #        image, 2*self.imparams['centerx']-self.xcentroid,
     #               2*self.imparams['centery']-self.ycentroid,
     #               1.5*config['INTENSITY_CAL']['aperture_radius'])
     self.intensity = detect_speckles.get_speckle_photometry(
         image, self.aperture)
     self.phase_intensities = [None, None, None, None]
     self.phases = config['NULLING']['phases']
     self.null_phase = None
示例#3
0
文件: test.py 项目: lbusoni/MEDIS
 def __init__(self, image,xp, yp, config):
     self.imparams = config['IM_PARAMS']
     self.abc       = config['INTENSITY_CAL']['abc']
     self.xcentroid = xp 
     self.ycentroid = yp 
     self.kvec      = DM.convert_pixels_kvecs(self.xcentroid,
                                              self.ycentroid,
                                              **self.imparams)
     self.kvecx     = self.kvec[0]
     self.kvecy     = self.kvec[1]
     self.krad      = np.linalg.norm((self.kvecx, self.kvecy))
     self.aperture  = detect_speckles.create_speckle_aperture(
             image, self.xcentroid, self.ycentroid, config['INTENSITY_CAL']['aperture_radius'])
     self.intensity = detect_speckles.get_speckle_photometry(image, self.aperture)
     self.intensities = [None, None, None, None]
示例#4
0
文件: testmain.py 项目: lbusoni/MEDIS
 def __init__(self, image, contour, imparams):
     self.speckleim = np.zeros(image.shape)
     self.none = cv2.drawContours(self.speckleim, [contour],
                                  0,
                                  color=1,
                                  thickness=-1)
     self.moments = cv2.moments(image * self.speckleim)
     self.intensity = self.moments['m00']
     self.intensity_scan = np.zeros(4)
     self.xcentroid = self.moments['m10'] / self.intensity
     self.ycentroid = self.moments['m01'] / self.intensity
     self.kvec = DM.convert_pixels_kvecs(self.xcentroid, self.ycentroid,
                                         **imparams)
     self.kvecx = -self.kvec[0]
     self.kvecy = self.kvec[1]
     self.krad = np.linalg.norm((self.kvecx, self.kvecy))
示例#5
0
def speckle_killer(wf, phase_map):
    # with open(iop.phase_ideal, 'rb') as handle:
    #     phase_ideal = pickle.load(handle)

    # quicklook_im(phase_map, logAmp=False)

    ijofinterest = skv3.identify_bright_points(proper.prop_get_amplitude(wf),
                                               controlregion)
    xyofinterest = [p[::-1] for p in ijofinterest]
    print(xyofinterest, len(xyofinterest))
    if len(xyofinterest) == 0:
        y = int(np.random.uniform(fp.controlregion[0], fp.controlregion[1]))
        x = int(np.random.uniform(fp.controlregion[2], fp.controlregion[3]))
        xyofinterest = [(y, x)]
    if len(xyofinterest) < fp.max_specks:
        fp.max_specks = len(xyofinterest)
    print(fp.max_specks)
    fps = skv3.filterpoints(xyofinterest,
                            max=fp.max_specks,
                            rad=fp.exclusionzone)
    print(fps)

    null_map = np.zeros((tp.ao_act, tp.ao_act))
    for speck in fps:
        print(speck)
        kvecx, kvecy = DM.convert_pixels_kvecs(speck[0],
                                               speck[1],
                                               tp.grid_size / 2,
                                               tp.grid_size / 2,
                                               angle=0,
                                               lambdaoverd=fp.lod)
        dm_phase = phase_map[speck[1], speck[0]]
        s_amp = proper.prop_get_amplitude(wf)[speck[1], speck[0]] * 5.3

        null_map += -DM.make_speckle_kxy(kvecx, kvecy, s_amp,
                                         dm_phase)  #+s_ideal#- 1.9377
    null_map /= len(fps)

    area_sum = np.sum(proper.prop_get_amplitude(wf) * controlregion)
    print(area_sum)
    with open(iop.measured_var, 'ab') as handle:
        pickle.dump(area_sum, handle, protocol=pickle.HIGHEST_PROTOCOL)

    return null_map
示例#6
0
        meanintensity = 0
        meankvec = 0
        meanphotom = 0

        for idx, xy in enumerate(xypixels):
            subim = pre.subimage(im, xy, window=10)
            subx = pre.subimage(ximcoords, xy, window=10)
            suby = pre.subimage(yimcoords, xy, window=10)
            gauss_params = snm.fitgaussian((subx, suby), subim)
            amplitude = gauss_params[0]

            #convert pixels returns an xy pair.
            # in theory all the kvecs should be (x, 0) or (0, y)
            # in which case the norm will be equal to x or y
            kvec = np.linalg.norm(
                DM.convert_pixels_kvecs(gauss_params[1], gauss_params[2],
                                        **im_params))
            print "Gaussian centroid", gauss_params[1], gauss_params[2]
            print "corr. k-vector", kvec
            meanintensity = (meanintensity * float(idx) / float(idx + 1) +
                             amplitude / float(idx + 1))
            meankvec = (meankvec * float(idx) / float(idx + 1) +
                        kvec / float(idx + 1))
            print gauss_params[2], gauss_params[1]
            aperture = create_speckle_mask(im,
                                           [gauss_params[2], gauss_params[1]],
                                           centerx, centery, fwhm)
            photometry = np.sum(im * aperture) / np.sum(aperture)
            #ipdb.set_trace()

            meanphotom = (meanphotom * float(idx) / float(idx + 1) +
                          photometry / float(idx + 1))
示例#7
0
        print "Fitting spot amplitudes and positions"
        #loops over the spots you clicked

        meankvec = 0
        meanphotom = 0
        for idx, xy in enumerate(xypixels):
            subim = pre.subimage(im, xy, window=10)
            subx = pre.subimage(ximcoords, xy, window=10)
            suby = pre.subimage(yimcoords, xy, window=10)
            gauss_params = snm.fitgaussian((subx, suby), subim)
            spotx, spoty = gauss_params[1], gauss_params[2]
            #convert pixels returns an xy pair.
            # in theory all the kvecs should be (x, 0) or (0, y)
            # in which case the norm will be equal to x or y
            kvec = np.linalg.norm(
                DM.convert_pixels_kvecs(spotx, spoty, **im_params))
            print "Gaussian centroid", spotx, spoty
            print "corr. k-vector", kvec
            meankvec = (meankvec * float(idx) / float(idx + 1) +
                        kvec / float(idx + 1))
            aperture = create_speckle_aperture(im, spotx, spoty, ap_rad)
            photometry = get_speckle_photometry(im, aperture)

            w1.set_data(np.log(np.abs(im * aperture)))
            plt.draw()
            plt.pause(0.01)
            w1.set_data(np.log(np.abs(im)))
            plt.draw()
            plt.pause(0.01)
            #w1.autoscale_view()
            meanphotom = (meanphotom * float(idx) / float(idx + 1) +