Skip to content

Commit

Permalink
Refs #10061 changes for IDF and improved loader speed
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRHill committed Aug 29, 2014
1 parent cf334a9 commit 67348e4
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 157 deletions.
Expand Up @@ -43,8 +43,8 @@ namespace Mantid
Load();
/// Algorithm's name for identification overriding a virtual method
virtual const std::string name() const { return "Load"; }
///Summary of algorithms purpose
virtual const std::string summary() const {return "Attempts to load a given file by finding an appropriate Load algorithm.";}
///Summary of algorithms purpose
virtual const std::string summary() const {return "Attempts to load a given file by finding an appropriate Load algorithm.";}

/// Algorithm's version for identification overriding a virtual method
virtual int version() const { return 1; }
Expand Down
Expand Up @@ -79,39 +79,15 @@ namespace DataHandling

/// Parses the header values for the FITS file
bool parseHeader(FITSInfo &headerInfo);
void loadSingleBinFromFile(Mantid::API::MatrixWorkspace_sptr &workspace, FITSInfo &fitsInfo, MantidVecPtr &x, long spetraCount, long binIndex);
void loadChunkOfBinsFromFile(Mantid::API::MatrixWorkspace_sptr &workspace, vector<vector<double> > &yVals, vector<vector<double> > &eVals, void *&bufferAny, MantidVecPtr &x, long spetraCount, int bitsPerPixel, long binChunkStartIndex);

API::MatrixWorkspace_sptr initAndPopulateHistogramWorkspace();

vector<FITSInfo> m_allHeaderInfo;

///// Implement abstract Algorithm methods
//void init();
///// Implement abstract Algorithm methods
//void exec();

///// Load file to a vector of strings
//void loadFile(std::string filename, std::vector<std::string>& lines);

///// Get Histogram type
//std::string getHistogramType(const std::vector<std::string>& lines);

///// Get Number of banks
//size_t getNumberOfBanks(const std::vector<std::string>& lines);

///// Scan imported file for bank information
//void scanBanks(const std::vector<std::string>& lines, std::vector<size_t>& bankStartIndex );

///// Parse bank in file to a map
//void parseBank(std::map<std::string, double>& parammap, const std::vector<std::string>& lines, size_t bankid, size_t startlineindex, int nProf);

///// Find first INS line at or after lineIndex
//size_t findINSLine(const std::vector<std::string>& lines, size_t lineIndex);

///// Generate output workspace
//DataObjects::TableWorkspace_sptr genTableWorkspace(std::map<size_t, std::map<std::string, double> > bankparammap);


int m_binChunkSize;
static const int FIXED_HEADER_SIZE = 2880;

};


Expand Down
24 changes: 18 additions & 6 deletions Code/Mantid/Framework/DataHandling/src/Load.cpp
Expand Up @@ -170,12 +170,24 @@ namespace Mantid
// ... store it's name and version and check that all other files have loaders with the same name and version.
std::string name = loader->name();
int version = loader->version();
std::string ext = fileNames[0].substr(fileNames[0].find_last_of("."));
for(size_t i = 1; i < fileNames.size(); ++i)
{
loader = getFileLoader(fileNames[i]);

if( name != loader->name() || version != loader->version() )
throw std::runtime_error("Cannot load multiple files when more than one Loader is needed.");
// If it's loading into a single file, perform a cursory check on file extensions only.
if(dynamic_cast<MultipleFileProperty*>(loader->getPointerToProperty("Filename")) != NULL)
{
if( fileNames[i].substr(fileNames[i].find_last_of(".")) != ext)
{
throw std::runtime_error("Cannot load multiple files when more than one Loader is needed.");
}
}
else
{
loader = getFileLoader(fileNames[i]);

if( name != loader->name() || version != loader->version() )
throw std::runtime_error("Cannot load multiple files when more than one Loader is needed.");
}
}
}

Expand Down Expand Up @@ -331,7 +343,7 @@ namespace Mantid
* Executes the algorithm.
*/
void Load::exec()
{
{
std::vector<std::vector<std::string> > fileNames = getProperty("Filename");

// Test for loading as a single file
Expand All @@ -351,7 +363,7 @@ namespace Mantid
}

void Load::loadSingleFile()
{
{
std::string loaderName = getPropertyValue("LoaderName");
if( loaderName.empty() )
{
Expand Down

0 comments on commit 67348e4

Please sign in to comment.