Skip to content
Snippets Groups Projects
Commit 3d50db47 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Merge remote branch 'origin/feature/7656_speed_up_loadeventnexustest'

parents 7954925e 990901ca
No related merge requests found
......@@ -37,16 +37,15 @@ private:
const double filterStart = 1;
const double filterEnd = 1000;
LoadEventNexus * ld = new LoadEventNexus;
ld->initialize();
ld->setPropertyValue("OutputWorkspace", wsName);
ld->setPropertyValue("Filename","CNCS_7860_event.nxs");
ld->setProperty("FilterByTimeStart", filterStart);
ld->setProperty("FilterByTimeStop", filterEnd);
ld->setProperty("MetaDataOnly", metadataonly);
LoadEventNexus ld;
ld.initialize();
ld.setPropertyValue("OutputWorkspace", wsName);
ld.setPropertyValue("Filename","CNCS_7860_event.nxs");
ld.setProperty("FilterByTimeStart", filterStart);
ld.setProperty("FilterByTimeStop", filterEnd);
ld.setProperty("MetaDataOnly", metadataonly);
ld->execute();
TS_ASSERT( ld->isExecuted() );
TS_ASSERT( ld.execute() );
auto outWs = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(wsName);
......@@ -69,18 +68,6 @@ public:
doTestSingleBank(true, false);
}
// void xtest_fileCheck()
// {
// LoadEventNexus ld;
// ld.initialize();
// ld.setPropertyValue("Filename","CNCS_7860_event.nxs"); // Only doing this to resolve the path to the file
// TS_ASSERT_EQUALS(ld.fileCheck(ld.getPropertyValue("Filename")), 80);
// //Try an ISIS nexus file
// ld.setPropertyValue("Filename","LOQ49886.nxs");
// TS_ASSERT_EQUALS(ld.fileCheck(ld.getPropertyValue("Filename")), 0);
// }
void test_Normal_vs_Precount()
{
Mantid::API::FrameworkManager::Instance();
......@@ -90,6 +77,7 @@ public:
ld.setPropertyValue("Filename","CNCS_7860_event.nxs");
ld.setPropertyValue("OutputWorkspace",outws_name);
ld.setPropertyValue("Precount", "0");
ld.setProperty<bool>("LoadLogs", false); // Time-saver
ld.execute();
TS_ASSERT( ld.isExecuted() );
......@@ -115,6 +103,11 @@ public:
//Check filename
TS_ASSERT_EQUALS(ld.getPropertyValue("Filename"),WS->run().getProperty("Filename")->value());
// Test that asking not to load the logs did what it should
// Make sure that we throw if we try to read a log (that shouldn't be there)
TS_ASSERT_THROWS( WS->getLog("proton_charge"), std::invalid_argument);
//----- Now we re-load with precounting and compare memory use ----
LoadEventNexus ld2;
std::string outws_name2 = "cncs_precount";
......@@ -122,6 +115,7 @@ public:
ld2.setPropertyValue("Filename","CNCS_7860_event.nxs");
ld2.setPropertyValue("OutputWorkspace",outws_name2);
ld2.setPropertyValue("Precount", "1");
ld2.setProperty<bool>("LoadLogs", false); // Time-saver
ld2.execute();
TS_ASSERT( ld2.isExecuted() );
......@@ -199,15 +193,15 @@ public:
const double filterStart = 45000;
const double filterEnd = 59000;
LoadEventNexus * ld = new LoadEventNexus;
ld->initialize();
ld->setPropertyValue("OutputWorkspace", wsName);
ld->setPropertyValue("Filename","CNCS_7860_event.nxs");
ld->setProperty("FilterByTofMin", filterStart);
ld->setProperty("FilterByTofMax", filterEnd);
LoadEventNexus ld;
ld.initialize();
ld.setPropertyValue("OutputWorkspace", wsName);
ld.setPropertyValue("Filename","CNCS_7860_event.nxs");
ld.setProperty("FilterByTofMin", filterStart);
ld.setProperty("FilterByTofMax", filterEnd);
ld.setProperty<bool>("LoadLogs", false); // Time-saver
ld->execute();
TS_ASSERT( ld->isExecuted() );
TS_ASSERT( ld.execute() );
auto outWs = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(wsName);
......@@ -225,81 +219,6 @@ public:
TSM_ASSERT("The min TOF in the workspace should be equal to or greater than the filtered cut-off", min >= filterStart);
}
void test_FilteredLoad_vs_LoadThenFilter()
{
Mantid::API::FrameworkManager::Instance();
EventWorkspace_sptr WS1, WS2;
std::string ws1Name = "cncs_filtered_on_load";
std::string ws2Name = "cncs_filtered_after";
LoadEventNexus * ld = new LoadEventNexus;
ld->initialize();
ld->setPropertyValue("OutputWorkspace",ws1Name);
ld->setPropertyValue("Filename","CNCS_7860_event.nxs");
ld->setPropertyValue("FilterByTimeStart", "60.0");
ld->setPropertyValue("FilterByTimeStop", "120.0");
ld->setPropertyValue("FilterByTofMin", "-1e10");
ld->setPropertyValue("FilterByTofMax", "1e10");
ld->execute();
TS_ASSERT( ld->isExecuted() );
TS_ASSERT_THROWS_NOTHING(
WS1 = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(ws1Name); )
//Valid WS and it is an EventWorkspace
TS_ASSERT( WS1 );
//Pixels have to be padded
TS_ASSERT_EQUALS( WS1->getNumberHistograms(), 51200);
//Events
TS_ASSERT_EQUALS( WS1->getNumberEvents(), 29753);
if (WS1->getNumberEvents() == 0)
return;
//Check one event from one pixel - does it have a reasonable pulse time
TS_ASSERT( WS1->getEventListPtr(7)->getEvents()[0].pulseTime() > DateAndTime(int64_t(1e9*365*10)) );
// Check the run_start property exists and is right.
Property * p = NULL;
TS_ASSERT( WS1->mutableRun().hasProperty("run_start") );
TS_ASSERT_THROWS_NOTHING( p = WS1->mutableRun().getProperty("run_start"); )
if (p)
{
TS_ASSERT_EQUALS( p->value(), "2010-03-25T16:08:37") ;
}
// ----------- Now load the entire thing -----------------
delete ld;
ld = new LoadEventNexus;
ld->initialize();
ld->setPropertyValue("OutputWorkspace",ws2Name);
ld->setPropertyValue("Filename","CNCS_7860_event.nxs");
ld->setPropertyValue("FilterByTimeStart", "-1e10");
ld->setPropertyValue("FilterByTimeStop", "1e10");
ld->setPropertyValue("FilterByTofMin", "-1e10");
ld->setPropertyValue("FilterByTofMax", "1e10");
ld->execute();
TS_ASSERT( ld->isExecuted() );
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("FilterByTime");
alg->setPropertyValue("InputWorkspace", ws2Name);
alg->setPropertyValue("OutputWorkspace", ws2Name);
alg->setPropertyValue("StartTime", "60.0");
alg->setPropertyValue("StopTime", "120.0");
alg->execute();
TS_ASSERT( alg->isExecuted() );
TS_ASSERT_THROWS_NOTHING(
WS2 = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(ws1Name); )
TS_ASSERT( WS2 );
TS_ASSERT_EQUALS( WS2->getNumberHistograms(), 51200);
TS_ASSERT_EQUALS( WS2->getNumberEvents(), 29753);
// The two workspaces are the same
TS_ASSERT( Mantid::API::equals(WS1, WS2) );
}
void test_Load_And_CompressEvents()
{
Mantid::API::FrameworkManager::Instance();
......@@ -310,6 +229,8 @@ public:
ld.setPropertyValue("OutputWorkspace",outws_name);
ld.setPropertyValue("Precount", "0");
ld.setPropertyValue("CompressTolerance", "0.05");
ld.setProperty<bool>("LoadMonitors", true); // For the next test, saving a load
ld.setProperty<bool>("LoadLogs", false); // Time-saver
ld.execute();
TS_ASSERT( ld.isExecuted() );
......@@ -333,18 +254,8 @@ public:
void test_Monitors()
{
Mantid::API::FrameworkManager::Instance();
LoadEventNexus ld;
std::string outws_name = "cncs";
ld.initialize();
ld.setPropertyValue("Filename","CNCS_7860_event.nxs");
ld.setPropertyValue("OutputWorkspace",outws_name);
ld.setProperty<bool>("LoadMonitors", true);
ld.execute();
TS_ASSERT( ld.isExecuted() );
std::string mon_outws_name = outws_name + "_monitors";
// Uses the workspace loaded in the last test to save a load execution
std::string mon_outws_name = "cncs_compressed_monitors";
MatrixWorkspace_sptr WS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(mon_outws_name);
//Valid WS and it is an MatrixWorkspace
TS_ASSERT( WS );
......@@ -368,30 +279,6 @@ public:
TS_ASSERT_DELTA( mon->getDistance(*sample), 1.426, 1e-6 );
}
// Test that not loading logs works ok.
void test_LoadLogs()
{
Mantid::API::FrameworkManager::Instance();
LoadEventNexus ld;
std::string outws_name = "_loadeventnexus_test_loadlogs";
ld.initialize();
ld.setPropertyValue("Filename","CNCS_7860_event.nxs");
ld.setPropertyValue("OutputWorkspace", outws_name);
ld.setProperty<bool>("LoadLogs", false);
ld.execute();
TS_ASSERT( ld.isExecuted() );
MatrixWorkspace_sptr WS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outws_name);
// Make sure that we throw if we try to read a log (that shouldn't be there)
TS_ASSERT_THROWS( WS->getLog("proton_charge"), std::invalid_argument);
}
void doTestSingleBank(bool SingleBankPixelsOnly, bool Precount, std::string BankName = "bank36", bool willFail=false)
{
Mantid::API::FrameworkManager::Instance();
......@@ -404,6 +291,7 @@ public:
ld.setPropertyValue("BankName", BankName);
ld.setProperty<bool>("SingleBankPixelsOnly", SingleBankPixelsOnly);
ld.setProperty<bool>("Precount", Precount);
ld.setProperty<bool>("LoadLogs", false); // Time-saver
ld.execute();
EventWorkspace_sptr WS;
......@@ -447,8 +335,9 @@ public:
/** Test with a particular ARCS file that has 2 preprocessors,
* meaning different-sized pulse ID files.
* DISABLED AS THE FILE ISN'T IN THE REPOSITORY
*/
void test_MultiplePreprocessors()
void xtest_MultiplePreprocessors()
{
Mantid::API::FrameworkManager::Instance();
LoadEventNexus ld;
......@@ -508,8 +397,10 @@ public:
ld.initialize();
ld.setPropertyValue("Filename", "ARCS_sim_event.nxs");
ld.setPropertyValue("OutputWorkspace", wsname);
ld.execute();
TS_ASSERT( ld.isExecuted() );
ld.setProperty("BankName","bank27");
ld.setProperty("SingleBankPixelsOnly",false);
ld.setProperty("LoadLogs",false);
TS_ASSERT( ld.execute() );
EventWorkspace_sptr WS;
TS_ASSERT_THROWS_NOTHING(
......@@ -517,9 +408,10 @@ public:
//Valid WS and it is an EventWorkspace
TS_ASSERT( WS );
if (!WS) return;
TS_ASSERT_EQUALS( WS->getNumberHistograms(), 117760);
TS_ASSERT_EQUALS( WS->getNumberEvents(), 128);
for (size_t wi = 0; wi < WS->getNumberHistograms(); wi++)
const auto numHist = WS->getNumberHistograms();
TS_ASSERT_EQUALS( numHist, 117760);
TS_ASSERT_EQUALS( WS->getNumberEvents(), 2);
for (size_t wi = 0; wi < numHist; wi+=5000)
{
// All events should be weighted events for simulated data
TS_ASSERT_EQUALS( WS->getEventList(wi).getEventType(), WEIGHTED);
......@@ -530,20 +422,6 @@ public:
TS_ASSERT_EQUALS(WS->getEventList(26798).getWeightedEvents()[0].tof(), 1476.0);
}
// There was an error where all the events from detectors that aren't in the IDF ended
// up in the first spectrum (ticket #7524). This makes sure there's no regression with the fix.
void test_BASIS_first_spectrum()
{
LoadEventNexus ld;
ld.initialize();
ld.setPropertyValue("Filename","BSS_11841_event.nxs");
ld.setPropertyValue("OutputWorkspace","Basis");
TS_ASSERT( ld.execute() );
EventWorkspace_const_sptr ws = AnalysisDataService::Instance().retrieveWS<EventWorkspace>("Basis");
TS_ASSERT_EQUALS( ws->getEventList(0).getNumberEvents(), 1 );
}
};
//------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment