Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lscsoft
bilby
Commits
25a152be
There was a problem fetching the pipeline summary.
Commit
25a152be
authored
6 years ago
by
Jade Powell
Browse files
Options
Downloads
Patches
Plain Diff
added sine_gaussian_example.py
parent
95522608
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!52
Burst
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/other_examples/sine_gaussian_example.py
+74
-0
74 additions, 0 deletions
examples/other_examples/sine_gaussian_example.py
with
74 additions
and
0 deletions
examples/other_examples/sine_gaussian_example.py
0 → 100644
+
74
−
0
View file @
25a152be
#!/bin/python
"""
Tutorial to demonstrate running parameter estimation on a sine gaussian injected signal.
"""
from
__future__
import
division
,
print_function
import
tupak
import
numpy
as
np
# Set the duration and sampling frequency of the data segment that we're going to inject the signal into
time_duration
=
4.
sampling_frequency
=
2048.
# Specify the output directory and the name of the simulation.
outdir
=
'
outdir
'
label
=
'
sine_gaussian
'
tupak
.
utils
.
setup_logger
(
outdir
=
outdir
,
label
=
label
)
# Set up a random seed for result reproducibility. This is optional!
np
.
random
.
seed
(
170801
)
# We are going to inject a sine gaussian waveform. We first establish a dictionary of parameters that
# includes all of the different waveform parameters
injection_parameters
=
dict
(
hrss
=
1e-22
,
Q
=
5.0
,
frequency
=
200.0
,
ra
=
1.375
,
dec
=
-
1.2108
,
geocent_time
=
1126259642.413
,
psi
=
2.659
)
# Create the waveform_generator using a sine Gaussian source function
waveform_generator
=
tupak
.
waveform_generator
.
WaveformGenerator
(
time_duration
=
time_duration
,
sampling_frequency
=
sampling_frequency
,
frequency_domain_source_model
=
tupak
.
source
.
sinegaussian
,
parameters
=
injection_parameters
)
hf_signal
=
waveform_generator
.
frequency_domain_strain
()
# 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
IFOs
=
[
tupak
.
detector
.
get_interferometer_with_fake_noise_and_injection
(
name
,
injection_polarizations
=
hf_signal
,
injection_parameters
=
injection_parameters
,
time_duration
=
time_duration
,
sampling_frequency
=
sampling_frequency
,
outdir
=
outdir
)
for
name
in
[
'
H1
'
,
'
L1
'
,
'
V1
'
]]
# Set up prior, which is a dictionary
priors
=
dict
()
# By default we will sample all terms in the signal models. However, this will take a long time for the calculation,
# so for this example we will set almost all of the priors to be equall to their injected values. This implies the
# prior is a delta function at the true, injected value. In reality, the sampler implementation is smart enough to
# not sample any parameter that has a delta-function prior.
for
key
in
[
'
hrss
'
,
'
psi
'
,
'
ra
'
,
'
dec
'
,
'
geocent_time
'
]:
priors
[
key
]
=
injection_parameters
[
key
]
# The above list does *not* include frequency and Q, which means those are the parameters
# that will be included in the sampler. If we do nothing, then the default priors get used.
priors
[
'
Q
'
]
=
tupak
.
prior
.
create_default_prior
(
name
=
'
Q
'
)
priors
[
'
frequency
'
]
=
tupak
.
prior
.
create_default_prior
(
name
=
'
frequency
'
)
# Initialise the likelihood by passing in the interferometer data (IFOs) and the waveoform generator
likelihood
=
tupak
.
likelihood
.
GravitationalWaveTransient
(
interferometers
=
IFOs
,
waveform_generator
=
waveform_generator
)
# Run sampler. In this case we're going to use the `dynesty` sampler
result
=
tupak
.
sampler
.
run_sampler
(
likelihood
=
likelihood
,
priors
=
priors
,
sampler
=
'
dynesty
'
,
npoints
=
1000
,
injection_parameters
=
injection_parameters
,
outdir
=
outdir
,
label
=
label
)
# make some plots of the outputs
result
.
plot_corner
()
print
(
result
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment