Skip to content

Commit

Permalink
Changed input properties. Refs #10622.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Jan 6, 2015
1 parent 4ead668 commit 3bbbe50
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
Expand Up @@ -73,7 +73,9 @@ namespace DataHandling
API::IMDEventWorkspace_sptr convertToMDEventWS(const std::vector<API::MatrixWorkspace_sptr> vec_ws2d);

/// Parse data table workspace to a vector of matrix workspaces
std::vector<API::MatrixWorkspace_sptr> convertToWorkspaces(DataObjects::TableWorkspace_sptr tablews);
std::vector<API::MatrixWorkspace_sptr>
convertToWorkspaces(DataObjects::TableWorkspace_sptr tablews,
API::MatrixWorkspace_const_sptr parentws);

/// Create parent workspace
API::MatrixWorkspace_sptr createParentWorkspace(size_t numspec);
Expand Down
28 changes: 24 additions & 4 deletions Code/Mantid/Framework/DataHandling/src/LoadHFIRPDD.cpp
Expand Up @@ -37,12 +37,23 @@ namespace DataHandling
*/
void LoadHFIRPDD::init()
{
declareProperty(new WorkspaceProperty<TableWorkspace>("InputWorkspace", "",
Direction::Input),
"Input table workspace for data.");

declareProperty(new WorkspaceProperty<MatrixWorkspace>(
"ParentWorkspace", "", Direction::Input),
"Input matrix workspace serving as parent workspace "
"containing sample logs.");

/* These are for stage 2
std::vector<std::string> exts;
exts.push_back(".dat");
exts.push_back(".txt");
declareProperty(
new API::FileProperty("Filename", "", API::FileProperty::Load, exts),
"The input filename of the stored data");
*/

declareProperty(new WorkspaceProperty<IMDEventWorkspace>(
"OutputWorkspace", "", Direction::Output),
Expand All @@ -56,18 +67,24 @@ namespace DataHandling
*/
void LoadHFIRPDD::exec()
{
/** Stage 2
// Process inputs
std::string spiceFileName = getProperty("Filename");
// Load SPICE data
m_dataTableWS = loadSpiceData(spiceFileName);
*/
m_dataTableWS = getProperty("InputWrokspace");
MatrixWorkspace_const_sptr parentWS = getProperty("ParentWorkspace");

// Convert table workspace to a list of 2D workspaces
std::vector<MatrixWorkspace_sptr> vec_ws2d = convertToWorkspaces(m_dataTableWS);
std::vector<MatrixWorkspace_sptr> vec_ws2d =
convertToWorkspaces(m_dataTableWS, parentWS);

// Convert to MD workspaces
IMDEventWorkspace_sptr m_mdEventWS = convertToMDEventWS(vec_ws2d);

// Set property
setProperty("OutputWorkspace", m_mdEventWS);

}
Expand Down Expand Up @@ -100,10 +117,11 @@ namespace DataHandling
//----------------------------------------------------------------------------------------------
/** Convert runs/pts from table workspace to a list of workspace 2D
*/
std::vector<MatrixWorkspace_sptr> LoadHFIRPDD::convertToWorkspaces(DataObjects::TableWorkspace_sptr tablews)
{
std::vector<MatrixWorkspace_sptr>
LoadHFIRPDD::convertToWorkspaces(DataObjects::TableWorkspace_sptr tablews,
API::MatrixWorkspace_const_sptr parentws) {
// For HB2A m_numSpec is 44
MatrixWorkspace_sptr parentws = createParentWorkspace(m_numSpec);
// MatrixWorkspace_sptr parentws = createParentWorkspace(m_numSpec);

// Get table workspace's column information
size_t ipt, irotangle, itime;
Expand Down Expand Up @@ -253,6 +271,8 @@ namespace DataHandling
*/
API::MatrixWorkspace_sptr LoadHFIRPDD::createParentWorkspace(size_t numspec)
{
// TODO - This method might be deleted

MatrixWorkspace_sptr tempws =
WorkspaceFactory::Instance().create("Workspace2D", numspec, 2, 1);

Expand Down
30 changes: 28 additions & 2 deletions Code/Mantid/Framework/DataHandling/test/LoadHFIRPDDTest.h
Expand Up @@ -4,9 +4,15 @@
#include <cxxtest/TestSuite.h>

#include "MantidDataHandling/LoadHFIRPDD.h"
#include "MantidDataHandling/LoadNexusProcessed.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/ITableWorkspace.h"

using Mantid::DataHandling::LoadHFIRPDD;
using Mantid::DataHandling::LoadNexusProcessed;

using namespace Mantid::API;
using namespace Mantid::DataObjects;

class LoadHFIRPDDTest : public CxxTest::TestSuite
{
Expand All @@ -16,7 +22,6 @@ class LoadHFIRPDDTest : public CxxTest::TestSuite
static LoadHFIRPDDTest *createSuite() { return new LoadHFIRPDDTest(); }
static void destroySuite( LoadHFIRPDDTest *suite ) { delete suite; }


void test_Init()
{
LoadHFIRPDD loader;
Expand All @@ -26,10 +31,31 @@ class LoadHFIRPDDTest : public CxxTest::TestSuite

void test_LoadHB2AData()
{
// This is the solution of stage 1. Stage 2 will be different
LoadNexusProcessed nxsloader;
nxsloader.initialize();
nxsloader.setProperty("Filename", "HB2A_exp0231_tabledata.nxs");
nxsloader.setProperty("OutputWorkspace", "DataTable");
nxsloader.execute();
ITableWorkspace_sptr datatablews =
boost::dynamic_pointer_cast<ITableWorkspace>(
AnalysisDataService::Instance().retrieve("DataTable"));
TS_ASSERT(datatablews);

nxsloader.setProperty("Filename", "HB2A_exp0231_log.nxs");
nxsloader.setProperty("OutputWorkspace", "LogParentWS");
nxsloader.execute();
MatrixWorkspace_sptr parentlogws =
boost::dynamic_pointer_cast<MatrixWorkspace>(
AnalysisDataService::Instance().retrieve("LogParentWS"));
TS_ASSERT(parentlogws);

LoadHFIRPDD loader;
loader.initialize();

loader.setPropertyValue("Filename", "HB2A_exp0231_scan0001.dat");
// loader.setPropertyValue("Filename", "HB2A_exp0231_scan0001.dat");
loader.setProperty("InputWorkspace", datatablews);
loader.setProperty("ParentWorkspace", parentlogws);
loader.setPropertyValue("OutputWorkspace", "HB2A_MD");

loader.execute();
Expand Down

0 comments on commit 3bbbe50

Please sign in to comment.