Skip to content

Commit

Permalink
Refs #6185 DetermineChunking for ISIS raw files
Browse files Browse the repository at this point in the history
  • Loading branch information
VickieLynch committed Dec 7, 2012
1 parent 1ded0f6 commit ec800e1
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions Code/Mantid/Framework/DataHandling/src/DetermineChunking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Workflow algorithm to determine chunking strategy.
#include "MantidDataHandling/DetermineChunking.h"
#include "MantidDataHandling/LoadPreNexus.h"
#include "MantidDataHandling/LoadEventNexus.h"
#include "LoadRaw/isisraw.h"
#include "MantidDataHandling/LoadRaw.h"
#include "MantidDataHandling/LoadRawHelper.h"
#include "MantidKernel/System.h"
#include "MantidKernel/VisibleWhenProperty.h"
#include "MantidAPI/TableRow.h"
Expand Down Expand Up @@ -117,11 +120,20 @@ namespace DataHandling
{
double maxChunk = this->getProperty("MaxChunkSize");
double filesize = 0;
int m_numberOfSpectra = 0;
string runinfo = this->getPropertyValue("Filename");
std::string ext = extension(runinfo);
Mantid::API::ITableWorkspace_sptr strategy = Mantid::API::WorkspaceFactory::Instance().createTable("TableWorkspace");
strategy->addColumn("int","ChunkNumber");
strategy->addColumn("int","TotalChunks");
if( ext.compare("xml") == 0 || runinfo.compare(runinfo.size()-10,10,"_event.nxs") == 0)
{
strategy->addColumn("int","ChunkNumber");
strategy->addColumn("int","TotalChunks");
}
else if( ext.compare("raw") == 0)
{
strategy->addColumn("int","SpectrumMin");
strategy->addColumn("int","SpectrumMax");
}
this->setProperty("OutputWorkspace", strategy);
#ifndef MPI_BUILD
// mpi needs work for every core, so don't do this
Expand All @@ -146,6 +158,7 @@ namespace DataHandling
//Event Nexus
else if( runinfo.compare(runinfo.size()-10,10,"_event.nxs") == 0)
{

// top level file information
::NeXus::File file(runinfo);
std::string m_top_entry_name = setTopEntryName(runinfo);
Expand Down Expand Up @@ -203,9 +216,25 @@ namespace DataHandling
filesize = static_cast<double>(total_events) * 48.0 / (1024.0*1024.0*1024.0);
}
//Histo Nexus
else if( ext.compare("raw") == 0)
{
// Check the size of the file loaded
Poco::File info(runinfo);
filesize = double(info.getSize())/(1024.*1024.*1024.0);
g_log.notice() << "File size is " << filesize << " GB" << std::endl;

LoadRawHelper *helper = new LoadRawHelper;
FILE* file = helper->openRawFile(runinfo);
ISISRAW iraw;
iraw.ioRAW(file, true);

// Read in the number of spectra in the RAW file
m_numberOfSpectra = iraw.t_nsp1;
g_log.notice() << "Spectra size is " << m_numberOfSpectra << " spectra" << std::endl;
}
else
{
return;
return;
}

int numChunks = static_cast<int>(filesize/maxChunk);
Expand All @@ -230,7 +259,18 @@ namespace DataHandling
}
#endif
Mantid::API::TableRow row = strategy->appendRow();
row << i << numChunks;
if( ext.compare("xml") == 0 || runinfo.compare(runinfo.size()-10,10,"_event.nxs") == 0)
{
row << i << numChunks;
}
else if( ext.compare("raw") == 0)
{
int spectraPerChunk = m_numberOfSpectra/numChunks;
int first = (i-1) * spectraPerChunk;
int last = first + spectraPerChunk - 1;
if (i == numChunks) last = m_numberOfSpectra;
row << first << last;
}
}
}
/// set the name of the top level NXentry m_top_entry_name
Expand Down

0 comments on commit ec800e1

Please sign in to comment.