signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
@schemed("<STR_LIT>")<EOL>def threshold(series, value): | err_msg = "<STR_LIT>"<EOL>err_msg += "<STR_LIT>"<EOL>raise ValueError(err_msg)<EOL> | Return list of values and indices values over threshold in series. | f16066:m0 |
@schemed("<STR_LIT>")<EOL>def threshold_only(series, value): | err_msg = "<STR_LIT>"<EOL>err_msg += "<STR_LIT>"<EOL>raise ValueError(err_msg)<EOL> | Return list of values and indices whose values in series are
larger (in absolute value) than value | f16066:m1 |
@schemed("<STR_LIT>")<EOL>def threshold_and_cluster(series, threshold, window): | err_msg = "<STR_LIT>"<EOL>err_msg += "<STR_LIT>"<EOL>raise ValueError(err_msg)<EOL> | Return list of values and indices values over threshold in series. | f16066:m3 |
def findchirp_cluster_over_window(times, values, window_length): | assert window_length > <NUM_LIT:0>, '<STR_LIT>'<EOL>from weave import inline<EOL>indices = numpy.zeros(len(times), dtype=int)<EOL>tlen = len(times) <EOL>k = numpy.zeros(<NUM_LIT:1>, dtype=int)<EOL>absvalues = abs(values) <EOL>times = times.astype(int)<EOL>code = """<STR_LIT>"""<EOL>inline(code, ['<STR_LIT>', '<STR_LIT>... | Reduce the events by clustering over a window using
the FindChirp clustering algorithm
Parameters
-----------
indices: Array
The list of indices of the SNR values
snr: Array
The list of SNR value
window_size: int
The size of the window in integer samples. Must be positiv... | f16066:m5 |
def cluster_reduce(idx, snr, window_size): | ind = findchirp_cluster_over_window(idx, snr, window_size)<EOL>return idx.take(ind), snr.take(ind)<EOL> | Reduce the events by clustering over a window
Parameters
-----------
indices: Array
The list of indices of the SNR values
snr: Array
The list of SNR value
window_size: int
The size of the window in integer samples.
Returns
-------
indices: Array
The list... | f16066:m6 |
def threshold_and_cluster(self, threshold, window): | pass<EOL> | Threshold and cluster the memory specified at instantiation with the
threshold and window size specified at creation.
Parameters
-----------
threshold : float32
The minimum absolute value of the series given at object initialization
to return when thresholding and clustering.
window : uint32
The size (in number ... | f16066:c1:m0 |
@classmethod<EOL><INDENT>def from_multi_ifo_interface(cls, opt, ifo, column, column_types, **kwds):<DEDENT> | opt = copy.deepcopy(opt)<EOL>opt_dict = vars(opt)<EOL>for arg, value in opt_dict.items():<EOL><INDENT>if isinstance(value, dict):<EOL><INDENT>setattr(opt, arg, getattr(opt, arg)[ifo])<EOL><DEDENT><DEDENT>return cls(opt, column, column_types, **kwds)<EOL> | To use this for a single ifo from the multi ifo interface requires
some small fixing of the opt structure. This does that. As we edit the
opt structure the process_params table will not be correct. | f16066:c2:m1 |
def newsnr_threshold(self, threshold): | if not self.opt.chisq_bins:<EOL><INDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>remove = [i for i, e in enumerate(self.events) if<EOL>ranking.newsnr(abs(e['<STR_LIT>']), e['<STR_LIT>'] / e['<STR_LIT>'])<EOL>< threshold]<EOL>self.events = numpy.delete(self.events, remove)<EOL> | Remove events with newsnr smaller than given threshold | f16066:c2:m3 |
def add_template_events(self, columns, vectors): | <EOL>new_events = None<EOL>for v in vectors:<EOL><INDENT>if v is not None:<EOL><INDENT>new_events = numpy.zeros(len(v), dtype=self.event_dtype)<EOL>break<EOL><DEDENT><DEDENT>assert new_events is not None<EOL>new_events['<STR_LIT>'] = self.template_index<EOL>for c, v in zip(columns, vectors):<EOL><INDENT>if v is not Non... | Add a vector indexed | f16066:c2:m6 |
def cluster_template_events(self, tcolumn, column, window_size): | cvec = self.template_events[column]<EOL>tvec = self.template_events[tcolumn]<EOL>if window_size == <NUM_LIT:0>:<EOL><INDENT>indices = numpy.arange(len(tvec))<EOL><DEDENT>else:<EOL><INDENT>indices = findchirp_cluster_over_window(tvec, cvec, window_size)<EOL><DEDENT>self.template_events = numpy.take(self.template_events,... | Cluster the internal events over the named column | f16066:c2:m7 |
def save_performance(self, ncores, nfilters, ntemplates, run_time,<EOL>setup_time): | self.run_time = run_time<EOL>self.setup_time = setup_time<EOL>self.ncores = ncores<EOL>self.nfilters = nfilters<EOL>self.ntemplates = ntemplates<EOL>self.write_performance = True<EOL> | Calls variables from pycbc_inspiral to be used in a timing calculation | f16066:c2:m13 |
def write_events(self, outname): | self.make_output_dir(outname)<EOL>if '<STR_LIT>' in outname:<EOL><INDENT>self.write_to_hdf(outname)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT> | Write the found events to a sngl inspiral table | f16066:c2:m14 |
def add_template_events_to_ifo(self, ifo, columns, vectors): | <EOL>self.template_events = self.template_event_dict[ifo]<EOL>self.add_template_events(columns, vectors)<EOL>self.template_event_dict[ifo] = self.template_events<EOL>self.template_events = None<EOL> | Add a vector indexed | f16066:c3:m1 |
def add_template_network_events(self, columns, vectors): | <EOL>new_events = None<EOL>new_events = numpy.zeros(<EOL>max([len(v) for v in vectors if v is not None]),<EOL>dtype=self.network_event_dtype<EOL>)<EOL>assert new_events is not None<EOL>new_events['<STR_LIT>'] = self.template_index<EOL>for c, v in zip(columns, vectors):<EOL><INDENT>if v is not None:<EOL><INDENT>if isins... | Add a vector indexed | f16066:c4:m1 |
def add_template_events_to_network(self, columns, vectors): | <EOL>self.template_events = self.template_event_dict['<STR_LIT>']<EOL>self.add_template_network_events(columns, vectors)<EOL>self.template_event_dict['<STR_LIT>'] = self.template_events<EOL>self.template_events = None<EOL> | Add a vector indexed | f16066:c4:m2 |
def cluster_template_events_single_ifo(<EOL>self, tcolumn, column, window_size, ifo): | <EOL>self.template_events = self.template_event_dict[ifo]<EOL>self.cluster_template_events(tcolumn, column, window_size)<EOL>self.template_event_dict[ifo] = self.template_events<EOL>self.template_events = None<EOL> | Cluster the internal events over the named column | f16066:c5:m1 |
def write_events(self, outname): | self.make_output_dir(outname)<EOL>if '<STR_LIT>' in outname:<EOL><INDENT>self.write_to_hdf(outname)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT> | Write the found events to a sngl inspiral table | f16066:c5:m3 |
def fit_above_thresh(distr, vals, thresh=None): | vals = numpy.array(vals)<EOL>if thresh is None:<EOL><INDENT>thresh = min(vals)<EOL><DEDENT>else:<EOL><INDENT>vals = vals[vals >= thresh]<EOL><DEDENT>alpha = fitalpha_dict[distr](vals, thresh)<EOL>return alpha, fitstd_dict[distr](vals, alpha)<EOL> | Maximum likelihood fit for the coefficient alpha
Fitting a distribution of discrete values above a given threshold.
Exponential p(x) = alpha exp(-alpha (x-x_t))
Rayleigh p(x) = alpha x exp(-alpha (x**2-x_t**2)/2)
Power p(x) = ((alpha-1)/x_t) (x/x_t)**-alpha
Values below threshold will be discarded.
If no t... | f16067:m0 |
def fit_fn(distr, xvals, alpha, thresh): | xvals = numpy.array(xvals)<EOL>fit = fitfn_dict[distr](xvals, alpha, thresh)<EOL>numpy.putmask(fit, xvals < thresh, <NUM_LIT:0.>)<EOL>return fit<EOL> | The fitted function normalized to 1 above threshold
To normalize to a given total count multiply by the count.
Parameters
----------
xvals : sequence of floats
Values where the function is to be evaluated
alpha : float
The fitted parameter
thresh : float
Threshold value applied to fitted values
Returns
-... | f16067:m1 |
def cum_fit(distr, xvals, alpha, thresh): | xvals = numpy.array(xvals)<EOL>cum_fit = cum_fndict[distr](xvals, alpha, thresh)<EOL>numpy.putmask(cum_fit, xvals < thresh, <NUM_LIT:0.>)<EOL>return cum_fit<EOL> | Integral of the fitted function above a given value (reverse CDF)
The fitted function is normalized to 1 above threshold
Parameters
----------
xvals : sequence of floats
Values where the function is to be evaluated
alpha : float
The fitted parameter
thresh : float
Threshold value applied to fitted values
... | f16067:m2 |
def tail_threshold(vals, N=<NUM_LIT:1000>): | vals = numpy.array(vals)<EOL>if len(vals) < N:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>vals.sort()<EOL>return min(vals[-N:])<EOL> | Determine a threshold above which there are N louder values | f16067:m3 |
def which_bin(par, minpar, maxpar, nbins, log=False): | assert (par >= minpar and par <= maxpar)<EOL>if log:<EOL><INDENT>par, minpar, maxpar = numpy.log(par), numpy.log(minpar), numpy.log(maxpar)<EOL><DEDENT>frac = float(par - minpar) / float(maxpar - minpar)<EOL>binind = int(frac * nbins)<EOL>if par == maxpar:<EOL><INDENT>binind = nbins - <NUM_LIT:1><EOL><DEDENT>return bin... | Helper function
Returns bin index where a parameter value belongs (from 0 through nbins-1)
when dividing the range between minpar and maxpar equally into bins.
Parameters
----------
par : float
Parameter value being binned
minpar : float
Minimum parameter value
maxpar : float
Maximum parameter value
nbins... | f16067:m5 |
def get_statistic(stat): | try:<EOL><INDENT>return statistic_dict[stat]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise RuntimeError('<STR_LIT>' % stat)<EOL><DEDENT> | Error-handling sugar around dict lookup for coincident statistics
Parameters
----------
stat : string
Name of the coincident statistic
Returns
-------
class
Subclass of Stat base class
Raises
------
RuntimeError
If the string is not recognized as corresponding to a Stat subclass | f16068:m0 |
def get_sngl_statistic(stat): | try:<EOL><INDENT>return sngl_statistic_dict[stat]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise RuntimeError('<STR_LIT>' % stat)<EOL><DEDENT> | Error-handling sugar around dict lookup for single-detector statistics
Parameters
----------
stat : string
Name of the single-detector statistic
Returns
-------
class
Subclass of Stat base class
Raises
------
RuntimeError
If the string is not recognized as corresponding to a Stat subclass | f16068:m1 |
def __init__(self, files): | import h5py<EOL>self.files = {}<EOL>for filename in files:<EOL><INDENT>f = h5py.File(filename, '<STR_LIT:r>')<EOL>stat = f.attrs['<STR_LIT>']<EOL>self.files[stat] = f<EOL><DEDENT>self.single_dtype = numpy.float32<EOL> | Create a statistic class instance
Parameters
----------
files: list of strs
A list containing the filenames of hdf format files used to help
construct the coincident statistics. The files must have a 'stat'
attribute which is used to associate them with the appropria... | f16068:c0:m0 |
def single(self, trigs): | return ranking.get_newsnr(trigs)<EOL> | Calculate the single detector statistic, here equal to newsnr
Parameters
----------
trigs: dict of numpy.ndarrays, h5py group (or similar dict-like object)
Dictionary-like object holding single detector trigger information.
Returns
-------
numpy.ndarray
... | f16068:c1:m0 |
def coinc(self, s0, s1, slide, step): | return (s0**<NUM_LIT> + s1**<NUM_LIT>) ** <NUM_LIT:0.5><EOL> | Calculate the coincident detection statistic.
Parameters
----------
s0: numpy.ndarray
Single detector ranking statistic for the first detector.
s1: numpy.ndarray
Single detector ranking statistic for the second detector.
slide: (unused in this statistic)
... | f16068:c1:m1 |
def coinc_multiifo(self, s, slide, step,<EOL>): | return sum(x ** <NUM_LIT> for x in s.values()) ** <NUM_LIT:0.5><EOL> | Calculate the coincident detection statistic.
Parameters
----------
s: dictionary keyed by ifo of single detector ranking
statistics
slide: (unused in this statistic)
step: (unused in this statistic)
Returns
-------
numpy.ndarray
Arr... | f16068:c1:m2 |
def single(self, trigs): | return ranking.get_newsnr_sgveto(trigs)<EOL> | Calculate the single detector statistic, here equal to newsnr_sgveto
Parameters
----------
trigs: dict of numpy.ndarrays, h5py group (or similar dict-like object)
Dictionary-like object holding single detector trigger information.
Returns
-------
numpy.ndarr... | f16068:c2:m0 |
def single(self, trigs): | return ranking.get_newsnr_sgveto_psdvar(trigs)<EOL> | Calculate the single detector statistic, here equal to newsnr
combined with sgveto and psdvar statistic
Parameters
----------
trigs: dict of numpy.ndarrays
Returns
-------
numpy.ndarray
The array of single detector values | f16068:c3:m0 |
def single(self, trigs): | newsnr = ranking.get_newsnr(trigs)<EOL>rchisq = trigs['<STR_LIT>'][:] / (<NUM_LIT> * trigs['<STR_LIT>'][:] - <NUM_LIT>)<EOL>newsnr[numpy.logical_and(newsnr < <NUM_LIT:10>, rchisq > <NUM_LIT:2>)] = -<NUM_LIT:1><EOL>return newsnr<EOL> | Calculate the single detector statistic.
Parameters
----------
trigs: dict of numpy.ndarrays, h5py group (or similar dict-like object)
Dictionary-like object holding single detector trigger information.
Returns
-------
newsnr: numpy.ndarray
Array... | f16068:c5:m0 |
def coinc(self, s0, s1, slide, step): | cstat = (s0**<NUM_LIT> + s1**<NUM_LIT>) ** <NUM_LIT:0.5><EOL>cstat[s0==-<NUM_LIT:1>] = <NUM_LIT:0><EOL>cstat[s1==-<NUM_LIT:1>] = <NUM_LIT:0><EOL>return cstat<EOL> | Calculate the coincident detection statistic.
Parameters
----------
s0: numpy.ndarray
Single detector ranking statistic for the first detector.
s1: numpy.ndarray
Single detector ranking statistic for the second detector.
slide: (unused in this statistic)
... | f16068:c5:m1 |
def single(self, trigs): | sngl_stat = self.get_newsnr(trigs)<EOL>singles = numpy.zeros(len(sngl_stat), dtype=self.single_dtype)<EOL>singles['<STR_LIT>'] = sngl_stat<EOL>singles['<STR_LIT>'] = trigs['<STR_LIT>'][:]<EOL>singles['<STR_LIT>'] = trigs['<STR_LIT>'][:]<EOL>singles['<STR_LIT>'] = trigs['<STR_LIT>'][:]<EOL>singles['<STR_LIT>'] = trigs['... | Calculate the single detector statistic and assemble other parameters
Parameters
----------
trigs: dict of numpy.ndarrays, h5py group (or similar dict-like object)
Dictionary-like object holding single detector trigger information.
'chisq_dof', 'snr', 'chisq', 'coa_phase', 'end_time', and 'sigmasq'
are req... | f16068:c6:m1 |
def logsignalrate(self, s0, s1, slide, step): | td = numpy.array(s0['<STR_LIT>'] - s1['<STR_LIT>'] - slide*step, ndmin=<NUM_LIT:1>)<EOL>pd = numpy.array((s0['<STR_LIT>'] - s1['<STR_LIT>']) %(<NUM_LIT> * numpy.pi), ndmin=<NUM_LIT:1>)<EOL>rd = numpy.array((s0['<STR_LIT>'] / s1['<STR_LIT>']) ** <NUM_LIT:0.5>, ndmin=<NUM_LIT:1>)<EOL>sn0 = numpy.array(s0['<STR_LIT>'], nd... | Calculate the normalized log rate density of signals via lookup | f16068:c6:m2 |
def coinc(self, s0, s1, slide, step): | rstat = s0['<STR_LIT>']**<NUM_LIT> + s1['<STR_LIT>']**<NUM_LIT><EOL>cstat = rstat + <NUM_LIT> * self.logsignalrate(s0, s1, slide, step)<EOL>cstat[cstat < <NUM_LIT:0>] = <NUM_LIT:0><EOL>return cstat ** <NUM_LIT:0.5><EOL> | Calculate the coincident detection statistic.
Parameters
----------
s0: numpy.ndarray
Single detector ranking statistic for the first detector.
s1: numpy.ndarray
Single detector ranking statistic for the second detector.
slide: numpy.ndarray
Array of ints. These represent the multiple of the timeslide
inte... | f16068:c6:m3 |
def find_fits(self, trigs): | try:<EOL><INDENT>tnum = trigs.template_num <EOL>ifo = trigs.ifo<EOL><DEDENT>except AttributeError:<EOL><INDENT>tnum = trigs['<STR_LIT>'] <EOL>assert len(self.ifos) == <NUM_LIT:1><EOL>ifo = self.ifos[<NUM_LIT:0>]<EOL><DEDENT>alphai = self.fits_by_tid[ifo]['<STR_LIT>'][tnum]<EOL>ratei = self.fits_by_tid[ifo]['<STR_LIT>... | Get fit coeffs for a specific ifo and template id(s) | f16068:c8:m3 |
def lognoiserate(self, trigs): | alphai, ratei, thresh = self.find_fits(trigs)<EOL>newsnr = self.get_newsnr(trigs)<EOL>lognoisel = - alphai * (newsnr - thresh) + numpy.log(alphai) +numpy.log(ratei)<EOL>return numpy.array(lognoisel, ndmin=<NUM_LIT:1>, dtype=numpy.float32)<EOL> | Calculate the log noise rate density over single-ifo newsnr
Read in single trigger information, make the newsnr statistic
and rescale by the fitted coefficients alpha and rate | f16068:c8:m4 |
def single(self, trigs): | return self.lognoiserate(trigs)<EOL> | Single-detector statistic, here just equal to the log noise rate | f16068:c8:m5 |
def coinc(self, s0, s1, slide, step): | <EOL>loglr = - s0 - s1<EOL>threshes = [self.fits_by_tid[i]['<STR_LIT>'] for i in self.ifos]<EOL>loglr += sum([t**<NUM_LIT> / <NUM_LIT> for t in threshes])<EOL>return (<NUM_LIT> * loglr) ** <NUM_LIT:0.5><EOL> | Calculate the final coinc ranking statistic | f16068:c8:m6 |
def single(self, trigs): | chisq_newsnr = ranking.get_newsnr(trigs)<EOL>rautochisq = trigs['<STR_LIT>'][:] / trigs['<STR_LIT>'][:]<EOL>autochisq_newsnr = ranking.newsnr(trigs['<STR_LIT>'][:], rautochisq)<EOL>return numpy.array(numpy.minimum(chisq_newsnr, autochisq_newsnr,<EOL>dtype=numpy.float32), ndmin=<NUM_LIT:1>, copy=False)<EOL> | Calculate the single detector statistic.
Parameters
----------
trigs: dict of numpy.ndarrays, h5py group (or similar dict-like object)
Dictionary-like object holding single detector trigger information.
'snr', 'cont_chisq', 'cont_chisq_dof', 'chisq_dof' and 'chisq'
... | f16068:c15:m0 |
def _check_lal_pars(p): | lal_pars = lal.CreateDict()<EOL>if p['<STR_LIT>']!=-<NUM_LIT:1>:<EOL><INDENT>lalsimulation.SimInspiralWaveformParamsInsertPNPhaseOrder(lal_pars,int(p['<STR_LIT>']))<EOL><DEDENT>if p['<STR_LIT>']!=-<NUM_LIT:1>:<EOL><INDENT>lalsimulation.SimInspiralWaveformParamsInsertPNAmplitudeOrder(lal_pars,int(p['<STR_LIT>']))<EOL><D... | Create a laldict object from the dictionary of waveform parameters
Parameters
----------
p: dictionary
The dictionary of lalsimulation paramaters
Returns
-------
laldict: LalDict
The lal type dictionary to pass to the lalsimulation waveform functions. | f16069:m0 |
def _spintaylor_aligned_prec_swapper(**p): | orig_approximant = p['<STR_LIT>']<EOL>if p['<STR_LIT>'] == <NUM_LIT:0> and p['<STR_LIT>'] == <NUM_LIT:0> and p['<STR_LIT>'] == <NUM_LIT:0> andp['<STR_LIT>'] == <NUM_LIT:0>:<EOL><INDENT>p['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>p['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>hp, hc = _lalsim_fd_waveform(**p)<E... | SpinTaylorF2 is only single spin, it also struggles with anti-aligned spin
waveforms. This construct chooses between the aligned-twospin TaylorF2 model
and the precessing singlespin SpinTaylorF2 models. If aligned spins are
given, use TaylorF2, if nonaligned spins are given use SpinTaylorF2. In
the case of nonaligned d... | f16069:m2 |
def td_approximants(scheme=_scheme.mgr.state): | return td_wav[type(scheme)].keys()<EOL> | Return a list containing the available time domain approximants for
the given processing scheme. | f16069:m8 |
def fd_approximants(scheme=_scheme.mgr.state): | return fd_wav[type(scheme)].keys()<EOL> | Return a list containing the available fourier domain approximants for
the given processing scheme. | f16069:m9 |
def sgburst_approximants(scheme=_scheme.mgr.state): | return sgburst_wav[type(scheme)].keys()<EOL> | Return a list containing the available time domain sgbursts for
the given processing scheme. | f16069:m10 |
def filter_approximants(scheme=_scheme.mgr.state): | return filter_wav[type(scheme)].keys()<EOL> | Return a list of fourier domain approximants including those
written specifically as templates. | f16069:m11 |
def get_obj_attrs(obj): | pr = {}<EOL>if obj is not None:<EOL><INDENT>if isinstance(obj, numpy.core.records.record):<EOL><INDENT>for name in obj.dtype.names:<EOL><INDENT>pr[name] = getattr(obj, name)<EOL><DEDENT><DEDENT>elif hasattr(obj, '<STR_LIT>') and obj.__dict__:<EOL><INDENT>pr = obj.__dict__<EOL><DEDENT>elif hasattr(obj, '<STR_LIT>'):<EOL... | Return a dictionary built from the attributes of the given object. | f16069:m12 |
def props(obj, required_args=None, **kwargs): | pr = get_obj_attrs(obj)<EOL>pr.update(kwargs)<EOL>if required_args is None:<EOL><INDENT>required_args = []<EOL><DEDENT>missing = set(required_args) - set(pr.keys())<EOL>if any(missing):<EOL><INDENT>raise ValueError("<STR_LIT>".format('<STR_LIT:U+002CU+0020>'.join(missing)))<EOL><DEDENT>input_params = default_args.copy(... | Return a dictionary built from the combination of defaults, kwargs,
and the attributes of the given object. | f16069:m13 |
def get_fd_waveform_sequence(template=None, **kwds): | kwds['<STR_LIT>'] = -<NUM_LIT:1><EOL>kwds['<STR_LIT>'] = -<NUM_LIT:1><EOL>p = props(template, required_args=fd_required_args, **kwds)<EOL>lal_pars = _check_lal_pars(p)<EOL>hp, hc = lalsimulation.SimInspiralChooseFDWaveformSequence(float(p['<STR_LIT>']),<EOL>float(pnutils.solar_mass_to_kg(p['<STR_LIT>'])),<EOL>float(pnu... | Return values of the waveform evaluated at the sequence of frequency
points.
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.
{params}
Returns
... | f16069:m15 |
def get_td_waveform(template=None, **kwargs): | input_params = props(template, required_args=td_required_args, **kwargs)<EOL>wav_gen = td_wav[type(_scheme.mgr.state)]<EOL>if input_params['<STR_LIT>'] not in wav_gen:<EOL><INDENT>raise ValueError("<STR_LIT>" %<EOL>(input_params['<STR_LIT>']))<EOL><DEDENT>return wav_gen[input_params['<STR_LIT>']](**input_params)<EOL> | Return the plus and cross polarizations of a time domain waveform.
Parameters
----------
template: object
An object that has attached properties. This can be used to subsitute
for keyword arguments. A common example would be a row in an xml table.
{params}
Returns
-------
h... | f16069:m16 |
def get_fd_waveform(template=None, **kwargs): | input_params = props(template, required_args=fd_required_args, **kwargs)<EOL>wav_gen = fd_wav[type(_scheme.mgr.state)]<EOL>if input_params['<STR_LIT>'] not in wav_gen:<EOL><INDENT>raise ValueError("<STR_LIT>" %<EOL>(input_params['<STR_LIT>']))<EOL><DEDENT>try:<EOL><INDENT>ffunc = input_params.pop('<STR_LIT>')<EOL>if ff... | Return a frequency domain gravitational waveform.
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.
{params}
Returns
-------
hplustilde: Frequ... | f16069:m17 |
def get_fd_waveform_from_td(**params): | <EOL>full_duration = duration = get_waveform_filter_length_in_time(**params)<EOL>nparams = params.copy()<EOL>while full_duration < duration * <NUM_LIT>:<EOL><INDENT>full_duration = get_waveform_filter_length_in_time(**nparams)<EOL>nparams['<STR_LIT>'] -= <NUM_LIT:1><EOL><DEDENT>if '<STR_LIT>' not in nparams:<EOL><INDEN... | Return time domain version of fourier domain approximant.
This returns a frequency domain version of a fourier domain approximant,
with padding and tapering at the start of the waveform.
Parameters
----------
params: dict
The parameters defining the waveform to generator.
See `get_... | f16069:m18 |
def get_td_waveform_from_fd(rwrap=<NUM_LIT>, **params): | <EOL>full_duration = duration = get_waveform_filter_length_in_time(**params)<EOL>nparams = params.copy()<EOL>while full_duration < duration * <NUM_LIT>:<EOL><INDENT>full_duration = get_waveform_filter_length_in_time(**nparams)<EOL>nparams['<STR_LIT>'] -= <NUM_LIT:1><EOL><DEDENT>if '<STR_LIT>' not in nparams:<EOL><INDEN... | Return time domain version of fourier domain approximant.
This returns a time domain version of a fourier domain approximant, with
padding and tapering at the start of the waveform.
Parameters
----------
rwrap: float
Cyclic time shift parameter in seconds. A fudge factor to ensure
... | f16069:m19 |
def get_interpolated_fd_waveform(dtype=numpy.complex64, return_hc=True,<EOL>**params): | def rulog2(val):<EOL><INDENT>return <NUM_LIT> ** numpy.ceil(numpy.log2(float(val)))<EOL><DEDENT>orig_approx = params['<STR_LIT>']<EOL>params['<STR_LIT>'] = params['<STR_LIT>'].replace('<STR_LIT>', '<STR_LIT>')<EOL>df = params['<STR_LIT>']<EOL>if '<STR_LIT>' not in params:<EOL><INDENT>duration = get_waveform_filter_leng... | Return a fourier domain waveform approximant, using interpolation | f16069:m20 |
def get_sgburst_waveform(template=None, **kwargs): | input_params = props_sgburst(template,**kwargs)<EOL>for arg in sgburst_required_args:<EOL><INDENT>if arg not in input_params:<EOL><INDENT>raise ValueError("<STR_LIT>" + str(arg))<EOL><DEDENT><DEDENT>return _lalsim_sgburst_waveform(**input_params)<EOL> | Return the plus and cross polarizations of a time domain
sine-Gaussian burst waveform.
Parameters
----------
template: object
An object that has attached properties. This can be used to subsitute
for keyword arguments. A common example would be a row in an xml table.
approximant : s... | f16069:m21 |
def get_imr_length(approx, **kwds): | m1 = float(kwds['<STR_LIT>'])<EOL>m2 = float(kwds['<STR_LIT>'])<EOL>s1z = float(kwds['<STR_LIT>'])<EOL>s2z = float(kwds['<STR_LIT>'])<EOL>f_low = float(kwds['<STR_LIT>'])<EOL>return pnutils.get_imr_duration(m1, m2, s1z, s2z, f_low, approximant=approx)<EOL> | Call through to pnutils to obtain IMR waveform durations | f16069:m23 |
def seobnrv2_length_in_time(**kwds): | return get_imr_length("<STR_LIT>", **kwds)<EOL> | Stub for holding the calculation of SEOBNRv2* waveform duration. | f16069:m24 |
def seobnrv4_length_in_time(**kwds): | return get_imr_length("<STR_LIT>", **kwds)<EOL> | Stub for holding the calculation of SEOBNRv4* waveform duration. | f16069:m25 |
def imrphenomd_length_in_time(**kwds): | return get_imr_length("<STR_LIT>", **kwds)<EOL> | Stub for holding the calculation of IMRPhenomD waveform duration. | f16069:m26 |
def get_waveform_filter(out, template=None, **kwargs): | n = len(out)<EOL>input_params = props(template, **kwargs)<EOL>if input_params['<STR_LIT>'] in filter_approximants(_scheme.mgr.state):<EOL><INDENT>wav_gen = filter_wav[type(_scheme.mgr.state)]<EOL>htilde = wav_gen[input_params['<STR_LIT>']](out=out, **input_params)<EOL>htilde.resize(n)<EOL>htilde.chirp_length = get_wave... | Return a frequency domain waveform filter for the specified approximant | f16069:m27 |
def td_waveform_to_fd_waveform(waveform, out=None, length=None,<EOL>buffer_length=<NUM_LIT:100>): | <EOL>if out is None:<EOL><INDENT>if length is None:<EOL><INDENT>N = pnutils.nearest_larger_binary_number(len(waveform) +buffer_length)<EOL>n = int(N//<NUM_LIT:2>) + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>n = length<EOL>N = (n-<NUM_LIT:1>)*<NUM_LIT:2><EOL><DEDENT>out = zeros(n, dtype=complex_same_precision_as(wavefor... | Convert a time domain into a frequency domain waveform by FFT.
As a waveform is assumed to "wrap" in the time domain one must be
careful to ensure the waveform goes to 0 at both "boundaries". To
ensure this is done correctly the waveform must have the epoch set such
the merger time is at... | f16069:m28 |
def get_two_pol_waveform_filter(outplus, outcross, template, **kwargs): | n = len(outplus)<EOL>if not hasattr(template, '<STR_LIT>') and '<STR_LIT>' not in kwargs:<EOL><INDENT>if hasattr(template, '<STR_LIT>'):<EOL><INDENT>kwargs['<STR_LIT>'] = template.alpha3<EOL><DEDENT><DEDENT>input_params = props(template, **kwargs)<EOL>if input_params['<STR_LIT>'] in fd_approximants(_scheme.mgr.state):<... | Return a frequency domain waveform filter for the specified approximant.
Unlike get_waveform_filter this function returns both h_plus and h_cross
components of the waveform, which are needed for searches where h_plus
and h_cross are not related by a simple phase shift. | f16069:m29 |
def get_template_amplitude_norm(template=None, **kwargs): | input_params = props(template,**kwargs)<EOL>approximant = kwargs['<STR_LIT>']<EOL>if approximant in _template_amplitude_norms:<EOL><INDENT>return _template_amplitude_norms[approximant](**input_params)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT> | Return additional constant template normalization. This only affects
the effective distance calculation. Returns None for all templates with a
physically meaningful amplitude. | f16069:m31 |
def get_waveform_filter_precondition(approximant, length, delta_f): | if approximant in _filter_preconditions:<EOL><INDENT>return _filter_preconditions[approximant](length, delta_f)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT> | Return the data preconditioning factor for this approximant. | f16069:m32 |
def get_waveform_filter_norm(approximant, psd, length, delta_f, f_lower): | if approximant in _filter_norms:<EOL><INDENT>return _filter_norms[approximant](psd, length, delta_f, f_lower)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT> | Return the normalization vector for the approximant | f16069:m33 |
def get_waveform_end_frequency(template=None, **kwargs): | input_params = props(template,**kwargs)<EOL>approximant = kwargs['<STR_LIT>']<EOL>if approximant in _filter_ends:<EOL><INDENT>return _filter_ends[approximant](**input_params)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT> | Return the stop frequency of a template | f16069:m34 |
def get_waveform_filter_length_in_time(approximant, template=None, **kwargs): | kwargs = props(template, **kwargs)<EOL>if approximant in _filter_time_lengths:<EOL><INDENT>return _filter_time_lengths[approximant](**kwargs)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT> | For filter templates, return the length in time of the template. | f16069:m35 |
def spintaylorf2(**kwds): | <EOL>f_lower = double(kwds['<STR_LIT>'])<EOL>delta_f = double(kwds['<STR_LIT>'])<EOL>distance = double(kwds['<STR_LIT>'])<EOL>mass1 = double(kwds['<STR_LIT>'])<EOL>mass2 = double(kwds['<STR_LIT>'])<EOL>spin1x = double(kwds['<STR_LIT>'])<EOL>spin1y = double(kwds['<STR_LIT>'])<EOL>spin1z = double(kwds['<STR_LIT>'])<EOL>p... | Return a SpinTaylorF2 waveform using CUDA to generate the phase and amplitude | f16070:m0 |
def nltides_fourier_phase_difference(f, delta_f, f0, amplitude, n, m1, m2): | kmin = int(f0/delta_f)<EOL>kmax = len(f)<EOL>f_ref, t_of_f_factor, phi_of_f_factor =pycbc.conversions.nltides_coefs(amplitude, n, m1, m2)<EOL>delta_psi_f_le_f0 = numpy.ones(kmin)<EOL>delta_psi_f_le_f0 *= - phi_of_f_factor * (f0/f_ref)**(n-<NUM_LIT>)<EOL>delta_psi_f_gt_f0 = - phi_of_f_factor * (f[kmin:kmax]/f_ref)**(n-<... | Calculate the change to the Fourier phase change due
to non-linear tides. Note that the Fourier phase Psi(f)
is not the same as the gravitational-wave phase phi(f) and
is computed by
Delta Psi(f) = 2 \pi f Delta t(f) - Delta phi(f)
Parameters
----------
f: numpy.array
Array of frequ... | f16072:m0 |
def nonlinear_tidal_spa(**kwds): | from pycbc import waveform<EOL>from pycbc.types import Array<EOL>kwds.pop('<STR_LIT>')<EOL>hp, hc = waveform.get_fd_waveform(approximant="<STR_LIT>", **kwds)<EOL>f = numpy.arange(len(hp)) * hp.delta_f<EOL>pd = Array(numpy.exp(-<NUM_LIT> * nltides_fourier_phase_difference(f,<EOL>hp.delta_f,<EOL>kwds['<STR_LIT>'], kwds[... | Generates a frequency-domain waveform that implements the
TaylorF2+NL tide model described in https://arxiv.org/abs/1808.07013 | f16072:m1 |
def spa_tmplt_engine(htilde, kmin, phase_order,<EOL>delta_f, piM, pfaN,<EOL>pfa2, pfa3, pfa4, pfa5, pfl5,<EOL>pfa6, pfl6, pfa7, amp_factor): | taylorf2_kernel(htilde.data, kmin, phase_order,<EOL>delta_f, piM, pfaN,<EOL>pfa2, pfa3, pfa4, pfa5, pfl5,<EOL>pfa6, pfl6, pfa7, amp_factor)<EOL> | Calculate the spa tmplt phase | f16074:m0 |
def fd_sine_gaussian(amp, quality, central_frequency, fmin, fmax, delta_f): | kmin = int(round(fmin / delta_f))<EOL>kmax = int(round(fmax / delta_f))<EOL>f = numpy.arange(kmin, kmax) * delta_f<EOL>tau = quality / <NUM_LIT:2> / numpy.pi / central_frequency<EOL>A = amp * numpy.pi ** <NUM_LIT:0.5> / <NUM_LIT:2> * tau<EOL>d = A * numpy.exp(-(numpy.pi * tau * (f - central_frequency))**<NUM_LIT>)<EO... | Generate a Fourier domain sine-Gaussian
Parameters
----------
amp: float
Amplitude of the sine-Gaussian
quality: float
The quality factor
central_frequency: float
The central frequency of the sine-Gaussian
fmin: float
The minimum frequency to generate the sine-Ga... | f16075:m0 |
def apply_fseries_time_shift(htilde, dt, kmin=<NUM_LIT:0>, copy=True): | if htilde.precision != '<STR_LIT>':<EOL><INDENT>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT>if copy:<EOL><INDENT>out = htilde.copy()<EOL><DEDENT>else:<EOL><INDENT>out = htilde<EOL><DEDENT>kmin = numpy.int32(kmin)<EOL>kmax = numpy.int32(len(htilde))<EOL>nb = int(numpy.ceil(kmax / nt_float))<EOL>if nb > <NUM_LIT>:... | Shifts a frequency domain waveform in time. The waveform is assumed to
be sampled at equal frequency intervals. | f16076:m0 |
def spa_length_in_time(**kwds): | m1 = kwds['<STR_LIT>']<EOL>m2 = kwds['<STR_LIT>']<EOL>flow = kwds['<STR_LIT>']<EOL>porder = int(kwds['<STR_LIT>'])<EOL>return findchirp_chirptime(m1, m2, flow, porder)<EOL> | Returns the length in time of the template,
based on the masses, PN order, and low-frequency
cut-off. | f16077:m1 |
def spa_tmplt_precondition(length, delta_f, kmin=<NUM_LIT:0>): | global _prec<EOL>if _prec is None or _prec.delta_f != delta_f or len(_prec) < length:<EOL><INDENT>v = numpy.arange(<NUM_LIT:0>, (kmin+length*<NUM_LIT:2>), <NUM_LIT:1.0>) * delta_f<EOL>v = numpy.power(v[<NUM_LIT:1>:len(v)], -<NUM_LIT>/<NUM_LIT>)<EOL>_prec = FrequencySeries(v, delta_f=delta_f, dtype=float32)<EOL><DEDENT>... | Return the amplitude portion of the TaylorF2 approximant, used to precondition
the strain data. The result is cached, and so should not be modified only read. | f16077:m3 |
def spa_distance(psd, mass1, mass2, lower_frequency_cutoff, snr=<NUM_LIT:8>): | kend = int(spa_tmplt_end(mass1=mass1, mass2=mass2) / psd.delta_f)<EOL>norm1 = spa_tmplt_norm(psd, len(psd), psd.delta_f, lower_frequency_cutoff)<EOL>norm2 = (spa_amplitude_factor(mass1=mass1, mass2=mass2)) ** <NUM_LIT><EOL>if kend >= len(psd):<EOL><INDENT>kend = len(psd) - <NUM_LIT:1><EOL><DEDENT>return sqrt(norm1[kend... | Return the distance at a given snr (default=8) of the SPA TaylorF2
template. | f16077:m6 |
@schemed("<STR_LIT>")<EOL>def spa_tmplt_engine(htilde, kmin, phase_order, delta_f, piM, pfaN,<EOL>pfa2, pfa3, pfa4, pfa5, pfl5,<EOL>pfa6, pfl6, pfa7, amp_factor): | err_msg = "<STR_LIT>"<EOL>err_msg += "<STR_LIT>"<EOL>raise ValueError(err_msg)<EOL> | Calculate the spa tmplt phase | f16077:m7 |
def spa_tmplt(**kwds): | <EOL>f_lower = kwds['<STR_LIT>']<EOL>delta_f = kwds['<STR_LIT>']<EOL>distance = kwds['<STR_LIT>']<EOL>mass1 = kwds['<STR_LIT>']<EOL>mass2 = kwds['<STR_LIT>']<EOL>s1z = kwds['<STR_LIT>']<EOL>s2z = kwds['<STR_LIT>']<EOL>phase_order = int(kwds['<STR_LIT>'])<EOL>spin_order = int(kwds['<STR_LIT>'])<EOL>if '<STR_LIT>' in kwd... | Generate a minimal TaylorF2 approximant with optimations for the sin/cos | f16077:m8 |
def rough_time_estimate(m1, m2, flow, fudge_length=<NUM_LIT>, fudge_min=<NUM_LIT>): | m = m1 + m2<EOL>msun = m * lal.MTSUN_SI<EOL>t = <NUM_LIT> / <NUM_LIT> * m * m * msun / (m1 * m2) /(numpy.pi * msun * flow) ** (<NUM_LIT> / <NUM_LIT>)<EOL>return <NUM_LIT> if t < <NUM_LIT:0> else (t + fudge_min) * fudge_length<EOL> | A very rough estimate of the duration of the waveform.
An estimate of the waveform duration starting from flow. This is intended
to be fast but not necessarily accurate. It should be an overestimate of
the length. It is derived from a simplification of the 0PN post-newtonian
terms and includes a fudge ... | f16078:m0 |
def mchirp_compression(m1, m2, fmin, fmax, min_seglen=<NUM_LIT>, df_multiple=None): | sample_points = []<EOL>f = fmin<EOL>while f < fmax:<EOL><INDENT>if df_multiple is not None:<EOL><INDENT>f = int(f/df_multiple)*df_multiple<EOL><DEDENT>sample_points.append(f)<EOL>f += <NUM_LIT:1.0> / rough_time_estimate(m1, m2, f, fudge_min=min_seglen)<EOL><DEDENT>if sample_points[-<NUM_LIT:1>] < fmax:<EOL><INDENT>samp... | Return the frequencies needed to compress a waveform with the given
chirp mass. This is based on the estimate in rough_time_estimate.
Parameters
----------
m1: float
mass of first component object in solar masses
m2: float
mass of second component object in solar masses
fmin : f... | f16078:m1 |
def spa_compression(htilde, fmin, fmax, min_seglen=<NUM_LIT>,<EOL>sample_frequencies=None): | if sample_frequencies is None:<EOL><INDENT>sample_frequencies = htilde.sample_frequencies.numpy()<EOL><DEDENT>kmin = int(fmin/htilde.delta_f)<EOL>kmax = int(fmax/htilde.delta_f)<EOL>tf = abs(utils.time_from_frequencyseries(htilde,<EOL>sample_frequencies=sample_frequencies).data[kmin:kmax])<EOL>sample_frequencies = samp... | Returns the frequencies needed to compress the given frequency domain
waveform. This is done by estimating t(f) of the waveform using the
stationary phase approximation.
Parameters
----------
htilde : FrequencySeries
The waveform to compress.
fmin : float
The starting frequency ... | f16078:m2 |
def vecdiff(htilde, hinterp, sample_points, psd=None): | vecdiffs = numpy.zeros(sample_points.size-<NUM_LIT:1>, dtype=float)<EOL>for kk,thisf in enumerate(sample_points[:-<NUM_LIT:1>]):<EOL><INDENT>nextf = sample_points[kk+<NUM_LIT:1>]<EOL>vecdiffs[kk] = abs(_vecdiff(htilde, hinterp, thisf, nextf, psd=psd))<EOL><DEDENT>return vecdiffs<EOL> | Computes a statistic indicating between which sample points a waveform
and the interpolated waveform differ the most. | f16078:m4 |
def compress_waveform(htilde, sample_points, tolerance, interpolation,<EOL>precision, decomp_scratch=None, psd=None): | fmin = sample_points.min()<EOL>df = htilde.delta_f<EOL>sample_index = (sample_points / df).astype(int)<EOL>amp = utils.amplitude_from_frequencyseries(htilde)<EOL>phase = utils.phase_from_frequencyseries(htilde)<EOL>comp_amp = amp.take(sample_index)<EOL>comp_phase = phase.take(sample_index)<EOL>if decomp_scratch is None... | Retrieves the amplitude and phase at the desired sample points, and adds
frequency points in order to ensure that the interpolated waveform
has a mismatch with the full waveform that is <= the desired tolerance. The
mismatch is computed by finding 1-overlap between `htilde` and the
decompressed waveform... | f16078:m5 |
@schemed("<STR_LIT>")<EOL>def inline_linear_interp(amp, phase, sample_frequencies, output,<EOL>df, f_lower, imin, start_index): | return<EOL> | Generate a frequency-domain waveform via linear interpolation
from sampled amplitude and phase. The sample frequency locations
for the amplitude and phase must be the same. This function may
be less accurate than scipy's linear interpolation, but should be
much faster. Additionally, it is 'schemed' and... | f16078:m6 |
def fd_decompress(amp, phase, sample_frequencies, out=None, df=None,<EOL>f_lower=None, interpolation='<STR_LIT>'): | precision = _precision_map[sample_frequencies.dtype.name]<EOL>if _precision_map[amp.dtype.name] != precision or_precision_map[phase.dtype.name] != precision:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if out is None:<EOL><INDENT>if df is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DE... | Decompresses an FD waveform using the given amplitude, phase, and the
frequencies at which they are sampled at.
Parameters
----------
amp : array
The amplitude of the waveform at the sample frequencies.
phase : array
The phase of the waveform at the sample frequencies.
sample_fr... | f16078:m7 |
@property<EOL><INDENT>def amplitude(self):<DEDENT> | return self._get('<STR_LIT>')<EOL> | The amplitude of the waveform at the `sample_points`.
This is always returned as an array; the same logic as for
`sample_points` is used to determine whether or not to cache in
memory.
Returns
-------
amplitude : Array | f16078:c0:m2 |
@property<EOL><INDENT>def phase(self):<DEDENT> | return self._get('<STR_LIT>')<EOL> | The phase of the waveform as the `sample_points`.
This is always returned as an array; the same logic as for
`sample_points` returned as an array; the same logic as for
`sample_points` is used to determine whether or not to cache in
memory.
Returns
-------
phase... | f16078:c0:m3 |
@property<EOL><INDENT>def sample_points(self):<DEDENT> | return self._get('<STR_LIT>')<EOL> | The frequencies at which the compressed waveform is sampled.
This is
always returned as an array, even if the stored `sample_points` is an
hdf dataset. If `load_to_memory` is True and the stored points are
an hdf dataset, the `sample_points` will cached in memory the first
time ... | f16078:c0:m4 |
def clear_cache(self): | self._cache.clear()<EOL> | Clear self's cache of amplitude, phase, and sample_points. | f16078:c0:m5 |
def decompress(self, out=None, df=None, f_lower=None, interpolation=None): | if f_lower is None:<EOL><INDENT>f_lower = self.sample_points.min()<EOL><DEDENT>if interpolation is None:<EOL><INDENT>interpolation = self.interpolation<EOL><DEDENT>return fd_decompress(self.amplitude, self.phase, self.sample_points,<EOL>out=out, df=df, f_lower=f_lower,<EOL>interpolation=interpolation)<EOL> | Decompress self.
Parameters
----------
out : {None, FrequencySeries}
Write the decompressed waveform to the given frequency series. The
decompressed waveform will have the same `delta_f` as `out`.
Either this or `df` must be provided.
df : {None, floa... | f16078:c0:m6 |
def write_to_hdf(self, fp, template_hash, root=None, precision=None): | if root is None:<EOL><INDENT>root = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>root = '<STR_LIT>'%(root)<EOL><DEDENT>if precision is None:<EOL><INDENT>precision = self.precision<EOL><DEDENT>elif precision == '<STR_LIT>' and self.precision == '<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>outdtype = _... | Write the compressed waveform to the given hdf file handler.
The waveform is written to:
`fp['[{root}/]compressed_waveforms/{template_hash}/{param}']`,
where `param` is the `sample_points`, `amplitude`, and `phase`. The
`interpolation`, `tolerance`, `mismatch` and `precision` are saved
... | f16078:c0:m7 |
@classmethod<EOL><INDENT>def from_hdf(cls, fp, template_hash, root=None, load_to_memory=True,<EOL>load_now=False):<DEDENT> | if root is None:<EOL><INDENT>root = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>root = '<STR_LIT>'%(root)<EOL><DEDENT>group = '<STR_LIT>' %(root, str(template_hash))<EOL>fp_group = fp[group]<EOL>sample_points = fp_group['<STR_LIT>']<EOL>amp = fp_group['<STR_LIT>']<EOL>phase = fp_group['<STR_LIT>']<EOL>if load_now:<EOL><I... | Load a compressed waveform from the given hdf file handler.
The waveform is retrieved from:
`fp['[{root}/]compressed_waveforms/{template_hash}/{param}']`,
where `param` is the `sample_points`, `amplitude`, and `phase`.
Parameters
----------
fp : h5py.File
An... | f16078:c0:m8 |
def select_waveform_generator(approximant): | <EOL>if approximant in waveform.fd_approximants():<EOL><INDENT>return FDomainCBCGenerator<EOL><DEDENT>elif approximant in waveform.td_approximants():<EOL><INDENT>return TDomainCBCGenerator<EOL><DEDENT>elif approximant in ringdown.ringdown_fd_approximants:<EOL><INDENT>if approximant == '<STR_LIT>':<EOL><INDENT>return FD... | Returns the single-IFO generator for the approximant.
Parameters
----------
approximant : str
Name of waveform approximant. Valid names can be found using
``pycbc.waveform`` methods.
Returns
-------
generator : (PyCBC generator instance)
A waveform generator object.
... | f16080:m0 |
@property<EOL><INDENT>def static_args(self):<DEDENT> | return self.frozen_params<EOL> | Returns a dictionary of the static arguments. | f16080:c0:m1 |
def generate_from_args(self, *args): | if len(args) != len(self.variable_args):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return self.generate(**dict(zip(self.variable_args, args)))<EOL> | Generates a waveform. The list of arguments must be in the same
order as self's variable_args attribute. | f16080:c0:m2 |
def generate(self, **kwargs): | self.current_params.update(kwargs)<EOL>return self._generate_from_current()<EOL> | Generates a waveform from the keyword args. The current params
are updated with the given kwargs, then the generator is called. | f16080:c0:m3 |
def _add_pregenerate(self, func): | self._pregenerate_functions.append(func)<EOL> | Adds a function that will be called by the generator function
before waveform generation. | f16080:c0:m4 |
def _postgenerate(self, res): | return res<EOL> | Allows the waveform returned by the generator function to be
manipulated before returning. | f16080:c0:m5 |
def _gdecorator(generate_func): | def dostuff(self):<EOL><INDENT>for func in self._pregenerate_functions:<EOL><INDENT>self.current_params = func(self.current_params)<EOL><DEDENT>res = generate_func(self) <EOL>return self._postgenerate(res)<EOL><DEDENT>return dostuff<EOL> | A decorator that allows for seemless pre/post manipulation of
the waveform generator function. | f16080:c0:m6 |
@_gdecorator<EOL><INDENT>def _generate_from_current(self):<DEDENT> | return self.generator(**self.current_params)<EOL> | Generates a waveform from the current parameters. | f16080:c0:m7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.