From 7cd2a21662abe64368f61fbc3f9636af1fa2eebc Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Tue, 26 May 2015 17:11:34 +0100 Subject: [PATCH] Added code to load the PAR file Refs #11833 --- .../src/VesuvioL1ThetaResolution.cpp | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Code/Mantid/Framework/Algorithms/src/VesuvioL1ThetaResolution.cpp b/Code/Mantid/Framework/Algorithms/src/VesuvioL1ThetaResolution.cpp index 14e85ef3ce31..388eda88cf4a 100644 --- a/Code/Mantid/Framework/Algorithms/src/VesuvioL1ThetaResolution.cpp +++ b/Code/Mantid/Framework/Algorithms/src/VesuvioL1ThetaResolution.cpp @@ -239,7 +239,33 @@ void VesuvioL1ThetaResolution::loadInstrument() { if(!parFilename.empty()) { g_log.information() << "Loading PAR file: " << parFilename << std::endl; - //TODO + // Get header format + std::map headerFormats; + headerFormats[5] = "spectrum,theta,t0,-,R"; + headerFormats[6] = "spectrum,-,theta,t0,-,R"; + + //TODO: get columns in first line + int numCols = 6; + + std::string headerFormat = headerFormats[numCols]; + if(headerFormat.empty()) { + std::stringstream error; + error << "Unrecognised PAR file header. Number of colums: " << numCols + << " (expected either 5 or 6."; + throw std::runtime_error(error.str()); + } + + // Update instrument + IAlgorithm_sptr updateInst = AlgorithmManager::Instance().create("UpdateInstrumentFromFile"); + updateInst->initialize(); + updateInst->setChild(true); + updateInst->setLogging(false); + updateInst->setProperty("Workspace", m_instWorkspace); + updateInst->setProperty("Filename", parFilename); + updateInst->setProperty("MoveMonitors", false); + updateInst->setProperty("IgnorePhi",true ); + updateInst->setProperty("AsciiHeader", headerFormat); + updateInst->execute(); } const int specIdxMin = static_cast(m_instWorkspace->getIndexFromSpectrumNumber(getProperty("SpectrumMin")));