コード例 #1
0
def cal_image(filepath,plot = True,path=None,band='gp',source='BD710031',bias=None,dark=None,flat=None):
    
    if not path:
        path = set_path()

    if length(bias) == 1:
        bias = make_bias(path=path)

    if length(dark) == 1:
        dark = make_dark(path=path)

    if length(flat) == 1:
        flat = make_flat(path=path,band=band,bias=bias,dark=dark)
        
        
    image0, header0 = qi.readimage(filepath)
    refh = h.pyfits.getheader(filepath)
   
    im = h.pyfits.open(filepath)
    newim = h.hcongrid((im[0].data-dark-bias)/flat, im[0].header,refh)
    
    if plot:
        qi.display_image(newim)
        
    return newim,header0
コード例 #2
0
def display_raws(path=None,band='gp',source='BD710031'):
    
    if not path:
        path = set_path()
    
    files,sz = tp.get_files(dir=path, tag=source+'.'+band)
    
    for i in range(len(files)):
        image = fits.getdata(files[i],0)
        qi.display_image(image,fignum=i)
コード例 #3
0
def find_stars(image, plot = False, fwhm = 20.0, threshold=3.):

    from astropy.stats import sigma_clipped_stats
    mean, median, std = sigma_clipped_stats(image, sigma=3.0)
    from photutils import daofind
    sources = daofind(image - median, fwhm=fwhm, threshold=threshold*std)
    
   # stars already found accurately, vet_sources will be implemented when working properly
   # vet_sources(10.0,10.0)
        
    if plot == True:
       # from astropy.visualization import SqrtStretch
       # from astropy.visualization.mpl_normalize import ImageNormalize
        positions = (sources['xcentroid'], sources['ycentroid'])
        apertures = CircularAperture(positions, r=4.)
        #norm = ImageNormalize(stretch=SqrtStretch())
        #plt.imshow(image, cmap='Greys', origin='lower', norm=norm)
        qi.display_image(image)
        apertures.plot(color='blue', lw=1.5, alpha=0.5)
        
    return sources
コード例 #4
0
def find_flux(image):
    model = fit(*indices(image.shape))
    qi.display_image(model)

    resid = model - image
    qi.display_image(resid)

    #plt.figure(2)
    #plt.hist(resid, bins=50)

    plt.figure(3)
    qi.display_image(resid)

    A = params[0]
    Xsig = params[3]
    Ysig = params[4]
    #Check if sigmas x and y = xcen and ycen

    flux = (A * 2 * pi * Xsig * Ysig)/10.
    
    num = (np.sum(image))/10.
    
    return num, flux
コード例 #5
0
plt.ylim(0,2048)


darks,dct = tp.get_files(tag='Dark')
biases,bct = tp.get_files(tag='Bias')
flats,fct = tp.get_files(tag='SkyFlat')
targetfiles,tct = tp.get_files(tag='KIC10935310')

bias = tp.master_bias(biases,outdir='./Photometry/',readnoise=False)

dark = tp.master_dark(darks,bias=bias,outdir='./Photometry/')

flat = tp.master_flat(flats,bias=bias,dark=dark,outdir='./Photometry/')

cal = (image - dark - bias)/flat
qi.display_image(cal,siglo=2,sighi=2)
plt.plot([x0],[y0],'y+',markersize=30,linewidth=1e6)
plt.xlim(0,2048)
plt.ylim(0,2048)

# define the aperture
radius,ynew,xnew,fwhm,aspect,snrmax,totflux,totap,chisq = \
    tp.optimal_aperture(x0,y0,image,skyrad=[15,20])

pref = np.array([[x0,y0],[836,1154],[645,1152], [1234,1002], [1131,1338], [377,426]])
coords0 = w.wcs_pix2world(pref,1) 
ras = coords0[:,0]
decs = coords0[:,1]

info = tp.batch_phot(targetfiles[:-1],ras,decs,bias=bias,dark=dark,flat=flat,
                     outdir='./Photometry/',skyrad=np.array([15,20]))