diff --git a/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp b/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp index 671b86e5936591976e186d56f54a073c3d9ee7f5..f07c8ddb494b6213d168b08d29796ab6b80d74fd 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp @@ -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"; diff --git a/Code/Mantid/Framework/DataHandling/src/LoadNexusLogs.cpp b/Code/Mantid/Framework/DataHandling/src/LoadNexusLogs.cpp index a0b0ba440cbafe5b9b5487597a6f0aec518c3313..8309816eda93cb15966bd9852189765b6f26f7a3 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadNexusLogs.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadNexusLogs.cpp @@ -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); }