Skip to content

Commit

Permalink
Documentation for LoadDetectorsGroupingFile. Refs #9571
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiSavici committed Jun 16, 2014
1 parent 8acb1ca commit 631a8a2
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 79 deletions.
Expand Up @@ -55,7 +55,7 @@ namespace DataHandling
///
virtual const std::string name() const { return "LoadDetectorsGroupingFile";};
///Summary of algorithms purpose
virtual const std::string summary() const {return "Load an XML or Map file, which contains definition of detectors grouping, to a GroupingWorkspace).";}
virtual const std::string summary() const {return "Load an XML or Map file, which contains definition of detectors grouping, to a GroupingWorkspace.";}

/// Algorithm's version for identification
virtual int version() const { return 1;};
Expand Down
209 changes: 131 additions & 78 deletions Code/Mantid/docs/source/algorithms/LoadDetectorsGroupingFile-v1.rst
Expand Up @@ -36,50 +36,47 @@ Parameters
- "ids": a node to define that all detectors of the spectrum whose ID
's defined by "ids" will be grouped together.

Example 1:

.. raw:: html

<?xml version="1.0" encoding="UTF-8" ?>

| `` ``\
| ``  ``\
| ``   ``\ \ ``3,34-44,47``\
| ``   ``\ \ ``bank21``\
| ``  ``\
| ``   ``\ \ ``bank26``\
| ``  ``\
| `` ``\
Example 2:

.. raw:: html

<?xml version="1.0" encoding="UTF-8" ?>

| `` ``\
| ``  ``\
| ``   ``\ \ ``3,34-44,47``\
| ``   ``\ \ ``bank21``\
| ``  ``\
| ``   ``\ \ ``bank26``\
| ``  ``\
| `` ``\
Example 3:

.. raw:: html

<?xml version="1.0" encoding="UTF-8" ?>

| `` ``\
| ``  ``\
| ``   ``\ \ ``3,34-44,47``\
| ``  ``\
| ``   ``\ \ ``26``\
| ``   ``\ \ ``27,28``\
| ``  ``\
| `` ``\
Example 1 (using detector IDs and explicit group ID):

.. code:: xml
<?xml version="1.0" encoding="UTF-8" ?>
<detector-grouping instrument="VULCAN">
<group ID="4">
<detids>28750-29981</detids>
<component>bank21</component>
<group ID="5">
<component>bank26</component>
</group>
</detector-grouping>
Example 2 (using detector IDs and default group ID):

.. code:: xml
<?xml version="1.0" encoding="UTF-8" ?>
<detector-grouping instrument="VULCAN">
<group>
<detids>28750-29981</detids>
<component>bank21</component>
<group>
<component>bank26</component>
</group>
</detector-grouping>
Example 3 (using spectra number - note that no instrument is required):

.. code:: xml
<?xml version="1.0" encoding="UTF-8" ?>
<detector-grouping>
<group ID="1">
<ids>3,34-44,47</ids>
<group ID="2">
<ids>26</ids>
<ids>27,28</ids>
</group>
</detector-grouping>
Map File Format
---------------
Expand All @@ -89,17 +86,21 @@ Extension: .map
The file must have the following format\* (extra space and comments
starting with # are allowed) :

| `` "unused number1"             ``
| `` "unused number2"``
| `` "number_of_input_spectra1"``
| `` "input spec1" "input spec2" "input spec3" "input spec4"``
| `` "input spec5 input spec6"``
| `` **    ``
| `` "unused number2" ``
| `` "number_of_input_spectra2"``
| `` "input spec1" "input spec2" "input spec3" "input spec4"``
.. code:: python
\* each phrase in "" is replaced by a single integer
"unused number1"
"unused number2"
"number_of_input_spectra1"
"input spec1" "input spec2" "input spec3" "input spec4"
"input spec5 input spec6"
**
"unused number2"
"number_of_input_spectra2"
"input spec1" "input spec2" "input spec3" "input spec4"
\* each phrase in " " is replaced by a single integer

\*\* the section of the file that follows is repeated once for each
group
Expand All @@ -112,28 +113,80 @@ is ignored and can be any integer (not necessarily the same integer)

An example of an input file follows:

| `` 3  ``
| `` 1  ``
| `` 64  ``
| `` 1 2 3 4 5 6 7 8 9 10  ``
| `` 11 12 13 14 15 16 17 18 19 20  ``
| `` 21 22 23 24 25 26 27 28 29 30  ``
| `` 31 32 33 34 35 36 37 38 39 40  ``
| `` 41 42 43 44 45 46 47 48 49 50  ``
| `` 51 52 53 54 55 56 57 58 59 60  ``
| `` 61 62 63 64  ``
| `` 2  ``
| `` 60``
| `` 65 66 67 68 69 70 71 72 73 74  ``
| `` 75 76 77 78 79 80 81 82 83 84  ``
| `` 85 86 87 88 89 90 91 92 93 94  ``
| `` 95 96 97 98 99 100 101 102 103 104  ``
| `` 105 106 107 108 109 110 111 112 113 114  ``
| `` 115 116 117 118 119 120 121 122 123 124``
| `` 3``
| `` 60``
| `` 125 126 127 - 180 181 182 183 184``
==

.. code:: python
3
1
64
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64
2
60
65 66 67 68 69 70 71 72 73 74
75 76 77 78 79 80 81 82 83 84
85 86 87 88 89 90 91 92 93 94
95 96 97 98 99 100 101 102 103 104
105 106 107 108 109 110 111 112 113 114
115 116 117 118 119 120 121 122 123 124
3
60
125 126 127 - 180 181 182 183 184
Usage
-----
.. testcode:: LoadDetectorsGroupingFile

# create some grouping file
import mantid
filename=mantid.config.getString("defaultsave.directory")+"test.xml"
f=open(filename,'w')
f.write('<?xml version="1.0" encoding="UTF-8" ?> \n')
f.write('<detector-grouping instrument="VULCAN"> \n')
f.write(' <group ID="1"> \n')
f.write(' <detids>28750-29981</detids> \n')
f.write(' <component>bank23</component> \n')
f.write(' </group> \n')
f.write(' <group ID="2"> \n')
f.write(' <component>bank26</component> \n')
f.write(' <component>bank27</component> \n')
f.write(' </group> \n')
f.write(' </detector-grouping>')
f.close()

#load the grouping file
ws=LoadDetectorsGroupingFile("test.xml")
sid=0
print "Detector "+ws.getDetector(sid).getName()+", with ID "+\
str(ws.getDetector(sid).getID())+ ", in spectrum "+str(sid)+\
" belongs to group "+str(int(ws.dataY(sid)[0]))
sid=2500
print "Detector "+ws.getDetector(sid).getName()+", with ID "+\
str(ws.getDetector(sid).getID())+ ", in spectrum "+str(sid)+\
" belongs to group "+str(int(ws.dataY(sid)[0]))
sid=5000
print "Detector "+ws.getDetector(sid).getName()+", with ID "+\
str(ws.getDetector(sid).getID())+ ", in spectrum "+str(sid)+\
" belongs to group "+str(int(ws.dataY(sid)[0]))

.. testcleanup:: LoadDetectorsGroupingFile

DeleteWorkspace(ws)
import os,mantid
filename=mantid.config.getString("defaultsave.directory")+"test.xml"
os.remove(filename)

Output:

.. testoutput:: LoadDetectorsGroupingFile

Detector bank23(0,0), with ID 26250, in spectrum 0 belongs to group 1
Detector bank21(4,4), with ID 28786, in spectrum 2500 belongs to group 1
Detector bank27(9,0), with ID 33822, in spectrum 5000 belongs to group 2

.. categories::

0 comments on commit 631a8a2

Please sign in to comment.