Skip to content

Commit

Permalink
Can load fit param from processed nexuse. re #6005
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders-Markvardsen committed Oct 25, 2012
1 parent 46eec87 commit 9516123
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
9 changes: 7 additions & 2 deletions Code/Mantid/Framework/API/src/ExperimentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ namespace API
for( Poco::StringTokenizer::Iterator itr = splitter.begin(); itr != iend; ++itr )
{
Poco::StringTokenizer tokens(*itr, ";");
if( tokens.count() != 4 ) continue;
if( tokens.count() < 4 ) continue;
std::string comp_name = tokens[0];
//if( comp_name == prev_name ) continue; this blocks reading in different parameters of the same component. RNT
//prev_name = comp_name;
Expand All @@ -1129,7 +1129,12 @@ namespace API
}
}
if( !comp ) continue;
pmap.add(tokens[1], comp, tokens[2], tokens[3]);
// create parameter's value as a sum of all tokens with index 3 or larger
// this allow a parameter's value to contain ";"
std::string paramValue = tokens[3];
for (int i = 4; i < tokens.count(); i++ )
paramValue += ";" + tokens[4];
pmap.add(tokens[1], comp, tokens[2], paramValue);
}
}

Expand Down
22 changes: 22 additions & 0 deletions Code/Mantid/Framework/DataHandling/test/LoadNexusProcessedTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,28 @@ class LoadNexusProcessedTest : public CxxTest::TestSuite

}

void test_load_fit_parameters()
{
LoadNexusProcessed alg;
TS_ASSERT_THROWS_NOTHING(alg.initialize());
TS_ASSERT( alg.isInitialized() );
alg.setPropertyValue("Filename", "HRP38692a.nxs");
alg.setPropertyValue("OutputWorkspace", "HRPDparameters");

TS_ASSERT_THROWS_NOTHING(alg.execute());

MatrixWorkspace_sptr ws;
ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("HRPDparameters");

// test to see if parameters are loaded
std::vector<boost::shared_ptr<const Mantid::Geometry::IComponent> > bankComp = ws->getInstrument()->getAllComponentsWithName("bank_bsk");

//std::cout << "kkkkkkkkkkkkkkkk " << bankComp.size() << " " << bankComp[0]->getParameterNames().size() << std::endl;

TS_ASSERT( bankComp[0]->getParameterNames().size() == 3 );
//TS_ASSERT_DELTA( bankComp->getNumberParameter("A")[0], 32.0, 0.0001);
}

private:
void doHistoryTest(MatrixWorkspace_sptr matrix_ws)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace Mantid

std::string m_formula; ///< the formula
std::string m_formulaUnit; ///< the unit that the formula expects
std::string m_resultUnit; ///<the rsult unit
std::string m_resultUnit; ///<the result unit

/// Static reference to the logger class
static Kernel::Logger& g_log;
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/Interpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MANTID_KERNEL_DLL Interpolation
std::vector<double> m_y;

/// method used for doing the interpolation
std::string m_name;
std::string m_method;

/// unit of x-axis
Unit_sptr m_xUnit;
Expand All @@ -76,10 +76,10 @@ class MANTID_KERNEL_DLL Interpolation
double value(const double& at) const;

/// set interpolation method
void setMethod(const std::string& method) { m_name=method; }
void setMethod(const std::string& method) { m_method=method; }

/// get interpolation method
std::string getMethod() const { return m_name; };
std::string getMethod() const { return m_method; };

/// set x-axis unit
void setXUnit(const std::string& unit);
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/Kernel/src/Interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Kernel

/** Constructor default to linear interpolation and x-unit set to TOF
*/
Interpolation::Interpolation() : m_name("linear")
Interpolation::Interpolation() : m_method("linear")
{
m_xUnit = UnitFactory::Instance().create("TOF");
m_yUnit = UnitFactory::Instance().create("TOF");
Expand Down Expand Up @@ -120,7 +120,7 @@ namespace Kernel
*/
void Interpolation::printSelf(std::ostream& os) const
{
os << m_name << " ; " << m_xUnit->unitID() << " ; " << m_yUnit->unitID();
os << m_method << " ; " << m_xUnit->unitID() << " ; " << m_yUnit->unitID();

for ( unsigned int i = 0; i < m_x.size(); i++)
{
Expand Down

0 comments on commit 9516123

Please sign in to comment.