aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/fr.py14
-rw-r--r--utils/gf.py3
-rw-r--r--utils/likelihood.py9
-rw-r--r--utils/plot.py11
4 files changed, 25 insertions, 12 deletions
diff --git a/utils/fr.py b/utils/fr.py
index 81ba3b2..80a26e1 100644
--- a/utils/fr.py
+++ b/utils/fr.py
@@ -248,10 +248,12 @@ def estimate_scale(args):
"""Estimate the scale at which new physics will enter."""
try: m_eign = args.m3x_2
except: m_eign = MASS_EIGENVALUES[1]
- if args.scale is not None:
- scale = args.scale
- scale_region = (scale/args.scale_region, scale*args.scale_region)
- elif args.energy_dependance is EnergyDependance.MONO:
+ if hasattr(args, 'scale'):
+ if args.scale != 0:
+ scale = args.scale
+ scale_region = (scale/args.scale_region, scale*args.scale_region)
+ return scale, scale_region
+ if args.energy_dependance is EnergyDependance.MONO:
scale = np.power(
10, np.round(np.log10(m_eign/args.energy)) - \
np.log10(args.energy**(args.dimension-3))
@@ -319,7 +321,7 @@ def fr_argparse(parser):
help='Fix the new physics scale'
)
parser.add_argument(
- '--scale', type=float, default=None,
+ '--scale', type=float, default=0,
help='Set the new physics scale'
)
parser.add_argument(
@@ -418,7 +420,7 @@ def params_to_BSMu(theta, dim, energy, mass_eigenvalues=MASS_EIGENVALUES,
'--fix-mixing and --fix-mixing-almost cannot be used together'
)
- if not isinstance(theta, list):
+ if not isinstance(theta, (list, tuple)):
theta = [theta]
if fix_mixing is MixingScenario.T12:
diff --git a/utils/gf.py b/utils/gf.py
index ddf3fdd..6ce7863 100644
--- a/utils/gf.py
+++ b/utils/gf.py
@@ -69,7 +69,8 @@ def steering_params(args):
# For Tianlu
# params.years = [999]
- params.minFitEnergy = args.binning[0] # GeV
+ params.minFitEnergy = args.binning[0] # GeV
+ params.maxFitEnergy = args.binning[-1] # GeV
params.load_data_from_text_file = False
return params
diff --git a/utils/likelihood.py b/utils/likelihood.py
index 93f3aea..7079d52 100644
--- a/utils/likelihood.py
+++ b/utils/likelihood.py
@@ -72,6 +72,8 @@ def lnprior(theta, paramset):
prior += Gaussian().logpdf(
param.nominal_value, param.value, param.std
)
+ print 'prioring param', param.name, '=', param.value
+ print 'prior', prior
elif param.prior is PriorsCateg.HALFGAUSS:
prior += Gaussian().logpdf(
param.nominal_value, param.value, param.std
@@ -177,7 +179,8 @@ def triangle_llh(theta, args, asimov_paramset, llh_paramset, fitter):
n = gen_identifier(args) + '.txt'
with open(args.output_measured_fr + n, 'a') as f:
f.write(r'{0:.3f} {1:.3f} {2:.3f} {3:.1f}'.format(
- fr[0], fr[1], fr[2], llh_paramset['logLam'].value
+ float(fr[0]), float(fr[1]), float(fr[2]),
+ llh_paramset['logLam'].value
))
f.write('\n')
@@ -202,6 +205,10 @@ def ln_prob(theta, args, asimov_paramset, llh_paramset, fitter):
lp = lnprior(theta, paramset=llh_paramset)
if not np.isfinite(lp):
return -np.inf
+ llh = triangle_llh(
+ theta, args=args, asimov_paramset=asimov_paramset,
+ llh_paramset=llh_paramset, fitter=fitter
+ )
return lp + triangle_llh(
theta, args=args, asimov_paramset=asimov_paramset,
llh_paramset=llh_paramset, fitter=fitter
diff --git a/utils/plot.py b/utils/plot.py
index a73235b..53a4a84 100644
--- a/utils/plot.py
+++ b/utils/plot.py
@@ -196,10 +196,10 @@ def chainer_plot(infile, outfile, outformat, args, llh_paramset):
# )
if args.data is DataType.REAL:
- fig.text(0.8, 0.7, 'IceCube Preliminary', color='red', fontsize=15,
+ plt.text(0.8, 0.7, 'IceCube Preliminary', color='red', fontsize=15,
ha='center', va='center')
elif args.data in [DataType.ASIMOV, DataType.REALISATION]:
- fig.text(0.8, 0.7, 'IceCube Simulation', color='red', fontsize=15,
+ plt.text(0.8, 0.7, 'IceCube Simulation', color='red', fontsize=15,
ha='center', va='center')
for of in outformat:
@@ -247,14 +247,15 @@ def chainer_plot(infile, outfile, outformat, args, llh_paramset):
g = plot_Tchain(Tchain, trns_axes_labels, trns_ranges)
if args.data is DataType.REAL:
- fig.text(0.8, 0.7, 'IceCube Preliminary', color='red', fontsize=15,
+ plt.text(0.8, 0.7, 'IceCube Preliminary', color='red', fontsize=15,
ha='center', va='center')
elif args.data in [DataType.ASIMOV, DataType.REALISATION]:
- fig.text(0.8, 0.7, 'IceCube Simulation', color='red', fontsize=15,
+ plt.text(0.8, 0.7, 'IceCube Simulation', color='red', fontsize=15,
ha='center', va='center')
mpl.pyplot.figtext(0.5, 0.7, fig_text, fontsize=15)
for of in outformat:
+ print 'Saving', outfile+'_elements'+of
g.export(outfile+'_elements.'+of)
@@ -281,6 +282,8 @@ def plot_statistic(data, outfile, outformat, args, scale_param, label=None):
min_idx = np.argmin(scales)
null = statistic[min_idx]
+ fig_text += '\nnull lnZ = {0:.2f}'.format(null)
+
if args.stat_method is StatCateg.BAYESIAN:
reduced_ev = -(statistic - null)
elif args.stat_method is StatCateg.FREQUENTIST: