times = [] vs = [] verrs = [] for spectra in data.data: dat = np.random.normal(spectra.flux, spectra.ferr) vel = doppler.CKMS*(spectra.wave-model.data[0].wave[0])/model.data[0].wave[0]-model.data[0].gamma[0] wcen = model.data[0].wave gam = model.data[0].gamma for f,e,t,w in zip(dat,spectra.ferr,spectra.time,spectra.wave): xcen, xerr = subs.centroid((len(f)-1)/2., fwhm, f, True, e) icen = int(round(xcen)) if icen >=0 and icen < len(w): dw = (w[-1]-w[0])/(len(w)-1) v = doppler.CKMS*(w[icen] + (xcen-icen)*dw - wcen)/wcen - gam dv = doppler.CKMS*xerr*dw/wcen vs.append(v) verrs.append(dv) times.append(t) l = len(vs) vs = np.array(vs).reshape((l)) verrs = np.array(verrs).reshape((l)) times = np.array(times).reshape((l)) # compute periodogram on same set of frequencies as p = pgram.wmls(times, vs, verrs, fs) # output best frequency fout.write(str(fs[p.argmax()]) + '\n')
# add noise and accumulate V/R data times = [] ratios = [] rerrs = [] for spectra in data.data: dat = np.random.normal(spectra.flux, spectra.ferr) vel = doppler.CKMS*(spectra.wave-model.data[0].wave[0])/model.data[0].wave[0]-model.data[0].gamma[0] for f,e,v,t in zip(dat,spectra.ferr,vel,spectra.time): bpix = (v > -vmax) & (v < 0) blue = f[bpix].sum() bvar = (e[bpix]**2).sum() rpix = (v < vmax) & (v >= 0) red = f[rpix].sum() rvar = (e[rpix]**2).sum() rat = blue/red rerr = np.abs(rat)*np.sqrt(bvar/blue**2+rvar/red**2) ratios.append(rat) rerrs.append(rerr) times.append(t) ratios = np.array(ratios) rerrs = np.array(rerrs) times = np.array(times) # compute periodogram on same set of frequencies as p = pgram.wmls(times, ratios, rerrs, fs) # output best frequency fout.write(str(fs[p.argmax()]) + '\n')