Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/feature/8960_SaveILLCosmos_Algor…
…ithm'
- Loading branch information
Showing
8 changed files
with
771 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/AsciiPointBase.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#ifndef MANTID_DATAHANDLING_ASCIIPOINTBASE_H_ | ||
#define MANTID_DATAHANDLING_ASCIIPOINTBASE_H_ | ||
|
||
//---------------------------------------------------------------------- | ||
// Includes | ||
//---------------------------------------------------------------------- | ||
#include "MantidAPI/Algorithm.h" | ||
#include <fstream> | ||
|
||
namespace Mantid | ||
{ | ||
namespace DataHandling | ||
{ | ||
/** | ||
Abstract base class for some ascii format save algorithms that print point data and dq/q. | ||
AsciiPointBase is a framework for some algorithms. It overrides exec and init and provides full | ||
implementation for any subclasses and as such any subclasses should only provide implementations | ||
for the additional abstract and virtual methods provided by this class. | ||
Copyright © 2007-14 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://github.com/mantidproject/mantid>. | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport AsciiPointBase : public API::Algorithm | ||
{ | ||
public: | ||
/// Default constructor | ||
AsciiPointBase() {} | ||
/// Destructor | ||
~AsciiPointBase() {} | ||
/// Algorithm's name for identification overriding a virtual method | ||
virtual const std::string name() const = 0; | ||
/// Algorithm's version for identification overriding a virtual method | ||
virtual int version() const = 0; | ||
/// Algorithm's category for identification overriding a virtual method | ||
virtual const std::string category() const { return "DataHandling\\Text"; } | ||
|
||
private: | ||
/// Sets documentation strings for this algorithm | ||
virtual void initDocs() = 0; | ||
/// Return the file extension this algorthm should output. | ||
virtual std::string ext() = 0; | ||
/// return if the line should start with a separator | ||
virtual bool leadingSep() {return true;} | ||
/// Add extra properties | ||
virtual void extraProps() = 0; | ||
/// write any extra information required | ||
virtual void extraHeaders(std::ofstream & file) = 0; | ||
/// write the main content of the data | ||
virtual void data(std::ofstream & file, const std::vector<double> & XData); | ||
/// Overwrites Algorithm method. | ||
void init(); | ||
/// Overwrites Algorithm method | ||
void exec(); | ||
/// returns true if the value is NaN | ||
bool checkIfNan(const double& value) const; | ||
/// returns true if the value if + or - infinity | ||
bool checkIfInfinite(const double& value) const; | ||
/// print the appropriate value to file | ||
void outputval (double val, std::ofstream & file, bool leadingSep = true); | ||
/// write the top of the file | ||
virtual std::vector<double> header(std::ofstream & file); | ||
protected: | ||
/// Return the separator character | ||
virtual char sep() {return '\t';} | ||
double m_qres; | ||
size_t m_xlength; | ||
API::MatrixWorkspace_const_sptr m_ws; | ||
}; | ||
|
||
} // namespace DataHandling | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_DATAHANDLING_SAVEANSTO_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveILLCosmosAscii.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#ifndef MANTID_DATAHANDLING_SaveILLCosmosAscii_H_ | ||
#define MANTID_DATAHANDLING_SaveILLCosmosAscii_H_ | ||
|
||
//---------------------------------------------------------------------- | ||
// Includes | ||
//---------------------------------------------------------------------- | ||
#include "MantidAPI/Algorithm.h" | ||
#include "MantidAPI/MatrixWorkspace.h" | ||
#include "MantidDataHandling/AsciiPointBase.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace DataHandling | ||
{ | ||
/** | ||
Saves a file in ILL Cosmos format from a 2D workspace | ||
(Workspace2D class). SaveILLCosmosAscii is an algorithm but inherits frrm the | ||
AsciiPointBase class which provides the main implementation for the init() & exec() methods. | ||
Output is tab delimited Ascii point data with dq/q and extra header information. | ||
Copyright © 2007-14 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://github.com/mantidproject/mantid>. | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport SaveILLCosmosAscii : public DataHandling::AsciiPointBase | ||
{ | ||
public: | ||
/// Default constructor | ||
SaveILLCosmosAscii() {} | ||
/// Destructor | ||
~SaveILLCosmosAscii() {} | ||
/// Algorithm's name for identification overriding a virtual method | ||
virtual const std::string name() const { return "SaveILLCosmosAscii"; } | ||
/// Algorithm's version for identification overriding a virtual method | ||
virtual int version() const { return 1; } | ||
|
||
private: | ||
/// Sets documentation strings for this algorithm | ||
virtual void initDocs(); | ||
/// Return the file extension this algorthm should output. | ||
virtual std::string ext() {return ".mft";} | ||
///extra properties specifically for this | ||
virtual void extraProps(); | ||
/// write any extra information required | ||
virtual void extraHeaders(std::ofstream & file); | ||
}; | ||
} // namespace DataHandling | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_DATAHANDLING_SaveILLCosmosAscii_H_ */ |
Oops, something went wrong.