-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlalsimutils.py
More file actions
5807 lines (5237 loc) · 260 KB
/
lalsimutils.py
File metadata and controls
5807 lines (5237 loc) · 260 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 2012 Evan Ochsner, R. O'Shaughnessy
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
A collection of useful data analysis routines
built from the SWIG wrappings of LAL and LALSimulation.
"""
import sys
import copy
import types
has_external_teobresum=False
import os
info_use_ext = True
if 'RIFT_NO_EXTERNAL' in os.environ:
info_use_ext = False
has_external_teobresum=False
else:
try:
import EOBRun_module
has_external_teobresum=True
except:
has_external_teobresum=False
True; # print(" - no EOBRun (TEOBResumS) - ")
info_use_resum_polarizations = False
if 'RIFT_RESUM_POLARIZATIONS' in os.environ:
info_use_resum_polarizations=True # fallback to ChooseTDModesFromPolarizations for TEOBResumS (since ChooseTDModes is not available at present)
from six.moves import range
log_loud = False
if 'RIFT_LOUD' in os.environ:
log_loud = True
import numpy as np
from numpy import sin, cos
from scipy import interpolate
from scipy import signal
import scipy # for decimate
try:
import precession
except ImportError:
print('Import Error - module missing. Please install the module "precession."')
def safe_int(mystr):
try:
return int(mystr)
except:
return None
sci_ver = list(map(safe_int, scipy.version.version.split('.'))) # scipy version number as int list.
from igwn_ligolw import lsctables, utils, ligolw #, table, ,ilwd # check all are needed
from glue.lal import Cache
lalmetaio_old_style=True
import lalmetaio
if not(hasattr(lalmetaio.SimInspiralTable, 'geocent_end_time_ns')):
# print(" NEW style lalmetaio ")
lalmetaio_old_style=False # no geocent_end_time_ns
import lal
import lalsimulation as lalsim
#import lalinspiral
import lalmetaio
#from pylal import seriesutils as series
from lal.series import read_psd_xmldoc
from lalframe import frread
# import RIFT.misc.tools as tools
__author__ = "Evan Ochsner <evano@gravity.phys.uwm.edu>, R. O'Shaughnessy"
rosDebugMessagesContainer = [False]
rosDebugMessagesLongContainer = [False]
if log_loud:
print( "[Loading lalsimutils.py : MonteCarloMarginalization version]",file=sys.stderr)
print( " scipy : ", scipy.__version__, file=sys.stderr)
print(" numpy : ", np.__version__,file=sys.stderr)
TOL_DF = 1.e-6 # Tolerence for two deltaF's to agree
#spin_convention = "radiation"
spin_convention = "L"
# from functools import wraps
# def strip_ilwdchar(_ContentHandler):
# """Wrap a LIGO_LW content handler to swap ilwdchar for int on-the-fly
# when reading a document
# This is adapted from :func:`ligo.skymap.utils.ilwd`, copyright
# Leo Singer (GPL-3.0-or-later).
# This is taken directly from https://github.com/gwpy/gwpy/blob/master/gwpy/io/ligolw.py#L92
# """
# from igwn_ligolw.lsctables import TableByName
# from igwn_ligolw.table import (Column, TableStream)
# from igwn_ligolw.types import (FromPyType, ToPyType)
# class IlwdMapContentHandler(_ContentHandler):
# def __init__(self, *args, **kwargs):
# super().__init__(*args, **kwargs)
# self._idconverter = {}
# @wraps(_ContentHandler.startColumn)
# def startColumn(self, parent, attrs):
# result = super().startColumn(parent, attrs)
# # if an old ID type, convert type definition to an int
# if result.Type == "ilwd:char":
# old_type = ToPyType[result.Type]
# def converter(old):
# return int(old_type(old))
# self._idconverter[(id(parent), result.Name)] = converter
# result.Type = FromPyType[int]
# try:
# validcolumns = TableByName[parent.Name].validcolumns
# except KeyError: # parent.Name not in TableByName
# return result
# if result.Name not in validcolumns:
# stripped_column_to_valid_column = {
# Column.ColumnName(name): name
# for name in validcolumns
# }
# if result.Name in stripped_column_to_valid_column:
# result.setAttribute(
# 'Name',
# stripped_column_to_valid_column[result.Name],
# )
# return result
# @wraps(_ContentHandler.startStream)
# def startStream(self, parent, attrs):
# result = super().startStream(parent, attrs)
# if isinstance(result, TableStream):
# loadcolumns = set(parent.columnnames)
# if parent.loadcolumns is not None:
# loadcolumns &= set(parent.loadcolumns)
# pid = id(parent)
# result._tokenizer.set_types([
# self._idconverter.pop((pid, colname), pytype)
# if colname in loadcolumns else None
# for pytype, colname in zip(
# parent.columnpytypes,
# parent.columnnames,
# )
# ])
# return result
# return IlwdMapContentHandler
# updated in igwn_ligolw
#cthdler = strip_ilwdchar(ligolw.LIGOLWContentHandler) #defines a content handler to load xml grids
cthdler = ligolw.LIGOLWContentHandler
#lsctables.use_in(cthdler)
waveform_approx_limit_dict = {
"NRHybSur3dq8": { "q-min":1./8, "chi-max":0.8
},
"NRSur7dq2": { "q-min":1./2, "chi-max":0.8
},
"NRSur7dq4": { "q-min":1./4, "chi-max":0.8
},
}
# Check lal version (lal.LAL_MSUN_SI or not). Enables portability through the version transition.
try:
x=lal.LAL_MSUN_SI
except:
# print " New style : no LAL prefix"
lsu_MSUN=lal.MSUN_SI
lsu_PC = lal.PC_SI
lsu_G = lal.G_SI
lsu_C = lal.C_SI
lsu_PI=lal.PI
lsu_TAPER_NONE=lalsim.SIM_INSPIRAL_TAPER_NONE
lsu_TAPER_START=lalsim.SIM_INSPIRAL_TAPER_START
lsu_TAPER_END=lalsim.SIM_INSPIRAL_TAPER_END
lsu_TAPER_STARTEND=lalsim.SIM_INSPIRAL_TAPER_STARTEND
lsu_DimensionlessUnit = lal.DimensionlessUnit
lsu_HertzUnit = lal.HertzUnit
lsu_SecondUnit = lal.SecondUnit
lsu_PNORDER_NEWTONIAN = lalsim.PNORDER_NEWTONIAN
lsu_PNORDER_HALF = lalsim.PNORDER_HALF
lsu_PNORDER_ONE = lalsim.PNORDER_ONE
lsu_PNORDER_ONE_POINT_FIVE = lalsim.PNORDER_ONE_POINT_FIVE
lsu_PNORDER_TWO = lalsim.PNORDER_TWO
lsu_PNORDER_TWO_POINT_FIVE = lalsim.PNORDER_TWO_POINT_FIVE
lsu_PNORDER_THREE = lalsim.PNORDER_THREE
lsu_PNORDER_THREE_POINT_FIVE = lalsim.PNORDER_THREE_POINT_FIVE
else:
print(" Old style : LAL prefix")
lsu_MSUN=lal.LAL_MSUN_SI
lsu_PC=lal.LAL_PC_SI
lsu_G = lal.LAL_G_SI
lsu_C = lal.LAL_C_SI
lsu_PI = lal.LAL_PI
lsu_TAPER_NONE=lalsim.LAL_SIM_INSPIRAL_TAPER_NONE
lsu_TAPER_START=lalsim.LAL_SIM_INSPIRAL_TAPER_START
lsu_TAPER_END=lalsim.LAL_SIM_INSPIRAL_TAPER_END
lsu_TAPER_STARTEND=lalsim.LAL_SIM_INSPIRAL_TAPER_STARTEND
lsu_DimensionlessUnit = lal.lalDimensionlessUnit
lsu_HertzUnit = lal.lalHertzUnit
lsu_SecondUnit = lal.lalSecondUnit
lsu_PNORDER_NEWTONIAN = lalsim.LAL_PNORDER_NEWTONIAN
lsu_PNORDER_HALF = lalsim.LAL_PNORDER_HALF
lsu_PNORDER_ONE = lalsim.LAL_PNORDER_ONE
lsu_PNORDER_ONE_POINT_FIVE = lalsim.LAL_PNORDER_ONE_POINT_FIVE
lsu_PNORDER_TWO = lalsim.LAL_PNORDER_TWO
lsu_PNORDER_TWO_POINT_FIVE = lalsim.LAL_PNORDER_TWO_POINT_FIVE
lsu_PNORDER_THREE = lalsim.LAL_PNORDER_THREE
lsu_PNORDER_THREE_POINT_FIVE = lalsim.LAL_PNORDER_THREE_POINT_FIVE
try:
lalSEOBv4 = lalsim.SEOBNRv4
lalIMRPhenomD = lalsim.IMRPhenomD
except:
lalSEOBv4 =-1
lalIMRPhenomD = -2
try:
lalTEOBv2 = -3 # not implemented
lalTEOBv4 = lalsim.SEOBNRv4T
except:
lalTEOBv2 = -3
lalTEOBv4 = -4
try:
lalSEOBNRv4HM = lalsim.SEOBNRv4HM
except:
lalSEOBNRv4HM = -5
try:
lalSEOBNRv4P = lalsim.SEOBNRv4P
lalSEOBNRv4PHM = lalsim.SEOBNRv4PHM
except:
lalSEOBNRv4P = -6
lalSEOBNRv4PHM = -7
try:
lalNRSur7dq4 = lalsim.NRSur7dq4
lalNRSur7dq2 = lalsim.NRSur7dq2
lalNRHybSur3dq8 = lalsim.NRHybSur3dq8
except:
lalNRSur7dq4 = -8
lalNRSur7dq2 = -9
lalNRHybSur3dq8 = -10
try:
lalIMRPhenomHM = lalsim.IMRPhenomHM
lalIMRPhenomXHM = lalsim.IMRPhenomXHM
lalSEOBNRv4HM_ROM = lalsim.SEOBNRv4HM_ROM
lalIMRPhenomXP = lalsim.IMRPhenomXP
lalIMRPhenomXPHM = lalsim.IMRPhenomXPHM
lalIMRPhenomXO4a = lalsim.IMRPhenomXO4a
except:
lalIMRPhenomXP = -11
lalIMRPhenomHM = -14
lalIMRPhenomXHM = -15
lalSEOBNRv4HM_ROM = -16
lalIMRPhenomXPHM = -17
lalIMRPhenomXO4a = -18
pending_FD_approx = ['IMRPhenomXP_NRTidalv2', 'IMRPhenomXAS_NRTidalv2']
pending_approx_code = {}
pending_default_code = -19
for name in pending_FD_approx:
if hasattr(lalsim, name):
pending_approx_code[name] = getattr(lalsim, name)
else:
pending_approx_code[name] = pending_default_code
pending_default_code += -1 # same convention as above
def check_FD_pending(code):
return code in pending_approx_code.values() # just test if it is in the list of pending, NOT that useful since everything appended here.
try:
my_junk = lalsim.SimInspiralChooseFDModes
is_ChooseFDModes_present =True
except:
is_ChooseFDModes_present =False
try:
lalIMRPhenomTP = lalsim.IMRPhenomTP
lalIMRPhenomTPHM = lalsim.IMRPhenomTPHM
except:
lalIMRPhenomTP = -12
lalIMRPhenomTPHM = -13
MsunInSec = lal.MSUN_SI*lal.G_SI/lal.C_SI**3
def modes_to_k(modes):
return [int(x[0]*(x[0]-1)/2 + x[1]-2) for x in modes]
# https://www.lsc-group.phys.uwm.edu/daswg/projects/lal/nightly/docs/html/_l_a_l_sim_inspiral_8c_source.html#l02910
def lsu_StringFromPNOrder(order):
if (order == lsu_PNORDER_NEWTONIAN):
return "newtonian"
elif (order == lsu_PNORDER_HALF):
return "oneHalfPN"
elif (order == lsu_PNORDER_ONE):
return "onePN"
elif (order == lsu_PNORDER_ONE_POINT_FIVE):
return "onePointFivePN"
elif (order == lsu_PNORDER_TWO):
return "twoPN"
elif (order == lsu_PNORDER_TWO_POINT_FIVE):
return "twoPointFivePN"
elif (order == lsu_PNORDER_THREE):
return "threePN"
elif (order == lsu_PNORDER_THREE_POINT_FIVE):
return "threePointFivePN"
elif (order == -1): # highest available
return "threePointFivePN"
else:
raise ("Unknown PN order ", order)
#
# Class to hold arguments of ChooseWaveform functions
#
valid_params = ['m1', 'm2', 's1x', 's1y', 's1z', 's2x', 's2y', 's2z', 'chi1_perp', 'chi2_perp', 'chi1_perp_bar', 'chi2_perp_bar','chi1_perp_u', 'chi2_perp_u', 's1z_bar', 's2z_bar', 'lambda1', 'lambda2', 'theta','phi', 'phiref', 'psi', 'incl', 'tref', 'dist', 'mc', 'mc_ecc', 'eta', 'delta_mc', 'chi1', 'chi2', 'thetaJN', 'phiJL', 'theta1', 'theta2', 'cos_theta1', 'cos_theta2', 'theta1_Jfix', 'theta2_Jfix', 'psiJ', 'beta', 'cos_beta', 'sin_phiJL', 'cos_phiJL', 'phi12', 'phi1', 'phi2', 'LambdaTilde', 'DeltaLambdaTilde', 'lambda_plus', 'lambda_minus', 'q', 'mtot','xi','chiz_plus', 'chiz_minus', 'chieff_aligned','fmin','fref', "SOverM2_perp", "SOverM2_L", "DeltaOverM2_perp", "DeltaOverM2_L", "shu","ampO", "phaseO",'eccentricity','eccentricity_squared', 'chi_pavg','mu1','mu2','eos_table_index','meanPerAno']
# so far, used for puffball, to prevent insanity (infinite growth) and/or death to downselect
# - note we also provide for extrinsic: RA (phi), phiref, psi, just in case we need it in the future
periodic_params = {'phi1':2*np.pi, 'phi2':2*np.pi, 'phiref':2*np.pi, 'psi':np.pi, 'meanPerAno':2*np.pi, 'phi':2*np.pi, 'phiJL':2*np.pi, 'psiJ':2*np.pi}
tex_dictionary = {
"mtot": r'$M$',
"mc": r'${\cal M}_c$',
"mc_ecc": r'${\cal M}_{\rm c,ecc}$',
"m1": '$m_1$',
"m2": '$m_2$',
"m1_source": r'$m_{1,source}$',
"m2_source": r'$m_{2,source}$',
"mtotal_source": r'$M_{source}$',
"q": "$q$",
"delta" : r"$\delta$",
"delta_mc" : r"$\delta$",
"beta" : r"$\beta$",
"cos_beta" : r"$\cos(\\beta)$",
"sin_beta" : r"$\sin(\\beta)$",
"sin_phiJL" : r"$\sin(\\phi_{JL})$",
"cos_phiJL" : r"$\cos(\\phi_{JL})$",
"phi12" : r"$\phi_{12}$",
"DeltaOverM2_perp" : r"$\Delta_\perp$",
"DeltaOverM2_L" : r"$\Delta_{||}$",
"SOverM2_perp" : r"$S_\perp$",
"SOverM2_L" : r"$S_{||}$",
"eta": r"$\eta$",
"chi_eff": r"$\chi_{eff}$",
"xi": r"$\chi_{eff}$",
"chi_p": r"$\chi_{p}$",
"chiMinus":r"$\chi_{eff,-}$",
"chiz_plus":r"$\chi_{z,+}$",
"chiz_minus":r"$\chi_{z,-}$",
"chi_pavg":r"$\langle\chi_{p}\rangle$",
"lambda_plus":r"$\lambda_{+}$",
"lambda_minus":r"$\lambda_{-}$",
"s1z": r"$\chi_{1,z}$",
"s2z": r"$\chi_{2,z}$",
"s1x": r"$\chi_{1,x}$",
"s2x": r"$\chi_{2,x}$",
"s1y": r"$\chi_{1,y}$",
"s2y": r"$\chi_{2,y}$",
"eccentricity":"$e$",
"meanPerAno":"$l_{gw}$",
# tex labels for inherited LI names
"a1z": r'$\chi_{1,z}$',
"a2z": r'$\chi_{2,z}$',
"mtotal": r'$M_{tot}$',
"theta1":r"$\theta_1$",
"theta2":r"$\theta_2$",
"phi1":r"$\phi_1$",
"phi2":r"$\phi_2$",
"cos_theta1":r"$\cos \\theta_1$",
"cos_theta2":r"$\cos \\theta_2$",
"chi1_perp": r"$\chi_{1,\perp}$",
"chi2_perp": r"$\chi_{2,\perp}$",
'chi1':r'$|\chi_1|$',
'chi2':r'$|\chi_2|$',
'lambda1':r'$\lambda_1$',
'lambda2':r'$\lambda_2$',
'LambdaTilde': r'$\tilde{\Lambda}$',
'lambdat': r'$\tilde{\Lambda}$',
'DeltaLambdaTilde': r'$\Delta\tilde{\Lambda}$',
'dlambdat': r'$\Delta\tilde{\Lambda}$',
'distance':r'$d_L$',
'mu1':r'$\mu_1$',
'mu2':r'$\mu_2$',
}
# Exponent used to define the u coordinate scaling
p_R = 0.25
class ChooseWaveformParams:
"""
Class containing all the arguments needed for SimInspiralChooseTD/FDWaveform
plus parameters theta, phi, psi, radec to go from h+, hx to h(t)
if radec==True: (theta,phi) = (DEC,RA) and strain will be computed using
XLALSimDetectorStrainREAL8TimeSeries
if radec==False: then strain will be computed using a simple routine
that assumes (theta,phi) are spherical coord.
in a frame centered at the detector
"""
def __init__(self, phiref=0., deltaT=1./4096., m1=10.*lsu_MSUN,
m2=10.*lsu_MSUN, s1x=0., s1y=0., s1z=0.,
s2x=0., s2y=0., s2z=0., fmin=40., fref=0., dist=1.e6*lsu_PC,
incl=0., lambda1=0., lambda2=0., waveFlags=None, nonGRparams=None,
ampO=0, phaseO=7, approx=lalsim.TaylorT4,
theta=0., phi=0., psi=0., tref=0., radec=False, detector="H1",
deltaF=None, fmax=0., # for use w/ FD approximants
taper=lsu_TAPER_NONE, # for use w/TD approximants
eccentricity=0., # make eccentricity a parameter
meanPerAno=0. # make meanPerAno a parameter
):
self.phiref = phiref
self.deltaT = deltaT
self.m1 = m1
self.m2 = m2
self.s1x = s1x
self.s1y = s1y
self.s1z = s1z
self.s2x = s2x
self.s2y = s2y
self.s2z = s2z
self.fmin = fmin
self.fref = fref
self.dist = dist
self.incl = incl
self.lambda1 = lambda1
self.lambda2 = lambda2
self.waveFlags = waveFlags
self.nonGRparams = nonGRparams
self.ampO = ampO
self.phaseO = phaseO
self.approx = approx
self.theta = theta # DEC. DEC =0 on the equator; the south pole has DEC = - pi/2
self.phi = phi # RA.
self.psi = psi
self.meanPerAno = 0.0 # port
self.longAscNodes = self.psi # port to master
self.eccentricity=eccentricity
self.meanPerAno=meanPerAno
self.tref = tref
self.radec = radec
self.detector = "H1"
self.deltaF=deltaF
self.fmax=fmax
self.taper = taper
self.snr = None # Only used for compatibility with AMR grid rapid_pe, should not usually be setting or using this
self.eos_table_index = None # only used for compatibility with tabular EOS formalisms, note user MUST always provide lambda1, lambda2 correctly for waveform generators!
# force this waveform's PN order to be 3 to avoid crashes
if self.approx == lalsim.EccentricTD:
self.phaseO = 3
# From Pankow/master
# See also: https://git.ligo.org/lscsoft/bilby_pipe/-/merge_requests/371/diffs
try:
_LAL_DICT_PARAMS = {"Lambda1": "lambda1", "Lambda2": "lambda2", "ampO": "ampO", "phaseO": "phaseO"}
_LAL_DICT_PTYPE = {"Lambda1": lal.DictInsertREAL8Value, "Lambda2": lal.DictInsertREAL8Value, "ampO": lal.DictInsertINT4Value, "phaseO": lal.DictInsertINT4Value}
except:
print(" lalsimutils: Warning: Running with non-master version of lal ! ")
def to_lal_dict(self):
extra_params = lal.CreateDict()
for k, p in ChooseWaveformParams._LAL_DICT_PARAMS.items():
typfunc = ChooseWaveformParams._LAL_DICT_PTYPE[k]
typfunc(extra_params, k, getattr(self, p))
# Properly add tidal parammeters
lalsim.SimInspiralWaveformParamsInsertTidalLambda1(extra_params, self.lambda1)
lalsim.SimInspiralWaveformParamsInsertTidalLambda2(extra_params, self.lambda2)
return extra_params
def to_lal_dict_extended(self,extra_args_dict=None):
"""
to_lal_dict_extended:
Extended implementation, to address massive proliferation of options to control waveform version
See https://git.ligo.org/lscsoft/bilby_pipe/-/merge_requests/371/diffs
"""
extra_params = self.to_lal_dict()
if extra_args_dict:
extra_keys = list(set(list(extra_args_dict)) - set(ChooseWaveformParams._LAL_DICT_PARAMS)) # list of new keys I need to find in lalsmulation
for key in extra_keys:
func = getattr(
lalsim, "SimInspiralWaveformParamsInsert" + key, 0
)
if func != 0:
func(extra_params, extra_args_dict[key])
return extra_params
def manual_copy(self):
P=self.copy()
waveFlags = self.waveFlags
if waveFlags:
waveFlagsNew = lalsim.SimInspiralCreateWaveformFlags()
lalsim.SimInspiralSetSpinOrder(waveFlagsNew, lalsim.SimInspiralGetSpinOrder(waveFlags))
lalsim.SimInspiralSetTidalOrder(waveFlagsNew, lalsim.SimInspiralGetTidalOrder(waveFlags))
P.waveFlags = waveFlagsNew
return P
def swap_components(self):
s1x,s1y,s1z = self.s1x,self.s1y,self.s1z
s2x,s2y,s2z = self.s2x,self.s2y,self.s2z
m1 =self.m1
m2 = self.m2
self.s1x,self.s1y,self.s1z = s2x,s2y,s2z
self.s2x,self.s2y,self.s2z = s1x,s1y,s1z
self.m1 = m2
self.m2 = m1
lam1,lam2 =self.lambda1,self.lambda2
self.lambda2=lam1
self.lambda1=lam2
self.phiref = self.phiref+np.pi
def assign_param(self,p,val):
"""
assign_param
Syntatic sugar to assign parameters to values.
Provides ability to specify a binary by its values of
- mchirp, eta
- system frame parameters
VERY HELPFUL if you want to change just one parameter at a time (e.g., for Fisher )
"""
if p == 'mtot':
# change implemented at fixed chi1, chi2, eta
q = self.m2/self.m1
self.m1,self.m2 = np.array( [1./(1+q), q/(1.+q)])*val
return self
if p == 'q':
# change implemented at fixed Mtot (NOT mc)
mtot = self.m2+self.m1
self.m1,self.m2 = np.array( [1./(1+val), val/(1.+val)])*mtot
return self
if p == 'log_mc':
# change implemented at fixed chi1, chi2, eta
eta = symRatio(self.m1,self.m2)
self.m1,self.m2 = m1m2(10**val,eta)
return self
if p == 'mc' or p=='mc_ecc':
# change implemented at fixed chi1, chi2, eta (and ecc)
eta = symRatio(self.m1,self.m2)
self.m1,self.m2 = m1m2(val,eta)
return self
if p == 'eta':
# change implemented at fixed chi1, chi2, mc
mc = mchirp(self.m1,self.m2)
self.m1,self.m2 = m1m2(mc,val)
return self
if p == 'delta':
# change implemented at fixed chi1, chi2, M
M = self.m1 + self.m2
self.m1 = M*(1+val)/2
self.m2 = M*(1-val)/2
return self
if p == 'delta_mc':
# change implemented at fixed chi1, chi2, *mc*
eta_here = 0.25*(1 - val*val)
self.assign_param('eta', eta_here)
return self
if p == 'chiz_plus':
# Designed to give the benefits of sampling in chi_eff, without introducing a transformation/prior that depends on mass
# Fixes chiz_minus by construction
czm = (self.s1z-self.s2z)/2.
czp = val
self.s1z = (czp+czm)
self.s2z = (czp-czm)
return self
if p == 'chiz_minus':
# Designed to give the benefits of sampling in chi_eff, without introducing a transformation/prior that depends on mass
# Fixes chiz_plus by construction
czm = val
czp = (self.s1z+self.s2z)/2.
self.s1z = (czp+czm)
self.s2z = (czp-czm)
return self
if p == 's1z_bar':
self.s1z = val
return self
if p == 's2z_bar':
self.s2z = val
return self
if p == 'chi1_perp_bar':
# chi1_perp = np.sqrt(self.s1x**2+self.s2y**2)
phi1 = np.arctan2(self.s1y, self.s1x)
chi1_perp_new = val*np.sqrt(1-self.s1z**2) # R=Rbar*(1-z^2)^0.5
self.s1x = chi1_perp_new*np.cos(phi1)
self.s1y = chi1_perp_new*np.sin(phi1)
return self
if p == 'chi1_perp_u':
# chi1_perp = np.sqrt(self.s1x**2+self.s2y**2)
Rb = np.power(val, 1./p_R)
phi1 = np.arctan2(self.s1y, self.s1x)
chi1_perp_new = Rb*np.sqrt(1-self.s1z**2) # R=Rbar*(1-z^2)^0.5
self.s1x = chi1_perp_new*np.cos(phi1)
self.s1y = chi1_perp_new*np.sin(phi1)
return self
if p == 'chi2_perp_bar':
# chi1_perp = np.sqrt(self.s1x**2+self.s2y**2)
phi2 = np.arctan2(self.s2y, self.s2x)
chi2_perp_new = val*np.sqrt(1-self.s2z**2) # R=Rbar*(1-z^2)^0.5
self.s2x = chi2_perp_new*np.cos(phi2)
self.s2y = chi2_perp_new*np.sin(phi2)
return self
if p == 'chi2_perp_u':
# chi1_perp = np.sqrt(self.s1x**2+self.s2y**2)
phi2 = np.arctan2(self.s2y, self.s2x)
Rb = np.power(val, 1./p_R)
chi2_perp_new = Rb*np.sqrt(1-self.s2z**2) # R=Rbar*(1-z^2)^0.5
self.s2x = chi2_perp_new*np.cos(phi2)
self.s2y = chi2_perp_new*np.sin(phi2)
return self
if p == 'lambda_plus':
# Designed to give the benefits of sampling in chi_eff, without introducing a transformation/prior that depends on mass
# Fixes chiz_minus by construction
czm = (self.lambda1-self.lambda2)/2.
czp = val
self.lambda1 = (czp+czm)
self.lambda2 = (czp-czm)
return self
if p == 'lambda_minus':
# Designed to give the benefits of sampling in chi_eff, without introducing a transformation/prior that depends on mass
# Fixes chiz_plus by construction
czm = val
czp = (self.lambda1+self.lambda2)/2.
self.lambda1 = (czp+czm)
self.lambda2 = (czp-czm)
return self
if p == 'chi1':
chi1Vec = np.array([self.s1x,self.s1y,self.s1z])
chi1VecMag = np.sqrt(np.dot(chi1Vec,chi1Vec))
if chi1VecMag < 1e-5:
Lref = self.OrbitalAngularMomentumAtReferenceOverM2()
Lhat = Lref/np.sqrt(np.dot(Lref,Lref))
self.s1x,self.s1y,self.s1z = val*Lhat
else:
self.s1x,self.s1y,self.s1z = val* chi1Vec/chi1VecMag
return self
if p == 'chi2':
chi2Vec = np.array([self.s2x,self.s2y,self.s2z])
chi2VecMag = np.sqrt(np.dot(chi2Vec,chi2Vec))
if chi2VecMag < 1e-5:
Lref = self.OrbitalAngularMomentumAtReferenceOverM2()
Lhat = Lref/np.sqrt(np.dot(Lref,Lref))
self.s2x,self.s2y,self.s2z = val*Lhat
else:
self.s2x,self.s2y,self.s2z = val* chi2Vec/chi2VecMag
return self
if p == 'thetaJN':
if self.fref == 0:
print(" Changing geometry requires a reference frequency ")
sys.exit(1)
thetaJN,phiJL,theta1,theta2,phi12,chi1,chi2,psiJ = self.extract_system_frame()
self.init_via_system_frame(thetaJN=val,phiJL=phiJL,theta1=theta1,theta2=theta2,phi12=phi12,chi1=chi1,chi2=chi2,psiJ=psiJ)
return self
if p == 'phiJL':
if self.fref == 0:
print(" Changing geometry requires a reference frequency ")
sys.exit(1)
thetaJN,phiJL,theta1,theta2,phi12,chi1,chi2,psiJ = self.extract_system_frame()
self.init_via_system_frame(thetaJN=thetaJN,phiJL=val,theta1=theta1,theta2=theta2,phi12=phi12,chi1=chi1,chi2=chi2,psiJ=psiJ)
return self
# if p == 'chi1':
# chi1_vec_now = np.array([self.s1x,self.s1y,self.s1z])
# chi1_now = np.sqrt(np.dot(chi1_vec_now,chi1_vec_now))
# if chi1_now < 1e-5:
# self.s1z = val # assume aligned
# return self
# self.s1x,self.s1y,self.s1z = chi1_vec_now * val/chi1_now
# return self
if p == 'theta1_Jfix':
if self.fref == 0:
print(" Changing geometry requires a reference frequency ")
sys.exit(1)
thetaJN,phiJL,theta1,theta2,phi12,chi1,chi2,psiJ = self.extract_system_frame()
self.init_via_system_frame(thetaJN=thetaJN,phiJL=phiJL,theta1=val,theta2=theta2,phi12=phi12,chi1=chi1,chi2=chi2,psiJ=psiJ)
return self
if p == 'theta1':
# Do it MANUALLY, assuming the L frame!
# Implementation avoids calling 'system_frame' transformations needlessly
chiperp_vec_now = np.array([self.s1x,self.s1y])
chiperp_now = np.sqrt(np.dot(chiperp_vec_now,chiperp_vec_now))
chi_now = np.sqrt(self.s1z**2 + chiperp_now**2)
if chiperp_now/chi_now < 1e-9: # aligned case - what do we do?
self.s1y=0
self.s1x = chi_now * np.sin(val)
self.s1z = chi_now * np.cos(val)
return self
self.s1x = chi_now*np.sin(val) * self.s1x/chiperp_now
self.s1y = chi_now*np.sin(val) * self.s1y/chiperp_now
self.s1z = chi_now*np.cos(val)
return self
if p == 'cos_theta1':
self.assign_param('theta1',np.arccos(val))
return self
if p == 'phi1':
# if self.fref == 0:
# print(" Changing geometry requires a reference frequency ")
# sys.exit(1)
# Do it MANUALLY, assuming the L frame!
chiperp_vec_now = np.array([self.s1x,self.s1y])
chiperp_now = np.sqrt(np.dot(chiperp_vec_now,chiperp_vec_now))
self.s1x = chiperp_now*np.cos(val)
self.s1y = chiperp_now*np.sin(val)
return self
if p == 'theta2_Jfix':
if self.fref == 0:
print(" Changing geometry requires a reference frequency ")
sys.exit(1)
thetaJN,phiJL,theta1,theta2,phi12,chi1,chi2,psiJ = self.extract_system_frame()
self.init_via_system_frame(thetaJN=thetaJN,phiJL=phiJL,theta1=theta1,theta2=val,phi12=phi12,chi1=chi1,chi2=chi2,psiJ=psiJ)
return self
if p == 'theta2':
# Do it MANUALLY, assuming the L frame!
# Implementation avoids calling 'system_frame' transformations needlessly
chiperp_vec_now = np.array([self.s2x,self.s2y])
chiperp_now = np.sqrt(np.dot(chiperp_vec_now,chiperp_vec_now))
chi_now = np.sqrt(self.s2z**2 + chiperp_now**2)
if chiperp_now/chi_now < 1e-9: # aligned case
self.s2y=0
self.s2x = chi_now * np.sin(val)
self.s2z = chi_now * np.cos(val)
return self
self.s2x = chi_now*np.sin(val) * self.s2x/chiperp_now
self.s2y = chi_now*np.sin(val) * self.s2y/chiperp_now
self.s2z = chi_now*np.cos(val)
return self
if p == 'cos_theta2':
self.assign_param('theta2',np.arccos(val))
return self
if p == 'phi2':
# if self.fref == 0:
# print(" Changing geometry requires a reference frequency ")
# sys.exit(1)
# Do it MANUALLY, assuming the L frame!
chiperp_vec_now = np.array([self.s2x,self.s2y])
chiperp_now = np.sqrt(np.dot(chiperp_vec_now,chiperp_vec_now))
self.s2x = chiperp_now*np.cos(val)
self.s2y = chiperp_now*np.sin(val)
return self
if p == 'psiJ':
if self.fref == 0:
print(" Changing geometry requires a reference frequency ")
sys.exit(1)
thetaJN,phiJL,theta1,theta2,phi12,chi1,chi2,psiJ = self.extract_system_frame()
self.init_via_system_frame(thetaJN=thetaJN,phiJL=phiJL,theta1=theta1,theta2=theta2,phi12=phi12,chi1=chi1,chi2=chi2,psiJ=val)
return self
if p == 'beta':
# Documentation: *changing* beta is designed for a single-spin binary at present
# Based on expressions in this paper
# http://adsabs.harvard.edu/abs/2012PhRvD..86f4020B
if self.fref == 0:
print(" Changing geometry requires a reference frequency ")
sys.exit(1)
thetaJN,phiJL,theta1,theta2,phi12,chi1,chi2,psiJ = self.extract_system_frame()
if chi2 > 1e-5:
print(" Changing beta only supported for single spin ")
sys.exit(2)
if np.abs(val)<1e-4:
theta1=0
self.init_via_system_frame(thetaJN=val,phiJL=phiJL,theta1=theta1,theta2=theta2,phi12=phi12,chi1=chi1,chi2=chi2,psiJ=psiJ)
return self
#kappa = np.cos(theta1) # target we want to determine
SoverL = chi1 * self.VelocityAtFrequency(self.fref) * self.m1/self.m2 # S/L = m1 chi v/m2
# sanity check this value of beta is *possible*
if val and np.cos(val)**2 < 1-SoverL**2:
print(" This value of beta cannot be attained, because SoverL= ", SoverL, " so beta max = ", np.arccos(np.sqrt(1-SoverL**2)))
sys.exit(3)
x=np.cos(val)
kappa = (- np.sin(val)**2 + x * np.sqrt( SoverL**2 - np.sin(val)**2))/SoverL
# Note that if gamma < 1, there are two roots for each value of beta
# def solveme(x):
# return (1+ x *SoverL)/np.sqrt(1+2*x*SoverL+SoverL**2) -val # using a root find instead of algebraic for readability
# kappa = optimize.newton(solveme,0.01)
# PROBLEM: Only implemented for radiation gauge, disable if in non-radiation gauge
if spin_convention == "radiation":
theta1 = np.arccos(kappa)
self.init_via_system_frame(thetaJN=val,phiJL=phiJL,theta1=theta1,theta2=theta2,phi12=phi12,chi1=chi1,chi2=chi2,psiJ=psiJ)
else:
print(" beta assignment not implemented in non-radiation gauge ")
sys.exit(4)
return self
# tidal parameters
if p == 'LambdaTilde':
Lt, dLt = tidal_lambda_tilde(self.m1, self.m2, self.lambda1, self.lambda2)
Lt = val
self.lambda1, self.lambda2 = tidal_lambda_from_tilde(self.m1, self.m2, Lt, dLt)
return self
if p == 'DeltaLambdaTilde':
Lt, dLt = tidal_lambda_tilde(self.m1, self.m2, self.lambda1, self.lambda2)
dLt = val
self.lambda1, self.lambda2 = tidal_lambda_from_tilde(self.m1, self.m2, Lt, dLt)
return self
if p == 'chieff_aligned':
chieff = self.extract_param('xi')
chieff_new = val
mtot = self.extract_param('mtot')
m1 = self.extract_param('m1')
m2 = self.extract_param('m2')
if np.abs(m1/m2 -1) > 1e-5:
# only works for aligned system. Note aligned convention changes from iteration to iteration -- will eventually be aligned with z, but..
# This assumes chiminus is a good and useful parameter.
# This parameterization was designed to be more stable for extreme mass ratio systems, where the usual chi- becomes highly degenerate
# Note that by construction, in the limit of large mass ratio, chi1 -> xi and chi2 -> - chiminus, so the parameterization is not degenerate
# Note we have chosen an exchange-antisymmetric combination (!), changing from prior use
# Note that this transformation can as a side effect change spins to be > 1
# {(m1 c1 + m2 c2 ) == (m1 + m2) \[Xi], (m2 c1 - m1 c2)/(m1 + m2) == \[Chi]Diff}
# {c1, c2} /. Solve[%, {c1, c2}][[1]] // Simplify
# Collect[%[[2]], {\[Xi], \[Chi]Diff}]
# % - \[Xi] // Simplify // FullSimplify
chi1 = self.s1z
chi2 = self.s2z
chiminus = (m2*chi1 - m1*chi2)/(m1 + m2) # change to be consistent with the 'chiMinus' use elsewhere, avoid extremes
# Solve equations for M xi, M chiminus.
chi1_new = (m1+m2)/(m1**2+m2**2) * (m1*chieff_new + m2*chiminus)
chi2_new = (m1+m2)/(m1**2+m2**2) * (m2*chieff_new + m1*chiminus)
# chi1_new = chieff_new + (m1 - m2)*m2*(chieff_new + chiminus)/(m1**2 + m2**2)
# chi2_new = chieff_new - (m1 - m2)*m1*(chieff_new + chiminus)/(m1**2 + m2**2)
self.s1z = chi1_new
self.s2z = chi2_new
#self.assign_param('chi1', chi1_new)
#self.assign_param('chi2', chi2_new)
else:
# for equal mass, require them to have the same value
self.assign_param('chi1', chieff_new)
self.assign_param('chi2', chieff_new)
return self
# Soichiro's coordinates : mu1, mu2, q_mu, chi2z_mu
if p == 'mu1':
# Sometimes we use fits where we are NOT in solar mass units, so be careful!
fac_scale = 1
if self.m1 > 1e10:
fac_scale = lal.MSUN_SI
mc = mchirp(self.m1/fac_scale,self.m2/fac_scale)
mu1,mu2,mu3 = tools.Mcqchi1chi2Tomu1mu2mu3(mc, self.m2/self.m1, self.s1z, self.s2z)
mcNew,q,chi1z,chi2z = tools.mu1mu2qchi2ToMcqchi1chi2(val, mu2,self.m2/self.m1, self.s2z) # q,chi2z is fixed
self.s1z = chi1z
# now change mc at fixed q
self.assign_param('mc',mcNew*fac_scale)
return self
if p == 'mu2':
fac_scale=1
if self.m1 > 1e10:
fac_scale = lal.MSUN_SI
mc = mchirp(self.m1/fac_scale,self.m2/fac_scale)
mu1,mu2,mu3 = tools.Mcqchi1chi2Tomu1mu2mu3(mc, self.m2/self.m1, self.s1z, self.s2z)
mcNew,q,chi1z,chi2z = tools.mu1mu2qchi2ToMcqchi1chi2(mu1, val,self.m2/self.m1, self.s2z) # q,chi2z is fixed
self.s1z = chi1z
# now change mc at fixed q
self.assign_param('mc',mcNew*fac_scale)
return self
if p == 'chi1z_mu':
raise("Not implemented yet")
if p == 'eccentricity_squared':
self.eccentricity = np.sqrt(val) # value is eccentricity squared
return self
# assign an attribute
if hasattr(self,p):
setattr(self,p,val)
return self
print(" No attribute ", p, " in ", dir(self))
print(" Is in valid_params? ", p in valid_params)
sys.exit(1)
def extract_param(self,p):
"""
assign_param
Syntatic sugar to extract parameters to values.
Necessary to make full use of assign_param on
- mchirp, eta
- system frame parameters
VERY HELPFUL if you want to change just one parameter at a time (e.g., for Fisher )
"""
if p == 'mtot':
return (self.m2+self.m1)
if p == 'q':
return self.m2/self.m1
if p == 'delta' or p=='delta_mc': # Same access routine
return (self.m1-self.m2)/(self.m1+self.m2)
if p == 'mc':
return mchirp(self.m1,self.m2)
if p == 'mc_ecc':
# defined Favata et al 2108.05861 see Eq. 1.1
# This is defined at periapstron; check to make sure your e's are defined corretly!
return mchirp(self.m1,self.m2)/np.power( 1 - 157*self.eccentricity**2/24., 3./5.)
if p == 'log_mc':
return np.log10(mchirp(self.m1,self.m2))
if p == 'eta':
return symRatio(self.m1,self.m2)
if p == 'chi1':
chi1Vec = np.array([self.s1x,self.s1y,self.s1z])
return np.sqrt(np.dot(chi1Vec,chi1Vec))
if p == 'chi2':
chi2Vec = np.array([self.s2x,self.s2y,self.s2z])
return np.sqrt(np.dot(chi2Vec,chi2Vec))
if p == 'chi1_perp':
chi1Vec = np.array([self.s1x,self.s1y,self.s1z])
if spin_convention == "L":
Lhat = np.array([0,0,1]) # CRITICAL to work with modern PE output. Argh. Must swap convention elsewhere
else:
Lhat = np.array( [np.sin(self.incl),0,np.cos(self.incl)]) # does NOT correct for psi polar anogle! Uses OLD convention for spins!
return np.sqrt( np.dot(chi1Vec,chi1Vec) - np.dot(Lhat, chi1Vec)**2 ) # L frame !
if p == 'chi1_perp_bar':
# not supporting old L convention
chi1_perp = np.sqrt( self.s1x**2 + self.s1y**2)
return chi1_perp/np.sqrt(1-self.s1z**2) # R = Rbar*sqrt(1-z**2)
if p == 'chi1_perp_u':
# not supporting old L convention
chi1_perp = np.sqrt( self.s1x**2 + self.s1y**2)
return np.power(chi1_perp/np.sqrt(1-self.s1z**2), p_R)
if p == 'chi2_perp':
chi2Vec = np.array([self.s2x,self.s2y,self.s2z])
if spin_convention == "L":
Lhat = np.array([0,0,1]) # CRITICAL to work with modern PE output. Argh. Must swap convention elsewhere
else:
Lhat = np.array( [np.sin(self.incl),0,np.cos(self.incl)]) # does NOT correct for psi polar anogle! Uses OLD convention for spins!
return np.sqrt( np.dot(chi2Vec,chi2Vec) - np.dot(Lhat, chi2Vec)**2 ) # L frame !
if p == 'chi2_perp_bar':
# not supporting old non-L convention
chi2_perp = np.sqrt( self.s2x**2 + self.s2y**2)
return chi2_perp/np.sqrt(1-self.s2z**2)
if p == 'chi2_perp_u':
# not supporting old non-L convention
chi2_perp = np.sqrt( self.s2x**2 + self.s2y**2)
return np.power(chi2_perp/np.sqrt(1-self.s2z**2), p_R)
if p == 's1z_bar':
return self.s1z
if p == 's2z_bar':
return self.s2z
if p == 'xi' or p == 'chieff_aligned':
chi1Vec = np.array([self.s1x,self.s1y,self.s1z])
chi2Vec = np.array([self.s2x,self.s2y,self.s2z])
Lhat = None
if spin_convention == "L":
Lhat = np.array([0,0,1]) # CRITICAL to work with modern PE output. Argh. Must swap convention elsewhere
else:
Lhat = np.array( [np.sin(self.incl),0,np.cos(self.incl)]) # does NOT correct for psi polar anogle! Uses OLD convention for spins!
xi = np.dot(Lhat, (self.m1*chi1Vec + self.m2* chi2Vec))/(self.m1+self.m2) # see also 'Xi', defined below
return xi
if p == 'chiMinus':
chi1Vec = np.array([self.s1x,self.s1y,self.s1z])
chi2Vec = np.array([self.s2x,self.s2y,self.s2z])
Lhat = None
if spin_convention == "L":
Lhat = np.array([0,0,1]) # CRITICAL to work with modern PE output. Argh. Must swap convention elsewhere
else:
Lhat = np.array( [np.sin(self.incl),0,np.cos(self.incl)]) # does NOT correct for psi polar anogle! Uses OLD convention for spins!
xi = np.dot(Lhat, (self.m1*chi1Vec - self.m2* chi2Vec))/(self.m1+self.m2) # see also 'Xi', defined below
return xi
if p == 'chiz_plus':
# Designed to give the benefits of sampling in chi_eff, without introducing a transformation/prior that depends on mass
return (self.s1z+self.s2z)/2.
if p == 'chiz_minus':
# Designed to give the benefits of sampling in chi_eff, without introducing a transformation/prior that depends on mass
return (self.s1z-self.s2z)/2.
if p == 'shu':
# https://arxiv.org/pdf/1801.08162.pdf
# Eq. 27
# Shu/M^2 = xi - 1/2 L.(S1/q + q S2)/M^2 = xi - 1/2 L.(m1 m2 chi1 + m1 m2 chi2) = xi - 1/2 eta(chi1+chi2).L
chi1Vec = np.array([self.s1x,self.s1y,self.s1z])
chi2Vec = np.array([self.s2x,self.s2y,self.s2z])
Lhat = None
if spin_convention == "L":
Lhat = np.array([0,0,1]) # CRITICAL to work with modern PE output. Argh. Must swap convention elsewhere
else:
Lhat = np.array( [np.sin(self.incl),0,np.cos(self.incl)]) # does NOT correct for psi polar anogle! Uses OLD convention for spins!
xi = np.dot(Lhat, (self.m1*chi1Vec + self.m2* chi2Vec))/(self.m1+self.m2) # see also 'Xi', defined below
shu = xi - 0.5*np.dot(Lhat, chi1Vec+chi2Vec) * (self.m1*self.m2)/ (self.m1+self.m2)**2
return shu
# Soichiro's coordinates : mu1, mu2, q_mu, chi2z_mu
if p == 'mu1':
fac_scale = 1
if self.m1 > 1e10:
fac_scale = lal.MSUN_SI