From 1171f5627624e8fe74a1dffe03a56be884b81ea9 Mon Sep 17 00:00:00 2001 From: dachengx Date: Thu, 21 Nov 2024 15:35:49 -0600 Subject: [PATCH] Rename old `PeakletClassification` as `PeakletClassificationVanilla` --- straxen/plugins/events/__init__.py | 70 +++++++++---------- straxen/plugins/events/event_basics_som.py | 4 +- ...vent_basics.py => event_basics_vanilla.py} | 2 +- .../events/event_nearest_triggering.py | 2 +- straxen/plugins/events/event_shadow.py | 2 +- .../plugins/events_nv/event_positions_nv.py | 2 +- straxen/plugins/peaklets/__init__.py | 6 +- .../peaklets/peaklet_classification_som.py | 4 +- ...n.py => peaklet_classification_vanilla.py} | 4 +- .../peaklets_he/peaklet_classification_he.py | 11 +-- straxen/plugins/peaks/__init__.py | 52 +++++++------- straxen/plugins/peaks/_peak_positions_base.py | 4 +- straxen/plugins/peaks/peak_basics_som.py | 4 +- ...{peak_basics.py => peak_basics_vanilla.py} | 2 +- .../plugins/peaks/peak_nearest_triggering.py | 2 +- straxen/plugins/peaks/peak_per_event.py | 2 +- straxen/plugins/peaks/peaks_som.py | 6 +- .../peaks/{peaks.py => peaks_vanilla.py} | 2 +- straxen/plugins/peaks_he/peak_basics_he.py | 7 +- straxen/plugins/peaks_he/peaks_he.py | 9 +-- 20 files changed, 100 insertions(+), 97 deletions(-) rename straxen/plugins/events/{event_basics.py => event_basics_vanilla.py} (99%) rename straxen/plugins/peaklets/{peaklet_classification.py => peaklet_classification_vanilla.py} (98%) rename straxen/plugins/peaks/{peak_basics.py => peak_basics_vanilla.py} (99%) rename straxen/plugins/peaks/{peaks.py => peaks_vanilla.py} (98%) diff --git a/straxen/plugins/events/__init__.py b/straxen/plugins/events/__init__.py index a4e661e9c..e12992307 100644 --- a/straxen/plugins/events/__init__.py +++ b/straxen/plugins/events/__init__.py @@ -1,54 +1,63 @@ -from . import corrected_areas -from .corrected_areas import * +from . import events +from .events import * -from . import distinct_channels -from .distinct_channels import * +from . import event_basics_som +from .event_basics_som import * -from . import energy_estimates -from .energy_estimates import * +from . import event_basics_vanilla +from .event_basics_vanilla import * + +from . import event_positions +from .event_positions import * from . import event_ambience from .event_ambience import * -from . import event_area_per_channel -from .event_area_per_channel import * +from . import event_shadow +from .event_shadow import * -from . import event_waveform -from .event_waveform import * +from . import event_se_score +from .event_se_score import * -from . import event_top_bottom_params -from .event_top_bottom_params import * +from . import veto_proximity +from .veto_proximity import * -from . import event_basics -from .event_basics import * +from . import distinct_channels +from .distinct_channels import * + +from . import energy_estimates +from .energy_estimates import * + +from . import corrected_areas +from .corrected_areas import * from . import event_info from .event_info import * -from . import event_info_double -from .event_info_double import * +from . import event_area_per_channel +from .event_area_per_channel import * from . import event_pattern_fit from .event_pattern_fit import * -from . import event_positions -from .event_positions import * +from . import event_info_double +from .event_info_double import * -from . import event_shadow -from .event_shadow import * +from . import event_nearest_triggering +from .event_nearest_triggering import * + +from . import event_waveform +from .event_waveform import * + +from . import event_top_bottom_params +from .event_top_bottom_params import * from . import event_w_bayes_class from .event_w_bayes_class import * -from . import events -from .events import * - from . import s2_recon_pos_diff from .s2_recon_pos_diff import * -from . import veto_proximity -from .veto_proximity import * - from . import event_position_uncertainty from .event_position_uncertainty import * @@ -63,12 +72,3 @@ from . import multi_scatter from .multi_scatter import * - -from . import event_basics_som -from .event_basics_som import * - -from . import event_nearest_triggering -from .event_nearest_triggering import * - -from . import event_se_score -from .event_se_score import * diff --git a/straxen/plugins/events/event_basics_som.py b/straxen/plugins/events/event_basics_som.py index ea162f819..faf5529fc 100644 --- a/straxen/plugins/events/event_basics_som.py +++ b/straxen/plugins/events/event_basics_som.py @@ -1,13 +1,13 @@ import strax import numpy as np -from straxen.plugins.events.event_basics import EventBasics +from straxen.plugins.events.event_basics_vanilla import EventBasicsVanilla export, __all__ = strax.exporter() @export -class EventBasicsSOM(EventBasics): +class EventBasicsSOM(EventBasicsVanilla): """Adds SOM fields for S1 and S2 peaks to event basics.""" __version__ = "0.0.1" diff --git a/straxen/plugins/events/event_basics.py b/straxen/plugins/events/event_basics_vanilla.py similarity index 99% rename from straxen/plugins/events/event_basics.py rename to straxen/plugins/events/event_basics_vanilla.py index 3841503d2..1c34b1875 100644 --- a/straxen/plugins/events/event_basics.py +++ b/straxen/plugins/events/event_basics_vanilla.py @@ -8,7 +8,7 @@ @export -class EventBasics(strax.Plugin): +class EventBasicsVanilla(strax.Plugin): """Computes the basic properties of the main/alternative S1/S2 within an event. The main S1 and alternative S1 are given by the largest two S1-Peaks within the event. The main diff --git a/straxen/plugins/events/event_nearest_triggering.py b/straxen/plugins/events/event_nearest_triggering.py index 1ca25f5c3..1c854bc33 100644 --- a/straxen/plugins/events/event_nearest_triggering.py +++ b/straxen/plugins/events/event_nearest_triggering.py @@ -77,7 +77,7 @@ def compute(self, events, peaks): split_peaks = strax.split_by_containment(peaks, events) result = np.zeros(len(events), self.dtype) - straxen.EventBasics.set_nan_defaults(result) + straxen.EventBasicsVanilla.set_nan_defaults(result) # 1. Assign peaks features to main S1 and main S2 in the event for event_i, (event, sp) in enumerate(zip(events, split_peaks)): diff --git a/straxen/plugins/events/event_shadow.py b/straxen/plugins/events/event_shadow.py index 4a6258180..2616432c8 100644 --- a/straxen/plugins/events/event_shadow.py +++ b/straxen/plugins/events/event_shadow.py @@ -108,7 +108,7 @@ def compute(self, events, peaks): split_peaks = strax.split_by_containment(peaks, events) result = np.zeros(len(events), self.dtype) - straxen.EventBasics.set_nan_defaults(result) + straxen.EventBasicsVanilla.set_nan_defaults(result) # 1. Assign peaks features to main S1 and main S2 in the event for event_i, (event, sp) in enumerate(zip(events, split_peaks)): diff --git a/straxen/plugins/events_nv/event_positions_nv.py b/straxen/plugins/events_nv/event_positions_nv.py index 46b4ac179..87ab2e6df 100644 --- a/straxen/plugins/events_nv/event_positions_nv.py +++ b/straxen/plugins/events_nv/event_positions_nv.py @@ -54,7 +54,7 @@ def compute(self, events_nv, hitlets_nv): angle = get_average_angle(hits_in_events, self.pmt_properties) event_angles["angle"] = angle compute_positions(event_angles, hits_in_events, self.pmt_properties) - strax.copy_to_buffer(events_nv, event_angles, f"_copy_events_nv") + strax.copy_to_buffer(events_nv, event_angles, "_copy_events_nv") return event_angles diff --git a/straxen/plugins/peaklets/__init__.py b/straxen/plugins/peaklets/__init__.py index 9ae66bb4d..34db22130 100644 --- a/straxen/plugins/peaklets/__init__.py +++ b/straxen/plugins/peaklets/__init__.py @@ -1,12 +1,12 @@ from . import peaklets from .peaklets import * -from . import peaklet_classification -from .peaklet_classification import * - from . import peaklet_classification_som from .peaklet_classification_som import * +from . import peaklet_classification_vanilla +from .peaklet_classification_vanilla import * + from . import peaklet_positions_cnf from .peaklet_positions_cnf import * diff --git a/straxen/plugins/peaklets/peaklet_classification_som.py b/straxen/plugins/peaklets/peaklet_classification_som.py index 7534ae17d..8f761c83e 100644 --- a/straxen/plugins/peaklets/peaklet_classification_som.py +++ b/straxen/plugins/peaklets/peaklet_classification_som.py @@ -1,7 +1,7 @@ import numpy as np import numpy.lib.recfunctions as rfn from scipy.spatial.distance import cdist -from straxen.plugins.peaklets.peaklet_classification import PeakletClassification +from straxen.plugins.peaklets.peaklet_classification_vanilla import PeakletClassificationVanilla import numba import strax @@ -11,7 +11,7 @@ @export -class PeakletClassificationSOM(PeakletClassification): +class PeakletClassificationSOM(PeakletClassificationVanilla): """ Self-Organizing Maps (SOM) https://xe1t-wiki.lngs.infn.it/doku.php?id=xenon:xenonnt:lsanchez:unsupervised_neural_network_som_methods diff --git a/straxen/plugins/peaklets/peaklet_classification.py b/straxen/plugins/peaklets/peaklet_classification_vanilla.py similarity index 98% rename from straxen/plugins/peaklets/peaklet_classification.py rename to straxen/plugins/peaklets/peaklet_classification_vanilla.py index 6385c0a2b..8f74b3546 100644 --- a/straxen/plugins/peaklets/peaklet_classification.py +++ b/straxen/plugins/peaklets/peaklet_classification_vanilla.py @@ -9,13 +9,13 @@ @export -class PeakletClassification(strax.Plugin): +class PeakletClassificationVanilla(strax.Plugin): """Classify peaklets as unknown, S1, or S2.""" __version__ = "3.0.3" - provides: Union[str, tuple] = "peaklet_classification" depends_on = "peaklets" + provides: Union[str, tuple] = "peaklet_classification" dtype = strax.peak_interval_dtype + [("type", np.int8, "Classification of the peak(let)")] s1_risetime_area_parameters = straxen.URLConfig( diff --git a/straxen/plugins/peaklets_he/peaklet_classification_he.py b/straxen/plugins/peaklets_he/peaklet_classification_he.py index 4af9a9e1d..e582792a8 100644 --- a/straxen/plugins/peaklets_he/peaklet_classification_he.py +++ b/straxen/plugins/peaklets_he/peaklet_classification_he.py @@ -1,18 +1,19 @@ import strax -from straxen.plugins.peaklets.peaklet_classification import PeakletClassification +from straxen.plugins.peaklets.peaklet_classification_vanilla import PeakletClassificationVanilla from straxen.plugins.defaults import HE_PREAMBLE export, __all__ = strax.exporter() @export -class PeakletClassificationHighEnergy(PeakletClassification): - __doc__ = HE_PREAMBLE + (PeakletClassification.__doc__ or "") - provides = "peaklet_classification_he" - depends_on = "peaklets_he" +class PeakletClassificationHighEnergy(PeakletClassificationVanilla): + __doc__ = HE_PREAMBLE + (PeakletClassificationVanilla.__doc__ or "") + __version__ = "0.0.2" child_plugin = True + depends_on = "peaklets_he" + provides = "peaklet_classification_he" def compute(self, peaklets_he): return super().compute(peaklets_he) diff --git a/straxen/plugins/peaks/__init__.py b/straxen/plugins/peaks/__init__.py index 217a7dc8d..996aab675 100644 --- a/straxen/plugins/peaks/__init__.py +++ b/straxen/plugins/peaks/__init__.py @@ -1,17 +1,14 @@ -from . import peak_top_bottom_params -from .peak_top_bottom_params import * - -from . import peak_ambience -from .peak_ambience import * +from . import peaks_som +from .peaks_som import * -from . import peak_basics -from .peak_basics import * +from . import peaks_vanilla +from .peaks_vanilla import * -from . import peak_classification_bayes -from .peak_classification_bayes import * +from . import peak_basics_som +from .peak_basics_som import * -from . import peak_s1_positions_cnn -from .peak_s1_positions_cnn import * +from . import peak_basics_vanilla +from .peak_basics_vanilla import * from . import peak_positions_cnf from .peak_positions_cnf import * @@ -22,14 +19,26 @@ from . import peak_positions from .peak_positions import * -from . import peak_proximity -from .peak_proximity import * +from . import peak_ambience +from .peak_ambience import * from . import peak_shadow from .peak_shadow import * -from . import peaks -from .peaks import * +from . import peak_se_score +from .peak_se_score import * + +from . import peak_proximity +from .peak_proximity import * + +from . import peak_nearest_triggering +from .peak_nearest_triggering import * + +from . import peak_top_bottom_params +from .peak_top_bottom_params import * + +from . import peak_s1_positions_cnn +from .peak_s1_positions_cnn import * from . import peak_per_event from .peak_per_event import * @@ -37,14 +46,5 @@ from . import peak_corrections from .peak_corrections import * -from . import peaks_som -from .peaks_som import * - -from . import peak_basics_som -from .peak_basics_som import * - -from . import peak_nearest_triggering -from .peak_nearest_triggering import * - -from . import peak_se_score -from .peak_se_score import * +from . import peak_classification_bayes +from .peak_classification_bayes import * diff --git a/straxen/plugins/peaks/_peak_positions_base.py b/straxen/plugins/peaks/_peak_positions_base.py index 14c036bb4..051304d61 100644 --- a/straxen/plugins/peaks/_peak_positions_base.py +++ b/straxen/plugins/peaks/_peak_positions_base.py @@ -1,11 +1,11 @@ import strax -from .peaks import Peaks +from .peaks_vanilla import PeaksVanilla export, __all__ = strax.exporter() @export -class PeakPositionsBase(Peaks): +class PeakPositionsBase(PeaksVanilla): __version__ = "0.0.0" child_plugin = True diff --git a/straxen/plugins/peaks/peak_basics_som.py b/straxen/plugins/peaks/peak_basics_som.py index e000c565b..b4df54e3a 100644 --- a/straxen/plugins/peaks/peak_basics_som.py +++ b/straxen/plugins/peaks/peak_basics_som.py @@ -1,12 +1,12 @@ import numpy as np import strax -from straxen.plugins.peaks.peak_basics import PeakBasics +from straxen.plugins.peaks.peak_basics_vanilla import PeakBasicsVanilla export, __all__ = strax.exporter() @export -class PeakBasicsSOM(PeakBasics): +class PeakBasicsSOM(PeakBasicsVanilla): """Adds SOM fields to peak basics to be propgated to event basics.""" __version__ = "0.0.1" diff --git a/straxen/plugins/peaks/peak_basics.py b/straxen/plugins/peaks/peak_basics_vanilla.py similarity index 99% rename from straxen/plugins/peaks/peak_basics.py rename to straxen/plugins/peaks/peak_basics_vanilla.py index 00cd72ba1..391a2af6b 100644 --- a/straxen/plugins/peaks/peak_basics.py +++ b/straxen/plugins/peaks/peak_basics_vanilla.py @@ -8,7 +8,7 @@ @export -class PeakBasics(strax.Plugin): +class PeakBasicsVanilla(strax.Plugin): """Compute the basic peak-properties, thereby dropping structured arrays. NB: This plugin can therefore be loaded as a pandas DataFrame. diff --git a/straxen/plugins/peaks/peak_nearest_triggering.py b/straxen/plugins/peaks/peak_nearest_triggering.py index a016fb8e0..d7ab3366b 100644 --- a/straxen/plugins/peaks/peak_nearest_triggering.py +++ b/straxen/plugins/peaks/peak_nearest_triggering.py @@ -79,7 +79,7 @@ def compute_triggering(self, peaks, current_peak): _peaks = _peaks[_is_triggering] # init result result = np.zeros(len(current_peak), self.dtype) - straxen.EventBasics.set_nan_defaults(result) + straxen.EventBasicsVanilla.set_nan_defaults(result) # use center_time as the anchor of things things = np.zeros(len(_peaks), dtype=strax.time_fields) diff --git a/straxen/plugins/peaks/peak_per_event.py b/straxen/plugins/peaks/peak_per_event.py index 5de47b423..c6da7f0f9 100644 --- a/straxen/plugins/peaks/peak_per_event.py +++ b/straxen/plugins/peaks/peak_per_event.py @@ -30,7 +30,7 @@ def compute(self, events, peaks): split_peaks = strax.split_by_containment(peaks, events) split_peaks_ind = strax.fully_contained_in(peaks, events) result = np.zeros(len(peaks), self.dtype) - straxen.EventBasics.set_nan_defaults(result) + straxen.EventBasicsVanilla.set_nan_defaults(result) # Assign peaks features to main S1 and main S2 in the event for event_i, (event, sp) in enumerate(zip(events, split_peaks)): diff --git a/straxen/plugins/peaks/peaks_som.py b/straxen/plugins/peaks/peaks_som.py index 3a28649b3..fb428a97e 100644 --- a/straxen/plugins/peaks/peaks_som.py +++ b/straxen/plugins/peaks/peaks_som.py @@ -1,12 +1,12 @@ import strax import numpy as np -from straxen.plugins.peaks.peaks import Peaks +from straxen.plugins.peaks.peaks_vanilla import PeaksVanilla export, __all__ = strax.exporter() @export -class PeaksSOM(Peaks): +class PeaksSOM(PeaksVanilla): """Same as Peaks but include in addition SOM type field to be propagated to event_basics. Thus, only change dtype. @@ -30,7 +30,7 @@ def infer_dtype(self): def compute(self, peaklets, merged_s2s): result = super().compute(peaklets, merged_s2s) - # For merged S2s SOM and straxen type are undefined: + # For merged_s2s SOM and straxen type are undefined: _is_merged_s2 = np.isin(result["time"], merged_s2s["time"]) & np.isin( strax.endtime(result), strax.endtime(merged_s2s) ) diff --git a/straxen/plugins/peaks/peaks.py b/straxen/plugins/peaks/peaks_vanilla.py similarity index 98% rename from straxen/plugins/peaks/peaks.py rename to straxen/plugins/peaks/peaks_vanilla.py index e3580bc9e..a51495c08 100644 --- a/straxen/plugins/peaks/peaks.py +++ b/straxen/plugins/peaks/peaks_vanilla.py @@ -9,7 +9,7 @@ @export -class Peaks(strax.Plugin): +class PeaksVanilla(strax.Plugin): """Merge peaklets and merged S2s such that we obtain our peaks (replacing all peaklets that were later re-merged as S2s). diff --git a/straxen/plugins/peaks_he/peak_basics_he.py b/straxen/plugins/peaks_he/peak_basics_he.py index 6711dff33..234dde4f3 100644 --- a/straxen/plugins/peaks_he/peak_basics_he.py +++ b/straxen/plugins/peaks_he/peak_basics_he.py @@ -1,14 +1,15 @@ import strax from straxen.plugins.defaults import HE_PREAMBLE -from straxen.plugins.peaks.peak_basics import PeakBasics +from straxen.plugins.peaks.peak_basics_vanilla import PeakBasicsVanilla export, __all__ = strax.exporter() @export -class PeakBasicsHighEnergy(PeakBasics): - __doc__ = HE_PREAMBLE + (PeakBasics.__doc__ or "") +class PeakBasicsHighEnergy(PeakBasicsVanilla): + __doc__ = HE_PREAMBLE + (PeakBasicsVanilla.__doc__ or "") + __version__ = "0.0.2" depends_on = "peaks_he" provides = "peak_basics_he" diff --git a/straxen/plugins/peaks_he/peaks_he.py b/straxen/plugins/peaks_he/peaks_he.py index 9ff167807..8a2cea9bf 100644 --- a/straxen/plugins/peaks_he/peaks_he.py +++ b/straxen/plugins/peaks_he/peaks_he.py @@ -1,17 +1,18 @@ import strax from straxen.plugins.defaults import HE_PREAMBLE -from straxen.plugins.peaks.peaks import Peaks +from straxen.plugins.peaks.peaks_vanilla import PeaksVanilla export, __all__ = strax.exporter() @export -class PeaksHighEnergy(Peaks): - __doc__ = HE_PREAMBLE + (Peaks.__doc__ or "") +class PeaksHighEnergy(PeaksVanilla): + __doc__ = HE_PREAMBLE + (PeaksVanilla.__doc__ or "") + + __version__ = "0.0.1" depends_on = ("peaklets_he", "peaklet_classification_he", "merged_s2s_he") data_kind = "peaks_he" provides = "peaks_he" - __version__ = "0.0.1" child_ends_with = "_he" def infer_dtype(self):