示例#1
0
 def test_get_factors(self):
     result = get_factors(
         np.asanyarray([
             2.2551711385, 2.478038901, 2.7001518288, 2.9214422642,
             3.1418428, 3.3612863, 3.5797059197, 3.7970351263
         ]), self.component_data)
     self.assertIsNotNone(result)
示例#2
0
文件: phases.py 项目: openafox/PyXRD
def get_structure_factors(range_stl, G, comp_list):
    """
        Calculates the structure factor and phase factor for:
        
            - range_stl: numpy array of 2*sin(θ) / λ values
            - G: the number of components (layer types)
            - comp_list: list of 
              :class:`~pyxrd.calculations.data_objects.ComponentData` instances
               
        This function calls :meth:`~pyxrd.calculations.components.get_factors`
        for each component in `comp_list` and stores the returned structure 
        factors and phase difference factors in a numpy array (of type complex)
        with shape (X, G) where X is expanded to fit the shape of `range_stl`.
    """
    shape = range_stl.shape + (G, )
    SF = np.zeros(shape, dtype=np.complex_)
    PF = np.zeros(shape, dtype=np.complex_)
    for i, comp in enumerate(comp_list):
        SF[:, i], PF[:, i] = get_factors(range_stl, comp)  # @UndefinedVariable
    return SF, PF
示例#3
0
def get_structure_factors(range_stl, G, comp_list):
    """
        Calculates the structure factor and phase factor for:
        
            - range_stl: numpy array of 2*sin(θ) / λ values
            - G: the number of components (layer types)
            - comp_list: list of 
              :class:`~pyxrd.calculations.data_objects.ComponentData` instances
               
        This function calls :meth:`~pyxrd.calculations.components.get_factors`
        for each component in `comp_list` and stores the returned structure 
        factors and phase difference factors in a numpy array (of type complex)
        with shape (X, G) where X is expanded to fit the shape of `range_stl`.
    """
    shape = range_stl.shape + (G,)
    SF = np.zeros(shape, dtype=np.complex_)
    PF = np.zeros(shape, dtype=np.complex_)
    for i, comp in enumerate(comp_list):
        SF[:, i], PF[:, i] = get_factors(range_stl, comp) # @UndefinedVariable
    return SF, PF
示例#4
0
 def get_factors(self, range_stl):
     """
     Get the structure factor for the given range of sin(theta)/lambda values.
     :param range_stl: A 1D numpy ndarray
     """
     return get_factors(range_stl, self.data_object)
示例#5
0
 def get_factors(self, range_stl):
     """
     Get the structure factor for the given range of sin(theta)/lambda values.
     :param range_stl: A 1D numpy ndarray
     """
     return get_factors(range_stl, self.data_object)
示例#6
0
 def test_get_factors(self):
     result = get_factors(
         np.asanyarray([2.2551711385, 2.478038901, 2.7001518288, 2.9214422642, 3.1418428, 3.3612863, 3.5797059197, 3.7970351263]),
         self.component_data
     )
     self.assertIsNotNone(result)