Python Interface for Particle Accelerator Language Standard (PALS) files.
PALSParserPy is a parser for the Particle Accelerator Language Standard
(PALS) for the Python language.
In addition, PALSParserPy provides translation functions:
- From
PALSfiles toBmadlattice files. - From
PALSfiles toMAD-Xlattice files. - From
PALSfiles to Python scripts that build anXsuite(xtrack) lattice.
For a translator from PALS to SciBmad,
use pals_to_scibmad in PALSParserJ.
For a translator from Bmad to PALS, the Bmad based Tao program can be used.
A translator from SciBmad to PALS is planned.
- 2026-08-05: Initial port of PALSParserJ, the Julia interface to the same C library.
Published PyPI wheels include the native parser and its dependencies:
pip install palsparserpy
# Or, in a uv project:
uv add palsparserpyWheels target Linux x86-64 (glibc 2.28+), macOS Intel/Apple silicon (11+), and Windows x86-64, with Python 3.10 or later. These installation commands require a release containing binary wheels (0.0.2 or later). Other platforms can build from the source distribution with CMake and a C++17 compiler (GCC 9+). The source distribution includes the pinned native sources.
Conda packages use the environment's separately packaged native library.
Explicit PALS_PARSER_CPP_LIB and PALS_PARSER_CPP_DIR overrides remain
available for development. For an external-library-only installation, set
PALS_BUNDLE_NATIVE=0 when building. Checkouts without a vendor/ directory default to that mode.
See release automation for native version updates, wheel checks, and initial PyPI configuration. See the installation guide for checkout development instructions.
import palsparserpy as pp
lat = pp.parse_and_expand_pals("lattice_files/ex.pals.yaml")
print(lat.full_expanded) # the expanded lattice, as YAML
pp.parameter_value(lat, "Q1a>length") # one parameter's value
pp.match_names(lat.full_expanded, "DH.*>BendP.e1") # the nodes a name selects
pp.write_bmad_file(pp.pals_to_bmad(pp.parse_file("lattice_files/bta.pals.yaml")),
"bta.bmad")For usage examples, see the runnable scripts in the examples directory, e.g.
python examples/read_pals.pyThey insert the repository root on sys.path, so they run from a checkout
whether or not the package has been installed.
Some examples are also provided as Jupyter notebooks (e.g.
examples/manipulate_tree.ipynb). To run them you need Jupyter:
pip install jupyter
jupyter notebook examples/manipulate_tree.ipynbpip install -e ".[test]"
pytestThe tests import the package from the checkout, so pip install -e . is
optional; the C library, however, must be built.
PALSParserPy is licensed under the GNU General Public License, version 2
only (GPL-2.0-only). See LICENSE.