Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1068 commits
Select commit Hold shift + click to select a range
2b78d0b
fix typo
TjarkMiener Jul 2, 2024
f65b073
use astropy to get the sky offset and separation from tel poiting and…
TjarkMiener Jul 3, 2024
c1f197a
Merge pull request #135 from cta-observatory/sky_offset
TjarkMiener Jul 8, 2024
8bf417b
Update reader.py
nietootein Jul 8, 2024
c224989
Update README.rst
nietootein Jul 8, 2024
0cd6951
Merge branch 'master' into dbscan_output
nietootein Jul 8, 2024
63d5621
Merge pull request #134 from cta-observatory/dbscan_output
TjarkMiener Jul 9, 2024
b7c4177
Update README.rst
TjarkMiener Jul 9, 2024
0244966
Merge pull request #136 from cta-observatory/TjarkMiener-patch-1
TjarkMiener Jul 9, 2024
ff21a16
Update release.yml
rcervinoucm Jul 9, 2024
4d757fd
Merge pull request #137 from cta-observatory/rcervinoucm-patch-3
TjarkMiener Jul 9, 2024
92d4e1a
Update release.yml
rcervinoucm Jul 9, 2024
257fee6
Update release.yml
rcervinoucm Jul 9, 2024
3d6256e
version update
rcervinoucm Jul 9, 2024
9d04a28
Update release.yml
rcervinoucm Jul 9, 2024
2c2b386
Update release.yml
rcervinoucm Jul 9, 2024
a988eef
Update release.yml
rcervinoucm Jul 9, 2024
e628f2c
Update release.yml
rcervinoucm Jul 9, 2024
0b93d14
Update release.yml
rcervinoucm Jul 9, 2024
ad3f5bd
Files must be open as read mode only, IOC The user can not open the f…
Pablitinho Jul 15, 2024
d15c642
Merge pull request #139 from Pablitinho/example_identifiers_file_open…
TjarkMiener Jul 15, 2024
ee2f825
Merge pull request #138 from cta-observatory/testRelease
TjarkMiener Jul 15, 2024
e81f1d6
add temp support for LST-1 dl1 image data in v5.0.0
TjarkMiener Jul 16, 2024
23bebdb
revert reading mode from example_identifiers_file
TjarkMiener Jul 16, 2024
b26f995
specify exception to be IOError
TjarkMiener Jul 16, 2024
ab08dad
add check to disable quality cuts when processing real data
TjarkMiener Jul 16, 2024
cd9d7bb
read also telescope trigger table
TjarkMiener Jul 17, 2024
5b81f21
Delete setup.py
rcervinoucm Jul 18, 2024
4b1fff7
Update .gitignore
rcervinoucm Jul 18, 2024
d046759
Update __init__.py
rcervinoucm Jul 18, 2024
d4ee49a
Delete dl1_data_handler/version.py
rcervinoucm Jul 18, 2024
eaa67b6
Delete dl1_data_handler/versionScript.py
rcervinoucm Jul 18, 2024
ac7cfc7
Delete .github/versionBackup.txt
rcervinoucm Jul 18, 2024
35d2531
Create pyproject.toml
rcervinoucm Jul 18, 2024
34298c9
Update build.sh
rcervinoucm Jul 18, 2024
2b98ebc
Update bld.bat
rcervinoucm Jul 18, 2024
a8564e9
Update meta.yaml
rcervinoucm Jul 18, 2024
39143e1
Update meta.yaml
rcervinoucm Jul 18, 2024
2b535e4
Update python-package-conda.yml
rcervinoucm Jul 18, 2024
dcabac3
Update release.yml
rcervinoucm Jul 18, 2024
42f2e97
Update pyproject.toml
rcervinoucm Jul 18, 2024
f942431
Merge pull request #140 from cta-observatory/allow_v5.0.0_real_data
TjarkMiener Jul 18, 2024
b67a604
moved _get_image oustide the dl1dh reader
TjarkMiener Jul 19, 2024
2d7178c
move _get_waveform() outside the dl1dh reader as well
TjarkMiener Jul 22, 2024
1f14734
removed flip for LST-1 real because it is not needed
TjarkMiener Jul 22, 2024
9d98666
renamed get_mapped_trigger_patch to get_mapped_triggerpatch
TjarkMiener Jul 22, 2024
0d32b91
remove trigger for stereo example description
TjarkMiener Jul 22, 2024
45de5fc
remove prefix support for camera_frame
TjarkMiener Jul 22, 2024
ccb174b
rename and join parameter_selection and event_selection to quality_se…
TjarkMiener Jul 22, 2024
9d52e9d
allow quality cuts for processing real data
TjarkMiener Jul 22, 2024
cbe4b42
Update release.yml
rcervinoucm Jul 23, 2024
ead2192
Delete .github/conda directory
rcervinoucm Jul 23, 2024
57255ea
major refactoring for batch generation
TjarkMiener Aug 5, 2024
6341a2c
removed redundant event and subarray info
TjarkMiener Aug 5, 2024
2bab416
edit path to pointing table
TjarkMiener Aug 5, 2024
c2abfdb
fix shape of trigger patch
TjarkMiener Aug 6, 2024
2797b08
fix get trigger features
TjarkMiener Aug 6, 2024
6f8e236
remove processor and transforms
TjarkMiener Aug 6, 2024
aa04da4
fix stereo reading mode
TjarkMiener Aug 8, 2024
ad1c206
keep simulation info in an astropy table
TjarkMiener Aug 8, 2024
c886d52
removed v5.0.0 support for real data and images
TjarkMiener Aug 8, 2024
8c3f52f
use ctapipe SubarrayDescription for setting up
TjarkMiener Aug 9, 2024
dd7dddc
define reading API
TjarkMiener Aug 9, 2024
b2a04c4
added classes into __all__
TjarkMiener Aug 9, 2024
2459bd2
pass batch to _get_features() and return feature dict and batch Table
TjarkMiener Aug 11, 2024
9cc587b
remove redundant flip
TjarkMiener Aug 11, 2024
149ea1b
make image mapper methos as API
TjarkMiener Sep 10, 2024
692e3a4
simplify map_image()
TjarkMiener Sep 10, 2024
b6c7af9
make reader as API
TjarkMiener Sep 11, 2024
e0312d9
polish docstrings
TjarkMiener Sep 12, 2024
43b6561
removed multiple locks
TjarkMiener Sep 12, 2024
379eca2
remove magic numbers by constants
TjarkMiener Sep 18, 2024
a0761b4
calculate class weights with floats
TjarkMiener Sep 18, 2024
c912337
get default image shape from the data
TjarkMiener Sep 18, 2024
9296b3c
use f-string
TjarkMiener Sep 18, 2024
900c8b2
make process type an enum
TjarkMiener Sep 18, 2024
9a93276
added the data loader with keras api
TjarkMiener Sep 19, 2024
db01b2a
remove files from config and pass them in the contructor
TjarkMiener Oct 16, 2024
92b8466
update to ctapipe v0.22.0
TjarkMiener Oct 16, 2024
8b01e43
temp fix keras/TF bug
TjarkMiener Oct 17, 2024
7aa503e
bug fix
TjarkMiener Oct 17, 2024
7e362ee
added skeleton for on-the-fly waveform cleaning with digital sum and …
TjarkMiener Oct 18, 2024
1944bbf
support keras2 & keras3
TjarkMiener Oct 18, 2024
5d1a8ef
bug fix; import keras
TjarkMiener Oct 18, 2024
2b31c4b
log number of particles per type
TjarkMiener Oct 30, 2024
c69be4e
fix logger
TjarkMiener Oct 30, 2024
93d9bd6
set BilinearMapper as default
TjarkMiener Oct 30, 2024
e2a0035
comment out qual cuts
TjarkMiener Oct 30, 2024
5d1f073
add a sort and remove the shuffle in the loader for prediction
TjarkMiener Nov 24, 2024
3c9aaa0
fix proper treatment of channels with relative and cleaned options
TjarkMiener Nov 24, 2024
8a657f4
fix ToDo string
TjarkMiener Nov 24, 2024
1237bc5
fix help for channels
TjarkMiener Nov 24, 2024
e9f76ff
upgrade to ctapipe v0.23.0
TjarkMiener Nov 25, 2024
aaf4b1b
retrieve trigger table also for MCs
TjarkMiener Nov 26, 2024
c820d6a
only apply transformation to sims data
TjarkMiener Nov 26, 2024
36841cc
add tel_id in sort
TjarkMiener Nov 27, 2024
a1b66e9
fix on_epoch_end
TjarkMiener Nov 27, 2024
fb64d8f
polish docstring
TjarkMiener Nov 27, 2024
990e352
add tick smoothing for RealLSTCam
TjarkMiener Nov 28, 2024
40af165
added blank features to the batch
TjarkMiener Dec 2, 2024
c56c2a1
added support for reading and loading stereo events
TjarkMiener Dec 3, 2024
be5c43c
make get_parameters external callable
TjarkMiener Dec 3, 2024
09bd3a9
polish docstrings
TjarkMiener Dec 3, 2024
68802db
fix docstrings
TjarkMiener Dec 3, 2024
05d2ace
bug fix to create event based on the type
TjarkMiener Dec 11, 2024
e91f39e
bug fix; loc returned Rows object for a single event in the batch whi…
TjarkMiener Dec 31, 2024
00156e1
add reference dummy location and obstime for SkyCoord object to avoid…
TjarkMiener Jan 7, 2025
01c37b3
bug fix; processing real stereo data
TjarkMiener Jan 9, 2025
c5706a5
fix import
TjarkMiener Jan 9, 2025
7c469cc
added a new reader for feature vectors (DLFeatureVectorReader)
TjarkMiener Jan 13, 2025
30d7b55
support data format v5.0.0 for real data
TjarkMiener Jan 13, 2025
947fa39
allow to read the pointing from both dl0 or dl1; dl1 has priority
TjarkMiener Jan 13, 2025
ffcc42f
add check if pointing table is available
TjarkMiener Jan 13, 2025
c511a0e
polish docstring
TjarkMiener Jan 13, 2025
cbac197
polish docstrings
TjarkMiener Jan 14, 2025
15393f0
move generation of batch to __getitem__()
TjarkMiener Jan 14, 2025
37c63fc
fix args from get mono and stereo function
TjarkMiener Jan 14, 2025
c24b120
fix AdvCam
TjarkMiener Feb 6, 2025
5c2b27b
fix stereo reading
TjarkMiener Feb 6, 2025
16cf8db
move constants to class
TjarkMiener Feb 6, 2025
a09c747
fix constants class attribute
TjarkMiener Feb 6, 2025
7847107
add minimal unit test
TjarkMiener Feb 10, 2025
a15468f
add also unit test for R1 reading
TjarkMiener Feb 10, 2025
f8964bf
add the r1 waveform reading unit test
TjarkMiener Feb 10, 2025
14bacc7
upgrade to ctapipe v0.23.2
TjarkMiener Feb 10, 2025
a023030
add test for the loader
TjarkMiener Feb 10, 2025
04609ef
move data loader to ctlearn
TjarkMiener Feb 10, 2025
698b2a8
Merge pull request #142 from cta-observatory/updateBuildConfig
TjarkMiener Feb 10, 2025
d0c539b
resolve merge conflicts
TjarkMiener Feb 10, 2025
2858037
speed up pytest by adding testpaths
TjarkMiener Feb 10, 2025
ad7d0cb
remove filelock because we do not use multi-processes in pytest
TjarkMiener Feb 10, 2025
874f261
add functions to close all open files and use it in the test
TjarkMiener Feb 10, 2025
590a516
Update python-package-conda.yml
rcervinoucm Feb 11, 2025
b219c1d
Update python-package-conda.yml
rcervinoucm Feb 11, 2025
cec14ab
Update python-package-conda.yml
rcervinoucm Feb 11, 2025
f59ec6f
use __destructor rather than close_files()
TjarkMiener Feb 11, 2025
8fff673
Update .zenodo.json
nietootein Feb 11, 2025
071d9ed
Update .zenodo.json
nietootein Feb 11, 2025
5decf4a
Merge pull request #143 from cta-observatory/move_get_image
TjarkMiener Feb 11, 2025
522d1e7
Add variable to skip quality checks
Feb 17, 2025
216bcb0
Add r0 waveform reader (full camera)
Feb 17, 2025
a921dbb
Correct start and stop sample definition
Feb 17, 2025
5989761
Introduce patches and random trigger patch
Feb 17, 2025
4ccb3f0
Add column with real number of Cherenkov to the batch
Feb 18, 2025
5a5fcec
Small reordering
Feb 18, 2025
fb69d9f
Introduce setting to get hot pixel from simulation
Feb 18, 2025
98ea97b
First implementation of balanced (nsb/cosmic) number of patches output
Feb 20, 2025
6a96306
fix camera coordinates & sky spherical offset calc
TjarkMiener Feb 20, 2025
e942a02
allow ctapipe version to be 0.22.0
TjarkMiener Feb 20, 2025
61c593d
fix typo
TjarkMiener Feb 20, 2025
94ebd58
fix mono mode
TjarkMiener Feb 20, 2025
3c6d55b
fix typo
TjarkMiener Feb 20, 2025
32361ec
fix typo
TjarkMiener Feb 20, 2025
4219383
remove old copy
TjarkMiener Feb 20, 2025
f13c6db
move sim info reading
TjarkMiener Feb 20, 2025
d4456a0
fix joining of table
TjarkMiener Feb 21, 2025
0c9999b
fix pytest
TjarkMiener Feb 21, 2025
8b70133
Do the patch counting in the example identifier
Feb 21, 2025
ea5b986
Changes to append features
Feb 21, 2025
f6735b1
Generate mono batch with append features
Feb 21, 2025
776ba4c
tuple error fixed by itering in rows
Feb 21, 2025
14fb916
move calc of cam coord offset and distance when readng the tel table
TjarkMiener Feb 23, 2025
a33556d
make get_tel_pointing only retrieve one tel
TjarkMiener Feb 23, 2025
571fab9
polish comments
TjarkMiener Feb 23, 2025
a9b4261
polish docstring
TjarkMiener Feb 23, 2025
8b7c12c
also use nominal frame for sky spherical offsets
TjarkMiener Feb 24, 2025
14ec1ce
Indexing
Feb 24, 2025
aac4946
Changes in append feature
Feb 24, 2025
61f5fea
correct append features
Feb 24, 2025
f377a7a
Allow interleave patches and reordering
Feb 24, 2025
6fdfb58
Fix bugs
jbuces Feb 24, 2025
f2dccef
prep for v0.14.0
TjarkMiener Feb 24, 2025
8875899
Last version of computing balanced patches in example identifiers
jbuces Feb 25, 2025
b20f264
Add all patches option
jbuces Feb 25, 2025
ec11d2e
small changes
jbuces Feb 25, 2025
e85512a
Merge pull request #150 from cta-observatory/fix_cam_coord
TjarkMiener Feb 25, 2025
7e945d1
all patches and double random but very slow
jbuces Feb 26, 2025
e0377b5
Optimization and get_true_image
jbuces Feb 26, 2025
7c51eb6
Optimization of the rest of output settings
jbuces Feb 26, 2025
ad971cb
Optimization in rest of output settings
jbuces Feb 27, 2025
f28f6d9
nb
jbuces Feb 27, 2025
476d3ce
Merge tag 'v0.14.0' into example_identifiers
jbuces Feb 27, 2025
649497d
small bugs and remove some prints
jbuces Feb 27, 2025
c4134f6
Add -1 waveform if not nsb or cosmic patches
jbuces Feb 27, 2025
7550e27
nsb_threshold -> cpe_threshold
jbuces Feb 27, 2025
be8c44e
add def to see if image and wf readers work
jbuces Feb 27, 2025
3727957
All options including r1 and image work well
jbuces Feb 27, 2025
d1bcdb8
Reorganise append features
jbuces Feb 27, 2025
46cf189
Reorganise append features and all ex identifiers have same columns
jbuces Feb 28, 2025
83aaf43
Same order and names for generate batch cols
jbuces Feb 28, 2025
cb047bb
Reducing lines
jbuces Feb 28, 2025
5ee297b
nsbness -> patch_class
jbuces Feb 28, 2025
4a28972
remove unnecessary trigger patches xpos from function
jbuces Feb 28, 2025
3e8bb38
comments and nb
jbuces Feb 28, 2025
a7b61fa
nbs
jbuces Feb 28, 2025
a26aab7
nbs
jbuces Mar 2, 2025
2ba2ed7
removing unnecessary nbs
jbuces Mar 2, 2025
b29f8e4
Add class_weight for balanced and double random
jbuces Mar 3, 2025
7f035e1
Fix and add n_bkg_events and n_signal_events
jbuces Mar 3, 2025
577faa6
Remove interleave patches (keep order non compatible), add tel_index …
jbuces Mar 5, 2025
e63de13
untab
jbuces Mar 5, 2025
2f3c174
Add random patch instead of -1 for balanced with comparator 0
jbuces Mar 6, 2025
5a4de8c
typo randint
jbuces Mar 6, 2025
026e8fa
bugfix pixel rotation
TjarkMiener Mar 8, 2025
0c8c6ca
prep v0.14.1
TjarkMiener Mar 8, 2025
1ce750a
Fixing typo
nietootein Mar 10, 2025
f2c8da1
Correct input shape after defining patches
jbuces Mar 10, 2025
26faa57
Updating version
nietootein Mar 11, 2025
3139aa9
formatting using black
TjarkMiener Mar 11, 2025
a444420
Small typo in comment
nietootein Mar 12, 2025
db725dd
Merge pull request #152 from cta-observatory/bugfix_pixrotation
TjarkMiener Mar 12, 2025
59d7c98
mistake input shape
jbuces Mar 11, 2025
267c42c
Compute all cherenkov pe per patch in ex id
jbuces Mar 12, 2025
cdae1fc
Comments and fixes
jbuces Mar 12, 2025
badcd83
input shape from patch size
jbuces Mar 12, 2025
a730330
Small corrections
jbuces Mar 12, 2025
1ea1abf
small bugs
jbuces Mar 12, 2025
2ca4301
define get_raw_ex in DataReader
jbuces Mar 13, 2025
854e77f
mapped waveform for hot pix not from sim
jbuces Mar 13, 2025
9be0604
Merge pull request #153 from cta-observatory/pre-rel-0.14.1
TjarkMiener Mar 13, 2025
4f85d85
remove hot pix from sim, now always from sim
jbuces Mar 14, 2025
849f728
add unmaped waveform output
jbuces Mar 14, 2025
cbff213
add neighbor dict calc
jbuces Mar 14, 2025
40bb22d
Merge tag 'v0.14.1' into Jorge_TriggerReader
jbuces Mar 14, 2025
904b278
unmaped wf
jbuces Mar 14, 2025
ae522b2
bug input shape
jbuces Mar 18, 2025
2175d42
add hexagonal patches and unmapped output
jbuces Mar 19, 2025
e760b96
test changes indexed
jbuces Mar 20, 2025
93fc762
tests for indexed convolution, reorganised patches
jbuces Apr 3, 2025
7a005ce
indexed reorganised output by patches
jbuces Apr 23, 2025
8e84810
Corrections for indexed
jbuces May 7, 2025
d6c148a
Untrack large nb
jbuces May 7, 2025
fea9474
Remove output options, left bal all wf, add HexagonalPatchMapper
jbuces Jun 4, 2025
e2c6cae
Combine ex_identifiers functions, add LST neighbor matrix
jbuces Jun 5, 2025
52599e2
small bugs and nb
jbuces Jun 6, 2025
7fed14d
add trigger patches file for sipm cam
jbuces Jun 6, 2025
e95c25b
double patches option and small bugs
jbuces Jul 14, 2025
1209939
l1 and tdscan trigger on patches and camera, divide get_raw_example i…
jbuces Jul 21, 2025
61049b2
restore gitignore for nb
jbuces Jul 21, 2025
34f51df
Merge remote-tracking branch 'origin/main' into Jorge_TriggerReader
jbuces Jul 21, 2025
6d67a2e
small bugs
jbuces Jul 21, 2025
283ac5e
enable r0 or r1 table reading depending on class
jbuces Jul 22, 2025
345205f
New camera geometry and changes in l1 triggernow output trigger per p…
jbuces Jul 30, 2025
96523eb
mapper bugs and append low trigger to batch
jbuces Aug 5, 2025
0fc243d
add option to read tdscan from external file
jbuces Sep 16, 2025
168e85a
Add sectors, improve l1, add option to load tdscan/l1 from h5
jbuces Oct 8, 2025
c9dbf42
small best practice issues.
jbuces Oct 8, 2025
af1882e
small bugs
jbuces Oct 8, 2025
21abc2d
remove old geometry files
jbuces Oct 8, 2025
135b18c
merge with main
jbuces Oct 8, 2025
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
94 changes: 93 additions & 1 deletion dl1_data_handler/image_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from scipy import spatial
from scipy.sparse import csr_matrix
from collections import Counter, namedtuple
import tables
from importlib.resources import files
import astropy.units as u

from ctapipe.instrument.camera import PixelShape
from ctapipe.core import TelescopeComponent
Expand All @@ -21,6 +24,7 @@
"RebinMapper",
"ShiftingMapper",
"SquareMapper",
"HexagonalPatchMapper",
]

class ImageMapper(TelescopeComponent):
Expand Down Expand Up @@ -56,6 +60,8 @@ class ImageMapper(TelescopeComponent):
Multiplication factor used for rebinning.
index_matrix : numpy.ndarray or None
Matrix used for indexing, initialized to None.
cam_neighbor_array : numpy.ndarray or None
Matrix used for indexing, initialized to None.

Methods
-------
Expand Down Expand Up @@ -91,6 +97,8 @@ def __init__(
self.camera_type = self.geometry.name
self.n_pixels = self.geometry.n_pixels
# Rotate the pixel positions by the pixel to align
if self.camera_type == "UNKNOWN-7987PX":
self.geometry.pix_rotation = 8.213 * u.deg
self.geometry.rotate(self.geometry.pix_rotation)

self.pix_x = np.around(
Expand All @@ -106,7 +114,7 @@ def __init__(
# Additional smooth the ticks for 'DigiCam', 'RealLSTCam' and 'CHEC' cameras
if self.camera_type in ["DigiCam", "RealLSTCam"]:
self.pix_y, self.y_ticks = self._smooth_ticks(self.pix_y, self.y_ticks)
if self.camera_type == "CHEC":
if self.camera_type in ["CHEC", "UNKNOWN-7987PX"]:
self.pix_x, self.x_ticks = self._smooth_ticks(self.pix_x, self.x_ticks)
self.pix_y, self.y_ticks = self._smooth_ticks(self.pix_y, self.y_ticks)

Expand All @@ -124,6 +132,7 @@ def __init__(

# Set the indexed matrix to None
self.index_matrix = None
self.cam_neighbor_array = None

def map_image(self, raw_vector: np.array) -> np.array:
"""
Expand Down Expand Up @@ -648,6 +657,89 @@ def _get_grids(
return input_grid, output_grid


class HexagonalPatchMapper(ImageMapper):
"""
HexagonalPatchMapper retrieves the necessary information to perform indexed
convolutions, also allows croping the images following the "sipm_patches.h5"
patches geometry and reorders the pixels.

This class extends the functionality of ImageMapper by implementing
methods to look up at the configuration file and perform the image cropping.
It is particularly useful for applications where we are working with waveforms
with high time dimension.
"""

def __init__(
self,
geometry,
config=None,
parent=None,
**kwargs,
):
super().__init__(
geometry=geometry,
config=config,
parent=parent,
**kwargs,
)

if geometry.pix_type != PixelShape.HEXAGON:
raise ValueError(
f"HexagonalPatchMapper is only available for hexagonal pixel cameras. Pixel type of the selected camera is '{geometry.pix_type}'."
)

path = files("dl1_data_handler.ressources").joinpath("newcam_sipm_patches.h5")

if geometry.name == "UNKNOWN-7987PX":
with tables.open_file(path, mode="r") as f:
self.trigger_patches = f.root.patches.masks[:]
self.index_map = f.root.mappings.index_map[:]
self.neighbor_array = f.root.neighbors.patch0_neighbors[:]
self.cam_neighbor_array = f.root.neighbors.camera_neighbors[:]
self.fl_neighbor_array_tdscan = f.root.neighbors.flower_neighbors_tdscan[:]
self.fl_neighbor_array_l1 = f.root.neighbors.flower_neighbors_l1[:]
self.supfl_neighbor_array_l1 = f.root.neighbors.superflower_neighbors_l1[:]
self.sectors_bool = f.root.sectors.mask[:]
self.sectors_indices = f.root.sectors.sectors_indices[:]
self.sect0_neighbors = f.root.sectors.sect0_neighbors[:]
self.sector_mappings = f.root.sectors.mapping[:]
# Remove -1 padding from each row
self.neighbor_tdscan_eps1_list = [row[row != -1].tolist() for row in self.fl_neighbor_array_tdscan]
self.fl_neighbor_l1_list = [row[row != -1].tolist() for row in self.fl_neighbor_array_l1]
self.supfl_neighbor_l1_list = [row[row != -1].tolist() for row in self.supfl_neighbor_array_l1]


self.num_patches = len(self.trigger_patches)
self.patch_size = self.neighbor_array.shape[0]
self.sector_size = self.sect0_neighbors.shape[0]

self.supfl_neighbor_l1_mask = self.supfl_neighbor_array_l1 >= 0
# Retrieve the camera neighbor array to perform convolutions with cameras different from AdvSiPMCam.
else:
neighbor_matrix = geometry.neighbor_matrix
num_pixels = neighbor_matrix.shape[0]
neighbor_lists = []
for i in range(num_pixels):
# Find indices where the row is True
neighbors = np.where(neighbor_matrix[i])[0]
neighbor_lists.append([i] + neighbors.tolist())

self.cam_neighbor_array = np.full((num_pixels, 7), -1, dtype=int)
for i, neighbors in enumerate(neighbor_lists):
self.cam_neighbor_array[i, :len(neighbors)] = neighbors
print("Computed neighbor array for: ", geometry.name)

def get_reordered_patch(self, raw_vector, patch_index, out_size):
# Retrieve the patch needed remapped to a standarized patch order.
if out_size == "patch":
mapper = self.index_map
else: #sector
mapper = self.sector_mappings
mapper = mapper[patch_index]
unmapped_waveform=raw_vector[mapper]
return unmapped_waveform


class ShiftingMapper(ImageMapper):
"""
ShiftingMapper applies a shifting transformation to map images
Expand Down
Loading