16#include <boost/python/class.hpp>
17#include <boost/python/copy_const_reference.hpp>
18#include <boost/python/list.hpp>
19#include <boost/python/overloads.hpp>
20#include <boost/python/register_ptr_to_python.hpp>
43double getPropertyAsSingleValueWithDefaultStatistic(
Run &self,
const std::string &
name) {
59double getPropertyAsSingleValueWithTimeAveragedMean(
Run &self,
const std::string &
name) {
72void addPropertyWithUnit(
Run &self,
const std::string &
name,
const bpl::object &
value,
const std::string &units,
74 extract<Property *> extractor(
value);
75 if (extractor.check()) {
78 auto new_prop = prop->
clone();
84 new_prop->setUnits(units);
92 property->setUnits(units);
104void addProperty(
Run &self,
const std::string &
name,
const bpl::object &
value,
bool replace) {
105 addPropertyWithUnit(self,
name,
value,
"", replace);
115void addOrReplaceProperty(
Run &self,
const std::string &
name,
const bpl::object &
value) {
126bpl::object getWithDefault(bpl::object self,
const bpl::object &key, bpl::object default_) {
127 bpl::object
exists(self.attr(
"__contains__"));
128 if (extract<bool>(
exists(key))()) {
129 return self.attr(
"__getitem__")(key);
141bpl::object get(bpl::object self,
const bpl::object &key) {
142 return getWithDefault(std::move(self), key, bpl::object());
149bpl::list keys(
Run &self) {
150 const std::vector<Mantid::Kernel::Property *> &logs = self.
getProperties();
152 for (
auto log : logs) {
153 names.append(log->name());
163BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(integrateProtonCharge_Overload, integrateProtonCharge, 0, 1)
164BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getPropertyAsSingleValue_Overload, getPropertyAsSingleValue, 1, 1)
170 register_ptr_to_python<Run *>();
173 class_<Run, boost::noncopyable>(
"Run")
174 .def(
"getProtonCharge", &
Run::getProtonCharge, arg(
"self"),
"Return the total good proton charge for the run")
177 integrateProtonCharge_Overload(
"Set the total good proton charge for the run, from the proton "
179 (arg(
"self"), arg(
"logname") =
"proton_charge")))
182 "Returns True if the given log value is contained within the run")
184 .def(
"getProperty", &
Run::getProperty, (arg(
"self"), arg(
"name")), return_value_policy<return_by_value>(),
185 "Returns the named property "
186 "(log value). Use '.value' "
187 "to return the value.")
189 .def(
"getPropertyAsSingleValue", getPropertyAsSingleValueWithDefaultStatistic, (arg(
"self"), arg(
"name")),
190 "Return a log as a single float value. Time series values are "
193 .def(
"getPropertyAsSingleValueWithTimeAveragedMean", getPropertyAsSingleValueWithTimeAveragedMean,
194 (arg(
"self"), arg(
"name")),
195 "Returns a log as a single float value. Calculated using "
196 "time-averaged mean.")
199 "Returns the time averaged standard deviation")
201 "Returns the time averaged value of a log")
203 "Returns the all of the statistics about the obect")
204 .def(
"getProperties", &
Run::getProperties, arg(
"self"), return_internal_reference<>(),
205 "Return the list of run properties managed by this object.")
208 return_value_policy<return_by_value>(),
209 "Returns the named log. Use '.value' to return the value. The "
213 .def(
"getLogData", (
const std::vector<Property *> &(
Run::*)()
const) &
Run::getLogData, arg(
"self"),
214 return_internal_reference<>(),
215 "Return the list of logs for this run. The same as "
219 (arg(
"self"), arg(
"index") = 0), return_value_policy<reference_existing_object>(),
220 "Return Goniometer object associated with this run by index, "
221 "default first goniometer.")
224 "Return the number of goniometer objects associated with this run.")
226 .def(
"addProperty", &addProperty, (arg(
"self"), arg(
"name"), arg(
"value"), arg(
"replace")),
227 "Adds a property with the given name "
228 "and value. If replace=True then an "
229 "existing property is overwritten")
231 .def(
"addProperty", &addPropertyWithUnit, (arg(
"self"), arg(
"name"), arg(
"value"), arg(
"units"), arg(
"replace")),
232 "Adds a property with the given name, value and unit. If "
233 "replace=True then an existing property is overwritten")
236 "Set the start and end time of the run")
238 .def(
"startTime", &
Run::startTime, arg(
"self"),
"Return the total starting time of the run.")
240 .def(
"endTime", &
Run::endTime, arg(
"self"),
"Return the total ending time of the run.")
242 .def(
"getTimeROI", &
Run::getTimeROI, arg(
"self"), return_value_policy<reference_existing_object>(),
243 "Return the time regoin of interest")
246 .def(
"get", &getWithDefault, (arg(
"self"), arg(
"key"), arg(
"default")),
247 "Returns the value pointed to by the key or the default value "
249 .def(
"get", &get, (arg(
"self"), arg(
"key")),
250 "Returns the value pointed to by the key or "
251 "None if it does not exist.")
252 .def(
"keys", &keys, arg(
"self"),
"Returns the names of the properties as list")
254 .def(
"__getitem__", &
Run::getProperty, (arg(
"self"), arg(
"name")), return_value_policy<return_by_value>())
255 .def(
"__setitem__", &addOrReplaceProperty, (arg(
"self"), arg(
"name"), arg(
"value")))
256 .def(
"__copy__", &Mantid::PythonInterface::generic__copy__<Run>)
257 .def(
"__deepcopy__", &Mantid::PythonInterface::generic__deepcopy__<Run>)
258 .def(
"__eq__", &Run::operator==, arg(
"self"), arg(
"other"));
double value
The value of the point.
#define GET_POINTER_SPECIALIZATION(TYPE)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
This class contains the information about the log entries.
double getTimeAveragedStd(const std::string &name) const
Get the time averaged standard deviation for a log.
const Types::Core::DateAndTime endTime() const
Return the run end time.
bool hasProperty(const std::string &name) const
Does the property exist on the object.
const Kernel::TimeROI & getTimeROI() const
const std::vector< Kernel::Property * > & getLogData() const
Access all log entries.
double getTimeAveragedValue(const std::string &name) const
Get the time averaged value for a log.
Kernel::TimeSeriesPropertyStatistics getStatistics(const std::string &name) const
Returns various statistics computations for a given property.
const Types::Core::DateAndTime startTime() const
Return the run start time.
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
const std::vector< Kernel::Property * > & getProperties() const
Return all of the current properties.
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
double getPropertyAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic=Kernel::Math::Mean) const
Returns a property as a single double value from its name.
void setStartAndEndTime(const Types::Core::DateAndTime &start, const Types::Core::DateAndTime &end)
Set the run start and end.
This class stores information regarding an experimental run as a series of log entries.
void integrateProtonCharge(const std::string &logname="proton_charge") const
Integrate the proton charge over the whole run time - default log proton_charge.
size_t getNumGoniometers() const
Get the number of goniometers in the Run.
const Geometry::Goniometer & getGoniometer() const
Return reference to the first const Goniometer object for this run.
double getProtonCharge() const
Get the proton charge.
Class to represent a particular goniometer setting, which is described by the rotation matrix.
Base class for properties.
void setName(const std::string &name)
Set the property's name.
virtual Property * clone() const =0
'Virtual copy constructor'
static std::unique_ptr< Kernel::Property > create(const std::string &name, const boost::python::object &defaultValue, const boost::python::object &validator, const unsigned int direction)
Creates a PropertyWithValue<Type> instance from the given information.
Defines a structure for releasing the Python GIL using the RAII pattern.
bool exists(Nexus::File &file, const std::string &name)
@ Input
An input workspace.