signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def _postgenerate(self, res):
hp, hc = res<EOL>try:<EOL><INDENT>hp = taper_timeseries(hp, tapermethod=self.current_params['<STR_LIT>'])<EOL>hc = taper_timeseries(hc, tapermethod=self.current_params['<STR_LIT>'])<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>return hp, hc<EOL>
Applies a taper if it is in current params.
f16080:c3:m1
def set_epoch(self, epoch):
self._epoch = float(epoch)<EOL>
Sets the epoch; epoch should be a float or a LIGOTimeGPS.
f16080:c8:m1
@property<EOL><INDENT>def static_args(self):<DEDENT>
return self._static_args<EOL>
Returns a dictionary of the static arguments.
f16080:c8:m2
def generate_from_args(self, *args):
return self.generate(**dict(zip(self.variable_args, args)))<EOL>
Generates a waveform, applies a time shift and the detector response function from the given args. The args are assumed to be in the same order as the variable args.
f16080:c8:m4
def generate(self, **kwargs):
self.current_params.update(kwargs)<EOL>rfparams = {param: self.current_params[param]<EOL>for param in kwargs if param not in self.location_args}<EOL>hp, hc = self.rframe_generator.generate(**rfparams)<EOL>if isinstance(hp, TimeSeries):<EOL><INDENT>df = self.current_params['<STR_LIT>']<EOL>hp = hp.to_frequencyseries(del...
Generates a waveform, applies a time shift and the detector response function from the given kwargs.
f16080:c8:m5
def ceilpow2(n):
signif,exponent = frexp(n)<EOL>if (signif < <NUM_LIT:0>):<EOL><INDENT>return <NUM_LIT:1>;<EOL><DEDENT>if (signif == <NUM_LIT:0.5>):<EOL><INDENT>exponent -= <NUM_LIT:1>;<EOL><DEDENT>return (<NUM_LIT:1>) << exponent<EOL>
convenience function to determine a power-of-2 upper frequency limit
f16081:m0
def coalign_waveforms(h1, h2, psd=None,<EOL>low_frequency_cutoff=None,<EOL>high_frequency_cutoff=None,<EOL>resize=True):
from pycbc.filter import matched_filter<EOL>mlen = ceilpow2(max(len(h1), len(h2)))<EOL>h1 = h1.copy()<EOL>h2 = h2.copy()<EOL>if resize:<EOL><INDENT>h1.resize(mlen)<EOL>h2.resize(mlen)<EOL><DEDENT>elif len(h1) != len(h2) or len(h2) % <NUM_LIT:2> != <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<E...
Return two time series which are aligned in time and phase. The alignment is only to the nearest sample point and all changes to the phase are made to the first input waveform. Waveforms should not be split accross the vector boundary. If it is, please use roll or cyclic time shift to ensure that the e...
f16081:m1
def phase_from_frequencyseries(htilde, remove_start_phase=True):
p = numpy.unwrap(numpy.angle(htilde.data)).astype(<EOL>real_same_precision_as(htilde))<EOL>if remove_start_phase:<EOL><INDENT>p += -p[<NUM_LIT:0>]<EOL><DEDENT>return FrequencySeries(p, delta_f=htilde.delta_f, epoch=htilde.epoch,<EOL>copy=False)<EOL>
Returns the phase from the given frequency-domain waveform. This assumes that the waveform has been sampled finely enough that the phase cannot change by more than pi radians between each step. Parameters ---------- htilde : FrequencySeries The waveform to get the phase for; must be a compl...
f16081:m2
def amplitude_from_frequencyseries(htilde):
amp = abs(htilde.data).astype(real_same_precision_as(htilde))<EOL>return FrequencySeries(amp, delta_f=htilde.delta_f, epoch=htilde.epoch,<EOL>copy=False)<EOL>
Returns the amplitude of the given frequency-domain waveform as a FrequencySeries. Parameters ---------- htilde : FrequencySeries The waveform to get the amplitude of. Returns ------- FrequencySeries The amplitude of the waveform as a function of frequency.
f16081:m3
def time_from_frequencyseries(htilde, sample_frequencies=None,<EOL>discont_threshold=<NUM_LIT>*numpy.pi):
if sample_frequencies is None:<EOL><INDENT>sample_frequencies = htilde.sample_frequencies.numpy()<EOL><DEDENT>phase = phase_from_frequencyseries(htilde).data<EOL>dphi = numpy.diff(phase)<EOL>time = -dphi / (<NUM_LIT>*numpy.pi*numpy.diff(sample_frequencies))<EOL>nzidx = numpy.nonzero(abs(htilde.data))[<NUM_LIT:0>]<EOL>k...
Computes time as a function of frequency from the given frequency-domain waveform. This assumes the stationary phase approximation. Any frequencies lower than the first non-zero value in htilde are assigned the time at the first non-zero value. Times for any frequencies above the next-to-last non-zero v...
f16081:m4
def phase_from_polarizations(h_plus, h_cross, remove_start_phase=True):
p = numpy.unwrap(numpy.arctan2(h_cross.data, h_plus.data)).astype(<EOL>real_same_precision_as(h_plus))<EOL>if remove_start_phase:<EOL><INDENT>p += -p[<NUM_LIT:0>]<EOL><DEDENT>return TimeSeries(p, delta_t=h_plus.delta_t, epoch=h_plus.start_time,<EOL>copy=False)<EOL>
Return gravitational wave phase Return the gravitation-wave phase from the h_plus and h_cross polarizations of the waveform. The returned phase is always positive and increasing with an initial phase of 0. Parameters ---------- h_plus : TimeSeries An PyCBC TmeSeries vector that contain...
f16081:m5
def amplitude_from_polarizations(h_plus, h_cross):
amp = (h_plus.squared_norm() + h_cross.squared_norm()) ** (<NUM_LIT:0.5>)<EOL>return TimeSeries(amp, delta_t=h_plus.delta_t, epoch=h_plus.start_time)<EOL>
Return gravitational wave amplitude Return the gravitation-wave amplitude from the h_plus and h_cross polarizations of the waveform. Parameters ---------- h_plus : TimeSeries An PyCBC TmeSeries vector that contains the plus polarization of the gravitational waveform. h_cross : ...
f16081:m6
def frequency_from_polarizations(h_plus, h_cross):
phase = phase_from_polarizations(h_plus, h_cross)<EOL>freq = numpy.diff(phase) / ( <NUM_LIT:2> * lal.PI * phase.delta_t )<EOL>start_time = phase.start_time + phase.delta_t / <NUM_LIT:2><EOL>return TimeSeries(freq.astype(real_same_precision_as(h_plus)),<EOL>delta_t=phase.delta_t, epoch=start_time)<EOL>
Return gravitational wave frequency Return the gravitation-wave frequency as a function of time from the h_plus and h_cross polarizations of the waveform. It is 1 bin shorter than the input vectors and the sample times are advanced half a bin. Parameters ---------- h_plus : TimeSeries ...
f16081:m7
def taper_timeseries(tsdata, tapermethod=None, return_lal=False):
if tapermethod is None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if tapermethod not in taper_map.keys():<EOL><INDENT>raise ValueError("<STR_LIT>" %(tapermethod, "<STR_LIT:U+002CU+0020>".join(taper_map.keys())))<EOL><DEDENT>if tsdata.dtype not in (float32, float64):<EOL><INDENT>raise TypeErr...
Taper either or both ends of a time series using wrapped LALSimulation functions Parameters ---------- tsdata : TimeSeries Series to be tapered, dtype must be either float32 or float64 tapermethod : string Should be one of ('TAPER_NONE', 'TAPER_START', 'TAPER_END', 'TAPER_STARTEND', 'start', 'end', 'starte...
f16081:m8
@schemed("<STR_LIT>")<EOL>def apply_fseries_time_shift(htilde, dt, kmin=<NUM_LIT:0>, copy=True):
Shifts a frequency domain waveform in time. The waveform is assumed to be sampled at equal frequency intervals.
f16081:m9
def apply_fd_time_shift(htilde, shifttime, kmin=<NUM_LIT:0>, fseries=None, copy=True):
dt = float(shifttime - htilde.epoch)<EOL>if dt == <NUM_LIT:0.>:<EOL><INDENT>if copy:<EOL><INDENT>htilde = <NUM_LIT:1.> * htilde<EOL><DEDENT><DEDENT>elif isinstance(htilde, FrequencySeries):<EOL><INDENT>htilde = apply_fseries_time_shift(htilde, dt, kmin=kmin, copy=copy)<EOL><DEDENT>else:<EOL><INDENT>if fseries is None:<...
Shifts a frequency domain waveform in time. The shift applied is shiftime - htilde.epoch. Parameters ---------- htilde : FrequencySeries The waveform frequency series. shifttime : float The time to shift the frequency series to. kmin : {0, int} The starting index of htil...
f16081:m10
def td_taper(out, start, end, beta=<NUM_LIT:8>, side='<STR_LIT:left>'):
out = out.copy()<EOL>width = end - start<EOL>winlen = <NUM_LIT:2> * int(width / out.delta_t)<EOL>window = Array(signal.get_window(('<STR_LIT>', beta), winlen))<EOL>xmin = int((start - out.start_time) / out.delta_t)<EOL>xmax = xmin + winlen//<NUM_LIT:2><EOL>if side == '<STR_LIT:left>':<EOL><INDENT>out[xmin:xmax] *= wind...
Applies a taper to the given TimeSeries. A half-kaiser window is used for the roll-off. Parameters ---------- out : TimeSeries The ``TimeSeries`` to taper. start : float The time (in s) to start the taper window. end : float The time (in s) to end the taper window. ...
f16081:m11
def fd_taper(out, start, end, beta=<NUM_LIT:8>, side='<STR_LIT:left>'):
out = out.copy()<EOL>width = end - start<EOL>winlen = <NUM_LIT:2> * int(width / out.delta_f)<EOL>window = Array(signal.get_window(('<STR_LIT>', beta), winlen))<EOL>kmin = int(start / out.delta_f)<EOL>kmax = kmin + winlen//<NUM_LIT:2><EOL>if side == '<STR_LIT:left>':<EOL><INDENT>out[kmin:kmax] *= window[:winlen//<NUM_LI...
Applies a taper to the given FrequencySeries. A half-kaiser window is used for the roll-off. Parameters ---------- out : FrequencySeries The ``FrequencySeries`` to taper. start : float The frequency (in Hz) to start the taper window. end : float The frequency (in Hz) to...
f16081:m12
def fd_to_td(htilde, delta_t=None, left_window=None, right_window=None,<EOL>left_beta=<NUM_LIT:8>, right_beta=<NUM_LIT:8>):
if left_window is not None:<EOL><INDENT>start, end = left_window<EOL>htilde = fd_taper(htilde, start, end, side='<STR_LIT:left>', beta=left_beta)<EOL><DEDENT>if right_window is not None:<EOL><INDENT>start, end = right_window<EOL>htilde = fd_taper(htilde, start, end, side='<STR_LIT:right>', beta=right_beta)<EOL><DEDENT>...
Converts a FD waveform to TD. A window can optionally be applied using ``fd_taper`` to the left or right side of the waveform before being converted to the time domain. Parameters ---------- htilde : FrequencySeries The waveform to convert. delta_t : float, optional Make the re...
f16081:m13
def FinalSpin( Xi, eta ):
s4 = -<NUM_LIT><EOL>s5 = -<NUM_LIT><EOL>t0 = -<NUM_LIT><EOL>t2 = -<NUM_LIT><EOL>t3 = <NUM_LIT><EOL>etaXi = eta * Xi<EOL>eta2 = eta*eta<EOL>finspin = (Xi + s4*Xi*etaXi + s5*etaXi*eta + t0*etaXi + <NUM_LIT>*(<NUM_LIT>**<NUM_LIT:0.5>)*eta + t2*eta2 + t3*eta2*eta)<EOL>if finspin > <NUM_LIT:1.0>:<EOL><INDENT>raise ValueErro...
Computes the spin of the final BH that gets formed after merger. This is done usingn Eq 5-6 of arXiv:0710.3345
f16082:m0
def fRD( a, M):
f = (lal.C_SI**<NUM_LIT> / (<NUM_LIT>*lal.PI*lal.G_SI*M*lal.MSUN_SI)) * (<NUM_LIT> - <NUM_LIT>*(<NUM_LIT:1.0>-a)**<NUM_LIT>)<EOL>return f<EOL>
Calculate the ring-down frequency for the final Kerr BH. Using Eq. 5.5 of Main paper
f16082:m1
def Qa( a ):
return (<NUM_LIT> + <NUM_LIT>*(<NUM_LIT:1.0>-a)**-<NUM_LIT>)<EOL>
Calculate the quality factor of ring-down, using Eq 5.6 of Main paper
f16082:m2
def imrphenomc_tmplt(**kwds):
<EOL>f_min = float128(kwds['<STR_LIT>'])<EOL>f_max = float128(kwds['<STR_LIT>'])<EOL>delta_f = float128(kwds['<STR_LIT>'])<EOL>distance = float128(kwds['<STR_LIT>'])<EOL>mass1 = float128(kwds['<STR_LIT>'])<EOL>mass2 = float128(kwds['<STR_LIT>'])<EOL>spin1z = float128(kwds['<STR_LIT>'])<EOL>spin2z = float128(kwds['<STR_...
Return an IMRPhenomC waveform using CUDA to generate the phase and amplitude Main Paper: arXiv:1005.3306
f16082:m3
def sigma_cached(self, psd):
if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>from pycbc.opt import LimitedSizeDict<EOL>self._sigmasq = LimitedSizeDict(size_limit=<NUM_LIT:2>**<NUM_LIT:5>)<EOL><DEDENT>key = id(psd)<EOL>if not hasattr(psd, '<STR_LIT>'):<EOL><INDENT>psd._sigma_cached_key = {}<EOL><DEDENT>if key not in self._sigmasq or id(self) not in ...
Cache sigma calculate for use in tandem with the FilterBank class
f16083:m0
def boolargs_from_apprxstr(approximant_strs):
if not isinstance(approximant_strs, list):<EOL><INDENT>approximant_strs = [approximant_strs]<EOL><DEDENT>return [tuple(arg.split('<STR_LIT::>')) for arg in approximant_strs]<EOL>
Parses a list of strings specifying an approximant and where that approximant should be used into a list that can be understood by FieldArray.parse_boolargs. Parameters ---------- apprxstr : (list of) string(s) The strings to parse. Each string should be formatted `APPRX:COND`, wher...
f16083:m1
def add_approximant_arg(parser, default=None, help=None):
if help is None:<EOL><INDENT>help=str("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>...
Adds an approximant argument to the given parser. Parameters ---------- parser : ArgumentParser The argument parser to add the argument to. default : {None, str} Specify a default for the approximant argument. Defaults to None. help : {None, str} Provide a custom help messag...
f16083:m2
def parse_approximant_arg(approximant_arg, warray):
return warray.parse_boolargs(boolargs_from_apprxstr(approximant_arg))[<NUM_LIT:0>]<EOL>
Given an approximant arg (see add_approximant_arg) and a field array, figures out what approximant to use for each template in the array. Parameters ---------- approximant_arg : list The approximant argument to parse. Should be the thing returned by ArgumentParser when parsing the argum...
f16083:m3
def find_variable_start_frequency(approximant, parameters, f_start, max_length,<EOL>delta_f = <NUM_LIT:1>):
l = max_length + <NUM_LIT:1><EOL>f = f_start - delta_f<EOL>while l > max_length:<EOL><INDENT>f += delta_f<EOL>l = pycbc.waveform.get_waveform_filter_length_in_time(approximant,<EOL>parameters, f_lower=f)<EOL><DEDENT>return f<EOL>
Find a frequency value above the starting frequency that results in a waveform shorter than max_length.
f16083:m4
def ensure_hash(self):
fields = self.table.fieldnames<EOL>if '<STR_LIT>' in fields:<EOL><INDENT>return<EOL><DEDENT>hash_fields = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',]<EOL>fields = [f for f in hash_fields if f in fields]<EOL>template_hash = np.array([hash...
Ensure that there is a correctly populated template_hash. Check for a correctly populated template_hash and create if it doesn't already exist.
f16083:c1:m2
def write_to_hdf(self, filename, start_index=None, stop_index=None,<EOL>force=False, skip_fields=None,<EOL>write_compressed_waveforms=True):
if not filename.endswith('<STR_LIT>'):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if os.path.exists(filename) and not force:<EOL><INDENT>raise IOError("<STR_LIT>" %(filename))<EOL><DEDENT>f = h5py.File(filename, '<STR_LIT:w>')<EOL>parameters = self.parameters<EOL>if skip_fields is not None:<EOL><INDENT>if no...
Writes self to the given hdf file. Parameters ---------- filename : str The name of the file to write to. Must end in '.hdf'. start_index : If a specific slice of the template bank is to be written to the hdf file, this would specify the index of the ...
f16083:c1:m3
def end_frequency(self, index):
from pycbc.waveform.waveform import props<EOL>return pycbc.waveform.get_waveform_end_frequency(<EOL>self.table[index],<EOL>approximant=self.approximant(index),<EOL>**self.extra_args)<EOL>
Return the end frequency of the waveform at the given index value
f16083:c1:m4
def parse_approximant(self, approximant):
return parse_approximant_arg(approximant, self.table)<EOL>
Parses the given approximant argument, returning the approximant to use for each template in self. This is done by calling `parse_approximant_arg` using self's table as the array; see that function for more details.
f16083:c1:m5
def approximant(self, index):
if '<STR_LIT>' not in self.table.fieldnames:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>return self.table["<STR_LIT>"][index]<EOL>
Return the name of the approximant ot use at the given index
f16083:c1:m6
def template_thinning(self, inj_filter_rejector):
if not inj_filter_rejector.enabled orinj_filter_rejector.chirp_time_window is None:<EOL><INDENT>return<EOL><DEDENT>injection_parameters = inj_filter_rejector.injection_params.table<EOL>fref = inj_filter_rejector.f_lower<EOL>threshold = inj_filter_rejector.chirp_time_window<EOL>m1= self.table['<STR_LIT>']<EOL>m2= self.t...
Remove templates from bank that are far from all injections.
f16083:c1:m8
def ensure_standard_filter_columns(self, low_frequency_cutoff=None):
<EOL>if not hasattr(self.table, '<STR_LIT>'):<EOL><INDENT>self.table = self.table.add_fields(np.zeros(len(self.table),<EOL>dtype=np.float32), '<STR_LIT>')<EOL><DEDENT>if low_frequency_cutoff is not None:<EOL><INDENT>if not hasattr(self.table, '<STR_LIT>'):<EOL><INDENT>vec = np.zeros(len(self.table), dtype=np.float32)<E...
Initialize FilterBank common fields Parameters ---------- low_frequency_cutoff: {float, None}, Optional A low frequency cutoff which overrides any given within the template bank file.
f16083:c1:m9
def round_up(self, num):
inc = self.increment<EOL>size = np.ceil(num / self.sample_rate / inc) * self.sample_rate * inc<EOL>return size<EOL>
Determine the length to use for this waveform by rounding. Parameters ---------- num : int Proposed size of waveform in seconds Returns ------- size: int The rounded size to use for the waveform buffer in seconds. This is calculaed using ...
f16083:c2:m1
def id_from_hash(self, hash_value):
return self.hash_lookup[hash_value]<EOL>
Get the index of this template based on its hash value Parameters ---------- hash : int Value of the template hash Returns -------- index : int The ordered index that this template has in the template bank.
f16083:c2:m3
def get_decompressed_waveform(self, tempout, index, f_lower=None,<EOL>approximant=None, df=None):
from pycbc.waveform.waveform import props<EOL>from pycbc.waveform import get_waveform_filter_length_in_time<EOL>tmplt_hash = self.table.template_hash[index]<EOL>compressed_waveform = pycbc.waveform.compress.CompressedWaveform.from_hdf(<EOL>self.filehandler, tmplt_hash,<EOL>load_now=True)<EOL>if self.waveform_decompress...
Returns a frequency domain decompressed waveform for the template in the bank corresponding to the index taken in as an argument. The decompressed waveform is obtained by interpolating in frequency space, the amplitude and phase points for the compressed template that are read in from th...
f16083:c3:m1
def generate_with_delta_f_and_max_freq(self, t_num, max_freq, delta_f,<EOL>low_frequency_cutoff=None,<EOL>cached_mem=None):
approximant = self.approximant(t_num)<EOL>if approximant.endswith('<STR_LIT>'):<EOL><INDENT>approximant = approximant.replace('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>if approximant == '<STR_LIT>':<EOL><INDENT>approximant = '<STR_LIT>'<EOL><DEDENT>if cached_mem is None:<EOL><INDENT>wav_len = int(max_freq / delta_f) + <NUM...
Generate the template with index t_num using custom length.
f16083:c3:m2
def props(obj, required, **kwargs):
<EOL>pr = get_obj_attrs(obj)<EOL>input_params = default_qnm_args.copy()<EOL>input_params.update(pr)<EOL>input_params.update(kwargs)<EOL>for arg in required:<EOL><INDENT>if arg not in input_params:<EOL><INDENT>raise ValueError('<STR_LIT>' + str(arg))<EOL><DEDENT><DEDENT>return input_params<EOL>
Return a dictionary built from the combination of defaults, kwargs, and the attributes of the given object.
f16084:m0
def lm_amps_phases(**kwargs):
l, m = kwargs['<STR_LIT:l>'], kwargs['<STR_LIT:m>']<EOL>amps, phis = {}, {}<EOL>try:<EOL><INDENT>amps['<STR_LIT>'] = kwargs['<STR_LIT>']<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>for n in range(kwargs['<STR_LIT>']):<EOL><INDENT>if (l, m, n) != (<NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT...
Take input_params and return dictionaries with amplitudes and phases of each overtone of a specific lm mode, checking that all of them are given.
f16084:m1
def lm_freqs_taus(**kwargs):
lmns = kwargs['<STR_LIT>']<EOL>freqs, taus = {}, {}<EOL>for lmn in lmns:<EOL><INDENT>l, m, nmodes = int(lmn[<NUM_LIT:0>]), int(lmn[<NUM_LIT:1>]), int(lmn[<NUM_LIT:2>])<EOL>for n in range(nmodes):<EOL><INDENT>try:<EOL><INDENT>freqs['<STR_LIT>' %(l,m,n)] = kwargs['<STR_LIT>' %(l,m,n)]<EOL><DEDENT>except KeyError:<EOL><IN...
Take input_params and return dictionaries with frequencies and damping times of each overtone of a specific lm mode, checking that all of them are given.
f16084:m2
def qnm_time_decay(tau, decay):
return - tau * numpy.log(decay)<EOL>
Return the time at which the amplitude of the ringdown falls to decay of the peak amplitude. Parameters ---------- tau : float The damping time of the sinusoid. decay: float The fraction of the peak amplitude. Returns ------- t_decay: float The time at which the...
f16084:m3
def qnm_freq_decay(f_0, tau, decay):
q_0 = pi * f_0 * tau<EOL>alpha = <NUM_LIT:1.> / decay<EOL>alpha_sq = <NUM_LIT:1.> / decay / decay<EOL>q_sq = (alpha_sq + <NUM_LIT:4>*q_0*q_0 + alpha*numpy.sqrt(alpha_sq + <NUM_LIT:16>*q_0*q_0)) / <NUM_LIT><EOL>return numpy.sqrt(q_sq) / pi / tau<EOL>
Return the frequency at which the amplitude of the ringdown falls to decay of the peak amplitude. Parameters ---------- f_0 : float The ringdown-frequency, which gives the peak amplitude. tau : float The damping time of the sinusoid. decay: float The fraction of the peak...
f16084:m4
def lm_tfinal(damping_times, modes):
t_max = {}<EOL>for lmn in modes:<EOL><INDENT>l, m, nmodes = int(lmn[<NUM_LIT:0>]), int(lmn[<NUM_LIT:1>]), int(lmn[<NUM_LIT:2>])<EOL>for n in range(nmodes):<EOL><INDENT>t_max['<STR_LIT>' %(l,m,n)] =qnm_time_decay(damping_times['<STR_LIT>' %(l,m,n)], <NUM_LIT:1.>/<NUM_LIT:1000>)<EOL><DEDENT><DEDENT>return max(t_max.value...
Return the maximum t_final of the modes given, with t_final the time at which the amplitude falls to 1/1000 of the peak amplitude
f16084:m5
def lm_deltat(freqs, damping_times, modes):
dt = {}<EOL>for lmn in modes:<EOL><INDENT>l, m, nmodes = int(lmn[<NUM_LIT:0>]), int(lmn[<NUM_LIT:1>]), int(lmn[<NUM_LIT:2>])<EOL>for n in range(nmodes):<EOL><INDENT>dt['<STR_LIT>' %(l,m,n)] = <NUM_LIT:1.> / qnm_freq_decay(freqs['<STR_LIT>' %(l,m,n)],<EOL>damping_times['<STR_LIT>' %(l,m,n)], <NUM_LIT:1.>/<NUM_LIT:1000>)...
Return the minimum delta_t of all the modes given, with delta_t given by the inverse of the frequency at which the amplitude of the ringdown falls to 1/1000 of the peak amplitude.
f16084:m6
def lm_ffinal(freqs, damping_times, modes):
f_max = {}<EOL>for lmn in modes:<EOL><INDENT>l, m, nmodes = int(lmn[<NUM_LIT:0>]), int(lmn[<NUM_LIT:1>]), int(lmn[<NUM_LIT:2>])<EOL>for n in range(nmodes):<EOL><INDENT>f_max['<STR_LIT>' %(l,m,n)] = qnm_freq_decay(freqs['<STR_LIT>' %(l,m,n)],<EOL>damping_times['<STR_LIT>' %(l,m,n)], <NUM_LIT:1.>/<NUM_LIT:1000>)<EOL><DED...
Return the maximum f_final of the modes given, with f_final the frequency at which the amplitude falls to 1/1000 of the peak amplitude
f16084:m7
def lm_deltaf(damping_times, modes):
df = {}<EOL>for lmn in modes:<EOL><INDENT>l, m, nmodes = int(lmn[<NUM_LIT:0>]), int(lmn[<NUM_LIT:1>]), int(lmn[<NUM_LIT:2>])<EOL>for n in range(nmodes):<EOL><INDENT>df['<STR_LIT>' %(l,m,n)] =<NUM_LIT:1.> / qnm_time_decay(damping_times['<STR_LIT>' %(l,m,n)], <NUM_LIT:1.>/<NUM_LIT:1000>)<EOL><DEDENT><DEDENT>return min(df...
Return the minimum delta_f of all the modes given, with delta_f given by the inverse of the time at which the amplitude of the ringdown falls to 1/1000 of the peak amplitude.
f16084:m8
def spher_harms(l, m, inclination):
<EOL>Y_lm = lal.SpinWeightedSphericalHarmonic(inclination, <NUM_LIT:0.>, -<NUM_LIT:2>, l, m).real<EOL>Y_lminusm = lal.SpinWeightedSphericalHarmonic(inclination, <NUM_LIT:0.>, -<NUM_LIT:2>, l, -m).real<EOL>Y_plus = Y_lm + (-<NUM_LIT:1>)**l * Y_lminusm<EOL>Y_cross = Y_lm - (-<NUM_LIT:1>)**l * Y_lminusm<EOL>return Y_plus,...
Return spherical harmonic polarizations
f16084:m9
def Kerr_factor(final_mass, distance):
<EOL>mass = final_mass * lal.MSUN_SI * lal.G_SI / lal.C_SI**<NUM_LIT:2><EOL>dist = distance * <NUM_LIT> * lal.PC_SI<EOL>return mass / dist<EOL>
Return the factor final_mass/distance (in dimensionless units) for Kerr ringdowns
f16084:m10
def apply_taper(delta_t, taper, f_0, tau, amp, phi, l, m, inclination):
<EOL>taper_times = -numpy.arange(<NUM_LIT:1>, int(taper*tau/delta_t))[::-<NUM_LIT:1>] * delta_t<EOL>Y_plus, Y_cross = spher_harms(l, m, inclination)<EOL>taper_hp = amp * Y_plus * numpy.exp(<NUM_LIT:10>*taper_times/tau) *numpy.cos(two_pi*f_0*taper_times + phi)<EOL>taper_hc = amp * Y_cross * numpy.exp(<NUM_LIT:10>*taper_...
Return tapering window.
f16084:m11
def taper_shift(waveform, output):
if len(waveform) == len(output):<EOL><INDENT>output.data += waveform.data<EOL><DEDENT>else:<EOL><INDENT>output.data[len(output)-len(waveform):] += waveform.data<EOL><DEDENT>return output<EOL>
Add waveform to output with waveform shifted accordingly (for tapering multi-mode ringdowns)
f16084:m12
def get_td_qnm(template=None, taper=None, **kwargs):
input_params = props(template, qnm_required_args, **kwargs)<EOL>f_0 = input_params.pop('<STR_LIT>')<EOL>tau = input_params.pop('<STR_LIT>')<EOL>amp = input_params.pop('<STR_LIT>')<EOL>phi = input_params.pop('<STR_LIT>')<EOL>inc = input_params.pop('<STR_LIT>', None)<EOL>l = input_params.pop('<STR_LIT:l>', <NUM_LIT:2>)<E...
Return a time domain damped sinusoid. Parameters ---------- template: object An object that has attached properties. This can be used to substitute for keyword arguments. A common example would be a row in an xml table. taper: {None, float}, optional Tapering at the beginning of...
f16084:m13
def get_fd_qnm(template=None, **kwargs):
input_params = props(template, qnm_required_args, **kwargs)<EOL>f_0 = input_params.pop('<STR_LIT>')<EOL>tau = input_params.pop('<STR_LIT>')<EOL>amp = input_params.pop('<STR_LIT>')<EOL>phi = input_params.pop('<STR_LIT>')<EOL>t_0 = input_params.pop('<STR_LIT>')<EOL>inc = input_params.pop('<STR_LIT>', None)<EOL>l = input_...
Return a frequency domain damped sinusoid. Parameters ---------- template: object An object that has attached properties. This can be used to substitute for keyword arguments. A common example would be a row in an xml table. f_0 : float The ringdown-frequency. tau : float ...
f16084:m14
def get_td_lm(template=None, taper=None, **kwargs):
input_params = props(template, lm_required_args, **kwargs)<EOL>amps, phis = lm_amps_phases(**input_params)<EOL>f_0 = input_params.pop('<STR_LIT>')<EOL>tau = input_params.pop('<STR_LIT>')<EOL>inc = input_params.pop('<STR_LIT>', None)<EOL>l, m = input_params.pop('<STR_LIT:l>'), input_params.pop('<STR_LIT:m>')<EOL>nmodes ...
Return time domain lm mode with the given number of overtones. Parameters ---------- template: object An object that has attached properties. This can be used to substitute for keyword arguments. A common example would be a row in an xml table. taper: {None, float}, optional Tap...
f16084:m15
def get_fd_lm(template=None, **kwargs):
input_params = props(template, lm_required_args, **kwargs)<EOL>amps, phis = lm_amps_phases(**input_params)<EOL>f_0 = input_params.pop('<STR_LIT>')<EOL>tau = input_params.pop('<STR_LIT>')<EOL>l, m = input_params.pop('<STR_LIT:l>'), input_params.pop('<STR_LIT:m>')<EOL>inc = input_params.pop('<STR_LIT>', None)<EOL>nmodes ...
Return frequency domain lm mode with a given number of overtones. Parameters ---------- template: object An object that has attached properties. This can be used to substitute for keyword arguments. A common example would be a row in an xml table. freqs : dict {lmn:f_lmn} Dictio...
f16084:m16
def get_td_from_final_mass_spin(template=None, taper=None,<EOL>distance=None, **kwargs):
input_params = props(template, mass_spin_required_args, **kwargs)<EOL>final_mass = input_params['<STR_LIT>']<EOL>final_spin = input_params['<STR_LIT>']<EOL>lmns = input_params['<STR_LIT>']<EOL>for lmn in lmns:<EOL><INDENT>if int(lmn[<NUM_LIT:2>]) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')...
Return time domain ringdown with all the modes specified. Parameters ---------- template: object An object that has attached properties. This can be used to substitute for keyword arguments. A common example would be a row in an xml table. taper: {None, float}, optional Tapering...
f16084:m17
def get_fd_from_final_mass_spin(template=None, distance=None, **kwargs):
input_params = props(template, mass_spin_required_args, **kwargs)<EOL>final_mass = input_params['<STR_LIT>']<EOL>final_spin = input_params['<STR_LIT>']<EOL>lmns = input_params['<STR_LIT>']<EOL>for lmn in lmns:<EOL><INDENT>if int(lmn[<NUM_LIT:2>]) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')...
Return frequency domain ringdown with all the modes specified. Parameters ---------- template: object An object that has attached properties. This can be used to substitute for keyword arguments. A common example would be a row in an xml table. distance : {None, float}, optional ...
f16084:m18
def get_td_from_freqtau(template=None, taper=None, **kwargs):
input_params = props(template, freqtau_required_args, **kwargs)<EOL>f_0, tau = lm_freqs_taus(**input_params)<EOL>lmns = input_params['<STR_LIT>']<EOL>for lmn in lmns:<EOL><INDENT>if int(lmn[<NUM_LIT:2>]) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>inc = input_params.pop...
Return time domain ringdown with all the modes specified. Parameters ---------- template: object An object that has attached properties. This can be used to substitute for keyword arguments. A common example would be a row in an xml table. taper: {None, float}, optional Tapering...
f16084:m19
def get_fd_from_freqtau(template=None, **kwargs):
input_params = props(template, freqtau_required_args, **kwargs)<EOL>f_0, tau = lm_freqs_taus(**input_params)<EOL>lmns = input_params['<STR_LIT>']<EOL>for lmn in lmns:<EOL><INDENT>if int(lmn[<NUM_LIT:2>]) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>inc = input_params.pop...
Return frequency domain ringdown with all the modes specified. Parameters ---------- template: object An object that has attached properties. This can be used to substitute for keyword arguments. A common example would be a row in an xml table. lmns : list Desired lmn modes as s...
f16084:m20
def docstr(self, prefix='<STR_LIT>', include_label=True):
outstr = "<STR_LIT>" %(prefix, self.name, str(self.default),<EOL>str(self.dtype).replace("<STR_LIT>", '<STR_LIT>').replace("<STR_LIT>", '<STR_LIT>')) +"<STR_LIT>" %(prefix, self.description)<EOL>if include_label:<EOL><INDENT>outstr += "<STR_LIT>" %(self.label)<EOL><DEDENT>return outstr<EOL>
Returns a string summarizing the parameter. Format is: <prefix>``name`` : {``default``, ``dtype``} <prefix> ``description`` Label: ``label``.
f16085:c0:m1
@property<EOL><INDENT>def names(self):<DEDENT>
return [x.name for x in self]<EOL>
Returns a list of the names of each parameter.
f16085:c1:m0
@property<EOL><INDENT>def aslist(self):<DEDENT>
return list(self)<EOL>
Cast to basic list.
f16085:c1:m1
@property<EOL><INDENT>def asdict(self):<DEDENT>
return dict([[x, x] for x in self])<EOL>
Returns a dictionary of the parameters keyed by the parameters.
f16085:c1:m2
def defaults(self):
return [(x, x.default) for x in self]<EOL>
Returns a list of the name and default value of each parameter, as tuples.
f16085:c1:m3
def default_dict(self):
return OrderedDict(self.defaults())<EOL>
Returns a dictionary of the name and default value of each parameter.
f16085:c1:m4
@property<EOL><INDENT>def nodefaults(self):<DEDENT>
return ParameterList([x for x in self if x.default is None])<EOL>
Returns a ParameterList of the parameters that have None for defaults.
f16085:c1:m5
@property<EOL><INDENT>def dtypes(self):<DEDENT>
return [(x, x.dtype) for x in self]<EOL>
Returns a list of the name and dtype of each parameter, as tuples.
f16085:c1:m6
@property<EOL><INDENT>def dtype_dict(self):<DEDENT>
return OrderedDict(self.dtypes)<EOL>
Returns a dictionary of the name and dtype of each parameter.
f16085:c1:m7
@property<EOL><INDENT>def descriptions(self):<DEDENT>
return [(x, x.description) for x in self]<EOL>
Returns a list of the name and description of each parameter, as tuples.
f16085:c1:m8
@property<EOL><INDENT>def description_dict(self):<DEDENT>
return OrderedDict(self.descriptions)<EOL>
Return a dictionary of the name and description of each parameter.
f16085:c1:m9
@property<EOL><INDENT>def labels(self):<DEDENT>
return [(x, x.label) for x in self]<EOL>
Returns a list of each parameter and its label, as tuples.
f16085:c1:m10
@property<EOL><INDENT>def label_dict(self):<DEDENT>
return OrderedDict(self.labels)<EOL>
Return a dictionary of the name and label of each parameter.
f16085:c1:m11
def docstr(self, prefix='<STR_LIT>', include_label=True):
return '<STR_LIT:\n>'.join([x.docstr(prefix, include_label) for x in self])<EOL>
Returns the ``docstr`` of each parameter joined together.
f16085:c1:m12
def insert_injfilterrejector_option_group(parser):
injfilterrejector_group =parser.add_argument_group(_injfilterrejector_group_help)<EOL>curr_arg = "<STR_LIT>"<EOL>injfilterrejector_group.add_argument(curr_arg, type=float, default=None,<EOL>help=_injfilterer_cthresh_help)<EOL>curr_arg = "<STR_LIT>"<EOL>injfilterrejector_group.add_argument(curr_arg, type=float, default=...
Add options for injfilterrejector to executable.
f16086:m0
def __init__(self, injection_file, chirp_time_window,<EOL>match_threshold, f_lower, coarsematch_deltaf=<NUM_LIT:1.>,<EOL>coarsematch_fmax=<NUM_LIT>, seg_buffer=<NUM_LIT:10>):
<EOL>if injection_file is None or injection_file == '<STR_LIT:False>' or(chirp_time_window is None and match_threshold is None):<EOL><INDENT>self.enabled = False<EOL>return<EOL><DEDENT>else:<EOL><INDENT>self.enabled = True<EOL><DEDENT>self.chirp_time_window = chirp_time_window<EOL>self.match_threshold = match_threshold...
Initialise InjFilterRejector instance.
f16086:c0:m0
@classmethod<EOL><INDENT>def from_cli(cls, opt):<DEDENT>
injection_file = opt.injection_file<EOL>chirp_time_window =opt.injection_filter_rejector_chirp_time_window<EOL>match_threshold = opt.injection_filter_rejector_match_threshold<EOL>coarsematch_deltaf = opt.injection_filter_rejector_coarsematch_deltaf<EOL>coarsematch_fmax = opt.injection_filter_rejector_coarsematch_fmax<E...
Create an InjFilterRejector instance from command-line options.
f16086:c0:m1
def generate_short_inj_from_inj(self, inj_waveform, simulation_id):
if not self.enabled:<EOL><INDENT>return<EOL><DEDENT>if simulation_id in self.short_injections:<EOL><INDENT>err_msg = "<STR_LIT>"<EOL>err_msg += str(simulation_id)<EOL>err_msg += "<STR_LIT>"<EOL>err_msg += "<STR_LIT>"<EOL>err_msg += "<STR_LIT>"<EOL>raise ValueError(err_msg)<EOL><DEDENT>curr_length = len(inj_waveform)<EO...
Generate and a store a truncated representation of inj_waveform.
f16086:c0:m2
def template_segment_checker(self, bank, t_num, segment, start_time):
if not self.enabled:<EOL><INDENT>return True<EOL><DEDENT>sample_rate = <NUM_LIT> * (len(segment) - <NUM_LIT:1>) * segment.delta_f<EOL>cum_ind = segment.cumulative_index<EOL>diff = segment.analyze.stop - segment.analyze.start<EOL>seg_start_time = cum_ind / sample_rate + start_time<EOL>seg_end_time = (cum_ind + diff) / s...
Test if injections in segment are worth filtering with template. Using the current template, current segment, and injections within that segment. Test if the injections and sufficiently "similar" to any of the injections to justify actually performing a matched-filter call. Ther are two...
f16086:c0:m3
def set_sim_data(inj, field, data):
try:<EOL><INDENT>sim_field = sim_inspiral_map[field]<EOL><DEDENT>except KeyError:<EOL><INDENT>sim_field = field<EOL><DEDENT>if sim_field == '<STR_LIT>':<EOL><INDENT>inj.geocent_end_time = int(data)<EOL>inj.geocent_end_time_ns = int(<NUM_LIT>*(data % <NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>setattr(inj, sim_field, da...
Sets data of a SimInspiral instance.
f16088:m0
def legacy_approximant_name(apx):
apx = str(apx)<EOL>try:<EOL><INDENT>order = sim.GetOrderFromString(apx)<EOL><DEDENT>except:<EOL><INDENT>print("<STR_LIT>")<EOL>order = -<NUM_LIT:1><EOL><DEDENT>name = sim.GetStringFromApproximant(sim.GetApproximantFromString(apx))<EOL>return name, order<EOL>
Convert the old style xml approximant name to a name and phase_order. Alex: I hate this function. Please delete this when we use Collin's new tables.
f16088:m1
def get_hdf_injtype(sim_file):
with h5py.File(sim_file, '<STR_LIT:r>') as fp:<EOL><INDENT>try:<EOL><INDENT>ftype = fp.attrs['<STR_LIT>']<EOL><DEDENT>except KeyError:<EOL><INDENT>ftype = CBCHDFInjectionSet.injtype<EOL><DEDENT><DEDENT>return hdfinjtypes[ftype]<EOL>
Gets the HDFInjectionSet class to use with the given file. This looks for the ``injtype`` in the given file's top level ``attrs``. If that attribute isn't set, will default to :py:class:`CBCHDFInjectionSet`. Parameters ---------- sim_file : str Name of the file. The file must already exist...
f16088:m2
def hdf_injtype_from_approximant(approximant):
retcls = None<EOL>for cls in hdfinjtypes.values():<EOL><INDENT>if approximant in cls.supported_approximants():<EOL><INDENT>retcls = cls<EOL><DEDENT><DEDENT>if retcls is None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>.format(approximant))<EOL><DEDENT>return retcls<EOL>
Gets the HDFInjectionSet class to use with the given approximant. Parameters ---------- approximant : str Name of the approximant. Returns ------- HDFInjectionSet : The type of HDFInjectionSet to use.
f16088:m3
def apply(self, strain, detector_name, f_lower=None, distance_scale=<NUM_LIT:1>,<EOL>simulation_ids=None, inj_filter_rejector=None):
if strain.dtype not in (float32, float64):<EOL><INDENT>raise TypeError("<STR_LIT>"+ str(strain.dtype))<EOL><DEDENT>lalstrain = strain.lal()<EOL>earth_travel_time = lal.REARTH_SI / lal.C_SI<EOL>t0 = float(strain.start_time) - earth_travel_time<EOL>t1 = float(strain.end_time) + earth_travel_time<EOL>add_injection = injec...
Add injections (as seen by a particular detector) to a time series. Parameters ---------- strain : TimeSeries Time series to inject signals into, of type float32 or float64. detector_name : string Name of the detector used for projecting injections. f_low...
f16088:c1:m1
def make_strain_from_inj_object(self, inj, delta_t, detector_name,<EOL>f_lower=None, distance_scale=<NUM_LIT:1>):
detector = Detector(detector_name)<EOL>if f_lower is None:<EOL><INDENT>f_l = inj.f_lower<EOL><DEDENT>else:<EOL><INDENT>f_l = f_lower<EOL><DEDENT>name, phase_order = legacy_approximant_name(inj.waveform)<EOL>hp, hc = get_td_waveform(<EOL>inj, approximant=name, delta_t=delta_t,<EOL>phase_order=phase_order,<EOL>f_lower=f_...
Make a h(t) strain time-series from an injection object as read from a sim_inspiral table, for example. Parameters ----------- inj : injection object The injection object to turn into a strain h(t). delta_t : float Sample rate to make injection at. ...
f16088:c1:m2
def end_times(self):
return [inj.get_time_geocent() for inj in self.table]<EOL>
Return the end times of all injections
f16088:c1:m3
@staticmethod<EOL><INDENT>def write(filename, samples, write_params=None, static_args=None):<DEDENT>
xmldoc = ligolw.Document()<EOL>xmldoc.appendChild(ligolw.LIGO_LW())<EOL>simtable = lsctables.New(lsctables.SimInspiralTable)<EOL>xmldoc.childNodes[<NUM_LIT:0>].appendChild(simtable)<EOL>if static_args is None:<EOL><INDENT>static_args = {}<EOL><DEDENT>if write_params is None:<EOL><INDENT>write_params = samples.fieldname...
Writes the injection samples to the given xml. Parameters ---------- filename : str The name of the file to write to. samples : io.FieldArray FieldArray of parameters. write_params : list, optional Only write the given parameter names. All giv...
f16088:c1:m4
@abstractmethod<EOL><INDENT>def apply(self, strain, detector_name, distance_scale=<NUM_LIT:1>,<EOL>simulation_ids=None, inj_filter_rejector=None,<EOL>**kwargs):<DEDENT>
pass<EOL>
Adds injections to a detector's time series.
f16088:c2:m1
@abstractmethod<EOL><INDENT>def make_strain_from_inj_object(self, inj, delta_t, detector_name,<EOL>distance_scale=<NUM_LIT:1>, **kwargs):<DEDENT>
pass<EOL>
Make a h(t) strain time-series from an injection object.
f16088:c2:m2
@abstractmethod<EOL><INDENT>def end_times(self):<DEDENT>
pass<EOL>
Return the end times of all injections
f16088:c2:m3
@abstractmethod<EOL><INDENT>def supported_approximants(self):<DEDENT>
pass<EOL>
Return a list of the supported approximants.
f16088:c2:m4
@classmethod<EOL><INDENT>def write(cls, filename, samples, write_params=None, static_args=None,<EOL>**metadata):<DEDENT>
with h5py.File(filename, '<STR_LIT:w>') as fp:<EOL><INDENT>if static_args is None:<EOL><INDENT>static_args = {}<EOL><DEDENT>fp.attrs["<STR_LIT>"] = static_args.keys()<EOL>fp.attrs['<STR_LIT>'] = cls.injtype<EOL>for key, val in metadata.items():<EOL><INDENT>fp.attrs[key] = val<EOL><DEDENT>if write_params is None:<EOL><I...
Writes the injection samples to the given hdf file. Parameters ---------- filename : str The name of the file to write to. samples : io.FieldArray FieldArray of parameters. write_params : list, optional Only write the given parameter names. Al...
f16088:c2:m5
def apply(self, strain, detector_name, f_lower=None, distance_scale=<NUM_LIT:1>,<EOL>simulation_ids=None, inj_filter_rejector=None):
if strain.dtype not in (float32, float64):<EOL><INDENT>raise TypeError("<STR_LIT>"+ str(strain.dtype))<EOL><DEDENT>lalstrain = strain.lal()<EOL>earth_travel_time = lal.REARTH_SI / lal.C_SI<EOL>t0 = float(strain.start_time) - earth_travel_time<EOL>t1 = float(strain.end_time) + earth_travel_time<EOL>add_injection = injec...
Add injections (as seen by a particular detector) to a time series. Parameters ---------- strain : TimeSeries Time series to inject signals into, of type float32 or float64. detector_name : string Name of the detector used for projecting injections. f_low...
f16088:c3:m0
def make_strain_from_inj_object(self, inj, delta_t, detector_name,<EOL>f_lower=None, distance_scale=<NUM_LIT:1>):
detector = Detector(detector_name)<EOL>if f_lower is None:<EOL><INDENT>f_l = inj.f_lower<EOL><DEDENT>else:<EOL><INDENT>f_l = f_lower<EOL><DEDENT>hp, hc = get_td_waveform(inj, delta_t=delta_t, f_lower=f_l,<EOL>**self.extra_args)<EOL>hp /= distance_scale<EOL>hc /= distance_scale<EOL>hp._epoch += inj.tc<EOL>hc._epoch += i...
Make a h(t) strain time-series from an injection object. Parameters ----------- inj : injection object The injection object to turn into a strain h(t). Can be any object which has waveform parameters as attributes, such as an element in a ``WaveformArray``. ...
f16088:c3:m1
def end_times(self):
return self.table.tc<EOL>
Return the end times of all injections
f16088:c3:m2
def apply(self, strain, detector_name, distance_scale=<NUM_LIT:1>,<EOL>simulation_ids=None, inj_filter_rejector=None):
if inj_filter_rejector is not None:<EOL><INDENT>raise NotImplementedError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if strain.dtype not in (float32, float64):<EOL><INDENT>raise TypeError("<STR_LIT>"+ str(strain.dtype))<EOL><DEDENT>lalstrain = strain.lal()<EOL>add_injection = injection_func_map[strain.dtype]<EOL>injectio...
Add injection (as seen by a particular detector) to a time series. Parameters ---------- strain : TimeSeries Time series to inject signals into, of type float32 or float64. detector_name : string Name of the detector used for projecting injections. distan...
f16088:c4:m0
def make_strain_from_inj_object(self, inj, delta_t, detector_name,<EOL>distance_scale=<NUM_LIT:1>):
detector = Detector(detector_name)<EOL>hp, hc = ringdown_td_approximants[inj['<STR_LIT>']](<EOL>inj, delta_t=delta_t, **self.extra_args)<EOL>hp._epoch += inj['<STR_LIT>']<EOL>hc._epoch += inj['<STR_LIT>']<EOL>if distance_scale != <NUM_LIT:1>:<EOL><INDENT>hp /= distance_scale<EOL>hc /= distance_scale<EOL><DEDENT>signal ...
Make a h(t) strain time-series from an injection object as read from an hdf file. Parameters ----------- inj : injection object The injection object to turn into a strain h(t). delta_t : float Sample rate to make injection at. detector_name : stri...
f16088:c4:m1
def end_times(self):
<EOL>tcs = self.table.tc<EOL>return tcs + <NUM_LIT:2><EOL>
Return the approximate end times of all injections. Currently, this just assumes all ringdowns are 2 seconds long.
f16088:c4:m2
@staticmethod<EOL><INDENT>def write(filename, samples, write_params=None, static_args=None,<EOL>injtype=None, **metadata):<DEDENT>
<EOL>ext = os.path.basename(filename)<EOL>if ext.endswith(('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')):<EOL><INDENT>_XMLInjectionSet.write(filename, samples, write_params,<EOL>static_args)<EOL><DEDENT>else:<EOL><INDENT>if injtype is None:<EOL><INDENT>if static_args is not None and '<STR_LIT>' in static_args:<EOL><INDENT>in...
Writes the injection samples to the given hdf file. Parameters ---------- filename : str The name of the file to write to. samples : io.FieldArray FieldArray of parameters. write_params : list, optional Only write the given parameter names. Al...
f16088:c5:m1
def apply(self, strain, detector_name, f_lower=None, distance_scale=<NUM_LIT:1>):
if strain.dtype not in (float32, float64):<EOL><INDENT>raise TypeError("<STR_LIT>"+ str(strain.dtype))<EOL><DEDENT>lalstrain = strain.lal()<EOL>earth_travel_time = lal.REARTH_SI / lal.C_SI<EOL>t0 = float(strain.start_time) - earth_travel_time<EOL>t1 = float(strain.end_time) + earth_travel_time<EOL>add_injection = injec...
Add injections (as seen by a particular detector) to a time series. Parameters ---------- strain : TimeSeries Time series to inject signals into, of type float32 or float64. detector_name : string Name of the detector used for projecting injections. f_low...
f16088:c6:m1