Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove expedients plugins because SOM will be default #1472

Merged
merged 3 commits into from
Nov 15, 2024
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
7 changes: 1 addition & 6 deletions straxen/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@
xnt_common_opts = common_opts.copy()
xnt_common_opts.update(
{
"register": list(common_opts["register"])
+ [
straxen.PeakletSOMClass,
straxen.PeaksSOMClassification,
straxen.EventSOMClassification,
],
"register": list(common_opts["register"]),
"register_all": list(common_opts["register_all"])
+ [
straxen.plugins,
Expand Down
62 changes: 0 additions & 62 deletions straxen/plugins/events/event_basics_som.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,65 +29,3 @@ def _set_dtype_requirements(self):
def compute(self, events, peaks):
result = super().compute(events, peaks)
return result


@export
class EventSOMClassification(strax.Plugin):
"""Plugin which propagates S1 SOM infromation to events as long straxen.PeakletClassification is
still used."""

depends_on = ("event_basics", "peak_som_classification")
__version__ = "0.0.1"

provides = "event_som_classification"

def infer_dtype(self):
dtype_peaklets = strax.time_fields + [
("s1_som_sub_type", np.int32, "Main S1 SOM subtype of the peak(let)"),
("s1_som_type", np.int8, "Main S1 SOM type of the peak(let)"),
("s1_loc_x_som", np.int16, "Main S1 x location of the peak(let) in the SOM"),
("s1_loc_y_som", np.int16, "Main S1 y location of the peak(let) in the SOM"),
("alt_s1_som_sub_type", np.int32, "Alt S1 SOM subtype of the peak(let)"),
("alt_s1_som_type", np.int8, "Alt S1 SOM type of the peak(let)"),
("alt_s1_loc_x_som", np.int16, "Alt S1 x location of the peak(let) in the SOM"),
("alt_s1_loc_y_som", np.int16, "Alt S1 y location of the peak(let) in the SOM"),
]
return dtype_peaklets

def propagate_field_to_event(self, peaks, events, events_som):
peaks_in_event = strax.split_by_containment(peaks, events)
return _propagate_field_to_event(peaks_in_event, events, events_som)

def compute(self, peaks, events):
events_som = np.zeros(len(events), self.dtype)
events_som[:] = -1
events_som["time"] = events["time"]
events_som["endtime"] = events["endtime"]

events_som = self.propagate_field_to_event(peaks, events, events_som)

return events_som


def _propagate_field_to_event(peaks_in_event, events, events_som):

for p_in_e, event, event_som in zip(peaks_in_event, events, events_som):
main_s1 = p_in_e[event["s1_index"]]
_main_s1_exist = event["s1_index"] != -1
if _main_s1_exist:
assert main_s1["time"] == event["s1_time"]
event_som["s1_som_sub_type"] = main_s1["som_sub_type"]
event_som["s1_som_type"] = main_s1["som_type"]
event_som["s1_loc_x_som"] = main_s1["loc_x_som"]
event_som["s1_loc_y_som"] = main_s1["loc_y_som"]

_alt_s1_exist = event["alt_s1_index"] != -1
if _alt_s1_exist:
alt_s1 = p_in_e[event["alt_s1_index"]]
assert alt_s1["time"] == event["alt_s1_time"], (alt_s1["time"], event["alt_s1_time"])
event_som["alt_s1_som_sub_type"] = alt_s1["som_sub_type"]
event_som["alt_s1_som_type"] = alt_s1["som_type"]
event_som["alt_s1_loc_x_som"] = alt_s1["loc_x_som"]
event_som["alt_s1_loc_y_som"] = alt_s1["loc_y_som"]

return events_som
14 changes: 0 additions & 14 deletions straxen/plugins/peaklets/peaklet_classification_som.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,3 @@ def compute_wf_attributes(data, sample_length, n_samples: int):
quantiles[i] = cumsum_steps[1:] - cumsum_steps[:-1]

return quantiles


@export
class PeakletSOMClass(PeakletClassificationSOM):
"""Plugin which allows in addition to the straxen classification the SOM classification."""

child_plugin = True
__version__ = "0.0.1"

provides = "peaklet_classification_som"

def compute(self, peaklets):
peaklet_classifcation_som = super().compute(peaklets)
return peaklet_classifcation_som
41 changes: 0 additions & 41 deletions straxen/plugins/peaks/peaks_som.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,3 @@ def compute(self, peaklets, merged_s2s):
result["som_sub_type"][_is_merged_s2] = -1

return result


@export
class PeaksSOMClassification(strax.Plugin):
"""Plugin which propagates S1 SOM infromation to peaks if straxen.PeakClassification is still
used."""

depends_on = ("peak_basics", "peaklet_classification_som")
__version__ = "0.0.1"

provides = "peak_som_classification"

def infer_dtype(self):
dtype_peaklets = strax.time_fields + [
("som_sub_type", np.int32, "SOM subtype of the peak(let)"),
("som_type", np.int8, "SOM type of the peak(let)"),
("loc_x_som", np.int16, "x location of the peak(let) in the SOM"),
("loc_y_som", np.int16, "y location of the peak(let) in the SOM"),
]
return dtype_peaklets

def compute(self, peaklets, peaks):
result = np.zeros(len(peaks), self.dtype)
result[:] = -1
result["time"] = peaks["time"]
result["endtime"] = peaks["endtime"]

# Only select S1 and update their SOM fields:
_is_s1_peaks = peaks["type"] == 1
_is_s1_som_peaklets = peaklets["straxen_type"] == 1
_are_same_s1_peaks = np.all(
result[_is_s1_peaks]["time"] == peaklets[_is_s1_som_peaklets]["time"]
)
assert _are_same_s1_peaks, "S1 peaks and SOM S1 peaklets are not identical?!?"

# Copy "manually" because only subset of data which does not work
# with copy to buffer:
for field in ("som_sub_type", "som_type", "loc_x_som", "loc_y_som"):
result[field][_is_s1_peaks] = peaklets[field][_is_s1_som_peaklets]

return result