47 auto filterProperty = std::make_unique<TimeSeriesProperty<bool>>(
"tmp");
50 auto filter2 = std::unique_ptr<TimeSeriesProperty<bool>>(
filter.
clone());
52 TimeInterval time1 = filter1->nthInterval(filter1->size() - 1);
53 TimeInterval time2 = filter2->nthInterval(filter2->size() - 1);
55 if (time1.begin() < time2.
begin()) {
56 filter1->addValue(time2.
begin(),
59 }
else if (time2.
begin() < time1.begin()) {
60 filter2->addValue(time1.begin(),
true);
66 time1 = filter1->nthInterval(i);
67 time2 = filter2->nthInterval(j);
74 if (time1.begin() > time2.
begin()) {
75 filter1->addValue(time2.
begin(), !filter1->nthValue(i));
76 time1 = filter1->nthInterval(i);
77 }
else if (time2.
begin() > time1.begin()) {
78 filter2->addValue(time1.begin(), !filter2->nthValue(j));
79 time2 = filter2->nthInterval(j);
86 filterProperty->addValue(time3.
begin(), (filter1->nthValue(i) && filter2->nthValue(j)));
89 if (time1.end() < time2.
end()) {
91 }
else if (time2.
end() < time1.end()) {
98 if (i == filter1->size() || j == filter2->size())
100 time1 = filter1->nthInterval(i);
101 time2 = filter2->nthInterval(j);
103 filterProperty->clearFilter();
104 m_filter = std::move(filterProperty);
124template <
typename SrcType>
struct ConvertToTimeSeriesDouble {
130 auto pmap = srcTypeSeries->valueAsMap();
131 for (
auto it =
pmap.begin(); it !=
pmap.end(); ++it) {
132 converted->addValue(it->first,
double(it->second));
139template <>
struct ConvertToTimeSeriesDouble<double> {
140 static TimeSeriesProperty<double> *apply(
const Property *prop) {
141 auto doubleSeries =
dynamic_cast<const TimeSeriesProperty<double> *
>(prop);
144 return doubleSeries->clone();
157 if (
auto doubleSeries = ConvertToTimeSeriesDouble<double>::apply(prop)) {
159 }
else if (
auto doubleSeries = ConvertToTimeSeriesDouble<int>::apply(prop)) {
161 }
else if (
auto doubleSeries = ConvertToTimeSeriesDouble<bool>::apply(prop)) {
164 throw std::invalid_argument(
"LogFilter::convertToTimeSeriesOfDouble - Cannot convert property, \"" + prop->
name() +
165 "\", to double series.");
void clear()
Clears filters.
const TimeSeriesProperty< bool > * filter() const
Returns a reference to the filter.
TimeSeriesProperty< double > * convertToTimeSeriesOfDouble(const Property *prop)
Converts the given property to a TimeSeriesProperty<double>, throws if invalid.
void addFilter(const TimeSeriesProperty< bool > &filter)
Adds a filter using boolean AND.
std::unique_ptr< TimeSeriesProperty< double > > m_prop
Owned pointer to the filtered property.
std::unique_ptr< TimeSeriesProperty< bool > > m_filter
Owned pointer to the filter mask.
LogFilter()=delete
Disable default constructor.
Base class for properties.
const std::string & name() const
Get the property's name.
Represents a time interval.
Types::Core::DateAndTime begin() const
Beginning of the interval.
bool isValid() const
True if the interval is not empty.
Types::Core::DateAndTime end() const
End of the interval.
TimeInterval intersection(const TimeInterval &ti) const
Returns an intersection of two intervals.
A specialised Property class for holding a series of time-value pairs.
TimeSeriesProperty< TYPE > * clone() const override
"Virtual" copy constructor
int size() const override
Returns the number of values at UNIQUE time intervals in the time series.
Generate a tableworkspace to store the calibration results.