本文整理汇总了Python中pyFAI.azimuthalIntegrator.AzimuthalIntegrator.polarization方法的典型用法代码示例。如果您正苦于以下问题:Python AzimuthalIntegrator.polarization方法的具体用法?Python AzimuthalIntegrator.polarization怎么用?Python AzimuthalIntegrator.polarization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyFAI.azimuthalIntegrator.AzimuthalIntegrator
的用法示例。
在下文中一共展示了AzimuthalIntegrator.polarization方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_mask_builder
# 需要导入模块: from pyFAI.azimuthalIntegrator import AzimuthalIntegrator [as 别名]
# 或者: from pyFAI.azimuthalIntegrator.AzimuthalIntegrator import polarization [as 别名]
def run_mask_builder(exposure=300, dark_sub_bool=True,
polarization_factor=0.99,
sample_name=None, calib_dict=None,
mask_dict=None, save_name=None):
""" function to generate mask
this function will execute a count scan and generate a mask based on
image collected from this scan.
Parameters
----------
exposure : float, optional
exposure time of this scan. default is 300s.
dark_sub_bool : bool, optional
turn on/off of dark subtraction. default is True.
polarization_factor: float, optional.
polarization correction factor, ranged from -1(vertical) to +1
(horizontal). default is 0.99. set to None for no correction.
sample_name : str, optional
name of sample that new mask is going to be generated from.
default is 'mask_target'
calib_dict : dict, optional
dictionary with parameters for geometry correction
software. default is read out from glbl attribute (parameters
from the most recent calibration)
mask_dict : dict, optional
dictionary for arguments in masking function. for more details,
please check docstring from ``xpdan.tools.mask_img``
save_name : str, optional
full path for this mask going to be saved. if it is None,
default name 'xpdacq_mask.npy' will be saved inside
xpdUser/config_base/
Note
----
current software dealing with geometry correction is ``pyFAI``
See also
--------
xpdan.tools.mask_img
"""
_check_obj(_REQUIRED_OBJ_LIST)
ips = get_ipython()
bto = ips.ns_table['user_global']['bt']
xrun = ips.ns_table['user_global']['xrun']
# default behavior
if sample_name is None:
sample_name = 'mask_target'
if mask_dict is None:
mask_dict = glbl.mask_dict
print("INFO: use mask options: {}".format(mask_dict))
if calib_dict is None:
calib_dict = getattr(glbl, 'calib_config_dict', None)
if calib_dict is None:
print("INFO: there is no glbl calibration dictionary linked\n"
"Please do ``run_calibration()`` or provide your own"
"calibration parameter set")
return
# setting up geometry parameters
ai = AzimuthalIntegrator()
ai.setPyFAI(**calib_dict)
# scan
mask_collection_uid = str(uuid.uuid4())
mask_builder_dict = {'sample_name':sample_name,
'sample_composition':{sample_name :1},
'is_mask': True,
'mask_collection_uid': mask_collection_uid}
sample = Sample(bto, mask_builder_dict)
xrun_uid = xrun(sample, ScanPlan(bto, ct, exposure))
light_header = glbl.db[-1]
if dark_sub_bool:
dark_uid = light_header.start['sc_dk_field_uid']
dark_header = glbl.db[dark_uid]
dark_img = np.asarray(glbl.db.get_images(dark_header,
glbl.det_image_field)).squeeze()
for ev in glbl.db.get_events(light_header, fill=True):
img = ev['data'][glbl.det_image_field]
if dark_sub_bool:
img -= dark_img
img /= ai.polarization(img.shape, polarization_factor)
mask = mask_img(img, ai, **mask_dict)
print("INFO: add mask to global state")
glbl.mask = mask
if save_name is None:
save_name = os.path.join(glbl.config_base, glbl.mask_md_name)
# still save the most recent mask, as we are in file-based
np.save(save_name, mask)
return mask