Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 30, 2024
1 parent a5ac0b1 commit e58f5c4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions viewer/feminos-viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ def white_to_jet(n):


def amplitude_to_color(
amplitude, min_amplitude=0, max_amplitude=4095, cmap_name="jet", log_scale=True
amplitude, min_amplitude=0, max_amplitude=4095, cmap_name="jet", log_scale=True
):
amplitude = max(amplitude, min_amplitude)

Expand All @@ -1625,7 +1625,7 @@ def amplitude_to_color(
else:
# Linear scaling
normalized_amplitude = (amplitude - min_amplitude) / (
max_amplitude - min_amplitude
max_amplitude - min_amplitude
)

# Normalize the value to be between 0 and 1
Expand Down Expand Up @@ -1675,9 +1675,9 @@ def get_event(tree: uproot.TTree, entry: int):

@njit
def compute_energy_estimate(
event: ak.highlevel.Record,
signal_ids_allowed: set[int],
baseline_range: float = 0.2,
event: ak.highlevel.Record,
signal_ids_allowed: set[int],
baseline_range: float = 0.2,
) -> float:
energy = 0.0
baseline_factor = int(baseline_range * len(event.signals.values[0]))
Expand All @@ -1697,7 +1697,7 @@ def compute_energy_estimate(

@njit
def compute_energy_of_waveform(
waveform: np.ndarray, baseline_range: float = 0.2
waveform: np.ndarray, baseline_range: float = 0.2
) -> float:
baseline_factor = int(baseline_range * len(waveform))
return np.max(waveform) - np.mean(waveform[:baseline_factor])
Expand Down Expand Up @@ -1770,7 +1770,7 @@ def __init__(self, _root):
self.readout_menu.pack(side=tk.LEFT, padx=20, pady=5)
self.selected_readout.set("IAXO-D1")
assert (
self.selected_readout.get() in readouts
self.selected_readout.get() in readouts
), f"Invalid readout {self.selected_readout.get()}. Available readouts are {readouts.keys()}"
self.readout_signal_ids = set(readouts[self.readout]["mapping"].keys())

Expand Down Expand Up @@ -2065,7 +2065,9 @@ def load_file(self):

def open_local_file(self, filename: str | None = None):
if filename is None:
self.filepath = filedialog.askopenfilename(filetypes=[("ROOT files", "*.root")])
self.filepath = filedialog.askopenfilename(
filetypes=[("ROOT files", "*.root")]
)
if not self.filepath:
return
else:
Expand Down Expand Up @@ -2314,7 +2316,7 @@ def plot_event_time(self):

signal_type = readouts[self.readout]["mapping"][int(signal_id)][0]
assert (
len(values) == 512
len(values) == 512
), f"Signal {signal_id} has {len(values)} bins, not 512"
for i in range(len(values)):
value = values[i]
Expand Down Expand Up @@ -2379,8 +2381,8 @@ def plot_readout_observables(self):
energy_estimate_quantile = 0.99

observable_energy_estimate = self.observable_energy_estimate[
: int(len(self.observable_energy_estimate) * energy_estimate_quantile)
]
: int(len(self.observable_energy_estimate) * energy_estimate_quantile)
]

self.ax_left.hist(
observable_energy_estimate,
Expand Down Expand Up @@ -2445,13 +2447,13 @@ def plot_readout_activity_x_y(self):
signal_id
for signal_id in self.observable_channel_activity.keys()
if signal_id in self.readout_signal_ids
and readouts[self.readout]["mapping"][signal_id][0] == "X"
and readouts[self.readout]["mapping"][signal_id][0] == "X"
]
signal_ids_y = [
signal_id
for signal_id in self.observable_channel_activity.keys()
if signal_id in self.readout_signal_ids
and readouts[self.readout]["mapping"][signal_id][0] == "Y"
and readouts[self.readout]["mapping"][signal_id][0] == "Y"
]

positions_x = [
Expand Down

0 comments on commit e58f5c4

Please sign in to comment.