|
Mantid
|
TimeROI : Object that holds information about when the time measurement was active. More...
#include <TimeROI.h>
Public Member Functions | |
| void | addMask (const std::string &startTime, const std::string &stopTime) |
| void | addMask (const std::time_t &startTime, const std::time_t &stopTime) |
| void | addMask (const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) |
| Remove a region that is already in use. | |
| void | addROI (const std::string &startTime, const std::string &stopTime) |
| void | addROI (const std::time_t &startTime, const std::time_t &stopTime) |
| void | addROI (const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) |
| Add new region as a union. | |
| void | appendROIFast (const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) |
| Append a new region to TimeROI fast. | |
| std::vector< std::pair< size_t, size_t > > | calculate_indices (const std::vector< Types::Core::DateAndTime > ×) const |
| void | clear () |
| Removes all ROI's, leaving an empty object. | |
| std::string | debugStrPrint (const std::size_t type=0) const |
| print the ROI boundaries to a string | |
| double | durationInSeconds () const |
| Duration of the whole TimeROI. | |
| double | durationInSeconds (const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) const |
| Duration of the TimeROI between startTime and stopTime. | |
| Types::Core::DateAndTime | firstTime () const |
| const std::vector< Types::Core::DateAndTime > & | getAllTimes () const |
| Types::Core::DateAndTime | getEffectiveTime (const Types::Core::DateAndTime &time) const |
| Returns the time supplied if it is in a "use" region, or the minimum of the next higher use region. | |
| size_t | getMemorySize () const |
| Types::Core::DateAndTime | lastTime () const |
| std::size_t | numberOfRegions () const |
| std::size_t | numBoundaries () const |
| bool | operator!= (const TimeROI &other) const |
| bool | operator== (const TimeROI &other) const |
| void | replaceROI (const std::vector< Types::Core::DateAndTime > &roi) |
| This assumes that the supplied vector is sorted in increasing order of time. | |
| void | replaceROI (const TimeROI &other) |
| void | replaceROI (const TimeSeriesProperty< bool > *roi) |
| void | saveNexus (Nexus::File *file) const |
| Types::Core::DateAndTime | timeAtIndex (unsigned long index) const |
| TimeROI () | |
| TimeROI (const Kernel::TimeSeriesProperty< bool > *filter) | |
| TimeROI (const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) | |
| const std::vector< Kernel::TimeInterval > | toTimeIntervals () const |
| This method is to lend itself to helping with transition. | |
| const std::vector< Kernel::TimeInterval > | toTimeIntervals (const Types::Core::DateAndTime &after) const |
| Time intervals returned where no time is before after. | |
| void | update_intersection (const TimeROI &other) |
| Updates the TimeROI values with the intersection with another TimeROI. | |
| void | update_or_replace_intersection (const TimeROI &other) |
| If this is empty, replace it with the supplied TimeROI, otherwise calculate the intersection. | |
| void | update_union (const TimeROI &other) |
| Updates the TimeROI values with the union with another TimeROI. | |
| bool | useAll () const |
| TimeROI selects all time to be used. | |
| bool | useNone () const |
| TimeROI selects no time to be used as all is invalid. | |
| bool | valueAtTime (const Types::Core::DateAndTime &time) const |
| This returns whether the time should be "used" (rather than ignored). | |
Static Public Attributes | |
| static const std::string | NAME = "Kernel_TimeROI" |
| the underlying property needs a name | |
| static const TimeROI | USE_ALL {} |
| Constant for TimeROI where any time is used. | |
| static const TimeROI | USE_NONE {DateAndTime::GPS_EPOCH - DateAndTime::ONE_SECOND, DateAndTime::GPS_EPOCH} |
| Constant for TimeROI where no time is used. | |
Private Member Functions | |
| bool | empty () const |
| std::vector< Types::Core::DateAndTime > | getAllTimes (const TimeROI &other) |
| get a list of all unique times. order is not guaranteed | |
| bool | isCompletelyInMask (const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) const |
| This method returns true if the entire region between startTime and stopTime is inside an existing ignore interval. | |
| bool | isCompletelyInROI (const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) const |
| This method returns true if the entire region between startTime and stopTime is inside an existing use interval. | |
| void | validateValues (const std::string &label) |
Private Attributes | |
| std::vector< Types::Core::DateAndTime > | m_roi |
TimeROI : Object that holds information about when the time measurement was active.
| Mantid::Kernel::TimeROI::TimeROI | ( | ) |
Definition at line 68 of file TimeROI.cpp.
| Mantid::Kernel::TimeROI::TimeROI | ( | const Types::Core::DateAndTime & | startTime, |
| const Types::Core::DateAndTime & | stopTime | ||
| ) |
Definition at line 70 of file TimeROI.cpp.
References addROI().
| Mantid::Kernel::TimeROI::TimeROI | ( | const Kernel::TimeSeriesProperty< bool > * | filter | ) |
Definition at line 74 of file TimeROI.cpp.
References replaceROI().
| void Mantid::Kernel::TimeROI::addMask | ( | const std::string & | startTime, |
| const std::string & | stopTime | ||
| ) |
Definition at line 151 of file TimeROI.cpp.
References addMask().
Referenced by Mantid::Kernel::LogFilter::addFilter(), addMask(), addMask(), and Mantid::Kernel::TimeSeriesProperty< TYPE >::durationInSeconds().
| void Mantid::Kernel::TimeROI::addMask | ( | const std::time_t & | startTime, |
| const std::time_t & | stopTime | ||
| ) |
Definition at line 232 of file TimeROI.cpp.
References addMask().
| void Mantid::Kernel::TimeROI::addMask | ( | const Types::Core::DateAndTime & | startTime, |
| const Types::Core::DateAndTime & | stopTime | ||
| ) |
Remove a region that is already in use.
This subtracts the intersection which means adding a mask to an empty area does nothing. This may leave redundant values in the ROI
Definition at line 161 of file TimeROI.cpp.
References clear(), Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, Mantid::Geometry::intersection(), Mantid::Kernel::TimeInterval::intersection(), isCompletelyInMask(), m_roi, numBoundaries(), useAll(), and validateValues().
| void Mantid::Kernel::TimeROI::addROI | ( | const std::string & | startTime, |
| const std::string & | stopTime | ||
| ) |
Definition at line 76 of file TimeROI.cpp.
References addROI().
Referenced by Mantid::Kernel::LogFilter::addFilter(), addROI(), addROI(), Mantid::DataObjects::TimeSplitter::combinedTimeROI(), Mantid::Algorithms::FilterByLogValue::exec(), Mantid::Algorithms::GetAllEi::findChopSpeedAndDelay(), Mantid::DataHandling::AlignAndFocusPowderSlim::AlignAndFocusPowderSlim::getFilterROI(), Mantid::Kernel::TimeSeriesProperty< TYPE >::makeFilterByValue(), Mantid::API::Run::operator+=(), TimeROI(), and update_union().
| void Mantid::Kernel::TimeROI::addROI | ( | const std::time_t & | startTime, |
| const std::time_t & | stopTime | ||
| ) |
Definition at line 134 of file TimeROI.cpp.
References addROI().
| void Mantid::Kernel::TimeROI::addROI | ( | const Types::Core::DateAndTime & | startTime, |
| const Types::Core::DateAndTime & | stopTime | ||
| ) |
Add new region as a union.
Definition at line 83 of file TimeROI.cpp.
References clear(), Mantid::Kernel::Logger::debug(), empty(), Mantid::Kernel::DateAndTimeHelpers::g_log, isCompletelyInROI(), m_roi, toTimeIntervals(), and validateValues().
| void Mantid::Kernel::TimeROI::appendROIFast | ( | const Types::Core::DateAndTime & | startTime, |
| const Types::Core::DateAndTime & | stopTime | ||
| ) |
Append a new region to TimeROI fast.
Use this method only when there is no need for the comprehensive logic of addROI.
Definition at line 142 of file TimeROI.cpp.
References m_roi.
| std::vector< std::pair< size_t, size_t > > Mantid::Kernel::TimeROI::calculate_indices | ( | const std::vector< Types::Core::DateAndTime > & | times | ) | const |
Definition at line 346 of file TimeROI.cpp.
References m_roi, and useAll().
Referenced by Mantid::DataHandling::AlignAndFocusPowderSlim::AlignAndFocusPowderSlim::determinePulseIndices(), and Mantid::DataHandling::AlignAndFocusPowderSlim::AlignAndFocusPowderSlim::determinePulseIndicesTargets().
| void Mantid::Kernel::TimeROI::clear | ( | ) |
| std::string Mantid::Kernel::TimeROI::debugStrPrint | ( | const std::size_t | type = 0 | ) | const |
print the ROI boundaries to a string
Returns the ROI boundaries to a string.
Example: debugStrPrint(0) returns "0: 2022-Dec-19 00:01:00 to 2022-Dec-26 00:01:00\n" for a single ROI debugStrPrint(1) returns "2022-Dec-19 00:01:00 2022-Dec-26 00:01:00\n" for a single ROI
| type | :: either "0" or "1", for different representation |
Definition at line 602 of file TimeROI.cpp.
References m_roi.
| double Mantid::Kernel::TimeROI::durationInSeconds | ( | ) | const |
Duration of the whole TimeROI.
Definition at line 624 of file TimeROI.cpp.
References m_roi, numBoundaries(), and useNone().
Referenced by Mantid::Algorithms::SumEventsByLogValue::createTableOutput(), Mantid::Kernel::TimeSeriesProperty< TYPE >::durationInSeconds(), durationInSeconds(), and export_TimeROI().
| double Mantid::Kernel::TimeROI::durationInSeconds | ( | const Types::Core::DateAndTime & | startTime, |
| const Types::Core::DateAndTime & | stopTime | ||
| ) | const |
Duration of the TimeROI between startTime and stopTime.
Definition at line 643 of file TimeROI.cpp.
References durationInSeconds(), m_roi, update_intersection(), and useAll().
|
private |
Definition at line 691 of file TimeROI.cpp.
References numBoundaries().
Referenced by addROI(), useAll(), and valueAtTime().
| Types::Core::DateAndTime Mantid::Kernel::TimeROI::firstTime | ( | ) | const |
Definition at line 328 of file TimeROI.cpp.
References m_roi.
Referenced by export_TimeROI(), Mantid::Kernel::TimeSeriesProperty< TYPE >::filteredTimesAsVector(), Mantid::Kernel::TimeSeriesProperty< TYPE >::filteredValuesAsVector(), and Mantid::Kernel::TimeSeriesProperty< TYPE >::firstValue().
|
inline |
|
private |
get a list of all unique times. order is not guaranteed
Definition at line 373 of file TimeROI.cpp.
References m_roi.
| Types::Core::DateAndTime Mantid::Kernel::TimeROI::getEffectiveTime | ( | const Types::Core::DateAndTime & | time | ) | const |
Returns the time supplied if it is in a "use" region, or the minimum of the next higher use region.
If the ROI is empty, the time is returned. If the Time is after the ROI, an exception is thrown This is intended to be used with logs.
Definition at line 309 of file TimeROI.cpp.
References m_roi, and valueAtTime().
| size_t Mantid::Kernel::TimeROI::getMemorySize | ( | ) | const |
Definition at line 619 of file TimeROI.cpp.
References numBoundaries().
|
private |
This method returns true if the entire region between startTime and stopTime is inside an existing ignore interval.
If part of the supplied region is not covered this returns false.
Definition at line 261 of file TimeROI.cpp.
References m_roi, useAll(), and valueAtTime().
Referenced by addMask().
|
private |
This method returns true if the entire region between startTime and stopTime is inside an existing use interval.
If part of the supplied region is not covered this returns false.
Definition at line 240 of file TimeROI.cpp.
References m_roi, and valueAtTime().
Referenced by addROI().
| Types::Core::DateAndTime Mantid::Kernel::TimeROI::lastTime | ( | ) | const |
Definition at line 335 of file TimeROI.cpp.
References m_roi.
Referenced by export_TimeROI(), and Mantid::Kernel::TimeSeriesProperty< TYPE >::lastValue().
| std::size_t Mantid::Kernel::TimeROI::numberOfRegions | ( | ) | const |
Definition at line 689 of file TimeROI.cpp.
References numBoundaries().
Referenced by export_TimeROI().
| std::size_t Mantid::Kernel::TimeROI::numBoundaries | ( | ) | const |
Definition at line 687 of file TimeROI.cpp.
References m_roi.
Referenced by addMask(), durationInSeconds(), empty(), Mantid::Algorithms::FilterByLogValue::exec(), getMemorySize(), and numberOfRegions().
| bool Mantid::Kernel::TimeROI::operator!= | ( | const TimeROI & | other | ) | const |
Definition at line 592 of file TimeROI.cpp.
References m_roi.
| bool Mantid::Kernel::TimeROI::operator== | ( | const TimeROI & | other | ) | const |
Definition at line 591 of file TimeROI.cpp.
References m_roi.
| void Mantid::Kernel::TimeROI::replaceROI | ( | const std::vector< Types::Core::DateAndTime > & | roi | ) |
This assumes that the supplied vector is sorted in increasing order of time.
Definition at line 441 of file TimeROI.cpp.
References m_roi.
| void Mantid::Kernel::TimeROI::replaceROI | ( | const TimeROI & | other | ) |
Definition at line 434 of file TimeROI.cpp.
References m_roi.
| void Mantid::Kernel::TimeROI::replaceROI | ( | const TimeSeriesProperty< bool > * | roi | ) |
Definition at line 386 of file TimeROI.cpp.
References Mantid::Kernel::TimeSeriesProperty< TYPE >::eliminateDuplicates(), Mantid::Kernel::TimeSeriesProperty< TYPE >::firstTime(), Mantid::Kernel::TimeSeriesProperty< TYPE >::lastTime(), Mantid::Kernel::TimeSeriesProperty< TYPE >::lastValue(), m_roi, Mantid::Kernel::TimeSeriesProperty< TYPE >::size(), Mantid::Kernel::TimeSeriesProperty< TYPE >::timesAsVector(), validateValues(), and Mantid::Kernel::TimeSeriesProperty< TYPE >::valuesAsVector().
Referenced by Mantid::API::LogManager::setTimeROI(), TimeROI(), update_intersection(), and update_or_replace_intersection().
| void Mantid::Kernel::TimeROI::saveNexus | ( | Nexus::File * | file | ) | const |
Definition at line 701 of file TimeROI.cpp.
References Mantid::Kernel::TimeSeriesProperty< TYPE >::addValue(), NAME, Mantid::Kernel::TimeSeriesProperty< TYPE >::saveProperty(), and toTimeIntervals().
| Types::Core::DateAndTime Mantid::Kernel::TimeROI::timeAtIndex | ( | unsigned long | index | ) | const |
Definition at line 341 of file TimeROI.cpp.
| const std::vector< Kernel::TimeInterval > Mantid::Kernel::TimeROI::toTimeIntervals | ( | ) | const |
This method is to lend itself to helping with transition.
Definition at line 557 of file TimeROI.cpp.
References m_roi.
Referenced by addROI(), Mantid::Algorithms::FilterEvents::createOutputWorkspaces(), Mantid::DataObjects::EventList::filterByPulseTime(), Mantid::Kernel::TimeSeriesProperty< TYPE >::filteredTimesAsVector(), Mantid::Kernel::TimeSeriesProperty< TYPE >::filteredValuesAsVector(), Mantid::DataObjects::EventList::filterInPlaceHelper(), getTimeIntervals(), saveNexus(), Mantid::Kernel::LogFilter::setFilter(), Mantid::Kernel::TimeSeriesProperty< TYPE >::timeAverageValue(), and Mantid::Kernel::TimeSeriesProperty< TYPE >::timeAverageValueAndStdDev().
| const std::vector< Kernel::TimeInterval > Mantid::Kernel::TimeROI::toTimeIntervals | ( | const Types::Core::DateAndTime & | after | ) | const |
Time intervals returned where no time is before after.
This is used in calculating ranges in TimeSeriesProperty.
| after | Only give TimeIntervals after this time |
Definition at line 574 of file TimeROI.cpp.
References m_roi.
| void Mantid::Kernel::TimeROI::update_intersection | ( | const TimeROI & | other | ) |
Updates the TimeROI values with the intersection with another TimeROI.
See https://en.wikipedia.org/wiki/Intersection for the intersection theory. The algorithm is adapted from https://www.geeksforgeeks.org/find-intersection-of-intervals-given-by-two-lists/
Intersection with an empty TimeROI will clear out this one.
Definition at line 503 of file TimeROI.cpp.
References Mantid::Kernel::ROI::calculate_intersection(), m_roi, replaceROI(), and USE_NONE.
Referenced by Mantid::Kernel::LogFilter::addFilter(), durationInSeconds(), Mantid::Algorithms::FilterByLogValue::exec(), export_TimeROI(), Mantid::Kernel::TimeSeriesProperty< TYPE >::makeFilterByValue(), and update_or_replace_intersection().
| void Mantid::Kernel::TimeROI::update_or_replace_intersection | ( | const TimeROI & | other | ) |
If this is empty, replace it with the supplied TimeROI, otherwise calculate the intersection.
Supplying an empty TimeROI will have no effect. Thinking of the TimeROI as filters, the goal is to filter with the intersection or with either of the filters if one of them is empty.
| other | :: the replacing or intersecting TimeROI. |
Definition at line 548 of file TimeROI.cpp.
References replaceROI(), update_intersection(), and useAll().
Referenced by Mantid::API::LogManager::cloneInTimeROI(), Mantid::Algorithms::FilterEvents::createOutputWorkspaces(), Mantid::API::Run::integrateProtonCharge(), and Mantid::Kernel::FilteredTimeSeriesProperty< HeldType >::intersectFilterWithOther().
| void Mantid::Kernel::TimeROI::update_union | ( | const TimeROI & | other | ) |
Updates the TimeROI values with the union with another TimeROI.
See https://en.wikipedia.org/wiki/Union_(set_theory) for more details
Union with an empty TimeROI will do nothing.
Definition at line 529 of file TimeROI.cpp.
References addROI().
Referenced by export_TimeROI(), and Mantid::API::Run::operator+=().
| bool Mantid::Kernel::TimeROI::useAll | ( | ) | const |
TimeROI selects all time to be used.
Definition at line 693 of file TimeROI.cpp.
References empty().
Referenced by addMask(), calculate_indices(), Mantid::DataHandling::AlignAndFocusPowderSlim::AlignAndFocusPowderSlim::determinePulseIndices(), Mantid::DataHandling::AlignAndFocusPowderSlim::AlignAndFocusPowderSlim::determinePulseIndicesTargets(), Mantid::Kernel::TimeSeriesProperty< TYPE >::durationInSeconds(), durationInSeconds(), export_TimeROI(), Mantid::Kernel::TimeSeriesProperty< TYPE >::extractStatistic(), Mantid::DataObjects::EventList::filterByPulseTime(), Mantid::Kernel::TimeSeriesProperty< TYPE >::filteredTimesAsVector(), Mantid::Kernel::TimeSeriesProperty< TYPE >::filteredValuesAsVector(), Mantid::DataObjects::EventList::filterInPlace(), Mantid::Kernel::FilteredTimeSeriesProperty< HeldType >::filterWith(), Mantid::Algorithms::GetAllEi::getAvrgLogValue(), Mantid::API::Run::integrateProtonCharge(), isCompletelyInMask(), Mantid::Kernel::TimeSeriesProperty< TYPE >::makeFilterByValue(), Mantid::API::Run::operator+=(), Mantid::Kernel::TimeSeriesProperty< TYPE >::timeAverageValue(), Mantid::Kernel::TimeSeriesProperty< TYPE >::timeAverageValueAndStdDev(), and update_or_replace_intersection().
| bool Mantid::Kernel::TimeROI::useNone | ( | ) | const |
TimeROI selects no time to be used as all is invalid.
Definition at line 695 of file TimeROI.cpp.
References USE_NONE.
Referenced by durationInSeconds(), export_TimeROI(), Mantid::Kernel::TimeSeriesProperty< TYPE >::timeAverageValue(), and valueAtTime().
|
private |
Definition at line 666 of file TimeROI.cpp.
References m_roi.
Referenced by addMask(), addROI(), and replaceROI().
| bool Mantid::Kernel::TimeROI::valueAtTime | ( | const Types::Core::DateAndTime & | time | ) | const |
This returns whether the time should be "used" (rather than ignored).
Anything outside of the region of interest is ignored.
The value is, essentially, whatever it was at the last recorded time before or equal to the one requested.
Definition at line 286 of file TimeROI.cpp.
References empty(), m_roi, and useNone().
Referenced by getEffectiveTime(), isCompletelyInMask(), and isCompletelyInROI().
|
private |
Definition at line 77 of file TimeROI.h.
Referenced by addMask(), addROI(), appendROIFast(), calculate_indices(), clear(), debugStrPrint(), durationInSeconds(), durationInSeconds(), firstTime(), getAllTimes(), getEffectiveTime(), isCompletelyInMask(), isCompletelyInROI(), lastTime(), numBoundaries(), operator!=(), operator==(), replaceROI(), replaceROI(), replaceROI(), timeAtIndex(), toTimeIntervals(), toTimeIntervals(), update_intersection(), validateValues(), and valueAtTime().
|
static |
the underlying property needs a name
Definition at line 21 of file TimeROI.h.
Referenced by Mantid::API::LogManager::loadNexus(), Mantid::API::LogManager::loadNexus(), and saveNexus().
|
static |
Constant for TimeROI where any time is used.
Definition at line 23 of file TimeROI.h.
Referenced by Mantid::DataObjects::TimeSplitter::getTimeROI().
|
static |
Constant for TimeROI where no time is used.
Definition at line 22 of file TimeROI.h.
Referenced by Mantid::Kernel::TimeSeriesProperty< TYPE >::makeFilterByValue(), update_intersection(), and useNone().