##// END OF EJS Templates
Some refac for new PySide2 bindings...
Some refac for new PySide2 bindings - made DataSourceItem iterable - added some tree print function for debug - fixed minor bug on DataSourceContorller which prevented from adding products in more than one call per provider - improved IDataProvider for future refac Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r85:1e3f92d40b0e
r92:9ff5f48e3d71
Show More
TimeSeriesUtils.h
93 lines | 3.0 KiB | text/x-c | CLexer
Added TS utils module...
r74 #ifndef TIMESERIESUTILS_H
#define TIMESERIESUTILS_H
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 #include "MultiComponentTimeSerie.h"
Added TS utils module...
r74 #include "ScalarTimeSerie.h"
#include "SpectrogramTimeSerie.h"
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 #include "VectorTimeSerie.h"
Added TS utils module...
r74
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 #include <TimeSeries.h>
Mostly working Spectrograms...
r84 #include <cmath>
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 #include <memory>
Added TS utils module...
r74
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 namespace TimeSeriesUtils
Added TS utils module...
r74 {
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 template<typename T> TimeSeries::ITimeSerie* copy(T input_ts)
{
if constexpr(std::is_base_of_v<TimeSeries::ITimeSerie, T>)
Added TS utils module...
r74 {
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 if(auto ts = dynamic_cast<VectorTimeSerie*>(input_ts))
{ return new VectorTimeSerie(*ts); }
if(auto ts = dynamic_cast<ScalarTimeSerie*>(input_ts))
{ return new ScalarTimeSerie(*ts); }
if(auto ts = dynamic_cast<MultiComponentTimeSerie*>(input_ts))
{ return new MultiComponentTimeSerie(*ts); }
if(auto ts = dynamic_cast<SpectrogramTimeSerie*>(input_ts))
{ return new SpectrogramTimeSerie(*ts); }
Added TS utils module...
r74 }
else
{
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 if(auto ts = std::dynamic_pointer_cast<VectorTimeSerie>(input_ts))
{ return new VectorTimeSerie(*ts); }
if(auto ts = std::dynamic_pointer_cast<ScalarTimeSerie>(input_ts))
{ return new ScalarTimeSerie(*ts); }
if(auto ts = std::dynamic_pointer_cast<SpectrogramTimeSerie>(input_ts))
{ return new SpectrogramTimeSerie(*ts); }
if(auto ts = std::dynamic_pointer_cast<MultiComponentTimeSerie>(input_ts))
{ return new MultiComponentTimeSerie(*ts); }
Added TS utils module...
r74 }
return nullptr;
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 }
Mostly working Spectrograms...
r84
struct axis_properties
{
double range;
double max_resolution;
bool is_log;
Updated to fixed TS lib, added spectrogram min/max sampling hints when available...
r85 double min;
double max;
Mostly working Spectrograms...
r84 };
constexpr auto IsLog = true;
constexpr auto IsLinear = false;
constexpr auto CheckMedian = true;
constexpr auto DontCheckMedian = false;
template<bool is_log, bool check_median>
axis_properties axis_analysis(
typename std::conditional<is_log, std::vector<double>&,
Updated to fixed TS lib, added spectrogram min/max sampling hints when available...
r85 const std::vector<double>&>::type axis,
double given_max_resolution = std::nan(""))
Mostly working Spectrograms...
r84 {
std::vector<double> axis_diff(axis.size());
if constexpr(is_log)
{
std::transform(std::cbegin(axis), std::cend(axis), std::begin(axis),
[](const auto v) { return std::log10(v); });
}
Updated to fixed TS lib, added spectrogram min/max sampling hints when available...
r85 auto min = *std::begin(axis);
auto max = *(std::cend(axis) - 1);
auto range = max - min;
auto min_diff = given_max_resolution;
if(std::isnan(min_diff))
Mostly working Spectrograms...
r84 {
Updated to fixed TS lib, added spectrogram min/max sampling hints when available...
r85 std::adjacent_difference(std::cbegin(axis), std::cend(axis),
std::begin(axis_diff));
min_diff =
(*std::min_element(std::cbegin(axis_diff) + 1, std::cend(axis_diff)));
if constexpr(check_median)
{
std::nth_element(std::begin(axis_diff) + 1,
std::begin(axis_diff) + axis_diff.size() / 2,
std::end(axis_diff));
auto median_diff = *(std::begin(axis_diff) + axis_diff.size() / 2);
if(median_diff > (4 * min_diff)) min_diff = median_diff;
}
Mostly working Spectrograms...
r84 }
Updated to fixed TS lib, added spectrogram min/max sampling hints when available...
r85
return {range, min_diff, is_log, min, max};
Mostly working Spectrograms...
r84 }
MultiComponent TS almost done, still blows up when built from python with empty data...
r76 } // namespace TimeSeriesUtils
Added TS utils module...
r74
#endif