Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
bilby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
27
Issues
27
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
12
Merge Requests
12
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lscsoft
bilby
Commits
4fd1d371
Commit
4fd1d371
authored
May 18, 2018
by
plasky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed two examples
parent
2cd37395
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
111 deletions
+0
-111
examples/injection_examples/injection.py
examples/injection_examples/injection.py
+0
-63
examples/injection_examples/time_domain_source_model.py
examples/injection_examples/time_domain_source_model.py
+0
-48
No files found.
examples/injection_examples/injection.py
deleted
100644 → 0
View file @
2cd37395
"""
Tutorial to show signal injection using new features of detector.py
"""
from
__future__
import
division
,
print_function
import
numpy
as
np
import
tupak
import
logging
def
main
():
tupak
.
utils
.
setup_logger
()
outdir
=
'outdir'
label
=
'injection'
# Create the waveform generator
waveform_generator
=
tupak
.
waveform_generator
.
WaveformGenerator
(
time_duration
=
4
,
sampling_frequency
=
2048
,
frequency_domain_source_model
=
tupak
.
source
.
lal_binary_black_hole
,
parameters
=
{
'reference_frequency'
:
50.0
,
'waveform_approximant'
:
'IMRPhenomPv2'
})
# Define the prior
# Merger time is some time in 2018, shame LIGO will never see it...
time_of_event
=
np
.
random
.
uniform
(
1198800018
,
1230336018
)
prior
=
dict
()
prior
[
'luminosity_distance'
]
=
tupak
.
prior
.
PowerLaw
(
alpha
=
2
,
minimum
=
100
,
maximum
=
5000
,
name
=
'luminosity_distance'
)
prior
[
'geocent_time'
]
=
tupak
.
prior
.
Uniform
(
time_of_event
-
0.01
,
time_of_event
+
0.01
,
name
=
'geocent_time'
)
prior
[
'mass_1'
]
=
tupak
.
prior
.
Gaussian
(
mu
=
40
,
sigma
=
5
,
name
=
'mass_1'
)
prior
[
'mass_2'
]
=
tupak
.
prior
.
Gaussian
(
mu
=
40
,
sigma
=
5
,
name
=
'mass_2'
)
tupak
.
prior
.
fill_priors
(
prior
,
waveform_generator
)
# Create signal injection
injection_parameters
=
{
name
:
prior
[
name
].
sample
()
for
name
in
prior
}
if
injection_parameters
[
'mass_1'
]
<
injection_parameters
[
'mass_2'
]:
injection_parameters
[
'mass_1'
],
injection_parameters
[
'mass_2'
]
=
\
injection_parameters
[
'mass_2'
],
injection_parameters
[
'mass_1'
]
logging
.
info
(
"Injection parameters:
\n
{}"
.
format
(
"
\n
"
.
join
([
"{}: {}"
.
format
(
key
,
injection_parameters
[
key
])
for
key
in
injection_parameters
])))
for
parameter
in
injection_parameters
:
waveform_generator
.
parameters
[
parameter
]
=
injection_parameters
[
parameter
]
injection_polarizations
=
waveform_generator
.
frequency_domain_strain
()
# Create interferometers and inject signal
interferometers
=
[
tupak
.
detector
.
get_interferometer_with_fake_noise_and_injection
(
name
,
injection_polarizations
=
injection_polarizations
,
injection_parameters
=
injection_parameters
,
sampling_frequency
=
2048
,
time_duration
=
4
,
outdir
=
outdir
)
for
name
in
[
'H1'
,
'L1'
,
'V1'
]]
# Define a likelihood
likelihood
=
tupak
.
likelihood
.
MarginalizedLikelihood
(
interferometers
,
waveform_generator
,
prior
=
prior
,
distance_marginalization
=
True
,
phase_marginalization
=
True
)
# Run the sampler
result
=
tupak
.
sampler
.
run_sampler
(
likelihood
,
prior
,
label
=
label
,
sampler
=
'dynesty'
,
npoints
=
500
,
resume
=
False
,
outdir
=
outdir
,
use_ratio
=
True
,
injection_parameters
=
injection_parameters
)
truth
=
[
injection_parameters
[
parameter
]
for
parameter
in
result
.
search_parameter_keys
]
result
.
plot_corner
(
truth
=
truth
)
print
(
result
)
if
__name__
==
"__main__"
:
main
()
examples/injection_examples/time_domain_source_model.py
deleted
100644 → 0
View file @
2cd37395
import
tupak
import
matplotlib.pyplot
as
plt
import
numpy
as
np
def
frequency_domain_sine_gaussian
(
f
,
A
,
f0
,
tau
,
phi0
,
geocent_time
,
ra
,
dec
,
psi
):
arg
=
-
(
np
.
pi
*
tau
*
(
f
-
f0
))
**
2
+
1j
*
phi0
plus
=
np
.
sqrt
(
np
.
pi
)
*
A
*
tau
*
np
.
exp
(
arg
)
/
2.
cross
=
plus
*
np
.
exp
(
1j
*
np
.
pi
/
2
)
return
{
'plus'
:
plus
,
'cross'
:
cross
}
def
time_domain_sine_gaussian
(
t
,
A
,
t0
,
f0
,
tau
,
phi0
,
geocent_time
,
ra
,
dec
,
psi
):
arg
=
-
(
-
(
t
-
t0
)
/
tau
)
**
2
plus
=
A
*
np
.
exp
(
arg
)
*
np
.
cos
(
2
*
np
.
pi
*
f0
*
t
+
phi0
)
cross
=
plus
*
np
.
exp
(
1j
*
np
.
pi
/
2
)
return
{
'plus'
:
plus
,
'cross'
:
cross
}
parameters
=
dict
()
parameters
[
'A'
]
=
10000
parameters
[
'f0'
]
=
5
parameters
[
't0'
]
=
10
parameters
[
'tau'
]
=
3
parameters
[
'geocent_time'
]
=
0
parameters
[
'phi0'
]
=
0
parameters
[
'ra'
]
=
0
parameters
[
'dec'
]
=
0
parameters
[
'psi'
]
=
0
wg
=
tupak
.
waveform_generator
.
WaveformGenerator
(
time_duration
=
2000
,
sampling_frequency
=
1000
,
time_domain_source_model
=
time_domain_sine_gaussian
,
parameters
=
parameters
)
wg
.
parameters
=
parameters
plt
.
plot
(
wg
.
frequency_array
,
wg
.
frequency_domain_strain
()[
'plus'
])
plt
.
xlim
(
4
,
6
)
plt
.
show
()
plt
.
plot
(
wg
.
frequency_array
,
wg
.
frequency_domain_strain
()[
'cross'
])
plt
.
xlim
(
4
,
6
)
plt
.
show
()
plt
.
plot
(
wg
.
time_array
,
wg
.
time_domain_strain
()[
'plus'
])
plt
.
xlim
(
0
,
20
)
plt
.
show
()
plt
.
plot
(
wg
.
time_array
,
wg
.
time_domain_strain
()[
'cross'
])
plt
.
xlim
(
0
,
20
)
plt
.
show
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment