Bases: object
provide methods for integration, variance calculation and distance/Q matrix calculation etc.
calculate the 1D intensity
Parameters: | pic – 2D array, array of raw counts, raw counts should be corrected |
---|---|
Retrun : | 1d array, 1D integrated intensity |
calculate the 1D intensity
Parameters: | pic – 2D array, array of raw counts, raw counts should be corrected |
---|---|
Retrun : | 1d array, variance of integrated intensity |
calculate the variance of raw counts of each pixel are calculated according to their loacl variance.
Parameters: | picflat – 1d array, flattend image array |
---|---|
Returns: | 2d array, variance of each pixel |
attribute forwarded to self.config, read-only
generate correction matrix. multiple the 2D raw counts array by this correction matrix to get corrected raw counts. It will calculate solid angle correction or polarization correction.
Returns: | 2d array, correction matrix to apply on the image |
---|
Calculate the distance matrix
Returns: | 2d array, distance between source and each pixel |
---|
generate self.bin_number used in integration
Parameters: | mask – mask 2D array, same dimension as image, 1 for masked pixel |
---|---|
Returns: | self.bin_number |
Calculate the q matrix
Returns: | 2d array, q value of each pixel’s center |
---|
Calculate the diffraction angle matrix
Returns: | 2d array, two theta angle of each pixel’s center |
---|
generate a twotheta matrix or q matrix which stores the tth or q value or each pixel
attribute forwarded to self.config, read-only
2D to 1D image integration, intensity of pixels are binned and then take average,
Parameters: | pic – 2D array, array of raw counts, raw counts should be corrected |
---|---|
Retrun : | 2d array, [tthorq, intensity, unceratinty] or [tthorq, intensity] |
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
prepare data for calculation
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
Bases: object
provide methods to filter files and load images
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
flip image if configured in config
Parameters: | pic – 2d array, image array |
---|---|
Returns: | 2d array, flipped image array |
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
generate the list of file in opendir according to include/exclude pattern
Parameters: |
|
---|---|
Returns: | list of str, a list of filenames (not include their full path) |
generate the list of file in opendir according to include/exclude pattern
Parameters: |
|
---|---|
Returns: | set of str, a list of filenames (not include their full path) |
attribute forwarded to self.config, read-only
load image, then subtract the background if configed in self.backgroundpic.
Parameters: | filename – str, image file name |
---|---|
Returns: | 2d ndarray, 2d image array (flipped) |
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
Bases: object
provide methods for mask generation, including:
static mask: fit2d (.msk) mask, tif mask, npy mask, masking edge pixels, dymanic mask: masking dead pixels, bright pixels
attribute forwarded to self.config, read-only
pixels with much higher intensity compare to adjacent pixels will be masked, this mask is used when there are some bright spots/pixels whose intensity is higher than its neighbors but not too high. Only use this on a very good powder averaged data. Otherwise it may mask wrong pixels.
This mask has similar functions as ‘selfcorr’ function. However, this mask will only consider pixels’ local neighbors pixels and tend to mask more pixels. While ‘selfcorr’ function compare one pixel to other pixels in same bin.
Parameters: |
|
---|---|
Returns: | 2d array of boolean, 1 stands for masked pixel |
pixels with much lower intensity compare to adjacent pixels will be masked
Parameters: | pic – 2d array, image array to be processed |
---|---|
Returns: | 2d array of boolean, 1 stands for masked pixel |
create a dynamic mask according to image array. This mask changes for different images
Parameters: |
|
---|---|
Returns: | 2d array of boolean, 1 stands for masked pixel |
mask the pixels near edge and around corner
Parameters: | edges – list of int (length of 5), first 4 are numbers of pixels masked at each edge in (left, right, top, bottom), last one is the radius of round cut at the corner |
---|---|
Returns: | 2d array of boolean, 1 stands for masked pixel |
flip image if configured in config
Parameters: | pic – 2d array, image array |
---|---|
Returns: | 2d array, flipped image array |
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
generate a mask according to the addmask and pic. save it to .npy. 1 stands for masked pixel the mask has same order as the pic, which means if the pic is flipped, the mask is fliped (when pic is loaded though loadimage, it is flipped)
Parameters: |
|
---|---|
Returns: | 2d array of boolean, 1 stands for masked pixel |
create a static mask according existing mask file. This mask remain unchanged for different images
Parameters: | addmask – list of string, file name of mask and/or ‘edge’, mask file supported: .msk, .npy, .tif file, ATTN: mask array should be already flipped, and 1 (or larger) stands for masked pixels, 0(<0) stands for unmasked pixels if ‘edge’ is specified here. it will create a mask that mask the pixel near the edge of detector, require self.maskedges |
---|---|
Returns: | 2d array of boolean, 1 stands for masked pixel |
a special mask used for undesampling image. It will create a mask that discard (total number*(1-undersamplerate)) pixels :param undersamplerate: float, 0~1, ratio of pixels to keep
Returns: | 2d array of boolean, 1 stands for masked pixel |
---|
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
Bases: object
save results into files
attribute forwarded to self.config, read-only
get the normalized full path of filename with out extension
Parameters: | filename – string, could be full path or file name only and with/without ext, only the base part of filename is used. |
---|---|
Returns: | string, full normalized path of file without extension |
attribute forwarded to self.config, read-only
attribute forwarded to self.config, read-only
save diffraction intensity in .chi and gsas format(optional)
Parameters: | rv – dict, result include integrated diffration intensity the rv[‘chi’] should be a 2d array with shape (2,len of intensity) or (3, len of intensity) file name is generated according to orginal file name and savedirectory |
---|
save diffraction intensity in .chi
Parameters: |
|
---|
save diffraction intensity in gsas format
Parameters: |
|
---|
attribute forwarded to self.config, read-only
Return string of integrated intensities in GSAS format. :param mode: string, gsas file type, could be ‘std’, ‘esd’, ‘fxye’ (gsas format) :param tth: ndarray, two theta angle :param iobs: ndarray, Xrd intensity :param esd: ndarray, optional error value of intensity
Returns: | string, a string to be saved to file |
---|
srxplanar main modular
Bases: object
main modular for srxplanar
create and save a mask according to addmask, pic, 1 stands for masked pixel in saved file
Parameters: |
|
---|---|
Returns: | 2d array, 1 stands for masked pixel here |
integrate 2d image to 1d diffraction pattern, then save to disk
Parameters: |
|
---|---|
Returns: | dict, rv[‘chi’] is a 2d array of integrated intensity, shape is (2, len of intensity) or (3, len of intensity) in [tth or q, intensity, (uncertainty)]. rv[‘filename’] is the name of file to save to disk |
process all file in filelist, integrate them separately or together
Parameters: |
|
---|---|
Returns: | list of dict, in each dict, rv[‘chi’] is a 2d array of integrated intensity, shape is (2, len of intensity) or (3, len of intensity) as [tth or q, intensity, (uncertainty)]. rv[‘filename’] is the name of file to save to disk |
prepare data used in calculation
Parameters: | pic – str, list of str, or 2d array, if provided, then recalculate dynamic mask, using pic |
---|---|
Returns: | None |
process the images according to filenames/includepattern/excludepattern/summation by default, it will scan current/tifdirectory and integrate all files match includepattern/excludepattern and/or filenames.
Usually this one is called from cmd line rather then script.
Returns: | None |
---|
update config using configfile/args/kwargs, then rerun all prepareCalculation()
Parameters: |
|
---|---|
Returns: | None |
read config and integrate images
Bases: diffpy.confutils.config.ConfigBase
config class, based on ConfigBase class in diffpy.confutils
calculate the max twotheta angle (and q) of a detector with current geometry
Parameters: | config – SrXplanarConfig, config instance stores the geometry parameters |
---|---|
Returns: | [tthmaxd, qmax], max twotheta angle(in degree) and max q value of current detector. |
load parameters from fit2d calibration information. copy/paste the fit2d calibration results to a txt file. this function will load xbeamcenter, ybeamceter... from the file
Parameters: | filename – str, file name (with full path if not in current dir) of fit2d file, or a string containing the calibraiton parameters copy from fit2d. |
---|---|
Returns: | dict, including ‘xbeamcenter’, ‘ybeamcenter’, ‘wavelength’, ‘rotationd’(angle of ratation), ‘tiltd’(angle of tilt rotation) |
Definition of __version__, __date__, __gitsha__.