21namespace MDAlgorithms {
41 return "Algorithm to load gauss cube files and output a 3D MDHistoWorkspace.";
48 auto algcreateMD = AlgorithmManager::Instance().createUnmanaged(
"CreateMDHistoWorkspace");
49 algcreateMD->initialize();
51 const std::vector<std::string> exts{
".cube"};
52 declareProperty(std::make_unique<FileProperty>(
"Filename",
"",
FileProperty::Load, exts),
53 "Path to gauss cube file (with extension .cube). Note algorithm assumes XYZ ordering.");
56 "3D MDHistoWorkspace containing the data in the .cube file.");
68 std::map<std::string, std::string> errors;
69 std::vector<std::string> prop_names = {
"Names",
"Frames",
"Units"};
70 for (
auto name : prop_names) {
71 std::vector<std::string> prop;
72 if (
name ==
"Names") {
77 if (prop.size() != 3) {
78 errors.emplace(
name,
"Property must contain three elements (workspace must have three dimensions).");
91 std::ifstream in(Filename.c_str());
93 for (
int indexOfLine = 0; indexOfLine < 2; ++indexOfLine) {
94 in.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
98 std::vector<double> extents(6, 0.0);
101 for (
size_t indexOfDim = 0; indexOfDim < 3; ++indexOfDim) {
103 if (str.length() < 1) {
104 throw std::logic_error(std::string(
105 "Third line must contain 4 elements (first isignored) and subsequent 3 are the lower extents of workspace."));
107 extents[2 * indexOfDim] = std::stod(str);
112 std::vector<int> nbins(3, 0);
113 for (
size_t indexOfDim = 0; indexOfDim < 3; ++indexOfDim) {
114 nbins[indexOfDim] = std::stoi(
getWord(in,
false));
115 for (
size_t indexOfWordToSkip = 0; indexOfWordToSkip < indexOfDim; ++indexOfWordToSkip) {
118 extents[2 * indexOfDim + 1] = extents[2 * indexOfDim] + std::stod(
getWord(in,
true));
119 if (indexOfDim < 2) {
125 size_t nBinsTotal = nbins[0] * nbins[1] * nbins[2];
126 std::vector<double> signal(nBinsTotal, 0.0);
127 std::vector<double>
error(nBinsTotal, 0.0);
129 for (
size_t indexOfBin = 0; indexOfBin < nBinsTotal && in.good(); ++indexOfBin) {
130 signal[indexOfBin] = std::stod(
getWord(in,
true));
147 setPropertyValue(
"OutputWorkspace", alg.
getPropertyValue(
"OutputWorkspace"));
#define DECLARE_ALGORITHM(classname)
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
void initialize() override
Initialization method invoked by the framework.
bool execute() override final
The actions to be performed by the algorithm on a dataset.
void setPropertyValue(const std::string &name, const std::string &value) override
Set the value of a property by string N.B.
@ Load
allowed here which will be passed to the algorithm
void copyProperty(const API::Algorithm_sptr &alg, const std::string &name)
Copy a property from an existing algorithm.
Kernel::IPropertyManager::TypedValue getProperty(const std::string &name) const override
Get the property held by this object.
std::string getPropertyValue(const std::string &name) const override
Get the property held by this object.
A property class for workspaces.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
LoadGaussCube : TODO: DESCRIPTION.
void exec() override
Execute the algorithm.
void init() override
Initialize the algorithm's properties.
int version() const override
Algorithm's version for identification.
const std::string name() const override
Algorithms name for identification.
std::map< std::string, std::string > validateInputs() override
Validate input.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
const std::string category() const override
Algorithm's category for identification.
Holds support functions for strings.
MANTID_KERNEL_DLL void readToEndOfLine(std::istream &in, bool ConsumeEOL)
Eat everything from the stream until the next EOL.
MANTID_KERNEL_DLL std::string getWord(std::istream &in, bool consumeEOL)
Returns the next word in the stream.
std::vector< std::string > MANTID_MDALGORITHMS_DLL parseNames(const std::string &names_string)
Helper class which provides the Collimation Length for SANS instruments.
Describes the direction (within an algorithm) of a Property.
@ Output
An output workspace.