Skip to content
Snippets Groups Projects
Commit 339a91ae authored by Freddie Akeroyd's avatar Freddie Akeroyd
Browse files

- Load ISIS frame by frame proton log and adjust for array length difference...

- Load ISIS frame by frame proton log and adjust for array length difference between this and event_index array
- Increase log level from debug to warning for message about event/proton array length mismatch 
Refs #3952
parent aff08d19
No related branches found
No related tags found
No related merge requests found
......@@ -352,7 +352,7 @@ public:
if (event_index.size() != alg->pulseTimes.size())
{
alg->getLogger().debug() << "Bank " << entry_name << " has a mismatch between the number of event_index entries and the number of pulse times.\n";
alg->getLogger().warning() << "Bank " << entry_name << " has a mismatch between the number of event_index entries and the number of pulse times.\n";
}
if (!loadError)
......@@ -1266,20 +1266,60 @@ bool LoadEventNexus::runLoadNexusLogs(const std::string &nexusfilename, API::Mat
loadLogs->setPropertyValue("Filename", nexusfilename);
loadLogs->setProperty<MatrixWorkspace_sptr> ("Workspace", localWorkspace);
loadLogs->execute();
//If successful, we can try to load the pulse times
Kernel::TimeSeriesProperty<double> * log = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( localWorkspace->mutableRun().getProperty("proton_charge") );
Kernel::TimeSeriesProperty<double> * log = 0;
// Freddie Akeroyd 11/10/2011
// current ISIS implementation contains an additional indirection between collected frames via an
// "event_frame_number" array in NXevent_data (which eliminates frames with no events).
// the proton_log is for all frames and so is longer than the event_index array, so we need to
// filter the proton_charge log based on event_frame_number
// This difference will be removed in future for compatibility with SNS, but the code below will allow current SANS2D files to load
std::vector<int> event_frame_number;
if (localWorkspace->mutableRun().hasProperty("proton_log"))
{
log = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( localWorkspace->mutableRun().getProperty("proton_log") );
alg->getLogger().information() << "Using old ISIS proton_log and event_frame_number indirection..." << endl;
::NeXus::File file(nexusfilename);
try
{
file.openPath("/raw_data_1/detector_1_events/event_frame_number");
file.getData(event_frame_number);
}
catch(const ::NeXus::Exception& exc)
{
alg->getLogger().error() << "Unable to load event_frame_number: " << exc.what() << endl;
}
file.close();
}
else
{
log = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( localWorkspace->mutableRun().getProperty("proton_charge") );
}
std::vector<Kernel::DateAndTime> temp = log->timesAsVector();
pulseTimes.reserve(temp.size());
// Warn if the pulse time found is below a minimum
size_t numBadTimes = 0;
Kernel::DateAndTime minDate("1991-01-01");
for (size_t i =0; i < temp.size(); i++)
{
pulseTimes.push_back( temp[i] );
if (temp[i] < minDate)
numBadTimes++;
}
if (event_frame_number.size() > 0) // ISIS indirection - see above comments
{
Mantid::Kernel::DateAndTime tval;
for (size_t i =0; i < event_frame_number.size(); i++)
{
tval = temp[ event_frame_number[i] ];
pulseTimes.push_back( tval );
if (tval < minDate)
numBadTimes++;
}
}
else
{
for (size_t i =0; i < temp.size(); i++)
{
pulseTimes.push_back( temp[i] );
if (temp[i] < minDate)
numBadTimes++;
}
}
if (numBadTimes > 0)
alg->getLogger().warning() << "Found " << numBadTimes << " entries in the proton_charge sample log with invalid pulse time!\n";
......
......@@ -90,7 +90,7 @@ namespace Mantid
std::string group_name(it->first);
std::string group_class(it->second);
if( group_name == "DASlogs" || group_class == "IXrunlog" ||
group_class == "IXselog" )
group_class == "IXselog" || group_name == "framelog" )
{
loadLogs(file, group_name, group_class, workspace);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment