-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsrgo.py
2383 lines (2149 loc) · 108 KB
/
srgo.py
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
""" Simulating the detection of millihertz (mHz) gravitational waves (GWs)
from astrophysical sources by a Storage Ring Gravitational-wave Observatory (SRGO).
Authors: Suvrat Rao, Hamburg Observatory, University of Hamburg
Julia Baumgarten, Physics department, Jacobs University Bremen """
import numpy as np
from fractions import Fraction
from matplotlib import ticker as mpl_ticker
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
# from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import seaborn as sns
import cv2
from scipy.spatial.transform import Rotation as R
from scipy.signal import spectrogram
# from scipy.signal import wiener
# from scipy.ndimage import gaussian_filter
from scipy.integrate import simps
from scipy.interpolate import interp1d
from scipy.interpolate import interp2d
from astropy.cosmology import FlatLambdaCDM
import astropy.units as u
import pymc3 as pm
import arviz as az
import theano.tensor as tt
# from theano import config
# import os
pi = np.pi
exp = np.e
sqrt = np.sqrt
sin = np.sin
cos = np.cos
array = np.array
arange = np.arange
ones = np.ones
fft = np.fft.fft
fftfreq = np.fft.fftfreq
concatenate = np.concatenate
prod = np.prod
delete = np.delete
floatX = 'float32' # config.floatX
# os.environ["MKL_NUM_THREADS"] = "5"
# Constants in SI units:
G = 6.67430 * 10 ** (-11) # gravitational constant
c = 299792458.0 # speed of light
pc = 3.085677581 * 10 ** 16 # parsec
au = 1.495978707 * 10 ** 11 # astronomical unit
msol = 1.98847 * 10 ** 30 # solar mass
day = 86164.0905 # sidereal Earth day
radian = pi / 180.0 # degree to radian
we = 7.2921150 * 10 ** (-5) # angular speed of Earth's rotation in radian/s.
H0 = 73.0*(1000/(10**6 * pc)) # Hubble constant
W0 = 0.6911 # LCDM universe dark energy density parameter
cosmo = FlatLambdaCDM(H0=73 * u.km / u.s / u.Mpc,
Tcmb0=2.725 * u.K, Om0=0.3089)
# ---------------------------------------------------------------------------------------------------------
# "DASHBOARD" for user input parameters:
"""Cannot use input() function since it gives EOFError when MCMC scans the code for global variables."""
# GW SOURCE PARAMETERS:
M1 = 1000000 # mass of object #1 in solar masses
M2 = 1000000 # mass of object #2 in solar masses
r = 1.0 # initial separation between bodies in au
# GW SOURCE-OBSERVER PARAMETERS:
inc = 0.0 # inclination angle of observer w.r.t binary system in degrees
Z = 0.1 # redshift of the binary system
phase = 0.0 # GW signal initial phase in degrees
# local sidereal time of SRGO in hh:mm:ss at the start of the observation run
LST = (00.0, 00.0, 00.0)
# if theta_lat == dec, sometimes there is a numerical error in calculating the angle from the rotation matrix, so we define theta_lat += 0.001
theta_lat = 51.0 # SRGO latitude in degrees
RA = (00.0, 00.0, 00.0) # GW source right ascension in hh:mm:ss
dec = 0.0 # GW source declination in degrees
# GW polarization angle (in degrees) as measured in equatorial celestial coordinates
psi_eq = 0.0
# STORAGE RING PARAMETERS:
v0 = 0.999999991*c # SRGO ion bunch speed (must be ultrarelativistic)
L = 100.0 # 26659.0 # SRGO circumference in meters
n_p = 1 # 2*2808 # SRGO number of bunches
# MCMC PARAMETERS AND FLAGS:
# do parameter estimation with MCMC using synthetic data? ([y]/n)
flag_mcmc = "n"
T_obs = day # duration of SRGO observation run
N = 200 # no. of SRGO data points acquired during T_obs
psnr = 3 # peak signal to noise ratio
# "ligo" (Whittle likelihood in Fourier space) or "custom" likelihood functions for MCMC
likelihood_type = "ligo"
flag_show_pts = "n" # show synthetic noisy data-points in signal plot ([y]/n)
flag_cp = "n" # show corner-plot subplots individually ([y]/n)
flag_extras = "y" # plot spectrogram & evolution of Euler angles ([y]/n)
flag_frq = "n" # compute peak signal vs. initial GW frequency ([y]/n)
flag_sensi = "n" # compute SRGO sensitivity curve ([y]/n)
flag_err = "n" # compute numerical integration error ([y]/n)
flag_range = "y" # compute observational range of SRGO ([y]/n)
flag_srcpos_skyloc = "n" # plot sky-loc precision vs. src position ([y]/n)
flag_sky = "n" # plot sky-loc area vs. PSNR and vs. observation time ([y]/n)
flag_mass = "n" # plot mass error vs. PSNR and vs. observation time ([y]/n)
# plot distance error vs. PSNR and vs. observation time ([y]/n)
flag_dist = "n"
# ---------------------------------------------------------------------------------------------------------
# GW waveform:
""" Dominant harmonic of inspiral phase GWs from non-spinning binaries, modelled via post-Newtonian theory.
Approximation of ISCO (Innermost Stable Circular Orbit) used for the end of the inspiral phase. """
m1 = M1*msol
m2 = M2*msol
M = (1 + Z) * ((m1 * m2) ** (3.0 / 5.0)) / \
((m1 + m2) ** (1.0 / 5.0)) # chirp mass
# final separation between bodies @ ISCO
Rf = 6.0 * G * max(m1, m2) / c ** 2.0
f0 = 2.0*sqrt(G * (m1 + m2)) / (2.0 * pi * (r*au) **
(3.0 / 2.0)) # initial GW frequency
# final GW frequency at the end of inspiral phase
f1 = 2.0*sqrt(G * (m1 + m2)) / (2.0 * pi * Rf ** (3.0 / 2.0))
k = (96.0 / 5.0) * (pi ** (8.0 / 3.0)) * \
((G * M / c ** 3.0) ** (5.0 / 3.0))
t_ins = (
(3.0 / 8.0) * (1.0 / k) * (f0 ** (-8.0 / 3.0) - f1 ** (-8.0 / 3.0))
) # inspiral time
# t_mrg = ( 5./256. )*( c**5/G**3 )*( r**4/((m1*m2)*(m1+m2)) ) #time to merger
t_ins_plot = t_ins
# GW source luminosity distance
# https://iopscience.iop.org/article/10.1086/313167
# d = (c/H0)*(Z + (1.0 - 3.0*W0/4.0)*Z**2.0 + (9.0*W0-10.0)*(W0/8.0)*Z**3.0)
d = 10**6 * pc * cosmo.luminosity_distance(Z).value
def f(t, f0, k, Z):
"""GW frequency."""
# Theano tensor variable and numpy object compatibility:
if flag_mcmc == "y" and flag_sensi != "y" and flag_err != "y" and flag_range != "y" and flag_srcpos_skyloc != "y" and flag_sky != "y" and flag_mass != "y" and flag_dist != "y" and flag_frq != "y" and str(type(t)) == "<class 'numpy.ndarray'>":
return (array([
(1.0 / (1.0 + Z)) * (f0 ** (-8.0 / 3.0) -
(8.0 / 3.0) * k * x) ** (-3.0 / 8.0)
for x in t])).astype(floatX)
else:
return (
(1.0 / (1.0 + Z)) * (f0 ** (-8.0 / 3.0) -
(8.0 / 3.0) * k * t) ** (-3.0 / 8.0)
).astype(floatX)
# return ((1./(1.+Z))* f0).astype(floatX) #constant GW frequency => continuous wave case
def h_plus(t, inc, phase, d, f0, k, Z, M):
"""GW plus-polarization."""
inc *= radian
phase *= radian
# Theano tensor variable and numpy object compatibility:
if flag_mcmc == "y" and flag_sensi != "y" and flag_err != "y" and flag_range != "y" and flag_srcpos_skyloc != "y" and flag_sky != "y" and flag_mass != "y" and flag_dist != "y" and flag_frq != "y" and str(type(t)) == "<class 'numpy.ndarray'>":
return (array([
4.0 / d
* (G * M / c ** 2) ** (5.0 / 3.0)
* ((pi * f(x, f0, k, Z) / c) ** (2.0 / 3.0))
* ((1.0 + cos(inc) ** 2.0) / 2.0)
* cos(2 * pi * f(x, f0, k, Z) * x + phase)
for x in t]))
else:
return (
4.0 / d
* (G * M / c ** 2) ** (5.0 / 3.0)
* ((pi * f(t, f0, k, Z) / c) ** (2.0 / 3.0)).astype(floatX)
* ((1.0 + cos(inc) ** 2.0) / 2.0).astype(floatX)
* cos(2 * pi * f(t, f0, k, Z) * t + phase).astype(floatX)
).astype(floatX)
def h_cross(t, inc, phase, d, f0, k, Z, M):
"""GW cross-polarization."""
inc *= radian
phase *= radian
# Theano tensor variable and numpy object compatibility:
if flag_mcmc == "y" and flag_sensi != "y" and flag_err != "y" and flag_range != "y" and flag_srcpos_skyloc != "y" and flag_sky != "y" and flag_mass != "y" and flag_dist != "y" and flag_frq != "y" and str(type(t)) == "<class 'numpy.ndarray'>":
return (array([
4.0 / d
* (G * M / c ** 2) ** (5.0 / 3.0)
* ((pi * f(x, f0, k, Z) / c) ** (2.0 / 3.0))
* cos(inc)
* sin(2 * pi * f(x, f0, k, Z) * x + phase)
for x in t]))
else:
return (
4.0 / d
* (G * M / c ** 2) ** (5.0 / 3.0)
* ((pi * f(t, f0, k, Z) / c) ** (2.0 / 3.0)).astype(floatX)
* cos(inc).astype(floatX)
* sin(2 * pi * f(t, f0, k, Z) * t + phase).astype(floatX)
).astype(floatX)
def findPrevPowerOf2(n):
""""Round off to nearest power of 2, smaller than n."""
k = 1
while k < n:
k = k << 1
if k == n:
return k
else:
return int(k/2)
# SRGO bunch clock least count (time between two consecutive ion arrivals)
T_sample = (L / v0) * (1.0 / n_p)
def time(n, t_obs, t_ins, f0, k, Z):
""""Return the corrected timing data points allowed by the experiment measurement."""
# observation period cannot exceed inspiral period in our code
t_obs = min(t_obs, t_ins)
n = min(n, int(t_obs / T_sample)) # allowed N
# Nyquist–Shannon sampling theorem
n = max(n, int(2.0*f(t_obs, f0, k, Z)*t_obs)+1)
if flag_mcmc == "y" and flag_sensi != "y" and flag_err != "y" and flag_range != "y" and flag_srcpos_skyloc != "y" and flag_sky != "y" and flag_mass != "y" and flag_dist != "y" and flag_frq != "y":
# to be able to use FFT trick for computing speed
n = findPrevPowerOf2(n)
if n < int(2.0*f(t_obs, f0, k, Z)*t_obs)+1:
n = 2*n
# allowed timing interval
T_timing = int(t_obs / (n * T_sample)) * T_sample
t = arange(0.0, t_obs, T_timing, dtype=floatX) # timing data points
if flag_mcmc == "y" and flag_sensi != "y" and flag_err != "y" and flag_range != "y" and flag_srcpos_skyloc != "y" and flag_sky != "y" and flag_mass != "y" and flag_dist != "y" and flag_frq != "y" and len(t) > n:
# to be able to use FFT trick for computing speed
pts = len(t) - n
t = t[:-pts]
return t, T_timing
# Effect of Earth's rotation:
# angular position of the detector on the SRGO ring, in degrees converted to radians
# (value 0 => detector is placed along the longitude passing via the center of SRGO, south of the center)
phi0 = 0.0 * radian
# SRGO latitude in degrees converted to radians
# if theta_lat == dec, sometimes there is a numerical error in calculating the angle from the rotation matrix, so we define theta_lat += 0.001
theta_lat += 360.0 # for Euler angles to be non-discontinuous functions of time
theta_lat *= radian
ra = (
(RA[0] * 3600.0 + RA[1] * 60.0 + RA[2]) * 360.0/(24.0*60.0*60.0)
) # GW source right ascension in seconds converted to degrees
# initial local sidereal time in seconds converted to degrees
# (lst==ra => observation run begins when the GW source is on the celestial meridian of SRGO)
lst = (LST[0] * 3600.0 + LST[1] * 60.0 + LST[2]) * 360.0/(24.0*60.0*60.0)
dec = dec # GW source declination in degrees
# GW polarization angle (in degrees) in equatorial celestial coordinates.
psi_eq = psi_eq
matrix_phi0 = array(
[
[cos(phi0), -sin(phi0), 0.0],
[sin(phi0), cos(phi0), 0.0],
[0.0, 0.0, 1.0],
],
dtype=floatX,
)
matrix_theta_lat = array(
[
[sin(theta_lat), 0.0, -cos(theta_lat)],
[0.0, 1.0, 0.0],
[cos(theta_lat), 0.0, sin(theta_lat)],
],
dtype=floatX,
)
matmul = np.matmul
matmul_matrix_theta_lat_matrix_phi0 = matmul(
matrix_theta_lat, matrix_phi0, dtype=floatX
)
tt_arctan2 = tt.arctan2
tt_arccos = tt.arccos
np_arctan2 = np.arctan2
np_arccos = np.arccos
def earth_rot(t, ra, lst, dec, psi_eq, flag):
"""Time-evolution of Euler angles due to effect of Earth's rotation."""
ra *= radian
lst *= radian
dec *= radian
psi_eq *= radian
matrix_dec = array(
[
[-sin(dec), 0.0, cos(dec)],
[0.0, 1.0, 0.0],
[-cos(dec), 0.0, -sin(dec)],
]
)
matrix_psi_eq = array(
[
[cos(psi_eq), -sin(psi_eq), 0.0],
[sin(psi_eq), cos(psi_eq), 0.0],
[0.0, 0.0, 1.0],
]
)
def mp_func(): # generator function, which can also be made into a multiprocessing function
for i in range(len(t)):
# print(i)
matrix_ra_time = array(
[
[
-cos(ra - lst - we * t[i]),
sin(ra - lst - we * t[i]),
0.0,
],
[
-sin(ra - lst - we * t[i]),
-cos(ra - lst - we * t[i]),
0.0,
],
[0.0, 0.0, 1.0],
]
)
rhs = matmul(matrix_psi_eq,
matmul(matrix_dec,
matmul(matrix_ra_time,
matmul_matrix_theta_lat_matrix_phi0
),
),
)
if flag == "mcmc":
yield (
tt_arctan2(rhs[2][1], -rhs[2][0]),
tt_arccos(rhs[2][2]),
tt_arctan2(rhs[1][2], rhs[0][2]),
)
else:
yield (
np_arctan2(rhs[2][1], -rhs[2][0], dtype=floatX),
np_arccos(rhs[2][2], dtype=floatX),
np_arctan2(rhs[1][2], rhs[0][2], dtype=floatX),
)
return array(list(zip(*mp_func())))
# SRGO response (without noise):
def F_plus(phi, theta, psi):
"""SRGO antenna pattern for GW plus-polarization."""
return cos(2.0 * psi) * sin(theta) ** 2.0
def F_cross(phi, theta, psi):
"""SRGO antenna pattern for GW cross-polarization."""
return sin(2.0 * psi) * sin(theta) ** 2.0
def h_eff(t, phi, theta, psi, inc, phase, d, f0, k, Z, M):
"""Effective longitudinal GW strain for SRGO test masses
that are circulating rapidly compared to the GW frequency."""
return (
-(1.0 / 2.0)
* (
F_plus(phi, theta, psi) * h_plus(t, inc, phase, d, f0, k, Z, M)
+ F_cross(phi, theta, psi) * h_cross(t, inc, phase, d, f0, k, Z, M)
)
)
def boole_quad(y, x, yofx, a, b, c, d, e, g, k, l, p, q):
"""Custom implementation of Boole's rule quadrature."""
h = (x[1] - x[0]) / 4.0
a1 = a[0] + h * (a[1] - a[0]) / (4.0 * h)
a2 = a[0] + 2.0 * h * (a[1] - a[0]) / (4.0 * h)
a3 = a[0] + 3.0 * h * (a[1] - a[0]) / (4.0 * h)
b1 = b[0] + h * (b[1] - b[0]) / (4.0 * h)
b2 = b[0] + 2.0 * h * (b[1] - b[0]) / (4.0 * h)
b3 = b[0] + 3.0 * h * (b[1] - b[0]) / (4.0 * h)
c1 = c[0] + h * (c[1] - c[0]) / (4.0 * h)
c2 = c[0] + 2.0 * h * (c[1] - c[0]) / (4.0 * h)
c3 = c[0] + 3.0 * h * (c[1] - c[0]) / (4.0 * h)
return (2.0 * h / 45.0) * (
7.0 * y[0]
+ 32.0 * yofx(x[0] + h, a1, b1, c1, d, e, g, k, l, p, q)
+ 12.0 * yofx(x[0] + 2.0 * h, a2, b2, c2, d, e, g, k, l, p, q)
+ 32.0 * yofx(x[0] + 3.0 * h, a3, b3, c3, d, e, g, k, l, p, q)
+ 7.0 * y[1]
)
def SRGO_signal(t, phi, theta, psi, inc, phase, d, f0, k, Z, M):
"""SRGO signal from response to GWs."""
integrand = h_eff(t, phi, theta, psi, inc, phase, d, f0, k, Z, M)
signal = [0.0]
append = signal.append # functional programming optimization
gen = ( # generator comprehension
append(
signal[-1]
+ (1.0 - v0 ** 2.0 / (2.0 * c ** 2.0))
* boole_quad(
integrand[i: i+2],
t[i: i+2],
h_eff,
phi[i: i+2],
theta[i: i+2],
psi[i: i+2],
inc,
phase,
d,
f0,
k,
Z,
M
)
)
for i in range(len(t) - 1)
)
dummy = list(gen)
return array(signal)
# Some quantities for plotting:
t_plt, dt_plt = time(6000, 3.0*day, t_ins, f0, k, Z)
phi_plt, theta_plt, psi_plt = earth_rot(t_plt, ra, lst, dec, psi_eq, "regular")
signal_plt = SRGO_signal(t_plt, phi_plt, theta_plt,
psi_plt, inc, phase, d, f0, k, Z, M)
# ----------------------------------------------------------------------------------------------------------------------------
if flag_frq == "y":
f0s = np.logspace(-7, 0, 1000)
peak = []
for f_0 in f0s:
t_ins1 = (
(3.0 / 8.0) * (1.0 / k) * (f_0 ** (-8.0 / 3.0) - f1 ** (-8.0 / 3.0))
) # inspiral time
ttobs = day/1440
t_frq, dt_frq = time(8000, ttobs, t_ins1, f_0, k, Z)
phi_frq, theta_frq, psi_frq = earth_rot(
t_frq, ra, lst, dec, psi_eq, "regular")
signal_frq = SRGO_signal(t_frq, phi_frq, theta_frq,
psi_frq, inc, phase, d, f_0, k, Z, M)
peak.append(max(abs(signal_frq))/9.14659e-24)
print('next')
peak = array(peak)
figf, axesf = plt.subplots(1, 1)
axesf.plot(f0s, peak, linewidth=1.5, color="darkorange",
label=r'$T_{obs}=$%r min' % (np.round(ttobs/60)))
axesf.axvline(x=1/ttobs, linewidth=1.0, linestyle='dashdot', color="black",
label=r'GW period equals $T_{obs}$')
axesf.set_xlabel("Initial GW frequency [Hz]")
axesf.set_ylabel("Scaled PSNR")
axesf.set_xscale('log')
#axesf.set_ylim(10**-21, 10**-6)
# axesf.set_xticks([10, 10**2, 10**3, 10**4, 10**5, 10 **
# 6, 10**7, 10**8, 10**9, 10**10, 10**11])
#axesf.set_yticks([10**-21, 10**-18, 10**-15, 10**-12, 10**-9, 10**-6])
axesf.tick_params(axis='y', which='minor')
axesf.legend()
# figf.canvas.manager.full_screen_toggle()
figf.tight_layout()
figf.savefig("saved_plots/peaksig_vs_frq.png", format="png", dpi=800)
def error(p):
"""For obtaining the numerical error of integration given the no. of data pts, 'p'."""
t_err, dt_err = time(p, 1.0*day, t_ins, f0, k, Z)
phi_err, theta_err, psi_err = earth_rot(
t_err, ra, lst, dec, psi_eq, "regular")
signal_err = SRGO_signal(t_err, phi_err, theta_err,
psi_err, inc, phase, d, f0, k, Z, M)
err = 100*max(abs(signal_err - signal_ref(t_err))) / \
max(abs(signal_ref(t_err)))
print(p, err)
return(err)
if flag_err == "y":
t_ref, dt_ref = time(10**6, 3.0*day, t_ins, f0, k, Z) # increase to 10**7
phi_ref, theta_ref, psi_ref = earth_rot(
t_ref, ra, lst, dec, psi_eq, "regular")
signal_ref = SRGO_signal(t_ref, phi_ref, theta_ref,
psi_ref, inc, phase, d, f0, k, Z, M)
signal_ref = interp1d(t_ref, signal_ref)
pts = 2.**arange(1, 15, 1) # increase to 20
errs = [error(p) for p in pts]
sns.reset_orig()
fig2, axes1 = plt.subplots(1, 1)
f_samprates = pts/day
axes1 = plt.gca()
axes2 = axes1.twiny()
axes1.loglog(pts, errs, color='blue', linewidth=1.25)
axes1.set_xlabel("No. of Data Points", fontweight='bold')
axes1.set_ylabel(
"Max. Numerical Error [%]", fontweight='bold')
axes1.legend(["$T_{obs} = 1.0$ day(s)"])
axes2.loglog(f_samprates, errs, color='blue', linewidth=0.0)
axes2.set_xlabel(
"Sampling Frequency [$\mathbf{s^{-1}}$]", fontweight='bold')
fig2.savefig("saved_plots/numerical_error.png", format="png", dpi=800)
# plt.close(fig2)
def srgo_range(dee, zed):
"""For numerically obtaining the SRGO observational range."""
M_rng = (1 + zed) * ((m1 * m2) ** (3.0 / 5.0)) / \
((m1 + m2) ** (1.0 / 5.0)) # chirp mass
# final separation between bodies @ ISCO
Rf_rng = 6.0 * G * max(m1, m2) / c ** 2.0
# initial GW frequency (realistic lowest possible mHz to give max. signal and cover all sources)
# observed frequency should be same, not at source
f0_rng = 1.0*10**-4 * (1 + zed)
# final GW frequency at the end of inspiral phase
f1_rng = 2.0*sqrt(G * (m1 + m2)) / (2.0 * pi * Rf_rng ** (3.0 / 2.0))
k_rng = (96.0 / 5.0) * (pi ** (8.0 / 3.0)) * \
((G * M_rng / c ** 3.0) ** (5.0 / 3.0))
t_ins_rng = (
(3.0 / 8.0) * (1.0 / k_rng) *
(f0_rng ** (-8.0 / 3.0) - f1_rng ** (-8.0 / 3.0))
) # inspiral time
inc_rng = 0.0 # inclination angle
phase_rng = 0.0 # initial GW phase
# set 3 hours as standard obs time
t_rng, dt_rng = time(2000, day/8.0, t_ins_rng, f0_rng, k_rng, zed)
phi_rng, theta_rng, psi_rng = earth_rot(
t_rng, ra, lst, dec, psi_eq, "regular")
signal_range = SRGO_signal(
t_rng, phi_rng, theta_rng, psi_rng, inc_rng, phase_rng, dee, f0_rng, k_rng, zed, M_rng)
# use rms instead of max(abs(signal_range)) to comply with srgo_sensitivity
peak_signal = (np.mean(signal_range**2.0))**0.5
print(zed, m1/msol, t_ins_rng/day, peak_signal)
return(peak_signal)
if flag_range == "y":
ra_vals = [0., 45., 90., 180., 270.]
dec_vals = [0., 30., 51., 70., 90.]
psi_eq_vals = [0., 45., 90., 135.]
# up to redshift of first stars (Cosmic Dawn)
z_array1 = np.linspace(0.0, 15.0, 100000)
d_array1 = 10**6 * pc * cosmo.luminosity_distance(z_array1).value
z_of_d = interp1d(d_array1, z_array1)
# from closest mHz spectroscopic binaries up to Cosmic Dawn distance
d_array = array([50*pc, 10**2*pc, 599*pc, 600*pc, 10**3*pc, 1499*pc, 1500*pc, 2199*pc, 2200*pc, 7999*pc, 8000*pc, 10**4*pc, 10**5*pc, 777847*pc, 777847.7361*pc,
10**6*pc, 10**7*pc, 27.3*pc*10**6, 27.4*pc*10**6, 10**8*pc, 10**8.5*pc, 10**9*pc, 10**9.25*pc, 10**9.5*pc, 10**9.75*pc, 10**10*pc, 10**10.25*pc, 10**10.35*pc, 10**10.5*pc, 10**10.838*pc, 10**6*pc*cosmo.luminosity_distance(10.0).value])
z_array = z_of_d(d_array)
sig_array = np.zeros(len(d_array))
for aaa in ra_vals:
ra = aaa
for bbb in dec_vals:
dec = bbb
for ccc in psi_eq_vals:
psi_eq = ccc
for i in range(len(d_array)):
if z_array[i] > 10.0: # first mHz SMBBHs due to galaxy mergers
# https://arxiv.org/abs/1903.06867
# https://iopscience.iop.org/article/10.3847/2041-8213/ab2646
# https://iopscience.iop.org/article/10.1088/1475-7516/2016/04/002/pdf
m1 = 10**5 * msol # only seed IMBH black holes beyond z=10
m2 = m1 # equal mass binaries
elif z_array[i] <= 10.0 and d_array[i] >= 27.4*pc*10**6:
# closest SMBBH (NGC 7727)
# https://doi.org/10.1051/0004-6361/202140827
m1 = 10**7 * msol # based on evolution of SMBH mass function
m2 = m1
elif d_array[i] < 27.4*pc*10**6 and d_array[i] >= 777847.7361*pc:
# closest galaxy (Andromeda)
# https://iopscience.iop.org/article/10.1086/432434
m1 = 10**5 * msol # equivalent to 10^3 & 10^8 msol EMRI
m2 = m1
elif d_array[i] < 777847.7361*pc and d_array[i] >= 8000*pc:
# closest dwarf galaxy (Canis Major) AND Milky Way center
# https://academic.oup.com/mnras/article/473/1/1186/4060726
# https://iopscience.iop.org/article/10.3847/2041-8213/ac1170
m1 = 10**6 * msol
m2 = 10**3 * msol
elif d_array[i] < 8000*pc and d_array[i] >= 2200*pc:
# closest globular cluster within our galaxy (Milky Way)
# https://en.wikipedia.org/wiki/List_of_globular_clusters#Milky_Way
m1 = 10**4 * msol
m2 = 10 * msol
elif d_array[i] < 2200*pc and d_array[i] >= 1500*pc:
# closest black hole within our galaxy (Milky Way)
# https://arxiv.org/abs/2201.13296
m1 = 10 * msol
m2 = m1
elif d_array[i] < 1500*pc and d_array[i] >= 600*pc:
# closest mHz binary neutron star within our galaxy
# https://iopscience.iop.org/article/10.1088/0004-637X/789/2/119
# http://www.johnstonsarchive.net/relativity/binpulstable.html
# https://en.wikipedia.org/wiki/PSR_J0737%E2%88%923039
# https://journals.aps.org/prx/abstract/10.1103/PhysRevX.11.041050
# https://www.science.org/doi/10.1126/science.1094645
# https://iopscience.iop.org/article/10.3847/1538-4357/ab12e3
# https://iopscience.iop.org/article/10.3847/1538-4357/aa7e89
# https://academic.oup.com/mnrasl/article/475/1/L57/4794951
# https://iopscience.iop.org/article/10.3847/2041-8213/aaad06
# https://iopscience.iop.org/article/10.3847/1538-4357/aabf8a
m1 = 1 * msol
m2 = m1
elif d_array[i] < 600*pc:
# closest mHz spectroscopic binaries within Milky Way:
# https://doi.org/10.1051/0004-6361:20041213
# https://sb9.astro.ulb.ac.be/
# https://gaia.ari.uni-heidelberg.de/singlesource.html
# https://gea.esac.esa.int/archive/documentation/GDR3/Miscellaneous/sec_credit_and_citation_instructions/
# https://en.wikipedia.org/wiki/WZ_Sagittae
# https://en.wikipedia.org/wiki/EX_Hydrae
# https://en.wikipedia.org/wiki/OY_Carinae
# https://en.wikipedia.org/wiki/Gliese_829
# https://en.wikipedia.org/wiki/GJ_3991
# https://en.wikipedia.org/wiki/Delta_Trianguli
# https://en.wikipedia.org/wiki/HR_5553
# https://en.wikipedia.org/wiki/HR_9038
# https://en.wikipedia.org/wiki/Zeta_Trianguli_Australis
# https://en.wikipedia.org/wiki/Delta_Capricorni
# https://en.wikipedia.org/wiki/Iota_Pegasi
m1 = 0.5 * msol
m2 = m1
sig_array[i] = max(
sig_array[i], srgo_range(d_array[i], z_array[i]))
c_d = [1., 1., 1., sig_array[3]/sig_array[2], sig_array[3]/sig_array[2], sig_array[3]/sig_array[2], (sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]),
(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2]), (sig_array[18]/sig_array[17])*(sig_array[14]/sig_array[13])*(sig_array[10]/sig_array[9])*(sig_array[8]/sig_array[7])*(sig_array[6]/sig_array[5])*(sig_array[3]/sig_array[2])]
# function that encapsulates variation due to redshift
k_d = array([sig_array[i]*d_array[i]/c_d[i] for i in range(len(d_array))])
k_of_d = interp1d(d_array, k_d, kind="slinear")
da = np.logspace(np.log10(50.001*pc), np.log10(10**6 * pc *
cosmo.luminosity_distance(9.999).value), 100000)
d0 = da[np.where(abs(k_of_d(da)*c_d[0]/da - 10**-21) /
10**-21 <= 0.05)[0][0]]
d1 = np.logspace(np.log10(50.001*pc), np.log10(d0), 1000)
y1 = k_of_d(d1)*c_d[0]/d1
d0 = da[np.where(abs(k_of_d(da)*c_d[3]/da - 10**-21) /
10**-21 <= 0.05)[0][0]]
d2 = np.logspace(np.log10(600*pc), np.log10(d0), 1000)
y2 = k_of_d(d2)*c_d[3]/d2
d0 = da[np.where(abs(k_of_d(da)*c_d[6]/da - 10**-21) /
10**-21 <= 0.05)[0][0]]
d3 = np.logspace(np.log10(1500*pc), np.log10(d0), 1000)
y3 = k_of_d(d3)*c_d[6]/d3
d0 = da[np.where(abs(k_of_d(da)*c_d[8]/da - 10**-21) /
10**-21 <= 0.05)[0][0]]
d4 = np.logspace(np.log10(2200*pc), np.log10(d0), 1000)
y4 = k_of_d(d4)*c_d[8]/d4
d0 = 10**6*pc*cosmo.luminosity_distance(9.999).value
d5 = np.logspace(np.log10(8000*pc), np.log10(d0), 1000)
y5 = k_of_d(d5)*c_d[10]/d5
d0 = 10**6*pc*cosmo.luminosity_distance(9.999).value
d6 = np.logspace(np.log10(777847.7361*pc), np.log10(d0), 1000)
y6 = k_of_d(d6)*c_d[14]/d6
d0 = 10**6*pc*cosmo.luminosity_distance(9.999).value
d7 = np.logspace(np.log10(27.4*pc*10**6), np.log10(d0), 1000)
y7 = k_of_d(d7)*c_d[18]/d7
sns.reset_orig()
fig3, axes3 = plt.subplots(1, 1)
axes3 = plt.gca()
axes4 = axes3.twiny() # the spines of the second axes are overdrawn on the first
facecolour = "snow"
axes3.set_facecolor(facecolour)
# fig3.set_facecolor(facecolour)
textcolour = "black"
axes4.spines['top'].set_color(textcolour)
axes4.spines['bottom'].set_color(textcolour)
axes4.spines['left'].set_color(textcolour)
axes4.spines['right'].set_color(textcolour)
axes3.xaxis.label.set_color(textcolour)
axes3.yaxis.label.set_color(textcolour)
axes4.xaxis.label.set_color(textcolour)
axes3.tick_params(axis='x', colors=textcolour)
axes3.tick_params(axis='y', colors=textcolour)
axes4.tick_params(axis='x', colors=textcolour)
#txtsize = axes3.xaxis.label.get_size()
axes3.plot(d_array/pc, sig_array, linewidth=1.5, color="blue", alpha=0.75,
zorder=10, label=r'$f_{GW}=0.1$ mHz; $T_{obs}=3.0$ h')
axes3.axvline(x=50, linewidth=1.0, linestyle='dashdot', color="darkorchid",
label="nearest ~$0.5M_{\odot}$ WD binaries")
axes3.fill_between(d1/pc, y1, facecolor="darkorchid",
alpha=0.35, zorder=10)
axes3.axvline(x=600, linewidth=1.0, linestyle='dashdot', color="hotpink",
label="nearest ~$1M_{\odot}$ NS binaries")
axes3.fill_between(d2/pc, y2, facecolor="hotpink", alpha=0.35, zorder=10)
axes3.axvline(x=1500, linewidth=1.0, linestyle='dashdot', color="deepskyblue",
label="nearest ~$10M_{\odot}$ BH binaries")
axes3.fill_between(d3/pc, y3, facecolor="deepskyblue",
alpha=0.35, zorder=10)
axes3.axvline(x=2200, linewidth=1.0, linestyle='dashdot', color="slategray",
label="nearest ~$10M_{\odot}$ & $10^4M_{\odot}$ EMRIs")
axes3.fill_between(d4/pc, y4, facecolor="slategray", alpha=0.35, zorder=10)
axes3.axvline(x=8000, linewidth=1.0, linestyle='dashdot', color="mediumseagreen",
label="nearest ~$10^3M_{\odot}$ & $10^6M_{\odot}$ EMRIs")
axes3.fill_between(d5/pc, y5, facecolor="mediumseagreen",
alpha=0.35, zorder=10)
axes3.axvline(x=777847.7361, linewidth=1.0, linestyle='dashdot', color="chocolate",
label="nearest ~$10^3M_{\odot}$ & $10^8M_{\odot}$ EMRIs")
axes3.fill_between(d6/pc, y6, facecolor="chocolate", alpha=0.35, zorder=10)
axes3.axvline(x=27.4*10**6, linewidth=1.0, linestyle='dashdot', color="darkorange",
label="nearest ~$10^7M_{\odot}$ SMBH binaries")
axes3.fill_between(d7/pc, y7, facecolor="darkorange",
alpha=0.35, zorder=10)
axes3.axvline(x=cosmo.luminosity_distance(10.0).value*10**6, linewidth=1.0, color="red",
linestyle='dashdot', label="first ~$10^7M_{\odot}$ SMBH binaries")
axes3.set_xlabel("GW source distance [pc]")
axes3.set_ylabel(
"Effective noise requirement [s]")
axes3.set_xscale('log')
axes3.set_yscale('log')
axes3.set_ylim(10**-21, 10**-6)
axes3.set_xticks([10, 10**2, 10**3, 10**4, 10**5, 10 **
6, 10**7, 10**8, 10**9, 10**10, 10**11])
axes3.set_yticks([10**-21, 10**-18, 10**-15, 10**-12, 10**-9, 10**-6])
axes3.tick_params(axis='y', which='minor')
leg = axes3.legend(loc='upper right', bbox_to_anchor=(
0.94, 1.0), facecolor=facecolour, framealpha=1, prop={'size': 5.75})
for text in leg.get_texts():
text.set_color(textcolour)
axes4.plot(z_array, sig_array, color='orange', linewidth=0.0)
axes4.set_xlabel("GW source redshift (z)")
axes4.set_xscale('log')
axes4.set_xticks([10**-9, 10**-8, 10**-7, 10**-6,
10**-5, 10**-4, 10**-3, 10**-2, 10**-1, 10**0, 10**1])
# fig3.canvas.manager.full_screen_toggle()
fig3.tight_layout()
fig3.savefig("saved_plots/srgo_range.png", format="png",
dpi=800, facecolor=fig3.get_facecolor())
# plt.close(fig3)
def sensi_curve(b, tobs, flag):
"""For numerically obtaining the SRGO sensitivity curve.""" # https://en.wikipedia.org/wiki/Spectral_density#Power_spectral_density
sigma_noise = 10**(-12)
M_sns = (1 + Z) * ((m1 * m2) ** (3.0 / 5.0)) / \
((m1 + m2) ** (1.0 / 5.0)) # chirp mass
# final separation between bodies @ ISCO
Rf_sns = 6.0 * G * max(m1, m2) / c ** 2.0
f0_sns = 2.0*sqrt(G * (m1 + m2)) / (2.0 * pi * (r*au) **
(3.0 / 2.0)) # initial GW frequency
# final GW frequency at the end of inspiral phase
f1_sns = 2.0*sqrt(G * (m1 + m2)) / (2.0 * pi * Rf_sns ** (3.0 / 2.0))
k_sns = (96.0 / 5.0) * (pi ** (8.0 / 3.0)) * \
((G * M_sns / c ** 3.0) ** (5.0 / 3.0))
t_ins_sns = (
(3.0 / 8.0) * (1.0 / k_sns) *
(f0_sns ** (-8.0 / 3.0) - f1_sns ** (-8.0 / 3.0))
) # inspiral time
# T_obs = infty ==> T_obs = LCM(day, 1/f).
def LCM(a, b):
""" Lowest close multiple """
x = max(a, b)
n = min(a, b)
i = 1
mult = x/n
if mult >= 100:
return (x)
else:
while i*mult % 1 >= 0.1:
i += 1
return (i*x)
f_const = f(0.0, f0_sns, 0.0, Z)
if flag == "finite":
Tobs = tobs
else:
Tobs = LCM(day, 1/f_const) # LCM approximation
if flag == "finite":
N_min = int(200*Tobs/day)
else:
# optimising signal generation using ~ limiting case of Nyquist-Shannon condition:
N_min = int(8*max(f_const, 1/day)*Tobs) + 1
t_sensi, dt_sensi = time(N_min, Tobs,
t_ins_sns, f0_sns, k_sns, Z)
phi_sensi, theta_sensi, psi_sensi = earth_rot(
t_sensi, ra, lst, dec, psi_eq, "regular")
# signal_sensi = SRGO_signal( # for binary GW sources
# t_sensi, phi_sensi, theta_sensi, psi_sensi, inc, phase, b, f0_sns, k_sns, Z, M_sns)
signal_sensi_CW = SRGO_signal( # for continuous GW sources
t_sensi, phi_sensi, theta_sensi, psi_sensi, inc, phase, b, f0_sns, 0.0, Z, M_sns)
# val_lhs = (np.mean(signal_sensi**2.0))**0.5 # RMS signal
val_lhs_CW = (np.mean(signal_sensi_CW**2.0))**0.5
val_rhs = 0.5*sigma_noise / (n_p*(1.0/T_sample))**0.5 # effective noise
# global d
# d = b*val_lhs/val_rhs # value of GW source distance where val_lhs == val_rhs i.e. SNR=1
# h_rms = ((np.mean(h_plus(t_sensi, inc, phase, d, f0_sns, k_sns, Z, M_sns)**2.0)
# + np.mean(h_cross(t_sensi, inc, phase, d, f0_sns, k_sns, Z, M_sns)**2.0))/2.0)**0.5
finite = sqrt(1 + (np.sinc(2*pi*f_const*Tobs/radian))**2 + 2 *
np.sinc(2*pi*f_const*Tobs/radian)*cos(2*phase*radian))
ASD = val_rhs * ((1.0 + cos(inc) ** 2.0) / 2.0) * h_plus(0.0, 0.0, 0.0, b,
f0_sns, 0.0, Z, M_sns) / val_lhs_CW
if flag == "finite":
ASD *= finite
print(f_const, ASD)
return(f_const, ASD)
if flag_sensi == "y": # utilizing symmetries to cover max. parameter range with min. iterations
M1_vals = [3.]
ra_vals = [0., 45., 90., 180., 270.]
dec_vals = [0., 30., 51., 70., 90.]
psi_eq_vals = [0., 45., 90., 135.]
inc_vals = [0., 45., 90., 135.]
phase_vals = [0., 45., 90., 135.]
l = 210
f0_array = np.zeros(l)
#h0_array = np.zeros(l)
#h0_temp = np.zeros(l)
h0_array_CW = np.zeros(l)
h0_temp_CW = np.zeros(l)
# N0 = ones(l) * (len(ra_vals)*len(dec_vals)*len(psi_eq_vals)
# * len(inc_vals)*len(phase_vals)*len(M1_vals))
N0_CW = ones(l) * (len(ra_vals)*len(dec_vals)*len(psi_eq_vals)
* len(inc_vals)*len(phase_vals)*len(M1_vals))
for aaa in ra_vals:
ra = aaa
for bbb in dec_vals:
dec = bbb
for ccc in psi_eq_vals:
psi_eq = ccc
for ddd in inc_vals:
inc = ddd
for eee in phase_vals:
phase = eee
for fff in M1_vals:
m1 = fff * msol
m2 = m1 # equal mass binaries
separation = (1.0/au)*(2.0*sqrt(G * (m1 + m2)) / (2.0 * pi * (1.0+Z) *
np.logspace(-7.0, -0.3, l)))**(2.0/3.0)
for i in range(l):
r = separation[i]
try:
f_0, h_0_CW = sensi_curve(
d, day/8, "infinite")
if f0_array[i] == 0.0:
f0_array[i] = f_0
# If sensi_curve returned NaN, set h_0_CW to 0.0
if np.isnan(h_0_CW):
h_0_CW = 0.0
N0_CW[i] -= 1
except Exception as e:
h_0_CW = 0.0
N0_CW[i] -= 1
h0_temp_CW[i] = h_0_CW
#h0_array += h0_temp
h0_array_CW += h0_temp_CW
#h0_array *= 1.0/N0
h0_array_CW *= 1.0/N0_CW
# To simulate graphic:
# First, plotting the paper-I sensitivity curve, modified to be normalized to T_obs = 3.0 h
fq = 10**np.linspace(-11, 6, 1000000)
i = int(np.where(np.abs(fq-10**(-7.0)) ==
np.min(np.abs(fq-10**(-7.0))))[0])
j = int(np.where(np.abs(fq-10**(-0.0)) ==
np.min(np.abs(fq-10**(-0.0))))[0])
i1 = int(np.where(np.abs(fq-10**(-8.0)) ==
np.min(np.abs(fq-10**(-8.0))))[0])
j1 = int(np.where(np.abs(fq-10**(1.0)) == np.min(np.abs(fq-10**(1.0))))[0])
t_noise = 10.0**(-12)
f_sampling = 2.0*2808*11245
# h = (16.0*np.pi/np.sqrt(30.0))*(t_noise/np.sqrt(f_sampling))*fq**(3.0/2.0) # from paper-I
T_obs_sns = day/8.0
h = (16.0*np.pi/np.sqrt(3.0))*(t_noise/np.sqrt(f_sampling*T_obs_sns)) * \
fq**(1.0) # modified for T_obs = 3.0 h
# CONVENTIONAL sensitivity curve, which is the ASD of the noise modeled as a characteristic strain:
frq = np.logspace(-7.0, 0.0, 700)
f_sampl = 2998000
hnf = 4*frq*t_noise/f_sampl
for k in range(len(fq)):
if (k < i and k != i1) or (k > j and k != j1):
h[k] = np.nan
# from the ASD plot on gwplotter.com, measured by pixel info in MS Paint
fm = np.array([10**(-3.697), 10**(-0.520)])
hm = np.array([10**(-15.778), 10**(-19.481)])
fe = np.array([10**(-3.994), 10**(-1.003)])
he = np.array([10**(-16.222), 10**(-19.704)])
fr = np.array([10**(-3.492), 10**(-2.006)])
hr = np.array([10**(-17.148), 10**(-17.889)])
fu = np.array([10**(-4.124), 10**(-2.824)])
hu = np.array([10**(-17.519), 10**(-19.0)])
# sns.reset_orig()
plt.figure()
plt.fill_between(fm, hm, facecolor='steelblue',
alpha=0.6, label="Massive binaries")
plt.fill_between(fe, he, facecolor='darkcyan', alpha=0.6,
label="Extreme mass-ratio inspirals")
plt.fill_between(fr, hr, facecolor='lightskyblue', alpha=0.6,
label="Resolvable galactic binaries")
plt.fill_between(fu, hu, facecolor='lime', alpha=0.6,
label="Unresolvable galactic binaries")
# plt.plot(fq, h, color='black', linewidth=1.5) # LHC-GW
plt.plot(f0_array, h0_array_CW, color='black', linewidth=1.5,
label="SRGO sensitivity curve\n$\sigma_{noise}=1 $ps, $f_{sample}=2.998$MHz")
# plt.plot(frq, hnf, color='black', linewidth=1.5,
# label="CONVENTIONAL SRGO sensitivity curve\n$\sigma_{noise}=1 $ps, $f_{sample}=2.998$MHz")
plt.legend(loc=2, borderpad=0.2, labelspacing=0.2)
plt.xlim(5*10**(-8.), 10**(0.))
plt.ylim(10**(-26.), 10**(-10.))
plt.ylabel(
"Strain Amplitude Spectral Density [1/$\sqrt{Hz}$]", fontweight='bold')
plt.xlabel("Frequency [Hz]", fontweight='bold')
plt.yscale('log')
plt.xscale('log')
plt.grid()
plt.tick_params(axis='x', which='minor')
plt.tight_layout()
plt.savefig("saved_plots/srgo_sensitivity.png", dpi=800)
# plt.close()
# ----------------------------------------------------------------------------------------------------------------------------
# Creating synthetic signal and adding only stochastic noise:
if flag_sensi != "y" and flag_err != "y" and flag_range != "y" and flag_srcpos_skyloc != "y" and flag_sky != "y" and flag_mass != "y" and flag_dist != "y" and flag_frq != "y":
t, dt = time(N, T_obs, t_ins, f0, k, Z)
N = len(t)
phi, theta, psi = earth_rot(t, ra, lst, dec, psi_eq, "regular")
signal = SRGO_signal(t, phi, theta, psi, inc, phase, d, f0, k, Z, M)
noise = np.random.normal(0.0, scale=max(
abs(signal_plt)) / psnr, size=N).astype(floatX)
# noise = np.random.normal(
# 0.0, scale=2.358462672796294e-16, size=N).astype(floatX)
noisy_signal = (signal + noise).astype(floatX)
# noisy_signal = wiener(noisy_signal, noise=max(
# abs(signal_plt)) / psnr) # Wiener noise filter
# Noise filter introduces new correlations between the independent data-points.
# Then we must account for the covariance matrix in the mcmc.
# https://www.researchgate.net/post/Does_using_a_noise_filter_before_performing_MCMC_fitting_of_a_model_to_noisy_data_increase_or_decrease_the_accuracy_of_the_fit
# Simulating noisy data and computing sky localization using MCMC:
if flag_mcmc == "y" and flag_sensi != "y" and flag_err != "y" and flag_range != "y" and flag_srcpos_skyloc != "y" and flag_sky != "y" and flag_mass != "y" and flag_dist != "y" and flag_frq != "y":
# Applying bandpass filter based on predicted mHz astrophysical sources:
if likelihood_type == "ligo":
noisy_signal_f = fft(noisy_signal)
freqs = fftfreq(N, dt)
# Note: The below inequalities do the opposite of what they appear to do!
# noisy_signal_f = np.where(
# abs(freqs) > 8.*10**(-5.), noisy_signal_f, 0.0)
# noisy_signal_f = np.where(
# abs(freqs) < 5.*10**(-1.), noisy_signal_f, 0.0)
# Power spectral density of the noise:
psd = (dt**2.0/t[-1])*abs(fft(noise))**2.0
def Whittle(model, data, sigma, df):
"""
2-dimensional Whittle Likelihood (Whittle, 1951); see also Cornish & Romano (2013).
https://doi.org/10.1017/pasa.2019.2
"""