\(\renewcommand\AA{\unicode{x212B}}\)
SaveDetectorsGrouping v1¶
Summary¶
Save a GroupingWorkspace to an XML file.
See Also¶
Properties¶
Name |
Direction |
Type |
Default |
Description |
---|---|---|---|---|
InputWorkspace |
Input |
GroupingWorkspace |
Mandatory |
GroupingWorkspace to output to XML file (GroupingWorkspace) |
OutputFile |
Input |
string |
Mandatory |
File to save the detectors mask in XML format. Allowed extensions: [‘.xml’] |
SaveUngroupedDetectors |
Input |
boolean |
True |
Whether to write out group number 0, the ungrouped group. |
Description¶
This algorithm is used to save a GroupingWorkspace to XML file in a format which is accepted by LoadDetectorsGroupingFile v1.
Usage¶
Example - Saving a custom grouping for MUSR instrument:
import os
result = CreateGroupingWorkspace(InstrumentName = 'MUSR')
grouping = result[0]
# Add spectra 1 - 16 to group 1
for i in range(0,16):
grouping.dataY(i)[0] = 1
# Add spectra 17 - 33 to group 2
for i in range(16,33):
grouping.dataY(i)[0] = 2
# Spectra 34 - 64 are left in group 0, i.e. are left unused
save_path = os.path.join(config["defaultsave.directory"], "musr_det_grouping.xml")
SaveDetectorsGrouping(grouping, save_path)
with open(save_path, 'r') as f:
print(f.read().replace('\t', ' ').strip())
Output:
<?xml version="1.0"?>
<detector-grouping idf-date="1900-01-31T23:59:59" instrument="MUSR">
<group ID="0">
<detids>34-64</detids>
</group>
<group ID="1">
<detids>1-16</detids>
</group>
<group ID="2">
<detids>17-33</detids>
</group>
</detector-grouping>
Categories: AlgorithmIndex | DataHandling\Grouping | Transforms\Grouping
Source¶
C++ header: SaveDetectorsGrouping.h
C++ source: SaveDetectorsGrouping.cpp