14#include <pybind11/numpy.h>
16namespace py = pybind11;
47 py::array_t<uint8_t> channels(channels_per_daphne * nframes);
48 auto ptr =
static_cast<uint8_t*
>(channels.request().ptr);
50 for (
size_t i = 0; i < (size_t)nframes; ++i) {
55 ptr[i * channels_per_daphne + 1] = fr->get_channel1();
56 ptr[i * channels_per_daphne + 2] = fr->get_channel2();
57 ptr[i * channels_per_daphne + 3] = fr->get_channel3();
59 channels.resize({ nframes, channels_per_daphne });
72 py::array_t<uint8_t> channels(nframes);
73 auto ptr =
static_cast<uint8_t*
>(channels.request().ptr);
75 for (
size_t i = 0; i < (size_t)nframes; ++i) {
116 py::array_t<uint16_t> ret(nframes * adcs_per_channel);
117 auto ptr =
static_cast<uint16_t*
>(ret.request().ptr);
118 for (
size_t i = 0; i < (size_t)nframes; ++i) {
121 for (
size_t j = 0; j < adcs_per_channel; ++j) {
122 ptr[i * adcs_per_channel + j] = fr->get_adc(j);
126 ret.resize({ nframes, adcs_per_channel });
143 py::array_t<uint16_t> ret(channels_per_daphne * nframes * adcs_per_channel);
144 auto ptr =
static_cast<uint16_t*
>(ret.request().ptr);
145 for (
size_t i = 0; i < (size_t)nframes; ++i) {
148 for (
size_t j = 0; j < adcs_per_channel; ++j)
149 for (
size_t k = 0; k < channels_per_daphne; ++k)
150 ptr[channels_per_daphne * (adcs_per_channel * i + j) + k] = fr->
get_adc(j, k);
152 ret.resize({ nframes * adcs_per_channel, channels_per_daphne });
167 py::array_t<uint64_t> ret(nframes);
168 auto ptr =
static_cast<uint64_t*
>(ret.request().ptr);
169 for (
size_t i = 0; i < (size_t)nframes; ++i) {
188 const size_t ticks_per_adc = 1;
190 py::array_t<uint64_t> ret(nframes * adcs_per_channel);
192 auto ptr =
static_cast<uint64_t*
>(ret.request().ptr);
193 for (
size_t i = 0; i < (size_t)nframes; ++i) {
196 for (
size_t j = 0; j < adcs_per_channel; ++j)
197 ptr[i * adcs_per_channel + j] = fr->
get_timestamp() + j * ticks_per_adc;
py::array_t< uint16_t > np_array_adc_stream(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of DAPHNEFrames in a fragment.
py::array_t< uint64_t > np_array_timestamp(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number o...
py::array_t< uint8_t > np_array_channels_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEFrames into a numpy array with dimensions (nframes).
py::array_t< uint8_t > np_array_channels(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEFrames into a numpy array with dimensions.
uint32_t get_n_frames_stream(daqdataformats::Fragment const &frag)
Gets number of DAPHNEStreamFrames in a fragment.
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the timestamps with dimension (number of...
py::array_t< uint16_t > np_array_adc_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< uint8_t > np_array_channels_stream(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEStreamFrames into a numpy array with dimensi...
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of ...
py::array_t< uint16_t > np_array_adc(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< uint8_t > np_array_channels_stream_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEEthStreamFrames into a numpy array with dimensions (nframes,...
py::array_t< uint64_t > np_array_timestamp_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (num...
py::array_t< uint64_t > np_array_timestamp_stream(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing DAPHNEStreamFrames into a numpy array with dimension ...