The PeaksWorkspace is a special Workspace that holds a list of single crystal Peak objects.
Each peak object contains several pieces of information. Not all of them are necessary:
Each Peak object contains a PeakShape. Only the integration algorithms which act on, and return PeaksWorkspaces set the shape of the peaks. The PeakShape is owned by the Peak, not the PeaksWorkspace, so when PeaksWorkspaces are split, or concatinated, the integration shapes are unaltered. Aside from the Null Peak Shape, each peak shape contains at least the following information.
Subtypes of PeakShape will then provide additional information. For example PeakShapeSpherical provides the radius as well as background inner, and background outer radius.
The PeaksWorkspace and Peak objects are exposed to python.
pws = mtd['name_of_peaks_workspace']
pws.getNumberOfPeaks()
p = pws.getPeak(12)
pws.removePeak(34)
You can get a handle to an existing peak with:
p = pws.getPeak(12)
Or you can create a new peak in this way:
qlab = V3D(1.23, 3.45, 2.22) # Q in the lab frame of the peak
detector_distance = 2.5 # sample-detector distance in meters. Detector distances are optional. Calculated in not provided.
p = pws.createPeak(qlab, detector_distance)
# The peak can later be added to the workspace
pws.addPeak(p)
Once you have a handle on a peak “p” you have several methods to query/modify its values:
hkl = p.getHKL()
p.setHKL(-5, 4, 3)
q = p.getQSampleFrame()
q = p.getQLabFrame()
detid = p.getDetectorID()
p.setIntensity(1000.0)
p.setSigmaIntensity(31.6)
counts = p.getIntensity()
wl = p.getWavelength()
tof = p.getTOF()
d = p.getDSpacing()
shape = p.getPeakShape()
Category: Concepts