v1.0.0
New Features
Pydantic data models for Tao state (pytao.model)
PyTao now provides Pydantic v2 models that represent the live state of Tao. These models can be queried from Tao, modified in Python, and applied back.
TaoConfig— captures the complete configuration of a Tao session: startup parameters,BmadCom,SpaceChargeCom,BeamInit,Beam,TaoGlobal, and per-element overrides.
config = tao.get_config()
config.beam_init.a_emit = 1e-8
config.set(tao) # apply all settings
config.set(tao, only_changed=True) # apply only what changed
- Settings sub-models —
BmadCom,SpaceChargeCom,BeamInit,Beam, andTaoGlobalcan also be used independently:
from pytao.model import BeamInit
beam_init = BeamInit.from_tao(tao)
beam_init.a_emit = 1e-6
with beam_init.set_context(tao):
# temporarily applied; restored on exit
...
Element— structured representation of a lattice element with head metadata, general attributes, Twiss parameters, orbit, transfer matrix, floor coordinates, multipoles, wake fields, chamber walls, and more. Data loading is controlled per-field.
ele = tao.ele("Q00W")
ele.twiss.beta_a
ele.attrs["k1"].data
ele.floor.end.actual.x
-
Lattice— a collection ofElementobjects with lookup by name, key, or index. Multiple constructors:from_tao_tracking,from_tao_unique,from_tao_eles. -
tao.eles()— query multiple elements using Tao's full element matching syntax (wildcards, ranges, key filters):
quads = tao.eles("quad::*")
eles_1_to_20 = tao.eles("1:20")
-
Serialization — all models support
.write()/.from_file()for JSON,.json.gz, msgpack, and YAML.ormsgpackis used for the (recommended and fastest) serialization method msgpack, whileorjsonis used for faster-than-stdlib JSON serialization. These are both new requirements. -
Code generation —
TaoGlobal,BeamInit, etc. are auto-generated from Bmad/Tao structure definitions (scripts/structs.json) viamodel/codegen.py.
ParticleGroup helper
tao.particles()— is a new shortcut to get an openPMD-BeamPhysicsParticleGroupinstance for a given element.
P = tao.particles("quad::Q1") # type: beamphysics.ParticleGroup
P.plot("x", "px")
Session archiving
tao.archive(directory)writes a self-contained, reproducible archive: the current lattice (viawrite bmad), a Tao command file with allsetcommands, and a bash script that re-launches the session.
sh_file, cmd_file = tao.archive("my_archive")
config.write_bash_loader_script()provides lower-level control over archive generation (custom Tao binary, prefix, optional lattice export).
CLI argument handling rework
TaoStartupnow parses all Tao command-line arguments the same way Tao does, rather than juggling a free-forminitstring alongside individual attributes.- Fixes for
pytao -commandwhich Tao had silently been ignoring; PyTao now handles it correctly. - All arguments are documented consistently in
pytao --help.
Error handling improvements
- More consistent error handling between
SubprocessTaoandTao: Tao messages from pipe command output are handled consistently between the regular Tao and the subprocess variant. - Filtered messages from pipe commands are redirected to Python logging.
- Added
PYTAO_LIB_PATHenvironment variable to force PyTao to use a specificlibtao.so.
Other Changes
- Autogenerated interface commands are now a mixin class
(
_TaoAutogeneratedCommandMixin), simplifying development. - Python 3.14 compatibility fixes.
- Better support for
pip-based (PyPI) installs with proper dependency listings. - Import cleanups and fixes throughout the codebase.
- Type annotations for auto-generated Tao
pipeinterface routines. - Small performance improvements in subprocess
- Subprocess tests reuse a single
SubprocessTaoinstance by default (setTAO_REUSE_SUBPROCESS=1), speeding up CI.
Backward Incompatible Changes
- Python 3.10+ is now required.
- Bmad >=20260317 is also now required for all features to behave as designed.
- Removed legacy
tao_interfaceandtao_pexpect. - Removed
pytao-guientrypoint andpytao.guisubmodule. - Removed the largely defunct
as_dictparameter from all interface commands. TaoStartup.initattribute was removed. The free-form init string is now parsed into individual attributes. It is still accepted as an initializer argument:TaoStartup(init="-lat foo.lat").
v0.5.7
What's Changed
- Fix Derivative Parser by @electronsandstuff in https://github.com/bmad-sim/pytao/pull/148
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.5.6...v0.5.7
v0.5.6
What's Changed
- DOC: release process by @ken-lauer in https://github.com/bmad-sim/pytao/pull/146
- FIX: handle potential empty string case for pytypes by @ken-lauer in https://github.com/bmad-sim/pytao/pull/147
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.5.5...v0.5.6
v0.5.5
What's Changed
- Fix FODO notebook by @ChristopherMayes in https://github.com/bmad-sim/pytao/pull/145
- Add parsers for the new
lord_controlandslave_controlTao pipe commands by @ChristopherMayes in https://github.com/bmad-sim/pytao/pull/144
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.5.4...v0.5.5
v0.5.4
What's Changed
- ENH: add Tao.from_lattice_contents by @ken-lauer in https://github.com/bmad-sim/pytao/pull/137
- Added that ACC_ENABLE_SHARED_ONLY=Y is acceptable. by @DavidSagan in https://github.com/bmad-sim/pytao/pull/142
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.5.3...v0.5.4
v0.5.3
What's Changed
- ENH: unique element ID helpers by @ken-lauer in https://github.com/bmad-sim/pytao/pull/135
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.5.2...v0.5.3
v0.5.2
What's Changed
- MAINT: rebuild interface for 'lat_header' by @ken-lauer in https://github.com/bmad-sim/pytao/pull/134
- DOC: add floor plan plot with ParticleGroup plot overlays example by @ken-lauer in https://github.com/bmad-sim/pytao/pull/110
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.5.1...v0.5.2
v0.5.1
What's Changed
- PERF: PyTao plotting performance has been improved.
- FIX: Overlapping plot regions should no longer affect PyTao's internal plotting mechanism.
Pull Requests
- PERF: use array buffer methods for plot curve line/symbol data retrieval by @ken-lauer in https://github.com/bmad-sim/pytao/pull/133
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.5.0...v0.5.1
v0.5.0
Changes
-
Bug fix: Tao refused to initialize after the very first initialization attempt failed.
-
Enhanced and reworked the
pytaocommand-line interface - If in a directory with a
tao.initfile, PyTao can be started with just runningpytaowith no arguments. -
IPython is used if available, though the regular Python interpreter will be used as a backup.
-
For the command-line interface, as in JupyterLab mode,
%taoand%%taomagics allow you to send commands directly to the Tao command-line. - For example:
%tao show lat - An even shorter shortcut is the input transformer.
-
This shortcut can be customized with the
--pyprefixargument. Every IPython line that starts with this character will turn into atao.cmd()line. It defaults to the backtick character (i.e., the key typically shared by tilde~) -
For example, noting the backtick:
In [1]: ` show lat
- A preliminary Tao input mode is also available that behaves like the standard Tao command-line. Tab completion is offered for top-level commands and element names (in certain scenarios). To access it, either use
tao.shell()or the single backtick shortcut:
In [1]: `
Tao> show lat
- New command-line arguments:
--helpto see PyTao and Tao's command-line options--pyplotto configure PyTao's plotting backend (mplorbokeh)--pyscriptto run a Python script after Tao initialization--pycommandto run a Python command after Tao initialization--pylogset the Python log level--pyno-subprocessuseTaoinstead ofSubprocessTao--pyquietto hide the banner when startingpytao--pytaoto go straight to Tao mode without initializing aTaoobject
Issues
#130#129#128#101
Screenshots
The input transformer:
Tao> command-line mode:
Element name tab completion in Tao> command-line mode:
What's Changed
- ENH:
pytaoCLI rework with tab completion/magics + fixes forTaoInitializationErrorby @ken-lauer in https://github.com/bmad-sim/pytao/pull/131
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.4.8...v0.5.0
v0.4.8
What's Changed
- FIX: Tao.track_beam() case issue by @ken-lauer in https://github.com/bmad-sim/pytao/pull/127
Full Changelog: https://github.com/bmad-sim/pytao/compare/v0.4.7...v0.4.8
Changes
-
pytaoimport speed was improved when not using plotting libraries. -
In
Tao.track_beam: - Bug fix: case sensitivity of track_start/track_end elements could cause
Tao.track_beamto fail. - Add support for
Tao.track_beam(start, end)to set the track start/end positions easily - Add support for setting
lattice_calc_onautomatically (and resetting it afterward)
Issues
#126
v0.4.7
Changes
pytaonow requires Bmad 20250226 or later.- Added
Tao.track_beam()which (by default) displays a progress bar while settingtrack_type = beam. - Added new module
pytao.pbarwhich helps with progress-bar related tools - For now, this is limited to beam tracking updates with track_beam_wrapper, a context manager which allows you to perform arbitrary Tao commands while it displays beam tracking status
-
Auto-detection of JupyterLab to determine which type of progress bar to use (CLI vs Jupyter widget)
-
Bug fix: layout plots may raise an exception in taking the
max()of an emptyele_y2slist. -
Added support for new
-quietflags fromTao.
Issues
Closed #119 Closed #120
Screenshots
- Using PyTao in Jupyter Lab:
https://github.com/user-attachments/assets/ed987e51-119b-4da0-96f6-b0c20135a451
- Using PyTao in the terminal:
https://github.com/user-attachments/assets/667e92bf-08b0-49f7-9abb-ad396ab9a3e2
v0.4.8
Changes
-
pytaoimport speed was improved when not using plotting libraries. -
In
Tao.track_beam: - Bug fix: case sensitivity of track_start/track_end elements could cause
Tao.track_beamto fail. - Add support for
Tao.track_beam(start, end)to set the track start/end positions easily - Add support for setting
lattice_calc_onautomatically (and resetting it afterward)
Issues
Closed #126
v0.5.0
Changes
-
Bug fix: Tao refused to initialize after the very first initialization attempt failed.
-
Enhanced and reworked the
pytaocommand-line interface - If in a directory with a
tao.initfile, PyTao can be started with just runningpytaowith no arguments. -
IPython is used if available, though the regular Python interpreter will be used as a backup.
-
For the command-line interface, as in JupyterLab mode,
%taoand%%taomagics allow you to send commands directly to the Tao command-line. - For example:
%tao show lat - An even shorter shortcut is the input transformer.
-
This shortcut can be customized with the
--pyprefixargument. Every IPython line that starts with this character will turn into atao.cmd()line. It defaults to the backtick character (i.e., the key typically shared by tilde~) -
For example, noting the backtick:
In [1]: ` show lat
- A preliminary Tao input mode is also available that behaves like the
standard Tao command-line. Tab completion is offered for top-level commands
and element names (in certain scenarios). To access it, either use
tao.shell()or the single backtick shortcut:
In [1]: `
Tao> show lat
- New command-line arguments:
--helpto see PyTao and Tao's command-line options--pyplotto configure PyTao's plotting backend (mplorbokeh)--pyscriptto run a Python script after Tao initialization--pycommandto run a Python command after Tao initialization--pylogset the Python log level--pyno-subprocessuseTaoinstead ofSubprocessTao--pyquietto hide the banner when startingpytao--pytaoto go straight to Tao mode without initializing aTaoobject
Issues
Closed #130 Closed #129 Closed #128 Closed #101
Screenshots
The input transformer:
Tao> command-line mode:
Element name tab completion in Tao> command-line mode: