16const DateAndTime UNSET_TIME(DateAndTime::GPS_EPOCH);
18const DateAndTime OPEN_END_TIME(
"2100-Jan-01 00:00:01");
21TimeROI toTimeROI(
const TimeSeriesProperty<bool> &filter) {
22 if (filter.lastValue() && filter.firstTime() == filter.lastTime())
23 return TimeROI(filter.lastTime(), OPEN_END_TIME);
24 return TimeROI(&filter);
83 if (std::find(values.cbegin(), values.cend(),
true) == values.cend()) {
87 filterOpenEnded =
false;
104 auto filter2 = std::unique_ptr<TimeSeriesProperty<bool>>(
filter.
clone());
106 const DateAndTime time1 = filter1->lastTime();
107 const DateAndTime time2 = filter2->lastTime();
110 filter1->addValue(time2,
113 }
else if (time2 < time1) {
114 filter2->addValue(time1,
true);
118 TimeROI mine = toTimeROI(*filter1);
119 TimeROI theirs = toTimeROI(*filter2);
132 if (filterOpenEnded) {
142 m_prop->filterWith(timeroi);
144 const auto mysize =
m_prop->size();
145 const auto penultimate_interval =
m_prop->nthInterval(mysize - 2);
146 const auto ultimate_interval =
m_prop->nthInterval(mysize - 1);
147 const auto oldEnd = ultimate_interval.stop();
148 const auto newEnd = ultimate_interval.start() + penultimate_interval.length();
151 timeroi.
addMask(newEnd, ultimate_interval.stop());
152 else if (newEnd > oldEnd)
153 timeroi.
addROI(oldEnd, newEnd);
160 m_prop->filterWith(timeroi);
176template <
typename SrcType>
struct ConvertToTimeSeriesDouble {
182 auto pmap = srcTypeSeries->valueAsMap();
183 for (
auto it =
pmap.begin(); it !=
pmap.end(); ++it) {
184 converted->addValue(it->first,
double(it->second));
199 if (
auto doubleSeries = ConvertToTimeSeriesDouble<double>::apply(prop)) {
201 }
else if (
auto doubleSeries = ConvertToTimeSeriesDouble<int>::apply(prop)) {
203 }
else if (
auto doubleSeries = ConvertToTimeSeriesDouble<bool>::apply(prop)) {
206 throw std::invalid_argument(
"LogFilter::convertToTimeSeriesOfDouble - Cannot convert property, \"" + prop->
name() +
207 "\", to double series.");
213 std::vector<bool> values;
214 std::vector<DateAndTime> times;
216 values.emplace_back(
true);
217 values.emplace_back(
false);
218 times.emplace_back(splitter.start());
219 times.emplace_back(splitter.stop());
222 if (filterOpenEnded) {
229 m_filter = std::make_unique<TimeSeriesProperty<bool>>(
"filter");
231 m_filter->replaceValues(times, values);
Templated class that defines a filtered time series but still gives access to the original data.
std::unique_ptr< FilteredTimeSeriesProperty< double > > m_prop
Owned pointer to the filtered property.
void clear()
Clears filters.
const TimeSeriesProperty< bool > * filter() const
Returns a reference to the filter.
void addFilter(const TimeSeriesProperty< bool > &filter)
Adds a filter using boolean AND.
FilteredTimeSeriesProperty< double > * convertToTimeSeriesOfDouble(const Property *prop)
Converts the given property to a TimeSeriesProperty<double>, throws if invalid.
std::unique_ptr< TimeSeriesProperty< bool > > m_filter
Owned pointer to the filter mask.
LogFilter()=delete
Disable default constructor.
void setFilter(const TimeROI &roi, const bool filterOpenEnded)
Base class for properties.
const std::string & name() const
Get the property's name.
TimeROI : Object that holds information about when the time measurement was active.
void addMask(const std::string &startTime, const std::string &stopTime)
const std::vector< Kernel::TimeInterval > toTimeIntervals() const
This method is to lend itself to helping with transition.
void addROI(const std::string &startTime, const std::string &stopTime)
void update_intersection(const TimeROI &other)
Updates the TimeROI values with the intersection with another TimeROI.
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.
std::vector< TYPE > valuesAsVector() const
Return the time series's values (unfiltered) as a vector<TYPE>
Types::Core::DateAndTime firstTime() const
Returns the first time regardless of filter.
TYPE lastValue() const
Returns the last value.
Generate a tableworkspace to store the calibration results.