17using Mantid::Types::Core::DateAndTime;
19using std::stringstream;
40 "A workspace with units of TOF");
42 "The name to use for the output workspace");
43 this->
declareProperty(
"LogName",
"",
"Name of the log to add the offset to");
45 "Number of (integer) values to move the log values. Required.");
53 if (logname.empty()) {
54 throw std::runtime_error(
"Failed to supply a LogName");
64 msg <<
"InputWorkspace \'" << this->
getPropertyValue(
"InputWorkspace") <<
"\' does not have LogName \'" << logname
66 throw std::runtime_error(msg.str());
70 int size = oldlog->realSize();
71 if (abs(indexshift) > size) {
73 msg <<
"IndexShift (=" << indexshift <<
") is larger than the log length (=" << size <<
")";
74 throw std::runtime_error(msg.str());
76 vector<double> values = oldlog->valuesAsVector();
77 vector<DateAndTime> times = oldlog->timesAsVector();
80 if (indexshift == 0) {
82 }
else if (indexshift > 0) {
83 values.erase(values.end() - indexshift, values.end());
84 times.erase(times.begin(), times.begin() + indexshift);
88 values.erase(values.begin(), values.begin() - indexshift);
89 times.erase(times.end() + indexshift, times.end());
94 newlog->setUnits(oldlog->units());
95 newlog->create(times, values);
99 if (outputWS != inputWS) {
101 duplicate->initialize();
102 duplicate->setProperty<
Workspace_sptr>(
"InputWorkspace", std::dynamic_pointer_cast<Workspace>(inputWS));
103 duplicate->execute();
105 outputWS = std::dynamic_pointer_cast<MatrixWorkspace>(temp);
110 outputWS->mutableRun().addProperty(newlog,
true);
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
A property class for workspaces.
ShiftLogTime : TODO: DESCRIPTION.
void exec() override
Run the algorithm.
void init() override
Sets documentation strings for this algorithm.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
The concrete, templated class for properties.
A specialised Property class for holding a series of time-value pairs.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ Input
An input workspace.
@ Output
An output workspace.