Skip to content

Commit

Permalink
excitation_function---> shape_factor_model
Browse files Browse the repository at this point in the history
  • Loading branch information
pc494 committed Sep 3, 2020
1 parent bebba5f commit cbf11da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions diffsims/generators/diffraction_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def calculate_ed_data(
structure,
reciprocal_radius,
rotation=(0, 0, 0),
excitation_function="linear",
shape_factor_model="linear",
max_excitation_error=1e-2,
with_direct_beam=True,
**kwargs
Expand All @@ -113,7 +113,7 @@ def calculate_ed_data(
rotation : tuple
Euler angles, in degrees, in the rzxz convention. Default is (0,0,0)
which aligns 'z' with the electron beam
excitation_function : function or str
shape_factor_model : function or str
a function that takes excitation_error and max_excitation_error (and potentially **kwargs) and returns an intensity
scaling factor. The code provides "linear" and "binary" options accessed with by parsing the associated strings
max_excitation_error : float
Expand All @@ -122,7 +122,7 @@ def calculate_ed_data(
If True, the direct beam is included in the simulated diffraction
pattern. If False, it is not.
**kwargs :
passed to excitation_function
passed to shape_factor_model
Returns
-------
Expand Down Expand Up @@ -162,12 +162,12 @@ def calculate_ed_data(
excitation_error = excitation_error[intersection]
g_hkls = spot_distances[intersection]

if excitation_function == "linear":
if shape_factor_model == "linear":
shape_factor = 1 - (excitation_error / max_excitation_error)
elif excitation_function == "binary":
elif shape_factor_model == "binary":
shape_factor = 1
else:
shape_factor = excitation_function(
shape_factor = shape_factor_model(
excitation_error, max_excitation_error, **kwargs
)

Expand Down
4 changes: 2 additions & 2 deletions diffsims/tests/test_generators/test_diffraction_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ def test_shape_factor_strings(
self, diffraction_calculator, local_structure, string
):
_ = diffraction_calculator.calculate_ed_data(
local_structure, 2, excitation_function=string
local_structure, 2, shape_factor_model=string
)

def test_shape_factor_custom(self, diffraction_calculator, local_structure):
def local_excite(excitation_error, maximum_excitation_error, t):
return (np.sin(t) * excitation_error) / maximum_excitation_error

_ = diffraction_calculator.calculate_ed_data(local_structure, 2,excitation_function=local_excite, t=0.2)
_ = diffraction_calculator.calculate_ed_data(local_structure, 2,shape_factor_model=local_excite, t=0.2)

def test_calculate_profile_class(self, local_structure, diffraction_calculator):
# tests the non-hexagonal (cubic) case
Expand Down

0 comments on commit cbf11da

Please sign in to comment.