disp = vsini else: disp = 3. else: known_sigma = True mask_hw_wide = av_m * disp / (GLOBALutils.Constants.c / 1.0e3) ml_v = av_m - mask_hw_wide mh_v = av_m + mask_hw_wide print '\t\t\tComputing the CCF...' cond = True while (cond): # first rough correlation to find the minimum vels, xc_full, sn, nlines_ccf, W_ccf = \ GLOBALutils.XCor(spec, ml_v, mh_v, weight, 0, lbary_ltopo, vel_width=velw,vel_step=velsh,\ spec_order=9,iv_order=10,sn_order=8,max_vel_rough=velw) xc_av = GLOBALutils.Average_CCF(xc_full, sn, sn_min=3., Simple=True, W=W_ccf) yy = scipy.signal.medfilt(xc_av, 11) pred = lowess(yy, vels, frac=0.4, it=10, return_sorted=False) tck1 = scipy.interpolate.splrep(vels, pred, k=1) xc_av_orig = xc_av.copy() xc_av /= pred vel0_xc = vels[np.argmin(xc_av)] rvels, rxc_av, rpred, rxc_av_orig, rvel0_xc = vels.copy( ), xc_av.copy(), pred.copy(), xc_av_orig.copy(), vel0_xc xc_av_rough = xc_av
for i in range(nspec.shape[1]): npix = np.arange(nspec.shape[2]) wav = np.polyval(coefs[i][1:][::-1], npix) * 10 nspec[0, i, :] = wav spl = interpolate.splrep(np.arange(wav.shape[0]), wav, k=3) dlambda_dx = interpolate.splev(np.arange(wav.shape[0]), spl, der=1) NN = np.average(dlambda_dx) dlambda_dx /= NN nspec[9, i, :] = nspec[5, i, :] * (dlambda_dx**1) nspec[8, i, :] = 100. ml_v = tlines - 0.01 mh_v = tlines + 0.01 weight = np.ones(len(tlines)) vels, xc_full, sn, nlines_ccf, W_ccf = \ GLOBALutils.XCor(nspec, ml_v, mh_v, weight, 0, 1., vel_width=300,vel_step=3.,\ spec_order=9,iv_order=10,sn_order=8,max_vel_rough=300) xc_av = GLOBALutils.Average_CCF(xc_full, sn, sn_min=3., Simple=True, W=W_ccf) #plot(vels,xc_av) #show() j = np.median(xc_av) im = np.argmax(xc_av) rv = vels[im] vels, xc_full, sn, nlines_ccf, W_ccf = \ GLOBALutils.XCor(nspec, ml_v, mh_v, weight, rv, 1., vel_width=20,vel_step=0.3,\ spec_order=9,iv_order=10,sn_order=8,max_vel_rough=300) xc_av = GLOBALutils.Average_CCF(xc_full, sn, sn_min=3., Simple=True, W=W_ccf) cent = np.sum(xc_av * vels) / np.sum(xc_av) print cent #axvline(cent) #plot(vels,xc_av-j)
disp = 3. else: known_sigma = True if disp < 10: disp = 5 mask_hw_wide = av_m * disp / (GLOBALutils.Constants.c / 1.0e3) ml_v = av_m - mask_hw_wide mh_v = av_m + mask_hw_wide print '\t\t\tComputing the CCF...' cond = True while (cond): # first rough correlation to find the minimum vels, xc_full, sn, nlines_ccf, W_ccf = \ GLOBALutils.XCor(spec, ml_v, mh_v, weight, 0, 1., vel_width=300,vel_step=1.,\ spec_order=9,iv_order=10,sn_order=8,max_vel_rough=300) xc_av = GLOBALutils.Average_CCF(xc_full, sn, sn_min=0.0, Simple=True, W=W_ccf) #print W_ccf # Normalize the continuum of the CCF robustly with lowess yy = scipy.signal.medfilt(xc_av, 11) pred = lowess(yy, vels, frac=0.4, it=10, return_sorted=False) tck1 = scipy.interpolate.splrep(vels, pred, k=1) xc_av_orig = xc_av.copy() xc_av /= pred vel0_xc = vels[np.argmin(xc_av)] rvels, rxc_av, rpred, rxc_av_orig, rvel0_xc = vels.copy(), \ xc_av.copy(), pred.copy(), xc_av_orig.copy(), vel0_xc
disp = vsini else: disp = 3. else: known_sigma = True mask_hw_wide = av_m * disp / (GLOBALutils.Constants.c/1.0e3) ml_v = av_m - mask_hw_wide mh_v = av_m + mask_hw_wide print '\t\t\tComputing the CCF...' cond = True while (cond): #first rough correlation to find the minimum vels, xc_full, sn, nlines_ccf, W_ccf = GLOBALutils.XCor(spec1, ml_v, mh_v,\ weight, 0, lbary_ltopo, vel_width=300, vel_step=3, start_order=0,\ spec_order=9, iv_order=10, sn_order=8,max_vel_rough=300) xc_av = GLOBALutils.Average_CCF(xc_full, sn, sn_min=3, Simple=True, start_order=0, W=W_ccf) #Normalize the continuum of the CCF robustly with R yy = scipy.signal.medfilt(xc_av,11) pred = lowess(yy, vels,frac=0.4,it=10,return_sorted=False) tck1 = scipy.interpolate.splrep(vels,pred,k=1) xc_av_orig = xc_av.copy() xc_av /= pred pred_rough = pred.copy() vel0_xc = vels[ np.argmin( xc_av ) ] rvels, rxc_av, rpred, rxc_av_orig, rvel0_xc = vels.copy(), \ xc_av.copy(), pred.copy(), xc_av_orig.copy(), vel0_xc xc_av_rough = xc_av