Skip to content

Commit

Permalink
Error 4: from above the instrument parameter loading is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDraper committed May 28, 2015
1 parent 5ac567b commit 455e782
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp
Expand Up @@ -1771,13 +1771,18 @@ EventWorkspace_sptr LoadEventNexus::createEmptyEventWorkspace() {
file.openGroup(entry_name, "NXentry");

// get the title
try {
file.openData("title");
if (file.getInfo().type == ::NeXus::CHAR) {
string title = file.getStrData();
if (!title.empty())
WS->setTitle(title);
}
file.closeData();
} catch (std::exception&)
{
//don't set the title if the field is not loaded
}

// get the notes
try {
Expand Down
22 changes: 6 additions & 16 deletions Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp
Expand Up @@ -6,19 +6,8 @@
#include "MantidAPI/Progress.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Instrument/Component.h"
#include "MantidGeometry/Instrument/Detector.h"
#include "MantidGeometry/Instrument/ObjCompAssembly.h"
#include "MantidGeometry/Instrument/RectangularDetector.h"
#include "MantidGeometry/Objects/ShapeFactory.h"
#include "MantidGeometry/Rendering/vtkGeometryCacheReader.h"
#include "MantidGeometry/Rendering/vtkGeometryCacheWriter.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/DateAndTime.h"
#include "MantidKernel/Interpolation.h"
#include "MantidKernel/PhysicalConstants.h"
#include "MantidKernel/UnitFactory.h"

#include <Poco/DOM/DOMParser.h>
#include <Poco/DOM/Document.h>
Expand Down Expand Up @@ -272,10 +261,11 @@ void LoadInstrument::runLoadParameterFile() {
/// found, else return "".
// directoryName must include a final '/'.
std::string LoadInstrument::getFullPathParamIDF(std::string directoryName) {
Poco::Path directoryPath (directoryName);
directoryPath.makeDirectory();
// Remove the path from the filename
const std::string::size_type stripPath = m_filename.find_last_of("\\/");
std::string instrumentFile =
m_filename.substr(stripPath + 1, m_filename.size());
Poco::Path filePath (m_filename);
std::string instrumentFile = filePath.getFileName();

// First check whether there is a parameter file whose name is the same as the
// IDF file,
Expand All @@ -295,11 +285,11 @@ std::string LoadInstrument::getFullPathParamIDF(std::string directoryName) {

// Assemble parameter file name
std::string fullPathParamIDF =
directoryName + prefix + "_Parameters" + suffix;
directoryPath.setFileName(prefix + "_Parameters" + suffix).toString();
if (Poco::File(fullPathParamIDF).exists() ==
false) { // No such file exists, so look for file based on instrument ID
// given by the prefix
fullPathParamIDF = directoryName + "/" + prefix + "_Parameters.xml";
fullPathParamIDF = directoryPath.setFileName(prefix + "_Parameters.xml").toString();
}

if (Poco::File(fullPathParamIDF).exists() ==
Expand Down
13 changes: 5 additions & 8 deletions Code/Mantid/Framework/DataHandling/src/LoadParameterFile.cpp
Expand Up @@ -2,14 +2,10 @@
// Includes
//----------------------------------------------------------------------
#include "MantidDataHandling/LoadParameterFile.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidGeometry/Instrument.h"
#include "MantidAPI/InstrumentDataService.h"
#include "MantidGeometry/Instrument/Detector.h"
#include "MantidGeometry/Instrument/Component.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/FileProperty.h"
#include "MantidKernel/ArrayProperty.h"

#include <Poco/DOM/DOMParser.h>
#include <Poco/DOM/Document.h>
Expand All @@ -19,7 +15,6 @@
#include <Poco/DOM/NodeFilter.h>
#include <Poco/DOM/AutoPtr.h>
#include <Poco/File.h>
#include <sstream>
#include "MantidGeometry/Instrument/InstrumentDefinitionParser.h"

using Poco::XML::DOMParser;
Expand Down Expand Up @@ -118,9 +113,11 @@ void LoadParameterFile::exec() {
// First see if the file exists
Poco::File ipfFile(filename);
if(!ipfFile.exists()) {
std::string directoryName =
Kernel::ConfigService::Instance().getInstrumentDirectory();
filename = directoryName + "/" + filename;
Poco::Path filePath(filename);
filename = Poco::Path(Kernel::ConfigService::Instance().getInstrumentDirectory())
.makeDirectory().
setFileName(filePath.getFileName()).
toString();
}
g_log.information() << "Parsing from XML file: " << filename
<< std::endl;
Expand Down

0 comments on commit 455e782

Please sign in to comment.