Mantid
Loading...
Searching...
No Matches
TimeROI.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
8#include "MantidTypes/Core/DateAndTime.h"
9#include <boost/python/class.hpp>
10#include <boost/python/copy_const_reference.hpp>
11#include <boost/python/list.hpp>
12#include <boost/python/register_ptr_to_python.hpp>
13#include <boost/python/tuple.hpp>
14
16using Mantid::Types::Core::DateAndTime;
17using namespace boost::python;
18
19boost::python::list getTimeIntervals(const TimeROI &self) {
20 boost::python::list times;
21 for (const auto &splitter : self.toTimeIntervals()) {
22 times.append(make_tuple(splitter.start(), splitter.stop()));
23 }
24 return times;
25}
26
28 register_ptr_to_python<TimeROI *>();
29
30 class_<TimeROI>("TimeROI", no_init)
31 .def("durationInSeconds", (double (TimeROI::*)() const) & TimeROI::durationInSeconds, arg("self"),
32 "Duration of the whole TimeROI")
33 .def("durationInSeconds",
34 (double (TimeROI::*)(const DateAndTime &, const DateAndTime &) const) & TimeROI::durationInSeconds,
35 (arg("self"), arg("startTime"), arg("stopTime")), "Duration of the TimeROI between startTime and stopTime")
36 .def("update_union", &TimeROI::update_union, (arg("self"), arg("other")),
37 return_value_policy<copy_const_reference>(),
38 "Updates the TimeROI values with the union with another TimeROI."
39 "See https://en.wikipedia.org/wiki/Union_(set_theory) for more details")
40 .def("update_intersection", &TimeROI::update_intersection, (arg("self"), arg("other")),
41 return_value_policy<copy_const_reference>(),
42 "Updates the TimeROI values with the intersection with another TimeROI."
43 "See https://en.wikipedia.org/wiki/Intersection for more details")
44 .def("useAll", &TimeROI::useAll, "True if all times are use")
45 .def("useNone", &TimeROI::useNone, "True if all times are ignore")
46 .def("numberOfRegions", &TimeROI::numberOfRegions, arg("self"), "Number of regions of interest")
47 .def("firstTime", &TimeROI::firstTime,
48 "First time in the object. Will generate an execption if useAll() is True.")
49 .def("lastTime", &TimeROI::lastTime, "Last time in the object. Will generate an execption if useAll() is True.")
50 .def("toTimeIntervals", &getTimeIntervals, arg("self"),
51 "Returns a list of start and stop times for all time intervals");
52}
boost::python::list getTimeIntervals(const TimeROI &self)
Definition TimeROI.cpp:19
void export_TimeROI()
Definition TimeROI.cpp:27
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
double durationInSeconds() const
Duration of the whole TimeROI.
Definition TimeROI.cpp:624
const std::vector< Kernel::TimeInterval > toTimeIntervals() const
This method is to lend itself to helping with transition.
Definition TimeROI.cpp:557
Types::Core::DateAndTime firstTime() const
Definition TimeROI.cpp:328
std::size_t numberOfRegions() const
Definition TimeROI.cpp:689
void update_union(const TimeROI &other)
Updates the TimeROI values with the union with another TimeROI.
Definition TimeROI.cpp:529
bool useNone() const
TimeROI selects no time to be used as all is invalid.
Definition TimeROI.cpp:695
bool useAll() const
TimeROI selects all time to be used.
Definition TimeROI.cpp:693
void update_intersection(const TimeROI &other)
Updates the TimeROI values with the intersection with another TimeROI.
Definition TimeROI.cpp:503
Types::Core::DateAndTime lastTime() const
Definition TimeROI.cpp:335