diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h index f39253429325c0939686951161d2571880e011cc..5fde56823b2848b7e5fb8ded443e2722059f2ebc 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h @@ -174,7 +174,6 @@ private: std::string m_sampleRotation; std::string m_imageType; - std::string m_baseName; size_t m_pixelCount; // Number of digits for the fixed width appendix number added to diff --git a/Framework/DataHandling/src/LoadFITS.cpp b/Framework/DataHandling/src/LoadFITS.cpp index 1b9e77436175fc5b005c3798f54a2191d6324975..4e0a0cc418556aae7e5b2c3197cccc53d2954250 100644 --- a/Framework/DataHandling/src/LoadFITS.cpp +++ b/Framework/DataHandling/src/LoadFITS.cpp @@ -37,7 +37,7 @@ const std::string LoadFITS::g_defaultImgType = "SAMPLE"; LoadFITS::LoadFITS() : m_headerScaleKey(), m_headerOffsetKey(), m_headerBitDepthKey(), m_headerRotationKey(), m_headerImageKeyKey(), m_headerAxisNameKeys(), - m_mapFile(), m_baseName(), m_pixelCount(0) { + m_mapFile(), m_pixelCount(0) { setupDefaultKeywordNames(); } @@ -424,9 +424,6 @@ void LoadFITS::doLoadFiles(const std::vector<std::string> &paths, // to it. std::string groupName = outWSName; - // This forms the name of the group - m_baseName = getPropertyValue("OutputWorkspace") + "_"; - size_t fileNumberInGroup = 0; WorkspaceGroup_sptr wsGroup; @@ -594,10 +591,6 @@ LoadFITS::makeWorkspace(const FITSInfo &fileInfo, size_t &newFileNumber, std::vector<char> &buffer, MantidImage &imageY, MantidImage &imageE, const Workspace2D_sptr parent, bool loadAsRectImg, int binSize, double noiseThresh) { - - std::string currNumberS = padZeros(newFileNumber, g_DIGIT_SIZE_APPEND); - ++newFileNumber; - // Create workspace (taking into account already here if rebinning is // going to happen) Workspace2D_sptr ws; @@ -653,7 +646,12 @@ LoadFITS::makeWorkspace(const FITSInfo &fileInfo, size_t &newFileNumber, } } - ws->setTitle(Poco::Path(fileInfo.filePath).getFileName()); + try { + ws->setTitle(Poco::Path(fileInfo.filePath).getFileName()); + } catch (std::runtime_error &) { + ws->setTitle(padZeros(newFileNumber, g_DIGIT_SIZE_APPEND)); + } + ++newFileNumber; addAxesInfoAndLogs(ws, loadAsRectImg, fileInfo, binSize, cmpp); diff --git a/Framework/DataHandling/test/LoadFITSTest.h b/Framework/DataHandling/test/LoadFITSTest.h index 55c3fc856e0373d832275e2996d0daa3faf3e3fc..ace4e8874b3cd1678b681febbe3e4b8109d7fe94 100644 --- a/Framework/DataHandling/test/LoadFITSTest.h +++ b/Framework/DataHandling/test/LoadFITSTest.h @@ -311,11 +311,18 @@ public: ws->getNumberHistograms(), g_SPECTRA_COUNT_ASRECT); } + TSM_ASSERT_EQUALS("The output workspace group should have two workspaces", + out->size(), 2); + // and finally a basic check of values in the image, to be safe MatrixWorkspace_sptr ws0; TS_ASSERT_THROWS_NOTHING( ws0 = boost::dynamic_pointer_cast<MatrixWorkspace>(out->getItem(0))); + TSM_ASSERT_EQUALS("The title of the first output workspace is not the name " + "of the first file", + ws0->getTitle(), g_smallFname1); + size_t n = ws0->getNumberHistograms(); TSM_ASSERT_EQUALS( "The value at a given spectrum and bin (first one) is not as expected", @@ -328,6 +335,25 @@ public: TSM_ASSERT_EQUALS( "The value at a given spectrum and bin (last one) is not as expected", ws0->readY(n - 1).back(), 142); + + MatrixWorkspace_sptr ws1; + TS_ASSERT_THROWS_NOTHING( + ws1 = boost::dynamic_pointer_cast<MatrixWorkspace>(out->getItem(1))); + + TSM_ASSERT_EQUALS("The title of the second output workspace is not the " + "name of the second file", + ws1->getTitle(), g_smallFname2); + TSM_ASSERT_EQUALS( + "The value at a given spectrum and bin (first one) is not as expected", + ws1->readY(n - 1)[0], 155); + + TSM_ASSERT_EQUALS( + "The value at a given spectrum and bin (middle one) is not as expected", + ws1->readY(n - 1)[g_SPECTRA_COUNT_ASRECT / 2], 199); + + TSM_ASSERT_EQUALS( + "The value at a given spectrum and bin (last one) is not as expected", + ws1->readY(n - 1).back(), 133); } void test_loadEmpty() { @@ -387,5 +413,4 @@ const std::string LoadFITSTest::g_hdrNAXIS = "2"; const std::string LoadFITSTest::g_hdrNAXIS1 = "512"; const std::string LoadFITSTest::g_hdrNAXIS2 = "512"; - #endif // MANTID_DATAHANDLING_LOADFITSTEST_H_