Skip to content
Snippets Groups Projects
Commit f8cae1c4 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Add minimal example and associated helper functions

- Adds an example showing the simplest number of steps to run PE on
  GW150914
- Adds a helper (rapper) function to quickly get the BBH likelihood
  instance
parent 97e20483
No related branches found
No related tags found
1 merge request!32Add minimal example and associated helper functions
Pipeline #
#!/bin/python
"""
Tutorial to demonstrate the minimum number of steps required to run parameter
stimation on GW150914 using open data.
"""
import tupak
t0 = tupak.utils.get_event_time("GW150914")
prior = dict(geocent_time=tupak.prior.Uniform(t0-0.1, t0+0.1, name='geocent_time'))
interferometers = tupak.detector.get_event_data("GW150914")
likelihood = tupak.likelihood.get_binary_black_hole_likelihood(interferometers)
result = tupak.sampler.run_sampler(likelihood, prior, label='GW150914')
result.plot_corner()
......@@ -135,3 +135,28 @@ class BasicLikelihood(object):
def log_likelihood_ratio(self):
return self.log_likelihood() - self.noise_log_likelihood()
def get_binary_black_hole_likelihood(interferometers):
""" A rapper to quickly set up a likelihood for BBH parameter estimation
Parameters
----------
interferometers: list
A list of `tupak.detector.Interferometer` instances, typically the
output of either `tupak.detector.get_interferometer_with_open_data`
or `tupak.detector.get_interferometer_with_fake_noise_and_injection`
Returns
likelihood: tupak.likelihood.Likelihood
The likelihood to pass to `run_sampler`
"""
waveform_generator = tupak.waveform_generator.WaveformGenerator(
frequency_domain_source_model=tupak.source.lal_binary_black_hole,
sampling_frequency=interferometers[0].sampling_frequency,
time_duration=interferometers[0].duration,
parameters={'waveform_approximant': 'IMRPhenomPv2',
'reference_frequency': 50})
likelihood = tupak.likelihood.Likelihood(
interferometers, waveform_generator)
return likelihood
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment