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/8365_ILL_D2B'
- Loading branch information
Showing
13 changed files
with
13,018 additions
and
1 deletion.
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
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
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
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
72 changes: 72 additions & 0 deletions
72
Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadILLAscii.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,72 @@ | ||
#ifndef MANTID_MDALGORITHMS_LOADILLASCII_H_ | ||
#define MANTID_MDALGORITHMS_LOADILLASCII_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/Algorithm.h" | ||
|
||
#include "MantidMDAlgorithms/LoadILLAsciiHelper.h" | ||
#include "MantidAPI/IFileLoader.h" | ||
#include "MantidAPI/IMDEventWorkspace.h" | ||
|
||
namespace Mantid { | ||
namespace MDAlgorithms { | ||
|
||
/** LoadILLAscii : | ||
This loader loads ILL data in Ascii format. | ||
For more details on data format, please see: | ||
<http://www.ill.eu/instruments-support/computing-for-science/data-analysis/raw-data/> | ||
Copyright © 2013 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 LoadILLAscii: public API::IFileLoader<Kernel::FileDescriptor> { | ||
public: | ||
LoadILLAscii(); | ||
virtual ~LoadILLAscii(); | ||
|
||
virtual const std::string name() const; | ||
virtual int version() const; | ||
virtual const std::string category() const; | ||
virtual const std::string summary() const; | ||
/// Returns a confidence value that this algorithm can load a file | ||
virtual int confidence(Kernel::FileDescriptor & descriptor) const; | ||
|
||
|
||
private: | ||
void init(); | ||
void exec(); | ||
void loadInstrumentName(ILLParser &); | ||
void loadExperimentDetails(ILLParser &p); | ||
void loadIDF(API::MatrixWorkspace_sptr &workspace); | ||
void loadsDataIntoTheWS(API::MatrixWorkspace_sptr &, const std::vector<int> &); | ||
API::IMDEventWorkspace_sptr mergeWorkspaces(std::vector<API::MatrixWorkspace_sptr> &); | ||
void setWorkspaceRotationAngle(API::MatrixWorkspace_sptr, double rotationAngle); | ||
|
||
//LoadHelper m_loader; | ||
std::string m_instrumentName; ///< Name of the instrument | ||
double m_wavelength; | ||
std::vector<std::string> m_supportedInstruments; | ||
}; | ||
|
||
} // namespace MDAlgorithms | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_MDALGORITHMS_LOADILLASCII_H_ */ |
90 changes: 90 additions & 0 deletions
90
Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadILLAsciiHelper.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_MDALGORITHMS_LOADILLASCIIHELPER_H_ | ||
#define MANTID_MDALGORITHMS_LOADILLASCIIHELPER_H_ | ||
|
||
#include "MantidMDAlgorithms/DllConfig.h" | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include <vector> | ||
#include <string> | ||
#include <map> | ||
|
||
namespace Mantid { | ||
namespace MDAlgorithms { | ||
|
||
/** LoadILLAsciiHelper : | ||
This parses ILL data in Ascii format. | ||
For more details on data format, please see: | ||
<http://www.ill.eu/instruments-support/computing-for-science/data-analysis/raw-data/> | ||
Copyright © 2013 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 ILLParser { | ||
public: | ||
ILLParser(const std::string &filename); | ||
virtual ~ILLParser(); | ||
void parse(); | ||
void showHeader(); | ||
std::string getInstrumentName(); | ||
|
||
// Those are large vectors: returning references => no copy constructors | ||
// std::vector< std::vector<int> > & getSpectraList() {return spectraList;} | ||
// std::vector<std::map<std::string, std::string> > & getSpectraHeaderList() {return spectraHeaders;} | ||
// No difference in running times :( | ||
|
||
std::vector< std::vector<int> > getSpectraList() const {return spectraList;} | ||
std::vector<std::map<std::string, std::string> > getSpectraHeaderList() const {return spectraHeaders;} | ||
|
||
template<typename T> T getValueFromHeader(const std::string &); | ||
template<typename T> T getValue(const std::string &, const std::map<std::string, std::string> &); | ||
private: | ||
void parseFieldR(); | ||
void parseFieldA(); | ||
void parseFieldNumeric(std::map<std::string, std::string> &header, | ||
int fieldWith); | ||
std::vector<int> parseFieldISpec(int fieldWith = intWith); | ||
|
||
void startParseSpectra(); | ||
std::vector<std::string> splitLineInFixedWithFields(const std::string &s, | ||
int fieldWidth, int lineWitdh = lineWith); | ||
|
||
template<typename T> T evaluate(std::string field); | ||
|
||
static const int lineWith = 80; | ||
static const int intWith = 8; | ||
static const int floatWith = 16; | ||
|
||
std::ifstream fin; | ||
// Not great, but to date there's 3 containers: | ||
std::map<std::string, std::string> header; // file global header | ||
std::vector<std::map<std::string, std::string> > spectraHeaders; // list with every spectrum header | ||
std::vector<std::vector<int> > spectraList; // same size list but with spectra contents | ||
|
||
}; | ||
|
||
} | ||
// namespace MDAlgorithms | ||
}// namespace Mantid | ||
|
||
#endif /* MANTID_MDALGORITHMS_LOADILLASCIIHELPER_H_ */ |
Oops, something went wrong.