signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def calibration_lines(freqs, data, tref=None): | if tref is None:<EOL><INDENT>tref = float(data.start_time)<EOL><DEDENT>for freq in freqs:<EOL><INDENT>measured_line = matching_line(freq, data, tref,<EOL>bin_size=data.duration)<EOL>data -= measured_line.data.real<EOL><DEDENT>return data<EOL> | Extract the calibration lines from strain data.
Parameters
----------
freqs: list
List containing the frequencies of the calibration lines.
data: pycbc.types.TimeSeries
Strain data to extract the calibration lines from.
tref: {None, float}, optional
Reference time for the li... | f16021:m4 |
def clean_data(freqs, data, chunk, avg_bin): | if avg_bin >= chunk:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if chunk >= data.duration:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>steps = numpy.arange(<NUM_LIT:0>, int(data.duration/chunk)-<NUM_LIT:0.5>, <NUM_LIT:0.5>)<EOL>seglen = chunk * data.sample_rate<EOL>t... | Extract time-varying (wandering) lines from strain data.
Parameters
----------
freqs: list
List containing the frequencies of the wandering lines.
data: pycbc.types.TimeSeries
Strain data to extract the wandering lines from.
chunk: float
Duration of the chunks the data will ... | f16021:m5 |
@abstractmethod<EOL><INDENT>def apply_calibration(self, strain):<DEDENT> | return<EOL> | Apply calibration model
This method should be overwritten by subclasses
Parameters
----------
strain : FrequencySeries
The strain to be recalibrated.
Return
------
strain_adjusted : FrequencySeries
The recalibrated strain. | f16022:c0:m1 |
def map_to_adjust(self, strain, prefix='<STR_LIT>', **params): | self.params.update({<EOL>key[len(prefix):]: params[key]<EOL>for key in params if prefix in key and self.ifo_name in key})<EOL>strain_adjusted = self.apply_calibration(strain)<EOL>return strain_adjusted<EOL> | Map an input dictionary of sampling parameters to the
adjust_strain function by filtering the dictionary for the
calibration parameters, then calling adjust_strain.
Parameters
----------
strain : FrequencySeries
The strain to be recalibrated.
prefix: str
... | f16022:c0:m2 |
@classmethod<EOL><INDENT>def from_config(cls, cp, ifo, section):<DEDENT> | all_params = dict(cp.items(section))<EOL>params = {key[len(ifo)+<NUM_LIT:1>:]: all_params[key]<EOL>for key in all_params if ifo.lower() in key}<EOL>model = params.pop('<STR_LIT>')<EOL>params['<STR_LIT>'] = ifo.lower()<EOL>return all_models[model](**params)<EOL> | Read a config file to get calibration options and transfer
functions which will be used to intialize the model.
Parameters
----------
cp : WorkflowConfigParser
An open config file.
ifo : string
The detector (H1, L1) for which the calibration model will
... | f16022:c0:m3 |
def __init__(self, minimum_frequency, maximum_frequency, n_points,<EOL>ifo_name): | Recalibrate.__init__(self, ifo_name=ifo_name)<EOL>minimum_frequency = float(minimum_frequency)<EOL>maximum_frequency = float(maximum_frequency)<EOL>n_points = int(n_points)<EOL>if n_points < <NUM_LIT:4>:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>self.n_points = n_points<EOL>self.spline_points = np.logs... | Cubic spline recalibration
see https://dcc.ligo.org/LIGO-T1400682/public
This assumes the spline points follow
np.logspace(np.log(minimum_frequency), np.log(maximum_frequency),
n_points)
Parameters
----------
minimum_frequency: float
minimum frequency of spline points
maximum_frequency: float
max... | f16022:c1:m0 |
def apply_calibration(self, strain): | amplitude_parameters =[self.params['<STR_LIT>'.format(self.ifo_name, ii)]<EOL>for ii in range(self.n_points)]<EOL>amplitude_spline = UnivariateSpline(self.spline_points,<EOL>amplitude_parameters)<EOL>delta_amplitude = amplitude_spline(strain.sample_frequencies.numpy())<EOL>phase_parameters =[self.params['<STR_LIT>'.for... | Apply calibration model
This applies cubic spline calibration to the strain.
Parameters
----------
strain : FrequencySeries
The strain to be recalibrated.
Return
------
strain_adjusted : FrequencySeries
The recalibrated strain. | f16022:c1:m1 |
def read_model_from_config(cp, ifo, section="<STR_LIT>"): | model = cp.get_opt_tag(section, "<STR_LIT>".format(ifo.lower()), None)<EOL>recalibrator = models[model].from_config(cp, ifo.lower(), section)<EOL>return recalibrator<EOL> | Returns an instance of the calibration model specified in the
given configuration file.
Parameters
----------
cp : WorflowConfigParser
An open config file to read.
ifo : string
The detector (H1, L1) whose model will be loaded.
section : {"calibration", string}
Section n... | f16023:m0 |
def next_power_of_2(n): | <EOL>return <NUM_LIT:1> << (len(bin(n)) - <NUM_LIT:2>)<EOL> | Return the smallest integer power of 2 larger than the argument.
Parameters
----------
n : int
A positive integer.
Returns
-------
m : int
Smallest integer power of 2 larger than n. | f16024:m0 |
def detect_loud_glitches(strain, psd_duration=<NUM_LIT>, psd_stride=<NUM_LIT>,<EOL>psd_avg_method='<STR_LIT>', low_freq_cutoff=<NUM_LIT>,<EOL>threshold=<NUM_LIT>, cluster_window=<NUM_LIT>, corrupt_time=<NUM_LIT>,<EOL>high_freq_cutoff=None, output_intermediates=False): | logging.info('<STR_LIT>')<EOL>taper_length = int(corrupt_time * strain.sample_rate)<EOL>w = numpy.arange(taper_length) / float(taper_length)<EOL>strain[<NUM_LIT:0>:taper_length] *= pycbc.types.Array(w, dtype=strain.dtype)<EOL>strain[(len(strain)-taper_length):] *= pycbc.types.Array(w[::-<NUM_LIT:1>],<EOL>dtype=strain.d... | Automatic identification of loud transients for gating purposes.
This function first estimates the PSD of the input time series using the
FindChirp Welch method. Then it whitens the time series using that
estimate. Finally, it computes the magnitude of the whitened series,
thresholds it and applies the... | f16024:m1 |
def from_cli(opt, dyn_range_fac=<NUM_LIT:1>, precision='<STR_LIT>',<EOL>inj_filter_rejector=None): | gating_info = {}<EOL>if opt.frame_cache or opt.frame_files or opt.frame_type:<EOL><INDENT>if opt.frame_cache:<EOL><INDENT>frame_source = opt.frame_cache<EOL><DEDENT>if opt.frame_files:<EOL><INDENT>frame_source = opt.frame_files<EOL><DEDENT>logging.info("<STR_LIT>")<EOL>if hasattr(opt, '<STR_LIT>') and opt.frame_sieve:<... | Parses the CLI options related to strain data reading and conditioning.
Parameters
----------
opt : object
Result of parsing the CLI with OptionParser, or any object with the
required attributes (gps-start-time, gps-end-time, strain-high-pass,
pad-data, sample-rate, (frame-cache or... | f16024:m2 |
def from_cli_single_ifo(opt, ifo, **kwargs): | single_det_opt = copy_opts_for_single_ifo(opt, ifo)<EOL>return from_cli(single_det_opt, **kwargs)<EOL> | Get the strain for a single ifo when using the multi-detector CLI | f16024:m3 |
def from_cli_multi_ifos(opt, ifos, **kwargs): | strain = {}<EOL>for ifo in ifos:<EOL><INDENT>strain[ifo] = from_cli_single_ifo(opt, ifo, **kwargs)<EOL><DEDENT>return strain<EOL> | Get the strain for all ifos when using the multi-detector CLI | f16024:m4 |
def insert_strain_option_group(parser, gps_times=True): | data_reading_group = parser.add_argument_group("<STR_LIT>",<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>if gps_times:<EOL><INDENT>data_reading_group.add_argument("<STR_LIT>",<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>", type=int)<EOL>data_reading_group.add_argument("<STR_LIT>",<EOL>help="<STR_LIT>"<EO... | Add strain-related options to the optparser object.
Adds the options used to call the pycbc.strain.from_cli function to an
optparser as an OptionGroup. This should be used if you
want to use these options in your code.
Parameters
-----------
parser : object
OptionParser instance. | f16024:m5 |
def insert_strain_option_group_multi_ifo(parser): | data_reading_group_multi = parser.add_argument_group("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>data_reading_group_multi.add_argument("<STR_LIT>", nargs='<STR_LIT:+>',<EOL>action=MultiDetOptionAction, metavar='<STR_LIT>',<EOL>help="<STR_LIT>"<EOL>"<... | Adds the options used to call the pycbc.strain.from_cli function to an
optparser as an OptionGroup. This should be used if you
want to use these options in your code.
Parameters
-----------
parser : object
OptionParser instance. | f16024:m6 |
def verify_strain_options(opts, parser): | for opt_group in ensure_one_opt_groups:<EOL><INDENT>ensure_one_opt(opts, parser, opt_group)<EOL><DEDENT>required_opts(opts, parser, required_opts_list)<EOL> | Sanity check provided strain arguments.
Parses the strain data CLI options and verifies that they are consistent
and reasonable.
Parameters
----------
opt : object
Result of parsing the CLI with OptionParser, or any object with the
required attributes (gps-start-time, gps-end-time,... | f16024:m7 |
def verify_strain_options_multi_ifo(opts, parser, ifos): | for ifo in ifos:<EOL><INDENT>for opt_group in ensure_one_opt_groups:<EOL><INDENT>ensure_one_opt_multi_ifo(opts, parser, ifo, opt_group)<EOL><DEDENT>required_opts_multi_ifo(opts, parser, ifo, required_opts_list)<EOL><DEDENT> | Sanity check provided strain arguments.
Parses the strain data CLI options and verifies that they are consistent
and reasonable.
Parameters
----------
opt : object
Result of parsing the CLI with OptionParser, or any object with the
required attributes (gps-start-time, gps-end-time,... | f16024:m8 |
def gate_data(data, gate_params): | def inverted_tukey(M, n_pad):<EOL><INDENT>midlen = M - <NUM_LIT:2>*n_pad<EOL>if midlen < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>padarr = <NUM_LIT:0.5>*(<NUM_LIT:1.>+numpy.cos(numpy.pi*numpy.arange(n_pad)/n_pad))<EOL>return numpy.concatenate((padarr,numpy.zeros(midlen),padarr[::-<NUM_LIT:1>])... | Apply a set of gating windows to a time series.
Each gating window is
defined by a central time, a given duration (centered on the given
time) to zero out, and a given duration of smooth tapering on each side of
the window. The window function used for tapering is a Tukey window.
Parameters
--... | f16024:m9 |
def __init__(self, strain, segment_length=None, segment_start_pad=<NUM_LIT:0>,<EOL>segment_end_pad=<NUM_LIT:0>, trigger_start=None, trigger_end=None,<EOL>filter_inj_only=False, injection_window=None,<EOL>allow_zero_padding=False): | self._fourier_segments = None<EOL>self.strain = strain<EOL>self.delta_t = strain.delta_t<EOL>self.sample_rate = strain.sample_rate<EOL>if segment_length:<EOL><INDENT>seg_len = segment_length<EOL><DEDENT>else:<EOL><INDENT>seg_len = strain.duration<EOL><DEDENT>self.delta_f = <NUM_LIT:1.0> / seg_len<EOL>self.time_len = se... | Determine how to chop up the strain data into smaller segments
for analysis. | f16024:c0:m0 |
def fourier_segments(self): | if not self._fourier_segments:<EOL><INDENT>self._fourier_segments = []<EOL>for seg_slice, ana in zip(self.segment_slices, self.analyze_slices):<EOL><INDENT>if seg_slice.start >= <NUM_LIT:0> and seg_slice.stop <= len(self.strain):<EOL><INDENT>freq_seg = make_frequency_series(self.strain[seg_slice])<EOL><DEDENT>elif seg_... | Return a list of the FFT'd segments.
Return the list of FrequencySeries. Additional properties are
added that describe the strain segment. The property 'analyze'
is a slice corresponding to the portion of the time domain equivelant
of the segment to analyze for triggers. The value 'cumul... | f16024:c0:m1 |
@classmethod<EOL><INDENT>def from_cli(cls, opt, strain):<DEDENT> | return cls(strain, segment_length=opt.segment_length,<EOL>segment_start_pad=opt.segment_start_pad,<EOL>segment_end_pad=opt.segment_end_pad,<EOL>trigger_start=opt.trig_start_time,<EOL>trigger_end=opt.trig_end_time,<EOL>filter_inj_only=opt.filter_inj_only,<EOL>injection_window=opt.injection_window,<EOL>allow_zero_padding... | Calculate the segmentation of the strain data for analysis from
the command line options. | f16024:c0:m2 |
@classmethod<EOL><INDENT>def from_cli_single_ifo(cls, opt, strain, ifo):<DEDENT> | return cls(strain, segment_length=opt.segment_length[ifo],<EOL>segment_start_pad=opt.segment_start_pad[ifo],<EOL>segment_end_pad=opt.segment_end_pad[ifo],<EOL>trigger_start=opt.trig_start_time[ifo],<EOL>trigger_end=opt.trig_end_time[ifo],<EOL>filter_inj_only=opt.filter_inj_only,<EOL>allow_zero_padding=opt.allow_zero_pa... | Calculate the segmentation of the strain data for analysis from
the command line options. | f16024:c0:m4 |
@classmethod<EOL><INDENT>def from_cli_multi_ifos(cls, opt, strain_dict, ifos):<DEDENT> | strain_segments = {}<EOL>for ifo in ifos:<EOL><INDENT>strain_segments[ifo] = cls.from_cli_single_ifo(opt,<EOL>strain_dict[ifo], ifo)<EOL><DEDENT>return strain_segments<EOL> | Calculate the segmentation of the strain data for analysis from
the command line options. | f16024:c0:m5 |
def __init__(self, frame_src, channel_name, start_time,<EOL>max_buffer=<NUM_LIT>,<EOL>sample_rate=<NUM_LIT>,<EOL>low_frequency_cutoff=<NUM_LIT:20>,<EOL>highpass_frequency=<NUM_LIT>,<EOL>highpass_reduction=<NUM_LIT>,<EOL>highpass_bandwidth=<NUM_LIT>,<EOL>psd_samples=<NUM_LIT:30>,<EOL>psd_segment_length=<NUM_LIT:4>,<EOL>... | super(StrainBuffer, self).__init__(frame_src, channel_name, start_time,<EOL>max_buffer=max_buffer,<EOL>force_update_cache=force_update_cache,<EOL>increment_update_cache=increment_update_cache)<EOL>self.low_frequency_cutoff = low_frequency_cutoff<EOL>self.analyze_flags = analyze_flags<EOL>self.data_quality_flags = data_... | Class to produce overwhitened strain incrementally
Parameters
----------
frame_src: str of list of strings
Strings that indicate where to read from files from. This can be a
list of frame files, a glob, etc.
channel_name: str
Name of the channel to re... | f16024:c1:m0 |
@property<EOL><INDENT>def start_time(self):<DEDENT> | return self.end_time - self.blocksize<EOL> | Return the start time of the current valid segment of data | f16024:c1:m1 |
@property<EOL><INDENT>def end_time(self):<DEDENT> | return float(self.strain.start_time + (len(self.strain) - self.total_corruption) / self.sample_rate)<EOL> | Return the end time of the current valid segment of data | f16024:c1:m2 |
def add_hard_count(self): | self.wait_duration = int(numpy.ceil(self.total_corruption / self.sample_rate + self.psd_duration))<EOL>self.invalidate_psd()<EOL> | Reset the countdown timer, so that we don't analyze data long enough
to generate a new PSD. | f16024:c1:m3 |
def invalidate_psd(self): | self.psd = None<EOL>self.psds = {}<EOL> | Make the current PSD invalid. A new one will be generated when
it is next required | f16024:c1:m4 |
def recalculate_psd(self): | seg_len = self.sample_rate * self.psd_segment_length<EOL>e = len(self.strain)<EOL>s = e - ((self.psd_samples + <NUM_LIT:1>) * self.psd_segment_length / <NUM_LIT:2>) * self.sample_rate<EOL>psd = pycbc.psd.welch(self.strain[s:e], seg_len=seg_len, seg_stride=seg_len / <NUM_LIT:2>)<EOL>psd.dist = spa_distance(psd, <NUM_LIT... | Recalculate the psd | f16024:c1:m5 |
def overwhitened_data(self, delta_f): | <EOL>if delta_f not in self.segments:<EOL><INDENT>buffer_length = int(<NUM_LIT:1.0> / delta_f)<EOL>e = len(self.strain)<EOL>s = int(e - buffer_length * self.sample_rate - self.reduced_pad * <NUM_LIT:2>)<EOL>fseries = make_frequency_series(self.strain[s:e])<EOL>if delta_f not in self.psds:<EOL><INDENT>psdt = pycbc.psd.i... | Return overwhitened data
Parameters
----------
delta_f: float
The sample step to generate overwhitened frequency domain data for
Returns
-------
htilde: FrequencySeries
Overwhited strain data | f16024:c1:m6 |
def near_hwinj(self): | if not self.state:<EOL><INDENT>return False<EOL><DEDENT>if not self.state.is_extent_valid(self.start_time, self.blocksize, pycbc.frame.NO_HWINJ):<EOL><INDENT>return True<EOL><DEDENT>return False<EOL> | Check that the current set of triggers could be influenced by
a hardware injection. | f16024:c1:m7 |
def null_advance_strain(self, blocksize): | sample_step = int(blocksize * self.sample_rate)<EOL>csize = sample_step + self.corruption * <NUM_LIT:2><EOL>self.strain.roll(-sample_step)<EOL>self.strain[len(self.strain) - csize + self.corruption:] = <NUM_LIT:0><EOL>self.strain.start_time += blocksize<EOL>self.taper_immediate_strain = True<EOL> | Advance and insert zeros
Parameters
----------
blocksize: int
The number of seconds to attempt to read from the channel | f16024:c1:m8 |
def advance(self, blocksize, timeout=<NUM_LIT:10>): | ts = super(StrainBuffer, self).attempt_advance(blocksize, timeout=timeout)<EOL>self.blocksize = blocksize<EOL>if ts is None:<EOL><INDENT>logging.info("<STR_LIT>", self.detector)<EOL>self.null_advance_strain(blocksize)<EOL>if self.state:<EOL><INDENT>self.state.null_advance(blocksize)<EOL><DEDENT>if self.dq:<EOL><INDENT>... | Advanced buffer blocksize seconds.
Add blocksize seconds more to the buffer, push blocksize seconds
from the beginning.
Parameters
----------
blocksize: int
The number of seconds to attempt to read from the channel
Returns
-------
status: bo... | f16024:c1:m9 |
@classmethod<EOL><INDENT>def from_cli(cls, ifo, args, maxlen):<DEDENT> | state_channel = analyze_flags = None<EOL>if args.state_channel and ifo in args.state_channeland args.analyze_flags and ifo in args.analyze_flags:<EOL><INDENT>state_channel = '<STR_LIT::>'.join([ifo, args.state_channel[ifo]])<EOL>analyze_flags = args.analyze_flags[ifo].split('<STR_LIT:U+002C>')<EOL><DEDENT>dq_channel = ... | Initialize a StrainBuffer object (data reader) for a particular
detector. | f16024:c1:m10 |
def _gates_from_cli(opts, gate_opt): | gates = {}<EOL>if getattr(opts, gate_opt) is None:<EOL><INDENT>return gates<EOL><DEDENT>for gate in getattr(opts, gate_opt):<EOL><INDENT>try:<EOL><INDENT>ifo, central_time, half_dur, taper_dur = gate.split('<STR_LIT::>')<EOL>central_time = float(central_time)<EOL>half_dur = float(half_dur)<EOL>taper_dur = float(taper_d... | Parses the given `gate_opt` into something understandable by
`strain.gate_data`. | f16025:m0 |
def gates_from_cli(opts): | return _gates_from_cli(opts, '<STR_LIT>')<EOL> | Parses the --gate option into something understandable by
`strain.gate_data`. | f16025:m1 |
def psd_gates_from_cli(opts): | return _gates_from_cli(opts, '<STR_LIT>')<EOL> | Parses the --psd-gate option into something understandable by
`strain.gate_data`. | f16025:m2 |
def apply_gates_to_td(strain_dict, gates): | <EOL>outdict = dict(strain_dict.items())<EOL>for ifo in gates:<EOL><INDENT>outdict[ifo] = strain.gate_data(outdict[ifo], gates[ifo])<EOL><DEDENT>return outdict<EOL> | Applies the given dictionary of gates to the given dictionary of
strain.
Parameters
----------
strain_dict : dict
Dictionary of time-domain strain, keyed by the ifos.
gates : dict
Dictionary of gates. Keys should be the ifo to apply the data to,
values are a tuple giving the... | f16025:m3 |
def apply_gates_to_fd(stilde_dict, gates): | <EOL>outdict = dict(stilde_dict.items())<EOL>strain_dict = dict([[ifo, outdict[ifo].to_timeseries()] for ifo in gates])<EOL>for ifo,d in apply_gates_to_td(strain_dict, gates).items():<EOL><INDENT>outdict[ifo] = d.to_frequencyseries()<EOL><DEDENT>return outdict<EOL> | Applies the given dictionary of gates to the given dictionary of
strain in the frequency domain.
Gates are applied by IFFT-ing the strain data to the time domain, applying
the gate, then FFT-ing back to the frequency domain.
Parameters
----------
stilde_dict : dict
Dictionary of freque... | f16025:m4 |
def add_gate_option_group(parser): | gate_group = parser.add_argument_group("<STR_LIT>")<EOL>gate_group.add_argument("<STR_LIT>", nargs="<STR_LIT:+>", type=str,<EOL>metavar="<STR_LIT>",<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>")<EOL>gate_group.add_argument("<STR_LIT>", action="<STR_LIT:store_true>",<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<ST... | Adds the options needed to apply gates to data.
Parameters
----------
parser : object
ArgumentParser instance. | f16025:m5 |
@abstractmethod<EOL><INDENT>def apply_calibration(self, strain):<DEDENT> | return<EOL> | Apply calibration model
This method should be overwritten by subclasses
Parameters
----------
strain : FrequencySeries
The strain to be recalibrated.
Return
------
strain_adjusted : FrequencySeries
The recalibrated strain. | f16026:c0:m1 |
def map_to_adjust(self, strain, prefix='<STR_LIT>', **params): | self.params.update({<EOL>key[len(prefix):]: params[key]<EOL>for key in params if prefix in key and self.ifo_name in key})<EOL>strain_adjusted = self.apply_calibration(strain)<EOL>return strain_adjusted<EOL> | Map an input dictionary of sampling parameters to the
adjust_strain function by filtering the dictionary for the
calibration parameters, then calling adjust_strain.
Parameters
----------
strain : FrequencySeries
The strain to be recalibrated.
prefix: str
... | f16026:c0:m2 |
@classmethod<EOL><INDENT>def from_config(cls, cp, ifo, section):<DEDENT> | all_params = dict(cp.items(section))<EOL>params = {key[len(ifo)+<NUM_LIT:1>:]: all_params[key]<EOL>for key in all_params if ifo.lower() in key}<EOL>params = {key: params[key] for key in params}<EOL>params.pop('<STR_LIT>')<EOL>params['<STR_LIT>'] = ifo.lower()<EOL>return cls(**params)<EOL> | Read a config file to get calibration options and transfer
functions which will be used to intialize the model.
Parameters
----------
cp : WorkflowConfigParser
An open config file.
ifo : string
The detector (H1, L1) for which the calibration model will
... | f16026:c0:m3 |
def apply_calibration(self, strain): | amplitude_parameters =[self.params['<STR_LIT>'.format(self.ifo_name, ii)]<EOL>for ii in range(self.n_points)]<EOL>amplitude_spline = UnivariateSpline(self.spline_points,<EOL>amplitude_parameters)<EOL>delta_amplitude = amplitude_spline(strain.sample_frequencies.numpy())<EOL>phase_parameters =[self.params['<STR_LIT>'.for... | Apply calibration model
This applies cubic spline calibration to the strain.
Parameters
----------
strain : FrequencySeries
The strain to be recalibrated.
Return
------
strain_adjusted : FrequencySeries
The recalibrated strain. | f16026:c1:m1 |
def update_c(self, fs=None, qinv=None, fc=None, kappa_c=<NUM_LIT:1.0>): | detuning_term = self.freq**<NUM_LIT:2> / (self.freq**<NUM_LIT:2> - <NUM_LIT> *self.freq*fs *qinv + fs**<NUM_LIT:2>)<EOL>return self.c_res * kappa_c / (<NUM_LIT:1> + <NUM_LIT> * self.freq/fc)*detuning_term<EOL> | Calculate the sensing function c(f,t) given the new parameters
kappa_c(t), kappa_a(t), f_c(t), fs, and qinv.
Parameters
----------
fc : float
Coupled-cavity (CC) pole at time t.
kappa_c : float
Scalar correction factor for sensing function at time t.
... | f16026:c2:m1 |
def update_g(self, fs=None, qinv=None, fc=None, kappa_tst_re=<NUM_LIT:1.0>,<EOL>kappa_tst_im=<NUM_LIT:0.0>, kappa_pu_re=<NUM_LIT:1.0>, kappa_pu_im=<NUM_LIT:0.0>,<EOL>kappa_c=<NUM_LIT:1.0>): | c = self.update_c(fs=fs, qinv=qinv, fc=fc, kappa_c=kappa_c)<EOL>a_tst = self.a_tst0 * (kappa_tst_re + <NUM_LIT> * kappa_tst_im)<EOL>a_pu = self.a_pu0 * (kappa_pu_re + <NUM_LIT> * kappa_pu_im)<EOL>return c * self.d0 * (a_tst + a_pu)<EOL> | Calculate the open loop gain g(f,t) given the new parameters
kappa_c(t), kappa_a(t), f_c(t), fs, and qinv.
Parameters
----------
fc : float
Coupled-cavity (CC) pole at time t.
kappa_c : float
Scalar correction factor for sensing function c at time t.
... | f16026:c2:m2 |
def update_r(self, fs=None, qinv=None, fc=None, kappa_c=<NUM_LIT:1.0>,<EOL>kappa_tst_re=<NUM_LIT:1.0>, kappa_tst_im=<NUM_LIT:0.0>, kappa_pu_re=<NUM_LIT:1.0>,<EOL>kappa_pu_im=<NUM_LIT:0.0>): | c = self.update_c(fs=fs, qinv=qinv, fc=fc, kappa_c=kappa_c)<EOL>g = self.update_g(fs=fs, qinv=qinv, fc=fc, kappa_c=kappa_c,<EOL>kappa_tst_re=kappa_tst_re,<EOL>kappa_tst_im=kappa_tst_im,<EOL>kappa_pu_re=kappa_pu_re, kappa_pu_im=kappa_pu_im)<EOL>return (<NUM_LIT:1.0> + g) / c<EOL> | Calculate the response function R(f,t) given the new parameters
kappa_c(t), kappa_a(t), f_c(t), fs, and qinv.
Parameters
----------
fc : float
Coupled-cavity (CC) pole at time t.
kappa_c : float
Scalar correction factor for sensing function c at time t.
... | f16026:c2:m3 |
def adjust_strain(self, strain, delta_fs=None, delta_qinv=None,<EOL>delta_fc=None, kappa_c=<NUM_LIT:1.0>, kappa_tst_re=<NUM_LIT:1.0>,<EOL>kappa_tst_im=<NUM_LIT:0.0>, kappa_pu_re=<NUM_LIT:1.0>, kappa_pu_im=<NUM_LIT:0.0>): | fc = self.fc0 + delta_fc if delta_fc else self.fc0<EOL>fs = self.fs0 + delta_fs if delta_fs else self.fs0<EOL>qinv = self.qinv0 + delta_qinv if delta_qinv else self.qinv0<EOL>r_adjusted = self.update_r(fs=fs, qinv=qinv, fc=fc, kappa_c=kappa_c,<EOL>kappa_tst_re=kappa_tst_re,<EOL>kappa_tst_im=kappa_tst_im,<EOL>kappa_pu_r... | Adjust the FrequencySeries strain by changing the time-dependent
calibration parameters kappa_c(t), kappa_a(t), f_c(t), fs, and qinv.
Parameters
----------
strain : FrequencySeries
The strain data to be adjusted.
delta_fc : float
Change in coupled-cavity ... | f16026:c2:m4 |
@classmethod<EOL><INDENT>def tf_from_file(cls, path, delimiter="<STR_LIT:U+0020>"):<DEDENT> | data = np.loadtxt(path, delimiter=delimiter)<EOL>freq = data[:, <NUM_LIT:0>]<EOL>h = data[:, <NUM_LIT:1>] + <NUM_LIT> * data[:, <NUM_LIT:2>]<EOL>return np.array([freq, h]).transpose()<EOL> | Convert the contents of a file with the columns
[freq, real(h), imag(h)] to a numpy.array with columns
[freq, real(h)+j*imag(h)].
Parameters
----------
path : string
delimiter : {" ", string}
Return
------
numpy.array | f16026:c2:m5 |
@classmethod<EOL><INDENT>def from_config(cls, cp, ifo, section):<DEDENT> | <EOL>tfs = []<EOL>tf_names = ["<STR_LIT>", "<STR_LIT>", "<STR_LIT:c>", "<STR_LIT:d>"]<EOL>for tag in ['<STR_LIT:->'.join([ifo, "<STR_LIT>", name])<EOL>for name in tf_names]:<EOL><INDENT>tf_path = cp.get_opt_tag(section, tag, None)<EOL>tfs.append(cls.tf_from_file(tf_path))<EOL><DEDENT>a_tst0 = tfs[<NUM_LIT:0>][:, <NUM_L... | Read a config file to get calibration options and transfer
functions which will be used to intialize the model.
Parameters
----------
cp : WorkflowConfigParser
An open config file.
ifo : string
The detector (H1, L1) for which the calibration model will
... | f16026:c2:m6 |
def map_to_adjust(self, strain, **params): | <EOL>arg_names = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>']<EOL>arg_labels = ['<STR_LIT>'.join(['<STR_LIT>', name]) for name in arg_names]<EOL>default_values = [<NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:0.0>,... | Map an input dictionary of sampling parameters to the
adjust_strain function by filtering the dictionary for the
calibration parameters, then calling adjust_strain.
Parameters
----------
strain : FrequencySeries
The strain to be recalibrated.
params : dict
... | f16026:c2:m7 |
def check_status(status): | if status:<EOL><INDENT>msg = lib.DftiErrorMessage(status)<EOL>msg = ctypes.c_char_p(msg).value<EOL>raise RuntimeError(msg)<EOL><DEDENT> | Check the status of a mkl functions and raise a python exeption if
there is an error. | f16028:m0 |
def get_measure_level(): | return _default_measurelvl<EOL> | Get the current 'measure level' used in deciding how much effort to put into
creating FFTW plans. From least effort (and shortest planning time) to most
they are 0 to 3. No arguments. | f16031:m4 |
def set_measure_level(mlvl): | global _default_measurelvl<EOL>if mlvl not in (<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>_default_measurelvl = mlvl<EOL> | Set the current 'measure level' used in deciding how much effort to expend
creating FFTW plans. Must be an integer from 0 (least effort, shortest time)
to 3 (most effort and time). | f16031:m5 |
def insert_fft_options(optgroup): | optgroup.add_argument("<STR_LIT>",<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>" + str([<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>]),<EOL>type=int, default=_default_measurelvl)<EOL>optgroup.add_argument("<STR_LIT>",<EOL>help="<STR_LIT>",<EOL>default=None)<EOL>optgroup.add_argument("<STR_LIT>",<EOL>help="<STR_LIT>",<EOL>def... | Inserts the options that affect the behavior of this backend
Parameters
----------
optgroup: fft_option
OptionParser argument group whose options are extended | f16031:m17 |
def verify_fft_options(opt,parser): | if opt.fftw_measure_level not in [<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>]:<EOL><INDENT>parser.error("<STR_LIT>".format(opt.fftw_measure_level))<EOL><DEDENT>if opt.fftw_import_system_wisdom and ((opt.fftw_input_float_wisdom_file is not None)<EOL>or (opt.fftw_input_double_wisdom_file is not None)):<EOL><INDENT>p... | Parses the FFT options and verifies that they are
reasonable.
Parameters
----------
opt : object
Result of parsing the CLI with OptionParser, or any object with the
required attributes.
parser : object
OptionParser instance. | f16031:m18 |
def insert_fft_option_group(parser): | fft_group = parser.add_argument_group("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>fft_group.add_argument("<STR_LIT>",<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>" + str(get_backend_names()),<EOL>nargs='<STR_LIT:*>', default=[])<EOL>for backend in get_backend_modules():<EOL><INDENT>try:<EOL><INDENT>backend.insert_fft_optio... | Adds the options used to choose an FFT backend. This should be used
if your program supports the ability to select the FFT backend; otherwise
you may simply call the fft and ifft functions and rely on default
choices. This function will also attempt to add any options exported
by available backends through a function ... | f16033:m0 |
def verify_fft_options(opt, parser): | if len(opt.fft_backends) > <NUM_LIT:0>:<EOL><INDENT>_all_backends = get_backend_names()<EOL>for backend in opt.fft_backends:<EOL><INDENT>if backend not in _all_backends:<EOL><INDENT>parser.error("<STR_LIT>".format(backend))<EOL><DEDENT><DEDENT><DEDENT>for backend in get_backend_modules():<EOL><INDENT>try:<EOL><INDENT>b... | Parses the FFT options and verifies that they are
reasonable.
Parameters
----------
opt : object
Result of parsing the CLI with OptionParser, or any object with the
required attributes.
parser : object
OptionParser instance. | f16033:m1 |
def from_cli(opt): | set_backend(opt.fft_backends)<EOL>backend = get_backend()<EOL>try:<EOL><INDENT>backend.from_cli(opt)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT> | Parses the command line options and sets the FFT backend
for each (available) scheme. Aside from setting the default
backed for this context, this function will also call (if
it exists) the from_cli function of the specified backends in
the *current* scheme; typically one would only call this function
... | f16033:m2 |
def fft(invec, outvec): | prec, itype, otype = _check_fft_args(invec, outvec)<EOL>_check_fwd_args(invec, itype, outvec, otype, <NUM_LIT:1>, None)<EOL>backend = get_backend()<EOL>backend.fft(invec, outvec, prec, itype, otype)<EOL>if isinstance(invec, _TimeSeries):<EOL><INDENT>outvec._epoch = invec._epoch<EOL>outvec._delta_f = <NUM_LIT:1.0>/(inve... | Fourier transform from invec to outvec.
Perform a fourier transform. The type of transform is determined
by the dtype of invec and outvec.
Parameters
----------
invec : TimeSeries or FrequencySeries
The input vector.
outvec : TimeSeries or FrequencySeries
The output. | f16034:m0 |
def ifft(invec, outvec): | prec, itype, otype = _check_fft_args(invec, outvec)<EOL>_check_inv_args(invec, itype, outvec, otype, <NUM_LIT:1>, None)<EOL>backend = get_backend()<EOL>backend.ifft(invec, outvec, prec, itype, otype)<EOL>if isinstance(invec, _TimeSeries):<EOL><INDENT>outvec._epoch = invec._epoch<EOL>outvec._delta_f = <NUM_LIT:1.0>/(inv... | Inverse fourier transform from invec to outvec.
Perform an inverse fourier transform. The type of transform is determined
by the dtype of invec and outvec.
Parameters
----------
invec : TimeSeries or FrequencySeries
The input vector.
outvec : TimeSeries or FrequencySeries
The o... | f16034:m1 |
def execute(self): | pass<EOL> | Compute the (forward) FFT of the input vector specified at object
instantiation, putting the output into the output vector specified
at objet instantiation. The intention is that this method should
be called many times, with the contents of the input vector
changing between invocations, but not the locations in memory ... | f16039:c0:m1 |
def execute(self): | pass<EOL> | Compute the (backward) FFT of the input vector specified at object
instantiation, putting the output into the output vector specified
at objet instantiation. The intention is that this method should
be called many times, with the contents of the input vector
changing between invocations, but not the locations in memory... | f16039:c1:m1 |
def plan_transpose(N1, N2): | rows = N1<EOL>cols = N2<EOL>iodim = numpy.zeros(<NUM_LIT:6>, dtype=numpy.int32)<EOL>iodim[<NUM_LIT:0>] = rows<EOL>iodim[<NUM_LIT:1>] = <NUM_LIT:1><EOL>iodim[<NUM_LIT:2>] = cols<EOL>iodim[<NUM_LIT:3>] = cols<EOL>iodim[<NUM_LIT:4>] = rows<EOL>iodim[<NUM_LIT:5>] = <NUM_LIT:1><EOL>N = N1*N2<EOL>vin = pycbc.types.zeros(N, d... | Create a plan for transposing internally to the pruned_FFT calculation.
(Alex to provide a write up with more details.)
Parameters
-----------
N1 : int
Number of rows.
N2 : int
Number of columns.
Returns
--------
plan : FFTWF plan
The plan for performing the FFTW transpose. | f16040:m0 |
def plan_first_phase(N1, N2): | N = N1*N2<EOL>vin = pycbc.types.zeros(N, dtype=numpy.complex64)<EOL>vout = pycbc.types.zeros(N, dtype=numpy.complex64)<EOL>f = float_lib.fftwf_plan_many_dft<EOL>f.argtypes = [ctypes.c_int, ctypes.c_void_p, ctypes.c_int,<EOL>ctypes.c_void_p, ctypes.c_void_p,<EOL>ctypes.c_int, ctypes.c_int,<EOL>ctypes.c_void_p, ctypes.c_... | Create a plan for the first stage of the pruned FFT operation.
(Alex to provide a write up with more details.)
Parameters
-----------
N1 : int
Number of rows.
N2 : int
Number of columns.
Returns
--------
plan : FFTWF plan
The plan for performing the first phase FFT. | f16040:m1 |
def first_phase(invec, outvec, N1, N2): | global _theplan<EOL>if _theplan is None:<EOL><INDENT>_theplan = plan_first_phase(N1, N2)<EOL><DEDENT>fexecute(_theplan, invec.ptr, outvec.ptr)<EOL> | This implements the first phase of the FFT decomposition, using
the standard FFT many plans.
Parameters
-----------
invec : array
The input array.
outvec : array
The output array.
N1 : int
Number of rows.
N2 : int
Number of columns. | f16040:m2 |
def second_phase(invec, indices, N1, N2): | invec = numpy.array(invec.data, copy=False)<EOL>NI = len(indices) <EOL>N1=int(N1)<EOL>N2=int(N2)<EOL>out = numpy.zeros(len(indices), dtype=numpy.complex64)<EOL>code = """<STR_LIT>"""<EOL>weave.inline(code, ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>)<EOL>return out<EOL> | This is the second phase of the FFT decomposition that actually performs
the pruning. It is an explicit calculation for the subset of points. Note
that there seem to be some numerical accumulation issues at various values
of N1 and N2.
Parameters
----------
invec :
The result of the first phase FFT
indices : array... | f16040:m3 |
def fast_second_phase(invec, indices, N1, N2): | invec = numpy.array(invec.data, copy=False)<EOL>NI = len(indices) <EOL>N1=int(N1)<EOL>N2=int(N2)<EOL>out = numpy.zeros(len(indices), dtype=numpy.complex64)<EOL>code = """<STR_LIT>"""<EOL>weave.inline(code, ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>extra_compile_args=[WEAVE_FLAG... | This is the second phase of the FFT decomposition that actually performs
the pruning. It is an explicit calculation for the subset of points. Note
that there seem to be some numerical accumulation issues at various values
of N1 and N2.
Parameters
----------
invec :
The result of the first phase FFT
indices : array... | f16040:m4 |
def fft_transpose_fftw(vec): | global _thetransposeplan<EOL>outvec = pycbc.types.zeros(len(vec), dtype=vec.dtype)<EOL>if _theplan is None:<EOL><INDENT>N1, N2 = splay(vec)<EOL>_thetransposeplan = plan_transpose(N1, N2)<EOL><DEDENT>ftexecute(_thetransposeplan, vec.ptr, outvec.ptr)<EOL>return outvec<EOL> | Perform an FFT transpose from vec into outvec.
(Alex to provide more details in a write-up.)
Parameters
-----------
vec : array
Input array.
Returns
--------
outvec : array
Transposed output array. | f16040:m5 |
def fft_transpose_numpy(vec): | N1, N2 = splay(vec)<EOL>return pycbc.types.Array(vec.data.copy().reshape(N2, N1).transpose().reshape(len(vec)).copy())<EOL> | Perform a numpy transpose from vec into outvec.
(Alex to provide more details in a write-up.)
Parameters
-----------
vec : array
Input array.
Returns
--------
outvec : array
Transposed output array. | f16040:m6 |
def splay(vec): | N2 = <NUM_LIT:2> ** int(numpy.log2( len(vec) ) / <NUM_LIT:2>)<EOL>N1 = len(vec) / N2<EOL>return N1, N2<EOL> | Determine two lengths to split stride the input vector by | f16040:m7 |
def pruned_c2cifft(invec, outvec, indices, pretransposed=False): | N1, N2 = splay(invec)<EOL>if not pretransposed:<EOL><INDENT>invec = fft_transpose(invec)<EOL><DEDENT>first_phase(invec, outvec, N1=N1, N2=N2)<EOL>out = fast_second_phase(outvec, indices, N1=N1, N2=N2)<EOL>return out<EOL> | Perform a pruned iFFT, only valid for power of 2 iffts as the
decomposition is easier to choose. This is not a strict requirement of the
functions, but it is unlikely to the optimal to use anything but power
of 2. (Alex to provide more details in write up.
Parameters
-----------
invec : array
The input vector. Thi... | f16040:m8 |
def compile(source, name): | cache = os.path.join(pycbc._cache_dir_path, name)<EOL>hash_file = cache + "<STR_LIT>"<EOL>lib_file = cache + "<STR_LIT>"<EOL>obj_file = cache + "<STR_LIT>"<EOL>try:<EOL><INDENT>if int(open(hash_file, "<STR_LIT:r>").read()) == hash(source):<EOL><INDENT>return lib_file<EOL><DEDENT>raise ValueError<EOL><DEDENT>except:<EOL... | Compile the string source code into a shared object linked against
the static version of cufft for callback support. | f16041:m0 |
def get_fn_plan(callback=None, out_callback=None, name='<STR_LIT>', parameters=None): | if parameters is None:<EOL><INDENT>parameters = []<EOL><DEDENT>source = fftsrc.render(input_callback=callback, output_callback=out_callback, parameters=parameters)<EOL>path = compile(source, name)<EOL>lib = ctypes.cdll.LoadLibrary(path)<EOL>fn = lib.execute<EOL>fn.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_... | Get the IFFT execute and plan functions | f16041:m1 |
def ensurearray(*args): | input_is_array = any(isinstance(arg, numpy.ndarray) for arg in args)<EOL>args = numpy.broadcast_arrays(*args)<EOL>args.append(input_is_array)<EOL>return args<EOL> | Apply numpy's broadcast rules to the given arguments.
This will ensure that all of the arguments are numpy arrays and that they
all have the same shape. See ``numpy.broadcast_arrays`` for more details.
It also returns a boolean indicating whether any of the inputs were
originally arrays.
Paramete... | f16043:m0 |
def formatreturn(arg, input_is_array=False): | if not input_is_array and arg.size == <NUM_LIT:1>:<EOL><INDENT>arg = arg.item()<EOL><DEDENT>return arg<EOL> | If the given argument is a numpy array with shape (1,), just returns
that value. | f16043:m1 |
def sec_to_year(sec): | return sec / lal.YRJUL_SI<EOL> | Converts number of seconds to number of years | f16043:m2 |
def primary_mass(mass1, mass2): | mass1, mass2, input_is_array = ensurearray(mass1, mass2)<EOL>mp = copy.copy(mass1)<EOL>mask = mass1 < mass2<EOL>mp[mask] = mass2[mask]<EOL>return formatreturn(mp, input_is_array)<EOL> | Returns the larger of mass1 and mass2 (p = primary). | f16043:m3 |
def secondary_mass(mass1, mass2): | mass1, mass2, input_is_array = ensurearray(mass1, mass2)<EOL>if mass1.shape != mass2.shape:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>ms = copy.copy(mass2)<EOL>mask = mass1 < mass2<EOL>ms[mask] = mass1[mask]<EOL>return formatreturn(ms, input_is_array)<EOL> | Returns the smaller of mass1 and mass2 (s = secondary). | f16043:m4 |
def mtotal_from_mass1_mass2(mass1, mass2): | return mass1 + mass2<EOL> | Returns the total mass from mass1 and mass2. | f16043:m5 |
def q_from_mass1_mass2(mass1, mass2): | return primary_mass(mass1, mass2) / secondary_mass(mass1, mass2)<EOL> | Returns the mass ratio m1/m2, where m1 >= m2. | f16043:m6 |
def invq_from_mass1_mass2(mass1, mass2): | return secondary_mass(mass1, mass2) / primary_mass(mass1, mass2)<EOL> | Returns the inverse mass ratio m2/m1, where m1 >= m2. | f16043:m7 |
def eta_from_mass1_mass2(mass1, mass2): | return mass1*mass2 / (mass1+mass2)**<NUM_LIT><EOL> | Returns the symmetric mass ratio from mass1 and mass2. | f16043:m8 |
def mchirp_from_mass1_mass2(mass1, mass2): | return eta_from_mass1_mass2(mass1, mass2)**(<NUM_LIT>/<NUM_LIT:5>) * (mass1+mass2)<EOL> | Returns the chirp mass from mass1 and mass2. | f16043:m9 |
def mass1_from_mtotal_q(mtotal, q): | return q*mtotal / (<NUM_LIT:1.>+q)<EOL> | Returns a component mass from the given total mass and mass ratio.
If the mass ratio q is >= 1, the returned mass will be the primary
(heavier) mass. If q < 1, the returned mass will be the secondary
(lighter) mass. | f16043:m10 |
def mass2_from_mtotal_q(mtotal, q): | return mtotal / (<NUM_LIT:1.>+q)<EOL> | Returns a component mass from the given total mass and mass ratio.
If the mass ratio q is >= 1, the returned mass will be the secondary
(lighter) mass. If q < 1, the returned mass will be the primary (heavier)
mass. | f16043:m11 |
def mass1_from_mtotal_eta(mtotal, eta): | return <NUM_LIT:0.5> * mtotal * (<NUM_LIT:1.0> + (<NUM_LIT:1.0> - <NUM_LIT> * eta)**<NUM_LIT:0.5>)<EOL> | Returns the primary mass from the total mass and symmetric mass
ratio. | f16043:m12 |
def mass2_from_mtotal_eta(mtotal, eta): | return <NUM_LIT:0.5> * mtotal * (<NUM_LIT:1.0> - (<NUM_LIT:1.0> - <NUM_LIT> * eta)**<NUM_LIT:0.5>)<EOL> | Returns the secondary mass from the total mass and symmetric mass
ratio. | f16043:m13 |
def mtotal_from_mchirp_eta(mchirp, eta): | return mchirp / (eta**(<NUM_LIT>/<NUM_LIT>))<EOL> | Returns the total mass from the chirp mass and symmetric mass ratio. | f16043:m14 |
def mass1_from_mchirp_eta(mchirp, eta): | mtotal = mtotal_from_mchirp_eta(mchirp, eta)<EOL>return mass1_from_mtotal_eta(mtotal, eta)<EOL> | Returns the primary mass from the chirp mass and symmetric mass ratio. | f16043:m15 |
def mass2_from_mchirp_eta(mchirp, eta): | mtotal = mtotal_from_mchirp_eta(mchirp, eta)<EOL>return mass2_from_mtotal_eta(mtotal, eta)<EOL> | Returns the primary mass from the chirp mass and symmetric mass ratio. | f16043:m16 |
def _mass2_from_mchirp_mass1(mchirp, mass1): | a = mchirp**<NUM_LIT:5> / mass1**<NUM_LIT:3><EOL>roots = numpy.roots([<NUM_LIT:1>,<NUM_LIT:0>,-a,-a*mass1])<EOL>real_root = roots[(abs(roots - roots.real)).argmin()]<EOL>return real_root.real<EOL> | r"""Returns the secondary mass from the chirp mass and primary mass.
As this is a cubic equation this requires finding the roots and returning
the one that is real. Basically it can be shown that:
.. math::
m_2^3 - a(m_2 + m_1) = 0,
where
.. math::
a = \frac{\mathcal{M}^5}{m_1^3}... | f16043:m17 |
def _mass_from_knownmass_eta(known_mass, eta, known_is_secondary=False,<EOL>force_real=True): | roots = numpy.roots([eta, (<NUM_LIT:2>*eta - <NUM_LIT:1>)*known_mass, eta*known_mass**<NUM_LIT>])<EOL>if force_real:<EOL><INDENT>roots = numpy.real(roots)<EOL><DEDENT>if known_is_secondary:<EOL><INDENT>return roots[roots.argmax()]<EOL><DEDENT>else:<EOL><INDENT>return roots[roots.argmin()]<EOL><DEDENT> | r"""Returns the other component mass given one of the component masses
and the symmetric mass ratio.
This requires finding the roots of the quadratic equation:
.. math::
\eta m_2^2 + (2\eta - 1)m_1 m_2 + \eta m_1^2 = 0.
This has two solutions which correspond to :math:`m_1` being the heavier
... | f16043:m18 |
def mass2_from_mass1_eta(mass1, eta, force_real=True): | return mass_from_knownmass_eta(mass1, eta, known_is_secondary=False,<EOL>force_real=force_real)<EOL> | Returns the secondary mass from the primary mass and symmetric mass
ratio. | f16043:m19 |
def mass1_from_mass2_eta(mass2, eta, force_real=True): | return mass_from_knownmass_eta(mass2, eta, known_is_secondary=True,<EOL>force_real=force_real)<EOL> | Returns the primary mass from the secondary mass and symmetric mass
ratio. | f16043:m20 |
def eta_from_q(q): | return q / (<NUM_LIT:1.>+q)**<NUM_LIT:2><EOL> | r"""Returns the symmetric mass ratio from the given mass ratio.
This is given by:
.. math::
\eta = \frac{q}{(1+q)^2}.
Note that the mass ratio may be either < 1 or > 1. | f16043:m21 |
def mass1_from_mchirp_q(mchirp, q): | mass1 = (q**(<NUM_LIT>/<NUM_LIT>))*((<NUM_LIT:1.0> + q)**(<NUM_LIT:1.>/<NUM_LIT>))*mchirp<EOL>return mass1<EOL> | Returns the primary mass from the given chirp mass and mass ratio. | f16043:m22 |
def mass2_from_mchirp_q(mchirp, q): | mass2 = (q**(-<NUM_LIT>/<NUM_LIT>))*((<NUM_LIT:1.0> + q)**(<NUM_LIT:1.>/<NUM_LIT>))*mchirp<EOL>return mass2<EOL> | Returns the secondary mass from the given chirp mass and mass ratio. | f16043:m23 |
def _a0(f_lower): | return <NUM_LIT> / (<NUM_LIT> * (numpy.pi * f_lower)**(<NUM_LIT>/<NUM_LIT>))<EOL> | Used in calculating chirp times: see Cokelaer, arxiv.org:0706.4437
appendix 1, also lalinspiral/python/sbank/tau0tau3.py. | f16043:m24 |
def _a3(f_lower): | return numpy.pi / (<NUM_LIT> * (numpy.pi * f_lower)**(<NUM_LIT>/<NUM_LIT>))<EOL> | Another parameter used for chirp times | f16043:m25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.