2026-03-12 20:34:54 +01:00
|
|
|
//
|
|
|
|
|
// Created by david on 11.03.2026.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "test_helpers.h"
|
|
|
|
|
|
|
|
|
|
void npy_save(std::string path, std::vector<double>& x) {
|
|
|
|
|
npy::npy_data_ptr<double> d;
|
|
|
|
|
d.data_ptr = x.data();
|
|
|
|
|
d.shape = {(unsigned long) x.size()};
|
|
|
|
|
npy::write_npy(path, d);
|
|
|
|
|
}
|
2026-03-12 21:28:50 +01:00
|
|
|
void npy_save(std::string path, std::vector<bool>& x) {
|
|
|
|
|
npy::npy_data_ptr<int> d;
|
|
|
|
|
std::vector<int> xx(x.begin(), x.end());
|
|
|
|
|
d.data_ptr = xx.data();
|
|
|
|
|
d.shape = {(unsigned long) x.size()};
|
|
|
|
|
npy::write_npy(path, d);
|
|
|
|
|
}
|
2026-03-12 20:34:54 +01:00
|
|
|
|
|
|
|
|
std::vector<double> fetch_y_axis(npy::npy_data<double>& acc) {
|
|
|
|
|
// TODO: later on, we should use a vector projection towards gravity
|
|
|
|
|
std::vector<double> signal;
|
|
|
|
|
const size_t rows_real = acc.shape[0];
|
|
|
|
|
#if DEBUG_IIR == 1
|
|
|
|
|
const size_t rows = 5;
|
|
|
|
|
#else
|
|
|
|
|
const size_t rows = acc.shape[0];
|
|
|
|
|
#endif
|
|
|
|
|
int stride = 3;
|
|
|
|
|
int offset = 1; // [x,y,z] per row - fetch y
|
|
|
|
|
signal.resize(rows);
|
|
|
|
|
if (acc.fortran_order) {
|
|
|
|
|
stride = 1;
|
|
|
|
|
offset = (int) rows_real;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
std::cout << "is_fortran=" << acc.fortran_order << std::endl;
|
|
|
|
|
for (size_t i = 0; i < 10; i++) {
|
|
|
|
|
std::cout << "acc.data[" << i << "]=" << acc.data[i] << std::endl;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
for (int i = 0; i < rows; i++) {
|
|
|
|
|
signal[i] = acc.data[i * stride + offset];
|
|
|
|
|
}
|
|
|
|
|
return signal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebugSsfStepDetectorThreshold::DebugSsfStepDetectorThreshold(size_t len_refr) : SsfStepDetector(len_refr) {}
|
|
|
|
|
double DebugSsfStepDetectorThreshold::filter(double val) {
|
|
|
|
|
this->SsfStepDetector::filter(val);
|
|
|
|
|
return peek_threshold();
|
|
|
|
|
}
|