-
Notifications
You must be signed in to change notification settings - Fork 19
3. Description of usage
To use pygix
one must first create and instance of the Transform
class. You will interact with this object, to set the experimental details and reduce your data. Here is an example of creating an instance of the Transform
class, setting the detector geometry with a .poni
file:
import pygix
pg = pygix.Transform()
pg.load('detector_calibration.poni')
Alternatively one can set the detector geometry by passing the values directly when instantiating the class:
pg = pygix.Transform(dist=0.2076, poni1=0.0943, poni2=0.1157,
rot1=0.00859, rot2=0.00174, rot3=0.0,
wavelength=9.5373, detector='Eiger4M')
The sample geometry parameters are set as follows:
pg.sample_orientation = 2 # a vertical geometry
pg.incident_angle = 0.2
pg.tilt_angle = -1.46
By default, sample_orientation = 1
for the standard horizontal geometry, and incident_angle
and tilt_angle
are zero.
A number of additional files can be specified to be considered when processing data. These include mask files (image arrays of the same size as the detector, where pixels to be ignored have a value of 1 and valid pixels have a value of 0), flat-field and dark-current images. If the detector is specified, a mask (if relevant) will be used, e.g., for the dead regions between modules in a Pilatus detector. However, one may wish to also create a separate mask file to mask off other irrelevant regions of data, such as beam stops, flight tubes, sample holder etc. Masks can be made with the pyFAI-drawmask
command line tool. These correction files can be passed as follows:
# passing paths to the images
pg.maskfile = '/data/correction_files/detector_mask.edf'
pg.flatfiles = '/data/correction_files/flat_0001.edf'
pg.darkfiles = '/data/correction_files/dark_0001.edf'
Note that for the dark current and flat field, one can pass a list of files. All of the supplied files will be averaged and the resulting array will be stored in as class attributes. Alternatively, one can pass numpy
arrays directly as follows:
# passing arrays
pg.mask = mask_array
pg.flatfield = flat_array
pg.darkcurrent = dark_array
Transforming into reciprocal space:
import fabio # library for loading X-ray images
data = fabio.open('datafile_0000.edf').data
intensity, qxy, qz = pg.transform_reciprocal(data, filename='datafile_0000_rsm.edf')
Transforming into angular coordinates:
intensity, alp_f, tth_f = pg.transform_angular(data)
Transforming into polar coordinates:
intensity, q_abs, chi = pg.transform_polar(data, npt=(1000, 720))
Sector integration:
i, q = pg.profile_sector(data, npt=1000, chi_pos=0, chi_width=20,
radial_range=(0, 20), unit='q_nm^-1')
Chi integration:
i, chi = pg.profile_chi(data, npt=200, radial_pos=7.7, radial_width=1.0,
chi_range=(-60, 60))
Out-of-plane box integration:
i, qz = pg.profile_op_box(data, npt=1000, ip_pos=13.23, ip_width=0.2,
op_range=(0, 32))
In-plane box integration:
i, qxy = pg.profile_ip_box(data, npt=1000, op_pos=1.2, op_width=1.0,
ip_range=(0, 28))
There are some tools for easy plotting GIXS data built into pygix.plotting
for 2D and 1D data. These handle all the default plotting options like axis labels etc.
from pygix import plotting as ppl
i, qxy, qz = pg.transform_reciprocal(data)
ppl.implot(i, qxy, qz, mode='rsm')
i, qz = pg.profile_sector(data, 1000, chi_pos=0, chi_width=20,
radial_range=(0, 20))
ppl.plot(i, qz)