Ejemplo n.º 1
0
p_ref = dct['p1']
mjds_thar,shifts = [],[]

print('\n\tDetermination of instrumental drift during the night...')
temps = []
for i in range(len(ThAr_ref_dates)):
    wavsol_pkl = dirout + ThAr_ref[i].split('/')[-1][:-4]+'wavsolpars.pkl'
    hthar = pyfits.open( ThAr_ref[i] )
    npix = hthar[0].data.shape[1]
    temps.append(float(hthar[0].header['HIERARCH CAHA GEN AMBI PRES']))
    mjd, mjd0 = cafeutils.mjd_fromheader2( hthar )
    mjds_thar.append(mjd)
    dct = pickle.load(open(wavsol_pkl,'r'))
    p_shift, pix_centers, orders, wavelengths, I, rms_ms, residuals  = \
                    GLOBALutils.Global_Wav_Solution_vel_shift(dct['All_Pixel_Centers'], dct['All_Wavelengths'], dct['All_Orders'],\
                                                        np.ones(len(dct['All_Orders'])), p_ref, order0=ro0, npix=npix,\
                                                        Cheby=use_cheby, ntotal=n_useful, maxrms=200, Inv=Inverse_m, minlines=500, nx=ncoef_x,nm=ncoef_m)
    shifts.append(p_shift[0])

mjds_thar,shifts,temps = np.array(mjds_thar),np.array(shifts),np.array(temps)-temps[0]
shv = (1e-6*shifts)*299792458.0
if len(mjds_thar) > 1:
    tck_v = scipy.interpolate.splrep(mjds_thar,shv,k=1)
    tck_shift = scipy.interpolate.splrep(mjds_thar,shifts,k=1)
    temp = np.arange(mjds_thar[0],mjds_thar[-1],0.0001)

    mjdsh_thar = (mjds_thar - int(temp.min())) * 24.
    thour = (temp - int(temp.min())) * 24.
    thours = (new_times - int(temp.min())) * 24.
    pp = PdfPages(dirout + 'proc/ThAr_shifts.pdf')
    plot(mjdsh_thar,shv,'ro')
Ejemplo n.º 2
0
for thar in ThAr_ref:
    h = pyfits.open(thar)
    mjd, mjd0 = pucherosutils.mjd_fromheader(h)
    hdth = pyfits.getheader(thar)
    thtimes.append(mjd)
    wavsol_pkl = dirout + 'ThAr' + hdth['DATE-OBS'][:10] + '_' + hdth[
        'DATE-OBS'][11:13] + '-' + hdth['DATE-OBS'][14:16] + '-' + hdth[
            'DATE-OBS'][17:] + '.wavsolpars.pkl'
    wavsol = pickle.load(open(wavsol_pkl, 'r'))
    G_pix = wavsol['G_pix']
    G_wav = wavsol['G_wav']
    G_ord = wavsol['G_ord']
    oro0 = wavsol['oro0']
    p_shift, pix_centers, orders, wavelengths, I, rms_ms, residuals  = \
         GLOBALutils.Global_Wav_Solution_vel_shift(G_pix, G_wav, G_ord,\
             np.ones(G_wav.shape), p1_ref, Cheby=True, Inv=True, \
      maxrms=150,minlines=250,order0=oro0,ntotal=nup,\
      npix=h[0].data.shape[0],nx=ncoef_x,nm=ncoef_m)
    thshifts.append(p_shift)
    f.write(thar + '\t' + str(thtime) + '\t' +
            str((1e-6 * p_shift) * 299792.458) + '\n')
    #print p_shift
thshifts, thtimes = np.array(thshifts), np.array(thtimes)

Is = np.argsort(thtimes)
thtimes, thshifts = thtimes[Is], thshifts[Is]
if len(thtimes) > 3:
    thshifts = (1e-6 * thshifts) * 299792.458
    thtck = scipy.interpolate.splrep(thtimes, thshifts, k=3, s=0)
    ejeje = np.arange(thtimes[0], thtimes[-1], 0.0001)
    ejeyy = scipy.interpolate.splev(ejeje, thtck, der=0)
    #if not avoid_plot:
Ejemplo n.º 3
0
print "\n\tDetermination of Instrumental drift along the night:"
for i in range(len(good_arcs)):
    hthar = pyfits.open(good_arcs[i])
    hour = mikeutils.get_hour(float(hthar[ih].header['UT-TIME']))
    thar_fits_simple = dirout + 'MIKE_' + hthar[ih].header[
        'UT-DATE'] + '_' + hour + '.ThAr.spec.simple.fits'
    length = pyfits.getdata(thar_fits_simple).shape[1]
    hour = mikeutils.get_hour(float(hthar[ih].header['UT-TIME']))
    wavsol_pkl = dirout + 'MIKE_' + hthar[ih].header[
        'UT-DATE'] + '_' + hour + '.wavsolpars.pkl'
    pdict = pickle.load(open(wavsol_pkl, 'r'))

    p1, sh_centers, sh_orders, sh_wavelengths, sh_I, sh_rms_ms, sh_residuals  = \
          GLOBALutils.Global_Wav_Solution_vel_shift(pdict['G_pix'],\
          pdict['G_wav'], pdict['G_ord'],\
          np.ones(len(pdict['G_ord'])), pref,\
          minlines=250, maxrms=150,order0=37, ntotal=n_useful,\
          Cheby=use_cheby, Inv=Inverse_m, npix=length,nx=ncoef_x,nm=ncoef_m)
    pshs.append(p1)
    arc_mjds.append(pdict['mjd'])
pshs, arc_mjds = np.array(pshs), np.array(arc_mjds)
tck_sh = scipy.interpolate.splrep(arc_mjds, pshs, k=1)

### start of science frame reductions ###
print '\n\tThe following targets will be processed:'
new_list = []
new_list_obnames = []
new_list_texp = []
for i in range(len(science)):
    fsim = science[i]
    obname = obnames[i]
Ejemplo n.º 4
0
        p0[0] = (25 + 49) * Global_ZP
        p1_co, G_pix_co, G_ord_co, G_wav_co, II_co, rms_ms_co, G_res_co = \
         GLOBALutils.Fit_Global_Wav_Solution(All_Pixel_Centers_co, All_Wavelengths_co, All_Orders_co,\
                                             np.ones(All_Intensities_co.shape), p0, Cheby=True,\
                                             maxrms=MRMS, Inv=Inverse_m,minlines=400,order0=49, \
          ntotal=nord_co,npix=len(thar_order),nx=ncoef_x,nm=ncoef_m)

        #shifts = np.array(shifts)
        #shifts = FEROSutils.sigma_clip(shifts)
        #the_sh   = np.around(shifts.mean(),1)
        #error_sh = np.around(np.sqrt(np.var(shifts)/float(len(shifts)-1)),1)
        #print 'Shifts (per order):', the_sh, '+-', error_sh

        p_shift, pix_centers, orders, wavelengths, I, rms_ms, residuals  = \
          GLOBALutils.Global_Wav_Solution_vel_shift(All_Pixel_Centers_co, All_Wavelengths_co, All_Orders_co,\
                                             np.ones(All_Intensities_co.shape), wsol_dict['p1_co'],\
                                                  Cheby=True,Inv=True,maxrms=MRMS,minlines=minlines_glob_co,\
                                                                order0=49,ntotal=nord_co,npix=len(thar_order),nx=ncoef_x,nm=ncoef_m)

    fout = 'proc/' + fsim.split('/')[-1][:-4] + 'sp.fits'
    spec = np.zeros((11, nord_ob, data.shape[0]))
    equis = np.arange(data.shape[0])
    for order in range(nord_ob):
        m = order + 49
        chebs = GLOBALutils.Calculate_chebs(equis,
                                            m,
                                            Inverse=Inverse_m,
                                            order0=49,
                                            ntotal=nord_ob,
                                            npix=data.shape[1],
                                            nx=ncoef_x,
                                            nm=ncoef_m)