Skip to content

Commit

Permalink
UpdateInstrumentFromFile now accepts ISIS Event Nexus files.
Browse files Browse the repository at this point in the history
Refs #8057
  • Loading branch information
martyngigg committed Oct 7, 2013
1 parent 43fb1b8 commit 6ca216a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include <nexus/NeXusFile.hpp>

namespace Mantid
{
Expand Down Expand Up @@ -85,7 +86,7 @@ namespace Mantid
/// Assumes the file is a raw file
void updateFromRaw(const std::string & filename);
/// Assumes the file is an ISIS NeXus file
void updateFromNeXus(const std::string & filename);
void updateFromNeXus(::NeXus::File & nxFile);
/// Updates from a more generic ascii file
void updateFromAscii(const std::string & filename);

Expand Down
39 changes: 13 additions & 26 deletions Code/Mantid/Framework/DataHandling/src/UpdateInstrumentFromFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ would tell the algorithm to interpret the columns as:
//----------------------------------------------------------------------
#include "MantidDataHandling/UpdateInstrumentFromFile.h"
#include "MantidDataHandling/LoadAscii.h"
#include "MantidDataHandling/LoadEventNexus.h"
#include "MantidDataHandling/LoadISISNexus2.h"
#include "MantidDataHandling/LoadRawHelper.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Instrument/ComponentHelper.h"
#include "MantidKernel/NexusDescriptor.h"
#include <nexus/NeXusFile.hpp>
#include <nexus/NeXusException.hpp>
#include "LoadRaw/isisraw2.h"

#include <boost/scoped_ptr.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <nexus/NeXusException.hpp>
#include <Poco/StringTokenizer.h>

#include <fstream>
Expand Down Expand Up @@ -136,11 +136,14 @@ namespace Mantid
if(NexusDescriptor::isHDF(filename))
{
LoadISISNexus2 isisNexus;
auto *descriptor = new Kernel::NexusDescriptor(filename);
if(isisNexus.confidence(*descriptor) > 0)
LoadEventNexus eventNexus;
boost::scoped_ptr<Kernel::NexusDescriptor> descriptor(new Kernel::NexusDescriptor(filename));
if(isisNexus.confidence(*descriptor) > 0 || eventNexus.confidence(*descriptor) > 0)
{
delete descriptor;
updateFromNeXus(filename);
auto & nxFile = descriptor->data();
const auto & rootEntry = descriptor->firstEntryNameType();
nxFile.openGroup(rootEntry.first, rootEntry.second);
updateFromNeXus(nxFile);
return;
}
}
Expand Down Expand Up @@ -207,33 +210,17 @@ namespace Mantid

/**
* Update the detector information from a NeXus file
* @param filename :: The input filename
* @param nxFile :: Handle to a NeXus file where the root group has been opened
*/
void UpdateInstrumentFromFile::updateFromNeXus(const std::string & filename)
void UpdateInstrumentFromFile::updateFromNeXus(::NeXus::File & nxFile)
{
try
{
::NeXus::File file(filename);
}
catch(::NeXus::Exception&)
{
throw std::runtime_error("Input file does not look like an ISIS NeXus file.");
}
::NeXus::File nxFile(filename);
try
{
nxFile.openPath("raw_data_1/isis_vms_compat");
nxFile.openGroup("isis_vms_compat","IXvms");
}
catch(::NeXus::Exception&)
{
try
{
nxFile.openPath("entry/isis_vms_compat"); // Could be original event file.
}
catch(::NeXus::Exception&)
{
throw std::runtime_error("Unknown NeXus flavour. Cannot update instrument positions.");
}
throw std::runtime_error("Unknown NeXus flavour. Cannot update instrument positions using this type of file");
}
// Det ID
std::vector<int32_t> detID;
Expand Down

0 comments on commit 6ca216a

Please sign in to comment.