\(\renewcommand\AA{\unicode{x212B}}\)

GenerateGroupingPowder v1

Summary

Generate grouping by angles.

See Also

LoadDetectorsGroupingFile, GroupDetectors

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

A workspace from which to generate the grouping.

GroupingWorkspace

Output

GroupingWorkspace

The grouping workspace created

AngleStep

Input

number

Mandatory

The polar angle step for grouping, in degrees.

AzimuthalStep

Input

number

360

The azimuthal angle step for grouping, in degrees.

AzimuthalStart

Input

number

0

The azimuthal angle start location, in degrees.

NumberByAngle

Input

boolean

True

If true, divide sphere into groups labeled by angular sector.Empty parts of the instrument will effectively have group numbers that do not exist in the output.If false, labels will be assigned in order of highest angle.

FileFormat

Input

string

xml

File extension/format for saving output: either xml (default) or nxs/nx5. Allowed values: [‘xml’, ‘nxs’, ‘nx5’]

GroupingFilename

Input

string

A grouping file that will be created. Allowed values: [‘xml’, ‘nxs’, ‘nx5’]

GenerateParFile

Input

boolean

True

If true, a par file with a corresponding name to the grouping file will be generated. Ignored if grouping file is not specified.

Description

For powder samples, with no texture, the scattering consists only of rings. This algorithm reads a workspace and an angle step, then generates a grouping file (.xml or .nxs) and an optional par file (.par), by grouping detectors in one of several methods:

  • Divide ring into circular sectors labeled i*step to (i+1)*step (see note below). The original and default behavior.

  • Divide sphere into spherical sectors, similarly to above but including azimuthal angles (see note below). Use NumberByAngle set to true and specify AzimuthalStep and AzimuthalStart.

  • Divide ring into circular sectors labeled in order, from large 2theta to low 2theta. Use NumberByAngle set to false and specify only AngleStep (or set AzimuthalStep to its default at 360).

  • Divide ring into circular sectors labeled in order, splitting left/right sides from large 2theta to low 2theta. One side is labeled first, then the other. Use NumberByAngle set to false, specify AngleStep, and specify AzimuthalStep as anything other than 360.

The par file is required for saving in the NXSPE format, since Mantid does not correctly calculate the angles for detector groups. It will contain average distances to the detector groups, and average scattering angles. The x and y extents in the par file are radians(step)*distance and 0.01, and are not supposed to be accurate. A par file can only be saved using the original default labeling scheme.

The grouping file (.xml) can be used with GroupDetectors to perform the grouping.

Note

The default behavior of this algorithm presents a conflict with the conventions used for GroupingWorkspace. In the default labeling, low angels (from 0 to step) would be given the group label of 0. However, GroupingWorkspace and algorithms calling it ignore groups with the label of 0, treating this as invalid data. To enable the use of a GroupingWorkspace to hold the grouping data, the labels created by the ring and spherical sector methods are increased by 1 inside the GroupingWorkspace, so that no group is labeled 0. However, to maintain consistent behavior with previous code, when saved to an XML file all group IDs are decreased by 1, so that group ID of 0 appears. This means that ifor this case the group IDs from the GroupingWorkspace will be 1 higher than the group IDs in the output XML file. This is the simplest way to create consistency with two conflicting conventions, without modifying old behavior.

Usage

Note

To run these usage examples please first download the usage data, and add these to your path. In Mantid this is done using Manage User Directories.

# create some grouping file
import mantid
outputFilename=mantid.config.getString("defaultsave.directory")+"powder.xml"

#load some file
ws=Load("CNCS_7860")

#generate the files
GenerateGroupingPowder(ws,10, GroupingFilename=outputFilename)

#check that it works
import os.path
if(os.path.isfile(outputFilename)):
    print("Found file powder.xml")
if(os.path.isfile(mantid.config.getString("defaultsave.directory")+"powder.par")):
    print("Found file powder.par")
wsg=GroupDetectors(ws,outputFilename)
print("The grouping workspace has {} histograms".format(wsg.getNumberHistograms()))

Output:

Found file powder.xml
Found file powder.par
The grouping workspace has 14 histograms

Similarly, one could instead specify the grouping workspace:

#load some file
ws=Load("CNCS_7860")
gws_name= "a_nice_name_for_grouping_workspace"

#generate the files
GenerateGroupingPowder(ws,10, GroupingWorkspace=gws_name)

#check that it works
gws = mtd[gws_name]
print("The grouping workspace has {} histograms".format(gws.getNumberHistograms()))

Output:

The grouping workspace has 51200 histograms

If one would use LoadDetectorsGroupingFile on powder.xml one would get a workspace that looks like

GenerateGroupingPowder.png

Categories: AlgorithmIndex | DataHandling\Grouping | Transforms\Grouping | Diffraction\Utility

Source

C++ header: GenerateGroupingPowder.h

C++ source: GenerateGroupingPowder.cpp