示例#1
0
def define_control_region(image):
    """Click on an image to define the vertices of a polygon defining a region"""
    spots = pre.get_spot_locations(
        image, comment='Click on the region you want to control')
    xs, ys = np.meshgrid(np.arange(image.shape[1]), np.arange(image.shape[0]))
    pp = snm.points_in_poly(xs, ys, spots)
    return pp, spots
示例#2
0
def define_control_annulus(image, cx= None, cy = None):
    """SHIFT- Click on the image to define the vertices of a polygon defining a region. May be convex or concave"""
    spots = pre.get_spot_locations(image, 
            comment='SHIFT-click to select IN THIS ORDER, inner radius, and outer radius of the annular region to control')
    xs, ys = np.meshgrid( np.arange(image.shape[1]),
                            np.arange(image.shape[0]))
    rad_in =np.linalg.norm(np.array(spots[0])-np.array([cx, cy])) 
    rad_out =np.linalg.norm(np.array(spots[1])-np.array([cx, cy])) 
    return ( pro.annulus(image, cx, cy, rad_in, rad_out), spots)
示例#3
0
def define_control_region(image):
    """SHIFT- Click on the image to define the vertices of a polygon defining a region. May be convex or concave"""
    spots = pre.get_spot_locations(
        image,
        comment=
        'SHIFT-click to select the vertices region you want to control\n, then close the window'
    )
    xs, ys = np.meshgrid(np.arange(image.shape[1]), np.arange(image.shape[0]))
    pp = snm.points_in_poly(xs, ys, spots)
    return pp, spots
示例#4
0
def get_satellite_centroids(image, window=20):
    """centroid each satellite spot using a 2d gaussian"""
    spots = pre.get_spot_locations(image, eq=True,
            comment='SHIFT-Click on the satellites CLOCKWISE'+
                     'starting from 10 o clock,\n then close the window')
    #satellite centers
    scs = np.zeros((len(spots), 2))
    for idx,xy in enumerate(spots):
        subim = pre.subimage(image, xy, window=window)
        popt = snm.image_centroid_gaussian1(subim)
        xcenp = popt[1]
        ycenp = popt[2]
        xcen = xy[0]-round(window/2)+xcenp
        ycen = xy[1]-round(window/2)+ycenp
        scs[idx,:] = xcen, ycen
    return scs
示例#5
0
def dm_reg_autorun(cleanimage, configfilename, configspecfile):
    #configfilename = 'speckle_null_config.ini'
    config = ConfigObj(configfilename, configspec=configspecfile)
    val = Validator()
    check = config.validate(val)
    #initial spot guesses
    try:
        initialspots = [ config['CALSPOTS']['spot10oclock'],  
                         config['CALSPOTS']['spot1oclock'],  
                         config['CALSPOTS']['spot4oclock'],  
                         config['CALSPOTS']['spot7oclock'],]
    except:
        print "WARNING: SPOTS NOT FOUND IN CONFIGFILE. RECALCULATING"
        initialspots = pre.get_spot_locations(image, eq=True,
                comment='SHIFT-Click on the satellites CLOCKWISE'+
                         'starting from 10 o clock,\n then close the window')
    spotcenters = recenter_satellites(cleanimage, 
                                initialspots, window=20)
    
    print "updated spotcenters: ",  spotcenters
    print 'initial spots', initialspots

    plt.figure()
    plt.imshow(np.log(cleanimage))
    plt.show()
    ans = raw_input('placeholder')

    c =find_center(spotcenters)
    a =find_angle(spotcenters)
    
    config['IM_PARAMS']['centerx'] = c[0]
    config['IM_PARAMS']['centery'] = c[1]
    config['IM_PARAMS']['angle']  = a 
    #cyclesperap = int(config['AOSYS']['dmcyclesperap'])
    kvecr = 33
    lambdaoverd = get_lambdaoverd(spotcenters, kvecr)
    config['IM_PARAMS']['lambdaoverd'] = lambdaoverd
    
    config['CALSPOTS']['spot10oclock'] = [np.round(x) for x in spotcenters[0]]
    config['CALSPOTS']['spot1oclock'] = [np.round(x) for x in spotcenters[1]]
    config['CALSPOTS']['spot4oclock'] = [np.round(x) for x in spotcenters[2]]
    config['CALSPOTS']['spot7oclock'] = [np.round(x) for x in spotcenters[3]]
    print "Image center: " , c
    print "DM angle: ", a
    print "lambda/D: ", str(lambdaoverd)
    config.write() 
    print "Updating configfile"
示例#6
0
        img_off = pre.equalize_image(img_off, **bgds)
        #ipdb.set_trace()
        p3k.sci_offset_up(-offs)
        #ipdb.set_trace()
    else :
        img_off = pre.combine_quadrants(pf.open(off_filename)) 
        img_off = img_off - bgd2
    
    
    
    # detect the position of the offseted image
    ipdb.set_trace()
    nx=img_off.shape[0]
    ny=img_off.shape[1]
    x, y = np.meshgrid(np.arange(nx),np.arange(ny))
    fun = pre.get_spot_locations(img_off)
    indmax = fun[0]
    subIm= pre.subimage(img_off, (indmax[0],indmax[1]), window=25)
    subx = pre.subimage(x, (indmax[0],indmax[1]), window=25)
    suby = pre.subimage(y, (indmax[0],indmax[1]), window=25)
    gauss_params = snm.fitgaussian((subx, suby), subIm)
    cx_off, cy_off = gauss_params[1], gauss_params[2]

    
    # calibrate pixel size
    D_pix = np.sqrt((cx_off-centerx)**2+(cy_off-centery)**2)
    lambdaoverd_arc = config['Image_params']['lambdaoverd_arc']    
    lambdaoverd = lambdaoverd_arc * D_pix / offs

    Itot = np.sum(pre.subimage(img_off, (cx_off,cy_off), window = 2*quad_width_pix))