ler 0.3.4__tar.gz → 0.3.6__tar.gz

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.

Files changed (29) hide show
  1. {ler-0.3.4 → ler-0.3.6}/PKG-INFO +1 -1
  2. {ler-0.3.4 → ler-0.3.6}/ler/__init__.py +6 -1
  3. {ler-0.3.4 → ler-0.3.6}/ler/image_properties/image_properties.py +78 -33
  4. {ler-0.3.4 → ler-0.3.6}/ler/image_properties/multiprocessing_routine.py +1 -1
  5. {ler-0.3.4 → ler-0.3.6}/ler/rates/gwrates.py +79 -57
  6. {ler-0.3.4 → ler-0.3.6}/ler/rates/ler.py +161 -116
  7. {ler-0.3.4 → ler-0.3.6}/ler.egg-info/PKG-INFO +1 -1
  8. {ler-0.3.4 → ler-0.3.6}/ler.egg-info/requires.txt +1 -1
  9. {ler-0.3.4 → ler-0.3.6}/setup.py +2 -2
  10. {ler-0.3.4 → ler-0.3.6}/LICENSE +0 -0
  11. {ler-0.3.4 → ler-0.3.6}/README.md +0 -0
  12. {ler-0.3.4 → ler-0.3.6}/ler/gw_source_population/__init__.py +0 -0
  13. {ler-0.3.4 → ler-0.3.6}/ler/gw_source_population/cbc_source_parameter_distribution.py +0 -0
  14. {ler-0.3.4 → ler-0.3.6}/ler/gw_source_population/cbc_source_redshift_distribution.py +0 -0
  15. {ler-0.3.4 → ler-0.3.6}/ler/gw_source_population/jit_functions.py +0 -0
  16. {ler-0.3.4 → ler-0.3.6}/ler/image_properties/__init__.py +0 -0
  17. {ler-0.3.4 → ler-0.3.6}/ler/lens_galaxy_population/__init__.py +0 -0
  18. {ler-0.3.4 → ler-0.3.6}/ler/lens_galaxy_population/jit_functions.py +0 -0
  19. {ler-0.3.4 → ler-0.3.6}/ler/lens_galaxy_population/lens_galaxy_parameter_distribution.py +0 -0
  20. {ler-0.3.4 → ler-0.3.6}/ler/lens_galaxy_population/mp.py +0 -0
  21. {ler-0.3.4 → ler-0.3.6}/ler/lens_galaxy_population/optical_depth.py +0 -0
  22. {ler-0.3.4 → ler-0.3.6}/ler/rates/__init__.py +0 -0
  23. {ler-0.3.4 → ler-0.3.6}/ler/utils/__init__.py +0 -0
  24. {ler-0.3.4 → ler-0.3.6}/ler/utils/plots.py +0 -0
  25. {ler-0.3.4 → ler-0.3.6}/ler/utils/utils.py +0 -0
  26. {ler-0.3.4 → ler-0.3.6}/ler.egg-info/SOURCES.txt +0 -0
  27. {ler-0.3.4 → ler-0.3.6}/ler.egg-info/dependency_links.txt +0 -0
  28. {ler-0.3.4 → ler-0.3.6}/ler.egg-info/top_level.txt +0 -0
  29. {ler-0.3.4 → ler-0.3.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ler
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Gravitational waves Lensing Rates
5
5
  Home-page: https://github.com/hemantaph/ler
6
6
  Author: Hemantakumar
@@ -13,7 +13,12 @@ except RuntimeError:
13
13
 
14
14
  __author__ = 'hemanta_ph <hemantaphurailatpam@gmail.com>'
15
15
 
16
- __version__ = "0.3.4"
16
+ # The version as used in the setup.py
17
+ __version__ = "0.3.6"
18
+
19
+ # add __file__
20
+ import os
21
+ __file__ = os.path.abspath(__file__)
17
22
 
18
23
  from . import rates, gw_source_population, lens_galaxy_population, image_properties, utils
19
24
 
@@ -119,7 +119,7 @@ class ImageProperties():
119
119
  n_min_images=2,
120
120
  n_max_images=4,
121
121
  geocent_time_min=1126259462.4,
122
- geocent_time_max=1126259462.4+365*24*3600*10,
122
+ geocent_time_max=1126259462.4+365*24*3600*20,
123
123
  lens_model_list=['EPL_NUMBA', 'SHEAR'],
124
124
  cosmology=None,
125
125
  spin_zero=True,
@@ -342,7 +342,7 @@ class ImageProperties():
342
342
 
343
343
  return lens_parameters
344
344
 
345
- def get_lensed_snrs(self, snr_calculator, list_of_detectors, lensed_param):
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
- optimal_snrs = dict()
407
- optimal_snrs["optimal_snr_net"] = (
408
- np.ones((number_of_lensed_events, n_max_images)) * np.nan
409
- )
410
- for detector in list_of_detectors:
411
- optimal_snrs[detector] = (
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
- optimal_snr = snr_calculator(
439
- mass_1[idx],
440
- mass_2[idx],
441
- effective_luminosity_distance[idx],
442
- theta_jn[idx],
443
- psi[idx],
444
- phase[idx],
445
- effective_geocent_time[idx],
446
- ra[idx],
447
- dec[idx],
448
- a_1[idx],
449
- a_2[idx],
450
- tilt_1[idx],
451
- tilt_2[idx],
452
- phi_12[idx],
453
- phi_jl[idx],
454
- output_jsonfile=False,
455
- )
456
-
457
- optimal_snrs["optimal_snr_net"][idx, i] = optimal_snr["optimal_snr_net"]
458
- for detector in list_of_detectors:
459
- optimal_snrs[detector][idx, i] = optimal_snr[detector]
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 optimal_snrs, lensed_param
512
+ return result_dict, lensed_param
@@ -159,7 +159,7 @@ def solve_lens_equation(lens_parameters):
159
159
  sourcePos_y=y_source,
160
160
  kwargs_lens=kwargs_lens,
161
161
  solver="analytical",
162
- magnification_limit=1.0 / 1000.0,
162
+ magnification_limit=1.0 / 100.0,
163
163
  arrival_time_sort=True,
164
164
  )
165
165
  nImages = len(x0_image_position) # shows how many images
@@ -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=25000,
189
+ batch_size=50000,
190
190
  cosmology=None,
191
- snr_finder="gwsnr",
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
- if snr_finder == "gwsnr":
219
- # initialization self.snr and self.pdet from GWSNR class
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
- print("snr_finder = ", self.snr)
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
- print("\n GWRATES also takes GWSNR params as kwargs, as follows:")
260
- print("mtot_min = ", self.snr_calculator_dict["mtot_min"])
261
- print("mtot_max = ", self.snr_calculator_dict["mtot_max"])
262
- print("ratio_min = ", self.snr_calculator_dict["ratio_min"])
263
- print("ratio_max = ", self.snr_calculator_dict["ratio_max"])
264
- print("mtot_resolution = ", self.snr_calculator_dict["mtot_resolution"])
265
- print("ratio_resolution = ", self.snr_calculator_dict["ratio_resolution"])
266
- print("sampling_frequency = ", self.snr_calculator_dict["sampling_frequency"])
267
- print("waveform_approximant = ", self.snr_calculator_dict["waveform_approximant"])
268
- print("minimum_frequency = ", self.snr_calculator_dict["minimum_frequency"])
269
- print("snr_type = ", self.snr_calculator_dict["snr_type"])
270
- print("psds = ", self.snr_calculator_dict["psds"])
271
- print("ifos = ", self.snr_calculator_dict["ifos"])
272
- print("interpolator_dir = ", self.snr_calculator_dict["interpolator_dir"])
273
- print("create_new_interpolator = ", self.snr_calculator_dict["create_new_interpolator"])
274
- print("gwsnr_verbose = ", self.snr_calculator_dict["gwsnr_verbose"])
275
- print("multiprocessing_verbose = ", self.snr_calculator_dict["multiprocessing_verbose"])
276
- print("mtot_cut = ", self.snr_calculator_dict["mtot_cut"])
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
- cosmology=self.cosmo,
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=True, output_jsonfile=None,
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 {output_jsonfile}")
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("unlensed_params already sampled.")
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
- print("calculating snrs...")
658
- snrs = self.snr(gw_param_dict=gw_param)
659
- gw_param.update(snrs)
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
- print(f"getting gw_params from json file {gw_param}...")
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 detectability_condition == "step_function":
753
- try:
754
- snr_param = gw_param["optimal_snr_net"]
755
- except:
756
- print("optimal_snr_net not provided in gw_param dict. Exiting...")
757
- return None
758
- threshold = snr_threshold
759
-
760
- elif detectability_condition == "pdet":
761
- # check if pdet is provided in gw_param dict
762
- if "pdet_net" in gw_param.keys():
763
- snr_param = gw_param["pdet_net"]
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
- if "optimal_snr_net" in gw_param.keys():
766
- snr_param = 1 - norm.cdf(snr_threshold - gw_param["optimal_snr_net"])
767
- gw_param["pdet_net"] = snr_param
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
- print(f"storing detectable gw params in {output_jsonfile}")
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
 
@@ -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 'gwsnr', the SNR will be calculated using the gwsnr package.
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 = {'ler_param': 'LeR_params.json', 'unlensed_param': 'unlensed_param.json', 'unlensed_param_detectable': 'unlensed_param_detectable.json'}.\n
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="gwsnr",
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(ler_param="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")
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
- if snr_finder == "gwsnr":
270
- # initialization self.snr and self.pdet from GWSNR class
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["ler_param"])
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
- print("snr_finder = ", self.snr)
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
- print("\n LeR also takes gwsnr.GWSNR params as kwargs, as follows:")
325
- print("mtot_min = ", self.snr_calculator_dict["mtot_min"])
326
- print("mtot_max = ", self.snr_calculator_dict["mtot_max"])
327
- print("ratio_min = ", self.snr_calculator_dict["ratio_min"])
328
- print("ratio_max = ", self.snr_calculator_dict["ratio_max"])
329
- print("mtot_resolution = ", self.snr_calculator_dict["mtot_resolution"])
330
- print("ratio_resolution = ", self.snr_calculator_dict["ratio_resolution"])
331
- print("sampling_frequency = ", self.snr_calculator_dict["sampling_frequency"])
332
- print("waveform_approximant = ", self.snr_calculator_dict["waveform_approximant"])
333
- print("minimum_frequency = ", self.snr_calculator_dict["minimum_frequency"])
334
- print("snr_type = ", self.snr_calculator_dict["snr_type"])
335
- print("psds = ", self.snr_calculator_dict["psds"])
336
- print("ifos = ", self.snr_calculator_dict["ifos"])
337
- print("interpolator_dir = ", self.snr_calculator_dict["interpolator_dir"])
338
- print("create_new_interpolator = ", self.snr_calculator_dict["create_new_interpolator"])
339
- print("gwsnr_verbose = ", self.snr_calculator_dict["gwsnr_verbose"])
340
- print("multiprocessing_verbose = ", self.snr_calculator_dict["multiprocessing_verbose"])
341
- print("mtot_cut = ", self.snr_calculator_dict["mtot_cut"])
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
  """
@@ -531,7 +544,7 @@ class LeR(LensGalaxyParameterDistribution):
531
544
  lens_priors=None,
532
545
  lens_priors_params=None,
533
546
  geocent_time_min=1126259462.4,
534
- geocent_time_max=1126259462.4+365*24*3600*10,
547
+ geocent_time_max=1126259462.4+365*24*3600*20,
535
548
  source_priors=None,
536
549
  source_priors_params=None,
537
550
  spin_zero=True,
@@ -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 {output_jsonfile}")
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
- print("calculating snrs...")
784
- snrs = self.snr(gw_param_dict=unlensed_param)
785
- unlensed_param.update(snrs)
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["ler_param"])
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
- print(f"getting unlensed_params from json file {unlensed_param}...")
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 detectability_condition == "step_function":
879
- param = unlensed_param["optimal_snr_net"]
880
- threshold = snr_threshold
881
-
882
- elif detectability_condition == "pdet":
883
- # check if pdet is provided in unlensed_param dict
884
- if "pdet_net" in unlensed_param.keys():
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
- if "optimal_snr_net" in unlensed_param.keys():
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
- print(f"storing detectable unlensed params in {output_jsonfile}")
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["ler_param"], data, replace=True)
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=True, resume=False, output_jsonfile=None,
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 {output_jsonfile}")
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
- print("calculating snrs...")
1043
- snrs, lensed_param = self.get_lensed_snrs(
1044
- snr_calculator=self.snr,
1045
- list_of_detectors=self.list_of_detectors,
1046
- lensed_param=lensed_param,
1047
- )
1048
- lensed_param.update(snrs)
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["ler_param"])
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
- print(f"getting lensed_params from json file {lensed_param}...")
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
- # from here, we focus on calculating the rate
1184
- if detectability_condition == "step_function":
1185
- if "optimal_snr_net" in lensed_param.keys():
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
- # montecarlo integration
1202
- total_rate = self.normalization_pdf_z_lensed * np.sum(snr_hit)/total_events
1203
- print("total lensed rate (yr^-1) (with step function): {}".format(total_rate))
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 detectability_condition == "pdet":
1206
- # check if pdet is provided in unlensed_param dict
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
- pdet = np.ones(np.shape(snr_param))
1218
- j = 0
1219
- idx_max = 0
1220
- for i in range(len(snr_threshold)):
1221
- idx_max = idx_max + num_img[i]
1222
- pdet[:,j:idx_max] = 1 - norm.cdf(snr_threshold[i] - snr_param[:,j:idx_max])
1223
- j = idx_max
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
- print(f"storing detectable lensed params in {output_jsonfile}")
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["ler_param"], data, replace=True)
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["ler_param"])
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['ler_param']} json file. Exiting...")
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["ler_param"], data, replace=True)
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["ler_param"])
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["ler_param"], data, replace=True)
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ler
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Gravitational waves Lensing Rates
5
5
  Home-page: https://github.com/hemantaph/ler
6
6
  Author: Hemantakumar
@@ -6,7 +6,7 @@ numba>=0.57.1
6
6
  bilby>=1.0.2
7
7
  gwsnr>=0.2.0
8
8
  scipy>=1.9.0
9
- lenstronomy==1.10.4
9
+ lenstronomy>=1.10.4
10
10
  astropy>=5.1
11
11
  tqdm>=4.64.1
12
12
  pointpats>=2.3
@@ -13,7 +13,7 @@ if python_version < (3, 10):
13
13
 
14
14
  setup(
15
15
  name="ler",
16
- version="0.3.4",
16
+ version="0.3.6",
17
17
  description="Gravitational waves Lensing Rates",
18
18
  long_description=long_description,
19
19
  long_description_content_type='text/markdown',
@@ -32,7 +32,7 @@ setup(
32
32
  "bilby>=1.0.2",
33
33
  "gwsnr>=0.2.0",
34
34
  "scipy>=1.9.0",
35
- "lenstronomy==1.10.4",
35
+ "lenstronomy>=1.10.4",
36
36
  "astropy>=5.1",
37
37
  "tqdm>=4.64.1",
38
38
  "pointpats>=2.3",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes