lib_acc_comp module¶
Functions for accumulation period management: computations of identifiers based on timestamps, etc.
-
lib_acc_comp.
adjust_seconds_fr
(samples_per_channel_in_frame, fs, seconds_fr, num_frame)[source]¶ Get the timestamp for the first sample in this frame.
- samples_per_channel_in_frame : int
- number of sample components per channel.
- fs : int or float
- sampling frequency.
- seconds_fr : int or float
- seconds for this frame (from frame header)
- num_frame : int
- frame number (from frame header).
- time_first_frame : float
- timestamp [s] corresponding to the first sample of this frame.
-
lib_acc_comp.
get_acc_block
(seconds_fr, seconds_ref, acc_time_str, tot_samples, num_channels, fs, frame_num, datatype='c')[source]¶ Get acc_block id for this frame.
- seconds_fr
- seconds in the header of the processed frame.
- seconds_ref : float
- seconds corresponding to the start of the current accumulation period.
- acc_time_str : str
- accumualation time. Expected format is a string from a float.
- tot_samples
- total number of sample components in the frame (for all the channels).
- num_channels
- number of channels in this frame.
- fs
- sampling frequency.
- frame_num
- frame number in the header of the processed frame.
- datatype: {‘r’ , ‘c’}
- ‘r’ for real, ‘c’ for complex.
datatype is required for computing the number of sample components per sample (2 for complex, 1 for real).acc_time str was initially devised to support fractions (e.g. “1/3”) before supporting float accumulation times (e.g. 0.32),but this feature (fractions) is no longer needed.
-
lib_acc_comp.
get_acc_block_for_time
(time_first_sample, list_acc_frontiers)[source]¶ Get accumulation block id.
- time_first_sample : float
- [s].
- list_acc_frontiers : list of floats
- generated with get_list_acc_frontiers().
- index_front
- accumulation block id.
- i
- list_acc_frontiers[index_front].
-
lib_acc_comp.
get_acc_float
(acc_time_str)[source]¶ Converts a fraction of integers into a float. Initially devised to support fractions in accumulation time, no longer needed.
- acc_time_str : str
- accumulation time as str of float (e.g. “0.25”) or fraction (e.g. “1/4”).
- acc_float : float
- accumulation time (e.g. 0.25).
TO DO:Consider removing along with get_num_den_accs(), initially devised to support fractions as integration times.To be replaced with simply float(acc_time_str).
-
lib_acc_comp.
get_frame_acc
(seconds_fr, num_frame, fs, samples_per_channel_in_frame, list_acc_frontiers, acc_time)[source]¶ Returns the index of the accumulation period corresponding to this frame, the relative number of the frame into the acc period, and the seconds corresponding to the first sample.
- seconds_fr
- seconds for this frame (from frame header)
- num_frame
- frame number (from frame header).
- fs
- sampling frequency.
- samples_per_channel_in_frame
- number of sample components per channel.
- list_acc_frontiers
- list generated with get_list_acc_frontiers().
- acc_time
- accumulation time.
- index_front
- index to the list of accumulation period frontiers.
- frame_rel_pos_time
- number of frame relative to the accumulation period.
- time_first_sample
- timestamp for the first sample of this frame.
- seconds_previous frame
- timestamp for the first sample of the previous frame.
- frames_per_acc
- number of frames per accumulation period.
TO DO:Merge with get_acc_block_for_time(), avoid repeated code.
-
lib_acc_comp.
get_list_acc_frontiers
(acc_time, signal_duration, seconds_ref)[source]¶ - Returns list of times of separators for accumulation periods, i.e. start times of the accumulation periods,
- plus another float with the end time of the last accumulation period.
- acc_time : float
- accumulation period duration [s].
- signal_duration : float
- duration of the experiment [s].
- seconds_ref : float
- number of seconds corresponding to the start of the experiment [s].
- out : list of float
- timestamps [s] from 0 to signal_duration with separators for acc periods.
-
lib_acc_comp.
get_num_den_accs
(acc_time_str)[source]¶ Get num and den for accumulation period.
- acc_time_str : str
- accumulation time (e.g. “1/3”).
- num : int
- numerator of the fraction.
- den : int
- denominator of the fraction.
TO DO:Consider removing along with get_acc_float(), initially devised to support fractions as integration times.