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

start SOM plugin #313

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
dbb07b1
start SOM plugin
LuisSanchez25 Apr 14, 2024
8439fee
fix minor issues
LuisSanchez25 Apr 18, 2024
a8de47d
fix typo in init file
LuisSanchez25 Apr 18, 2024
ff8686c
fix compute function
LuisSanchez25 Apr 18, 2024
d4df772
remove depends and provides
LuisSanchez25 Apr 18, 2024
de7c2e4
remove peaklet -> to peaks
LuisSanchez25 Apr 18, 2024
9295a0a
add som model
LuisSanchez25 Apr 23, 2024
f91899f
change compute function
LuisSanchez25 Apr 24, 2024
4cb2aa7
fix path to SOM file
LuisSanchez25 Apr 24, 2024
12460bd
modify super function + other smaller issues
LuisSanchez25 Apr 24, 2024
7ee2a88
change model
LuisSanchez25 Apr 24, 2024
ce43e49
remove no type 0 assertion
LuisSanchez25 Apr 24, 2024
2d3d2fa
change date to decile function
LuisSanchez25 Apr 24, 2024
a06723b
add missing function + remove unnecessary class
LuisSanchez25 Apr 24, 2024
f590aa1
aft calculation added
LuisSanchez25 Apr 24, 2024
de47fae
change variable to right version
LuisSanchez25 Apr 24, 2024
d634332
AFT cacl change
LuisSanchez25 Apr 24, 2024
f25bb4c
change provides and datakind
LuisSanchez25 Apr 24, 2024
46ff026
include all peak code in peak_som
LuisSanchez25 May 13, 2024
4c95559
remove options causing conflicts
LuisSanchez25 May 13, 2024
0af507c
change inheritence
LuisSanchez25 May 13, 2024
ce6afe3
remove n_tpc_pmt option
LuisSanchez25 May 13, 2024
bf0b3bd
return n_tpc_pmt option, hardcoded
LuisSanchez25 May 13, 2024
1371981
merge_dtypes
LuisSanchez25 May 13, 2024
51d8036
merge_dtypes change format
LuisSanchez25 May 13, 2024
902c19c
manually combine datatypes
LuisSanchez25 May 13, 2024
b250355
stopped trying to merge dtypes, changed buffer to copy
LuisSanchez25 May 13, 2024
a5bd5c0
gut peak plugin. place in SOM plugin
LuisSanchez25 May 13, 2024
7a713c3
make separate plugin for classification
LuisSanchez25 May 16, 2024
94526ea
return configs to peaks
LuisSanchez25 May 16, 2024
1b886e9
refactor peaks
LuisSanchez25 May 16, 2024
6e9465f
remove circular import
LuisSanchez25 May 16, 2024
96db435
change xams_som context registration
LuisSanchez25 May 16, 2024
d384085
misspelled plugin fix
LuisSanchez25 May 16, 2024
590c5c3
misspelled plugin fix 2
LuisSanchez25 May 16, 2024
5e0585e
register peakwaveforms?
LuisSanchez25 May 16, 2024
326eae4
restart peak_wavefrom plugin
LuisSanchez25 May 16, 2024
4995a2d
modify context for SOM plugin
LuisSanchez25 May 16, 2024
bb76649
fix minor spelling mistake
LuisSanchez25 May 16, 2024
3b659f5
change context as test
LuisSanchez25 May 16, 2024
fb3526f
changed original peaks back to peaks
LuisSanchez25 May 16, 2024
dce8f2c
minor fix
LuisSanchez25 May 16, 2024
cf5866c
som plugin Peaks -> strax.Plugin
LuisSanchez25 May 16, 2024
3727a2f
back to square 1?
LuisSanchez25 May 16, 2024
76f7581
change pipeline to use merged_peaks instead
LuisSanchez25 May 16, 2024
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
18 changes: 18 additions & 0 deletions amstrax/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
ax.PulseProcessingEXT,
ax.PeaksEXT,
ax.PeakBasicsEXT,
#ax.PeakWaveforms,
#ax.PeaksSOM
# LED plugins not default
# ax.RecordsLED,
# ax.LEDCalibration,
Expand Down Expand Up @@ -100,6 +102,22 @@ def xams(output_folder='./strax_data',

return st

def xams_som(**kwargs):
"""XENONnT context for the SOM."""

st = ax.contexts.xams(**kwargs)
#del st._plugin_class_registry["peaks"]
st.register(
(
ax.PeaksSOM,
ax.MergedPeaks,
#straxen.EventBasicsSOM,
)
)

return st


def context_for_daq_reader(st: strax.Context,
run_id: str,
detector: str = 'xams',
Expand Down
2 changes: 1 addition & 1 deletion amstrax/plugins/events/event_area_per_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class EventAreaPerChannel(strax.Plugin):
"""Simple plugin that provides area per channel for main and alternative S1/S2 in the event."""

depends_on = ("event_basics", "peaks")
depends_on = ("event_basics", "merged_peaks")
provides = ("event_area_per_channel", "event_n_channel")
data_kind = immutabledict(zip(provides, ("events", "events")))
__version__ = "0.1.1"
Expand Down
2 changes: 1 addition & 1 deletion amstrax/plugins/events/event_waveform.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EventWaveform(strax.Plugin):
"""Simple plugin that provides total (data) and top (data_top) waveforms for main and
alternative S1/S2 in the event."""

depends_on = ("event_basics", "peaks")
depends_on = ("event_basics", "merged_peaks")
provides = "event_waveform"
__version__ = "0.0.1"

Expand Down
2 changes: 1 addition & 1 deletion amstrax/plugins/events/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'triggering peak'),
)
class Events(strax.OverlapWindowPlugin):
depends_on = ['peaks',
depends_on = ['merged_peaks',
'peak_basics',
]
rechunk_on_save = False
Expand Down
4 changes: 4 additions & 0 deletions amstrax/plugins/peaks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
from . import peak_positions
from .peak_positions import *

from . import peaks_som
from .peaks_som import *

from . import merged_peaks
from .merged_peaks import *
32 changes: 32 additions & 0 deletions amstrax/plugins/peaks/merged_peaks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import numpy as np
import numpy.lib.recfunctions as rfn
from scipy.spatial.distance import cdist
import os
import numba

import strax
#from amstrax import Peaks

export, __all__ = strax.exporter()

@export
class MergedPeaks(strax.MergeOnlyPlugin):
"""
Self-Organizing Maps (SOM)
https://xe1t-wiki.lngs.infn.it/doku.php?id=xenon:xenonnt:lsanchez:unsupervised_neural_network_som_methods
For peaklet classification. We this pluggin will provide 2 data types, the 'type' we are
already familiar with, classifying peaklets as s1, s2 (using the new classification) or
unknown (from the previous classification). As well as a new data type, SOM type, which
will be assigned numbers based on the cluster in the SOM in which they are found. For
each version I will make some documentation in the corrections repository explaining
what I believe each cluster represents.

This correction/plugin is currently on the testing phase, feel free to use it if you are
curious or just want to test it or try it out but note this is note ready to be used in
analysis.
"""
depends_on = ('peaks', 'peaks_som')
#data_kind = 'peaks'
# parallel = 'process'
provides = ('merged_peaks')

Check notice on line 32 in amstrax/plugins/peaks/merged_peaks.py

View check run for this annotation

codefactor.io / CodeFactor

amstrax/plugins/peaks/merged_peaks.py#L32

Trailing newlines (trailing-newlines)
7 changes: 4 additions & 3 deletions amstrax/plugins/peaks/peak_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
)
class PeakBasics(strax.Plugin):
provides = ("peak_basics",)
depends_on = ("peaks", )
depends_on = ("merged_peaks", )
data_kind = "peaks"

parallel = "False"
Expand Down Expand Up @@ -158,7 +158,8 @@
# 0 = unknown
# 1 = s1
# 2 = s2

"""

Check notice on line 161 in amstrax/plugins/peaks/peak_basics.py

View check run for this annotation

codefactor.io / CodeFactor

amstrax/plugins/peaks/peak_basics.py#L161

String statement has no effect (pointless-string-statement)
# Remove previous classification from peaks
is_s1 = p['area'] >= self.config['s1_min_area']
is_s1 &= r['range_50p_area'] > self.config['s1_min_width']
is_s1 &= r['range_50p_area'] < self.config['s1_max_width']
Expand All @@ -176,7 +177,7 @@

r['type'][is_s1] = 1
r['type'][is_s2] = 2

"""
return r


Expand Down
8 changes: 4 additions & 4 deletions amstrax/plugins/peaks/peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
strax.Option('diagnose_sorting', track=False, default=False,
help="Enable runtime checks for sorting and disjointness"),
strax.Option('n_tpc_pmts', track=False, default=False,
help="Number of channels"),
help="Number of channels"),
strax.Option('gain_to_pe_array', default=None,
help="Gain to pe array"),
)
Expand All @@ -51,13 +51,13 @@
__version__ = '0.1.50'

def infer_dtype(self):

return strax.peak_dtype(n_channels=self.config['n_tpc_pmts'])

def compute(self, records, start, end):

r = records

if self.config['gain_to_pe_array'] is None:
self.to_pe = np.ones(self.config['n_tpc_pmts'])
else:
Expand Down Expand Up @@ -90,4 +90,4 @@

strax.compute_widths(peaks)

return peaks
return peaks

Check notice on line 93 in amstrax/plugins/peaks/peaks.py

View check run for this annotation

codefactor.io / CodeFactor

amstrax/plugins/peaks/peaks.py#L93

Final newline missing (missing-final-newline)
Loading
Loading