Commit efce7330 authored by Christos Karathanasis's avatar Christos Karathanasis

SNR from command line / Add snr=10,11 pickles

parent 64966d35
......@@ -62,7 +62,9 @@ parser = OptionParser(
Option("--combine", default=None,
help="Directory of constant_H0 Pdets to combine into single Pdet pickle."),
Option("--outputfile", default=None,
help="Name of output pdet file.")
help="Name of output pdet file."),
Option("--snr", default='12.0', type=float,
help="Network SNR threshold.")
])
opts, args = parser.parse_args()
print(opts)
......@@ -90,7 +92,7 @@ linear = str2bool(opts.linear_cosmology)
basic = str2bool(opts.basic_pdet)
full_waveform = str2bool(opts.full_waveform)
Nsamps = int(opts.Nsamps)
network_snr_threshold = float(opts.snr)
constant_H0 = str2bool(opts.constant_H0)
pdet_path = str(opts.combine)
......@@ -114,7 +116,7 @@ if opts.combine is None:
pdet = gwcosmo.detection_probability.DetectionProbability(mass_distribution=mass_distribution, asd=psd, basic=basic,
linear=linear, alpha=alpha, Mmin=Mmin, Mmax=Mmax,
full_waveform=full_waveform, Nsamps=Nsamps,
constant_H0=constant_H0, H0=H0)
constant_H0=constant_H0, H0=H0, network_snr_threshold=network_snr_threshold)
if opts.outputfile is None:
if mass_distribution == 'BBH-powerlaw':
......@@ -152,7 +154,7 @@ else:
pdet = gwcosmo.likelihood.detection_probability.DetectionProbability(
mass_distribution=mass_distribution, alpha=alpha,
asd=psd, detectors=['H1', 'L1'], Nsamps=2,
network_snr_threshold=12, Omega_m=0.308,
network_snr_threshold=12.0, Omega_m=0.308,
linear=False, basic=False, M1=50., M2=50.,
constant_H0=False, H0=H0vec, full_waveform=True)
......@@ -198,6 +200,7 @@ else:
pdet.linear = linear
pdet.seed = seed
pdet.detectors = detectors
pdet.network_snr_threshold = network_snr_threshold
logit_prob=logit(prob)
for i in range (len(logit_prob)):
......@@ -206,11 +209,11 @@ else:
pdet.interp_average = interp_average
if mass_distribution == 'BBH-powerlaw':
pdet_path = '{}PSD_{}_alpha_{}_Mmin_{}_Mmax_{}_Nsamps{}_{}.p'.format(psd, mass_distribution,
pdet_path = '{}PSD_{}_alpha_{}_Mmin_{}_Mmax_{}_Nsamps{}_{}_snr_{}.p'.format(psd, mass_distribution,
str(alpha), str(Mmin), str(Mmax),
str(Nsamps), kind)
str(Nsamps), kind,network_snr_threshold)
else:
pdet_path = '{}PSD_{}_Nsamps{}_{}.p'.format(psd, mass_distribution, str(Nsamps), kind)
pdet_path = '{}PSD_{}_Nsamps{}_{}_snr_{}.p'.format(psd, mass_distribution, str(Nsamps), kind,network_snr_threshold)
pickle.dump( pdet, open( pdet_path, "wb" ) )
......@@ -110,7 +110,9 @@ parser = OptionParser(
Option("--outputfile", default='Posterior',
help="Name of output file"),
Option("--plot", default=None,
help="Plot .npz file")
help="Plot .npz file"),
Option("--snr", default='12.0', type=float,
help="Network SNR threshold.")
])
opts, args = parser.parse_args()
print(opts)
......@@ -203,7 +205,7 @@ else:
full_waveform=str2bool(opts.full_waveform)
Kcorr = str2bool(opts.Kcorrections)
reweight = str2bool(opts.reweight)
network_snr_threshold = float(opts.snr)
population_params = dict(mass_distribution=mass_distribution,alpha=alpha,mmin=mmin,mmax=mmax,Lambda=Lambda)
options_string = opts.method
......@@ -276,7 +278,7 @@ else:
if mass_distribution == 'BBH-powerlaw':
pdet_path = data_path + '{}PSD_{}_alpha_{}_Mmin_{}_Mmax_{}_Nsamps{}_{}.p'.format(psd, mass_distribution, alpha, mmin, mmax, Nsamps, kind)
pdet_path = data_path + '{}PSD_{}_alpha_{}_Mmin_{}_Mmax_{}_Nsamps{}_{}_snr_{}.p'.format(psd, mass_distribution, alpha, mmin, mmax, Nsamps, kind,network_snr_threshold)
print(pdet_path)
if os.path.isfile(pdet_path) is True:
pdet = pickle.load(open(pdet_path, 'rb'))
......@@ -284,10 +286,10 @@ else:
else:
print('Calculating detection probability from scratch. This will take a while... Consider using a precomputed one for speed.')
pdet = gwcosmo.detection_probability.DetectionProbability(mass_distribution=mass_distribution,asd=psd,
basic=basic,full_waveform=full_waveform,H0=H0)
basic=basic,full_waveform=full_waveform,H0=H0,network_snr_threshold=network_snr_threshold)
if (mass_distribution == 'BNS' or mass_distribution == 'NSBH'):
pdet_path = data_path + '{}PSD_{}_Nsamps{}_{}.p'.format(psd, mass_distribution, Nsamps, kind)
pdet_path = data_path + '{}PSD_{}_Nsamps{}_{}_snr_{}.p'.format(psd, mass_distribution, Nsamps, kind,network_snr_threshold)
if os.path.isfile(pdet_path) is True:
pdet = pickle.load(open(pdet_path, 'rb'))
print('Loading precomputed pdet with a {} mass distribution at {} sensitivity.'.format(mass_distribution, psd))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment