Beispiel #1
0
                                                   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)

        p0 = np.zeros(npar_wsol)
        p0[0] = (7 + ro0) * Global_ZP
        p1, G_pix, G_ord, G_wav, II, rms_ms, G_res = \
            GLOBALutils.Fit_Global_Wav_Solution(All_Pixel_Centers, All_Wavelengths, All_Orders,\
                                                np.ones(All_Intensities.shape), p0, Cheby=use_cheby,\
                                                maxrms=MRMS, Inv=Inverse_m,minlines=200,order0=ro0, \
                                                ntotal=nord1,npix=len(thar_order),nx=ncoef_x,nm=ncoef_m)
        """
        equis = np.arange(len(thar_order))
        order = 0
        while order < nord1:
            m   = order + ro0
            chebs = GLOBALutils.Calculate_chebs(equis, m, order0=ro0,ntotal=nord1, \
                npix=len(equis), Inverse=Inverse_m,nx=ncoef_x,nm=ncoef_m)

            WavSol = (1.0/float(m)) * GLOBALutils.Joint_Polynomial_Cheby(p1,chebs,ncoef_x,ncoef_m)
            plot(WavSol,lines_thar2[order])
            order+=1
        show()
        """
        lines_thar2 = thar_S['chip2']
Beispiel #2
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 )
            wavs.append(GLOBALutils.Cheby_eval( coeffs_pix2wav,  0.5*len(thar_order), len(thar_order) ))
            ords.append(torder)
            torder += 1

        p0    = np.zeros( npar_wsol )
        p0[0] =  (int(.5*n_useful)+ro0) * Global_ZP
        p1, G_pix, G_ord, G_wav, II, rms_ms, G_res = GLOBALutils.Fit_Global_Wav_Solution(All_Pixel_Centers, All_Wavelengths,\
                                                     All_Orders, np.ones(All_Intensities.shape), p0, Cheby=use_cheby,       \
                                                     order0=ro0, ntotal=n_useful, maxrms=200, Inv=Inverse_m, minlines=200,  \
                                                     npix=len(thar_order),nx=ncoef_x,nm=ncoef_m)

        pdict = {'p1':p1,'mjd':mjd, 'G_pix':G_pix, 'G_ord':G_ord, 'G_wav':G_wav, 'II':II, 'rms_ms':rms_ms,\
                     'G_res':G_res, 'All_Centroids':All_Centroids, 'All_Wavelengths':All_Wavelengths, 'All_Orders':All_Orders, 'All_Pixel_Centers':All_Pixel_Centers, 'All_Sigmas':All_Sigmas}
        pickle.dump( pdict, open( wavsol_pkl, 'w' ) )

    else:
        print("\t\tUsing previously computed wavelength solution in file",wavsol_pkl)
        pdict = pickle.load(open(wavsol_pkl,'r'))


wavsol_pkl = dirout + ThAr_ref[0].split('/')[-1][:-4]+'wavsolpars.pkl'
dct        = pickle.load(open(wavsol_pkl,'r'))
p_ref = dct['p1']
mjds_thar,shifts = [],[]
Beispiel #3
0
                    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)
            All_Sigmas = np.append(All_Sigmas, sigmas)
            All_Intensities = np.append(All_Intensities, intensities)

    #show()
        p0 = np.zeros(npar_wsol)
        p0[0] = (32 + 93) * Global_ZP
        p1, G_pix, G_ord, G_wav, II, rms_ms, G_res = \
            GLOBALutils.Fit_Global_Wav_Solution(All_Pixel_Centers, All_Wavelengths, All_Orders,\
                                                np.ones(All_Intensities.shape), p0, Cheby=use_cheby,\
                                                maxrms=50, Inv=Inverse_m,minlines=minlines_glob,order0=93, \
                                                ntotal=n_useful,npix=len(thar_order),nx=ncoef_x,nm=ncoef_m)

        equis = np.arange(thar_S.shape[2])
        for order in range(n_useful):
            m = order + 93
            chebs = GLOBALutils.Calculate_chebs(equis,
                                                m,
                                                npix=thar_S.shape[2],
                                                order0=93,
                                                ntotal=n_useful,
                                                Inverse=Inverse_m,
                                                nx=ncoef_x,
                                                nm=ncoef_m)
            WavSol = (1.0 / m) * GLOBALutils.Joint_Polynomial_Cheby(
                p1, chebs, ncoef_x, ncoef_m)
Beispiel #4
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)
                All_Sigmas        = np.append( All_Sigmas, sigmas)
                All_Intensities   = np.append( All_Intensities, intensities )
                All_residuals     = np.append( All_Residuals, residuals)
                All_Sigmas        = np.append( All_Sigmas,sigmas)
            
        p0    = np.zeros( npar_wsol )
        p0[0] = int(.5*n_useful) * Global_ZP

        p1, G_pix, G_ord, G_wav, II, rms_ms, G_res = \
            GLOBALutils.Fit_Global_Wav_Solution(All_Pixel_Centers, All_Wavelengths, All_Orders, \
            np.ones(All_Intensities.shape), p0, npix=lines_thar.shape[1], Cheby=use_cheby, \
            maxrms=MRMS, Inv=Inverse_m, minlines=1000,order0=oro0,nx=ncoef_x,nm=ncoef_m,ntotal=n_useful)
        """
        fl = open('../fies/lovis.txt')
        lls, lts,sts = [],[],[]
        lines = fl.readlines()
        for line in lines:
            cos = line.split()
            lls.append(float(cos[0]))
            lts.append(cos[3])
            sts.append(float(cos[2]))
        lls,lts,sts = np.array(lls),np.array(lts),np.array(sts)
        equis = np.arange(4096)
        for i in np.arange(orderi,orderf+1):
            if i > 14:
                m = i + oro0
            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 )
            All_residuals     = np.append( All_Residuals, residuals)
            All_Sigmas        = np.append( All_Sigmas,sigmas)
			
            order += 1
            orre  += 1

        p0    = np.zeros( npar_wsol )
        p0[0] = (32+oro0) * Global_ZP

        p1, G_pix, G_ord, G_wav, II, rms_ms, G_res = \
			GLOBALutils.Fit_Global_Wav_Solution(All_Pixel_Centers, All_Wavelengths, All_Orders, np.ones(All_Intensities.shape), p0, npix=len(lines_thar[orre,:]), Cheby=use_cheby, maxrms=150, Inv=Inverse_m, minlines=800,order0=oro0,nx=ncoef_x,nm=ncoef_m,ntotal=ntotal)

        if rms_ms/np.sqrt(float(len(G_pix))) < 20:
            pdict = {'p1':p1, 'G_pix':G_pix, 'G_ord':G_ord, 'G_wav':G_wav, 'II':II,\
                     'rms_ms':rms_ms, 'G_res':G_res, 'All_Centroids':All_Centroids,\
                     'All_Sigmas':All_Sigmas, 'or0':or0, 'orwa':orwa, 'oro0':oro0,\
                     'rough_shift':rough_shift}
            pickle.dump( pdict, open( wavsol_pkl, 'w' ) )
            thtimes.append(thmjd)
            thRA.append(hth['RA-D'])
            thDEC.append(hth['DEC-D'])
            thnames.append(wavsol_pkl)
        else:
            bad_thars.append(counter)
    else:
        print "\t\tUsing previously computed wavelength solution in file",wavsol_pkl
Beispiel #6
0
                                   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)))
        t_ords, t_wavs = np.array(t_ords), np.array(t_wavs)
        #GLOBALutils.get_zero_order_number(t_ords,t_wavs)

        p0 = np.zeros(npar_wsol)
        p0[0] = (25 + 49) * Global_ZP
        p1, G_pix, G_ord, G_wav, II, rms_ms, G_res = \
            GLOBALutils.Fit_Global_Wav_Solution(All_Pixel_Centers, All_Wavelengths, All_Orders,\
                                                np.ones(All_Intensities.shape), p0, Cheby=True,\
                                                maxrms=MRMS, Inv=Inverse_m,minlines=400,order0=49, \
      ntotal=nord_ob,npix=len(thar_order),nx=ncoef_x,nm=ncoef_m)

        thar_out = np.zeros((2, nord_ob, lines_thar_ob.shape[1]))
        equis = np.arange(lines_thar_ob.shape[1])
        order = 0
        while order < nord_ob:
            m = order + 49
            chebs = GLOBALutils.Calculate_chebs(equis,
                                                m,
                                                Inverse=Inverse_m,
                                                order0=49,
                                                ntotal=nord_ob,
                                                npix=len(thar_order),
                                                nx=ncoef_x,
                                                nm=ncoef_m)