Skip to content
Snippets Groups Projects

Resolve "add neutron star merger to examples"

Merged Francisco Hernandez requested to merge 176-add-neutron-star-merger-to-examples into master
Files
6
#!/bin/python
"""
Tutorial to demonstrate running parameter estimation on a binary neutron star
system taking into account tidal deformabilities.
This example estimates the masses using a uniform prior in both component masses
and also estimates the tidal deformabilities using a uniform prior in both
tidal deformabilities
"""
from __future__ import division, print_function
import numpy as np
import tupak
# Specify the output directory and the name of the simulation.
outdir = 'outdir'
label = 'bns_example'
tupak.core.utils.setup_logger(outdir=outdir, label=label)
# Set up a random seed for result reproducibility. This is optional!
np.random.seed(88170235)
# We are going to inject a binary neutron star waveform. We first establish a
# dictionary of parameters that includes all of the different waveform
# parameters, including masses of the two black holes (mass_1, mass_2),
# spins of both black holes (a_1,a_2) , etc.
injection_parameters = dict(
mass_1=1.5, mass_2=1.3, a_1=0.0, a_2=0.0, luminosity_distance=50.,
iota=0.4, psi=2.659, phase=1.3, geocent_time=1126259642.413,
ra=1.375, dec=-1.2108, lambda1=400, lambda2=450)
# Set the duration and sampling frequency of the data segment that we're going
# to inject the signal into. For the
# TaylorF2 waveform, we cut the signal close to the isco frequency
duration = 8
sampling_frequency = 2*1570.
start_time = injection_parameters['geocent_time'] + 2 - duration
# Fixed arguments passed into the source model. The analysis starts at 40 Hz.
waveform_arguments = dict(waveform_approximant='TaylorF2',
reference_frequency=50., minimum_frequency=40.0)
# Create the waveform_generator using a LAL Binary Neutron Star source function
waveform_generator = tupak.gw.WaveformGenerator(
duration=duration, sampling_frequency=sampling_frequency,
frequency_domain_source_model=tupak.gw.source.lal_binary_neutron_star,
waveform_arguments=waveform_arguments)
# Set up interferometers. In this case we'll use three interferometers
# (LIGO-Hanford (H1), LIGO-Livingston (L1), and Virgo (V1)).
# These default to their design sensitivity and start at 40 Hz.
interferometers = tupak.gw.detector.InterferometerList(['H1', 'L1', 'V1'])
for interferometer in interferometers:
interferometer.minimum_frequency = 40
interferometers.set_strain_data_from_power_spectral_densities(
sampling_frequency=sampling_frequency, duration=duration,
start_time=start_time)
interferometers.inject_signal(parameters=injection_parameters,
waveform_generator=waveform_generator)
priors = tupak.gw.prior.BNSPriorSet()
for key in ['a_1', 'a_2', 'psi', 'geocent_time', 'ra', 'dec',
'iota', 'luminosity_distance', 'phase']:
priors[key] = injection_parameters[key]
# Initialise the likelihood by passing in the interferometer data (IFOs)
# and the waveoform generator
likelihood = tupak.gw.GravitationalWaveTransient(
interferometers=interferometers, waveform_generator=waveform_generator,
time_marginalization=False, phase_marginalization=False,
distance_marginalization=False, prior=priors)
# Run sampler. In this case we're going to use the `nestle` sampler
result = tupak.run_sampler(
likelihood=likelihood, priors=priors, sampler='nestle', npoints=1000,
injection_parameters=injection_parameters, outdir=outdir, label=label)
result.plot_corner()
Loading