You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: Misalignment in Time Series Data Due to Differing Trajectory Sizes with reactive scripts
Problem Description
Currently, PJ uses the nearest time index for data retrieval (TimeseriesRef::atTime(double t)), which can lead to inaccuracies when analyzing time series data of different sizes. This method may inadvertently use outdated data towards the end of a data set, affecting analysis reliability.
I have exposed the internal index through TimeseriesRef::getIndexAtTime(double t) to ensure that indices match when correlating data points across different series. This ensures that comparisons and analyses use data points from the same measurement intervals.
To address this issue more robustly, I propose enhancing the TimeseriesRef class to support both exact and nearest match strategies for time-based data retrieval:
enumclassMatchType {
Exact, // Returns an index only if the exact time is found
Nearest // Returns the nearest time index (current behavior)
};
std::optional<unsigned> getIndexAtTime(double t, MatchType match_type) const {
if (match_type == MatchType::Exact) {
auto it = std::find_if(_plot_data->begin(), _plot_data->end(),
[t](constauto& point) { return point.x == t; });
if (it != _plot_data->end()) {
returnstd::distance(_plot_data->begin(), it);
}
return std::nullopt; // Exact time not found
} else {
return _plot_data->getIndexFromX(t); // Nearest match
}
}
doubleatTime(double t, MatchType match_type) const {
autoindex = getIndexAtTime(t, match_type);
if (!index) {
throwstd::runtime_error("Time point not found for exact match requirement");
}
return _plot_data->at(*index).y;
}
However, I think that @facontidavide could have better ideas.
The text was updated successfully, but these errors were encountered:
Issue: Misalignment in Time Series Data Due to Differing Trajectory Sizes with reactive scripts
Problem Description
Currently, PJ uses the nearest time index for data retrieval (
TimeseriesRef::atTime(double t)
), which can lead to inaccuracies when analyzing time series data of different sizes. This method may inadvertently use outdated data towards the end of a data set, affecting analysis reliability.Example of the Problem
Please found some dummy data here: DummyData_2024-03-19.csv
Implemented Workaround
I have exposed the internal index through
TimeseriesRef::getIndexAtTime(double t)
to ensure that indices match when correlating data points across different series. This ensures that comparisons and analyses use data points from the same measurement intervals.Code Snippet Illustrating the Workaround
Proposed Solution
To address this issue more robustly, I propose enhancing the
TimeseriesRef
class to support both exact and nearest match strategies for time-based data retrieval:However, I think that @facontidavide could have better ideas.
The text was updated successfully, but these errors were encountered: