A package for handling and displaying data for atomic physics calculations
Project description
Atom-Toolkit
A Python package for manipulating atomic physics data in a notebook environment. It models atomic structure as a hierarchy of NetworkX graphs — gross-structure energy levels at the top, with hyperfine and Zeeman sublevels generated automatically on demand — and provides a convenient interface for working with spectroscopic data, transitions, and selection rules.
Features
- Load data directly from NIST ASD — fetch energy levels and transition data for any ion/neutral with a single call
- Three-layer level hierarchy —
EnergyLevel→HFLevel→ZLevel(Zeeman), each layer generated lazily the first time it is accessed - Rich key access for levels and transitions:
atom.levels['4f14.6s 2S1/2'] # gross level atom.levels['4f14.6s 2S1/2 F=0'] # hyperfine sublevel atom.levels['4f14.6s 2S1/2 F=0 mF=0'] # flat shorthand atom.levels['4f14.6s 2S1/2']['F=0'] # hyperfine sublevel atom.levels['4f14.6s 2S1/2']['F=0']['mF=0'] # flat shorthand atom.levels[1][0] # indexing by energy atom.levels[0:4] # indexing by energy atom.transitions[level_a, level_b] # order-independent
- Automatic sublevel transitions — setting a frequency or Einstein A coefficient on an
EnergyLeveltransition propagates down to all HF and Zeeman sub-transitions, applying the correct selection rules and angular-momentum weights - Support for LS, JJ, LK, and JK couplings, with quantum numbers extracted automatically from NIST-format configuration and term strings
- Branching ratios and lifetimes computed from A coefficients
- Grotrian diagrams and spectra — matplotlib-based plots of level structure and spectral lineshapes (in development)
- Serialisation — save/load atoms to disk as JSON for fast repeated use
Installation
pip install -e .
Dependencies: pint, pint-pandas, pandas, numpy, networkx, sympy, matplotlib, scipy, tqdm
Loading NIST data
The primary loader fetches data from the NIST ASD web API:
from atomtoolkit import IO
df = IO.load_NIST_data('Yb II')
If the API is unavailable (e.g. returns a 403 error), you can download a CSV manually instead:
- Go to https://physics.nist.gov/PhysRefData/ASD/levels_form.html
- Enter the species name (e.g.
Yb II), enable all output fields, and set Format = CSV - Save the file and load it with:
df = IO.load_NIST_data_from_csv('path/to/YbII.csv')
The bundled species in resources/ were downloaded this way and are used automatically by the species/ files.
Quick start
from atomtoolkit.atom import Atom
from atomtoolkit import IO, Q_
# Load level data — from the API or a local CSV
df = IO.load_NIST_data('Yb II') # live API
# df = IO.load_NIST_data_from_csv('resources/YbII.csv') # local fallback
a = Atom.from_dataframe(df, name='173Yb II', I=2.5)
# Set hyperfine coefficients on a gross level
d32 = a.levels['4f14.5d 2D3/2']
d32.hfA = Q_(-0.11, 'GHz')
d32.hfB = Q_(0.95, 'GHz')
b12 = a.levels['4f13.(2F*<7/2>).5d.6s.(3D) 3[3/2]*1/2']
b12.hfA = Q_(0.61, 'GHz')
# Set transition data — HF and Zeeman sub-transitions are updated automatically
repump_935 = a.transitions[b12, d32]
repump_935.A = Q_(120, 'kHz')
# Access individual sublevels
print(d32['F=2']['mF=-1'].level) # Hz energy including HF shift
print(repump_935.subtransitions()) # all HF sub-transitions with selection rules
Data model
Atom
├── EnergyLevel (gross structure — from NIST, in cm^-1 or Hz)
│ └── HFLevel (hyperfine — generated from A, B, C coefficients)
│ └── ZLevel (Zeeman — generated from gF factor)
│
└── Transition (gross — carries A coefficient, freq)
└── HFTransition
└── ZTransition (carries geometric coupling factors)
All quantities use a shared pint unit registry with a spectroscopy context, so .to('Hz') and .to('cm**-1') conversions work everywhere. The Q_() constructor creates dimensioned quantities using this registry.
Species files
The species/ directory contains ready-to-use atoms (171Yb II, 173Yb II, 174Yb II, 133Ba II, 6Li I) with hyperfine coefficients and corrected transitions applied. Load them with:
from species import Yb_II_171
a = Yb_II_171.atom # pre-built Atom object
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file atom_toolkit-0.2.0.tar.gz.
File metadata
- Download URL: atom_toolkit-0.2.0.tar.gz
- Upload date:
- Size: 75.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b413f3f92d87ac92a238de6e36bf174cdccb8969d0745a24216e9479899bb68
|
|
| MD5 |
8c281e15c63b8df6d79ba4531ad9230c
|
|
| BLAKE2b-256 |
1c57ccb0e1bc08ce459e0eda2f4f4b3c5d1f93ca5058fd1d3c8db50b9fbfc4da
|
File details
Details for the file atom_toolkit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: atom_toolkit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 62.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57e4b7aa9b6538c40d3d664dcac8c8c6ff8d605d51c6b098cad6af1be81464a8
|
|
| MD5 |
bbab1c584268b9e630dddbf4432de046
|
|
| BLAKE2b-256 |
2c12a91008a5de713bbc02502281cc7ed52ba78f9fabac1cf521efbc6cc598d2
|