diff options
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/misc.py | 42 | ||||
| -rw-r--r-- | utils/plot.py | 16 |
2 files changed, 37 insertions, 21 deletions
diff --git a/utils/misc.py b/utils/misc.py index 331e78a..f0c1ad4 100644 --- a/utils/misc.py +++ b/utils/misc.py @@ -196,63 +196,67 @@ class SortingHelpFormatter(argparse.HelpFormatter): super(SortingHelpFormatter, self).add_arguments(actions) -def gen_outfile_name(args): - """Generate a name for the output file based on the input args. - - Parameters - ---------- - args : argparse - argparse object to print - - """ +def gen_identifier(args): mr = args.measured_ratio si = args.sigma_ratio if args.fix_source_ratio: sr = args.source_ratio if args.fix_mixing: - outfile = args.outfile+'_{0:03d}_{1:03d}_{2:03d}_{3:04d}_sfr_{4:03d}_{5:03d}_{6:03d}_DIM{7}_fix_mixing'.format( + out = '_{0:03d}_{1:03d}_{2:03d}_{3:04d}_sfr_{4:03d}_{5:03d}_{6:03d}_DIM{7}_fix_mixing'.format( int(mr[0]*100), int(mr[1]*100), int(mr[2]*100), int(si*1000), int(sr[0]*100), int(sr[1]*100), int(sr[2]*100), args.dimension ) elif args.fix_mixing_almost: - outfile = args.outfile+'_{0:03d}_{1:03d}_{2:03d}_{3:04d}_sfr_{4:03d}_{5:03d}_{6:03d}_DIM{7}_fix_mixing_almost'.format( + out = '_{0:03d}_{1:03d}_{2:03d}_{3:04d}_sfr_{4:03d}_{5:03d}_{6:03d}_DIM{7}_fix_mixing_almost'.format( int(mr[0]*100), int(mr[1]*100), int(mr[2]*100), int(si*1000), int(sr[0]*100), int(sr[1]*100), int(sr[2]*100), args.dimension ) elif args.fix_scale: - outfile = args.outfile+'_{0:03d}_{1:03d}_{2:03d}_{3:04d}_sfr_{4:03d}_{5:03d}_{6:03d}_DIM{7}_fixed_scale_{8}'.format( + out = '_{0:03d}_{1:03d}_{2:03d}_{3:04d}_sfr_{4:03d}_{5:03d}_{6:03d}_DIM{7}_fixed_scale_{8}'.format( int(mr[0]*100), int(mr[1]*100), int(mr[2]*100), int(si*1000), int(sr[0]*100), int(sr[1]*100), int(sr[2]*100), args.dimension, args.scale ) else: - outfile = args.outfile+'_{0:03d}_{1:03d}_{2:03d}_{3:04d}_sfr_{4:03d}_{5:03d}_{6:03d}_DIM{7}_single_scale'.format( + out = '_{0:03d}_{1:03d}_{2:03d}_{3:04d}_sfr_{4:03d}_{5:03d}_{6:03d}_DIM{7}_single_scale'.format( int(mr[0]*100), int(mr[1]*100), int(mr[2]*100), int(si*1000), int(sr[0]*100), int(sr[1]*100), int(sr[2]*100), args.dimension ) else: if args.fix_mixing: - outfile = args.outfile+'_{0:03d}_{1:03d}_{2:03d}_{3:04d}_DIM{4}_fix_mixing'.format( + out = '_{0:03d}_{1:03d}_{2:03d}_{3:04d}_DIM{4}_fix_mixing'.format( int(mr[0]*100), int(mr[1]*100), int(mr[2]*100), int(si*1000), args.dimension ) elif args.fix_mixing_almost: - outfile = args.outfile+'_{0:03d}_{1:03d}_{2:03d}_{3:04d}_DIM{4}_fix_mixing_almost'.format( + out = '_{0:03d}_{1:03d}_{2:03d}_{3:04d}_DIM{4}_fix_mixing_almost'.format( int(mr[0]*100), int(mr[1]*100), int(mr[2]*100), int(si*1000), args.dimension ) elif args.fix_scale: - outfile = args.outfile+'_{0:03d}_{1:03d}_{2:03d}_{3:04d}_DIM{4}_fixed_scale_{5}'.format( + out = '_{0:03d}_{1:03d}_{2:03d}_{3:04d}_DIM{4}_fixed_scale_{5}'.format( int(mr[0]*100), int(mr[1]*100), int(mr[2]*100), int(si*1000), args.dimension, args.scale ) else: - outfile = args.outfile+'_{0:03d}_{1:03d}_{2:03d}_{3:04d}_DIM{4}'.format( + out = '_{0:03d}_{1:03d}_{2:03d}_{3:04d}_DIM{4}'.format( int(mr[0]*100), int(mr[1]*100), int(mr[2]*100), int(si*1000), args.dimension ) - if args.likelihood is Likelihood.FLAT: outfile += '_flat' - return outfile + if args.likelihood is Likelihood.FLAT: out += '_flat' + return out + + +def gen_outfile_name(args): + """Generate a name for the output file based on the input args. + + Parameters + ---------- + args : argparse + argparse object to print + + """ + return args.outfile + gen_identifier(args) def parse_bool(s): diff --git a/utils/plot.py b/utils/plot.py index 0ff89c2..0d02c2a 100644 --- a/utils/plot.py +++ b/utils/plot.py @@ -100,6 +100,10 @@ def plot_argparse(parser): '--plot-bayes', type=misc_utils.parse_bool, default='False', help='Plot Bayes factor' ) + parser.add_argument( + '--plot-angles-limit', type=misc_utils.parse_bool, default='False', + help='Plot limit vs BSM angles' + ) def flat_angles_to_u(x): @@ -274,6 +278,7 @@ def bayes_factor_plot(dirname, outfile, outformat, args, xlim): raw.append(np.load(os.path.join(root, fn))) raw = np.sort(np.vstack(raw), axis=0) print 'raw', raw + print 'raw.shape', raw.shape scales, evidences = raw.T null = evidences[0] @@ -309,12 +314,19 @@ def myround(x, base=5, up=False, down=False): else: int(base * np.round(float(x)/base)) -def plot_BSM_angles_limit(infile, outfile, xticks, outformat, args, bayesian): +def plot_BSM_angles_limit(dirname, outfile, outformat, args, bayesian): """Make BSM angles vs scale limit plot.""" + if not args.plot_angles_limit: return print "Making BSM angles limit plot.""" fig_text = gen_figtext(args) + xticks = [r'$\mathcal{O}_{12}$', r'$\mathcal{O}_{13}$', r'$\mathcal{O}_{23}$'] - raw = np.load(infile) + raw = [] + for root, dirs, filenames in os.walk(dirname): + for fn in filenames: + if fn[-4:] == '.npy': + raw.append(np.load(os.path.join(root, fn))) + raw = np.sort(np.vstack(raw), axis=0) print 'raw', raw print 'raw.shape', raw.shape sc_ranges = ( |
