diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h b/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h index bd0d1c05f9db5909c349602531b1906c8c231ab2..22b9f68afefa34157162cdcc15d087f7dbd4a959 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h @@ -118,9 +118,9 @@ public: /// Saves this experiment description to the open NeXus file virtual void saveExperimentInfoNexus(::NeXus::File *file) const; /// Loads an experiment description from the open NeXus file - virtual void loadExperimentInfoNexus(::NeXus::File *file, std::string ¶meterStr); + virtual void loadExperimentInfoNexus(const std::string& nxFilename, ::NeXus::File *file, std::string ¶meterStr); /// Load the instrument from an open NeXus file. - virtual void loadInstrumentInfoNexus(::NeXus::File *file, std::string ¶meterStr); + virtual void loadInstrumentInfoNexus(const std::string& nxFilename, ::NeXus::File *file, std::string ¶meterStr); /// Load the sample and log info from an open NeXus file. virtual void loadSampleAndLogInfoNexus(::NeXus::File *file); diff --git a/Code/Mantid/Framework/API/src/ExperimentInfo.cpp b/Code/Mantid/Framework/API/src/ExperimentInfo.cpp index a2d400489c0e36fff4d403caa67e890700b75ce1..ee9718586f73035400ca08ab598c2f7b27f91da9 100644 --- a/Code/Mantid/Framework/API/src/ExperimentInfo.cpp +++ b/Code/Mantid/Framework/API/src/ExperimentInfo.cpp @@ -15,7 +15,6 @@ #include "MantidKernel/InstrumentInfo.h" #include "MantidKernel/Property.h" #include "MantidKernel/Strings.h" -#include "MantidKernel/TimeSeriesProperty.h" #include <boost/algorithm/string.hpp> #include <boost/make_shared.hpp> @@ -928,6 +927,7 @@ void ExperimentInfo::loadSampleAndLogInfoNexus(::NeXus::File *file) { //-------------------------------------------------------------------------------------------- /** Load the object from an open NeXus file. * @param file :: open NeXus file + * @param nxFilename :: the filename of the nexus file * @param[out] parameterStr :: special string for all the parameters. * Feed that to ExperimentInfo::readParameterMap() after the * instrument is done. @@ -935,17 +935,19 @@ void ExperimentInfo::loadSampleAndLogInfoNexus(::NeXus::File *file) { * file and cannot * be loaded from the IDF. */ -void ExperimentInfo::loadExperimentInfoNexus(::NeXus::File *file, +void ExperimentInfo::loadExperimentInfoNexus(const std::string& nxFilename, + ::NeXus::File *file, std::string ¶meterStr) { // load sample and log info loadSampleAndLogInfoNexus(file); - loadInstrumentInfoNexus(file, parameterStr); + loadInstrumentInfoNexus(nxFilename, file, parameterStr); } //-------------------------------------------------------------------------------------------- /** Load the instrument from an open NeXus file. * @param file :: open NeXus file + * @param nxFilename :: the filename of the nexus file * @param[out] parameterStr :: special string for all the parameters. * Feed that to ExperimentInfo::readParameterMap() after the * instrument is done. @@ -953,7 +955,8 @@ void ExperimentInfo::loadExperimentInfoNexus(::NeXus::File *file, * file and cannot * be loaded from the IDF. */ -void ExperimentInfo::loadInstrumentInfoNexus(::NeXus::File *file, +void ExperimentInfo::loadInstrumentInfoNexus(const std::string& nxFilename, + ::NeXus::File *file, std::string ¶meterStr) { std::string instrumentName; std::string instrumentXml; @@ -1003,13 +1006,13 @@ void ExperimentInfo::loadInstrumentInfoNexus(::NeXus::File *file, file->closeGroup(); } - instrumentFilename = Strings::strip(instrumentFilename); + instrumentFilename = Strings::strip(instrumentFilename);; instrumentXml = Strings::strip(instrumentXml); instrumentName = Strings::strip(instrumentName); if (!instrumentXml.empty()) { // instrument xml is being loaded from the nxs file, set the instrumentFilename // to identify the Nexus file as the source of the data - instrumentFilename = instrumentFilename; + instrumentFilename = nxFilename; g_log.debug() << "Using instrument IDF XML text contained in nexus file.\n"; } else diff --git a/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp b/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp index 64c7084fdff37c1b41c4e4124fcab7beb547f22c..46b48f0cba02e8e08486229cc75498545c1910ba 100644 --- a/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp +++ b/Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp @@ -301,7 +301,7 @@ void FileBackedExperimentInfo::populateFromFile() const { std::string parameterStr; const_cast<FileBackedExperimentInfo *>(this) - ->loadExperimentInfoNexus(&nxFile, parameterStr); + ->loadExperimentInfoNexus(m_filename, &nxFile, parameterStr); const_cast<FileBackedExperimentInfo *>(this) ->readParameterMap(parameterStr); } catch (::NeXus::Exception &exc) { diff --git a/Code/Mantid/Framework/API/test/ExperimentInfoTest.h b/Code/Mantid/Framework/API/test/ExperimentInfoTest.h index 80592866959a9ed7142e8d5f8469e93453cbae2d..54dff4064b7223b044dc4b640227e2cc5db690d9 100644 --- a/Code/Mantid/Framework/API/test/ExperimentInfoTest.h +++ b/Code/Mantid/Framework/API/test/ExperimentInfoTest.h @@ -18,8 +18,6 @@ #include <boost/regex.hpp> #include <Poco/DirectoryIterator.h> -#include <iomanip> -#include <iostream> #include <set> using namespace Mantid::API; @@ -593,22 +591,23 @@ public: void test_nexus() { + std::string filename = "ExperimentInfoTest1.nxs"; NexusTestHelper th(true); - th.createFile("ExperimentInfoTest1.nxs"); + th.createFile(filename); ExperimentInfo ws; boost::shared_ptr<Instrument> inst1(new Instrument()); inst1->setName("GEM"); inst1->setFilename("GEM_Definition.xml"); inst1->setXmlText(""); ws.setInstrument(inst1); - + TS_ASSERT_THROWS_NOTHING( ws.saveExperimentInfoNexus(th.file); ); // ------------------------ Re-load the contents ---------------------- ExperimentInfo ws2; std::string parameterStr; th.reopenFile(); - TS_ASSERT_THROWS_NOTHING( ws2.loadExperimentInfoNexus(th.file, parameterStr) ); + TS_ASSERT_THROWS_NOTHING( ws2.loadExperimentInfoNexus(filename, th.file, parameterStr) ); Instrument_const_sptr inst = ws2.getInstrument(); TS_ASSERT_EQUALS( inst->getName(), "GEM" ); TS_ASSERT( inst->getFilename().find("GEM_Definition.xml",0) != std::string::npos ); @@ -618,8 +617,9 @@ public: void test_nexus_empty_instrument() { + std::string filename = "ExperimentInfoTest2.nxs"; NexusTestHelper th(true); - th.createFile("ExperimentInfoTest2.nxs"); + th.createFile(filename); ExperimentInfo ws; boost::shared_ptr<Instrument> inst1(new Instrument()); inst1->setName(""); @@ -633,7 +633,7 @@ public: ExperimentInfo ws2; std::string parameterStr; th.reopenFile(); - TS_ASSERT_THROWS_NOTHING( ws2.loadExperimentInfoNexus(th.file, parameterStr) ); + TS_ASSERT_THROWS_NOTHING( ws2.loadExperimentInfoNexus(filename, th.file, parameterStr) ); Instrument_const_sptr inst = ws2.getInstrument(); TS_ASSERT_EQUALS( inst->getName(), "" ); TS_ASSERT_EQUALS( parameterStr, "" ); @@ -641,8 +641,9 @@ public: void testNexus_W_matrix() { + std::string filename = "ExperimentInfoWMatrixTest.nxs"; NexusTestHelper th(true); - th.createFile("ExperimentInfoWMatrixTest.nxs"); + th.createFile(filename); ExperimentInfo ei; DblMatrix WTransf(3,3,true); @@ -665,7 +666,7 @@ public: ExperimentInfo other; std::string InstrParameters; - TS_ASSERT_THROWS_NOTHING(other.loadExperimentInfoNexus(th.file,InstrParameters)); + TS_ASSERT_THROWS_NOTHING(other.loadExperimentInfoNexus(filename, th.file,InstrParameters)); std::vector<double> wMatrRestored=other.run().getPropertyValueAsType<std::vector<double> >("W_MATRIX"); diff --git a/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h b/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h index f3fa9eb6c621e80188e7144bc58e139e45c4ca73..2f367c924d47fd0958a1589a8fdef79eaf88252e 100644 --- a/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h +++ b/Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h @@ -36,7 +36,7 @@ public: ::NeXus::File nxFile(m_filename, NXACC_READ); nxFile.openGroup("mantid_workspace_1", "NXentry"); std::string paramString; - m_inMemoryExptInfo->loadExperimentInfoNexus(&nxFile, paramString); + m_inMemoryExptInfo->loadExperimentInfoNexus(m_filename, &nxFile, paramString); m_inMemoryExptInfo->readParameterMap(paramString); } @@ -56,8 +56,6 @@ public: void test_getInstrument_populates_object() { auto fileBacked = createTestObject(); - auto fileBackedInstrument = fileBacked->getInstrument(); - auto inMemoryInstrument = m_inMemoryExptInfo->getInstrument(); TS_ASSERT_EQUALS(fileBacked->constInstrumentParameters(), m_inMemoryExptInfo->constInstrumentParameters()); diff --git a/Code/Mantid/Framework/Algorithms/src/CreateDummyCalFile.cpp b/Code/Mantid/Framework/Algorithms/src/CreateDummyCalFile.cpp index 7491718576509b60a3742f61d8548bda9ef2db9e..a52545be04793cc493f1956e208fc781fe2ac4ea 100644 --- a/Code/Mantid/Framework/Algorithms/src/CreateDummyCalFile.cpp +++ b/Code/Mantid/Framework/Algorithms/src/CreateDummyCalFile.cpp @@ -14,8 +14,6 @@ #include <Poco/DOM/DOMParser.h> #include <Poco/DOM/Document.h> #include <Poco/DOM/Element.h> -#include <Poco/File.h> -#include <Poco/Path.h> #include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/detail/classification.hpp> diff --git a/Code/Mantid/Framework/DataHandling/src/LoadEmptyInstrument.cpp b/Code/Mantid/Framework/DataHandling/src/LoadEmptyInstrument.cpp index dd0048791d0efa70b282b0b1e544fd724a4c9d0e..ea0be927b4d5f7d745f6bb8e49a8ccf5e5e98af3 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadEmptyInstrument.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadEmptyInstrument.cpp @@ -5,8 +5,6 @@ #include "MantidKernel/ConfigService.h" #include "MantidKernel/BoundedValidator.h" #include "MantidAPI/RegisterFileLoader.h" -#include <cmath> -#include <Poco/Path.h> namespace Mantid { namespace DataHandling { diff --git a/Code/Mantid/Framework/DataHandling/src/LoadIDFFromNexus.cpp b/Code/Mantid/Framework/DataHandling/src/LoadIDFFromNexus.cpp index 41c64c2b9c1bbcf42a30856f036109112ea06364..de2bebdd7de7dc3b6a52a9ac489acb88e924c672 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadIDFFromNexus.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadIDFFromNexus.cpp @@ -67,7 +67,7 @@ void LoadIDFFromNexus::exec() { // If the nexus file also contains a instrument parameter map entry this // is returned as parameterString std::string parameterString; - localWorkspace->loadInstrumentInfoNexus(&nxfile, parameterString); + localWorkspace->loadInstrumentInfoNexus(filename, &nxfile, parameterString); // at present loadInstrumentInfoNexus does not populate any instrument params // into the workspace including those that are defined in the IDF. // Here populate inst params defined in IDF diff --git a/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp index 59d6ac822dc772466242b18abfd9bbaa39ca4a70..bea9fc8087661e912bf297ce805452e8f79602fb 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -15,8 +15,8 @@ #include "MantidDataObjects/PeaksWorkspace.h" #include "MantidDataObjects/PeakNoShapeFactory.h" #include "MantidDataObjects/PeakShapeSphericalFactory.h" +#include "MantidDataObjects/PeakShapeEllipsoidFactory.h" #include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/ConfigService.h" #include "MantidKernel/DateAndTime.h" #include "MantidKernel/UnitFactory.h" #include "MantidKernel/BoundedValidator.h" @@ -28,14 +28,8 @@ #include <boost/regex.hpp> #include <boost/lexical_cast.hpp> #include <boost/shared_array.hpp> -#include <cmath> -#include <Poco/Path.h> + #include <Poco/StringTokenizer.h> -#include "MantidDataObjects/PeaksWorkspace.h" -#include "MantidKernel/MultiThreaded.h" -#include "MantidDataObjects/PeakNoShapeFactory.h" -#include "MantidDataObjects/PeakShapeSphericalFactory.h" -#include "MantidDataObjects/PeakShapeEllipsoidFactory.h" #include <nexus/NeXusException.hpp> @@ -1033,7 +1027,7 @@ API::Workspace_sptr LoadNexusProcessed::loadPeaksEntry(NXEntry &entry) { m_cppFile->openPath(entry.path()); // This is try { // This loads logs, sample, and instrument. - peakWS->loadExperimentInfoNexus(m_cppFile, parameterStr); + peakWS->loadExperimentInfoNexus(getPropertyValue("Filename"), m_cppFile, parameterStr); } catch (std::exception &e) { g_log.information("Error loading Instrument section of nxs file"); g_log.information(e.what()); @@ -1557,7 +1551,7 @@ API::Workspace_sptr LoadNexusProcessed::loadEntry(NXRoot &root, m_cppFile->openPath(mtd_entry.path()); try { // This loads logs, sample, and instrument. - local_workspace->loadExperimentInfoNexus( + local_workspace->loadExperimentInfoNexus(getPropertyValue("Filename"), m_cppFile, parameterStr); // REQUIRED PER PERIOD } catch (std::exception &e) { g_log.information("Error loading Instrument section of nxs file"); diff --git a/Code/Mantid/Framework/DataHandling/src/SaveNexusProcessed.cpp b/Code/Mantid/Framework/DataHandling/src/SaveNexusProcessed.cpp index 7f0833ecbf64939ceacdca1f557b728e71a76248..920cb2deb2f81f210d7581fab30866479222f51a 100644 --- a/Code/Mantid/Framework/DataHandling/src/SaveNexusProcessed.cpp +++ b/Code/Mantid/Framework/DataHandling/src/SaveNexusProcessed.cpp @@ -10,15 +10,12 @@ #include "MantidDataObjects/PeaksWorkspace.h" #include "MantidDataObjects/OffsetsWorkspace.h" #include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/ConfigService.h" #include "MantidKernel/BoundedValidator.h" #include "MantidNexus/NexusFileIO.h" #include <nexus/NeXusFile.hpp> #include <boost/regex.hpp> #include <boost/shared_ptr.hpp> -#include <cmath> #include <Poco/File.h> -#include <Poco/Path.h> using namespace Mantid::API; diff --git a/Code/Mantid/Framework/DataHandling/test/LoadEventNexusTest.h b/Code/Mantid/Framework/DataHandling/test/LoadEventNexusTest.h index b5dccfdd468c05919e5309f708036fff3c7458e8..d90f01212397d7864147f3c26b4ca20590500098 100644 --- a/Code/Mantid/Framework/DataHandling/test/LoadEventNexusTest.h +++ b/Code/Mantid/Framework/DataHandling/test/LoadEventNexusTest.h @@ -490,7 +490,6 @@ public: auto ws = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(outws); auto inst = ws->getInstrument(); - TS_ASSERT( inst->getFilename().empty() ); // This is how we know we got it from inside the nexus file TS_ASSERT_EQUALS( inst->getName(), "HYSPECA" ); TS_ASSERT_EQUALS( inst->getValidFromDate(), std::string("2011-Jul-20 17:02:48.437294000") ); TS_ASSERT_EQUALS( inst->getNumberDetectors(), 20483 ); diff --git a/Code/Mantid/Framework/DataObjects/src/MDBoxFlatTree.cpp b/Code/Mantid/Framework/DataObjects/src/MDBoxFlatTree.cpp index 4bbb537e1cd78f44d495132e0aac1a576c5cdef9..19117d593b5817e345a0a7107f260db74161a485 100644 --- a/Code/Mantid/Framework/DataObjects/src/MDBoxFlatTree.cpp +++ b/Code/Mantid/Framework/DataObjects/src/MDBoxFlatTree.cpp @@ -1,7 +1,5 @@ #include "MantidKernel/Strings.h" #include "MantidDataObjects/MDBoxFlatTree.h" -#include "MantidDataObjects/MDEvent.h" -#include "MantidDataObjects/MDLeanEvent.h" #include "MantidAPI/BoxController.h" #include "MantidAPI/FileBackedExperimentInfo.h" #include "MantidDataObjects/MDEventFactory.h" @@ -461,7 +459,7 @@ void MDBoxFlatTree::loadExperimentInfos(::NeXus::File *const file, const std::st std::string parameterStr; try { // Get the sample, logs, instrument - ei->loadExperimentInfoNexus(file, parameterStr); + ei->loadExperimentInfoNexus(filename, file, parameterStr); // Now do the parameter map ei->readParameterMap(parameterStr); // And add it to the mutliple experiment info. diff --git a/Code/Mantid/Framework/Geometry/src/Instrument.cpp b/Code/Mantid/Framework/Geometry/src/Instrument.cpp index 368d093b6b600577b98a9e57c1c832ccdb803718..5607adc721d52e0e9b93863c92a1e10b828ba0d9 100644 --- a/Code/Mantid/Framework/Geometry/src/Instrument.cpp +++ b/Code/Mantid/Framework/Geometry/src/Instrument.cpp @@ -4,7 +4,6 @@ #include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidGeometry/Instrument/RectangularDetector.h" -#include <Poco/Path.h> #include <queue> using namespace Mantid::Kernel; @@ -1071,8 +1070,6 @@ void Instrument::saveNexus(::NeXus::File *file, file->writeData("description", "XML contents of the instrument IDF file."); file->closeGroup(); - file->writeData("instrument_source", Poco::Path(getFilename()).getFileName()); - // Now the parameter map, as a NXnote via its saveNexus method if (isParametrized()) { const Geometry::ParameterMap ¶ms = *getParameterMap(); diff --git a/Code/Mantid/Framework/Geometry/src/Instrument/IDFObject.cpp b/Code/Mantid/Framework/Geometry/src/Instrument/IDFObject.cpp index 150a84be6b9cecddb2c8a9c671aa27360b417506..b12a725e8612fab46392aed42cf3378335dd75d7 100644 --- a/Code/Mantid/Framework/Geometry/src/Instrument/IDFObject.cpp +++ b/Code/Mantid/Framework/Geometry/src/Instrument/IDFObject.cpp @@ -1,6 +1,5 @@ #include "MantidGeometry/Instrument/IDFObject.h" #include "MantidKernel/ChecksumHelper.h" -#include <Poco/DateTimeFormatter.h> #include <Poco/String.h> namespace Mantid {