示例#1
0
    Flat, RO_fl, GA_fl = uvesutils.MedianCombine(flats, bias=MasterBias)
    hdu = pyfits.PrimaryHDU(Flat)
    if (os.access(dirout + 'Flat.fits', os.F_OK)):
        os.remove(dirout + 'Flat.fits')
    hdu.writeto(dirout + 'Flat.fits')
    print "\t\t-> MasterFlat: done!"

    hdu = pyfits.open(orderref[0])
    d1 = hdu[1].data - MasterBias[:, :, 0]
    d2 = hdu[2].data - MasterBias[:, :, 1]
    d1 = d1.T
    d2 = d2.T
    print "\tTracing echelle orders..."
    c_all1, nord1 = GLOBALutils.get_them(d1,
                                         int(0.2 * ext_aperture),
                                         trace_degree,
                                         mode=1,
                                         nsigmas=10)
    print '\t\t' + str(nord1) + ' orders for chip1 found...'
    c_all2, nord2 = GLOBALutils.get_them(d2,
                                         int(0.2 * ext_aperture),
                                         trace_degree,
                                         mode=1,
                                         nsigmas=10,
                                         endat=2030)
    print '\t\t' + str(nord2) + ' orders for chip2 found...'

    trace_dict = {'c_all1':c_all1,'nord1':nord1,\
                  'c_all2':c_all2,'nord2':nord2,\
                  'GA_bias': GA_bias, 'RO_bias': RO_bias,\
                  'GA_fl': GA_fl, 'RO_fl': RO_fl}
示例#2
0
    hdu = pyfits.PrimaryHDU( MasterBias )
    if (os.access(dirout+'MasterBias.fits',os.F_OK)):
        os.remove(dirout+'MasterBias.fits')
    hdu.writeto(dirout+'MasterBias.fits')
    print("\t\t-> Masterbias: done!")

    # median combine list of flats
    Flat, RO_fl, GA_fl = cafeutils.MedianCombine(flats, zero=dirout+'MasterBias.fits')
    hdu = pyfits.PrimaryHDU(Flat)
    if (os.access(dirout+'Flat.fits',os.F_OK)):
        os.remove(dirout+'Flat.fits')
    hdu.writeto(dirout+'Flat.fits')
    print("\t\t-> Masterflats: done!")

    print("\tTracing echelle orders...")
    c_all,nord = GLOBALutils.get_them(Flat, ext_aperture, trace_degree, maxords=-1, mode=1)
    c_all, nord = GLOBALutils.good_orders(c_all,nord,Flat.shape[0],Flat.shape[1],ext_aperture)
    if nord >= 90:
        c_all = c_all[:90]
        nord=90
    print('\t\t'+ str(nord)+' orders found.')

    # pickle traces
    trace_dict = {'c_all':c_all,
                  'nord':nord,
                  'GA_bias': GA_bias, 'RO_bias' : RO_bias,
                  'GA_fl': GA_fl, 'RO_fl': RO_fl}
    pickle.dump( trace_dict, open( dirout+"trace.pkl", 'w' ) )

else:
    trace_dict = pickle.load( open( dirout+"trace.pkl", 'r' ) )
示例#3
0
    pre_process = 1
else:
    print "\tPre-processing files found, going straight to extraction"
    pre_process = 0

if pre_process == 1:
    # Find orders & traces
    print "\tTracing echelle orders..."

    h = pyfits.open(dirin + stst)
    if len(h) > 1:
        h[0].data = h[1].data
    d = h[0].data
    d = mikeutils.OverscanTrim(d, bias_sec, ov_sec)
    d = d.T
    c_all, nord = GLOBALutils.get_them(d, ext_aperture, 4, mode=1)
    c_all = c_all[1:-1]
    nord = len(c_all)
    print '\t\t', nord, 'orders found in red CCD'

    hb = pyfits.open(dirin + 'b' + stst[1:])
    if len(h) > 1:
        hb[0].data = hb[1].data
    db = hb[0].data
    db = mikeutils.OverscanTrim(db, bias_sec, ov_sec)
    db = db.T
    c_all_b, nord_b = GLOBALutils.get_them(db, ext_aperture, 4, mode=1)
    print '\t\t', nord_b, 'orders found in blue CCD'

    # median combine list of ob flats
    print "\tMedian combining flat frames"
示例#4
0
        os.remove(dirout + 'Flat.fits')
    hdu.writeto(dirout + 'Flat.fits')
    print "\t\t-> Masterflat: done!"
    #Flat = pyfits.getdata(dirout+'Flat.fits')
    #RO_flat, GA_flat = 1.,1.

    # Find orders & traces
    print "\tTracing echelle orders..."
    h = pyfits.open(dirin + stst)[0]
    hth = pyfits.getheader(dirin + stst)
    d = h.data
    d = pfsutils.OverscanTrim(d, bias_section, over_section)
    d -= MasterBias
    c_all, nord = GLOBALutils.get_them(d,
                                       ext_aperture - 1,
                                       trace_degree,
                                       mode=1,
                                       nsigmas=5)

    trace_dict = {
        'c_all': c_all,
        'nord': nord,
        'GA_bias': GA_bias,
        'RO_bias': RO_bias,
        'GA_flat': GA_flat,
        'RO_flat': RO_flat
    }
    pickle.dump(trace_dict, open(dirout + 'trace.pkl', 'w'))

else:
    print '\t\tLoading Masterbias, Masterflat and traces'
示例#5
0
    print "\t\tGenerating Master calibration frames..."
    Flat, RO_fl, GA_fl = hiresutils.MedianCombine(flats, chip=chip)
    hdu = pyfits.PrimaryHDU(Flat)
    if (os.access(dirout + 'Flat_' + str(int(chip)) + '.fits', os.F_OK)):
        os.remove(dirout + 'Flat_' + str(int(chip)) + '.fits')
    hdu.writeto(dirout + 'Flat_' + str(int(chip)) + '.fits')
    print "\t\t-> Masterflat: done!"

    hdu = pyfits.open(dirin + stst)
    d = hdu[chip].data
    d = hiresutils.OverscanTrim(d, hdu[chip].header['DATASEC'])
    d = d.T
    print "\tTracing echelle orders..."
    c_all, nord = GLOBALutils.get_them(d,
                                       ext_aperture + 5,
                                       trace_degree,
                                       mode=1,
                                       nsigmas=10,
                                       nc2=1)
    print '\t\t' + str(nord) + ' orders found...'

    # pickle traces
    trace_dict = {'c_all': c_all, 'nord': nord, 'GA_fl': GA_fl, 'RO_fl': RO_fl}
    pickle.dump(trace_dict,
                open(dirout + 'trace_' + str(int(chip)) + '.pkl', 'w'))

else:
    trace_dict = pickle.load(open(dirout + 'trace_' + str(int(chip)) + '.pkl'))
    c_all = trace_dict['c_all']
    nord = trace_dict['nord']
    # recover GA*, RO*
    GA_fl = trace_dict['GA_fl']
示例#6
0
文件: hirespipe.py 项目: mrawls/ceres
if (pre_process == 1):
    # median combine list of flats
    print "\t\tGenerating Master calibration frames..."
    Flat, RO_fl, GA_fl = hiresutils.MedianCombine(flats, chip=chip)
    hdu = pyfits.PrimaryHDU(Flat)
    if (os.access(dirout + 'Flat_' + str(int(chip)) + '.fits', os.F_OK)):
        os.remove(dirout + 'Flat_' + str(int(chip)) + '.fits')
    hdu.writeto(dirout + 'Flat_' + str(int(chip)) + '.fits')
    print "\t\t-> Masterflat: done!"

    hdu = pyfits.open(dirin + stst)
    d = hdu[chip].data
    d = hiresutils.OverscanTrim(d, hdu[chip].header['DATASEC'])
    d = d.T
    print "\tTracing echelle orders..."
    c_all, nord = GLOBALutils.get_them(d, ext_aperture, trace_degree, mode=1)
    print '\t\t' + str(nord) + ' orders found...'

    # pickle traces
    trace_dict = {'c_all': c_all, 'nord': nord, 'GA_fl': GA_fl, 'RO_fl': RO_fl}
    pickle.dump(trace_dict,
                open(dirout + 'trace_' + str(int(chip)) + '.pkl', 'w'))

else:
    trace_dict = pickle.load(open(dirout + 'trace_' + str(int(chip)) + '.pkl'))
    c_all = trace_dict['c_all']
    nord = trace_dict['nord']
    # recover GA*, RO*
    GA_fl = trace_dict['GA_fl']
    RO_fl = trace_dict['RO_fl']
    # recover flats & master bias
示例#7
0
                                                     dirout +
                                                     'MasterBias.fits',
                                                     dark_bo=have_darks,
                                                     dlist=MasDarl)
        hdu = pyfits.PrimaryHDU(Flat)
        if (os.access(dirout + 'MasterFlat.fits', os.F_OK)):
            os.remove(dirout + 'MasterFlat.fits')
        hdu.writeto(dirout + 'MasterFlat.fits')

    print "\t\t-> Masterflats: done!"
    print "\tTracing echelle orders..."
    h = pyfits.open(dirout + 'MasterFlat.fits')[0]
    d = h.data
    d = d.T
    c_all, nord = GLOBALutils.get_them(d,
                                       ext_aperture + 1,
                                       trace_degree,
                                       maxords=45)
    print '\t\t' + str(nord) + ' orders found ...'
    trace_dict = {'c_all': c_all, 'nord': nord, 'roF': roF, 'gaF': gaF}
    pickle.dump(trace_dict, open(dirout + "trace.pkl", 'w'))

else:
    h = pyfits.open(dirout + 'MasterBias.fits')
    MasterBias = h[0].data
    # load orders & tracers
    trace_dict = pickle.load(open(dirout + "trace.pkl", 'r'))
    #print trace_dict['c_all'].shape
    c_all = trace_dict['c_all']
    nord = trace_dict['nord']
    roF = trace_dict['roF']
    gaF = trace_dict['gaF']
示例#8
0
    Flat, RO_flat, GA_flat = vbtutils.MedianCombine(flats, zero_bo=True, dark_bo=False, flat_bo=False,zero=dirout+'MasterBias.fits')
    hdu = pyfits.PrimaryHDU( Flat )

    if (os.access(dirout+'MasterFlat.fits',os.F_OK)):
        os.remove(dirout+'MasterFlat.fits')
    hdu.writeto(dirout+'MasterFlat.fits')
    print "\t\t-> Masterflat: done!"

    # Find orders & traces
    print "\tTracing echelle orders..."
    h = pyfits.open(dirin+stst)[0]
    hth = pyfits.getheader(dirin+stst)
    d = h.data[0]
    d = vbtutils.OverscanTrim(d,bsec)
    d -= MasterBias
    c_all, nord = GLOBALutils.get_them(d,20,trace_degree,mode=1,nsigmas=3,endat=4100)
    print '\t\t'+str(nord)+' orders found...'
    
    trace_dict = {'c_all':c_all, 'nord':nord, 'DARKS':MDARKS, 'dtimes':dark_times, 'RO_flat':RO_flat, 'GA_flat':GA_flat}
    pickle.dump( trace_dict, open( dirout+"trace.pkl", 'w' ) )


else:
    trace_dict = pickle.load( open( dirout+"trace.pkl", 'r' ) )

    c_all = trace_dict['c_all']
    nord = trace_dict['nord']
    RO_flat = trace_dict['RO_flat']
    GA_flat = trace_dict['GA_flat']

    h = pyfits.open(dirout+'MasterBias.fits')
        d = h.data
        d = dupontutils.OverscanTrim(d,hth['BIASSEC'])
        d -= MasterBias
        d /= Flat

        if bad_colummn:
            d = dupontutils.b_col(d)	

        d = d[:1420,:]	
        if use_ref:
            c_comp = pickle.load( open( ref_traces, 'r' ) )['c_all']
            nord = pickle.load( open( ref_traces, 'r' ) )['nord']
            lim = pickle.load( open( ref_traces, 'r' ) )['lims']
            c_all,pshift = GLOBALutils.retrace( d, c_comp )
        else:
            c_all, nord = GLOBALutils.get_them(d,5,trace_degree,mode=1)
            print '\t\t'+str(nord)+' orders found...'
    else:
        trace_dict = pickle.load( open( dirout+"trace.pkl", 'r' ) )
        c_all = trace_dict['c_all']
        nord = trace_dict['nord']
        GAIN = trace_dict['GA_ob']
        RON = trace_dict['RO_ob']
	
    trace_dict = {'c_all':c_all, 'nord':nord, 'GA_ob': GAIN, 'RO_ob': RON, 'DARKS':MDARKS, 'dtimes':dark_times}
    pickle.dump( trace_dict, open( dirout+"trace.pkl", 'w' ) )


else:
    trace_dict = pickle.load( open( dirout+"trace.pkl", 'r' ) )
示例#10
0
    #    Centers[i,:]=scipy.polyval(c_co[i],ejx)
    #bac_co = GLOBALutils.get_scat(MasterFlat_co.T,Centers,span = 6)
    #MasterFlat_co = MasterFlat_co - bac_co.T
    #MasterFlat_ob = MasterFlat - MasterFlat_co

    #plot(MasterFlat_ob[1000])
    #show()
    #plot(np.median(MasterFlat[:,2050:],axis=1))
    #show()
    #plot(MasterFlat[1000])
    #plot(MasterFlat_co[1000])
    #show()

    c_all, nord_all = GLOBALutils.get_them(MasterFlat.T,
                                           4.,
                                           trace_degree,
                                           maxords=-1,
                                           nsigmas=1,
                                           mode=1)
    print nord_all
    c_ob, c_co, nord_ob, nord_co = fideosutils.clean_orders(
        c_all, MasterFlat.T)
    print nord_ob, nord_co
    c_co, nord_co = fideosutils.good_orders(c_co, nord_co, MasterFlat.shape[1],
                                            MasterFlat.shape[0],
                                            ext_aperture_co)
    c_ob, nord_ob = fideosutils.good_orders(c_ob, nord_ob, MasterFlat.shape[1],
                                            MasterFlat.shape[0],
                                            ext_aperture_ob)
    print nord_ob, nord_co
    print nord_ob, 'object orders found'
    print nord_co, 'comparison orders found'