From 562065276bbbb5976a352016e80f821c296e83ab Mon Sep 17 00:00:00 2001 From: Lottie Greenwood Date: Wed, 5 Nov 2014 10:11:47 +0000 Subject: [PATCH] Commit 02 Refs #3493 --- .../inc/MantidDataHandling/SaveAscii2.h | 1 + .../Framework/DataHandling/src/SaveAscii2.cpp | 27 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h index 08e2c77d4a9d..4e0dc838f1f5 100644 --- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h +++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h @@ -89,6 +89,7 @@ namespace Mantid bool m_writeDX; bool m_writeID; bool m_isHistogram; + bool m_isCommonBins; API::MatrixWorkspace_const_sptr m_ws; }; } // namespace DataHandling diff --git a/Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp b/Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp index 0b4068ea8072..dc2e82d82e81 100644 --- a/Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp +++ b/Code/Mantid/Framework/DataHandling/src/SaveAscii2.cpp @@ -93,6 +93,7 @@ namespace Mantid int nSpectra = static_cast(m_ws->getNumberHistograms()); m_nBins = static_cast(m_ws->blocksize()); m_isHistogram = m_ws->isHistogramData(); + m_isCommonBins = m_ws->isCommonBins(); //checking for ragged workspace m_writeID = getProperty("WriteSpectrumID"); if (nSpectra != 1) m_writeID = true; @@ -102,9 +103,8 @@ namespace Mantid int spec_max = getProperty("WorkspaceIndexMax"); bool writeHeader = getProperty("ColumnHeader"); bool appendToFile = getProperty("AppendToFile"); - //here we need to check for ragged? + // Check whether we need to write the fourth column - bool checkRagged = getProperty("RaggedWorkspace"); //in testing m_writeDX = getProperty("WriteXError"); std::string choice = getPropertyValue("Separator"); std::string custom = getPropertyValue("CustomSeparator"); @@ -238,7 +238,7 @@ namespace Mantid @param spectraItr :: a set iterator pointing to a set of workspace IDs to be saved @param file :: the file writer object */ - void SaveAscii2::writeSpectra(const std::set::const_iterator & spectraItr, std::ofstream & file) + void SaveAscii2::writeSpectra(const std::set::const_iterator & spectraItr, std::ofstream & file) { auto spec = m_ws->getSpectrum(*spectraItr); auto specNo = spec->getSpectrumNo(); @@ -246,17 +246,23 @@ namespace Mantid for(int bin=0;binreadX(*spectraItr)[bin]; + } - if (m_isHistogram) // bin centres + if (m_isHistogram & m_isCommonBins) // bin centres { - file << ( m_ws->readX(0)[bin] + m_ws->readX(0)[bin+1] )/2; + file << ( m_ws->readX(0)[bin] + m_ws->readX(0)[bin+1] )/2; } + else // data points { file << m_ws->readX(0)[bin]; } file << m_sep; file << m_ws->readY(*spectraItr)[bin]; + file << m_sep; file << m_ws->readE(*spectraItr)[bin]; if (m_writeDX) @@ -280,7 +286,7 @@ namespace Mantid @param spectraIndex :: an integer relating to a workspace ID @param file :: the file writer object */ - void SaveAscii2::writeSpectra(const int & spectraIndex, std::ofstream & file) + void SaveAscii2::writeSpectra(const int & spectraIndex, std::ofstream & file) //<- shouldnt be here { auto spec = m_ws->getSpectrum(spectraIndex); auto specNo = spec->getSpectrumNo(); @@ -288,9 +294,13 @@ namespace Mantid for(int bin=0;binreadX(0)[bin] + m_ws->readX(1)[bin+1] )/2; + } + if (!m_isCommonBins) //checking for ragged workspace { - file << ( m_ws->readX(0)[bin] + m_ws->readX(0)[bin+1] )/2; + file << m_ws->readX(spectraIndex)[bin]; } else // data points { @@ -298,6 +308,7 @@ namespace Mantid } file << m_sep; file << m_ws->readY(spectraIndex)[bin]; + file << m_sep; file << m_ws->readE(spectraIndex)[bin]; if (m_writeDX)