15#include <boost/python/class.hpp>
16#include <boost/python/copy_const_reference.hpp>
17#include <boost/python/list.hpp>
18#include <boost/python/overloads.hpp>
19#include <boost/python/register_ptr_to_python.hpp>
42double getPropertyAsSingleValueWithDefaultStatistic(
Run &self,
const std::string &name) {
58double getPropertyAsSingleValueWithTimeAveragedMean(
Run &self,
const std::string &name) {
71void addPropertyWithUnit(
Run &self,
const std::string &name,
const bpl::object &
value,
const std::string &units,
73 extract<Property *> extractor(
value);
74 if (extractor.check()) {
84 property->setUnits(units);
96void addProperty(
Run &self,
const std::string &name,
const bpl::object &
value,
bool replace) {
97 addPropertyWithUnit(self, name,
value,
"", replace);
107void addOrReplaceProperty(
Run &self,
const std::string &name,
const bpl::object &
value) {
108 addProperty(self, name,
value,
true);
118bpl::object getWithDefault(bpl::object self,
const bpl::object &key, bpl::object default_) {
119 bpl::object
exists(self.attr(
"__contains__"));
120 if (extract<bool>(
exists(key))()) {
121 return self.attr(
"__getitem__")(key);
133bpl::object get(bpl::object self,
const bpl::object &key) {
134 return getWithDefault(std::move(self), key, bpl::object());
141bpl::list keys(
Run &self) {
142 const std::vector<Mantid::Kernel::Property *> &logs = self.
getProperties();
144 for (
auto log : logs) {
145 names.append(log->name());
162 register_ptr_to_python<Run *>();
165 class_<Run, boost::noncopyable>(
"Run")
166 .def(
"getProtonCharge", &
Run::getProtonCharge, arg(
"self"),
"Return the total good proton charge for the run")
169 integrateProtonCharge_Overload(
"Set the total good proton charge for the run, from the proton "
171 (arg(
"self"), arg(
"logname") =
"proton_charge")))
174 "Returns True if the given log value is contained within the run")
176 .def(
"getProperty", &
Run::getProperty, (arg(
"self"), arg(
"name")), return_value_policy<return_by_value>(),
177 "Returns the named property "
178 "(log value). Use '.value' "
179 "to return the value.")
181 .def(
"getPropertyAsSingleValue", getPropertyAsSingleValueWithDefaultStatistic, (arg(
"self"), arg(
"name")),
182 "Return a log as a single float value. Time series values are "
185 .def(
"getPropertyAsSingleValueWithTimeAveragedMean", getPropertyAsSingleValueWithTimeAveragedMean,
186 (arg(
"self"), arg(
"name")),
187 "Returns a log as a single float value. Calculated using "
188 "time-averaged mean.")
191 "Returns the time averaged standard deviation")
193 .def(
"getProperties", &
Run::getProperties, arg(
"self"), return_internal_reference<>(),
194 "Return the list of run properties managed by this object.")
197 return_value_policy<return_by_value>(),
198 "Returns the named log. Use '.value' to return the value. The "
202 .def(
"getLogData", (
const std::vector<Property *> &(
Run::*)()
const) &
Run::getLogData, arg(
"self"),
203 return_internal_reference<>(),
204 "Return the list of logs for this run. The same as "
208 (arg(
"self"), arg(
"index") = 0), return_value_policy<reference_existing_object>(),
209 "Return Goniometer object associated with this run by index, "
210 "default first goniometer.")
213 "Return the number of goniometer objects associated with this run.")
215 .def(
"addProperty", &addProperty, (arg(
"self"), arg(
"name"), arg(
"value"), arg(
"replace")),
216 "Adds a property with the given name "
217 "and value. If replace=True then an "
218 "existing property is overwritten")
220 .def(
"addProperty", &addPropertyWithUnit, (arg(
"self"), arg(
"name"), arg(
"value"), arg(
"units"), arg(
"replace")),
221 "Adds a property with the given name, value and unit. If "
222 "replace=True then an existing property is overwritten")
225 "Set the start and end time of the run")
227 .def(
"startTime", &
Run::startTime, arg(
"self"),
"Return the total starting time of the run.")
229 .def(
"endTime", &
Run::endTime, arg(
"self"),
"Return the total ending time of the run.")
232 .def(
"get", &getWithDefault, (arg(
"self"), arg(
"key"), arg(
"default")),
233 "Returns the value pointed to by the key or the default value "
235 .def(
"get", &get, (arg(
"self"), arg(
"key")),
236 "Returns the value pointed to by the key or "
237 "None if it does not exist.")
238 .def(
"keys", &keys, arg(
"self"),
"Returns the names of the properties as list")
240 .def(
"__getitem__", &
Run::getProperty, (arg(
"self"), arg(
"name")), return_value_policy<return_by_value>())
241 .def(
"__setitem__", &addOrReplaceProperty, (arg(
"self"), arg(
"name"), arg(
"value")))
242 .def(
"__copy__", &Mantid::PythonInterface::generic__copy__<Run>)
243 .def(
"__deepcopy__", &Mantid::PythonInterface::generic__deepcopy__<Run>)
244 .def(
"__eq__", &Run::operator==, arg(
"self"), arg(
"other"));
double value
The value of the point.
#define GET_POINTER_SPECIALIZATION(TYPE)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, valueAsPrettyStr, 0, 2) void export_Property()
#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 std::vector< Kernel::Property * > & getLogData() const
Access all log entries.
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.
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)
Based on the current group in the file, does the named sub-entry exist?
@ Input
An input workspace.