Mantid
Loading...
Searching...
No Matches
TimeROI.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2022 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidKernel/DllConfig.h"
12
13namespace Mantid {
14namespace Kernel {
15
18class MANTID_KERNEL_DLL TimeROI {
19public:
21 static const std::string NAME;
22 static const TimeROI USE_NONE;
23 static const TimeROI USE_ALL;
24
25 TimeROI();
26 TimeROI(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime);
28
29 double durationInSeconds() const;
30 double durationInSeconds(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) const;
31 std::size_t numBoundaries() const;
32 std::size_t numberOfRegions() const;
34 bool useAll() const;
36 bool useNone() const;
37 void clear();
38 void addROI(const std::string &startTime, const std::string &stopTime);
39 void addROI(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime);
40 void addROI(const std::time_t &startTime, const std::time_t &stopTime);
41 void appendROIFast(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime);
42 void addMask(const std::string &startTime, const std::string &stopTime);
43 void addMask(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime);
44 void addMask(const std::time_t &startTime, const std::time_t &stopTime);
45 bool valueAtTime(const Types::Core::DateAndTime &time) const;
46 Types::Core::DateAndTime getEffectiveTime(const Types::Core::DateAndTime &time) const;
47 Types::Core::DateAndTime firstTime() const;
48 Types::Core::DateAndTime lastTime() const;
49 const std::vector<Types::Core::DateAndTime> &getAllTimes() const { return m_roi; }
50
51 void replaceROI(const TimeSeriesProperty<bool> *roi);
52 void replaceROI(const TimeROI &other);
53 void replaceROI(const std::vector<Types::Core::DateAndTime> &roi);
54
55 void update_union(const TimeROI &other);
56 void update_intersection(const TimeROI &other);
57 void update_or_replace_intersection(const TimeROI &other);
58 const std::vector<Kernel::TimeInterval> toTimeIntervals() const;
59 const std::vector<Kernel::TimeInterval> toTimeIntervals(const Types::Core::DateAndTime &after) const;
60 bool operator==(const TimeROI &other) const;
61 bool operator!=(const TimeROI &other) const;
63 std::string debugStrPrint(const std::size_t type = 0) const;
64 size_t getMemorySize() const;
65 Types::Core::DateAndTime timeAtIndex(unsigned long index) const;
66 std::vector<std::pair<size_t, size_t>> calculate_indices(const std::vector<Types::Core::DateAndTime> &times) const;
67
68 // nexus items
69 void saveNexus(Nexus::File *file) const;
70
71private:
72 std::vector<Types::Core::DateAndTime> getAllTimes(const TimeROI &other);
73 void validateValues(const std::string &label);
74 bool empty() const;
75 bool isCompletelyInROI(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) const;
76 bool isCompletelyInMask(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) const;
77 std::vector<Types::Core::DateAndTime> m_roi;
78};
79
80namespace ROI {
86template <typename TYPE>
87std::vector<TYPE> calculate_intersection(const std::vector<TYPE> &left, const std::vector<TYPE> &right);
88} // namespace ROI
89
90} // namespace Kernel
91} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
double left
double right
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
const std::vector< Types::Core::DateAndTime > & getAllTimes() const
Definition TimeROI.h:49
std::vector< Types::Core::DateAndTime > m_roi
Definition TimeROI.h:77
static const std::string NAME
the underlying property needs a name
Definition TimeROI.h:21
static const TimeROI USE_ALL
Constant for TimeROI where any time is used.
Definition TimeROI.h:23
static const TimeROI USE_NONE
Constant for TimeROI where no time is used.
Definition TimeROI.h:22
A specialised Property class for holding a series of time-value pairs.
std::vector< TYPE > calculate_intersection(const std::vector< TYPE > &left, const std::vector< TYPE > &right)
This calculates the intersection of two sorted vectors that represent regions of interest (ROI).
Definition TimeROI.cpp:449
Helper class which provides the Collimation Length for SANS instruments.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)