Mantid
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
Mantid::Kernel::TimeROI Class Reference

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 > &times) 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::TimeIntervaltoTimeIntervals () const
 This method is to lend itself to helping with transition.
 
const std::vector< Kernel::TimeIntervaltoTimeIntervals (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
 

Detailed Description

TimeROI : Object that holds information about when the time measurement was active.

Definition at line 18 of file TimeROI.h.

Constructor & Destructor Documentation

◆ TimeROI() [1/3]

Mantid::Kernel::TimeROI::TimeROI ( )

Definition at line 68 of file TimeROI.cpp.

◆ TimeROI() [2/3]

Mantid::Kernel::TimeROI::TimeROI ( const Types::Core::DateAndTime &  startTime,
const Types::Core::DateAndTime &  stopTime 
)

Definition at line 70 of file TimeROI.cpp.

References addROI().

◆ TimeROI() [3/3]

Mantid::Kernel::TimeROI::TimeROI ( const Kernel::TimeSeriesProperty< bool > *  filter)

Definition at line 74 of file TimeROI.cpp.

References replaceROI().

Member Function Documentation

◆ addMask() [1/3]

void Mantid::Kernel::TimeROI::addMask ( const std::string &  startTime,
const std::string &  stopTime 
)

◆ addMask() [2/3]

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().

◆ addMask() [3/3]

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().

◆ addROI() [1/3]

void Mantid::Kernel::TimeROI::addROI ( const std::string &  startTime,
const std::string &  stopTime 
)

◆ addROI() [2/3]

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().

◆ addROI() [3/3]

void Mantid::Kernel::TimeROI::addROI ( const Types::Core::DateAndTime &  startTime,
const Types::Core::DateAndTime &  stopTime 
)

◆ appendROIFast()

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.

◆ calculate_indices()

std::vector< std::pair< size_t, size_t > > Mantid::Kernel::TimeROI::calculate_indices ( const std::vector< Types::Core::DateAndTime > &  times) const

◆ clear()

void Mantid::Kernel::TimeROI::clear ( )

Removes all ROI's, leaving an empty object.

Definition at line 698 of file TimeROI.cpp.

References clear(), and m_roi.

Referenced by addMask(), addROI(), and clear().

◆ debugStrPrint()

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

Parameters
type:: either "0" or "1", for different representation
Returns
ROI boundaries

Definition at line 602 of file TimeROI.cpp.

References m_roi.

◆ durationInSeconds() [1/2]

double Mantid::Kernel::TimeROI::durationInSeconds ( ) const

◆ durationInSeconds() [2/2]

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().

◆ empty()

bool Mantid::Kernel::TimeROI::empty ( ) const
private

Definition at line 691 of file TimeROI.cpp.

References numBoundaries().

Referenced by addROI(), useAll(), and valueAtTime().

◆ firstTime()

Types::Core::DateAndTime Mantid::Kernel::TimeROI::firstTime ( ) const

◆ getAllTimes() [1/2]

const std::vector< Types::Core::DateAndTime > & Mantid::Kernel::TimeROI::getAllTimes ( ) const
inline

Definition at line 49 of file TimeROI.h.

◆ getAllTimes() [2/2]

std::vector< DateAndTime > Mantid::Kernel::TimeROI::getAllTimes ( const TimeROI other)
private

get a list of all unique times. order is not guaranteed

Definition at line 373 of file TimeROI.cpp.

References m_roi.

◆ getEffectiveTime()

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().

◆ getMemorySize()

size_t Mantid::Kernel::TimeROI::getMemorySize ( ) const

Definition at line 619 of file TimeROI.cpp.

References numBoundaries().

◆ isCompletelyInMask()

bool Mantid::Kernel::TimeROI::isCompletelyInMask ( const Types::Core::DateAndTime &  startTime,
const Types::Core::DateAndTime &  stopTime 
) const
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().

◆ isCompletelyInROI()

bool Mantid::Kernel::TimeROI::isCompletelyInROI ( const Types::Core::DateAndTime &  startTime,
const Types::Core::DateAndTime &  stopTime 
) const
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().

◆ lastTime()

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().

◆ numberOfRegions()

std::size_t Mantid::Kernel::TimeROI::numberOfRegions ( ) const

Definition at line 689 of file TimeROI.cpp.

References numBoundaries().

Referenced by export_TimeROI().

◆ numBoundaries()

std::size_t Mantid::Kernel::TimeROI::numBoundaries ( ) const

◆ operator!=()

bool Mantid::Kernel::TimeROI::operator!= ( const TimeROI other) const

Definition at line 592 of file TimeROI.cpp.

References m_roi.

◆ operator==()

bool Mantid::Kernel::TimeROI::operator== ( const TimeROI other) const

Definition at line 591 of file TimeROI.cpp.

References m_roi.

◆ replaceROI() [1/3]

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.

◆ replaceROI() [2/3]

void Mantid::Kernel::TimeROI::replaceROI ( const TimeROI other)

Definition at line 434 of file TimeROI.cpp.

References m_roi.

◆ replaceROI() [3/3]

void Mantid::Kernel::TimeROI::replaceROI ( const TimeSeriesProperty< bool > *  roi)

◆ saveNexus()

void Mantid::Kernel::TimeROI::saveNexus ( Nexus::File *  file) const

◆ timeAtIndex()

Types::Core::DateAndTime Mantid::Kernel::TimeROI::timeAtIndex ( unsigned long  index) const

Definition at line 341 of file TimeROI.cpp.

References index, and m_roi.

◆ toTimeIntervals() [1/2]

const std::vector< Kernel::TimeInterval > Mantid::Kernel::TimeROI::toTimeIntervals ( ) const

◆ toTimeIntervals() [2/2]

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.

Parameters
afterOnly give TimeIntervals after this time

Definition at line 574 of file TimeROI.cpp.

References m_roi.

◆ update_intersection()

void Mantid::Kernel::TimeROI::update_intersection ( const TimeROI other)

◆ 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.

Parameters
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().

◆ update_union()

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+=().

◆ useAll()

bool Mantid::Kernel::TimeROI::useAll ( ) const

◆ useNone()

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().

◆ validateValues()

void Mantid::Kernel::TimeROI::validateValues ( const std::string &  label)
private

Definition at line 666 of file TimeROI.cpp.

References m_roi.

Referenced by addMask(), addROI(), and replaceROI().

◆ valueAtTime()

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().

Member Data Documentation

◆ m_roi

std::vector<Types::Core::DateAndTime> Mantid::Kernel::TimeROI::m_roi
private

◆ NAME

const std::string Mantid::Kernel::TimeROI::NAME = "Kernel_TimeROI"
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().

◆ USE_ALL

const TimeROI Mantid::Kernel::TimeROI::USE_ALL {}
static

Constant for TimeROI where any time is used.

Definition at line 23 of file TimeROI.h.

Referenced by Mantid::DataObjects::TimeSplitter::getTimeROI().

◆ USE_NONE

const TimeROI Mantid::Kernel::TimeROI::USE_NONE {DateAndTime::GPS_EPOCH - DateAndTime::ONE_SECOND, DateAndTime::GPS_EPOCH}
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().


The documentation for this class was generated from the following files: