From 476f03f4e8d9e2c958d6bbcd6e61ca1fd6467a05 Mon Sep 17 00:00:00 2001 From: Karl Palmen <karl.palmen@stfc.ac.uk> Date: Wed, 24 Jun 2015 16:33:10 +0100 Subject: [PATCH] Separate parameter loading re #12924 Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk> --- .../API/inc/MantidAPI/ExperimentInfo.h | 2 ++ .../Framework/API/src/ExperimentInfo.cpp | 32 ++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h b/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h index 22b9f68afef..ce48b4b8329 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/ExperimentInfo.h @@ -121,6 +121,8 @@ public: virtual void loadExperimentInfoNexus(const std::string& nxFilename, ::NeXus::File *file, std::string ¶meterStr); /// Load the instrument from an open NeXus file. virtual void loadInstrumentInfoNexus(const std::string& nxFilename, ::NeXus::File *file, std::string ¶meterStr); + /// Load instrument parameters from an open Nexus file in Instument group if found there + virtual void loadInstrumentParametersNexus ( ::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 c0879084045..8df918b3c2b 100644 --- a/Code/Mantid/Framework/API/src/ExperimentInfo.cpp +++ b/Code/Mantid/Framework/API/src/ExperimentInfo.cpp @@ -973,14 +973,9 @@ void ExperimentInfo::loadInstrumentInfoNexus(const std::string& nxFilename, g_log.debug(std::string("Unable to load instrument_xml: ") + ex.what()); } - try { - file->openGroup("instrument_parameter_map", "NXnote"); - file->readData("data", parameterStr); - file->closeGroup(); - } catch (NeXus::Exception &ex) { - g_log.debug(std::string("Unable to load instrument_parameter_map: ") + ex.what()); - g_log.information("Parameter map entry missing from NeXus file. Continuing without it."); - } + // load parameters if found + loadInstrumentParametersNexus( file, parameterStr ); + // Close the instrument group file->closeGroup(); @@ -1042,6 +1037,27 @@ std::string ExperimentInfo::loadInstrumentXML(const std::string &filename) { } } +//-------------------------------------------------------------------------------------------- +/** Load the instrument parameters from an open NeXus file if found there. + * @param file :: open NeXus file in its Instrument group + * @param[out] parameterStr :: special string for all the parameters. + * Feed that to ExperimentInfo::readParameterMap() after the + * instrument is done. + */ +void ExperimentInfo::loadInstrumentParametersNexus( ::NeXus::File *file, + std::string ¶meterStr) { + try + { + file->openGroup("instrument_parameter_map", "NXnote"); + file->readData("data", parameterStr); + file->closeGroup(); + } catch (NeXus::Exception &ex) { + g_log.debug(std::string("Unable to load instrument_parameter_map: ") + ex.what()); + g_log.information("Parameter map entry missing from NeXus file. Continuing without it."); + } + +} + //------------------------------------------------------------------------------------------------- /** Parse the result of ParameterMap.asString() into the ParameterMap * of the current instrument. The instrument needs to have been loaded -- GitLab