radiocore.tools package¶
Submodules¶
radiocore.tools.buffer module¶
Defines a Buffer module.
- class radiocore.tools.buffer.Buffer(size: Union[int, float], dtype: str = 'complex64', lock: bool = False, cuda: bool = False)¶
Bases:
radiocore._internal.injector.InjectorThe Buffer class manage a CPU or GPU array.
The CUDA (GPU) array is allocated by cuSignal. The memory is managed. Therefore, it’s DMA’ed to the CPU automatically.
- sizeint, float
size of the array
- dtypestr, optional
element type of the array (default is complex64)
- lockbool, optional
lock array when using it (default if False)
- cudabool, optional
allocate memory on the GPU (default is False)
- consume()¶
Return a handle of the original array memory.
When lock is enabled, it will also restrict the access to this resource until the original caller is done.
- property data¶
Return the pointer of the inner buffer.
- property dtype¶
Return the dtype of the array.
- property is_cuda: bool¶
Return if the array is allocated in the GPU memory.
- property is_locked: bool¶
Return if the array is currently in use.
- property size: int¶
Return the size of the array.
radiocore.tools.carrousel module¶
Defines a Carrousel module.
- class radiocore.tools.carrousel.Carrousel(items: List, print_overflow: bool = True)¶
Bases:
objectThe Carrousel class provides a ring buffer of elements.
The operation of this class is similar to the collections.Queue. But unlike it, this class doesn’t discard the element after its poped. This is more efficient, specially if using GPU memory.
This class doesn’t support multiple producers.
- itemsarr
array of items to be cycled through
- print_overflowbool, optional
print ‘overflow’ in stdout whenever some happens (default is True)
- property capacity: int¶
Return the total amount of items this instance can hold.
- dequeue()¶
Return the reference of an item to be read.
- enqueue()¶
Return the reference of an item to be written into.
- property is_empty: int¶
Return if there is any items in use.
- property is_full: int¶
Return if all the items are the use.
- property is_healthy: bool¶
Return if it’s secure to read any item. Used to ensure buffer health.
It’s considered healthy if there is two or more items in use.
- property occupancy: int¶
Return the amount of items currently in use.
- property overflow: int¶
Return the number of overflows since the instantiation.
- reset()¶
Reset class to the initial state.
radiocore.tools.chopper module¶
Defines a Chopper module.
- class radiocore.tools.chopper.Chopper(size: Union[int, float], chunk_size: Union[int, float])¶
Bases:
objectThe Copper class is a helper to divide a big array into smaller chunks.
It’s usefull when you need to populate an array used for processing with smaller arrays.
- sizeint, float
total size of the original array
- chunk_sizeint, float
desired chunk size
- chop(input_arr)¶
Return a reference to the bigger array’s original memory.
- input_arrarr
original array
- property chunk_size¶
Return the chunk size.
- static get_to_da_choppa()¶
Return where is the choppa.
- property size¶
Return the size of the entire buffer.
radiocore.tools.tuner module¶
Defines a Tuner module.
- class radiocore.tools.tuner.Channel(index: int, bandwidth: float, demodulator: None, lower_frequency: float, center_frequency: float, higher_frequency: float)¶
Bases:
objectThe Channel class holds frequency boundaries and other related data.
- lower_frequencyfloat
lower frequency boundary of the channel
- center_frequencyfloat
center frequency of the channel
- higher_frequencyfloat
higher frequency boundary of the channel
- bandwidthfloat
bandwidth of the channel
- property address_bytes: bytes¶
- bandwidth: float¶
- center_frequency: float¶
- demodulator: None¶
- higher_frequency: float¶
- index: int¶
- lower_frequency: float¶
- class radiocore.tools.tuner.Tuner(cuda: bool = False)¶
Bases:
radiocore._internal.injector.InjectorThe Tuner class channelizes the input data into channels.
The operation of this class assumes that the input signal is arranged in one second chunks. This class is based on a FFT, a resampler, and a IFFT. It’s quite fast in the GPU.
- cudabool
use the GPU for processing (default is False)
- add_channel(frequency: float, bandwidth: float, demodulator)¶
Register a new channel to be processed.
This call recalculates all parameters.
- frequencyfloat
output channel center frequency
- bandwidthfloat
output channel bandwidth
- demodulatorFM, MFM, or WBFM
demodulator instance
- channels() List[radiocore.tools.tuner.Channel]¶
Return list of registered channels.
- property input_bandwidth: float¶
Return the bandwidth of the input data.
- property input_frequency: float¶
Return the center frequency of the input data.
- load(input_signal)¶
Pre-process the input data.
This method should be called in advance of run().
- input_signalarr
input signal buffer with one second worth of samples
- request_bandwidth(bandwidth: float)¶
Override the calculated bandwidth.
The desired bandwidth should be greater than the original. The value set by this method will be overridden if add_channel is called afterward.
- bandwidthfloat
desired bandwidth
- reset()¶
Reset the state of the Tuner.
- run(channel_index: int)¶
Return the channelized signal.
This method should be called after load().
- channel_indexint
index of the channel