Skip to content

Commit

Permalink
Merge branch 'master' into feature/10380_refl_ui_options_col_quote_co…
Browse files Browse the repository at this point in the history
…mmas
  • Loading branch information
Harry Jeffery committed Oct 20, 2014
2 parents 2e65601 + d865271 commit 39cc41b
Show file tree
Hide file tree
Showing 65 changed files with 5,190 additions and 3,352 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDNode.h
Expand Up @@ -71,6 +71,7 @@ class IMDNode
*@param loadFileData -- if true, the data on HDD and not yet in memory are loaded into memory before deleting fileBacked information,
if false, all on HDD contents are discarded, which can break the data integrity (used by destructor) */
virtual void clearFileBacked(bool loadFileData)=0;
virtual void reserveMemoryForLoad(uint64_t)=0;

/**Save the box at specific disk position using the class, respoinsible for the file IO. */
virtual void saveAt(API::IBoxControllerIO *const /*saver */, uint64_t /*position*/)const=0;
Expand Down
Expand Up @@ -129,6 +129,9 @@ namespace DataHandling

static void loadSampleDataISIScompatibility(::NeXus::File& file, Mantid::API::MatrixWorkspace_sptr WS);

/// method used to return instrument name for some old ISIS files where it is not written properly within the instrument
static std::string readInstrumentFromISIS_VMSCompat(::NeXus::File &hFile);

public:

/// The name and path of the input file
Expand Down
4,661 changes: 2,349 additions & 2,312 deletions Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp

Large diffs are not rendered by default.

35 changes: 23 additions & 12 deletions Code/Mantid/Framework/DataHandling/src/LoadNexusMonitors.cpp
Expand Up @@ -42,7 +42,7 @@ LoadNexusMonitors::~LoadNexusMonitors()
{
}

/// Initialisation method.
/// Initialization method.
void LoadNexusMonitors::init()
{
declareProperty(new API::FileProperty("Filename", "", API::FileProperty::Load,
Expand Down Expand Up @@ -76,12 +76,12 @@ void LoadNexusMonitors::exec()
string_map_t entries = file.getEntries();
for (it = entries.begin(); it != entries.end(); ++it)
{
if ( ((it->first == "entry") || (it->first == "raw_data_1")) && (it->second == "NXentry") )
{
file.openGroup(it->first, it->second);
if ( ((it->first == "entry") || (it->first == "raw_data_1")) && (it->second == "NXentry") )
{
file.openGroup(it->first, it->second);
m_top_entry_name = it->first;
break;
}
break;
}
}
prog1.report();

Expand Down Expand Up @@ -353,14 +353,25 @@ void LoadNexusMonitors::exec()
// Need to get the instrument name from the file
std::string instrumentName;
file.openGroup("instrument", "NXinstrument");
file.openData("name");
instrumentName = file.getStrData();
try
{
file.openData("name");
instrumentName = file.getStrData();
// Now let's close the file as we don't need it anymore to load the instrument.
file.closeData();
file.closeGroup(); // Close the NXentry
file.close();

}
catch(std::runtime_error &) // no correct instrument definition (old ISIS file, fall back to isis_vms_compat)
{
file.closeGroup(); // Close the instrument NXentry
instrumentName =LoadEventNexus::readInstrumentFromISIS_VMSCompat(file);
file.close();
}

g_log.debug() << "Instrument name read from NeXus file is " << instrumentName << std::endl;

// Now let's close the file as we don't need it anymore to load the instrument.
file.closeData();
file.closeGroup(); // Close the NXentry
file.close();

this->WS->getAxis(0)->unit() = Kernel::UnitFactory::Instance().create("TOF");
this->WS->setYUnit("Counts");
Expand Down
16 changes: 12 additions & 4 deletions Code/Mantid/Framework/DataHandling/src/LoadReflTBL.cpp
Expand Up @@ -291,7 +291,7 @@ namespace Mantid
auto colQmin = ws->addColumn("str","Qmin");
auto colQmax = ws->addColumn("str","Qmax");
auto colDqq = ws->addColumn("str","dq/q");
auto colScale = ws->addColumn("str","Scale");
auto colScale = ws->addColumn("double","Scale");
auto colStitch = ws->addColumn("int","StitchGroup");
auto colOptions = ws->addColumn("str","Options");

Expand All @@ -317,6 +317,11 @@ namespace Mantid
}
getCells(line, columns);

const std::string scaleStr = columns.at(16);
double scale = 1.0;
if(!scaleStr.empty())
Mantid::Kernel::Strings::convert<double>(columns.at(16), scale);

//check if the first run in the row has any data associated with it
// 0 = runs, 1 = theta, 2 = trans, 3 = qmin, 4 = qmax
if (columns[0] != "" || columns[1] != "" || columns[2] != "" || columns[3] != "" || columns[4] != "")
Expand All @@ -327,7 +332,7 @@ namespace Mantid
row << columns.at(i);
}
row << columns.at(15);
row << columns.at(16);
row << scale;
row << stitchID;
}

Expand All @@ -341,7 +346,7 @@ namespace Mantid
row << columns.at(i);
}
row << columns.at(15);
row << columns.at(16);
row << scale;
row << stitchID;
}

Expand All @@ -352,7 +357,10 @@ namespace Mantid
TableRow row = ws->appendRow();
for (int i = 10; i < 17; ++i)
{
row << columns.at(i);
if(i == 16)
row << scale;
else
row << columns.at(i);
}
row << stitchID;
}
Expand Down
6 changes: 4 additions & 2 deletions Code/Mantid/Framework/DataHandling/src/SaveReflTBL.cpp
Expand Up @@ -111,7 +111,8 @@ namespace Mantid
//now add dq/q and scale from the first row in the group
TableRow row = ws->getRow(rowNos[0]);
writeVal(row.cell<std::string>(5),file);
writeVal(row.cell<std::string>(6),file, false, true);
std::string scaleStr = boost::lexical_cast<std::string>(row.cell<double>(6));
writeVal(scaleStr, file, false, true);
}

//now do the same for the ungrouped
Expand All @@ -130,7 +131,8 @@ namespace Mantid
}
//now add dq/q and scale
writeVal(row.cell<std::string>(5),file);
writeVal(row.cell<std::string>(6),file, false, true);
std::string scaleStr = boost::lexical_cast<std::string>(row.cell<double>(6));
writeVal(scaleStr, file, false, true);
}
file.close();
}
Expand Down
26 changes: 26 additions & 0 deletions Code/Mantid/Framework/DataHandling/test/LoadNexusMonitorsTest.h
Expand Up @@ -95,6 +95,32 @@ class LoadNexusMonitorsTest : public CxxTest::TestSuite
TS_ASSERT( ld.isExecuted() );
}

void testBrokenISISFile()
{
// Just need to make sure it runs.
Mantid::API::FrameworkManager::Instance();
LoadNexusMonitors ld;
std::string outws_name = "LOQ_49886_monitors";
ld.initialize();
ld.setPropertyValue("Filename", "LOQ49886.nxs");
ld.setPropertyValue("OutputWorkspace", outws_name);
TS_ASSERT_THROWS_NOTHING( ld.execute() );
TS_ASSERT( ld.isExecuted() );

MatrixWorkspace_sptr WS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outws_name);
//Valid WS and it is an MatrixWorkspace
TS_ASSERT( WS );
//Correct number of monitors found
TS_ASSERT_EQUALS( WS->getNumberHistograms(), 2 );
//Monitors data is correct
TS_ASSERT_EQUALS( WS->readY(0)[0], 0 );
TS_ASSERT_EQUALS( WS->readY(1)[0], 0 );

TS_ASSERT_EQUALS( WS->readX(0)[0], 5.0 );
TS_ASSERT_EQUALS( WS->readX(1)[5],19995.0 );

}

void test_10_monitors()
{
Poco::Path path(ConfigService::Instance().getTempDir().c_str());
Expand Down
12 changes: 6 additions & 6 deletions Code/Mantid/Framework/DataHandling/test/LoadReflTBLTest.h
Expand Up @@ -65,7 +65,7 @@ class LoadReflTBLTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(3)),0.01,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(4)),0.06,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(5)),0.04,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(6)),2,0.01);
TS_ASSERT_DELTA(row.cell<double>(6),2,0.01);
TS_ASSERT_EQUALS(row.cell<int>(7),1);

row = outputWS->getRow(1);
Expand All @@ -75,7 +75,7 @@ class LoadReflTBLTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(3)),0.01,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(4)),0.06,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(5)),0.04,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(6)),2,0.01);
TS_ASSERT_DELTA(row.cell<double>(6),2,0.01);
TS_ASSERT_EQUALS(row.cell<int>(7),2);

row = outputWS->getRow(2);
Expand All @@ -85,7 +85,7 @@ class LoadReflTBLTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(3)),0.035,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(4)),0.3,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(5)),0.04,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(6)),2,0.01);
TS_ASSERT_DELTA(row.cell<double>(6),2,0.01);
TS_ASSERT_EQUALS(row.cell<int>(7),2);

cleanupafterwards();
Expand Down Expand Up @@ -128,7 +128,7 @@ class LoadReflTBLTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(3)),0.01,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(4)),0.06,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(5)),0.04,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(6)),2,0.01);
TS_ASSERT_DELTA(row.cell<double>(6),2,0.01);
TS_ASSERT_EQUALS(row.cell<int>(7),1);

row = outputWS->getRow(1);
Expand All @@ -138,7 +138,7 @@ class LoadReflTBLTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(3)),0.01,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(4)),0.06,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(5)),0.04,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(6)),2,0.01);
TS_ASSERT_DELTA(row.cell<double>(6),2,0.01);
TS_ASSERT_EQUALS(row.cell<int>(7),2);

row = outputWS->getRow(2);
Expand All @@ -148,7 +148,7 @@ class LoadReflTBLTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(3)),0.035,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(4)),0.3,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(5)),0.04,0.001);
TS_ASSERT_DELTA(boost::lexical_cast<double>(row.cell<std::string>(6)),2,0.01);
TS_ASSERT_DELTA(row.cell<double>(6),2,0.01);
TS_ASSERT_EQUALS(row.cell<int>(7),2);

cleanupafterwards();
Expand Down
34 changes: 17 additions & 17 deletions Code/Mantid/Framework/DataHandling/test/SaveReflTBLTest.h
Expand Up @@ -69,10 +69,10 @@ class SaveReflTBLTest : public CxxTest::TestSuite
ITableWorkspace_sptr ws = CreateWorkspace();

TableRow row = ws->appendRow();
row << "13460" << "0.7" << "13463,13464" << "0.01" << "0.06" << "0.04" << "2" << 4;
row << "13460" << "0.7" << "13463,13464" << "0.01" << "0.06" << "0.04" << 2.0 << 4;

row = ws->appendRow();
row << "13470" << "2.3" << "13463,13464" << "0.035" << "0.3" << "0.04" << "2" << 5;
row << "13470" << "2.3" << "13463,13464" << "0.035" << "0.3" << "0.04" << 2.0 << 5;

Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("SaveReflTBL");
alg->setRethrows(true);
Expand Down Expand Up @@ -111,7 +111,7 @@ class SaveReflTBLTest : public CxxTest::TestSuite
ITableWorkspace_sptr ws = CreateWorkspace();

TableRow row = ws->appendRow();
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << "2" << 1;
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << 2.0 << 1;

Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("SaveReflTBL");
alg->setRethrows(true);
Expand All @@ -135,7 +135,7 @@ class SaveReflTBLTest : public CxxTest::TestSuite
auto colQmin = ws->addColumn("str","Qmin");
auto colQmax = ws->addColumn("str","Qmax");
auto colDqq = ws->addColumn("str","dq/q");
auto colScale = ws->addColumn("str","Scale");
auto colScale = ws->addColumn("double","Scale");

colRuns->setPlotType(0);
colTheta->setPlotType(0);
Expand All @@ -146,13 +146,13 @@ class SaveReflTBLTest : public CxxTest::TestSuite
colScale->setPlotType(0);

TableRow row = ws->appendRow();
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << "2";
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << 2.0;

row = ws->appendRow();
row << "13462" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << "2";
row << "13462" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << 2.0;

row = ws->appendRow();
row << "13470" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << "2";
row << "13470" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << 2.0;

Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create("SaveReflTBL");
alg->setRethrows(true);
Expand Down Expand Up @@ -214,7 +214,7 @@ class SaveReflTBLTest : public CxxTest::TestSuite
auto colQmin = ws->addColumn("str","Qmin");
auto colQmax = ws->addColumn("str","Qmax");
auto colDqq = ws->addColumn("str","dq/q");
auto colScale = ws->addColumn("str","Scale");
auto colScale = ws->addColumn("double","Scale");
auto colStitch = ws->addColumn("int","StitchGroup");

colRuns->setPlotType(0);
Expand All @@ -227,32 +227,32 @@ class SaveReflTBLTest : public CxxTest::TestSuite
colStitch->setPlotType(0);

TableRow row = ws->appendRow();
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << "2" << 1;
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << 2.0 << 1;

row = ws->appendRow();
row << "13462" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << "2" << 1;
row << "13462" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << 2.0 << 1;

row = ws->appendRow();
row << "13470" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << "2" << 1;
row << "13470" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << 2.0 << 1;

row = ws->appendRow();
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << "2" << 2;
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << 2.0 << 2;

row = ws->appendRow();
row << "13462" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << "2" << 2;
row << "13462" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << 2.0 << 2;

row = ws->appendRow();
row << "13470" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << "2" << 3;
row << "13470" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << 2.0 << 3;

row = ws->appendRow();
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << "2" << 0;
row << "13460" << "0.7" << "13463" << "0.01" << "0.06" << "0.04" << 2.0 << 0;

//this row's last two cells will show in the tableworkspace, but the first row in stich group 3's will take priority when saving
row = ws->appendRow();
row << "13462" << "2.3" << "13463" << "0.035" << "0.3" << "0.4" << "3" << 3;
row << "13462" << "2.3" << "13463" << "0.035" << "0.3" << "0.4" << 3.0 << 3;

row = ws->appendRow();
row << "13470" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << "2" << 4;
row << "13470" << "2.3" << "13463" << "0.035" << "0.3" << "0.04" << 2.0 << 4;

return ws;
}
Expand Down

0 comments on commit 39cc41b

Please sign in to comment.