Scripting 2D Powder Diffraction Data Reduction with Jython

Introduction

It is possible to access all the integration routines available in DAWN using the Jython scripting interface, but it is not a simple process (in version 1.6, this should be improved in future versions).

All the integration methods can be imported by with the following lines of code:

from uk.ac.diamond.scisoft.analysis.diffraction.powder import PixelSplittingIntegration as PSI
from uk.ac.diamond.scisoft.analysis.diffraction.powder import NonPixelSplittingIntegration as NPSI
from uk.ac.diamond.scisoft.analysis.diffraction.powder import NonPixelSplittingIntegration2D as NPSI2D
from uk.ac.diamond.scisoft.analysis.diffraction.powder import PixelSplittingIntegration2D as PSI2D

from uk.ac.diamond.scisoft.analysis.roi import ROIProfile
from uk.ac.diamond.scisoft.analysis.diffraction.powder import PixelIntegrationUtils as Putils
import uk.ac.diamond.scisoft.analysis.roi.XAxis as axis

The last two are needed to specify the axis type (q/2 theta/d/pixel), and perform any intensity correction.

To load in the metadata required to integrate the image you also need:

from uk.ac.diamond.scisoft.analysis.io import NexusDiffractionCalibrationReader as NexusMetaReader


With these imports a basic integration can be performed with the following lines of code:

meta = NexusMetaReader.getDiffractionMetadataFromNexus(r"Path/To/Your/Calibration/File.nxs",None)

#Load image data
data = dnp.io.load(r"Path/To/Your/Data.tiff")['image_name'][...]

#Create object to do integration [In this case pixel split](metadata, then number of bins)
integrator = PSI(meta, 2000)
#integrator = NPSI(meta, 2000)
#integrator = PSI2D(meta, 2000, 360)
#integrator.setAxisType(axis.ANGLE)

###
# 1D Azimuthal
###

#For full image, integrating azimuthally, in q only need to call
out = integrator.integrate(data._jdataset())
#out[0] is axis, out[1] is intensity
dnp.plot.line(out[0],out[1], name="Plot 1", title = "Full Image - non split")

Other options can be explored using methods on the integrator object or in the PixelIntegrationUtils class.