Skip to content

Commit 7a6ca3e

Browse files
committed
Enhances enums with descriptive methods
1 parent e40a5b2 commit 7a6ca3e

File tree

1 file changed

+38
-0
lines changed
  • src/easydiffraction/experiments/experiment

1 file changed

+38
-0
lines changed

src/easydiffraction/experiments/experiment/enums.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class SampleFormEnum(str, Enum):
1414
def default(cls) -> 'SampleFormEnum':
1515
return cls.POWDER
1616

17+
def description(self) -> str:
18+
if self is SampleFormEnum.POWDER:
19+
return 'Powdered or polycrystalline sample.'
20+
elif self is SampleFormEnum.SINGLE_CRYSTAL:
21+
return 'Single crystal sample.'
22+
1723

1824
class ScatteringTypeEnum(str, Enum):
1925
"""Type of scattering modeled in an experiment."""
@@ -25,6 +31,12 @@ class ScatteringTypeEnum(str, Enum):
2531
def default(cls) -> 'ScatteringTypeEnum':
2632
return cls.BRAGG
2733

34+
def description(self) -> str:
35+
if self is ScatteringTypeEnum.BRAGG:
36+
return 'Bragg diffraction for conventional structure refinement.'
37+
elif self is ScatteringTypeEnum.TOTAL:
38+
return 'Total scattering for pair distribution function analysis (PDF).'
39+
2840

2941
class RadiationProbeEnum(str, Enum):
3042
"""Incident radiation probe used in the experiment."""
@@ -36,6 +48,12 @@ class RadiationProbeEnum(str, Enum):
3648
def default(cls) -> 'RadiationProbeEnum':
3749
return cls.NEUTRON
3850

51+
def description(self) -> str:
52+
if self is RadiationProbeEnum.NEUTRON:
53+
return 'Neutron diffraction.'
54+
elif self is RadiationProbeEnum.XRAY:
55+
return 'X-ray diffraction.'
56+
3957

4058
class BeamModeEnum(str, Enum):
4159
"""Beam delivery mode for the instrument."""
@@ -47,6 +65,12 @@ class BeamModeEnum(str, Enum):
4765
def default(cls) -> 'BeamModeEnum':
4866
return cls.CONSTANT_WAVELENGTH
4967

68+
def description(self) -> str:
69+
if self is BeamModeEnum.CONSTANT_WAVELENGTH:
70+
return 'Constant wavelength (CW) diffraction.'
71+
elif self is BeamModeEnum.TIME_OF_FLIGHT:
72+
return 'Time-of-flight (TOF) diffraction.'
73+
5074

5175
class PeakProfileTypeEnum(str, Enum):
5276
"""Available peak profile types per scattering and beam mode."""
@@ -77,3 +101,17 @@ def default(
77101
(ScatteringTypeEnum.TOTAL, BeamModeEnum.CONSTANT_WAVELENGTH): cls.GAUSSIAN_DAMPED_SINC,
78102
(ScatteringTypeEnum.TOTAL, BeamModeEnum.TIME_OF_FLIGHT): cls.GAUSSIAN_DAMPED_SINC,
79103
}[(scattering_type, beam_mode)]
104+
105+
def description(self) -> str:
106+
if self is PeakProfileTypeEnum.PSEUDO_VOIGT:
107+
return 'Pseudo-Voigt profile'
108+
elif self is PeakProfileTypeEnum.SPLIT_PSEUDO_VOIGT:
109+
return 'Split pseudo-Voigt profile with empirical asymmetry correction.'
110+
elif self is PeakProfileTypeEnum.THOMPSON_COX_HASTINGS:
111+
return 'Thompson-Cox-Hastings profile with FCJ asymmetry correction.'
112+
elif self is PeakProfileTypeEnum.PSEUDO_VOIGT_IKEDA_CARPENTER:
113+
return 'Pseudo-Voigt profile with Ikeda-Carpenter asymmetry correction.'
114+
elif self is PeakProfileTypeEnum.PSEUDO_VOIGT_BACK_TO_BACK:
115+
return 'Pseudo-Voigt profile with Back-to-Back Exponential asymmetry correction.'
116+
elif self is PeakProfileTypeEnum.GAUSSIAN_DAMPED_SINC:
117+
return 'Gaussian-damped sinc profile for pair distribution function (PDF) analysis.'

0 commit comments

Comments
 (0)