Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
276 commits
Select commit Hold shift + click to select a range
830064e
massive reduction in multiplication of arrays, also introduced the co…
AasimZJan Jun 6, 2024
20cbab5
fixed output
AasimZJan Jun 6, 2024
0ec8ca2
psi terms are no in arrays
AasimZJan Jun 6, 2024
14a59d0
added option of giving modes
AasimZJan Jun 7, 2024
38fc914
Comments added
AasimZJan Jun 8, 2024
afefad2
added argument parser
AasimZJan Jun 8, 2024
6a7f9ff
comments
AasimZJan Jun 8, 2024
ac5fe7f
minor changes
AasimZJan Jun 8, 2024
237ee03
added fref to create_lisa_injections
AasimZJan Jun 8, 2024
ce77ad2
added options, made things cleaner, added comments and got it int wor…
AasimZJan Jun 8, 2024
602a455
added print_params_lisa function
AasimZJan Jun 8, 2024
7ba2c43
precompute takes in fref
AasimZJan Jun 8, 2024
917fdda
minor changes
AasimZJan Jun 8, 2024
9a5bab2
minor changes
AasimZJan Jun 8, 2024
f50f6ec
added folders
AasimZJan Jun 8, 2024
4e060c5
removed full path
AasimZJan Jun 8, 2024
c4329c2
Fixed lsu import
AasimZJan Jun 8, 2024
7b91f28
added argument parser
AasimZJan Jun 8, 2024
3bef8f8
added the option to prevent shift in get_tf_phase
AasimZJan Jun 10, 2024
3ff2da1
added options to pseduo pipe
AasimZJan Jun 10, 2024
18e0062
psuedo pipe
AasimZJan Jun 11, 2024
c8c815f
fixed deltaF None issue
AasimZJan Jun 11, 2024
bccfec3
fixed data integration half not being read issue
AasimZJan Jun 14, 2024
d201dc6
minor changes (Spaces)
AasimZJan Jun 14, 2024
57d13c4
removed local path additions
AasimZJan Jun 14, 2024
12de2e1
NRHyb
AasimZJan Jun 29, 2024
c915b5a
set shift to false, letting the code decidtf = 0 instead of shifting it
AasimZJan Jun 29, 2024
808bd5d
fixed modes issue
AasimZJan Jun 29, 2024
02a8e6e
injections
AasimZJan Jun 29, 2024
0dae926
added a function to read NR hdf5 files
AasimZJan Jun 29, 2024
044825c
changes to incklude NR innjections
AasimZJan Jun 29, 2024
792799c
minor changes
AasimZJan Jun 29, 2024
44513ac
Merge branch 'master' of github.com:AasimZJan/RIFT-LISA-3G
AasimZJan Jun 29, 2024
38f12e9
had options for NR injections
AasimZJan Jun 29, 2024
91b855d
can read NR hdf5 file
AasimZJan Jun 29, 2024
1c128ce
removed a print statement
AasimZJan Jun 29, 2024
edeb33c
fixed a return error
AasimZJan Jun 29, 2024
cf0c402
fixed return error
AasimZJan Jun 30, 2024
656ff62
reset shift to True
AasimZJan Jun 30, 2024
817f0a0
fixed tapering
AasimZJan Jul 2, 2024
a3d969f
changed how phase defined in tf-phase dict, now phase is 0 at fref fo…
AasimZJan Jul 17, 2024
558b419
NR injections
AasimZJan Jul 17, 2024
a606fd4
NR injections
AasimZJan Jul 17, 2024
cb10a03
fixed fiducial time for LISA
AasimZJan Jul 17, 2024
18c8a8b
deleted scripts LISA folder
AasimZJan Jul 17, 2024
4577797
time resampling for LISA
AasimZJan Jul 17, 2024
3e3d8b0
changed to allow for time resampling
AasimZJan Jul 17, 2024
ff33f7b
implemented time interpolation for time resampling
AasimZJan Jul 18, 2024
0e7474b
-phiref when generating injections
AasimZJan Jul 18, 2024
1ad691c
create lisa injection will take in a positive phiref and make it nega…
AasimZJan Jul 19, 2024
abf278f
reverted to passing positive phiref to create_lisa_injection function…
AasimZJan Jul 19, 2024
747d7e0
allows it to read mdc.xml.gz file
AasimZJan Jul 19, 2024
ed6fa6f
Now can vary skylocation and save it in the output
AasimZJan Jul 20, 2024
e1abaac
fixed print_params_lisa for ra-dec
AasimZJan Jul 20, 2024
2acb2bc
fixed indentation
AasimZJan Jul 20, 2024
7666a80
fixed saving output
AasimZJan Jul 21, 2024
7c11798
LISA option to read LISA all.net
AasimZJan Jul 21, 2024
593bce7
fixed tvals being empty array issue
AasimZJan Jul 21, 2024
194de4c
added skylocation as parameters
AasimZJan Jul 21, 2024
b1c271f
now the sampler gets 0 as skylocation to prevent the prior from impac…
AasimZJan Jul 21, 2024
c81f917
run checks
AasimZJan Jul 23, 2024
5636bc5
added beta and lambda parameters for CIP sampling
AasimZJan Jul 30, 2024
6f14013
changed for skylocation PE
AasimZJan Jul 30, 2024
b31418d
changes for skylocation PE
AasimZJan Jul 30, 2024
4a36300
added options to allow for skylocation PE
AasimZJan Jul 30, 2024
272c494
allow it to read ILE output with skylocation
AasimZJan Jul 30, 2024
57a29c2
fixed typo
AasimZJan Jul 31, 2024
fe12d0b
removed bounds for spin
AasimZJan Aug 1, 2024
884f0f5
options for fixed sky
AasimZJan Aug 1, 2024
200f79f
removed a wrong comment
AasimZJan Aug 1, 2024
a1a8597
fref changed from 200 to 0.0001
AasimZJan Aug 1, 2024
8244a10
fixed pe summary label issue
AasimZJan Aug 7, 2024
ab8a8cf
fisher errors for initial grid
AasimZJan Aug 7, 2024
084eb0f
plot_RIFT.py improved
AasimZJan Aug 7, 2024
1c0816f
improved fisher_errors
AasimZJan Aug 7, 2024
6b22c45
improved LISA_response
AasimZJan Aug 7, 2024
9127f4a
psd generation
AasimZJan Aug 7, 2024
efe073e
top docstring
AasimZJan Aug 7, 2024
ebbf33b
improved
AasimZJan Aug 8, 2024
3a52d76
added romspline for NR reader in lalsimutils
AasimZJan Aug 8, 2024
812a838
plot rift
AasimZJan Aug 8, 2024
17e3e7c
spin and skylocation bounds
AasimZJan Aug 8, 2024
d80bc77
spin ranges
AasimZJan Aug 8, 2024
dc4dc7d
spin ranges
AasimZJan Aug 8, 2024
5509746
template ini
AasimZJan Aug 8, 2024
e5efb66
pseudo pipe
AasimZJan Aug 8, 2024
a826e48
fixed bug
AasimZJan Aug 8, 2024
aebd58f
fixed bug
AasimZJan Aug 8, 2024
d7947b1
plot_RIFT
AasimZJan Aug 9, 2024
ca41cfb
beta and lambda bounds
AasimZJan Aug 9, 2024
02be47e
beta and lambda bounds
AasimZJan Aug 9, 2024
841ff07
minor change in one of the parser descriptions
AasimZJan Aug 9, 2024
3199b96
added more plots to plot_RIFT
AasimZJan Aug 10, 2024
9ef2ecc
fisher_errors.py: Increased the span skylocation parameters as the po…
AasimZJan Aug 12, 2024
141a0a7
util_RIFT_pseudo_pipe.py: For high SNR cases > 600, we need to ask fo…
AasimZJan Aug 12, 2024
deed239
plot_posterior_corner.py: Changes to remove the hardcoded ranges on p…
AasimZJan Aug 12, 2024
9fcd4a8
mcsamplerPortfolio.py: Bringing this upto speed with most recent ROS …
AasimZJan Aug 12, 2024
bdd7e72
create_injections.py: tested for bugs
AasimZJan Aug 12, 2024
459074d
plot_RIFT.py: will now output Diagnostics.txt that will contain diagn…
AasimZJan Aug 12, 2024
a733eac
hlmoff_for_LISA: can take in XPHM and XHM
AasimZJan Aug 12, 2024
caefa0a
lalsimutils.py: Fixed a bug in the NR injection creator
AasimZJan Aug 12, 2024
e7d4372
fisher_errors.py: Now it can take more options in the parser like snr…
AasimZJan Aug 12, 2024
311439c
create_injections.py: Now it can read in mdc.xml.gz to create injecti…
AasimZJan Aug 12, 2024
8758c5b
generate_LISA_psd.py: added a comment
AasimZJan Aug 13, 2024
353220a
integrate_likelihood_extrinsic_batchmode: removed unnecessary comments
AasimZJan Aug 13, 2024
0c08666
create_injections.py: mindor changes to how arguments were arranged
AasimZJan Aug 13, 2024
76da56b
integrate_likelihood_extrinsic_batchmode: fixed a bug, wasn't able to…
AasimZJan Aug 13, 2024
14483a3
fisher_errors.py: stabilize errors for eta at eta ~0.25
AasimZJan Aug 13, 2024
8a0a945
LISA_response.py: introduced a try statement incase a mode is request…
AasimZJan Aug 13, 2024
0f43d7a
integrate_likelihood_extrinsic_batchmode: erronously had deleted the …
AasimZJan Aug 13, 2024
4c68310
A new branch
AasimZJan Aug 14, 2024
614a5c2
lalsimutils.py: removed resizing for FD in hlmoff_for_LISA
AasimZJan Aug 15, 2024
2010a92
lalsimutils.py: added a comment to warn the user that a TD waveform i…
AasimZJan Aug 16, 2024
14d0279
LISA_response.py: phiref being defined at fref
Aug 16, 2024
8797908
lalsimutils.py: added a warning if a FD version of a TD waveforms get…
Aug 16, 2024
f59a2dc
dag_utils.py: missing from this repo
Aug 16, 2024
8924dcd
lalsimutils.py: fixed typo in the warning I added to warn to user tha…
Aug 16, 2024
ebf640d
LISA_response.py: added phi shift
Aug 16, 2024
a12fb5c
lalsimutils.py: added resize for FD waveforms, FD waveforms have 1 mo…
Aug 16, 2024
8a3bc77
LISA_response.py: IMPORTANT: reduced the time taken by 80%, evaluate_…
AasimZJan Aug 16, 2024
8bfcb96
LISA_response.py: IMPORTANT: reduced the time taken by 80%, evaluate_…
AasimZJan Aug 16, 2024
fd7b045
dag_utils.py: added this since this was missing
AasimZJan Aug 17, 2024
29ec520
util_RIFT_pseudo_pipe.py: added rift ile memory option for longer LIS…
Aug 18, 2024
0810c49
BBH_lisa.ini: newer ini file
Aug 18, 2024
219ebd7
BBH_lisa.ini: added a new line between LISA and approximant arguments
Aug 18, 2024
f000855
removed test_branch.txt
Aug 18, 2024
ec64a51
integrate_likelihood_extrinsic_batchmode: added comments
Aug 18, 2024
5fc2cb7
integrate_likelihood_extrinsic_batchmode: added integrating comment
Aug 19, 2024
d15336d
util_ManualOverlapGrid.py: added option to mirror beta points, the op…
Aug 19, 2024
b796790
LISA_response.py: IMPORTANT: phi recovery works now, reference phase …
Aug 19, 2024
b5083a5
BBH_lisa.ini: removed data-integration-window-half
Aug 19, 2024
baa8ad9
sangria_test: initial commit for sangria testing
AasimZJan Aug 20, 2024
6fad616
factored_likelihood_LISA.py: added the ability to set reference phase…
AasimZJan Aug 20, 2024
6dd51e4
BBH_lisa.ini: 3 psd ini file
AasimZJan Aug 20, 2024
63ddd09
factored_likelihood_LISA.py: now it can read three psds
AasimZJan Aug 20, 2024
6151cc8
LISA_response.py: removed unnecessary comments
AasimZJan Aug 21, 2024
c5a65bf
util_RIFT_pseudo_pipe.py: removed the hacky solution for including A,…
AasimZJan Aug 21, 2024
d804b20
sangria_test: added pycbc_to_rift
AasimZJan Aug 21, 2024
b34cdfa
pycbc_to_rift.py: added resizing and resampling to sangria data
AasimZJan Aug 22, 2024
15caa24
factored_likelihood_LISA.py: f_dict instead of frequency_dict in prec…
Aug 22, 2024
0886070
integrate_likelihood_extrinsic_batchmode: now the error with internal…
Aug 22, 2024
fd23c5a
util_RIFT_pseudo_pipe.py: fixed a bug with ile-memory input
Aug 22, 2024
c82f512
Merge branch 'sangria_test' of github.com:AasimZJan/RIFT-LISA-3G into…
AasimZJan Aug 22, 2024
bbf90e1
factored_likelihood_LISA.py: added to a print statement, will output …
AasimZJan Aug 22, 2024
2c0c395
factored_likelihood_LISA.py: fixed bug
Aug 22, 2024
067cb95
integrate_likelihood_extrinsic_batchmode: set inv_spec_trunc_Q to Fal…
Aug 22, 2024
98207eb
factored_likelihood_LISA.py: removed a debugging statement that outpu…
Aug 22, 2024
af42af3
factored_likelihood_LISA.py: added to debug in the IP function
Aug 22, 2024
59a6e43
integrate_likelihood_extrinsic_batchmode: fixed sky-network co-ordina…
Aug 22, 2024
91760c3
util_ConstructIntrinsicPosterior_GenericCoordinates.py: added comments
AasimZJan Aug 30, 2024
98edc02
create_event_parameter_pipeline_BasicIteration: fixed macrongroup issue
Aug 30, 2024
358de3b
fisher_errors.py: can create a grid now
Aug 30, 2024
2cbf148
fisher_errors.py: can create a grid now
Aug 30, 2024
d29db1f
create_injections.py: changed fmax to fNyq
Aug 30, 2024
0590e24
LISA_response.py: added a function to generate LISA response for non …
Aug 31, 2024
a602ef8
util_RIFT_pseudo_pipe.py: removed coinc dependence for LISA
Aug 31, 2024
55db43a
util_RIFT_pseudo_pipe.py: removed internal sky netwrok co-ordinates f…
Aug 31, 2024
142febb
BBH_lisa.ini: removed puff search option
Aug 31, 2024
d8782c5
util_RIFT_pseudo_pipe.py: removed puff search option
Aug 31, 2024
8c8405a
util_RIFT_pseudo_pipe.py: removed additional data-integration-window-…
Aug 31, 2024
b5445ff
util_ConstructIntrinsicPosterior_GenericCoordinates.py: full paramete…
Aug 31, 2024
be41681
create_event_parameter_pipeline_BasicIteration: fixed macrongroup for…
Aug 31, 2024
bf53d04
LISA_response.py: I was passing wrong ChooseWaveforParamsArray to cre…
AasimZJan Sep 4, 2024
67d54d7
LISA_response.py: fixed some bugs (lalsimutile->lsu), P.incl instead …
AasimZJan Sep 4, 2024
74f31b6
LISA_response.py: added create_h5_files_from_data_dict, get_fvals, fr…
AasimZJan Sep 7, 2024
906413a
LISA_response.py: removed a new line
AasimZJan Sep 8, 2024
abe0781
radler_utils: first commit to radler utils
AasimZJan Sep 8, 2024
095ae1f
utils.py: added docstrings
AasimZJan Sep 8, 2024
597ac26
utils.py: removed a print statement
AasimZJan Sep 8, 2024
c1c8c8a
lalsimutils.py: added PhenomD as an approximant for LISA after testin…
AasimZJan Sep 8, 2024
fcc6867
IMPORTANT: factored_likelihood_LISA.py: commented out phase shift, fi…
AasimZJan Sep 9, 2024
0a065f9
utils.py: minor change to a docstring
AasimZJan Sep 10, 2024
5530f59
integrate_likelihood_extrinsic_batchmode: fixed fNyq and fmax mixup
Sep 11, 2024
752f47e
Merge branch 'sangria_test' of github.com:AasimZJan/RIFT-LISA-3G into…
Sep 11, 2024
16a606b
utils.py: now it will check if interpolation is needed when generatin…
AasimZJan Sep 11, 2024
b11c378
factored_likelihood_LISA.py: IMPORTANT, changed assert to np.isclose …
Sep 11, 2024
14fbe69
added author
Sep 11, 2024
774ef0c
added author
AasimZJan Sep 11, 2024
77b5b6f
utils.py: more options to prevent interpolation
AasimZJan Sep 11, 2024
3c3b216
utils.py: debugged this
AasimZJan Sep 11, 2024
a90b5bf
utils.py: can now taper waveforms
AasimZJan Sep 12, 2024
cdedf92
helper_LDG_Events.py and util_RIFT_pseudo_pipe.py: now they will fit …
Sep 13, 2024
328e539
Merge branch 'sangria_test' of github.com:AasimZJan/RIFT-LISA-3G into…
Sep 13, 2024
4c0a03e
plot_RIFT.py: added docstrings
Sep 13, 2024
def6d2d
util_RIFT_pseudo_pipe.py: more puff iterations and added spin as puff…
Sep 13, 2024
d55c5ca
renamed radler_utils to utils
Sep 13, 2024
6ad6681
docstrings
Sep 13, 2024
f0e4f82
util_RIFT_pseudo_pipe.py, helper_LDG_Events.py: removed unnecessary o…
Sep 13, 2024
6e7f172
BBH_lisa.ini: cleaned up
Sep 13, 2024
5ead6bd
util_RIFT_pseudo_pipe.py: fixed bugs related lisa-fixed-sky
Sep 14, 2024
83d5cb8
util_RIFT_pseudo_pipe.py: internal correlate beta lambda
Sep 15, 2024
f597a76
util_RIFT_pseudo_pipe.py: puff iterations option added, also added pu…
Sep 15, 2024
9ee46c8
lalsimutils.py: removed a comment
Sep 15, 2024
1176486
utils.py: can read in sangria data now
AasimZJan Sep 15, 2024
189912e
utils.py: can add noise to sangria data
AasimZJan Sep 17, 2024
1c0f17d
utils.py: added functions to change psi, beta and lambda from SSB fra…
AasimZJan Sep 19, 2024
fa14151
util_RIFT_pseudo_pipe.py: fixed puff iterations bug
Sep 19, 2024
524f36d
lalsimutils.py: fixed a typo
Sep 19, 2024
b6b2116
integrate_likelihood_extrinsic_batchmode: added flat prior for distance
Sep 19, 2024
fd3ca23
create_injections.py: added 3 PSDs
Sep 19, 2024
3951012
integrate_likelihood_extrinsic_batchmode: will print out distance prior
Sep 19, 2024
07c9206
plot_RIFT.py, BBH_lisa.ini: updates
Sep 19, 2024
a58b469
create_event_parameter_pipeline_BasicIteration: changed n-eff for ext…
Sep 20, 2024
6c9b4d2
integrate_likelihood_extrinsic_batchmode: added debug comments to res…
Sep 20, 2024
ec45c29
utils.py: get_secondary_mode_for_skylocation
Sep 20, 2024
517cbe2
utils.py: added function that calculates secondary peak
AasimZJan Sep 20, 2024
2dd1f79
LISA_injections.py: better lisa injections generator
AasimZJan Sep 22, 2024
e9e5d52
LISA_injections.py: fixed injections
AasimZJan Sep 22, 2024
9f48609
generate_injections.py: first commit
AasimZJan Sep 22, 2024
0d34e7e
IMPORTANT: fixed injection creator
AasimZJan Sep 22, 2024
90a8bd9
IMPORTANT: fixed deltaF issue
AasimZJan Sep 22, 2024
05b2fdf
LISA_injections.py: will create coinc.xml too
Sep 23, 2024
1ff6fef
lalsimutils.py: fixed a typo
Sep 23, 2024
3c0efda
IMPORTANT: factored_likelihood_LISA.py, changed np.isclose to assert …
Sep 23, 2024
df4c407
util_SimInspiralToCoinc.py: fixed a typo
Sep 23, 2024
e333b89
integrate_likelihood_extrinsic_batchmode: will show 1/deltaF of a dat…
Sep 23, 2024
386605c
LISA_response.py: removed a debug statement
Sep 23, 2024
d34388f
mcsamplerAdaptiveVolume.py: now shows max lnL instead of max Prob
Sep 24, 2024
3f2e3b5
removed pycaches
AasimZJan Sep 24, 2024
a1ab9d2
LISA_injections.py: factor of 2 when generating injections
AasimZJan Sep 24, 2024
a127c1b
convert_psd_ascii2xml: plot psd for sanity
Sep 25, 2024
616806d
utils.py: adding tapering percent
Sep 28, 2024
328d4c7
integrate_likelihood_extrinsic_batchmode: IMPORTANT using cubic splin…
Sep 30, 2024
fe53884
factored_likelihood_LISA.py: IMPORTANT, will multiply lnL by 2 as I a…
Sep 30, 2024
b1ff7a9
LISA_injections.py, ggenerate_injections.py: IMPORTANT: SNR multiplie…
Sep 30, 2024
78d9bf0
fisher_errors.py: will generate points on the secondary mode now
Sep 30, 2024
34a9eb4
fisher_errors.py: added capability to setup grid on secondary peak
Sep 30, 2024
870bf07
utils.py: changed output format of LISA_to_SSB
Oct 1, 2024
14bdd97
utils.py: changed get_radler_mbhb_params to get_ldc_mbhb_params
Oct 2, 2024
d925a65
LISA_response.py: extra line for radler
Oct 7, 2024
d38fd8a
util_RIFT_pseudo_pipe.py, create_event_parameter_pipeline_BasicIterat…
Oct 8, 2024
32b880c
BBH_lisa.ini: can take in option for CIP request disk
Oct 8, 2024
500b0fb
utils.py: removed interpolation for resizing
AasimZJan Oct 8, 2024
3b939a7
Merge branch 'radler'
AasimZJan Oct 17, 2024
16d75cf
Update README.md
AasimZJan Oct 25, 2024
61ba4fb
Update README.md
AasimZJan Oct 25, 2024
35755bd
Update README.md
AasimZJan Oct 25, 2024
3c3acb0
Update README.md
AasimZJan Oct 25, 2024
c009a99
Update README.md
AasimZJan Oct 25, 2024
e567bc3
Update README.md
AasimZJan Oct 25, 2024
1445cc7
Update README.md
AasimZJan Oct 25, 2024
9436c13
Update README.md
AasimZJan Oct 25, 2024
fca55c4
Update README.md
AasimZJan Oct 25, 2024
b1415e5
Update README.md
AasimZJan Oct 25, 2024
24ca0c2
Update README.md
AasimZJan Oct 25, 2024
57f96ef
Update README.md
AasimZJan Oct 25, 2024
1c53d20
Update README.md
AasimZJan Oct 25, 2024
49c6d02
Update README.md
AasimZJan Oct 25, 2024
673cc3f
Update README.md
AasimZJan Oct 25, 2024
dc7b204
note.txt: added a note whihc says this branch was used for LISA-RIFT …
AasimZJan Apr 19, 2025
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
272 changes: 272 additions & 0 deletions MonteCarloMarginalizeCode/Code/RIFT/LISA/initial_grid/fisher_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
#!/usr/bin/env python

"""The purpose of this code is to give rough estimates of width of posteriors for Mc, eta, spin and skylocation for initial grid generation."""
import numpy as np
import RIFT.lalsimutils as lsu
from RIFT.LISA.response.LISA_response import *
from argparse import ArgumentParser
from scipy.interpolate import interp1d
import os

__author__ = "A. Jan"
###########################################################################################
# Functions to generate 2-PN waveforms as per http://arxiv.org/abs/gr-qc/9502040.
###########################################################################################
def amplitude_2PN(fvals, Mc):
"""Returns amplitude in frequency domains for a 2-PN waveform"""
# print(f"amplitude_2PN: {locals()}")
return 1 * Mc**(5/6) * fvals**(-7/6)

def phase_2PN(fvals, Mc, eta, sigma, beta, coa_phase=0, coa_time=0):
"""Returns phase in frequency domains for a 2-PN waveform"""
# print(f"phase_2PN: {locals()}")
M = Mc/eta**(3/5)
fac = np.pi*M*fvals
newtonian = 3/128 * (np.pi*Mc*fvals)**(-5/3)
one_PN = 20/9 * (743/336 + 11/4* eta)*(fac)**(2/3)
one_five_PN = 4 * (4*np.pi - beta)*fac
two_PN = 10*(3058673/1016064 + 5429/1008*eta + 617/144*eta**2 - sigma)*(fac)**(4/3)
phase_vals = 2*np.pi*fvals*coa_time - coa_phase - np.pi/4 + newtonian * (1 + one_PN - one_five_PN + two_PN)
return phase_vals

def time_2PN(fvals, Mc, eta, sigma, beta, coa_time=0):
"""Returns time corresponding to input frequency for a 2-PN waveform"""
M = Mc/eta**(3/5)
fac = np.pi*M*fvals
time_vals = coa_time - 5/256* Mc*(np.pi*Mc*fvals)**(-8/3) * (1 + 4/3 * (743/336 + 11/4 * eta)*(fac)**(2/3) - 8/5 *(4*np.pi - beta)*fac + 2*(3058673/1016064 + 5429/1008 * eta + 617/144*eta**2 - sigma)*(fac)**(4/3))
return time_vals

def get_sigma_beta(Mc, eta, a1z, a2z):
"""Returns sigma and beta parameters that are used in construction of the waveform. These parameters contain information about spin."""
alpha = Mc / eta**(3/5)
beta = Mc**2 / eta**(1/5)
m1 = 0.5 * (alpha + np.sqrt(alpha**2 - 4*beta))
m2 = 0.5 * (alpha - np.sqrt(alpha**2 - 4*beta))
M = m1 + m2
sigma_val = eta/48 * (-247 * a1z*a1z + 721 * a1z*a2z)
beta_val = 1/12 * ((113 * (m1/M)**2 + 75 * eta)*a1z + (113 * (m2/M)**2 + 75 * eta)*a2z )
return sigma_val, beta_val

def get_derivative(fvals, Mc, eta, sigma, beta, wf):
"""Derivates of the waveform with respect to coalescence time, coalescence phase, Mc, eta, sigma, beta"""
# print(f"get_derivative: {locals()}")
M = Mc/eta**(3/5)
v = (np.pi*M*fvals)**(1/3)

A4 = 4/3 * (743/336 + 11/4 * eta)
B4 = 8/5 * (4*np.pi - beta)
C4 = 2 * (3058673/1016064 + 5429/1008 * eta + 617/144 * eta**2 - sigma)

A5 = 743/168 - 33/4 * eta
B5 = 27/5 * (4*np.pi - beta)
C5 = 18 * (3058673/1016064 - 5429/4032 * eta - 617/96*eta**2 - sigma)

d_tc = 2*np.pi*1j*(fvals) * wf
d_phi = -1j * wf

d_log_mc = -1j*(5/128 * (np.pi*Mc*fvals)**(-5/3) * (1 + A4*v**2 - B4*v**3 + C4*v**4)) * wf
d_log_eta = -1j*(1/96 * (np.pi*Mc*fvals)**(-5/3) * ( A5*v**2 - B5*v**3 + C5*v**4)) * wf

d_beta = 1j * 3/32 * eta**(-3/5) * (np.pi*Mc*fvals)**(-2/3) * wf
d_sigma = -1j * 15/64 * eta**(-4/5) * (np.pi*Mc*fvals)**(-1/3) * wf
return np.array([d_tc, d_phi, d_log_mc, d_log_eta, d_beta, d_sigma])

def get_wf(fvals, Mc, eta, sigma, beta, psd_vals, coa_phase=0, coa_time=0, snr=None, LISA_response=False, skylocation = None):
"""Generate a 2-PN waveform"""
phase = phase_2PN(fvals, Mc, eta, sigma, beta, coa_phase, coa_time)
amp = amplitude_2PN(fvals, Mc)
wf = amp * np.exp(1j*phase)
if LISA_response:
H = transformed_Hplus_Hcross(skylocation[0], skylocation[1], 0.0, 0.0, 0.0, 2, 2)
time = time_2PN(fvals, Mc, eta, sigma, beta, coa_time)
A, E, T = Evaluate_Gslr(time + coa_time, fvals, H, skylocation[0], skylocation[1])
wf = wf * A
if snr:
# bring the source closer or further, depending on SNR
deltaF = np.diff(fvals)[0]
snr_fiducial = np.sqrt(get_inner_product(wf, wf, psd_vals, deltaF))
correction = snr / snr_fiducial
wf = correction * wf
return wf

###########################################################################################
# Utilities
###########################################################################################
def load_psd(psdf, fvals):
"""Loads in PSD"""
# load in psd
psd_dict = {}
inst = "A"
print( "Reading PSD for instrument %s from %s" % (inst, psdf))
psd_dict[inst] = lsu.get_psd_series_from_xmldoc(psdf, inst)
psd_fvals = psd_dict[inst].f0 + psd_dict[inst].deltaF*np.arange(psd_dict[inst].data.length)
interp_func = interp1d(psd_fvals, psd_dict[inst].data.data)
return interp_func(fvals)

def get_mass_from_mc_eta(mc, eta):
"""Returns m1, m2 from mc and eta."""
alpha = mc / eta**(3/5)
beta = mc**2 / eta**(1/5)
m1 = 0.5 * (alpha + np.sqrt(alpha**2 - 4*beta))
m2 = 0.5 * (alpha - np.sqrt(alpha**2 - 4*beta))
return m1, m2

def get_mc_eta_from_mass(m1, m2):
"""Returns m1, m2 from mc and eta."""
mc = (m1*m2)**(3/5) / (m1+m2)**(1/5)
eta = (m1*m2) / (m1+m2)**(2)
if eta==0.25:
eta=0.24999
return mc, eta

def get_inner_product(wf1, wf2, psd_vals, deltaF):
"""Calculate inner product"""
assert len(wf1) == len(wf2) == len(psd_vals)
weight = 1/psd_vals
intgd = np.sum(np.conj(wf1) * wf2 * weight) * deltaF
return 4 * np.real(intgd)

def get_massratio_error(eta, q, eta_error):
return eta_error * (1 + q)**3 / (1 - q)

def get_spin_error(eta, q, a1z, a2z, eta_error, beta_error, sigma_error):
q_error = get_massratio_error(eta, q, eta_error)
if round(a1z,4)==round(a2z,4):
a1z = a1z + 0.001 * a1z
a2z = a2z - 0.001 * a2z

c1 = sigma_error - eta_error/48 * (474*a1z*a2z)
a1 = eta/48 * 474 * a2z
b1 = eta/48 * 474 * a1z

c2 = beta_error - eta_error/12 * ( (113/q + 75)*a1z + (113*q + 75)*a2z) - eta/12 * ( (-113/q**2)*a1z*q_error + 113*a2z*q_error)
a2 = eta/12 * (113/q + 75)
b2 = eta/12 * (113*q + 75)

coefficients = np.array([ [a1, a2], [b1, b2] ])
dependents = np.array( [c1, c2] )
answers = np.abs(np.linalg.solve(coefficients, dependents))
return [np.min(answers), np.max(answers)]

###########################################################################################
# Fisher matrix
###########################################################################################
def get_fisher_matrix(Mc, eta, sigma, beta, fvals, psd_vals, deltaF, wf):
"""Get fisher information matrix"""
derivatives = get_derivative(fvals, Mc, eta, sigma, beta, wf)
N = 6
tau_ij = np.zeros((N,N))
for i in np.arange(0, N):
for j in np.arange(0, N):
tau_ij[i,j] = get_inner_product(derivatives[i], derivatives[j], psd_vals, deltaF)
inv_tau_ij = (np.linalg.inv(tau_ij))
return tau_ij, inv_tau_ij

def get_error_bounds(P_inj, snr, psd_path):
"""Get error bounds on parameters using fisher information matrix."""
response=True # use LISA response
deltaF = 0.00001 # hardcoded deltaF
mc, eta = get_mc_eta_from_mass(P_inj.m1/lsu.lsu_MSUN, P_inj.m2/lsu.lsu_MSUN)
q = P_inj.m2/P_inj.m1

if q == 1:
q = 0.9

# convert chirp mass to seconds
Mc = mc * 5 * 10**(-6)
M = Mc/eta**(3/5)
sigma, beta = get_sigma_beta(Mc, eta, P_inj.s1z, P_inj.s2z)
fmax = 6**(-3/2) / np.pi/ M
print(f"Fmax is = {fmax} Hz")
fvals = np.arange(float(opts.snr_fmin), fmax, deltaF)

# Load psd
psd_vals = load_psd(opts.psd_path, fvals)

# generate waveform
wf = get_wf(fvals, Mc, eta, sigma, beta, psd_vals, 0, float(P_inj.tref), snr=float(opts.snr), LISA_response=response, skylocation=[P_inj.theta, P_inj.phi])
print(f"SNR of generated waveform is = {np.sqrt(get_inner_product(wf,wf,psd_vals, deltaF))}")

# Calculate fisher matrix
tau_ij, inv_tau_ij = get_fisher_matrix(Mc, eta, sigma, beta, fvals, psd_vals, deltaF, wf)
if eta < 0.24:
factor_eta = 12.5
if eta >=0.24: # the errors estimates seem to be large for q~1 case.
factor_eta = 1.0
factor_mc = 50
factor_spin1 = 60
factor_spin2 = 60
spin_bounds = get_spin_error(eta, q, P_inj.s1z, P_inj.s2z, (np.sqrt(1/tau_ij[3,3]))*eta, np.sqrt(1/tau_ij[4,4]), np.sqrt(1/tau_ij[5,5]))

print(f"Mc span = {2*factor_mc*np.sqrt(1/tau_ij[2,2])*mc}, eta span = {2*np.sqrt(1/tau_ij[3,3])*eta*factor_eta}, s1z span = {2*factor_spin1*spin_bounds[0]}, s2z span = {2*factor_spin2*spin_bounds[1]}, beta span = {0.036*(210/snr)**2}, lambda span = {0.044*(210/snr)**2}")


return np.array([ mc - factor_mc*np.sqrt(1/tau_ij[2,2])*mc, mc + factor_mc*np.sqrt(1/tau_ij[2,2])*mc, eta-(np.sqrt(1/tau_ij[3,3]))*eta*factor_eta, eta+(np.sqrt(1/tau_ij[3,3]))*eta*factor_eta, P_inj.s1z - factor_spin1*spin_bounds[0], P_inj.s1z + factor_spin1*spin_bounds[0], P_inj.s2z - factor_spin2*spin_bounds[1], P_inj.s2z + factor_spin2*spin_bounds[1], P_inj.theta - 0.018*(210/snr), P_inj.theta + 0.018*(210/snr), P_inj.phi - 0.022*(210/snr), P_inj.phi + 0.022*(210/snr)])


###########################################################################################

if __name__ =='__main__':
###########################################################################################
parser=ArgumentParser()
parser.add_argument("--inj", help="Full path to mdc.xml.gz")
parser.add_argument("--psd-path", help="Full path to A-psd.xm.gz")
parser.add_argument("--snr", help="SNR of the signal")
parser.add_argument("--snr-fmin", help="fmin used in snr calculations", default=0.0001)
parser.add_argument("--generate-grid", help="Use the fisherbounds to generate grid", default=True)
parser.add_argument("--points", help="number of points in the grid", default=25000)
opts = parser.parse_args()
print(f"Loading file:\n {opts.inj}")
P_inj_list = lsu.xml_to_ChooseWaveformParams_array(opts.inj)
P_inj = P_inj_list[0]
print("######")
print(f"m1 = {P_inj.m1/lsu.lsu_MSUN}, m2 = {P_inj.m2/lsu.lsu_MSUN}, s1z = {P_inj.s1z}, s2z = {P_inj.s2z}, beta = {P_inj.theta}, lambda = {P_inj.phi}, tref = {P_inj.tref} s")
print("######")
error_bounds = get_error_bounds(P_inj, float(opts.snr), opts.psd_path)
print(f"Mc bounds = [{error_bounds[0]:0.2f}, {error_bounds[1]:0.2f}]")
print(f"eta bounds = [{error_bounds[2]:0.8f}, {error_bounds[3]:0.8f}]")
print(f"s1z bounds = [{error_bounds[4]:0.6f}, {error_bounds[5]:0.6f}]")
print(f"s2z bounds = [{error_bounds[6]:0.6f}, {error_bounds[7]:0.6f}]")
print(f"beta bounds = [{error_bounds[8]:0.6f}, {error_bounds[9]:0.6f}]")
print(f"lambda bounds = [{error_bounds[10]:0.6f}, {error_bounds[11]:0.6f}]")
mc_span, eta_span = (error_bounds[1] - error_bounds[0]), (error_bounds[3] - error_bounds[2])
s1z_span, s2z_span = (error_bounds[5] - error_bounds[4]), (error_bounds[7] - error_bounds[6])
beta_span, lambda_span = (error_bounds[9] - error_bounds[8]), (error_bounds[11] - error_bounds[10])
if opts.generate_grid:
import os
from RIFT.LISA.utils.utils import *
cmd = f"util_ManualOverlapGrid.py --inj {opts.inj} "
cmd += f"--parameter mc --parameter-range '[{error_bounds[0]:0.2f}, {error_bounds[1]:0.2f}]' "
cmd += f"--parameter eta --parameter-range '[{error_bounds[2]:0.5f}, {error_bounds[3]:0.5f}]' "
cmd += f"--random-parameter s1z --random-parameter-range '[{error_bounds[4]:0.6f}, {error_bounds[5]:0.6f}]' "
cmd += f"--random-parameter s2z --random-parameter-range '[{error_bounds[6]:0.6f}, {error_bounds[7]:0.6f}]' "
cmd += f"--random-parameter theta --random-parameter-range '[{error_bounds[8]:0.6f}, {error_bounds[9]:0.6f}]' "
cmd += f"--random-parameter phi --random-parameter-range '[{error_bounds[10]:0.6f}, {error_bounds[11]:0.6f}]' "
cmd += f"--grid-cartesian-npts {int(opts.points)} --skip-overlap"
print(f"\t Generating grid\n{cmd}")
os.system(cmd)
os.system('mv overlap-grid.xml.gz overlap-grid-primary.xml.gz')

secondary_peak = get_secondary_mode_for_skylocation(float(P_inj.tref), P_inj.phi, P_inj.theta)
beta_sec, lambda_sec = secondary_peak[0,2], secondary_peak[0,1]
print(f"Secondary peak: lambda {lambda_sec}, beta {beta_sec}")
cmd = f"util_ManualOverlapGrid.py --inj {opts.inj} "
cmd += f"--parameter mc --parameter-range '[{error_bounds[0]:0.2f}, {error_bounds[1]:0.2f}]' "
cmd += f"--parameter eta --parameter-range '[{error_bounds[2]:0.5f}, {error_bounds[3]:0.5f}]' "
cmd += f"--random-parameter s1z --random-parameter-range '[{error_bounds[4]:0.6f}, {error_bounds[5]:0.6f}]' "
cmd += f"--random-parameter s2z --random-parameter-range '[{error_bounds[6]:0.6f}, {error_bounds[7]:0.6f}]' "
cmd += f"--random-parameter theta --random-parameter-range '[{beta_sec-0.5*beta_span}, {beta_sec+0.5*beta_span}]' "
cmd += f"--random-parameter phi --random-parameter-range '[{lambda_sec-0.5*lambda_span}, {lambda_sec+0.5*lambda_span}]' "
cmd += f"--grid-cartesian-npts {int(opts.points)} --skip-overlap"
print(f"\t Generating grid\n{cmd}")
os.system(cmd)
os.system('mv overlap-grid.xml.gz overlap-grid-secondary.xml.gz')
os.system('ligolw_add overlap-grid-primary.xml.gz overlap-grid-secondary.xml.gz -o overlap-grid.xml.gz')








Loading