forked from gwastro/pycbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add additional waveform and detector library examples (gwastro#4456)
* add waveform and detector examples * add coursel to highlight pycbc features * fixes suggested by Ian
- Loading branch information
1 parent
287aeb8
commit 0c96700
Showing
10 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[detector-f1] | ||
method = earth_normal | ||
latitude = 0.7120943348136864 | ||
longitude = -1.9861846887695471 | ||
yangle = 2.0943951023931953 | ||
|
||
[detector-f2] | ||
method = earth_normal | ||
latitude = -0.5497787143782138 | ||
longitude = -2.0594885173533086 | ||
yangle = 2.5830872929516078 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import matplotlib.pyplot as plt | ||
from pycbc.detector import add_detector_on_earth, Detector | ||
import pycbc.psd | ||
import numpy as np | ||
|
||
# Set up potential Cosmic Explorer detector locations | ||
|
||
# 40 km detector | ||
lon = -125 / 180.0 * np.pi | ||
lat = 46 / 180.0 * np.pi | ||
yangle = 100.0 / 180.0 * np.pi | ||
# yangle is the rotation clockwise from pointing north at 0 | ||
# xangle can also be specified and allows for detectors that don't have | ||
# 90 degree opening between arms. By default we assume xangle is yangle + pi/2 | ||
add_detector_on_earth("C4", lon, lat, yangle=yangle, | ||
xlength=40000, ylength=40000) | ||
|
||
# 20 km detector | ||
# Arm length is optional, but if provided, you can accurately calcuale | ||
# high-frequency corrects if you provide a frequency argument to the | ||
# antenna pattern method | ||
lon = -94 / 180.0 * np.pi | ||
lat = 29 / 180.0 * np.pi | ||
yangle = 160.0 / 180.0 * np.pi | ||
add_detector_on_earth("C2", lon, lat, yangle=yangle, | ||
xlength=20000, ylength=20000) | ||
|
||
ra, dec = np.meshgrid(np.arange(0, np.pi*2.0, .1), | ||
np.arange(-np.pi / 2.0, np.pi / 2.0, .1)) | ||
ra = ra.flatten() | ||
dec = dec.flatten() | ||
|
||
pol = 0 | ||
time = 1e10 + 8000 # A time when ra ~ lines up with lat/lon coordinates | ||
|
||
for d in [Detector("C4"), Detector("C2")]: | ||
fp, fc = d.antenna_pattern(ra, dec, pol, time) | ||
|
||
plt.figure() | ||
plt.subplot(111, projection="mollweide") | ||
ra[ra>np.pi] -= np.pi * 2.0 | ||
plt.scatter(ra, dec, c=fp**2.0 + fc**2.0) | ||
plt.title("Mollweide") | ||
plt.grid(True) | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import matplotlib.pyplot as pp | ||
from pycbc.waveform import get_td_waveform | ||
|
||
# Let's plot what our new waveform looks like | ||
pp.figure() | ||
|
||
# You can select sets of modes or individual modes using the 'mode_array' | ||
# The standard format is to provide a list of (l, m) modes, however | ||
# a string format is also provided to aid use in population from config files. | ||
# e.g. "22 33" is also acceptable to select these two modes. | ||
# "None" will result in the waveform return its default which is usually | ||
# to return all implemented modes. | ||
for mode_select in [None, | ||
[(2, 2), (3, 3)], # Select two modes at once | ||
[(2, 2)], | ||
[(2, 1)], | ||
[(3, 2)], | ||
[(4, 4)], | ||
]: | ||
hp, hc = get_td_waveform(approximant="IMRPhenomXPHM", | ||
mass1=7, | ||
mass2=40, | ||
f_lower=20.0, | ||
mode_array=mode_select, | ||
inclination = 1.0, | ||
delta_t=1.0/4096) | ||
|
||
|
||
|
||
if mode_select is None: | ||
label = 'Full Waveform' | ||
a = hp.max() | ||
else: | ||
label = "l, m = " + ' '.join([f"{l}, {m}" for l, m in mode_select]) | ||
|
||
(hp / a).plot(label=label) | ||
|
||
pp.xlim(-1, 0.05) | ||
pp.legend() | ||
pp.xlabel('Time [s]') | ||
pp.ylabel('Relative Strain') | ||
pp.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters