Skip to content

Commit

Permalink
Fixed some minor issue and add doc. Refs #11098.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Mar 4, 2015
1 parent 4538f13 commit 10ff30d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 15 deletions.
Expand Up @@ -17,12 +17,12 @@ class SpiceXMLNode {
const std::string &nodedescription);
void setValue(const std::string &strvalue);

const bool hasUnit() const;
const bool hasValue() const;
bool hasUnit() const;
bool hasValue() const;

const bool isString() const;
const bool isInteger() const;
const bool isDouble() const;
bool isString() const;
bool isInteger() const;
bool isDouble() const;

const std::string getName() const;
const std::string getUnit() const;
Expand Down Expand Up @@ -83,7 +83,6 @@ class DLLExport LoadSpiceXML2DDet : public API::Algorithm {

///
void parseSpiceXML(const std::string &xmlfilename,
const std::string &detlogname, std::string &detstring,
std::map<std::string, SpiceXMLNode> &logstringmap);

///
Expand Down
19 changes: 10 additions & 9 deletions Code/Mantid/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp
Expand Up @@ -65,15 +65,15 @@ void SpiceXMLNode::setValues(const std::string &nodetype,
return;
}

const bool SpiceXMLNode::hasUnit() const { return (m_unit.size() > 0); }
bool SpiceXMLNode::hasUnit() const { return (m_unit.size() > 0); }

const bool SpiceXMLNode::hasValue() const { return (m_value.size() > 0); }
bool SpiceXMLNode::hasValue() const { return (m_value.size() > 0); }

const bool SpiceXMLNode::isString() const { return (m_typechar == STRING); }
bool SpiceXMLNode::isString() const { return (m_typechar == STRING); }

const bool SpiceXMLNode::isInteger() const { return (m_typechar == INT32); }
bool SpiceXMLNode::isInteger() const { return (m_typechar == INT32); }

const bool SpiceXMLNode::isDouble() const { return (m_typechar == FLOAT32); }
bool SpiceXMLNode::isDouble() const { return (m_typechar == FLOAT32); }

const std::string SpiceXMLNode::getName() const { return m_name; }
const std::string SpiceXMLNode::getUnit() const { return m_unit; }
Expand Down Expand Up @@ -132,7 +132,7 @@ void LoadSpiceXML2DDet::exec() {
// Parse
std::map<std::string, SpiceXMLNode> map_xmlnode;
std::string detvaluestr("");
parseSpiceXML(xmlfilename, detlogname, detvaluestr, map_xmlnode);
parseSpiceXML(xmlfilename, map_xmlnode);

size_t n = std::count(detvaluestr.begin(), detvaluestr.end(), '\n');
g_log.notice() << "[DB] detector string value = " << n << "\n" << detvaluestr
Expand All @@ -146,8 +146,8 @@ void LoadSpiceXML2DDet::exec() {
}

void LoadSpiceXML2DDet::parseSpiceXML(
const std::string &xmlfilename, const std::string &detlogname,
std::string &detstring, std::map<std::string, SpiceXMLNode> &logstringmap) {
const std::string &xmlfilename,
std::map<std::string, SpiceXMLNode> &logstringmap) {
// Open file
std::ifstream ifs;
ifs.open(xmlfilename.c_str());
Expand Down Expand Up @@ -246,7 +246,8 @@ MatrixWorkspace_sptr LoadSpiceXML2DDet::createMatrixWorkspace(
// Get node value string (256x256 as a whole)
SpiceXMLNode detnode = miter->second;
const std::string detvaluestr = detnode.getValue();
int numlines = std::count(detvaluestr.begin(), detvaluestr.end(), '\n');
size_t numlines = static_cast<size_t>(
std::count(detvaluestr.begin(), detvaluestr.end(), '\n'));
g_log.notice() << "[DB] Detector counts string contains " << numlines
<< "\n";

Expand Down
57 changes: 57 additions & 0 deletions Code/Mantid/docs/source/algorithms/LoadSpiceXML2DDet-v1.rst
@@ -0,0 +1,57 @@
.. algorithm::

.. summary::

.. alias::

.. properties::

Description
-----------

This algorithm is to import SPICE-generated XML file that
records data of one measurement by a (two-dimensional) Anger camera
and create a MatrixWorkspace to contain the detectors' counts, monitor counts
and other sample log data.


Format of SPICE XML data file
#########################

The SPICE XML data file contains four sections
- ???
- ???
- Parameters
- Counts

Each of them contains child nodes for detailed information, such as ...



Output Worskpaces
#################

One MatrixWorskpaces will be exported from the algorith.

'OutputWorkspace' is ...



Usage
-----

**Example - load a HB3A SPICE .xml file:**

.. testcode:: ExLoadHB3AMXLData


.. testcleanup:: ExLoadHB3AXMLData

#DeleteWorkspace(infows)

Output:

.. testoutput:: ExLoadHB3AXMLData


.. categories::

0 comments on commit 10ff30d

Please sign in to comment.