ler 0.3.5__py3-none-any.whl → 0.3.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ler might be problematic. Click here for more details.
- ler/__init__.py +1 -1
- ler/image_properties/image_properties.py +77 -32
- ler/rates/gwrates.py +79 -57
- ler/rates/ler.py +160 -115
- {ler-0.3.5.dist-info → ler-0.3.6.dist-info}/METADATA +1 -1
- {ler-0.3.5.dist-info → ler-0.3.6.dist-info}/RECORD +9 -9
- {ler-0.3.5.dist-info → ler-0.3.6.dist-info}/LICENSE +0 -0
- {ler-0.3.5.dist-info → ler-0.3.6.dist-info}/WHEEL +0 -0
- {ler-0.3.5.dist-info → ler-0.3.6.dist-info}/top_level.txt +0 -0
ler/__init__.py
CHANGED
|
@@ -342,7 +342,7 @@ class ImageProperties():
|
|
|
342
342
|
|
|
343
343
|
return lens_parameters
|
|
344
344
|
|
|
345
|
-
def get_lensed_snrs(self,
|
|
345
|
+
def get_lensed_snrs(self, lensed_param, list_of_detectors=None, snr_calculator=None, pdet_calculator=None):
|
|
346
346
|
"""
|
|
347
347
|
Function to calculate the signal to noise ratio for each image in each event.
|
|
348
348
|
|
|
@@ -403,14 +403,27 @@ class ImageProperties():
|
|
|
403
403
|
)
|
|
404
404
|
|
|
405
405
|
# setting up snr dictionary
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
406
|
+
result_dict = dict()
|
|
407
|
+
if snr_calculator:
|
|
408
|
+
result_dict["optimal_snr_net"] = (
|
|
409
|
+
np.ones((number_of_lensed_events, n_max_images)) * np.nan
|
|
410
|
+
)
|
|
411
|
+
# setting up pdet dictionary
|
|
412
|
+
elif pdet_calculator:
|
|
413
|
+
result_dict["pdet_net"] = (
|
|
412
414
|
np.ones((number_of_lensed_events, n_max_images)) * np.nan
|
|
413
415
|
)
|
|
416
|
+
else:
|
|
417
|
+
raise ValueError("snr_calculator or pdet_calculator not given")
|
|
418
|
+
|
|
419
|
+
# if detector list are provided for snr or pdet calculation
|
|
420
|
+
if list_of_detectors:
|
|
421
|
+
for detector in list_of_detectors:
|
|
422
|
+
result_dict[detector] = (
|
|
423
|
+
np.ones((number_of_lensed_events, n_max_images)) * np.nan
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
|
|
414
427
|
|
|
415
428
|
# for updating the lensed_param
|
|
416
429
|
lensed_param["effective_luminosity_distance"] = np.ones((number_of_lensed_events, n_max_images)) * np.nan
|
|
@@ -435,33 +448,65 @@ class ImageProperties():
|
|
|
435
448
|
# Each image has their own effective luminosity distance and effective geocent time
|
|
436
449
|
if len(effective_luminosity_distance) != 0:
|
|
437
450
|
# Returns a dictionary
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
451
|
+
if snr_calculator:
|
|
452
|
+
optimal_snr = snr_calculator(
|
|
453
|
+
gw_param_dict= dict(
|
|
454
|
+
mass_1=mass_1[idx],
|
|
455
|
+
mass_2=mass_2[idx],
|
|
456
|
+
luminosity_distance=effective_luminosity_distance[idx],
|
|
457
|
+
theta_jn=theta_jn[idx],
|
|
458
|
+
psi=psi[idx],
|
|
459
|
+
phase=phase[idx],
|
|
460
|
+
geocent_time=effective_geocent_time[idx],
|
|
461
|
+
ra=ra[idx],
|
|
462
|
+
dec=dec[idx],
|
|
463
|
+
a_1=a_1[idx],
|
|
464
|
+
a_2=a_2[idx],
|
|
465
|
+
tilt_1=tilt_1[idx],
|
|
466
|
+
tilt_2=tilt_2[idx],
|
|
467
|
+
phi_12=phi_12[idx],
|
|
468
|
+
phi_jl=phi_jl[idx],
|
|
469
|
+
),
|
|
470
|
+
output_jsonfile=False,
|
|
471
|
+
)
|
|
472
|
+
result_dict["optimal_snr_net"][idx, i] = optimal_snr["optimal_snr_net"]
|
|
473
|
+
|
|
474
|
+
if list_of_detectors:
|
|
475
|
+
for detector in list_of_detectors:
|
|
476
|
+
result_dict[detector][idx, i] = optimal_snr[detector]
|
|
477
|
+
|
|
478
|
+
elif pdet_calculator:
|
|
479
|
+
pdet = pdet_calculator(
|
|
480
|
+
gw_param_dict= dict(
|
|
481
|
+
mass_1=mass_1[idx],
|
|
482
|
+
mass_2=mass_2[idx],
|
|
483
|
+
luminosity_distance=effective_luminosity_distance[idx],
|
|
484
|
+
theta_jn=theta_jn[idx],
|
|
485
|
+
psi=psi[idx],
|
|
486
|
+
phase=phase[idx],
|
|
487
|
+
geocent_time=effective_geocent_time[idx],
|
|
488
|
+
ra=ra[idx],
|
|
489
|
+
dec=dec[idx],
|
|
490
|
+
a_1=a_1[idx],
|
|
491
|
+
a_2=a_2[idx],
|
|
492
|
+
tilt_1=tilt_1[idx],
|
|
493
|
+
tilt_2=tilt_2[idx],
|
|
494
|
+
phi_12=phi_12[idx],
|
|
495
|
+
phi_jl=phi_jl[idx],
|
|
496
|
+
),
|
|
497
|
+
output_jsonfile=False,
|
|
498
|
+
)
|
|
499
|
+
result_dict["pdet_net"][idx, i] = pdet["pdet_net"]
|
|
500
|
+
|
|
501
|
+
if list_of_detectors:
|
|
502
|
+
for detector in list_of_detectors:
|
|
503
|
+
result_dict[detector][idx, i] = pdet[detector]
|
|
504
|
+
|
|
460
505
|
|
|
461
506
|
lensed_param["effective_luminosity_distance"][:, i] = effective_luminosity_distance
|
|
462
507
|
lensed_param["effective_geocent_time"][:, i] = effective_geocent_time
|
|
463
508
|
|
|
464
|
-
lensed_param["luminosity_distance"]
|
|
465
|
-
lensed_param["geocent_time"]
|
|
509
|
+
del lensed_param["luminosity_distance"]
|
|
510
|
+
del lensed_param["geocent_time"]
|
|
466
511
|
|
|
467
|
-
return
|
|
512
|
+
return result_dict, lensed_param
|
ler/rates/gwrates.py
CHANGED
|
@@ -186,9 +186,11 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
186
186
|
z_max=10.0,
|
|
187
187
|
event_type="BBH",
|
|
188
188
|
size=100000,
|
|
189
|
-
batch_size=
|
|
189
|
+
batch_size=50000,
|
|
190
190
|
cosmology=None,
|
|
191
|
-
snr_finder=
|
|
191
|
+
snr_finder=None,
|
|
192
|
+
pdet_finder=None,
|
|
193
|
+
list_of_detectors=None,
|
|
192
194
|
json_file_names=None,
|
|
193
195
|
interpolator_directory="./interpolator_pickle",
|
|
194
196
|
ler_directory="./ler_data",
|
|
@@ -215,12 +217,18 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
215
217
|
def initialization():
|
|
216
218
|
# initialization of parent class
|
|
217
219
|
self.class_initialization(params=kwargs)
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
# initialization self.snr and self.pdet from GWSNR class
|
|
221
|
+
if not snr_finder and not pdet_finder:
|
|
220
222
|
self.gwsnr_intialization(params=kwargs)
|
|
223
|
+
self.gwsnr = True
|
|
224
|
+
self.pdet = pdet_finder
|
|
221
225
|
else:
|
|
222
226
|
self.snr = snr_finder
|
|
227
|
+
self.pdet = pdet_finder
|
|
228
|
+
self.gwsnr = False
|
|
229
|
+
self.list_of_detectors = list_of_detectors
|
|
223
230
|
|
|
231
|
+
# store all the gwrates input parameters
|
|
224
232
|
self.store_gwrates_params(output_jsonfile=self.json_file_names["gwrates_param"])
|
|
225
233
|
|
|
226
234
|
if verbose:
|
|
@@ -229,7 +237,6 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
229
237
|
else:
|
|
230
238
|
with contextlib.redirect_stdout(None):
|
|
231
239
|
initialization()
|
|
232
|
-
|
|
233
240
|
|
|
234
241
|
def print_all_params(self):
|
|
235
242
|
"""
|
|
@@ -245,9 +252,13 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
245
252
|
print("size = ", self.size)
|
|
246
253
|
print("batch_size = ", self.batch_size)
|
|
247
254
|
print("cosmology = ", self.cosmo)
|
|
248
|
-
|
|
255
|
+
if self.snr:
|
|
256
|
+
print("snr_finder = ", self.snr)
|
|
257
|
+
if self.pdet:
|
|
258
|
+
print("pdet_finder = ", self.pdet)
|
|
249
259
|
print("json_file_names = ", self.json_file_names)
|
|
250
260
|
print("interpolator_directory = ", self.interpolator_directory)
|
|
261
|
+
print("ler_directory = ", self.ler_directory)
|
|
251
262
|
|
|
252
263
|
print("\n GWRATES also takes CBCSourceParameterDistribution params as kwargs, as follows:")
|
|
253
264
|
print("source_priors=", self.gw_param_sampler_dict["source_priors"])
|
|
@@ -256,24 +267,26 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
256
267
|
print("spin_precession=", self.gw_param_sampler_dict["spin_precession"])
|
|
257
268
|
print("create_new_interpolator=", self.gw_param_sampler_dict["create_new_interpolator"])
|
|
258
269
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
270
|
+
if self.gwsnr:
|
|
271
|
+
print("\n GWRATES also takes GWSNR params as kwargs, as follows:")
|
|
272
|
+
print("mtot_min = ", self.snr_calculator_dict["mtot_min"])
|
|
273
|
+
print("mtot_max = ", self.snr_calculator_dict["mtot_max"])
|
|
274
|
+
print("ratio_min = ", self.snr_calculator_dict["ratio_min"])
|
|
275
|
+
print("ratio_max = ", self.snr_calculator_dict["ratio_max"])
|
|
276
|
+
print("mtot_resolution = ", self.snr_calculator_dict["mtot_resolution"])
|
|
277
|
+
print("ratio_resolution = ", self.snr_calculator_dict["ratio_resolution"])
|
|
278
|
+
print("sampling_frequency = ", self.snr_calculator_dict["sampling_frequency"])
|
|
279
|
+
print("waveform_approximant = ", self.snr_calculator_dict["waveform_approximant"])
|
|
280
|
+
print("minimum_frequency = ", self.snr_calculator_dict["minimum_frequency"])
|
|
281
|
+
print("snr_type = ", self.snr_calculator_dict["snr_type"])
|
|
282
|
+
print("psds = ", self.snr_calculator_dict["psds"])
|
|
283
|
+
print("ifos = ", self.snr_calculator_dict["ifos"])
|
|
284
|
+
print("interpolator_dir = ", self.snr_calculator_dict["interpolator_dir"])
|
|
285
|
+
print("create_new_interpolator = ", self.snr_calculator_dict["create_new_interpolator"])
|
|
286
|
+
print("gwsnr_verbose = ", self.snr_calculator_dict["gwsnr_verbose"])
|
|
287
|
+
print("multiprocessing_verbose = ", self.snr_calculator_dict["multiprocessing_verbose"])
|
|
288
|
+
print("mtot_cut = ", self.snr_calculator_dict["mtot_cut"])
|
|
289
|
+
del self.gwsnr
|
|
277
290
|
|
|
278
291
|
print("\n For reference, the chosen source parameters are listed below:")
|
|
279
292
|
print("merger_rate_density = ", self.gw_param_samplers["merger_rate_density"])
|
|
@@ -416,10 +429,11 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
416
429
|
input_params = dict(
|
|
417
430
|
z_min=self.z_min,
|
|
418
431
|
z_max=self.z_max,
|
|
432
|
+
cosmology=self.cosmo,
|
|
419
433
|
event_type=self.event_type,
|
|
420
434
|
source_priors=None,
|
|
421
435
|
source_priors_params=None,
|
|
422
|
-
|
|
436
|
+
|
|
423
437
|
spin_zero=True,
|
|
424
438
|
spin_precession=False,
|
|
425
439
|
interpolator_directory=self.interpolator_directory,
|
|
@@ -557,7 +571,7 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
557
571
|
pass
|
|
558
572
|
|
|
559
573
|
def gw_cbc_statistics(
|
|
560
|
-
self, size=None, resume=False, save_batch=
|
|
574
|
+
self, size=None, resume=False, save_batch=False, output_jsonfile=None,
|
|
561
575
|
):
|
|
562
576
|
"""
|
|
563
577
|
Function to generate gw GW source parameters. This function also stores the parameters in json file.
|
|
@@ -593,7 +607,7 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
593
607
|
output_jsonfile = output_jsonfile or self.json_file_names["gw_param"]
|
|
594
608
|
self.json_file_names["gw_param"] = output_jsonfile
|
|
595
609
|
output_path = os.path.join(self.ler_directory, output_jsonfile)
|
|
596
|
-
print(f"Simulated GW params will be stored in {
|
|
610
|
+
print(f"Simulated GW params will be stored in {output_path}")
|
|
597
611
|
|
|
598
612
|
# sampling in batches
|
|
599
613
|
if resume and os.path.exists(output_path):
|
|
@@ -621,7 +635,7 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
621
635
|
print(f"saving all gw_params in {output_path}...")
|
|
622
636
|
append_json(output_path, gw_param, replace=True)
|
|
623
637
|
else:
|
|
624
|
-
print("
|
|
638
|
+
print("gw_params already sampled.")
|
|
625
639
|
gw_param = get_param_from_json(output_path)
|
|
626
640
|
self.dict_buffer = None # save memory
|
|
627
641
|
|
|
@@ -654,9 +668,14 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
654
668
|
print("sampling gw source params...")
|
|
655
669
|
gw_param = self.sample_gw_parameters(size=size)
|
|
656
670
|
# Get all of the signal to noise ratios
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
671
|
+
if self.snr:
|
|
672
|
+
print("calculating snrs...")
|
|
673
|
+
snrs = self.snr(gw_param_dict=gw_param)
|
|
674
|
+
gw_param.update(snrs)
|
|
675
|
+
elif self.pdet:
|
|
676
|
+
print("calculating pdet...")
|
|
677
|
+
pdet = self.pdet(gw_param_dict=gw_param)
|
|
678
|
+
gw_param.update(pdet)
|
|
660
679
|
|
|
661
680
|
# adding batches
|
|
662
681
|
if not save_batch:
|
|
@@ -727,7 +746,8 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
727
746
|
gw_param = self.json_file_names["gw_param"]
|
|
728
747
|
if type(gw_param) == str:
|
|
729
748
|
self.json_file_names["gw_param"] = gw_param
|
|
730
|
-
|
|
749
|
+
path_ = self.ler_directory+"/"+gw_param
|
|
750
|
+
print(f"getting gw_params from json file {path_}...")
|
|
731
751
|
gw_param = get_param_from_json(self.ler_directory+"/"+gw_param)
|
|
732
752
|
else:
|
|
733
753
|
print("using provided gw_param dict...")
|
|
@@ -748,29 +768,30 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
748
768
|
# recalculate more accurate snrs
|
|
749
769
|
snrs = self.snr_bilby(gw_param_dict=gw_param)
|
|
750
770
|
gw_param.update(snrs)
|
|
751
|
-
|
|
752
|
-
if
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
print("
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
771
|
+
|
|
772
|
+
if self.snr:
|
|
773
|
+
if "optimal_snr_net" not in gw_param:
|
|
774
|
+
raise ValueError("'optimal_snr_net' not in gw parm dict provided")
|
|
775
|
+
if detectability_condition == "step_function":
|
|
776
|
+
print("given detectability_condition == 'step_function'")
|
|
777
|
+
param = gw_param["optimal_snr_net"]
|
|
778
|
+
threshold = snr_threshold
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
elif detectability_condition == "pdet":
|
|
782
|
+
print("given detectability_condition == 'pdet'")
|
|
783
|
+
param = 1 - norm.cdf(snr_threshold - gw_param["optimal_snr_net"])
|
|
784
|
+
gw_param["pdet_net"] = param
|
|
785
|
+
threshold = 0.5
|
|
786
|
+
elif self.pdet:
|
|
787
|
+
if "pdet_net" in gw_param:
|
|
788
|
+
print("given detectability_condition == 'pdet'")
|
|
789
|
+
param = gw_param["pdet_net"]
|
|
790
|
+
threshold = 0.5
|
|
764
791
|
else:
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
else:
|
|
769
|
-
print("pdet or optimal_snr_net not provided in gw_param dict. Exiting...")
|
|
770
|
-
return None
|
|
771
|
-
threshold = 0.5
|
|
772
|
-
|
|
773
|
-
idx_detectable = snr_param > threshold
|
|
792
|
+
raise ValueError("'pdet_net' not in gw parm dict provided")
|
|
793
|
+
|
|
794
|
+
idx_detectable = param > threshold
|
|
774
795
|
detectable_events = np.sum(idx_detectable)
|
|
775
796
|
# montecarlo integration
|
|
776
797
|
# The total rate R = norm <Theta(rho-rhoc)>
|
|
@@ -788,7 +809,8 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
788
809
|
output_jsonfile = self.json_file_names["gw_param_detectable"]
|
|
789
810
|
else:
|
|
790
811
|
self.json_file_names["gw_param_detectable"] = output_jsonfile
|
|
791
|
-
|
|
812
|
+
path_ = self.ler_directory+"/"+output_jsonfile
|
|
813
|
+
print(f"storing detectable gw params in {path_}")
|
|
792
814
|
append_json(self.ler_directory+"/"+output_jsonfile, gw_param, replace=True)
|
|
793
815
|
|
|
794
816
|
# write the results
|
|
@@ -866,7 +888,7 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
866
888
|
events_total = 0
|
|
867
889
|
|
|
868
890
|
buffer_file = self.ler_directory+"/"+"gw_params_buffer.json"
|
|
869
|
-
print("collected number of events = ", n)
|
|
891
|
+
print("collected number of detectable events = ", n)
|
|
870
892
|
# loop until n samples are collected
|
|
871
893
|
while n < size:
|
|
872
894
|
# disable print statements
|
|
@@ -897,7 +919,7 @@ class GWRATES(CBCSourceParameterDistribution):
|
|
|
897
919
|
else:
|
|
898
920
|
append_json(file_name=meta_data_path, new_dictionary=meta_data, replace=True)
|
|
899
921
|
|
|
900
|
-
print("collected number of events = ", n)
|
|
922
|
+
print("collected number of detectable events = ", n)
|
|
901
923
|
print("total number of events = ", events_total)
|
|
902
924
|
print(f"total gw rate (yr^-1): {total_rate}")
|
|
903
925
|
|
ler/rates/ler.py
CHANGED
|
@@ -40,12 +40,12 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
40
40
|
recommended batch_size = 50000, if size = 1000000.
|
|
41
41
|
snr_finder : `str`
|
|
42
42
|
default snr_finder = 'gwsnr'.
|
|
43
|
-
if
|
|
43
|
+
if None, the SNR will be calculated using the gwsnr package.
|
|
44
44
|
if 'custom', the SNR will be calculated using a custom function.
|
|
45
45
|
The custom function should have input and output as given in GWSNR.snr method.
|
|
46
46
|
json_file_names: `dict`
|
|
47
47
|
names of the json files to strore the necessary parameters.
|
|
48
|
-
default json_file_names = {'
|
|
48
|
+
default json_file_names = {'ler_params': 'LeR_params.json', 'unlensed_param': 'unlensed_param.json', 'unlensed_param_detectable': 'unlensed_param_detectable.json'}.\n
|
|
49
49
|
kwargs : `keyword arguments`
|
|
50
50
|
Note : kwargs takes input for initializing the :class:`~ler.lens_galaxy_population.LensGalaxyParameterDistribution`, :meth:`~gwsnr_intialization`.
|
|
51
51
|
|
|
@@ -239,7 +239,9 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
239
239
|
size=100000,
|
|
240
240
|
batch_size=50000,
|
|
241
241
|
cosmology=None,
|
|
242
|
-
snr_finder=
|
|
242
|
+
snr_finder=None,
|
|
243
|
+
pdet_finder=None,
|
|
244
|
+
list_of_detectors=None,
|
|
243
245
|
json_file_names=None,
|
|
244
246
|
interpolator_directory="./interpolator_pickle",
|
|
245
247
|
ler_directory="./ler_data",
|
|
@@ -254,7 +256,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
254
256
|
self.cosmo = cosmology if cosmology else LambdaCDM(H0=70, Om0=0.3, Ode0=0.7)
|
|
255
257
|
self.size = size
|
|
256
258
|
self.batch_size = batch_size
|
|
257
|
-
self.json_file_names = dict(
|
|
259
|
+
self.json_file_names = dict(ler_params="ler_params.json", unlensed_param="unlensed_param.json", unlensed_param_detectable="unlensed_param_detectable.json", lensed_param="lensed_param.json", lensed_param_detectable="lensed_param_detectable.json")
|
|
258
260
|
if json_file_names:
|
|
259
261
|
self.json_file_names.update(json_file_names)
|
|
260
262
|
self.interpolator_directory = interpolator_directory
|
|
@@ -266,13 +268,19 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
266
268
|
def initialization():
|
|
267
269
|
# initialization of parent class
|
|
268
270
|
self.class_initialization(params=kwargs)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
+
# initialization self.snr and self.pdet from GWSNR class
|
|
272
|
+
if not snr_finder and not pdet_finder:
|
|
271
273
|
self.gwsnr_intialization(params=kwargs)
|
|
274
|
+
self.gwsnr = True
|
|
275
|
+
self.pdet = pdet_finder
|
|
272
276
|
else:
|
|
273
277
|
self.snr = snr_finder
|
|
278
|
+
self.pdet = pdet_finder
|
|
279
|
+
self.gwsnr = False
|
|
280
|
+
self.list_of_detectors = list_of_detectors
|
|
281
|
+
|
|
274
282
|
# store all the ler input parameters
|
|
275
|
-
self.store_ler_params(output_jsonfile=self.json_file_names["
|
|
283
|
+
self.store_ler_params(output_jsonfile=self.json_file_names["ler_params"])
|
|
276
284
|
|
|
277
285
|
# if verbose, prevent anything from printing
|
|
278
286
|
if verbose:
|
|
@@ -296,7 +304,10 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
296
304
|
print("size = ", self.size)
|
|
297
305
|
print("batch_size = ", self.batch_size)
|
|
298
306
|
print("cosmology = ", self.cosmo)
|
|
299
|
-
|
|
307
|
+
if self.snr:
|
|
308
|
+
print("snr_finder = ", self.snr)
|
|
309
|
+
if self.pdet:
|
|
310
|
+
print("pdet_finder = ", self.pdet)
|
|
300
311
|
print("json_file_names = ", self.json_file_names)
|
|
301
312
|
print("interpolator_directory = ", self.interpolator_directory)
|
|
302
313
|
print("ler_directory = ", self.ler_directory)
|
|
@@ -321,24 +332,26 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
321
332
|
print("geocent_time_max = ", self.geocent_time_max)
|
|
322
333
|
print("lens_model_list = ", self.lens_model_list)
|
|
323
334
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
335
|
+
if self.gwsnr:
|
|
336
|
+
print("\n LeR also takes gwsnr.GWSNR params as kwargs, as follows:")
|
|
337
|
+
print("mtot_min = ", self.snr_calculator_dict["mtot_min"])
|
|
338
|
+
print("mtot_max = ", self.snr_calculator_dict["mtot_max"])
|
|
339
|
+
print("ratio_min = ", self.snr_calculator_dict["ratio_min"])
|
|
340
|
+
print("ratio_max = ", self.snr_calculator_dict["ratio_max"])
|
|
341
|
+
print("mtot_resolution = ", self.snr_calculator_dict["mtot_resolution"])
|
|
342
|
+
print("ratio_resolution = ", self.snr_calculator_dict["ratio_resolution"])
|
|
343
|
+
print("sampling_frequency = ", self.snr_calculator_dict["sampling_frequency"])
|
|
344
|
+
print("waveform_approximant = ", self.snr_calculator_dict["waveform_approximant"])
|
|
345
|
+
print("minimum_frequency = ", self.snr_calculator_dict["minimum_frequency"])
|
|
346
|
+
print("snr_type = ", self.snr_calculator_dict["snr_type"])
|
|
347
|
+
print("psds = ", self.snr_calculator_dict["psds"])
|
|
348
|
+
print("ifos = ", self.snr_calculator_dict["ifos"])
|
|
349
|
+
print("interpolator_dir = ", self.snr_calculator_dict["interpolator_dir"])
|
|
350
|
+
print("create_new_interpolator = ", self.snr_calculator_dict["create_new_interpolator"])
|
|
351
|
+
print("gwsnr_verbose = ", self.snr_calculator_dict["gwsnr_verbose"])
|
|
352
|
+
print("multiprocessing_verbose = ", self.snr_calculator_dict["multiprocessing_verbose"])
|
|
353
|
+
print("mtot_cut = ", self.snr_calculator_dict["mtot_cut"])
|
|
354
|
+
del self.gwsnr
|
|
342
355
|
|
|
343
356
|
print("\n For reference, the chosen source parameters are listed below:")
|
|
344
357
|
print("merger_rate_density = ", self.gw_param_samplers["merger_rate_density"])
|
|
@@ -461,7 +474,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
461
474
|
dictionary of unlensed GW source parameters.
|
|
462
475
|
"""
|
|
463
476
|
|
|
464
|
-
return get_param_from_json(self.json_file_names["unlensed_param"])
|
|
477
|
+
return get_param_from_json(self.ler_directory+"/"+self.json_file_names["unlensed_param"])
|
|
465
478
|
|
|
466
479
|
@property
|
|
467
480
|
def unlensed_param_detectable(self):
|
|
@@ -474,7 +487,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
474
487
|
dictionary of unlensed GW source parameters.
|
|
475
488
|
"""
|
|
476
489
|
|
|
477
|
-
return get_param_from_json(self.json_file_names["unlensed_param_detectable"])
|
|
490
|
+
return get_param_from_json(self.ler_directory+"/"+self.json_file_names["unlensed_param_detectable"])
|
|
478
491
|
|
|
479
492
|
@property
|
|
480
493
|
def lensed_param(self):
|
|
@@ -487,7 +500,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
487
500
|
dictionary of lensed GW source parameters.
|
|
488
501
|
"""
|
|
489
502
|
|
|
490
|
-
return get_param_from_json(self.json_file_names["lensed_param"])
|
|
503
|
+
return get_param_from_json(self.ler_directory+"/"+self.json_file_names["lensed_param"])
|
|
491
504
|
|
|
492
505
|
@property
|
|
493
506
|
def lensed_param_detectable(self):
|
|
@@ -500,7 +513,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
500
513
|
dictionary of lensed GW source parameters.
|
|
501
514
|
"""
|
|
502
515
|
|
|
503
|
-
return get_param_from_json(self.json_file_names["lensed_param_detectable"])
|
|
516
|
+
return get_param_from_json(self.ler_directory+"/"+self.json_file_names["lensed_param_detectable"])
|
|
504
517
|
|
|
505
518
|
def class_initialization(self, params=None):
|
|
506
519
|
"""
|
|
@@ -636,7 +649,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
636
649
|
self.snr_bilby = gwsnr.compute_bilby_snr
|
|
637
650
|
self.snr_calculator_dict["mtot_max"] = gwsnr.mtot_max
|
|
638
651
|
self.snr_calculator_dict["psds"] = gwsnr.psds_list
|
|
639
|
-
#self.pdet = gwsnr.pdet
|
|
652
|
+
# self.pdet = gwsnr.pdet
|
|
640
653
|
|
|
641
654
|
def store_ler_params(self, output_jsonfile="ler_params.json"):
|
|
642
655
|
"""
|
|
@@ -659,7 +672,6 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
659
672
|
snr_finder=str(self.snr),
|
|
660
673
|
json_file_names=str(self.json_file_names),
|
|
661
674
|
interpolator_directory=str(self.interpolator_directory),
|
|
662
|
-
ler_directory=str(self.ler_directory),
|
|
663
675
|
)
|
|
664
676
|
|
|
665
677
|
# cbc params
|
|
@@ -719,7 +731,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
719
731
|
output_jsonfile = output_jsonfile or self.json_file_names["unlensed_param"]
|
|
720
732
|
self.json_file_names["unlensed_param"] = output_jsonfile
|
|
721
733
|
output_path = os.path.join(self.ler_directory, output_jsonfile)
|
|
722
|
-
print(f"unlensed params will be store in {
|
|
734
|
+
print(f"unlensed params will be store in {output_path}")
|
|
723
735
|
|
|
724
736
|
# sampling in batches
|
|
725
737
|
if resume and os.path.exists(output_path):
|
|
@@ -780,9 +792,14 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
780
792
|
print("sampling gw source params...")
|
|
781
793
|
unlensed_param = self.sample_gw_parameters(size=size)
|
|
782
794
|
# Get all of the signal to noise ratios
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
795
|
+
if self.snr:
|
|
796
|
+
print("calculating snrs...")
|
|
797
|
+
snrs = self.snr(gw_param_dict=unlensed_param)
|
|
798
|
+
unlensed_param.update(snrs)
|
|
799
|
+
elif self.pdet:
|
|
800
|
+
print("calculating pdet...")
|
|
801
|
+
pdet = self.pdet(gw_param_dict=unlensed_param)
|
|
802
|
+
unlensed_param.update(pdet)
|
|
786
803
|
|
|
787
804
|
# adding batches
|
|
788
805
|
if not save_batch:
|
|
@@ -847,14 +864,15 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
847
864
|
"""
|
|
848
865
|
|
|
849
866
|
# call self.json_file_names["ler_param"] and for adding the final results
|
|
850
|
-
data = load_json(self.ler_directory+"/"+self.json_file_names["
|
|
867
|
+
data = load_json(self.ler_directory+"/"+self.json_file_names["ler_params"])
|
|
851
868
|
|
|
852
869
|
# get gw params from json file if not provided
|
|
853
870
|
if unlensed_param is None:
|
|
854
871
|
unlensed_param = self.json_file_names["unlensed_param"]
|
|
855
872
|
if type(unlensed_param) == str:
|
|
856
873
|
self.json_file_names["unlensed_param"] = unlensed_param
|
|
857
|
-
|
|
874
|
+
path_ = self.ler_directory+"/"+unlensed_param
|
|
875
|
+
print(f"getting unlensed_params from json file {path_}...")
|
|
858
876
|
unlensed_param = get_param_from_json(self.ler_directory+"/"+unlensed_param)
|
|
859
877
|
else:
|
|
860
878
|
print("using provided unlensed_param dict...")
|
|
@@ -875,22 +893,25 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
875
893
|
snrs = self.snr_bilby(gw_param_dict=unlensed_param)
|
|
876
894
|
unlensed_param.update(snrs)
|
|
877
895
|
|
|
878
|
-
if
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
896
|
+
if self.snr:
|
|
897
|
+
if "optimal_snr_net" not in unlensed_param:
|
|
898
|
+
raise ValueError("'optimal_snr_net' not in unlensed parm dict provided")
|
|
899
|
+
if detectability_condition == "step_function":
|
|
900
|
+
print("given detectability_condition == 'step_function'")
|
|
901
|
+
param = unlensed_param["optimal_snr_net"]
|
|
902
|
+
threshold = snr_threshold
|
|
903
|
+
elif detectability_condition == "pdet":
|
|
904
|
+
print("given detectability_condition == 'pdet'")
|
|
905
|
+
param = 1 - norm.cdf(snr_threshold - unlensed_param["optimal_snr_net"])
|
|
906
|
+
unlensed_param["pdet_net"] = param
|
|
907
|
+
threshold = 0.5
|
|
908
|
+
elif self.pdet:
|
|
909
|
+
if "pdet_net" in unlensed_param:
|
|
910
|
+
print("given detectability_condition == 'pdet'")
|
|
885
911
|
param = unlensed_param["pdet_net"]
|
|
912
|
+
threshold = 0.5
|
|
886
913
|
else:
|
|
887
|
-
|
|
888
|
-
param = 1 - norm.cdf(snr_threshold - unlensed_param["optimal_snr_net"])
|
|
889
|
-
unlensed_param["pdet_net"] = param
|
|
890
|
-
else:
|
|
891
|
-
print("pdet or optimal_snr_net not provided in unlensed_param dict. Exiting...")
|
|
892
|
-
return None
|
|
893
|
-
threshold = 0.5
|
|
914
|
+
raise ValueError("'pdet_net' not in unlensed parm dict provided")
|
|
894
915
|
|
|
895
916
|
idx_detectable = param > threshold
|
|
896
917
|
detectable_events = np.sum(idx_detectable)
|
|
@@ -910,18 +931,19 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
910
931
|
output_jsonfile = self.json_file_names["unlensed_param_detectable"]
|
|
911
932
|
else:
|
|
912
933
|
self.json_file_names["unlensed_param_detectable"] = output_jsonfile
|
|
913
|
-
|
|
934
|
+
path_ = self.ler_directory+"/"+output_jsonfile
|
|
935
|
+
print(f"storing detectable unlensed params in {path_}")
|
|
914
936
|
append_json(self.ler_directory+"/"+output_jsonfile, unlensed_param, replace=True)
|
|
915
937
|
|
|
916
938
|
# write the results
|
|
917
939
|
data["detectable_unlensed_rate_per_year"] = total_rate
|
|
918
940
|
data["detectability_condition"] = detectability_condition
|
|
919
|
-
append_json(self.ler_directory+"/"+self.json_file_names["
|
|
941
|
+
append_json(self.ler_directory+"/"+self.json_file_names["ler_params"], data, replace=True)
|
|
920
942
|
|
|
921
943
|
return total_rate, unlensed_param
|
|
922
944
|
|
|
923
945
|
def lensed_cbc_statistics(
|
|
924
|
-
self, size=None, save_batch=
|
|
946
|
+
self, size=None, save_batch=False, resume=False, output_jsonfile=None,
|
|
925
947
|
):
|
|
926
948
|
"""
|
|
927
949
|
Function to generate lensed GW source parameters. This function also stores the parameters in json file.
|
|
@@ -955,7 +977,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
955
977
|
output_jsonfile = output_jsonfile or self.json_file_names["lensed_param"]
|
|
956
978
|
self.json_file_names["lensed_param"] = output_jsonfile
|
|
957
979
|
output_path = os.path.join(self.ler_directory, output_jsonfile)
|
|
958
|
-
print(f"lensed params will be store in {
|
|
980
|
+
print(f"lensed params will be store in {output_path}")
|
|
959
981
|
|
|
960
982
|
# sampling in batches
|
|
961
983
|
if resume and os.path.exists(output_path):
|
|
@@ -1039,13 +1061,23 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1039
1061
|
size = np.sum(idx)
|
|
1040
1062
|
|
|
1041
1063
|
# Get all of the signal to noise ratios
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1064
|
+
if self.snr:
|
|
1065
|
+
print("calculating snrs...")
|
|
1066
|
+
snrs, lensed_param = self.get_lensed_snrs(
|
|
1067
|
+
lensed_param=lensed_param,
|
|
1068
|
+
list_of_detectors=self.list_of_detectors,
|
|
1069
|
+
snr_calculator=self.snr,
|
|
1070
|
+
)
|
|
1071
|
+
lensed_param.update(snrs)
|
|
1072
|
+
|
|
1073
|
+
elif self.pdet:
|
|
1074
|
+
print("calculating pdet...")
|
|
1075
|
+
pdet, lensed_param = self.get_lensed_snrs(
|
|
1076
|
+
lensed_param=lensed_param,
|
|
1077
|
+
list_of_detectors=self.list_of_detectors,
|
|
1078
|
+
pdet_calculator=self.pdet,
|
|
1079
|
+
)
|
|
1080
|
+
lensed_param.update(pdet)
|
|
1049
1081
|
|
|
1050
1082
|
# adding batches
|
|
1051
1083
|
if not save_batch:
|
|
@@ -1118,14 +1150,15 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1118
1150
|
"""
|
|
1119
1151
|
|
|
1120
1152
|
# call self.json_file_names["ler_param"] and for adding the final results
|
|
1121
|
-
data = load_json(self.ler_directory+"/"+self.json_file_names["
|
|
1153
|
+
data = load_json(self.ler_directory+"/"+self.json_file_names["ler_params"])
|
|
1122
1154
|
|
|
1123
1155
|
# get gw params from json file if not provided
|
|
1124
1156
|
if lensed_param is None:
|
|
1125
1157
|
lensed_param = self.json_file_names["lensed_param"]
|
|
1126
1158
|
if type(lensed_param) == str:
|
|
1127
1159
|
self.json_file_names["lensed_param"] = lensed_param
|
|
1128
|
-
|
|
1160
|
+
path_ = self.ler_directory+"/"+lensed_param
|
|
1161
|
+
print(f"getting lensed_params from json file {path_}...")
|
|
1129
1162
|
lensed_param = get_param_from_json(self.ler_directory+"/"+lensed_param)
|
|
1130
1163
|
else:
|
|
1131
1164
|
print("using provided lensed_param dict...")
|
|
@@ -1180,55 +1213,66 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1180
1213
|
)
|
|
1181
1214
|
lensed_param.update(snrs)
|
|
1182
1215
|
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1216
|
+
if self.snr:
|
|
1217
|
+
if "optimal_snr_net" not in lensed_param:
|
|
1218
|
+
raise ValueError("'optimal_snr_net' not in lensed parm dict provided")
|
|
1219
|
+
if detectability_condition == "step_function":
|
|
1220
|
+
print("given detectability_condition == 'step_function'")
|
|
1221
|
+
|
|
1222
|
+
if "optimal_snr_net" in lensed_param.keys():
|
|
1223
|
+
snr_param = lensed_param["optimal_snr_net"]
|
|
1224
|
+
snr_param = -np.sort(-snr_param, axis=1) # sort snr in descending order
|
|
1225
|
+
else:
|
|
1226
|
+
print("snr not provided in lensed_param dict. Exiting...")
|
|
1227
|
+
return None
|
|
1228
|
+
snr_hit = np.full(len(snr_param), True) # boolean array to store the result of the threshold condition
|
|
1229
|
+
|
|
1230
|
+
# for each row: choose a threshold and check if the number of images above threshold. Sum over the images. If sum is greater than num_img, then snr_hit = True
|
|
1231
|
+
j = 0
|
|
1232
|
+
idx_max = 0
|
|
1233
|
+
for i in range(len(snr_threshold)):
|
|
1234
|
+
idx_max = idx_max + num_img[i]
|
|
1235
|
+
snr_hit = snr_hit & (np.sum((snr_param[:,j:idx_max] > snr_threshold[i]), axis=1) >= num_img[i])
|
|
1236
|
+
j = idx_max
|
|
1237
|
+
|
|
1238
|
+
# montecarlo integration
|
|
1239
|
+
total_rate = self.normalization_pdf_z_lensed * np.sum(snr_hit)/total_events
|
|
1240
|
+
print("total lensed rate (yr^-1) (with step function): {}".format(total_rate))
|
|
1241
|
+
|
|
1242
|
+
elif detectability_condition == "pdet":
|
|
1243
|
+
print("given detectability_condition == 'pdet'")
|
|
1244
|
+
# pdet dimension is (size, n_max_images)
|
|
1186
1245
|
snr_param = lensed_param["optimal_snr_net"]
|
|
1187
1246
|
snr_param = -np.sort(-snr_param, axis=1) # sort snr in descending order
|
|
1188
|
-
else:
|
|
1189
|
-
print("snr not provided in lensed_param dict. Exiting...")
|
|
1190
|
-
return None
|
|
1191
|
-
snr_hit = np.full(len(snr_param), True) # boolean array to store the result of the threshold condition
|
|
1192
|
-
|
|
1193
|
-
# for each row: choose a threshold and check if the number of images above threshold. Sum over the images. If sum is greater than num_img, then snr_hit = True
|
|
1194
|
-
j = 0
|
|
1195
|
-
idx_max = 0
|
|
1196
|
-
for i in range(len(snr_threshold)):
|
|
1197
|
-
idx_max = idx_max + num_img[i]
|
|
1198
|
-
snr_hit = snr_hit & (np.sum((snr_param[:,j:idx_max] > snr_threshold[i]), axis=1) >= num_img[i])
|
|
1199
|
-
j = idx_max
|
|
1200
1247
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1248
|
+
pdet = np.ones(np.shape(snr_param))
|
|
1249
|
+
j = 0
|
|
1250
|
+
idx_max = 0
|
|
1251
|
+
for i in range(len(snr_threshold)):
|
|
1252
|
+
idx_max = idx_max + num_img[i]
|
|
1253
|
+
pdet[:,j:idx_max] = 1 - norm.cdf(snr_threshold[i] - snr_param[:,j:idx_max])
|
|
1254
|
+
j = idx_max
|
|
1255
|
+
|
|
1256
|
+
snr_hit = np.prod(pdet, axis=1)>0.5
|
|
1257
|
+
# montecarlo integration
|
|
1258
|
+
total_rate = self.normalization_pdf_z_lensed * np.sum(snr_hit)/total_events
|
|
1259
|
+
print(f"total lensed rate (yr^-1) (with pdet function): {total_rate}")
|
|
1204
1260
|
|
|
1205
|
-
elif
|
|
1206
|
-
# check if pdet is provided in
|
|
1261
|
+
elif self.pdet:
|
|
1262
|
+
# check if pdet is provided in lensed_param dict
|
|
1207
1263
|
if "pdet_net" in lensed_param.keys():
|
|
1264
|
+
print("given detectability_condition == 'pdet'")
|
|
1208
1265
|
pdet = lensed_param["pdet_net"]
|
|
1209
1266
|
pdet = -np.sort(-pdet, axis=1) # sort pdet in descending order
|
|
1210
1267
|
pdet = pdet[:,:np.sum(num_img)] # use only num_img images
|
|
1211
|
-
else:
|
|
1212
|
-
if "optimal_snr_net" in lensed_param.keys():
|
|
1213
|
-
# pdet dimension is (size, n_max_images)
|
|
1214
|
-
snr_param = lensed_param["optimal_snr_net"]
|
|
1215
|
-
snr_param = -np.sort(-snr_param, axis=1) # sort snr in descending order
|
|
1216
1268
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
else:
|
|
1225
|
-
print("pdet or optimal_snr_net not provided in lensed_param dict. Exiting...")
|
|
1226
|
-
return None
|
|
1227
|
-
|
|
1228
|
-
snr_hit = np.prod(pdet, axis=1)>0.5
|
|
1229
|
-
# montecarlo integration
|
|
1230
|
-
total_rate = self.normalization_pdf_z_lensed * np.sum(snr_hit)/total_events
|
|
1231
|
-
print(f"total lensed rate (yr^-1) (with pdet function): {total_rate}")
|
|
1269
|
+
snr_hit = np.prod(pdet, axis=1)>0.5
|
|
1270
|
+
# montecarlo integration
|
|
1271
|
+
total_rate = self.normalization_pdf_z_lensed * np.sum(snr_hit)/total_events
|
|
1272
|
+
print(f"total lensed rate (yr^-1) (with pdet function): {total_rate}")
|
|
1273
|
+
|
|
1274
|
+
else:
|
|
1275
|
+
raise ValueError("'pdet_net' not in unlensed parm dict provided")
|
|
1232
1276
|
|
|
1233
1277
|
print(f"number of simulated lensed detectable events: {np.sum(snr_hit)}")
|
|
1234
1278
|
print(f"number of simulated all lensed events: {total_events}")
|
|
@@ -1245,13 +1289,14 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1245
1289
|
output_jsonfile = self.json_file_names["lensed_param_detectable"]
|
|
1246
1290
|
else:
|
|
1247
1291
|
self.json_file_names["lensed_param_detectable"] = output_jsonfile
|
|
1248
|
-
|
|
1292
|
+
path_ = self.ler_directory+"/"+output_jsonfile
|
|
1293
|
+
print(f"storing detectable lensed params in {path_}")
|
|
1249
1294
|
append_json(self.ler_directory+"/"+output_jsonfile, lensed_param, replace=True)
|
|
1250
1295
|
|
|
1251
1296
|
# write the results
|
|
1252
1297
|
data["detectable_lensed_rate_per_year"] = total_rate
|
|
1253
1298
|
data["detectability_condition"] = detectability_condition
|
|
1254
|
-
append_json(self.ler_directory+"/"+self.json_file_names["
|
|
1299
|
+
append_json(self.ler_directory+"/"+self.json_file_names["ler_params"], data, replace=True)
|
|
1255
1300
|
|
|
1256
1301
|
return total_rate, lensed_param
|
|
1257
1302
|
|
|
@@ -1277,19 +1322,19 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1277
1322
|
"""
|
|
1278
1323
|
|
|
1279
1324
|
# call json_file_ler_param and add the results
|
|
1280
|
-
data = load_json(self.ler_directory+"/"+self.json_file_names["
|
|
1325
|
+
data = load_json(self.ler_directory+"/"+self.json_file_names["ler_params"])
|
|
1281
1326
|
|
|
1282
1327
|
try:
|
|
1283
1328
|
unlensed_rate = data['detectable_unlensed_rate_per_year']
|
|
1284
1329
|
lensed_rate = data['detectable_lensed_rate_per_year']
|
|
1285
1330
|
except:
|
|
1286
|
-
raise ValueError(f"detectable_unlensed_rate_per_year or 'detectable_lensed_rate_per_year' not found in {self.json_file_names['
|
|
1331
|
+
raise ValueError(f"detectable_unlensed_rate_per_year or 'detectable_lensed_rate_per_year' not found in {self.json_file_names['ler_params']} json file. Exiting...")
|
|
1287
1332
|
|
|
1288
1333
|
rate_ratio = unlensed_rate / lensed_rate
|
|
1289
1334
|
# append the results
|
|
1290
1335
|
data['rate_ratio'] = rate_ratio
|
|
1291
1336
|
# write the results
|
|
1292
|
-
append_json(self.ler_directory+"/"+self.json_file_names["
|
|
1337
|
+
append_json(self.ler_directory+"/"+self.json_file_names["ler_params"], data, replace=True)
|
|
1293
1338
|
|
|
1294
1339
|
print(f"unlensed_rate: {unlensed_rate}")
|
|
1295
1340
|
print(f"lensed_rate: {lensed_rate}")
|
|
@@ -1356,7 +1401,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1356
1401
|
"""
|
|
1357
1402
|
|
|
1358
1403
|
# call json_file_ler_param and add the results
|
|
1359
|
-
data = load_json(self.ler_directory+"/"+self.json_file_names["
|
|
1404
|
+
data = load_json(self.ler_directory+"/"+self.json_file_names["ler_params"])
|
|
1360
1405
|
|
|
1361
1406
|
# get unlensed rate
|
|
1362
1407
|
unlensed_rate, unlensed_param = self.unlensed_rate(
|
|
@@ -1382,7 +1427,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1382
1427
|
data['rate_ratio'] = rate_ratio
|
|
1383
1428
|
data['detectability_condition'] = detectability_condition
|
|
1384
1429
|
# write the results
|
|
1385
|
-
append_json(self.ler_directory+"/"+self.json_file_names["
|
|
1430
|
+
append_json(self.ler_directory+"/"+self.json_file_names["ler_params"], data, replace=True)
|
|
1386
1431
|
|
|
1387
1432
|
print(f"unlensed_rate (per year): {unlensed_rate}")
|
|
1388
1433
|
print(f"lensed_rate (per year): {lensed_rate}")
|
|
@@ -1458,7 +1503,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1458
1503
|
events_total = 0
|
|
1459
1504
|
|
|
1460
1505
|
buffer_file = self.ler_directory+"/"+"unlensed_params_buffer.json"
|
|
1461
|
-
print("collected number of events = ", n)
|
|
1506
|
+
print("collected number of detectable events = ", n)
|
|
1462
1507
|
|
|
1463
1508
|
while n < size:
|
|
1464
1509
|
# disable print statements
|
|
@@ -1489,7 +1534,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1489
1534
|
else:
|
|
1490
1535
|
append_json(file_name=meta_data_path, new_dictionary=meta_data, replace=True)
|
|
1491
1536
|
|
|
1492
|
-
print("collected number of events = ", n)
|
|
1537
|
+
print("collected number of detectable events = ", n)
|
|
1493
1538
|
print("total number of events = ", events_total)
|
|
1494
1539
|
print(f"total unlensed rate (yr^-1): {total_rate}")
|
|
1495
1540
|
|
|
@@ -1594,7 +1639,7 @@ class LeR(LensGalaxyParameterDistribution):
|
|
|
1594
1639
|
num_img = num_img[idx]
|
|
1595
1640
|
|
|
1596
1641
|
buffer_file = self.ler_directory+"/"+"lensed_params_buffer.json"
|
|
1597
|
-
print("collected number of events = ", n)
|
|
1642
|
+
print("collected number of detectable events = ", n)
|
|
1598
1643
|
# loop until n samples are collected
|
|
1599
1644
|
while n < size:
|
|
1600
1645
|
# disable print statements
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
ler/__init__.py,sha256=
|
|
1
|
+
ler/__init__.py,sha256=Y1j_RXriJ7OLOdESsyeZkh4W7p438p5-Hgt88zZsQCA,804
|
|
2
2
|
ler/gw_source_population/__init__.py,sha256=HG0ve5wTpBDN2fNMxHLnoOqTz-S0jXM_DsWEJ5PEHAw,126
|
|
3
3
|
ler/gw_source_population/cbc_source_parameter_distribution.py,sha256=jAFBAen3ZsGkJSxSDeBT0WZlVYNTIF-ICRiftVlnlMo,66229
|
|
4
4
|
ler/gw_source_population/cbc_source_redshift_distribution.py,sha256=ajI4L7vkoNNzw2Y_bZTe9T3F9uFcrYt_KaINT9anuvw,28160
|
|
5
5
|
ler/gw_source_population/jit_functions.py,sha256=phUYdbFRvNMRgXJtSwGYSY2HN5h3n3IcLJR9AvHyC6o,8666
|
|
6
6
|
ler/image_properties/__init__.py,sha256=XfJFlyZuOrKODT-z9WxjR9mI8eT399YJV-jzcJKTqGo,71
|
|
7
|
-
ler/image_properties/image_properties.py,sha256=
|
|
7
|
+
ler/image_properties/image_properties.py,sha256=XKOTimOFmSCNlEfUT_oEwPGm7P3tEwEtfsydXeJmhy8,24080
|
|
8
8
|
ler/image_properties/multiprocessing_routine.py,sha256=f5sXcAx01xAx7AvOFE1Q99w7X9WIUwqlsUl7zq--rG4,17805
|
|
9
9
|
ler/lens_galaxy_population/__init__.py,sha256=TXk1nwiYy0tvTpKs35aYK0-ZK63g2JLPyGG_yfxD0YU,126
|
|
10
10
|
ler/lens_galaxy_population/jit_functions.py,sha256=8ZlseC6oaNuiZg5DvOeoonkH1BUE_dZyFMfmAx7_TPw,8419
|
|
@@ -12,13 +12,13 @@ ler/lens_galaxy_population/lens_galaxy_parameter_distribution.py,sha256=e_3lgfJi
|
|
|
12
12
|
ler/lens_galaxy_population/mp.py,sha256=TPnFDEzojEqJzE3b0g39emZasHeeaeXN2q7JtMcgihk,6387
|
|
13
13
|
ler/lens_galaxy_population/optical_depth.py,sha256=m4rBkE2-7Gd6z_oHmHOfg4bPHOi0xotCs5VQnFbzz_A,42333
|
|
14
14
|
ler/rates/__init__.py,sha256=N4li9NouSVjZl5HIhyuiKKRyrpUgQkBZaUeDgL1m4ic,43
|
|
15
|
-
ler/rates/gwrates.py,sha256=
|
|
16
|
-
ler/rates/ler.py,sha256=
|
|
15
|
+
ler/rates/gwrates.py,sha256=cAMC57G9D0yiJLN_Q6qV4wyTlnyk_vkrZ3nCbbSb6dw,40718
|
|
16
|
+
ler/rates/ler.py,sha256=Ff1u0sWb_1rHzuUjm7xgZ1q8xBh57TQ3VxJVjgFhjZE,76975
|
|
17
17
|
ler/utils/__init__.py,sha256=JWF9SKoqj1BThpV_ynfoyUeU06NQQ45DHCUGaaMSp_8,42
|
|
18
18
|
ler/utils/plots.py,sha256=D8MjTrfyE4cc0D6KBu1Mw4VMllp9Yp73bSi2cqPmNOM,10742
|
|
19
19
|
ler/utils/utils.py,sha256=BPMUMamJeAW9-LlvW4ao93jAZSG6YBS6Hd3FpTYJgB4,27465
|
|
20
|
-
ler-0.3.
|
|
21
|
-
ler-0.3.
|
|
22
|
-
ler-0.3.
|
|
23
|
-
ler-0.3.
|
|
24
|
-
ler-0.3.
|
|
20
|
+
ler-0.3.6.dist-info/LICENSE,sha256=9LeXXC3WaHBpiUGhLVgOVnz0F12olPma1RX5zgpfp8Q,1081
|
|
21
|
+
ler-0.3.6.dist-info/METADATA,sha256=92RR_37n1guw-A7aebZbeeDqPnosEJ-fee4NQaeiqOY,6521
|
|
22
|
+
ler-0.3.6.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
23
|
+
ler-0.3.6.dist-info/top_level.txt,sha256=VWeWLF_gNMjzquGmqrLXqp2J5WegY86apTUimMTh68I,4
|
|
24
|
+
ler-0.3.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|