Пример #1
0
def mk_skyflats(file_list=None,file_path=None, bias_fil=None):
    import xastropy.PH136.experiments.hrdiagram as hrd
    from astropy.io.fits import getdata

    # Frames
    B_sky = 32 + np.arange(5)
    V_sky = 37 + np.arange(5)
    R_sky = 43 + np.arange(5)
    all_sky = [B_sky, V_sky, R_sky]

    # Outfiles
    outfil = ['Sky_B.fits', 'Sky_V.fits', 'Sky_R.fits']
    filters = ['B','V','R']

    # Bias
    if bias_fil == None:
        bias_fil = 'Bias.fits'
    bias_img,bias_head = getdata(bias_fil,0,header=True)
    

    # Loop on Filters
    for ff in filters:
        # Index
        idx = filters.index(ff)

        # Generate file names
        files= hrd.mk_file_list(all_sky[idx])

        # Stack with scaling
        img = hrd.stack_img(files, bias_img=bias_img, norm=True)

        # Trim
        trim_img = hrd.trimflip_img(img)

        # Deal with zeros
        zro = np.where( trim_img == 0.)
        trim_img[zro] = 1.

        # Write
        print 'Sky Flats: Writing ', outfil[idx]
        fits.writeto(outfil[idx], trim_img, clobber=True)

    print 'Sky Flats: All done'
    return
Пример #2
0
def mk_bias(file_list=None,file_path=None,outfil=None):
    # There is no overscan region (yes there is!)
    #  So, we need a bias image
    import xastropy.PH136.experiments.hrdiagram as hrd
    from astropy.io.fits import getdata
    from astropy.io.fits import Column
    from astropy.io import fits 
    from astropy.stats import sigma_clip 

    # Defaults
    if file_path == None: 
        file_path = 'Raw/'
    
    if outfil == None: 
        outfil = 'Bias.fits'

    # Files
    bias_fil = None
    if file_list == None:
        # Generate them ourself
        biasfrm = 2 + np.arange(10)
        bias_fil = hrd.mk_file_list(biasfrm, file_path=file_path)

    # Read Noise
    arr,head = getdata(str(bias_fil[0]),0,header=True)
    clip_arr = sigma_clip(arr, 2.5, None)
    rnoise = np.std(clip_arr,dtype=np.float64)
    print 'Read Noise = ', rnoise, ' counts'

    #pdb.set_trace()
    #dpt = ds9.ds9()
    #dpt.set_np2arr(arr)

    # Stack the frames
    img = hrd.stack_img(bias_fil)

    # Write
    head.update('RNOISE', rnoise, 'READ NOISE')
    fits.writeto(outfil, img, head, clobber=True)
    return