Exemple #1
0
                                      np.arange(len(Centers[i, :])))
    bkg_obj_fits = dirout + 'BKG_' + 'Pref.fits'
    if (os.access(bkg_obj_fits, os.F_OK) == False or force_bkg):
        bkg = GLOBALutils.get_scat(d, Centers, span=4)
        if (os.access(bkg_obj_fits, os.F_OK)):
            os.remove(bkg_obj_fits)
        hdu = pyfits.PrimaryHDU(bkg)
        hdu.writeto(bkg_obj_fits)
    else:
        bkg = pyfits.getdata(bkg_obj_fits)
    d -= bkg
    if os.access(Pref_fits, os.F_OK) == False or force_P:
        P_ref = np.zeros(d.shape)
        for i in range(nord):
            P_marsh = GLOBALutils.PCoeff(d, c_alls[i, :], ext_aperture, ron,
                                         gain, NSigma_Marsh, S_Marsh, N_Marsh,
                                         Marsh_alg, min_extract_col,
                                         max_extract_col)
            P_ref += P_marsh

        if (os.access(Pref_fits, os.F_OK)):
            os.remove(Pref_fits)
        hdu = pyfits.PrimaryHDU(P_ref)
        hdu.writeto(Pref_fits)
else:
    print "\tWeights for optimal extraction loaded..."
    P_ref = pyfits.getdata(Pref_fits)

# Extract Flat
print '\n\tExtraction of Flat calibration frames:'
Flat_spec_fits = dirout + 'Flat_spec.fits'
P_fits = dirout + 'P_flat.fits'
Exemple #2
0
    print "\t\tNo extracted flat object spectra found or extraction forced, extracting and saving..."

    Centers = np.zeros((len(c_all),Flat.shape[1]))
    for i in range(nord):
        Centers[i,:]=scipy.polyval(c_all[i,:],np.arange(len(Centers[i,:])))
    bac = GLOBALutils.get_scat(Flat,Centers,span=7)
    fl = Flat - bac
    bacfile = dirout + 'BAC_FLAT.fits'
    if (os.access(bacfile,os.F_OK)):
            os.remove( bacfile )
    hdbac = pyfits.PrimaryHDU( bac )
    hdbac.writeto(bacfile)

    print "\t\tWill extract",nord,"orders for object fibre..."
    for i in range(nord):
        P_marsh = GLOBALutils.PCoeff( fl, c_all[i,:], ext_aperture, RO_fl, GA_fl,\
		  NSigma_Marsh, S_Marsh, N_Marsh, Marsh_alg, min_extract_col,max_extract_col )
        P    += P_marsh

    if (os.access(P_fits,os.F_OK)):
        os.remove( P_fits )
    hdu = pyfits.PrimaryHDU( P )
    hdu.writeto( P_fits )

    S_flat  = GLOBALutils.optimal_extraction(fl,P,c_all,ext_aperture,RO_fl,GA_fl,\
              S_Marsh,10*NCosmic_Marsh,min_extract_col,max_extract_col,npools)
    for i in range(nord):
	S_flat[i,1] = S_flat[i,1][::-1]
	S_flat[i,2] = S_flat[i,2][::-1]

    if (os.access(S_flat_fits,os.F_OK)):
        os.remove( S_flat_fits )
Exemple #3
0
    Flat = MasterFlat.T  #- bac
    Centers = np.zeros((nord_ob, MasterFlat.shape[0]))
    ejx = np.arange(MasterFlat.shape[0])
    imshow(Flat, vmin=0, vmax=10000)
    for i in range(nord_ob):
        Centers[i, :] = scipy.polyval(c_ob[i], ejx)
        plot(ejx, Centers[i, :], 'r')
    show()

    #bac = FIDEOSutils.scat_flat(MasterFlat.T,c_ob,c_co)

    for i in range(nord_ob):
        print i
        try:
            P_marsh = GLOBALutils.PCoeff( Flat, c_ob[i,:], ext_aperture_ob, RO_ob, GA_ob,\
                      NSigma_Marsh, S_Marsh, N_Marsh, Marsh_alg ,\
                      min_extract_col,max_extract_col )
            P_ob += P_marsh
        except:
            print 'problem'
        i += 1

    S_flat_ob_simple = GLOBALutils.simple_extraction(Flat,c_ob,ext_aperture_ob,min_extract_col,\
                                                         max_extract_col,npools)
    S_flat_ob  = GLOBALutils.optimal_extraction(Flat,P_ob,c_ob,ext_aperture_ob,RO_ob,GA_ob,S_Marsh,\
                                                    NCosmic_Marsh,min_extract_col,max_extract_col,npools)

    S_flat_ob_simple = GLOBALutils.invert(S_flat_ob_simple)
    S_flat_ob = GLOBALutils.invert(S_flat_ob)

    if (os.access(P_ob_fits, os.F_OK)):