Example #1
0
        torder = 0
        for order in range(ro0,ro0+n_useful+1,1):
            #print order
            order_s = str(order)
            if (order < 100):
                order_s = '0' + str(order)
            thar_order_orig = lines_thar[order - difo]
            #IV              = iv_thar_ob_R[order,:]
            L = np.where(thar_order_orig != 0)[0]
            IV = 1. / (thar_order_orig / gain + (ron/gain)**2 )
            IV[L] = 0.
            wei             = np.sqrt( IV )
            thar_order      = thar_order_orig #- bkg

            coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths, rms_ms, residuals, centroids,sigmas, intensities \
                = GLOBALutils.Initial_Wav_Calibration( order_dir+'order_'+order_s+'.iwdat', thar_order, order, np.ones(len(thar_order)), rmsmax=300, minlines=10, FixEnds=False,Dump_Argon=dumpargon, Dump_AllLines=True, Cheby=use_cheby,porder=3,rough_shift=rough_shift)

            if (order == int(.5*n_useful)+ro0):

                if (use_cheby):
                    Global_ZP = GLOBALutils.Cheby_eval( coeffs_pix2wav,  0.5*len(thar_order), len(thar_order) )
                else:
                    Global_ZP = scipy.polyval( coeffs_pix2wav, 0.0 )

            All_Pixel_Centers = np.append( All_Pixel_Centers, pixel_centers )
            All_Wavelengths   = np.append( All_Wavelengths, wavelengths )
            All_Orders        = np.append( All_Orders, np.zeros( len(pixel_centers) ) + order -ro0)
            All_Centroids     = np.append( All_Centroids, centroids)
            All_Sigmas        = np.append( All_Sigmas, sigmas)
            All_Intensities   = np.append( All_Intensities, intensities )
            All_residuals     = np.append( All_residuals, residuals )
Example #2
0
                order_s = '0' + str(order)
            thar_order_orig = lines_thar2[order]
            I = np.where(np.isnan(thar_order_orig))
            J = np.where(np.isnan(thar_order_orig) == False)
            thar_order_orig[I] = np.median(thar_order_orig[J])
            thar_order = thar_order_orig - scipy.signal.medfilt(
                thar_order_orig, 101)
            wei = np.ones(len(thar_order))
            if order == 0:
                do_xc = False
            else:
                do_xc = True
            coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths,\
            rms_ms, residuals, centroids, sigmas, intensities =\
                     GLOBALutils.Initial_Wav_Calibration(order_dir+'nborder_'+\
                     order_s+'.iwdat', thar_order, order, wei, rmsmax=100, \
                     minlines=20,FixEnds=False,Dump_Argon=dumpargon,sigmai=2.,\
                     Dump_AllLines=True, Cheby=use_cheby,porder=ncoef_x,do_xc=False, line_width=6,pixelization=True)

            if order == 7:
                Global_ZP = GLOBALutils.Cheby_eval(coeffs_pix2wav,
                                                   0.5 * (len(thar_order) - 1),
                                                   len(thar_order))

            All_Pixel_Centers = np.append(All_Pixel_Centers, pixel_centers)
            All_Wavelengths = np.append(All_Wavelengths, wavelengths)
            All_Orders = np.append(All_Orders,
                                   np.zeros(len(pixel_centers)) + order)
            All_Centroids = np.append(All_Centroids, centroids)
            All_Sigmas = np.append(All_Sigmas, sigmas)
            All_Intensities = np.append(All_Intensities, intensities)
Example #3
0
        for order in range(n_useful):
            order_s = str(order)
            if (order < 10):
                order_s = '0' + str(order)

            thar_order_orig = lines_thar[order, :]
            IV = iv_thar[order, :]
            wei = np.sqrt(IV)
            #bkg             = PFSutils.Lines_mBack(thar_order_orig, IV,  thres_rel=3)
            #thar_order      = thar_order_orig - bkg
            thar_order = thar_order_orig

            coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths,\
            rms_ms, residuals, centroids, sigmas, intensities =\
                GLOBALutils.Initial_Wav_Calibration(order_dir+'norder_'+\
                order_s+'o.iwdat', thar_order, order, wei, rmsmax=100, \
                minlines=10,FixEnds=False,Dump_Argon=dumpargon,\
                Dump_AllLines=True, Cheby=use_cheby,porder=ncoef_x,fact=fact,del_width=30.)

            if (order == 32):
                if (use_cheby):
                    Global_ZP = GLOBALutils.Cheby_eval(coeffs_pix2wav,
                                                       0.5 * len(thar_order),
                                                       len(thar_order))
                else:
                    Global_ZP = scipy.polyval(coeffs_pix2wav, 0.0)

            All_Pixel_Centers = np.append(All_Pixel_Centers, pixel_centers)
            All_Wavelengths = np.append(All_Wavelengths, wavelengths)
            All_Orders = np.append(All_Orders,
                                   np.zeros(len(pixel_centers)) + order)
            All_Centroids = np.append(All_Centroids, centroids)
Example #4
0
        for order in range(len(c_all)):
            order_s = str(order)
            if (order < 10):
                order_s = '0' + str(order)
            thar_order_orig = lines_thar[order]
            I = np.where(np.isnan(thar_order_orig))
            J = np.where(np.isnan(thar_order_orig) == False)
            thar_order_orig[I] = np.median(thar_order_orig[J])
            thar_order = thar_order_orig - scipy.signal.medfilt(
                thar_order_orig, 101)
            wei = np.ones(len(thar_order))

            coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths,\
            rms_ms, residuals, centroids, sigmas, intensities =\
               GLOBALutils.Initial_Wav_Calibration(order_dir+'echorder_'+\
               order_s+'_'+str(int(chip))+'.iwdat', thar_order, order, wei, rmsmax=100, \
               minlines=20,FixEnds=False,Dump_Argon=dumpargon,\
               Dump_AllLines=True, Cheby=use_cheby,porder=ncoef_x)

            if (chip == 2) and (order == 8):
                Global_ZP = GLOBALutils.Cheby_eval(coeffs_pix2wav,
                                                   0.5 * (len(thar_order) - 1),
                                                   len(thar_order))

            All_Pixel_Centers = np.append(All_Pixel_Centers, pixel_centers)
            All_Wavelengths = np.append(All_Wavelengths, wavelengths)
            All_Orders = np.append(All_Orders,
                                   np.zeros(len(pixel_centers)) + order)
            All_Centroids = np.append(All_Centroids, centroids)
            All_Sigmas = np.append(All_Sigmas, sigmas)
            All_Intensities = np.append(All_Intensities, intensities)
Example #5
0
            if (order < 10):
                order_s = '0' + str(order)

            thar_order_orig = lines_thar[order, :]
            #bkg             = PFSutils.Lines_mBack(thar_order_orig, IV,  thres_rel=3)
            thar_order = thar_order_orig - scipy.signal.medfilt(
                thar_order_orig, 21)
            wei = np.ones(len(thar_order))
            ccf_max, rshift = GLOBALutils.cor_thar(lines_thar[order],filename=order_dir+'order_'+\
               order_s+'.iwdat',span=20,binning=binx)

            coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths,\
          rms_ms, residuals, centroids, sigmas, intensities =\
      GLOBALutils.Initial_Wav_Calibration(order_dir+'order_'+\
      order_s+'.iwdat', thar_order, order, wei, rmsmax=100, \
      minlines=30,FixEnds=False,Dump_Argon=dumpargon,\
      Dump_AllLines=True, Cheby=use_cheby,porder=5,del_width=4.0,\
      binning=binx,rough_shift=rshift,line_width=6)

            fwhms_lns = sigmas * 2.355
            inis_lns = pixel_centers - fwhms_lns * 0.5
            fins_lns = pixel_centers + fwhms_lns * 0.5
            inis_wvs = GLOBALutils.Cheby_eval(coeffs_pix2wav, inis_lns,
                                              float(len(thar_order)))
            fins_wvs = GLOBALutils.Cheby_eval(coeffs_pix2wav, fins_lns,
                                              float(len(thar_order)))
            fwhms_wvs = fins_wvs - inis_wvs
            resolution = wavelengths / fwhms_wvs

            #print "\t\t\tmedian Resolution of order", order, '('+str(np.around(np.median(wavelengths)))+' A)=', np.around(np.median(resolution))
            #plot(wavelengths, resolution,'ro')
Example #6
0
        trans = np.zeros([nup, 4])
        while orre <= or40:
            order_s = str(order)
            if (order < 10):
                order_s = '0' + str(order)

            thar_order_orig = lines_thar[orre, :]
            IV = iv_thar[orre, :]
            wei = np.sqrt(IV)
            #bkg = utils.Lines_mBack(thar_order_orig, IV, thres_rel=3)
            #thar_order = thar_order_orig - bkg
            thar_order = thar_order_orig
            coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths,\
            rms_ms, residuals, centroids, sigmas, intensities \
                = GLOBALutils.Initial_Wav_Calibration(order_dir+'gorder'+order_s+'.dat',\
                                                    thar_order,order,wei,rmsmax=5000000,\
                                                    minlines=6,FixEnds=True,Dump_Argon=False,\
                                                    Dump_AllLines=True, Cheby=use_cheby,rough_shift=delta)

            if (order == 20):
                if (use_cheby):
                    Global_ZP = GLOBALutils.Cheby_eval(coeffs_pix2wav, 511,
                                                       len(thar_order))
                else:
                    Global_ZP = scipy.polyval(coeffs_pix2wav, 0.0)
            #print residuals
            All_Pixel_Centers = np.append(All_Pixel_Centers, pixel_centers)
            All_Wavelengths = np.append(All_Wavelengths, wavelengths)
            All_Orders = np.append(All_Orders,
                                   np.zeros(len(pixel_centers)) + order)
            All_Centroids = np.append(All_Centroids, centroids)
            All_Sigmas = np.append(All_Sigmas, sigmas)
Example #7
0
    
        for order in range(orderi,orderf+1):
            order_s = str(order)
            if (order < 10):
                order_s = '0'+str(order)
            thar_order_orig = lines_thar[order,:]
            IV              = iv_thar[order,:]
            wei             = np.sqrt( IV )
            bkg             = scipy.signal.medfilt(thar_order_orig,201)
            thar_order      = thar_order_orig - thar_order_orig.min()
            f = open(order_dir+'order_'+order_s+sufix)
            lines = f.readlines()
            if len(lines)>5:
                coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths, rms_ms,\
                residuals, centroids, sigmas, intensities = GLOBALutils.Initial_Wav_Calibration( \
                                  order_dir+'order_'+order_s+sufix, thar_order, order, wei,\
                                  rmsmax=200, minlines=10, FixEnds=False, Dump_Argon=False, \
                                  Dump_AllLines=True, Cheby=use_cheby, rough_shift=rough_shift,do_xc=False)
                """
                fwhms_lns = sigmas*2.355
                inis_lns  = pixel_centers - fwhms_lns*0.5
                fins_lns  = pixel_centers + fwhms_lns*0.5           
                inis_wvs  = GLOBALutils.Cheby_eval(coeffs_pix2wav,inis_lns,float(len(thar_order)))
                fins_wvs  = GLOBALutils.Cheby_eval(coeffs_pix2wav,fins_lns,float(len(thar_order)))
                fwhms_wvs = inis_wvs - fins_wvs
                resolution2 = wavelengths / fwhms_wvs

                print "\t\t\tmedian Resolution of order", order, '=', np.around(np.median(resolution2))
                #"""
                if (order == int(0.5*n_useful)): 
                    if (use_cheby):
                        Global_ZP = GLOBALutils.Cheby_eval( coeffs_pix2wav, 0.5*len(thar_order), len(thar_order) )
        OK = []
        OW = []
	
        while order < n_last:
            order_s = str(order)
            if (order < 10):
                order_s = '0'+str(order)
            thar_order_orig = lines_thar[orre,:]
            IV              = iv_thar[orre,:]
            wei             = np.sqrt( IV )
            bkg             = GLOBALutils.Lines_mBack(thar_order_orig, IV, thres_rel=3, line_w=10)
            thar_order      = thar_order_orig - bkg

            coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths, rms_ms,\
                              residuals, centroids, sigmas, intensities = GLOBALutils.Initial_Wav_Calibration( \
                              order_dir+'order_'+order_s+'o.iwdat', thar_order, order, wei, rmsmax=1000, \
			      minlines=10, FixEnds=False, Dump_Argon=False, Dump_AllLines=True, Cheby=use_cheby, \
                              rough_shift = rough_shift)

            fwhms_lns = sigmas*2.355
            inis_lns  = pixel_centers - fwhms_lns*0.5
            fins_lns  = pixel_centers + fwhms_lns*0.5			
            inis_wvs  = GLOBALutils.Cheby_eval(coeffs_pix2wav,inis_lns,float(len(thar_order)))
            fins_wvs  = GLOBALutils.Cheby_eval(coeffs_pix2wav,fins_lns,float(len(thar_order)))
            fwhms_wvs = inis_wvs - fins_wvs
            resolution2 = wavelengths / fwhms_wvs

            if wavelengths.max() > 5500 and wavelengths.min()<5500:
                print "\t\t\tmedian Resolution of order", order, '=', np.around(np.median(resolution2))
			
            if (order == 32): 
                if (use_cheby):
Example #9
0
        t_ords, t_wavs = [], []
        for order in range(nord_ob):
            order_s = str(order)
            if (order < 10):
                order_s = '0' + str(order)

            thar_order_orig = lines_thar_ob[order, :]
            IV = iv_thar_ob[order, :]
            wei = np.sqrt(IV)
            bkg = np.zeros(
                len(thar_order_orig)
            )  # - GLOBALutils.Lines_mBack(thar_order_orig, IV,  thres_rel=3)
            thar_order = thar_order_orig - bkg

            coeffs_pix2wav, coeffs_pix2sigma, pixel_centers, wavelengths, rms_ms, residuals, centroids, sigmas, intensities \
                = GLOBALutils.Initial_Wav_Calibration( order_dir+'fideos_'+order_s+'.iwdat', thar_order, order, wei, \
                                                   rmsmax=10000, minlines=10,FixEnds=False,Dump_Argon=False,Cheby=True,porder=ncoef_x,rough_shift = offset_ob)
            if (order == 25):
                Global_ZP = GLOBALutils.Cheby_eval(coeffs_pix2wav, 1023,
                                                   len(thar_order))

            All_Pixel_Centers = np.append(All_Pixel_Centers, pixel_centers)
            All_Wavelengths = np.append(All_Wavelengths, wavelengths)
            All_Orders = np.append(All_Orders,
                                   np.zeros(len(pixel_centers)) + order)
            All_Centroids = np.append(All_Centroids, centroids)
            All_Sigmas = np.append(All_Sigmas, sigmas)
            All_Intensities = np.append(All_Intensities, intensities)

            t_ords.append(order)
            t_wavs.append(
                GLOBALutils.Cheby_eval(coeffs_pix2wav, 1023, len(thar_order)))