legend-exp / LegendDataManagement.jl

LegendMetadata access in Julia
Other
4 stars 5 forks source link

Simplified data loader #59

Open theHenks opened 1 month ago

theHenks commented 1 month ago

Included read_ldata function to simplify data loading for a single DataTier and ChannelId including fast flattening and concatenation of tables and arrays. The following functionality is implemented: Example (requires a $LEGEND_DATA_CONFIG environment variable pointing to a legend data-config file):

using LegendDataManagement, LegendHDF5IO
l200 = LegendData(:l200)
filekeys = search_dsik(FileKey, l200.tier[:jldsp, :cal, :p03, :r000])

chinfo = channelinfo(l200, (:p03, :r000, :cal); system=:geds, only_processable=true)

ch = chinfo[1].channel

dsp = read_ldata(l200, :jldsp, first(filekeys), ch)
dsp = read_ldata(l200, :jldsp, :cal, :p03, :r000, ch)
dsp = read_ldata((:e_cusp, :e_trap, :blmean, :blslope), l200, :jldsp, :cal, :p03, :r000, ch)

read_ldata automitcally loads LEGEND data for a specific DataTier and data selection like e.g. a FileKey or a run-selection based for a given ChannelId. The search_disk function allows the user to search for available DataTier and FileKey on disk. The first argument can be either a selection of keys in form of a NTuple of Symbol or a PropertyFunction which will be applied during loading. It is also possible to load whole a DataPartition or DataPeriod for a given ChannelId ch:

dsp = read_ldata(l200, :jldsp, :cal, DataPartition(1), ch)
dsp = read_ldata(l200, :jldsp, :cal, DataPeriod(3), ch)

In additon, it is possible to load a random selection of n_evts events randomly selected from each loaded file:

dsp = read_ldata(l200, :jldsp, :cal, :p03, :r000, ch; n_evts=1000)

For simplicity, the ch can also be given as a DetectorID which will be converted internally to a ChannelId:

det = chinfo[1].detector
dsp = read_ldata(l200, :jldsp, :cal, :p03, :r000, det)
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 34.07821% with 236 lines in your changes missing coverage. Please review.

Project coverage is 34.25%. Comparing base (413c7df) to head (f631749). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
ext/LegendDataManagementLegendHDF5IOExt.jl 0.00% 99 Missing :warning:
src/calibration_functions.jl 0.00% 31 Missing :warning:
src/evt_functions.jl 0.00% 24 Missing :warning:
src/dataprod_config.jl 0.00% 23 Missing :warning:
src/utils/pars_utils.jl 0.00% 16 Missing :warning:
src/active_volume.jl 83.72% 14 Missing :warning:
src/legend_data.jl 79.66% 12 Missing :warning:
src/data_io.jl 0.00% 10 Missing :warning:
src/utils/data_utils.jl 0.00% 4 Missing :warning:
src/filekey.jl 0.00% 2 Missing :warning:
... and 1 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #59 +/- ## ========================================== + Coverage 33.02% 34.25% +1.22% ========================================== Files 27 28 +1 Lines 1620 1854 +234 ========================================== + Hits 535 635 +100 - Misses 1085 1219 +134 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

oschulz commented 1 month ago

This is still in progress, right?

theHenks commented 1 month ago

I need some final checks, than it is ready. But the core is in principle ready to be merged.