Child pages
  • Scripting 2D Powder Diffraction Data Reduction with Jython
Skip to end of metadata
Go to start of metadata


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 import PixelSplittingIntegration as PSI
from import NonPixelSplittingIntegration as NPSI
from import NonPixelSplittingIntegration2D as NPSI2D
from import PixelSplittingIntegration2D as PSI2D

from import ROIProfile
from import PixelIntegrationUtils as Putils
import 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 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 ="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)

# 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.

  • No labels