Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ python -m venv env
Then activate it and install the necessary packages
```bash
source env/bin/activate
pip install wums[pickling,plotting] tensorflow tensorflow-probability numpy h5py hist scipy matplotlib mplhep seaborn pandas plotly kaleido
pip install wums[pickling,plotting] tensorflow tensorflow-probability tf_keras numpy h5py hist scipy matplotlib mplhep seaborn pandas plotly kaleido
```
The packages `matplotlib`, `mplhep`, `seaborn`, `pandas`, `plotly`, and `kaleido` are only needed for the plotting scripts.
For the `text2hdf5.py` conversion also the `uproot` package is needed.
Expand Down Expand Up @@ -197,7 +197,7 @@ rabbit_print_impacts results/fitresult.hdf5

We use pre-commit hooks and linters in the CI. Activate git pre-commit hooks (only need to do this once when checking out)
```
git config --local include.path ../.gitconfig
git config --local include.path ../.gitconfig
```
In case rabbit is included as a submodule, use instead:
```
Expand Down
63 changes: 26 additions & 37 deletions bin/rabbit_plot_likelihood_scan.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env python3

import argparse
import os

import matplotlib.pyplot as plt
import mplhep as hep
import numpy as np

Expand All @@ -16,32 +14,6 @@
logger = None


def writeOutput(fig, outfile, extensions=[], postfix=None, args=None, meta_info=None):
name, _ = os.path.splitext(outfile)

if postfix:
name += f"_{postfix}"

for ext in extensions:
if ext[0] != ".":
ext = "." + ext
output = name + ext
print(f"Write output file {output}")
plt.savefig(output)

output = name.rsplit("/", 1)
output[1] = os.path.splitext(output[1])[0]
if len(output) == 1:
output = (None, *output)
if args is None and meta_info is None:
return
output_tools.write_logfile(
*output,
args=args,
meta_info=meta_info,
)


def parseArgs():
parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down Expand Up @@ -73,6 +45,11 @@ def parseArgs():
default="./test",
help="Folder path for output",
)
parser.add_argument(
"--eoscp",
action="store_true",
help="Override use of xrdcp and use the mount instead",
)
parser.add_argument(
"-p", "--postfix", type=str, help="Postfix for output file name"
)
Expand Down Expand Up @@ -113,6 +90,13 @@ def parseArgs():
default=None,
help="x axis limits",
)
parser.add_argument(
"--ylim",
type=float,
nargs=2,
default=None,
help="y axis limits",
)
parser.add_argument("--titlePos", type=int, default=2, help="title position")
parser.add_argument(
"--config",
Expand All @@ -133,6 +117,7 @@ def plot_scan(
subtitle=None,
titlePos=0,
xlim=None,
ylim=None,
combine=None,
ylabel=r"$-2\,\Delta \log L$",
config={},
Expand All @@ -148,13 +133,15 @@ def plot_scan(

if xlim is None:
xlim = (min(x), max(x))
if ylim is None:
ylim = (min(y), max(y))

fig, ax = plot_tools.figure(
x,
xlabel,
ylabel,
xlim=xlim,
ylim=(min(y), max(y)), # logy=args.logy
ylim=ylim, # logy=args.logy
)

ax.axhline(y=1, color="gray", linestyle="--", alpha=0.5)
Expand Down Expand Up @@ -227,6 +214,7 @@ def plot_scan(

def main():
args = parseArgs()
outdir = output_tools.make_plot_dir(args.outpath, eoscp=args.eoscp)

global logger
logger = logging.setup_logger(__file__, args.verbose, args.noColorLogger)
Expand Down Expand Up @@ -280,19 +268,20 @@ def main():
subtitle=args.subtitle,
titlePos=args.titlePos,
xlim=args.xlim,
ylim=args.ylim,
config=config,
combine=(vals, nlls) if args.combine is not None else None,
no_hessian=args.noHessian,
)
os.makedirs(args.outpath, exist_ok=True)
outfile = os.path.join(args.outpath, f"nll_scan_{param}")
writeOutput(
fig,
outfile=outfile,
extensions=["png", "pdf"],
meta_info=meta,

to_join = [f"nll_scan_{param}", args.postfix]
outfile = "_".join(filter(lambda x: x, to_join))
plot_tools.save_pdf_and_png(outdir, outfile)
output_tools.write_index_and_log(
outdir,
outfile,
analysis_meta_info=meta,
args=args,
postfix=args.postfix,
)


Expand Down
Loading