Skip to content

Commit

Permalink
Begin work on translation of parameters re #7617
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Sep 17, 2013
1 parent 1c17fa2 commit b96fed5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/ITableWorkspace.h"

#include <Poco/DOM/Element.h>

namespace Mantid
{
namespace DataHandling
Expand Down Expand Up @@ -57,6 +59,12 @@ namespace DataHandling
/// Load file to a vector of strings
void loadFile(std::string filename, std::vector<std::string>& lines);

/// Add an ALFBE parameter
void addALFBEparameter(const API::ITableWorkspace_sptr & tablews, Poco::XML::Document* mDoc, Poco::XML::Element* parent, const std::string paramName);

// Translate a parameter name from as it appears in the table workspace to its name in the XML file
std::string getXMLParameterName( const std::string name );

/// Get row numbers of the parameters in the table workspace
void getTableRowNumbers(const API::ITableWorkspace_sptr & tablews, std::map<std::string, size_t>& parammap);

Expand Down
28 changes: 27 additions & 1 deletion Code/Mantid/Framework/DataHandling/src/ConvertFullprofToXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ namespace DataHandling
Element* instrumentElem = mDoc->createElement("component-link");
instrumentElem->setAttribute("name","wholeInstrument");
rootElem->appendChild(instrumentElem);
addALFBEparameter( paramTable, mDoc, instrumentElem, "Alph0");

// Add banks
if(paramTable->columnCount() < 2){
Expand All @@ -151,11 +152,36 @@ namespace DataHandling
return;
}

/* Add an ALFBE parameter to the XML document according to the table workspace
*
* paramName is the name of the parameter as it appears in the table workspace
*/
void ConvertFullprofToXML::addALFBEparameter(const API::ITableWorkspace_sptr & tablews, Poco::XML::Document* mDoc, Element* parent, const std::string paramName)
{
Element* parameterElem = mDoc->createElement("parameter");
parameterElem->setAttribute("name", getXMLParameterName(paramName));
parameterElem->setAttribute("type","fitting");
parent->appendChild(parameterElem);
}

/*
* Get the XML name of a parameter given its Table Workspace name
*/
std::string ConvertFullprofToXML::getXMLParameterName( const std::string name )
{
std::string prefix = "IkedaCarpenterPV:";
if(name == "Alph0") return prefix+"Alpha0";
if(name == "Beta0") return prefix+"Beta0";
if(name == "Alph1") return prefix+"Alpha1";
if(name == "Beta1") return prefix+"Kappa";
return "?"+name;
}

/* This function fills in a list of the row numbers starting 0 of the parameters
in the table workspace, so one can find the position in a column of
the value of the given parameter.
*/
void getTableRowNumbers(const API::ITableWorkspace_sptr & tablews, std::map<std::string, size_t>& parammap)
void ConvertFullprofToXML::getTableRowNumbers(const API::ITableWorkspace_sptr & tablews, std::map<std::string, size_t>& parammap)
{
parammap.clear();

Expand Down

0 comments on commit b96fed5

Please sign in to comment.