14#include <pybind11/numpy.h>
16namespace py = pybind11;
42 py::array_t<uint8_t> channels(channels_per_daphne * nframes);
43 auto ptr =
static_cast<uint8_t*
>(channels.request().ptr);
45 for (
size_t i=0; i<(size_t)nframes; ++i) {
49 ptr[i*channels_per_daphne + 1] = fr->get_channel1();
50 ptr[i*channels_per_daphne + 2] = fr->get_channel2();
51 ptr[i*channels_per_daphne + 3] = fr->get_channel3();
54 channels.resize({nframes, channels_per_daphne});
65 py::array_t<uint8_t> channels(nframes);
66 auto ptr =
static_cast<uint8_t*
>(channels.request().ptr);
68 for (
size_t i=0; i<(size_t)nframes; ++i) {
99 py::array_t<uint16_t> ret(nframes * adcs_per_channel);
100 auto ptr =
static_cast<uint16_t*
>(ret.request().ptr);
101 for (
size_t i=0; i<(size_t)nframes; ++i) {
104 for (
size_t j=0; j<adcs_per_channel; ++j) {
105 ptr[i*adcs_per_channel + j] = fr->get_adc(j);
110 ret.resize({nframes, adcs_per_channel});
126 py::array_t<uint16_t> ret(channels_per_daphne * nframes * adcs_per_channel);
127 auto ptr =
static_cast<uint16_t*
>(ret.request().ptr);
128 for (
size_t i=0; i<(size_t)nframes; ++i) {
130 for (
size_t j=0; j<adcs_per_channel; ++j)
131 for (
size_t k=0; k<channels_per_daphne; ++k)
132 ptr[channels_per_daphne * (adcs_per_channel * i + j) + k] = fr->
get_adc(j,k);
134 ret.resize({nframes*adcs_per_channel, channels_per_daphne});
147 py::array_t<uint64_t> ret(nframes);
148 auto ptr =
static_cast<uint64_t*
>(ret.request().ptr);
149 for (
size_t i=0; i<(size_t)nframes; ++i) {
165 const size_t ticks_per_adc = 1;
167 py::array_t<uint64_t> ret(nframes*adcs_per_channel);
169 auto ptr =
static_cast<uint64_t*
>(ret.request().ptr);
170 for (
size_t i=0; i<(size_t)nframes; ++i) {
172 for (
size_t j=0; j<adcs_per_channel; ++j)
173 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 dimensi...
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< uint64_t > np_array_timestamp_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (n...
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 (nu...
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 dimensio...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of DAPHNEFrames in a fragment
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)
uint32_t get_n_frames_stream(daqdataformats::Fragment const &frag)
Gets number of DAPHNEStreamFrames in a fragment
py::array_t< uint8_t > np_array_channels_stream_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEStreamFrames 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
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< 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< 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< 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 ...