Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lisa dev merge #4128

Merged
merged 33 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
280c740
fix waveform_transforms not defined issue
WuShichao Sep 7, 2022
ed1e8ea
add static_args back
WuShichao Sep 7, 2022
611e517
fix cc issues
WuShichao Sep 7, 2022
fc97c48
adopt Ian's changes for LISA
WuShichao Sep 8, 2022
550cbb1
update for LISA bank
WuShichao Sep 8, 2022
ee8e4ab
fix self.ta[ifo] issue
WuShichao Sep 8, 2022
78cb2bb
fix
WuShichao Sep 8, 2022
f72ca9f
fix ta issue
WuShichao Sep 8, 2022
9de05ff
remove all changes
WuShichao Sep 8, 2022
cb01440
Plugin testing script
ConWea Sep 9, 2022
0a52509
Merge pull request #1 from ConWea/lisa_dev_merge
WuShichao Sep 9, 2022
8d18f82
remove all hard-coded "BBHx"
WuShichao Sep 9, 2022
cebbf74
Rel bug fix
ConWea Sep 9, 2022
03c83ce
Begin no atenna response wf interface
ConWea Sep 9, 2022
fc78785
remove old bbhx plugin
WuShichao Sep 10, 2022
9878636
add general interface for BBHx
WuShichao Sep 10, 2022
7344620
is_lisa issue not fix yet
WuShichao Sep 10, 2022
f720860
Merged interface changes
ConWea Sep 12, 2022
b619ac6
Adding test scripts
ConWea Sep 12, 2022
c3422a7
Plot code for inference
ConWea Sep 12, 2022
15ce6d9
Approximant name change
ConWea Sep 12, 2022
01c6265
Changed is_lisa flag to checking approximant name against type of wav…
ConWea Sep 13, 2022
d571721
Modified cython code with own version of likelihood_parts function fo…
ConWea Sep 13, 2022
ada9c53
Error in changing to dictionary output from plugin
ConWea Sep 13, 2022
327b1f3
Fixes to PR request. Mainly reconfiguring due to convention choice of…
ConWea Sep 13, 2022
964959d
Merge branch 'gwastro:master' into lisa_dev_merge
WuShichao Sep 13, 2022
dc13cda
Merge branch 'gwastro:master' into lisa_dev_merge
WuShichao Sep 13, 2022
d8cacae
Code rename conventions
ConWea Sep 14, 2022
4b950d0
Merge branch 'lisa_dev_merge' of https://github.com/WuShichao/pycbc i…
ConWea Sep 14, 2022
2f8bfc7
Commiting changes for naming convention after merge
ConWea Sep 14, 2022
b631da5
Changes from codeclimate
ConWea Sep 14, 2022
3bcf4fa
More codeclimate changes
ConWea Sep 14, 2022
1da6acd
More codeclimate changes
ConWea Sep 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions bin/bank/pycbc_brute_bank
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ parser.add_argument('--approximant', required=True,
parser.add_argument('--minimal-match', default=0.97, type=float)
parser.add_argument('--buffer-length', default=2, type=float,
help='size of waveform buffer in seconds')
parser.add_argument('--sample-rate', default=2048, type=int,
parser.add_argument('--sample-rate', default=2048, type=float,
help='sample rate in seconds')
parser.add_argument('--low-frequency-cutoff', default=20.0, type=float)
parser.add_argument('--enable-sigma-bound', action='store_true')
Expand Down Expand Up @@ -85,6 +85,8 @@ if args.input_config is not None:
if any(config_parser.get_subsections('waveform_transforms')):
waveform_transforms = transforms.read_transforms_from_config(
config_parser, 'waveform_transforms')
else:
waveform_transforms = None

dists_joint = prior_from_config(cp=config_parser)

Expand Down Expand Up @@ -270,8 +272,10 @@ class GenUniformWaveform(object):
def generate(self, **kwds):
kwds.update(fdict)
if kwds['approximant'] in pycbc.waveform.fd_approximants():
hp, hc = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f,
ws = pycbc.waveform.get_fd_waveform(delta_f=self.delta_f,
f_lower=self.f_lower, **kwds)
hp = ws[0]
hc = ws[1]
if 'fratio' in kwds:
hp = hc * kwds['fratio'] + hp * (1 - kwds['fratio'])
else:
Expand Down Expand Up @@ -349,12 +353,13 @@ def draw(rtype):
for k, v in zip(p, points):
params[k] = v

# Add `static_args` back, some transformations may need them.
if args.input_config is not None and static_args is not None:
for k in static_args.keys():
params[k] = numpy.array([static_args[k]]*size)

# Apply `waveform_transforms` defined in the .ini file to samples.
if args.input_config is not None and waveform_transforms is not None:
# Add `static_args` back, some transformations may need them.
if static_args is not None:
for k in static_args.keys():
params[k] = numpy.array([static_args[k]]*size)
params = transforms.apply_transforms(params, waveform_transforms)

params['approximant'] = numpy.array([args.approximant]*size)
Expand Down
78 changes: 78 additions & 0 deletions examples/lisa/plot_gen_mchirp_q.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import pickle
import numpy as np

def s_ldc2pycbc(mag, pol):
return mag*np.cos(pol)

def mr(m1,m2):
return m1/m2

def mchi(m1, m2):
return ((m1*m2)**(3/5))/(m1+m2)**(1/5)

def plt(index):

with open('param_files/MBHB_params_v2.pkl', 'rb') as f:
pmbhb = pickle.load(f)

p_index = index
pMBHB = pmbhb[p_index]

print(pMBHB)

from ldc.common import tools

modes = [(2,2)]#, (2,1), (3,3), (3,2), (4,4), (4,3)]

psi, incl = tools.aziPolAngleL2PsiIncl(pMBHB["EclipticLatitude"],
pMBHB["EclipticLongitude"],
pMBHB['InitialPolarAngleL'],
pMBHB['InitialAzimuthalAngleL'])

if psi < 0.:
psi = psi + 2*np.pi

q = mr(pMBHB['Mass1'], pMBHB['Mass2'])
mchirp = mchi(pMBHB['Mass1'],pMBHB['Mass2'])

params = {'approximant': 'BBHX_PhenomD',
'mass1': pMBHB['Mass1'],
'mass2': pMBHB['Mass2'],
'inclination': incl,
'tc': pMBHB['CoalescenceTime'],
'polarization': psi,
'spin1z': s_ldc2pycbc(pMBHB['Spin1'], pMBHB['PolarAngleOfSpin1']),
'spin2z': s_ldc2pycbc(pMBHB['Spin2'], pMBHB['PolarAngleOfSpin2']),
'coa_phase' : pMBHB['PhaseAtCoalescence'],
'distance': pMBHB['Distance'],
'eclipticlatitude': pMBHB['EclipticLatitude'],
'eclipticlongitude': pMBHB['EclipticLongitude'],
'mchirp':mchirp,
'q':q,
'mode_array':modes}

plot_code = f"""
pycbc_inference_plot_posterior \
--input-file simple_test.hdf \
--output-file simple_run_post.png \
--z-arg snr --plot-scatter --plot-marginal
--parameters \
mass1_from_mchirp_q(mchirp,q):mass1\
mass2_from_mchirp_q(mchirp,q):mass2\
tc\
--expected-parameters mass1_from_mchirp_q(mchirp,q):{params['mass1']}\
mass2_from_mchirp_q(mchirp,q):{params['mass2']}\
tc:{params['tc']}
"""
return plot_code

import subprocess

p = [0]

for i in p:#range(15):
process = subprocess.Popen(plt(i).split(), stdout=subprocess.PIPE)
output, error = process.communicate()
print('rel{} image created'.format(i))


49 changes: 49 additions & 0 deletions examples/lisa/plugin_test/test_waveform_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import numpy as np
import pickle

import pycbc.waveform

signals = []

def s_ldc2pycbc(mag, pol):
return mag*np.cos(pol)

with open('../param_files/MBHB_params_v2.pkl', 'rb') as f:
pmbhb = pickle.load(f)

pMBHB = pmbhb[0]

modes = [(2,2)]

params = {'approximant': 'BBHX_PhenomD',
'mass1': pMBHB['Mass1'],
'mass2': pMBHB['Mass2'],
'delta_f':1/31536000,
'inclination': np.pi/3,
'tc': pMBHB['CoalescenceTime'],
'polarization': np.pi/2,
'spin1z': s_ldc2pycbc(pMBHB['Spin1'], pMBHB['PolarAngleOfSpin1']),
'spin2z': s_ldc2pycbc(pMBHB['Spin2'], pMBHB['PolarAngleOfSpin2']),
'coa_phase' : pMBHB['PhaseAtCoalescence'],
'distance': pMBHB['Distance'],
'eclipticlatitude': pMBHB['EclipticLatitude'],
'eclipticlongitude': pMBHB['EclipticLongitude'],
'mode_array':modes}

signals.append(params)

params = signals[0]



A = pycbc.waveform.get_fd_waveform(f_lower=0.0001, **params)

import matplotlib.pylab as plt


td_A = A[0].to_timeseries()

plt.figure(figsize=(12,6))
plt.plot(td_A.sample_times,td_A)
plt.xlim(params['tc']-1000, params['tc']+1000)
plt.savefig('test_waveform_plugin.jpg')
7 changes: 7 additions & 0 deletions examples/lisa/run_inference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
ahnitz marked this conversation as resolved.
Show resolved Hide resolved
pycbc_inference --verbose \
--config-files configs/0/model_debug-config.ini \
configs/0/data_debug-config.ini \
configs/0/sampler_debug-config.ini \
--output-file inference_test.hdf \
--force
7 changes: 7 additions & 0 deletions examples/lisa/simple_inf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
pycbc_inference --verbose \
--config-files simple_run/model_debug-config.ini \
simple_run/data_debug-config.ini \
simple_run/sampler_debug-config.ini \
--output-file simple_test.hdf \
--force
Loading