gwnr.waveform β waveform tools
Generation, conditioning, alignment, hybridization and characterization of gravitational
waveforms. Source: gwnr/waveform/.
waveform.pyβ waveform generationget_waveform(approximant, phase_order, amplitude_order, spin_order, template_params, start_frequency, sample_rate, length, datafile=None, verbose=False)get_polarizations_from_multipoles(waveform_multipoles, inclination, coa_phase, verbose=False)project_polarizations_onto_detector(ifo_name, hp, hc, ra, dec, pol, tc, taper_mode='TAPER_NONE', amp_scaler=1.0)
align.pyβ waveform alignmentcondition.pyβ conditioning and windowinghybridize.pyβ inspiral β merger-ringdown hybridizationeccentric.pyβ eccentric binariesparameters.pyβ parameter conversionsutils.pyβ waveform utilitiestidal.pyβ tidal corrections for NSBH/BNSnr_waveform_sxs.pyβ SXS NR waveforms as templatesprepare_waveforms.pyβ SXS waveform preparation pipeline
waveform.py β waveform generation
General-purpose entry points wrapping PyCBC/LAL generators.
get_waveform(approximant, phase_order, amplitude_order, spin_order, template_params, start_frequency, sample_rate, length, datafile=None, verbose=False)
Generates a waveform for the point described by template_params (an object carrying masses,
spins, orientation angles β e.g. a SimInspiral row). Dispatches to the appropriate PyCBC
time-domain or frequency-domain generator based on approximant, and supports NR data files via
datafile.
get_polarizations_from_multipoles(waveform_multipoles, inclination, coa_phase, verbose=False)
Assembles the plus/cross polarizations from a dictionary of complex spherical-harmonic multipoles
indexed by (l, m), evaluating spin-weighted spherical harmonics at the given inclination and
coalescence phase.
project_polarizations_onto_detector(ifo_name, hp, hc, ra, dec, pol, tc, taper_mode='TAPER_NONE', amp_scaler=1.0)
Projects polarizations onto a named detector (H1, L1, V1, G1, β¦) using its antenna
pattern for sky location (ra, dec), polarization angle pol and coalescence time tc.
Optionally tapers the input via LAL taper modes.
align.py β waveform alignment
Functions to time/phase-shift one waveform to agree with another. All operate on PyCBC
TimeSeries pairs (hp, hc) interpreted as h = A(t) exp(-i Ξ¦(t)).
| Function | Alignment criterion |
|---|---|
shift_waveform_phase_time(hp, hc, t_shift, ph_shift, ...) |
Apply a given time and phase shift |
shift_waveform_phase(hp, hc, ph_shift, ...) |
Apply a given phase shift only |
shift_waveform_time(hp, hc, t_shift, ...) |
Apply a given time shift only |
align_waveforms_amplitude_peak(hp1, hc1, hp2, hc2, ...) |
Align the two waveforms at their amplitude peaks |
align_waveforms_at_frequency(hp1, hc1, hp2, hc2, falign, ...) |
Align where the instantaneous GW frequency crosses falign |
align_waveforms_optimally(hp1, hc1, hp2, hc2, psd='aLIGOZeroDetHighPower', ...) |
Iteratively determine and apply the time/phase shifts that maximize the noise-weighted inner product |
align_waveforms_suboptimally(...) |
Cheaper variant of the above |
align_curves(x1, y1, x2, y2, ...) |
Generic 1-D alignment: minimizes the integral of |y2(x+Ξx) β y1(x)| over the offset Ξx |
Most functions accept shift_epochs_only (shift epochs rather than rolling data),
trim_leading / trim_trailing (drop zeros introduced by shifting), and verbose flags.
condition.py β conditioning and windowing
smooth(x, window_len=11, window='flat')β moving-window smoothing by convolution with a chosen window (flat,hanning, β¦), with reflected-copy edge handling.moving_window_average(x, i, window_len=10)β average ofxin a window centered on indexi.planck_window(N, eps, one_sided=True, winstart=0)β Planck-taper window, the standard smooth turn-on used to avoid Gibbs artifacts when Fourier-transforming NR waveforms.windowing_tanh(waveform_array, bin_to_center_window, sharpness)β hyperbolic-tangent window.blend(hin, mm, sample, time, t_opt, WinID=-1)β blend (window) an NR waveform with a set of Planck-taper windows;blendTimeSeriesis the deprecatedTimeSeriesvariant.
hybridize.py β inspiral β merger-ringdown hybridization
Machinery to hybridize complex time series (waveform modes), aligning and blending an inspiral model with mergerβringdown (typically NR) data over a frequency-selected window.
hybridize_modes(inspiral_modes, merger_ringdown_modes, inspiral_orbital_frequency, frq_attach, frq_width=10.0, delta_t=1/4096, no_sp=8, modes_to_hybridize=[(2,2),(3,3),(4,4)], mode_to_align_by=(2,2), hybridize_using_avg_orbital_frequency=True, hybridize_aligning_merger_to_inspiral=True, include_conjugate_modes=True, verbose=False)
Hybridizes each requested (l, m) mode: locates the attachment window from the (optionally
averaged) orbital frequency around frq_attach with width frq_width, phase-aligns the
mergerβringdown against the inspiral using mode_to_align_by, and blends the two across the
window. Conjugate (l, βm) modes can be filled in automatically.
Supporting functions: find_first_value_location_in_series /
find_last_value_location_in_series (locate frequency crossings), mismatch_discrete,
align_in_phase, blend_series, and compute_amplitude / compute_phase /
compute_frequency for decomposing complex mode data.
eccentric.py β eccentric binaries
get_periastron_frequencies(hp, hc)/get_apastron_frequencies(hp, hc)β locate the periastron/apastron passages from oscillations in the instantaneous GW frequency of the polarizations, returning their times and frequencies (get_peak_freqsis the underlying peak-finder).eccentricity_at_extremum_frequency(mass1, mass2, spin1z, spin2z, e0, l0, f_lower, sample_rate, f_extremum, extremum='periastron', ...)β evolve an eccentric system from initial eccentricitye0and mean anomalyl0and measure the eccentricity when the chosen extremum sweeps throughf_extremum.eccentricity_at_reference_frequency(..., f_reference, ...)β orbital eccentricity at a reference orbit-averaged frequency, given initial conditions atf_lower.get_eccentric_waveform_and_dynamics(...)β runs an external eccentric-IMR executable to produce both the coordinate trajectory and GW polarizations over a grid of masses and eccentricities.optimize_eccentricity(x1, y1, q, ...)β fits(e, mean anomaly)atf_lowerso the modelβs radial evolution best matches a given (e.g. NR) trajectory.
parameters.py β parameter conversions
Small, pure conversion helpers:
| Function | Meaning |
|---|---|
spins_to_PNeffective_spin(m1, m2, chi1, chi2) |
Leading-order PN effective spin |
spins_to_2PNeffective_spin(m1, m2, chi1, chi2) |
2PN effective spin combination |
spins_to_massweighted_spin(m1, m2, chi1, chi2) |
Mass-weighted spin (Ο_eff) |
spins_to_damoureffective_spin(m1, m2, chi1, chi2) |
Damour effective spin |
chip_from_masses_spins(m1, m2, s1x, s1y, s1z, s2x, s2y, s2z) |
IMRPhenomPv2 precession parameter Ο_p (assumes m1 > m2) |
q_to_eta(q) / eta_to_q(eta) |
Mass ratio β symmetric mass ratio |
utils.py β waveform utilities
get_detector_response(ra, dec, psi, detector_tag, gmst=0)β antenna-pattern response factors for a detector.generate_detector_strain(template_params, h_plus, h_cross)β combine polarizations into detector strain using the sourceβs sky/polarization angles.get_ncycles_to_merger(hp, hc)β number of GW cycles before merger.get_time_at_frequency_from_polarizations(hp, hc, fvalue),get_time_at_frequency(fr, fvalue),get_time_at_y(fr, fvalue)β locate when a frequency (or generic y-value) is attained in aTimeSeries.get_freq_crossings(freq, f0, df_threshold=0.4)β all crossing times of frequencyf0(useful for eccentric signals where the frequency oscillates).get_isco_x,get_isco_frequency,f_ISCO_spin(mass1, mass2, spin1z, spin2z)β Kerr ISCO frequency fitting formulas for aligned-spin binaries.
tidal.py β tidal corrections for NSBH/BNS
class tidalWavs
Applies tidal amplitude and phase corrections on top of a point-particle frequency-domain model:
tidalCorrectionAmplitude(mf, eta, sBH, tidalLambda), tidalPNPhase,
tidalPNPhaseDeriv, tidalCorrectionPhase, and
getWaveform(M, eta, sBH, Lambda, distance=1e6*lal.PC_SI, f_lower=15.0, ...) which returns the
tidally-corrected waveform.
random_match(...)
Monte-Carlo study helper: draws random NSBH parameters and computes matches between tidal and
point-particle waveforms, writing results to match.dat.
nr_waveform_sxs.py β SXS NR waveforms as templates
get_nr_data_location(p, ...)β resolves the location of NR data corresponding to parametersp, via thenumrel_datafield, environment variables (NR_CATALOG_PATH,NR_CATALOG_FILE), or a template-bank-to-NR mapping.get_hplus_hcross_from_sxs(hdf5_file_name, template_params, delta_t, modeLmin=2, modeLmax=8, modeMmin=2, modeMmax=None, junk_duration=600, taper=True, ...)β reads SXS-format HDF5 modes, sums them at the requested orientation, rescales to physical mass/distance, removes junk radiation and tapers, returning(hp, hc).get_hplus_hcross_from_get_td_waveform(**p)β adapter so NR waveforms can be generated through the standardpycbc.waveform.get_td_waveforminterface.
(A parallel copy of this module lives at gwnr.nr.nr_waveform_sxs.)
prepare_waveforms.py β SXS waveform preparation pipeline
class PrepareSXSWaveform
Prepares raw SpEC/SXS simulation output for analysis, for a given resolution (Lev) and
eccentricity subdirectory:
join_waveform_h5_files()β join per-segment waveform HDF5 files,extrapolate(ch_mass=1.0, ...)β extrapolate finite-radius waveforms to null infinity,join_horizons()β join apparent-horizon data,transform_to_com_frame(...)β correct for center-of-mass drift,prepare_waveform(...)β run the full pipeline (optionally uploading results).
Properties expose the directory layout (sim_dir, out_dir, joined_outfile_dir,
extrap_out_dir, β¦). Requires SXS post-processing tools to be available.