signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def load_frequencyseries(path, group=None):
ext = _os.path.splitext(path)[<NUM_LIT:1>]<EOL>if ext == '<STR_LIT>':<EOL><INDENT>data = _numpy.load(path) <EOL><DEDENT>elif ext == '<STR_LIT>':<EOL><INDENT>data = _numpy.loadtxt(path)<EOL><DEDENT>elif ext == '<STR_LIT>':<EOL><INDENT>key = '<STR_LIT:data>' if group is None else group<EOL>f = h5py.File(path, '<STR_LI...
Load a FrequencySeries from a .hdf, .txt or .npy file. The default data types will be double precision floating point. Parameters ---------- path: string source file path. Must end with either .npy or .txt. group: string Additional name for internal storage use. Ex. hdf storage uses this as the key value...
f15958:m0
def get_delta_f(self):
return self._delta_f<EOL>
Return frequency between consecutive samples in Hertz.
f15958:c0:m3
def get_epoch(self):
return self._epoch<EOL>
Return frequency series epoch as a LIGOTimeGPS.
f15958:c0:m4
def get_sample_frequencies(self):
return Array(range(len(self))) * self._delta_f<EOL>
Return an Array containing the sample frequencies.
f15958:c0:m5
def at_frequency(self, freq):
return self[int(freq / self.delta_f)]<EOL>
Return the value at the specified frequency
f15958:c0:m7
@property<EOL><INDENT>def start_time(self):<DEDENT>
return self.epoch<EOL>
Return the start time of this vector
f15958:c0:m8
@start_time.setter<EOL><INDENT>def start_time(self, time):<DEDENT>
self._epoch = _lal.LIGOTimeGPS(time)<EOL>
Set the start time
f15958:c0:m9
@property<EOL><INDENT>def end_time(self):<DEDENT>
return self.start_time + self.duration<EOL>
Return the end time of this vector
f15958:c0:m10
@property<EOL><INDENT>def duration(self):<DEDENT>
return <NUM_LIT:1.0> / self.delta_f<EOL>
Return the time duration of this vector
f15958:c0:m11
@property<EOL><INDENT>def delta_t(self):<DEDENT>
return <NUM_LIT:1.0> / self.sample_rate<EOL>
Return the time between samples if this were a time series. This assume the time series is even in length!
f15958:c0:m12
@property<EOL><INDENT>def sample_rate(self):<DEDENT>
return (len(self) - <NUM_LIT:1>) * self.delta_f * <NUM_LIT><EOL>
Return the sample rate this would have in the time domain. This assumes even length time series!
f15958:c0:m13
def __eq__(self,other):
if super(FrequencySeries,self).__eq__(other):<EOL><INDENT>return (self._epoch == other._epoch and self._delta_f == other._delta_f)<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>
This is the Python special method invoked whenever the '==' comparison is used. It will return true if the data of two frequency series are identical, and all of the numeric meta-data are identical, irrespective of whether or not the two instances live in the same memory (for that comparison, the Python statement 'a i...
f15958:c0:m14
def almost_equal_elem(self,other,tol,relative=True,dtol=<NUM_LIT:0.0>):
<EOL>if (dtol < <NUM_LIT:0.0>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if super(FrequencySeries,self).almost_equal_elem(other,tol=tol,relative=relative):<EOL><INDENT>if relative:<EOL><INDENT>return (self._epoch == other._epoch and<EOL>abs(self._delta_f-other._delta_f) <= dtol*self._delta_f)<EOL><DEDENT>e...
Compare whether two frequency series are almost equal, element by element. If the 'relative' parameter is 'True' (the default) then the 'tol' parameter (which must be positive) is interpreted as a relative tolerance, and the comparison returns 'True' only if abs(self[i]-other[i]) <= tol*abs(self[i]) for all elements o...
f15958:c0:m15
def almost_equal_norm(self,other,tol,relative=True,dtol=<NUM_LIT:0.0>):
<EOL>if (dtol < <NUM_LIT:0.0>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if super(FrequencySeries,self).almost_equal_norm(other,tol=tol,relative=relative):<EOL><INDENT>if relative:<EOL><INDENT>return (self._epoch == other._epoch and<EOL>abs(self._delta_f-other._delta_f) <= dtol*self._delta_f)<EOL><DEDENT>e...
Compare whether two frequency series are almost equal, normwise. If the 'relative' parameter is 'True' (the default) then the 'tol' parameter (which must be positive) is interpreted as a relative tolerance, and the comparison returns 'True' only if abs(norm(self-other)) <= tol*abs(norm(self)). If 'relative' is 'False...
f15958:c0:m16
@_convert<EOL><INDENT>def lal(self):<DEDENT>
lal_data = None<EOL>if self._epoch is None:<EOL><INDENT>ep = _lal.LIGOTimeGPS(<NUM_LIT:0>,<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>ep = self._epoch<EOL><DEDENT>if self._data.dtype == _numpy.float32:<EOL><INDENT>lal_data = _lal.CreateREAL4FrequencySeries("<STR_LIT>",ep,<NUM_LIT:0>,self.delta_f,_lal.SecondUnit,len(self...
Produces a LAL frequency series object equivalent to self. Returns ------- lal_data : {lal.*FrequencySeries} LAL frequency series object containing the same data as self. The actual type depends on the sample's dtype. If the epoch of self was 'None', the epoc...
f15958:c0:m17
def save(self, path, group=None, ifo='<STR_LIT>'):
ext = _os.path.splitext(path)[<NUM_LIT:1>]<EOL>if ext == '<STR_LIT>':<EOL><INDENT>output = _numpy.vstack((self.sample_frequencies.numpy(),<EOL>self.numpy())).T<EOL>_numpy.save(path, output)<EOL><DEDENT>elif ext == '<STR_LIT>':<EOL><INDENT>if self.kind == '<STR_LIT>':<EOL><INDENT>output = _numpy.vstack((self.sample_freq...
Save frequency series to a Numpy .npy, hdf, or text file. The first column contains the sample frequencies, the second contains the values. In the case of a complex frequency series saved as text, the imaginary part is written as a third column. When using hdf format, the data is stored as a single vector, along with ...
f15958:c0:m18
@_noreal<EOL><INDENT>def to_timeseries(self, delta_t=None):<DEDENT>
from pycbc.fft import ifft<EOL>from pycbc.types import TimeSeries, real_same_precision_as<EOL>nat_delta_t = <NUM_LIT:1.0> / ((len(self)-<NUM_LIT:1>)*<NUM_LIT:2>) / self.delta_f<EOL>if not delta_t:<EOL><INDENT>delta_t = nat_delta_t<EOL><DEDENT>tlen = int(<NUM_LIT:1.0> / self.delta_f / delta_t + <NUM_LIT:0.5>)<EOL>flen...
Return the Fourier transform of this time series. Note that this assumes even length time series! Parameters ---------- delta_t : {None, float}, optional The time resolution of the returned series. By default the resolution is determined by length and delta_f of th...
f15958:c0:m19
@_noreal<EOL><INDENT>def cyclic_time_shift(self, dt):<DEDENT>
from pycbc.waveform import apply_fseries_time_shift<EOL>data = apply_fseries_time_shift(self, dt)<EOL>data.start_time = self.start_time - dt<EOL>return data<EOL>
Shift the data and timestamps by a given number of seconds Shift the data and timestamps in the time domain a given number of seconds. To just change the time stamps, do ts.start_time += dt. The time shift may be smaller than the intrinsic sample rate of the data. Note that data will ...
f15958:c0:m20
def match(self, other, psd=None,<EOL>low_frequency_cutoff=None, high_frequency_cutoff=None):
from pycbc.types import TimeSeries<EOL>from pycbc.filter import match<EOL>if isinstance(other, TimeSeries):<EOL><INDENT>if other.duration != self.duration:<EOL><INDENT>other = other.copy()<EOL>other.resize(int(other.sample_rate * self.duration))<EOL><DEDENT>other = other.to_frequencyseries()<EOL><DEDENT>if len(other) !...
Return the match between the two TimeSeries or FrequencySeries. Return the match between two waveforms. This is equivelant to the overlap maximized over time and phase. By default, the other vector will be resized to match self. Beware, this may remove high frequency content or the end ...
f15958:c0:m21
def autochisq_from_precomputed(sn, corr_sn, hautocorr, indices,<EOL>stride=<NUM_LIT:1>, num_points=None, oneside=None,<EOL>twophase=True, maxvalued=False):
Nsnr = len(sn)<EOL>achisq = np.zeros(len(indices))<EOL>num_points_all = int(Nsnr/stride)<EOL>if num_points is None:<EOL><INDENT>num_points = num_points_all<EOL><DEDENT>if (num_points > num_points_all):<EOL><INDENT>num_points = num_points_all<EOL><DEDENT>snrabs = np.abs(sn[indices])<EOL>cphi_array = (sn[indices]).real /...
Compute correlation (two sided) between template and data and compares with autocorrelation of the template: C(t) = IFFT(A*A/S(f)) Parameters ---------- sn: Array[complex] normalized (!) array of complex snr for the template that produced the trigger(s) being tested corr_sn : Array[complex] normalized (!) ...
f15959:m0
def __init__(self, stride, num_points, onesided=None, twophase=False,<EOL>reverse_template=False, take_maximum_value=False,<EOL>maximal_value_dof=None):
if stride > <NUM_LIT:0>:<EOL><INDENT>self.do = True<EOL>self.column_name = "<STR_LIT>"<EOL>self.table_dof_name = "<STR_LIT>"<EOL>self.dof = num_points<EOL>self.num_points = num_points<EOL>self.stride = stride<EOL>self.one_sided = onesided<EOL>if (onesided is not None):<EOL><INDENT>self.dof = self.dof * <NUM_LIT:2><EOL>...
Initialize autochisq calculation instance Parameters ----------- stride : int Number of sample points between points at which auto-chisq is calculated. num_points : int Number of sample points at which to calculate auto-chisq in each direction from the trigger onesided : optional, default=None, choices...
f15959:c0:m0
def values(self, sn, indices, template, psd, norm, stilde=None,<EOL>low_frequency_cutoff=None, high_frequency_cutoff=None):
if self.do and (len(indices) > <NUM_LIT:0>):<EOL><INDENT>htilde = make_frequency_series(template)<EOL>key = (id(template), id(psd))<EOL>if key != self._autocor_id:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>if not self.reverse_template:<EOL><INDENT>Pt, _, P_norm = matched_filter_core(htilde,<EOL>htilde, psd=psd,<EOL>low...
Calculate the auto-chisq at the specified indices. Parameters ----------- sn : Array[complex] SNR time series of the template for which auto-chisq is being computed. Provided unnormalized. indices : Array[int] List of points at which to calculate auto-chisq template : Pycbc template object The template...
f15959:c0:m1
def power_chisq_bins_from_sigmasq_series(sigmasq_series, num_bins, kmin, kmax):
sigmasq = sigmasq_series[kmax - <NUM_LIT:1>]<EOL>edge_vec = numpy.arange(<NUM_LIT:0>, num_bins) * sigmasq / num_bins<EOL>bins = numpy.searchsorted(sigmasq_series[kmin:kmax], edge_vec, side='<STR_LIT:right>')<EOL>bins += kmin<EOL>return numpy.append(bins, kmax)<EOL>
Returns bins of equal power for use with the chisq functions Parameters ---------- sigmasq_series: FrequencySeries A frequency series containing the cumulative power of a filter template preweighted by a psd. num_bins: int The number of chisq bins to calculate. kmin: int ...
f15960:m0
def power_chisq_bins(htilde, num_bins, psd, low_frequency_cutoff=None,<EOL>high_frequency_cutoff=None):
sigma_vec = sigmasq_series(htilde, psd, low_frequency_cutoff,<EOL>high_frequency_cutoff).numpy()<EOL>kmin, kmax = get_cutoff_indices(low_frequency_cutoff,<EOL>high_frequency_cutoff,<EOL>htilde.delta_f,<EOL>(len(htilde)-<NUM_LIT:1>)*<NUM_LIT:2>)<EOL>return power_chisq_bins_from_sigmasq_series(sigma_vec, num_bins, kmin, ...
Returns bins of equal power for use with the chisq functions Parameters ---------- htilde: FrequencySeries A frequency series containing the template waveform num_bins: int The number of chisq bins to calculate. psd: FrequencySeries A frequency series containing the psd. It...
f15960:m1
@schemed(BACKEND_PREFIX)<EOL>def shift_sum(v1, shifts, bins):
err_msg = "<STR_LIT>"<EOL>err_msg += "<STR_LIT>"<EOL>raise ValueError(err_msg)<EOL>
Calculate the time shifted sum of the FrequencySeries
f15960:m3
def power_chisq_at_points_from_precomputed(corr, snr, snr_norm, bins, indices):
num_bins = len(bins) - <NUM_LIT:1><EOL>chisq = shift_sum(corr, indices, bins) <EOL>return (chisq * num_bins - (snr.conj() * snr).real) * (snr_norm ** <NUM_LIT>)<EOL>
Calculate the chisq timeseries from precomputed values for only select points. This function calculates the chisq at each point by explicitly time shifting and summing each bin. No FFT is involved. Parameters ---------- corr: FrequencySeries The product of the template and data in the freq...
f15960:m4
def power_chisq_from_precomputed(corr, snr, snr_norm, bins, indices=None, return_bins=False):
<EOL>global _q_l, _qtilde_l, _chisq_l<EOL>bin_snrs = []<EOL>if _q_l is None or len(_q_l) != len(snr):<EOL><INDENT>q = zeros(len(snr), dtype=complex_same_precision_as(snr))<EOL>qtilde = zeros(len(snr), dtype=complex_same_precision_as(snr))<EOL>_q_l = q<EOL>_qtilde_l = qtilde<EOL><DEDENT>else:<EOL><INDENT>q = _q_l<EOL>qt...
Calculate the chisq timeseries from precomputed values. This function calculates the chisq at all times by performing an inverse FFT of each bin. Parameters ---------- corr: FrequencySeries The produce of the template and data in the frequency domain. snr: TimeSeries The unnor...
f15960:m5
def power_chisq(template, data, num_bins, psd,<EOL>low_frequency_cutoff=None,<EOL>high_frequency_cutoff=None,<EOL>return_bins=False):
htilde = make_frequency_series(template)<EOL>stilde = make_frequency_series(data)<EOL>bins = power_chisq_bins(htilde, num_bins, psd, low_frequency_cutoff,<EOL>high_frequency_cutoff)<EOL>corra = zeros((len(htilde)-<NUM_LIT:1>)*<NUM_LIT:2>, dtype=htilde.dtype)<EOL>total_snr, corr, tnorm = matched_filter_core(htilde, stil...
Calculate the chisq timeseries Parameters ---------- template: FrequencySeries or TimeSeries A time or frequency series that contains the filter template. data: FrequencySeries or TimeSeries A time or frequency series that contains the data to filter. The length must be commensu...
f15960:m7
def values(self, corr, snrv, snr_norm, psd, indices, template):
if self.do:<EOL><INDENT>num_above = len(indices)<EOL>if self.snr_threshold:<EOL><INDENT>above = abs(snrv * snr_norm) > self.snr_threshold<EOL>num_above = above.sum()<EOL>logging.info('<STR_LIT>' % num_above)<EOL>above_indices = indices[above]<EOL>above_snrv = snrv[above]<EOL>rchisq = numpy.zeros(len(indices), dtype=num...
Calculate the chisq at points given by indices. Returns ------- chisq: Array Chisq values, one for each sample index chisq_dof: Array Number of statistical degrees of freedom for the chisq test in the given template
f15960:c0:m3
def calculate_chisq_bins(self, template, psd):
num_bins = int(self.parse_option(template, self.num_bins))<EOL>if hasattr(psd, '<STR_LIT>') andtemplate.approximant in psd.sigmasq_vec:<EOL><INDENT>kmin = int(template.f_lower / psd.delta_f)<EOL>kmax = template.end_idx<EOL>bins = power_chisq_bins_from_sigmasq_series(<EOL>psd.sigmasq_vec[template.approximant], num_bins,...
Obtain the chisq bins for this template and PSD.
f15960:c1:m1
def values(self, corr_plus, corr_cross, snrv, psd,<EOL>indices, template_plus, template_cross, u_vals,<EOL>hplus_cross_corr, hpnorm, hcnorm):
if self.do:<EOL><INDENT>num_above = len(indices)<EOL>if self.snr_threshold:<EOL><INDENT>above = abs(snrv) > self.snr_threshold<EOL>num_above = above.sum()<EOL>logging.info('<STR_LIT>' % num_above)<EOL>above_indices = indices[above]<EOL>above_snrv = snrv[above]<EOL>rchisq = numpy.zeros(len(indices), dtype=numpy.float32)...
Calculate the chisq at points given by indices. Returns ------- chisq: Array Chisq values, one for each sample index chisq_dof: Array Number of statistical degrees of freedom for the chisq test in the given template
f15960:c1:m2
def __init__(self, bank, num_bins=<NUM_LIT:0>,<EOL>snr_threshold=None,<EOL>chisq_locations=None):
if snr_threshold is not None:<EOL><INDENT>self.do = True<EOL>self.num_bins = num_bins<EOL>self.snr_threshold = snr_threshold<EOL>self.params = {}<EOL>for descr in chisq_locations:<EOL><INDENT>region, values = descr.split("<STR_LIT::>")<EOL>mask = bank.table.parse_boolargs([(<NUM_LIT:1>, region), (<NUM_LIT:0>, '<STR_LIT...
Create sine-Gaussian Chisq Calculator Parameters ---------- bank: pycbc.waveform.TemplateBank The template bank that will be processed. num_bins: str The string determining the number of power chisq bins snr_threshold: float The threshold to c...
f15961:c0:m0
def values(self, stilde, template, psd, snrv, snr_norm,<EOL>bchisq, bchisq_dof, indices):
if not self.do:<EOL><INDENT>return None<EOL><DEDENT>if template.params.template_hash not in self.params:<EOL><INDENT>return numpy.ones(len(snrv))<EOL><DEDENT>values = self.params[template.params.template_hash].split('<STR_LIT:U+002C>')<EOL>bins = self.cached_chisq_bins(template, psd)<EOL>chisq = numpy.ones(len(snrv))<E...
Calculate sine-Gaussian chisq Parameters ---------- stilde: pycbc.types.Frequencyseries The overwhitened strain template: pycbc.types.Frequencyseries The waveform template being analyzed psd: pycbc.types.Frequencyseries The power spectral dens...
f15961:c0:m3
def segment_snrs(filters, stilde, psd, low_frequency_cutoff):
snrs = []<EOL>norms = []<EOL>for bank_template in filters:<EOL><INDENT>snr, _, norm = matched_filter_core(<EOL>bank_template, stilde, h_norm=bank_template.sigmasq(psd),<EOL>psd=None, low_frequency_cutoff=low_frequency_cutoff)<EOL>snrs.append(snr)<EOL>norms.append(norm)<EOL><DEDENT>return snrs, norms<EOL>
This functions calculates the snr of each bank veto template against the segment Parameters ---------- filters: list of FrequencySeries The list of bank veto templates filters. stilde: FrequencySeries The current segment of data. psd: FrequencySeries low_frequency_cutoff: fl...
f15964:m0
def template_overlaps(bank_filters, template, psd, low_frequency_cutoff):
overlaps = []<EOL>template_ow = template / psd<EOL>for bank_template in bank_filters:<EOL><INDENT>overlap = overlap_cplx(template_ow, bank_template,<EOL>low_frequency_cutoff=low_frequency_cutoff, normalized=False)<EOL>norm = sqrt(<NUM_LIT:1> / template.sigmasq(psd) / bank_template.sigmasq(psd))<EOL>overlaps.append(over...
This functions calculates the overlaps between the template and the bank veto templates. Parameters ---------- bank_filters: List of FrequencySeries template: FrequencySeries psd: FrequencySeries low_frequency_cutoff: float Returns ------- overlaps: List of complex overlap valu...
f15964:m1
def bank_chisq_from_filters(tmplt_snr, tmplt_norm, bank_snrs, bank_norms,<EOL>tmplt_bank_matches, indices=None):
if indices is not None:<EOL><INDENT>tmplt_snr = Array(tmplt_snr, copy=False)<EOL>bank_snrs_tmp = []<EOL>for bank_snr in bank_snrs:<EOL><INDENT>bank_snrs_tmp.append(bank_snr.take(indices))<EOL><DEDENT>bank_snrs=bank_snrs_tmp<EOL><DEDENT>bank_chisq = zeros(len(tmplt_snr), dtype=real_same_precision_as(tmplt_snr))<EOL>for ...
This function calculates and returns a TimeSeries object containing the bank veto calculated over a segment. Parameters ---------- tmplt_snr: TimeSeries The SNR time series from filtering the segment against the current search template tmplt_norm: float The normalization fac...
f15964:m2
def values(self, template, psd, stilde, snrv, norm, indices):
if self.do:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>overlaps = self.cache_overlaps(template, psd)<EOL>bank_veto_snrs, bank_veto_norms = self.cache_segment_snrs(stilde, psd)<EOL>chisq = bank_chisq_from_filters(snrv, norm, bank_veto_snrs,<EOL>bank_veto_norms, overlaps, indices)<EOL>dof = numpy.repeat(self.dof, len(chis...
Returns ------- bank_chisq_from_filters: TimeSeries of bank veto values - if indices is None then evaluated at all time samples, if not then only at requested sample indices bank_chisq_dof: int, approx number of statistical degrees of freedom
f15964:c0:m3
def snr_series_to_xml(snr_series, document, sngl_inspiral_id):
snr_lal = snr_series.lal()<EOL>snr_lal.name = '<STR_LIT>'<EOL>snr_lal.sampleUnits = '<STR_LIT>'<EOL>snr_xml = _build_series(snr_lal, (u'<STR_LIT>', u'<STR_LIT>'), None,<EOL>'<STR_LIT>', '<STR_LIT:s>')<EOL>snr_node = document.childNodes[-<NUM_LIT:1>].appendChild(snr_xml)<EOL>eid_param = ligolw_param.Param.build(u'<STR_L...
Save an SNR time series into an XML document, in a format compatible with BAYESTAR.
f15965:m1
def make_psd_xmldoc(psddict, xmldoc=None):
xmldoc = ligolw.Document() if xmldoc is None else xmldoc.childNodes[<NUM_LIT:0>]<EOL>root_name = u"<STR_LIT>"<EOL>Attributes = ligolw.sax.xmlreader.AttributesImpl<EOL>lw = xmldoc.appendChild(<EOL>ligolw.LIGO_LW(Attributes({u"<STR_LIT:Name>": root_name})))<EOL>for instrument, psd in psddict.items():<EOL><INDENT>xmlserie...
Add a set of PSDs to a LIGOLW XML document. If the document is not given, a new one is created first.
f15965:m2
def __init__(self, ifos, coinc_results, **kwargs):
self.template_id = coinc_results['<STR_LIT>' % ifos[<NUM_LIT:0>]]<EOL>self.coinc_results = coinc_results<EOL>self.ifos = ifos<EOL>self.is_hardware_injection = ('<STR_LIT>' in coinc_results<EOL>and coinc_results['<STR_LIT>'])<EOL>if '<STR_LIT>' in kwargs:<EOL><INDENT>fud = kwargs['<STR_LIT>']<EOL>assert len({fud[ifo]['<...
Initialize a ligolw xml representation of a zerolag trigger for upload from pycbc live to gracedb. Parameters ---------- ifos: list of strs A list of the ifos pariticipating in this trigger coinc_results: dict of values A dictionary of values. The format ...
f15965:c0:m0
def save(self, filename):
gz = filename.endswith('<STR_LIT>')<EOL>ligolw_utils.write_filename(self.outdoc, filename, gz=gz)<EOL>
Write this trigger to gracedb compatible xml format Parameters ---------- filename: str Name of file to write to disk.
f15965:c0:m1
def default_empty(shape, dtype):
default = numpy.zeros(shape, dtype=dtype)<EOL>set_default_empty(default)<EOL>return default<EOL>
Numpy's empty array can have random values in it. To prevent that, we define here a default emtpy array. This default empty is a numpy.zeros array, except that objects are set to None, and all ints to ID_NOT_SET.
f15966:m1
def lstring_as_obj(true_or_false=None):
if true_or_false is not None:<EOL><INDENT>_default_types_status['<STR_LIT>'] = true_or_false<EOL>numpy.typeDict[u'<STR_LIT>'] = numpy.object_if _default_types_status['<STR_LIT>']else '<STR_LIT>' % _default_types_status['<STR_LIT>']<EOL><DEDENT>return _default_types_status['<STR_LIT>']<EOL>
Toggles whether lstrings should be treated as strings or as objects. When FieldArrays is first loaded, the default is True. Parameters ---------- true_or_false : {None|bool} Pass True to map lstrings to objects; False otherwise. If None provided, just returns the current state. Ret...
f15966:m2
def ilwd_as_int(true_or_false=None):
if true_or_false is not None:<EOL><INDENT>_default_types_status['<STR_LIT>'] = true_or_false<EOL>numpy.typeDict[u'<STR_LIT>'] = intif _default_types_status['<STR_LIT>']else '<STR_LIT>' % default_strlen<EOL><DEDENT>return _default_types_status['<STR_LIT>']<EOL>
Similar to lstring_as_obj, sets whether or not ilwd:chars should be treated as strings or as ints. Default is True.
f15966:m3
def default_strlen(strlen=None):
if strlen is not None:<EOL><INDENT>_default_types_status['<STR_LIT>'] = strlen<EOL>lstring_as_obj(_default_types_status['<STR_LIT>'])<EOL>ilwd_as_int(_default_types_status['<STR_LIT>'])<EOL><DEDENT>return _default_types_status['<STR_LIT>']<EOL>
Sets the default string length for lstring and ilwd:char, if they are treated as strings. Default is 50.
f15966:m4
def get_vars_from_arg(arg):
return set(_pyparser.findall(arg))<EOL>
Given a python string, gets the names of any identifiers use in it. For example, if ``arg = '3*narf/foo.bar'``, this will return ``set(['narf', 'foo', 'bar'])``.
f15966:m5
def get_fields_from_arg(arg):
return set(_fieldparser.findall(arg))<EOL>
Given a python string, gets FieldArray field names used in it. This differs from get_vars_from_arg in that any identifier with a '.' in it will be treated as one identifier. For example, if ``arg = '3*narf/foo.bar'``, this will return ``set(['narf', 'foo.bar'])``.
f15966:m6
def get_instance_fields_from_arg(arg):
return set(_instfieldparser.findall(arg))<EOL>
Given a python string definining a method function on an instance of an FieldArray, returns the field names used in it. This differs from get_fields_from_arg in that it looks for variables that start with 'self'.
f15966:m7
def get_needed_fieldnames(arr, names):
fieldnames = set([])<EOL>cls = arr.__class__<EOL>if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL><DEDENT>parsed_names = set([])<EOL>for name in names:<EOL><INDENT>parsed_names.update(get_fields_from_arg(name))<EOL><DEDENT>names = list(parsed_names & (set(dir(arr)) | set(arr.fieldnames)))<EOL>for nam...
Given a FieldArray-like array and a list of names, determines what fields are needed from the array so that using the names does not result in an error. Parameters ---------- arr : instance of a FieldArray or similar The array from which to determine what fields to get. names : (list of...
f15966:m8
def get_dtype_descr(dtype):
return [dt for dt in dtype.descr if not (dt[<NUM_LIT:0>] == '<STR_LIT>' and dt[<NUM_LIT:1>][<NUM_LIT:1>] == '<STR_LIT>')]<EOL>
Numpy's ``dtype.descr`` will return empty void fields if a dtype has offsets specified. This function tries to fix that by not including fields that have no names and are void types.
f15966:m9
def combine_fields(dtypes):
if not isinstance(dtypes, list):<EOL><INDENT>dtypes = [dtypes]<EOL><DEDENT>new_dt = numpy.dtype([dt for dtype in dtypesfor dt in get_dtype_descr(dtype)])<EOL>return new_dt<EOL>
Combines the fields in the list of given dtypes into a single dtype. Parameters ---------- dtypes : (list of) numpy.dtype(s) Either a numpy.dtype, or a list of numpy.dtypes. Returns ------- numpy.dtype A new dtype combining the fields in the list of dtypes.
f15966:m10
def _ensure_array_list(arrays):
<EOL>return [numpy.array(arr, ndmin=<NUM_LIT:1>) if not isinstance(arr, numpy.ndarray)<EOL>else arr for arr in arrays]<EOL>
Ensures that every element in a list is an instance of a numpy array.
f15966:m11
def merge_arrays(merge_list, names=None, flatten=True, outtype=None):
<EOL>merge_list = _ensure_array_list(merge_list)<EOL>if not all(merge_list[<NUM_LIT:0>].shape == arr.shape for arr in merge_list):<EOL><INDENT>raise ValueError("<STR_LIT>" +<EOL>"<STR_LIT>")<EOL><DEDENT>if flatten:<EOL><INDENT>new_dt = combine_fields([arr.dtype for arr in merge_list])<EOL><DEDENT>else:<EOL><INDENT>new_...
Merges the given arrays into a single array. The arrays must all have the same shape. If one or more of the given arrays has multiple fields, all of the fields will be included as separate fields in the new array. Parameters ---------- merge_list : list of arrays The list of arrays to merge...
f15966:m12
def add_fields(input_array, arrays, names=None, assubarray=False):
if not isinstance(arrays, list):<EOL><INDENT>arrays = [arrays]<EOL><DEDENT>arrays = _ensure_array_list(arrays)<EOL>if names is not None:<EOL><INDENT>if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL><DEDENT>subarray_names = [name for name in names if len(name.split('<STR_LIT:.>')) > <NUM_LIT:1>]<EOL><...
Adds the given array(s) as new field(s) to the given input array. Returns a new instance of the input_array with the new fields added. Parameters ---------- input_array : instance of a numpy.ndarray or numpy recarray The array to to add the fields to. arrays : (list of) numpy array(s) ...
f15966:m13
def _isstring(dtype):
return dtype.type == numpy.unicode_ or dtype.type == numpy.string_<EOL>
Given a numpy dtype, determines whether it is a string. Returns True if the dtype is string or unicode.
f15966:m14
def aliases_from_fields(fields):
return dict(c for c in fields if isinstance(c, tuple))<EOL>
Given a dictionary of fields, will return a dictionary mapping the aliases to the names.
f15966:m15
def fields_from_names(fields, names=None):
if names is None:<EOL><INDENT>return fields<EOL><DEDENT>if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL><DEDENT>aliases_to_names = aliases_from_fields(fields)<EOL>names_to_aliases = dict(zip(aliases_to_names.values(),<EOL>aliases_to_names.keys()))<EOL>outfields = {}<EOL>for name in names:<EOL><INDEN...
Given a dictionary of fields and a list of names, will return a dictionary consisting of the fields specified by names. Names can be either the names of fields, or their aliases.
f15966:m16
def __new__(cls, shape, name=None, zero=True, **kwargs):
obj = super(FieldArray, cls).__new__(cls, shape, **kwargs).view(<EOL>type=cls)<EOL>obj.name = name<EOL>obj.__persistent_attributes__ = [a<EOL>for a in cls.__persistent_attributes__]<EOL>obj._functionlib = {f: func for f,func in cls._functionlib.items()}<EOL>obj._virtualfields = [f for f in cls._virtualfields]<EOL>if ze...
Initializes a new empty array.
f15966:c0:m0
def __array_finalize__(self, obj):
if obj is None:<EOL><INDENT>return<EOL><DEDENT>try:<EOL><INDENT>obj.__copy_attributes__(self)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>if self.dtype.names is not None andany(isinstance(name, unicode) for name in obj.dtype.names):<EOL><INDENT>self.dtype.names = map(str, self.dtype.names)<EOL><DEDE...
Default values are set here. See <https://docs.scipy.org/doc/numpy/user/basics.subclassing.html> for details.
f15966:c0:m1
def __copy_attributes__(self, other, default=None):
[setattr(other, attr, copy.deepcopy(getattr(self, attr, default)))for attr in self.__persistent_attributes__]<EOL>
Copies the values of all of the attributes listed in `self.__persistent_attributes__` to other.
f15966:c0:m2
def __getattribute__(self, attr):
<EOL>try:<EOL><INDENT>return numpy.ndarray.__getattribute__(self, attr)<EOL><DEDENT>except AttributeError as e:<EOL><INDENT>if attr in self.fields:<EOL><INDENT>return self.__getitem__(attr)<EOL><DEDENT>raise AttributeError(e)<EOL><DEDENT>
Allows fields to be accessed as attributes.
f15966:c0:m3
def __setitem__(self, item, values):
if type(item) is int and type(values) is numpy.ndarray:<EOL><INDENT>values = tuple(values)<EOL><DEDENT>try:<EOL><INDENT>return super(FieldArray, self).__setitem__(item, values)<EOL><DEDENT>except ValueError:<EOL><INDENT>fields = item.split('<STR_LIT:.>')<EOL>if len(fields) > <NUM_LIT:1>:<EOL><INDENT>for field in fields...
Wrap's recarray's setitem to allow attribute-like indexing when setting values.
f15966:c0:m4
def __getbaseitem__(self, item):
<EOL>out = self.view(numpy.ndarray)[item]<EOL>if out.dtype.fields is None:<EOL><INDENT>return out<EOL><DEDENT>elif out.ndim == <NUM_LIT:0>:<EOL><INDENT>return out.view(numpy.recarray)<EOL><DEDENT>else:<EOL><INDENT>return out.view(type(self))<EOL><DEDENT>
Gets an item assuming item is either an index or a fieldname.
f15966:c0:m5
def __getsubitem__(self, item):
try:<EOL><INDENT>return self.__getbaseitem__(item)<EOL><DEDENT>except ValueError as err:<EOL><INDENT>subitems = item.split('<STR_LIT:.>')<EOL>if len(subitems) > <NUM_LIT:1>:<EOL><INDENT>return self.__getbaseitem__(subitems[<NUM_LIT:0>]<EOL>).__getsubitem__('<STR_LIT:.>'.join(subitems[<NUM_LIT:1>:]))<EOL><DEDENT>else:<E...
Gets a subfield using `field.subfield` notation.
f15966:c0:m6
def __getitem__(self, item):
try:<EOL><INDENT>return self.__getsubitem__(item)<EOL><DEDENT>except ValueError:<EOL><INDENT>item_dict = dict(_numpy_function_lib.items())<EOL>item_dict.update(self._functionlib)<EOL>itemvars = get_vars_from_arg(item)<EOL>itemvars = get_fields_from_arg(item)<EOL>d = {attr: getattr(self, attr)<EOL>for attr in set(dir(se...
Wraps recarray's `__getitem__` so that math functions on fields and attributes can be retrieved. Any function in numpy's library may be used.
f15966:c0:m7
def __contains__(self, field):
return field in self.fields<EOL>
Returns True if the given field name is in self's fields.
f15966:c0:m8
def sort(self, axis=-<NUM_LIT:1>, kind='<STR_LIT>', order=None):
try:<EOL><INDENT>numpy.recarray.sort(self, axis=axis, kind=kind, order=order)<EOL><DEDENT>except ValueError:<EOL><INDENT>if isinstance(order, list):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self[:] = self[numpy.argsort(self[order])]<EOL><DEDENT>
Sort an array, in-place. This function extends the standard numpy record array in-place sort to allow the basic use of Field array virtual fields. Only a single field is currently supported when referencing a virtual field. Parameters ---------- axis : int, optional ...
f15966:c0:m9
def addattr(self, attrname, value=None, persistent=True):
setattr(self, attrname, value)<EOL>if persistent and attrname not in self.__persistent_attributes__:<EOL><INDENT>self.__persistent_attributes__.append(attrname)<EOL><DEDENT>
Adds an attribute to self. If persistent is True, the attribute will be made a persistent attribute. Persistent attributes are copied whenever a view or copy of this array is created. Otherwise, new views or copies of this will not have the attribute.
f15966:c0:m10
def add_methods(self, names, methods):
if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL>methods = [methods]<EOL><DEDENT>for name,method in zip(names, methods):<EOL><INDENT>setattr(self, name, types.MethodType(method, self))<EOL><DEDENT>
Adds the given method(s) as instance method(s) of self. The method(s) must take `self` as a first argument.
f15966:c0:m11
def add_properties(self, names, methods):
cls = type(self)<EOL>cls = type(cls.__name__, (cls,), dict(cls.__dict__))<EOL>if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL>methods = [methods]<EOL><DEDENT>for name,method in zip(names, methods):<EOL><INDENT>setattr(cls, name, property(method))<EOL><DEDENT>return self.view(type=cls)<EOL>
Returns a view of self with the given methods added as properties. From: <http://stackoverflow.com/a/2954373/1366472>.
f15966:c0:m12
def add_virtualfields(self, names, methods):
if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL>methods = [methods]<EOL><DEDENT>out = self.add_properties(names, methods)<EOL>if out._virtualfields is None:<EOL><INDENT>out._virtualfields = []<EOL><DEDENT>out._virtualfields.extend(names)<EOL>return out<EOL>
Returns a view of this array with the given methods added as virtual fields. Specifically, the given methods are added using add_properties and their names are added to the list of virtual fields. Virtual fields are properties that are assumed to operate on one or more of self's fields, ...
f15966:c0:m13
def add_functions(self, names, functions):
if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL>functions = [functions]<EOL><DEDENT>if len(functions) != len(names):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>self._functionlib.update(dict(zip(names, functions)))<EOL>
Adds the given functions to the function library. Functions are added to this instance of the array; all copies of and slices of this array will also have the new functions included. Parameters ---------- names : (list of) string(s) Name or list of names of the func...
f15966:c0:m14
def del_functions(self, names):
if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL><DEDENT>for name in names:<EOL><INDENT>self._functionlib.pop(name)<EOL><DEDENT>
Removes the specified function names from the function library. Functions are removed from this instance of the array; all copies and slices of this array will also have the functions removed. Parameters ---------- names : (list of) string(s) Name or list of names o...
f15966:c0:m15
@classmethod<EOL><INDENT>def from_arrays(cls, arrays, name=None, **kwargs):<DEDENT>
obj = numpy.rec.fromarrays(arrays, **kwargs).view(type=cls)<EOL>obj.name = name<EOL>return obj<EOL>
Creates a new instance of self from the given (list of) array(s). This is done by calling numpy.rec.fromarrays on the given arrays with the given kwargs. The type of the returned array is cast to this class, and the name (if provided) is set. Parameters ---------- arrays...
f15966:c0:m16
@classmethod<EOL><INDENT>def from_records(cls, records, name=None, **kwargs):<DEDENT>
obj = numpy.rec.fromrecords(records, **kwargs).view(<EOL>type=cls)<EOL>obj.name = name<EOL>return obj<EOL>
Creates a new instance of self from the given (list of) record(s). A "record" is a tuple in which each element is the value of one field in the resulting record array. This is done by calling `numpy.rec.fromrecords` on the given records with the given kwargs. The type of the returned ar...
f15966:c0:m17
@classmethod<EOL><INDENT>def from_kwargs(cls, **kwargs):<DEDENT>
arrays = []<EOL>names = []<EOL>for p,vals in kwargs.items():<EOL><INDENT>if not isinstance(vals, numpy.ndarray):<EOL><INDENT>if not isinstance(vals, list):<EOL><INDENT>vals = [vals]<EOL><DEDENT>vals = numpy.array(vals)<EOL><DEDENT>arrays.append(vals)<EOL>names.append(p)<EOL><DEDENT>return cls.from_arrays(arrays, names=...
Creates a new instance of self from the given keyword arguments. Each argument will correspond to a field in the returned array, with the name of the field given by the keyword, and the value(s) whatever the keyword was set to. Each keyword may be set to a single value or a list of value...
f15966:c0:m18
@classmethod<EOL><INDENT>def from_ligolw_table(cls, table, columns=None, cast_to_dtypes=None):<DEDENT>
name = table.tableName.split('<STR_LIT::>')[<NUM_LIT:0>]<EOL>if columns is None:<EOL><INDENT>columns = table.validcolumns<EOL><DEDENT>else:<EOL><INDENT>new_columns = {}<EOL>for col in columns:<EOL><INDENT>new_columns[col] = table.validcolumns[col]<EOL><DEDENT>columns = new_columns<EOL><DEDENT>if cast_to_dtypes is not N...
Converts the given ligolw table into an FieldArray. The `tableName` attribute is copied to the array's `name`. Parameters ---------- table : LIGOLw table instance The table to convert. columns : {None|list} Optionally specify a list of columns to retrieve...
f15966:c0:m19
def to_array(self, fields=None, axis=<NUM_LIT:0>):
if fields is None:<EOL><INDENT>fields = self.fieldnames<EOL><DEDENT>if isinstance(fields, string_types):<EOL><INDENT>fields = [fields]<EOL><DEDENT>return numpy.stack([self[f] for f in fields], axis=axis)<EOL>
Returns an `numpy.ndarray` of self in which the fields are included as an extra dimension. Parameters ---------- fields : {None, (list of) strings} The fields to get. All of the fields must have the same datatype. If None, will try to return all of the fields. ...
f15966:c0:m20
@property<EOL><INDENT>def fieldnames(self):<DEDENT>
return self.dtype.names<EOL>
Returns a tuple listing the field names in self. Equivalent to `array.dtype.names`, where `array` is self.
f15966:c0:m21
@property<EOL><INDENT>def virtualfields(self):<DEDENT>
if self._virtualfields is None:<EOL><INDENT>vfs = tuple()<EOL><DEDENT>else:<EOL><INDENT>vfs = tuple(self._virtualfields)<EOL><DEDENT>return vfs<EOL>
Returns a tuple listing the names of virtual fields in self.
f15966:c0:m22
@property<EOL><INDENT>def functionlib(self):<DEDENT>
return self._functionlib<EOL>
Returns the library of functions that are available when calling items.
f15966:c0:m23
@property<EOL><INDENT>def fields(self):<DEDENT>
return tuple(list(self.fieldnames) + list(self.virtualfields))<EOL>
Returns a tuple listing the names of fields and virtual fields in self.
f15966:c0:m24
@property<EOL><INDENT>def aliases(self):<DEDENT>
return dict(c[<NUM_LIT:0>] for c in self.dtype.descr if isinstance(c[<NUM_LIT:0>], tuple))<EOL>
Returns a dictionary of the aliases, or "titles", of the field names in self. An alias can be specified by passing a tuple in the name part of the dtype. For example, if an array is created with ``dtype=[(('foo', 'bar'), float)]``, the array will have a field called `bar` that has alias ...
f15966:c0:m25
def add_fields(self, arrays, names=None, assubarray=False):
newself = add_fields(self, arrays, names=names, assubarray=assubarray)<EOL>self.__copy_attributes__(newself)<EOL>return newself<EOL>
Adds the given arrays as new fields to self. Returns a new instance with the new fields added. Note: this array does not change; the returned array is a new copy. Parameters ---------- arrays : (list of) numpy array(s) The arrays to add. If adding multiple arrays, must be a list; if adding a single array, can...
f15966:c0:m26
def parse_boolargs(self, args):
if not isinstance(args, list):<EOL><INDENT>args = [args]<EOL><DEDENT>return_vals = []<EOL>bool_args = []<EOL>for arg in args:<EOL><INDENT>if not isinstance(arg, tuple):<EOL><INDENT>return_val = arg<EOL>bool_arg = None<EOL><DEDENT>elif len(arg) == <NUM_LIT:1>:<EOL><INDENT>return_val = arg[<NUM_LIT:0>]<EOL>bool_arg = Non...
Returns an array populated by given values, with the indices of those values dependent on given boolen tests on self. The given `args` should be a list of tuples, with the first element the return value and the second argument a string that evaluates to either True or False for each ele...
f15966:c0:m27
def append(self, other):
try:<EOL><INDENT>return numpy.append(self, other).view(type=self.__class__)<EOL><DEDENT>except TypeError:<EOL><INDENT>str_fields = [name for name in self.fieldnames<EOL>if _isstring(self.dtype[name])]<EOL>new_strlens = dict(<EOL>[[name,<EOL>max(self.dtype[name].itemsize, other.dtype[name].itemsize)]<EOL>for name in str...
Appends another array to this array. The returned array will have all of the class methods and virutal fields of this array, including any that were added using `add_method` or `add_virtualfield`. If this array and other array have one or more string fields, the dtype for those fields a...
f15966:c0:m28
@classmethod<EOL><INDENT>def parse_parameters(cls, parameters, possible_fields):<DEDENT>
if isinstance(possible_fields, string_types):<EOL><INDENT>possible_fields = [possible_fields]<EOL><DEDENT>possible_fields = map(str, possible_fields)<EOL>arr = cls(<NUM_LIT:1>, dtype=zip(possible_fields,<EOL>len(possible_fields)*[float]))<EOL>return list(get_needed_fieldnames(arr, parameters))<EOL>
Parses a list of parameters to get the list of fields needed in order to evaluate those parameters. Parameters ---------- parameters : (list of) string(s) The list of desired parameters. These can be (functions of) fields or virtual fields. possible_field...
f15966:c0:m29
@classmethod<EOL><INDENT>def default_fields(cls, include_virtual=True, **kwargs):<DEDENT>
output = cls._staticfields.copy()<EOL>if include_virtual:<EOL><INDENT>output.update({name: VIRTUALFIELD_DTYPE<EOL>for name in cls._virtualfields})<EOL><DEDENT>return output<EOL>
The default fields and their dtypes. By default, this returns whatever the class's ``_staticfields`` and ``_virtualfields`` is set to as a dictionary of fieldname, dtype (the dtype of virtualfields is given by VIRTUALFIELD_DTYPE). This function should be overridden by subclasses to add d...
f15966:c1:m0
def __new__(cls, shape, name=None, additional_fields=None,<EOL>field_kwargs=None, **kwargs):
if field_kwargs is None:<EOL><INDENT>field_kwargs = {}<EOL><DEDENT>if '<STR_LIT>' in kwargs and '<STR_LIT>' in kwargs:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>default_fields = cls.default_fields(include_virtual=False,<EOL>**field_kwargs)<EOL>if '<STR_LIT>' in kwargs:<EOL><INDENT>names = kwargs.pop('<STR_L...
The ``additional_fields`` should be specified in the same way as ``dtype`` is normally given to FieldArray. The ``field_kwargs`` are passed to the class's default_fields method as keyword arguments.
f15966:c1:m1
def add_default_fields(self, names, **kwargs):
if isinstance(names, string_types):<EOL><INDENT>names = [names]<EOL><DEDENT>default_fields = self.default_fields(include_virtual=False, **kwargs)<EOL>arr = self.__class__(<NUM_LIT:1>, field_kwargs=kwargs)<EOL>sortdict = dict([[nm, ii] for ii,nm in enumerate(names)])<EOL>names = list(get_needed_fieldnames(arr, names))<E...
Adds one or more empty default fields to self. Parameters ---------- names : (list of) string(s) The names of the fields to add. Must be a field in self's default fields. Other keyword args are any arguments passed to self's default fields. Returns ------- new array : instance of this array A copy of thi...
f15966:c1:m2
@classmethod<EOL><INDENT>def parse_parameters(cls, parameters, possible_fields=None):<DEDENT>
if possible_fields is not None:<EOL><INDENT>possible_fields = dict([[f, dt]<EOL>for f,dt in possible_fields.items()])<EOL>class ModifiedArray(cls):<EOL><INDENT>_staticfields = possible_fields<EOL><DEDENT>cls = ModifiedArray<EOL><DEDENT>return cls(<NUM_LIT:1>, names=parameters).fieldnames<EOL>
Parses a list of parameters to get the list of fields needed in order to evaluate those parameters. Parameters ---------- parameters : (list of) strings The list of desired parameters. These can be (functions of) fields or virtual fields. possible_fields ...
f15966:c1:m3
@property<EOL><INDENT>def primary_mass(self):<DEDENT>
return conversions.primary_mass(self.mass1, self.mass2)<EOL>
Returns the larger of self.mass1 and self.mass2.
f15966:c2:m0
@property<EOL><INDENT>def secondary_mass(self):<DEDENT>
return conversions.secondary_mass(self.mass1, self.mass)<EOL>
Returns the smaller of self.mass1 and self.mass2.
f15966:c2:m1
@property<EOL><INDENT>def mtotal(self):<DEDENT>
return conversions.mtotal_from_mass1_mass2(self.mass1, self.mass2)<EOL>
Returns the total mass.
f15966:c2:m2
@property<EOL><INDENT>def q(self):<DEDENT>
return conversions.q_from_mass1_mass2(self.mass1, self.mass2)<EOL>
Returns the mass ratio m1/m2, where m1 >= m2.
f15966:c2:m3
@property<EOL><INDENT>def eta(self):<DEDENT>
return conversions.eta_from_mass1_mass2(self.mass1, self.mass2)<EOL>
Returns the symmetric mass ratio.
f15966:c2:m4
@property<EOL><INDENT>def mchirp(self):<DEDENT>
return conversions.mchirp_from_mass1_mass2(self.mass1, self.mass2)<EOL>
Returns the chirp mass.
f15966:c2:m5
@property<EOL><INDENT>def chi_eff(self):<DEDENT>
return conversions.chi_eff(self.mass1, self.mass2, self.spin1z,<EOL>self.spin2z)<EOL>
Returns the effective spin.
f15966:c2:m6
@property<EOL><INDENT>def spin_px(self):<DEDENT>
return conversions.primary_spin(self.mass1, self.mass2, self.spin1x,<EOL>self.spin2x)<EOL>
Returns the x-component of the spin of the primary mass.
f15966:c2:m7
@property<EOL><INDENT>def spin_py(self):<DEDENT>
return conversions.primary_spin(self.mass1, self.mass2, self.spin1y,<EOL>self.spin2y)<EOL>
Returns the y-component of the spin of the primary mass.
f15966:c2:m8