Created
March 23, 2017 16:30
-
-
Save chiahaoliu/8d3d162db55526e396ed7771852c6828 to your computer and use it in GitHub Desktop.
pure pyFAI integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""example to do pure pyFAI integration""" | |
import os | |
import tifffile as tif | |
from pyFAI.azimuthalIntegrator import AzimuthalIntegrator | |
def pyFAI_integrate(data_dir, poni_fp, npt=1450, mask=None): | |
"""helper function to integrate a series of images inside data_dir with geometry and mask provided | |
Parameters | |
---------- | |
data_dir : str | |
path to directory filled with images you want to integrate | |
poni_fp : str | |
filepath to poni file contains calibration parameters | |
npt : int, optional | |
number of integration grid. default to 1450. | |
mask : ndarray, optional | |
mask object that follows pyFAI logic. Default is None (no mask) | |
Example | |
------- | |
data_dir = '~/xpdUser/tiff_base/<my_sample_dir>/' | |
poni_fp = '~/xpdUser/config_base/<latest_poni_file>.poni' | |
mask = np.load('~/xpdUser/config_base/xpdacq_mask.npy') | |
pyFAI_integrate(data_dir, ponit_fp, mask=mask) | |
"""" | |
fn_list = os.listdir(data_dir) | |
az = AzimuthalIntegrator() | |
az.load(poni_fp) | |
print(az) # display calibration information displayed | |
total_num = len(fn_list) | |
for ind, fn in enumerate(fn_list): | |
stem, tail = os.path.splitext(fn) | |
print("INFO: integrate {}/{}".format(ind+1, total_num)) | |
img = tif.imread(os.path.join(data_dir, fn)) | |
az.integrate1d(img, npt, filename=stem, mask=mask) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment