@@ -136,7 +136,8 @@ def two_theta_to_q(two_theta: float, xray_wavelength: float) -> float:
136
136
def grain_to_hwhm (
137
137
tau : float , two_theta : float , K : float = 0.9 , wavelength : float | str = "CuKa"
138
138
) -> float :
139
- """_summary_
139
+ """Calculate the half-width half-max (alpha or gamma) for a given grain size and
140
+ angle.
140
141
141
142
Args:
142
143
tau (float): grain size in nm
@@ -197,7 +198,7 @@ def _sub_layouts(self) -> dict[str, Component]:
197
198
help_str = "This defines the wavelength of the incident X-ray radiation." ,
198
199
options = [
199
200
{
200
- "label" : f'{ name .replace ("a" , "α" ).replace ("b" , "β" )} ({ wavelength :.3f} Å)' ,
201
+ "label" : f'{ name .replace ("a" , "α" ).replace ("b" , "β" )} ({ wavelength :.3f} Å)' , # noqa: RUF001
201
202
"value" : name ,
202
203
}
203
204
for name , wavelength in WAVELENGTHS .items ()
@@ -243,7 +244,7 @@ def _sub_layouts(self) -> dict[str, Component]:
243
244
self .get_choice_input (
244
245
kwarg_label = "x_axis" ,
245
246
state = state ,
246
- label = "Choice of 𝑥 axis" ,
247
+ label = "Choice of x axis" ,
247
248
help_str = "Can choose between 2𝜃 or Q, where Q is the magnitude of the reciprocal lattice and "
248
249
"independent of radiation source." , # TODO: improve
249
250
options = [
@@ -293,10 +294,7 @@ def layout(self, static_image: bool = False) -> Columns:
293
294
Columns: from crystal_toolkit.helpers.layouts
294
295
"""
295
296
sub_layouts = self ._sub_layouts
296
- if static_image :
297
- inner = sub_layouts ["static_image" ]
298
- else :
299
- inner = sub_layouts ["graph" ]
297
+ inner = sub_layouts ["static_image" ] if static_image else sub_layouts ["graph" ]
300
298
301
299
return Columns (
302
300
[
@@ -355,11 +353,8 @@ def get_figure(
355
353
num_sigma = {"G" : 5 , "L" : 12 , "V" : 12 }[peak_profile ]
356
354
357
355
# optimal number of points per degree determined through usage experiments
358
- if grain_size > 10 :
359
- # scaled to log size to the 4th power
360
- N_density = 150 * (math .log10 (grain_size ) ** 4 )
361
- else :
362
- N_density = 150
356
+ # scaled to log size to the 4th power
357
+ N_density = 150 * (math .log10 (grain_size ) ** 4 ) if grain_size > 10 else 150
363
358
364
359
N = int (N_density * domain ) # num total points
365
360
0 commit comments