DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
rawdatautils.unpack.dataclasses Namespace Reference

Classes

class  DAPHNEAnalysisData
 
class  DAPHNEChannelDataBase
 
class  DAPHNEStreamAnalysisData
 
class  DAPHNEStreamHeaderData
 
class  DAPHNEStreamWaveformData
 
class  DAPHNEWaveformData
 
class  DAQHeaderData
 
class  FragmentDataBase
 
class  FragmentHeaderData
 
class  RecordDataBase
 
class  SourceIDData
 
class  TDEEthAnalysisData
 
class  TDEEthChannelDataBase
 
class  TDEEthHeaderData
 
class  TDEEthWaveformData
 
class  TriggerActivityData
 
class  TriggerCandidateData
 
class  TriggerHeaderData
 
class  TriggerPrimitiveData
 
class  TriggerRecordData
 
class  WIBEthAnalysisData
 
class  WIBEthChannelDataBase
 
class  WIBEthHeaderData
 
class  WIBEthWaveformData
 

Functions

 dts_to_seconds (dts)
 
 dts_to_datetime (dts_timestamp)
 
 sparsify_array_diff_locs_and_vals (arr)
 Sparsification and desparsifications for arrays.
 
 desparsify_array_diff_locs_and_vals (change_locations, change_values, arr_size)
 
 sparsify_array_diff_of_diff_locs_and_vals (arr)
 
 desparsify_array_diff_of_diff_locs_and_vals (arr_first, change_locations, change_values, arr_size)
 

Function Documentation

◆ desparsify_array_diff_locs_and_vals()

rawdatautils.unpack.dataclasses.desparsify_array_diff_locs_and_vals ( change_locations,
change_values,
arr_size )

Definition at line 32 of file dataclasses.py.

32def desparsify_array_diff_locs_and_vals(change_locations, change_values, arr_size):
33 # Create an empty array of the original size
34 reconstructed_arr = np.empty(arr_size, dtype=np.uint)
35 # Loop through each change location
36 for i in range(len(change_locations)):
37 # Apply the change value from the current change location to the end or next change location
38 if (i + 1) == len(change_locations):
39 reconstructed_arr[change_locations[i]:] = change_values[i]
40 else:
41 reconstructed_arr[change_locations[i]:change_locations[i + 1]] = change_values[i]
42 return reconstructed_arr
43

◆ desparsify_array_diff_of_diff_locs_and_vals()

rawdatautils.unpack.dataclasses.desparsify_array_diff_of_diff_locs_and_vals ( arr_first,
change_locations,
change_values,
arr_size )

Definition at line 54 of file dataclasses.py.

54def desparsify_array_diff_of_diff_locs_and_vals(arr_first, change_locations, change_values, arr_size):
55 # Reconstruct the differential array from sparse representation
56 arr_diff = desparsify_array_diff_locs_and_vals(change_locations, change_values, arr_size - 1)
57 # Reconstruct the original array by cumulatively summing the differences and adding the first value
58 arr = np.concatenate((np.array([0], dtype=np.uint), arr_diff)).cumsum() + arr_first
59 return arr
60
61@dataclass(order=True)

◆ dts_to_datetime()

rawdatautils.unpack.dataclasses.dts_to_datetime ( dts_timestamp)

Definition at line 16 of file dataclasses.py.

16def dts_to_datetime(dts_timestamp):
17 return datetime.fromtimestamp(dts_to_seconds(dts_timestamp), tz=pytz.timezone("UTC"))
18

◆ dts_to_seconds()

rawdatautils.unpack.dataclasses.dts_to_seconds ( dts)

Definition at line 13 of file dataclasses.py.

13def dts_to_seconds(dts):
14 return dts*16 //1e9
15

◆ sparsify_array_diff_locs_and_vals()

rawdatautils.unpack.dataclasses.sparsify_array_diff_locs_and_vals ( arr)

Sparsification and desparsifications for arrays.

Definition at line 21 of file dataclasses.py.

21def sparsify_array_diff_locs_and_vals(arr):
22 # Find indices where the value changes compared to the previous value, adjusting the first index to start from 0
23 change_locations = np.insert(np.where(arr[1:] != arr[:-1])[0], 0, -1) + 1
24 # Check if the array is not empty
25 if len(arr) > 0:
26 # Return locations of changes, values at these locations, and the length of the array
27 return change_locations, arr[change_locations], len(arr)
28 else:
29 # Return empty results for an empty array
30 return [], [], 0
31

◆ sparsify_array_diff_of_diff_locs_and_vals()

rawdatautils.unpack.dataclasses.sparsify_array_diff_of_diff_locs_and_vals ( arr)

Definition at line 44 of file dataclasses.py.

44def sparsify_array_diff_of_diff_locs_and_vals(arr):
45 # Store the first value of the array for later reconstruction
46 arr_first = arr[0]
47 # Compute the difference of consecutive elements
48 arr_diff = np.diff(arr)
49 # Use sparsify function to find locations and values of changes in the diff array
50 arr_diff_locs, arr_diff_vals, _ = sparsify_array_diff_locs_and_vals(arr_diff)
51 # Return the first value, change locations, change values, and array size for reconstruction
52 return arr_first, arr_diff_locs, arr_diff_vals, len(arr)
53