|
4 | 4 |
|
5 | 5 | from scipy.constants import epsilon_0, hbar, c |
6 | 6 | import numpy as np |
7 | | -import re |
| 7 | +import re |
8 | 8 | from .sensor_utils import expand_statespec |
9 | 9 |
|
10 | | -from typing import Union, Optional, Literal, Tuple, List, Dict, Callable, NamedTuple, Any |
11 | | - |
12 | | -from .exceptions import RydiquleError |
13 | | - |
14 | | -__all__ = [ |
15 | | - 'QSpec', |
16 | | - 'A_QState', |
17 | | - 'QState', |
18 | | - 'D1_excited', |
19 | | - 'D1_states', |
20 | | - 'D2_excited', |
21 | | - 'D2_states', |
22 | | - 'ground_state', |
23 | | - 'expand_qnums', |
24 | | - 'calc_eta', |
25 | | - 'calc_kappa', |
26 | | - 'validate_qnums', |
27 | | -] |
28 | | -__lazy_loads = [ |
29 | | - 'ATOMS' |
30 | | -] |
31 | | - |
32 | | -def __dir__() -> List[str]: |
33 | | - |
34 | | - return sorted(__all__ + __lazy_loads) |
35 | | - |
36 | | - |
37 | | -def __getattr__(name: str) -> Any: |
38 | | - |
39 | | - if name == 'ATOMS': |
40 | | - import arc.alkali_atom_data as arc_atoms |
41 | | - |
42 | | - ATOMS = { |
43 | | - 'H': arc_atoms.Hydrogen, |
44 | | - 'Li6': arc_atoms.Lithium6, 'Li7': arc_atoms.Lithium7, |
45 | | - 'Na': arc_atoms.Sodium, |
46 | | - 'K39': arc_atoms.Potassium39, 'K40': arc_atoms.Potassium40, 'K41': arc_atoms.Potassium41, |
47 | | - 'Rb85': arc_atoms.Rubidium85, 'Rb87': arc_atoms.Rubidium87, |
48 | | - 'Cs': arc_atoms.Caesium |
49 | | - } |
50 | | - """ |
51 | | - Alkali atoms defined by ARC that can be used with :class:`~.Cell`. |
52 | | - """ |
53 | | - return ATOMS |
54 | | - else: |
55 | | - raise AttributeError(f'Module {__name__} does not have attribute {name}') |
| 10 | +from typing import Union, Optional, Literal, Tuple, List, Dict, Callable, NamedTuple, TYPE_CHECKING |
| 11 | + |
| 12 | +from .exceptions import RydiquleError, AtomError |
| 13 | + |
| 14 | +if TYPE_CHECKING: |
| 15 | + import arc.alkali_atom_data |
| 16 | + |
| 17 | +ATOMS = { |
| 18 | + 'H': 'Hydrogen', |
| 19 | + 'Li6': 'Lithium6', 'Li7': 'Lithium7', |
| 20 | + 'Na': 'Sodium', |
| 21 | + 'K39': 'Potassium39', 'K40': 'Potassium40', 'K41': 'Potassium41', |
| 22 | + 'Rb85': 'Rubidium85', 'Rb87': 'Rubidium87', |
| 23 | + 'Cs': 'Caesium' |
| 24 | +} |
| 25 | +""" |
| 26 | +Alkali atoms defined by ARC that can be used with :class:`~.Cell`. |
| 27 | +""" |
| 28 | + |
| 29 | +def _load_arc_atom(atom_flag: str) -> 'arc.alkali_atom_data.Alkali_Atom': |
| 30 | + """ |
| 31 | + Function that lazy loads ARC atoms from :external+arc:module:`~arc.alkali_atom_data` |
| 32 | +
|
| 33 | + Returns |
| 34 | + ------- |
| 35 | + arc.alkali_atom_data.Alkali_Atom |
| 36 | + ARC alkali atom class associated with the provided atom_flag. |
| 37 | + """ |
| 38 | + |
| 39 | + import arc.alkali_atom_data as arc_atoms |
| 40 | + |
| 41 | + if atom_flag not in ATOMS.keys(): |
| 42 | + raise AtomError(f"Atom flag must be one of {ATOMS.keys()}") |
| 43 | + |
| 44 | + return getattr(arc_atoms, ATOMS[atom_flag])() # instantiate the class here |
56 | 45 |
|
57 | 46 |
|
58 | 47 | ground_n = { |
|
0 commit comments