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
17 changes: 14 additions & 3 deletions bin/rabbit_plot_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def main():
suffix=suffix,
axes_names=axes_names,
)
h_cov_channel = h_cov
elif len(instance.get("channels", {}).keys()) > 1:
# plot covariance matrix in each channel
nbins = np.prod(channel_hist.shape)
Expand Down Expand Up @@ -318,9 +319,19 @@ def main():
put_trailing=True,
)

cov_channel_vals = (
h_cov_channel.values()
if hasattr(h_cov_channel, "values")
else h_cov_channel
)
if len(cov_channel_vals.shape) > 2:
flat = np.prod(
cov_channel_vals.shape[: len(cov_channel_vals.shape) // 2]
)
cov_channel_vals = cov_channel_vals.reshape((flat, flat))
vals = np.reshape(
h_cov_channel.values(),
(h_cov_channel.shape[0], *h2d.shape[: len(h2d.shape) // 2]),
cov_channel_vals,
(cov_channel_vals.shape[0], *h2d.shape[: len(h2d.shape) // 2]),
)
h2d.values()[...] = np.reshape(vals, h2d.shape)

Expand Down Expand Up @@ -356,7 +367,7 @@ def main():
h_cov_i,
args,
channel=channel,
axes=other_axes,
axes_names=other_axes,
config=config,
meta=meta,
suffix=suffix,
Expand Down
1 change: 1 addition & 0 deletions bin/rabbit_plot_hists.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ def make_plot(
closed=True,
facecolor=facecolor_pred,
edgecolor="black",
alpha=facecolor_alpha_pred,
)
)
extra_labels_upper.append(pred_label)
Expand Down
8 changes: 6 additions & 2 deletions rabbit/tensorwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,16 @@ def add_channel(self, axes, name=None, masked=False, flow=False):
self.dict_sumw2[name] = {}
self.dict_beta_variations[name] = {}

# add masked channels last and not masked channels first
# add masked channels last
this_channel = {"axes": [a for a in axes], "masked": masked, "flow": flow}
if masked:
self.channels[name] = this_channel
else:
self.channels = {name: this_channel, **self.channels}
self.channels = {
**{k: v for k, v in self.channels.items() if not v["masked"]},
name: this_channel,
**{k: v for k, v in self.channels.items() if v["masked"]},
}

self.dict_logkavg[name] = {}
self.dict_logkhalfdiff[name] = {}
Expand Down