本文整理汇总了Python中pyFAI.azimuthalIntegrator.AzimuthalIntegrator.tth方法的典型用法代码示例。如果您正苦于以下问题:Python AzimuthalIntegrator.tth方法的具体用法?Python AzimuthalIntegrator.tth怎么用?Python AzimuthalIntegrator.tth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyFAI.azimuthalIntegrator.AzimuthalIntegrator
的用法示例。
在下文中一共展示了AzimuthalIntegrator.tth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CalibrationModel
# 需要导入模块: from pyFAI.azimuthalIntegrator import AzimuthalIntegrator [as 别名]
# 或者: from pyFAI.azimuthalIntegrator.AzimuthalIntegrator import tth [as 别名]
class CalibrationModel(object):
def __init__(self, img_model=None):
"""
:param img_model:
:type img_model: ImgModel
"""
self.img_model = img_model
self.points = []
self.points_index = []
self.spectrum_geometry = AzimuthalIntegrator()
self.cake_geometry = None
self.calibrant = Calibrant()
self.start_values = {'dist': 200e-3,
'wavelength': 0.3344e-10,
'pixel_width': 79e-6,
'pixel_height': 79e-6,
'polarization_factor': 0.99}
self.orig_pixel1 = 79e-6
self.orig_pixel2 = 79e-6
self.fit_wavelength = False
self.fit_distance = True
self.is_calibrated = False
self.use_mask = False
self.filename = ''
self.calibration_name = 'None'
self.polarization_factor = 0.99
self.supersampling_factor = 1
self._calibrants_working_dir = os.path.dirname(calibrants.__file__)
self.cake_img = np.zeros((2048, 2048))
self.tth = np.linspace(0, 25)
self.int = np.sin(self.tth)
self.num_points = len(self.int)
self.peak_search_algorithm = None
def find_peaks_automatic(self, x, y, peak_ind):
"""
Searches peaks by using the Massif algorithm
:param x:
x-coordinate in pixel - should be from original image (not supersampled x-coordinate)
:param y:
y-coordinate in pixel - should be from original image (not supersampled y-coordinate)
:param peak_ind:
peak/ring index to which the found points will be added
:return:
array of points found
"""
massif = Massif(self.img_model._img_data)
cur_peak_points = massif.find_peaks([x, y], stdout=DummyStdOut())
if len(cur_peak_points):
self.points.append(np.array(cur_peak_points))
self.points_index.append(peak_ind)
return np.array(cur_peak_points)
def find_peak(self, x, y, search_size, peak_ind):
"""
Searches a peak around the x,y position. It just searches for the maximum value in a specific search size.
:param x:
x-coordinate in pixel - should be from original image (not supersampled x-coordinate)
:param y:
y-coordinate in pixel - should be form original image (not supersampled y-coordinate)
:param search_size:
the length of the search rectangle in pixels in all direction in which the algorithm searches for
the maximum peak
:param peak_ind:
peak/ring index to which the found points will be added
:return:
point found (as array)
"""
left_ind = np.round(x - search_size * 0.5)
if left_ind < 0:
left_ind = 0
top_ind = np.round(y - search_size * 0.5)
if top_ind < 0:
top_ind = 0
search_array = self.img_model.img_data[left_ind:(left_ind + search_size),
top_ind:(top_ind + search_size)]
x_ind, y_ind = np.where(search_array == search_array.max())
x_ind = x_ind[0] + left_ind
y_ind = y_ind[0] + top_ind
self.points.append(np.array([x_ind, y_ind]))
self.points_index.append(peak_ind)
return np.array([np.array((x_ind, y_ind))])
def clear_peaks(self):
self.points = []
self.points_index = []
def create_cake_geometry(self):
self.cake_geometry = AzimuthalIntegrator()
pyFAI_parameter = self.spectrum_geometry.getPyFAI()
pyFAI_parameter['polarization_factor'] = self.polarization_factor
pyFAI_parameter['wavelength'] = self.spectrum_geometry.wavelength
self.cake_geometry.setPyFAI(dist=pyFAI_parameter['dist'],
poni1=pyFAI_parameter['poni1'],
poni2=pyFAI_parameter['poni2'],
rot1=pyFAI_parameter['rot1'],
#.........这里部分代码省略.........
示例2: CalibrationData
# 需要导入模块: from pyFAI.azimuthalIntegrator import AzimuthalIntegrator [as 别名]
# 或者: from pyFAI.azimuthalIntegrator.AzimuthalIntegrator import tth [as 别名]
class CalibrationData(object):
def __init__(self, img_data=None):
self.img_data = img_data
self.points = []
self.points_index = []
self.spectrum_geometry = AzimuthalIntegrator()
self.calibrant = Calibrant()
self.start_values = {'dist': 200e-3,
'wavelength': 0.3344e-10,
'pixel_width': 79e-6,
'pixel_height': 79e-6,
'polarization_factor': 0.99}
self.orig_pixel1 = 79e-6
self.orig_pixel2 = 79e-6
self.fit_wavelength = False
self.fit_distance = True
self.is_calibrated = False
self.use_mask = False
self.filename = ''
self.calibration_name = 'None'
self.polarization_factor = 0.99
self.supersampling_factor = 1
self._calibrants_working_dir = os.path.dirname(Calibrants.__file__)
self.cake_img = np.zeros((2048, 2048))
self.tth = np.linspace(0, 25)
self.int = np.sin(self.tth)
def find_peaks_automatic(self, x, y, peak_ind):
"""
Searches peaks by using the Massif algorithm
:param x:
x-coordinate in pixel - should be from original image (not supersampled x-coordinate)
:param y:
y-coordinate in pixel - should be from original image (not supersampled y-coordinate)
:param peak_ind:
peak/ring index to which the found points will be added
:return:
array of points found
"""
massif = Massif(self.img_data._img_data)
cur_peak_points = massif.find_peaks([x, y])
if len(cur_peak_points):
self.points.append(np.array(cur_peak_points))
self.points_index.append(peak_ind)
return np.array(cur_peak_points)
def find_peak(self, x, y, search_size, peak_ind):
"""
Searches a peak around the x,y position. It just searches for the maximum value in a specific search size.
:param x:
x-coordinate in pixel - should be from original image (not supersampled x-coordinate)
:param y:
y-coordinate in pixel - should be form original image (not supersampled y-coordinate)
:param search_size:
the amount of pixels in all direction in which the algorithm searches for the maximum peak
:param peak_ind:
peak/ring index to which the found points will be added
:return:
point found (as array)
"""
left_ind = np.round(x - search_size * 0.5)
top_ind = np.round(y - search_size * 0.5)
x_ind, y_ind = np.where(self.img_data._img_data[left_ind:(left_ind + search_size),
top_ind:(top_ind + search_size)] == \
self.img_data._img_data[left_ind:(left_ind + search_size),
top_ind:(top_ind + search_size)].max())
x_ind = x_ind[0] + left_ind
y_ind = y_ind[0] + top_ind
self.points.append(np.array([x_ind, y_ind]))
self.points_index.append(peak_ind)
return np.array([np.array((x_ind, y_ind))])
def clear_peaks(self):
self.points = []
self.points_index = []
def create_cake_geometry(self):
self.cake_geometry = AzimuthalIntegrator()
pyFAI_parameter = self.spectrum_geometry.getPyFAI()
pyFAI_parameter['polarization_factor'] = self.polarization_factor
pyFAI_parameter['wavelength'] = self.spectrum_geometry.wavelength
self.cake_geometry.setPyFAI(dist=pyFAI_parameter['dist'],
poni1=pyFAI_parameter['poni1'],
poni2=pyFAI_parameter['poni2'],
rot1=pyFAI_parameter['rot1'],
rot2=pyFAI_parameter['rot2'],
rot3=pyFAI_parameter['rot3'],
pixel1=pyFAI_parameter['pixel1'],
pixel2=pyFAI_parameter['pixel2'])
self.cake_geometry.wavelength = pyFAI_parameter['wavelength']
def setup_peak_search_algorithm(self, algorithm, mask=None):
"""
Initializes the peak search algorithm on the current image
:param algorithm:
peak search algorithm used. Possible algorithms are 'Massif' and 'Blob'
#.........这里部分代码省略.........