def get_apastron_frequencies(hp, hc): ''' Input ----- hp, hc: pycbc.types.timeseries Plus (+) and Cross (x) polarizations Output: ------- apastron_frequencies: numpy.array Frequency of GW emission at periastron at increasing values of time apastron_times: numpy.array Times at which apastron passages occur ''' freq = frequency_from_polarizations(hp, hc) ft, ff = get_peak_freqs(-1 * freq) return (ft, -1 * ff)
def gen_waveform(iota, phi, numrel_data): print "I am in gen_waveform()!" ## FIXME(Gonghan): It seems that this variable is never used. global wavelabel wavelabel = os.path.join(savepath, numrel_data.split('/')[-1].replace(".h5", "")) f = h5py.File(numrel_data, 'r') global hp, hc hp, hc = get_td_waveform(approximant='NR_hdf5', numrel_data=numrel_data, mass1=f.attrs['mass1'] * mass, mass2=f.attrs['mass2'] * mass, spin1z=f.attrs['spin1z'], spin2z=f.attrs['spin2z'], delta_t=1.0 / sample_frequency, f_lower=30., inclination=iota, coa_phase=phi, distance=1000) print "in gen_waveform, have got hp, hc. iota: {}, phi: {}".format( iota, phi) print "hp:", hp print "hc:", hc f.close() # Taper waveform for smooth FFTs hp = taper_timeseries(hp, tapermethod="TAPER_START") hc = taper_timeseries(hc, tapermethod="TAPER_START") global amp, foft amp = wfutils.amplitude_from_polarizations(hp, hc) foft = wfutils.frequency_from_polarizations(hp, hc) # Shift time origin to merger global sample_times ## FIXME(Gonghan): Not sure how we want to define zero time. sample_times = amp.sample_times - amp.sample_times[np.argmax(amp)]
def _get_tf_path(self, approximant='SEOBNRv4_opt', sample_rate=4096 * 4): """ Get frequency track of an event based on GraceDb parameters. Parameters ---------- approximant : str, optional f_lower : int, optional sample_rate : int, optional Returns ------- tf_path : gwpy.timeseries.TimeSeries object Time series of frequency. """ if not all( hasattr(self, x) for x in ['graceid', 'm1', 'm2', 's1z', 's2z', 'start_time', 'end_time']): return None hp, hc = get_td_waveform(approximant='SEOBNRv4_opt', mass1=self.m1, mass2=self.m2, spin1z=self.s1z, spin2z=self.s2z, delta_t=1.0 / sample_rate, f_lower=30, frame_axis=SIM_INSPIRAL_FRAME_AXIS_ORBITAL_L) foft = frequency_from_polarizations(hp, hc) try: foft = utils.trim_foft(foft) except: pass tf_path = TimeSeries(foft, t0=self.end_time + float(foft.start_time), dt=foft.delta_t) tf_path = tf_path.crop(self.start_time, self.end_time) tf_path.name = self.graceid + '_path' return tf_path
for row in snglburst_table: if (row.snr > args.omicron_snr_thresh and omicron_start_time < row.peak_time < omicron_end_time): omicron_times.append(row.peak_time + row.peak_time_ns * 10**(-9)) omicron_snr.append(row.snr) omicron_freq.append(row.peak_frequency) # Generate inspiral waveform and calculate f(t) to plot on top of Omicron triggers hp, hc = get_td_waveform(approximant='SEOBNRv2', mass1=m1, mass2=m2, spin1x=0, spin1y=0, spin1z=s1z, spin2x=0, spin2y=0, spin2z=s2z, delta_t=(1./32768.), f_lower=30) f = frequency_from_polarizations(hp, hc) amp = amplitude_from_polarizations(hp, hc) stop_idx = amp.abs_max_loc()[1] f = f[:stop_idx] freq = np.array(f.data) times = np.array(f.sample_times) + cbc_end_time logging.info('Plotting') plt.figure(0) cm = plt.cm.get_cmap('Reds') plt.scatter(omicron_times,omicron_freq,c=omicron_snr,s=30,cmap=cm,linewidth=0) plt.grid(b=True, which='both') cbar = plt.colorbar()
omicron_freq.append(row.peak_frequency) # Generate inspiral waveform and calculate f(t) to plot on top of Omicron triggers hp, hc = get_td_waveform(approximant='SEOBNRv2', mass1=m1, mass2=m2, spin1x=0, spin1y=0, spin1z=s1z, spin2x=0, spin2y=0, spin2z=s2z, delta_t=(1. / 32768.), f_lower=30) f = frequency_from_polarizations(hp, hc) amp = amplitude_from_polarizations(hp, hc) stop_idx = amp.abs_max_loc()[1] f = f[:stop_idx] freq = np.array(f.data) times = np.array(f.sample_times) + cbc_end_time logging.info('Plotting') plt.figure(0) cm = plt.cm.get_cmap('Reds') plt.scatter(omicron_times, omicron_freq, c=omicron_snr,
def gen_waveform(numrel_data, iota, phi): ## FIXME(Gonghan): It seems that wavelabel is never used. # global wavelabel # wavelabel=os.PATH.join(savepath, waveformName.split('/')[-1].replace(".h5","")) f = h5py.File(numrel_data, 'r') # Getting the 2-2 mode polarizations first. hp, hc = get_td_waveform(approximant='NR_hdf5', numrel_data=numrel_data, mass1=f.attrs['mass1'] * mass, mass2=f.attrs['mass2'] * mass, spin1z=f.attrs['spin1z'], spin2z=f.attrs['spin2z'], delta_t=1.0 / sample_frequency, f_lower=30., inclination=iota, coa_phase=phi, distance=1000, mode_array=[[2, 2], [2, -2]]) # Taper waveform for smooth FFTs hp = taper_timeseries(hp, tapermethod="TAPER_START") hc = taper_timeseries(hc, tapermethod="TAPER_START") amp = wfutils.amplitude_from_polarizations(hp, hc) peakAmpTime = amp.sample_times[np.argmax(amp)] '''mode_array=[[2,2], [2,-2]]''' # Getting the full-mode waveform. hp, hc = get_td_waveform(approximant='NR_hdf5', numrel_data=numrel_data, mass1=f.attrs['mass1'] * mass, mass2=f.attrs['mass2'] * mass, spin1z=f.attrs['spin1z'], spin2z=f.attrs['spin2z'], delta_t=1.0 / sample_frequency, f_lower=30., inclination=iota, coa_phase=phi, distance=1000) f.close() # Taper waveform for smooth FFTs hp = taper_timeseries(hp, tapermethod="TAPER_START") hc = taper_timeseries(hc, tapermethod="TAPER_START") amp = wfutils.amplitude_from_polarizations(hp, hc) foft = wfutils.frequency_from_polarizations(hp, hc) # Shift time origin to merger ## FIXME(Gonghan): Not sure how we want to define zero time. sample_times = amp.sample_times - peakAmpTime # sample_times = amp.sample_times # # Trim the timeseries before the CWT # hp_red = hp[:int(sample_frequency)] return { "hp": hp, "hc": hc, "amp": amp, "foft": foft, "sample_times": sample_times }