Skip to main content

A JSON based lattice file format

Project description


LatticeJSON is a JSON based lattice file format. JSON is able to describe complex data structures, has a human readable syntax and is available in all common programming language. It is therefore an appropriate choice to characterize the magnetic lattice of a particle accelerator.


This repository contains the Specification of LatticeJSON in form of a JSON Schema.


A LatticeJSON file for a FODO lattice:

  "version": "2.2",
  "title": "FODO Lattice",
  "info": "This is the simplest possible strong focusing lattice.",
  "root": "ring",
  "elements": {
    "d1": ["Drift", {"length": 0.55}],
    "q1": ["Quadrupole", {"length": 0.2, "k1": 1.2}],
    "q2": ["Quadrupole", {"length": 0.4, "k1": -1.2}],
    "b1": ["Dipole", {"length": 1.5, "angle": 0.392701, "e1": 0.1963505, "e2": 0.1963505}]
  "lattices": {
    "cell": ["q1", "d1", "b1", "d1", "q2", "d1", "b1", "d1", "q1"],
    "ring": ["cell", "cell", "cell", "cell", "cell", "cell", "cell", "cell"]


Python Version PyPI CI

This repository also contains a Python based command-line tool which is able validate and convert LatticeJSON files into other common lattice file formats and vice versa.

You can install and update it using pip or pipenv:

pip install -U latticejson

Validate a LatticeJSON file:

latticejson validate /path/to/lattice.json

Convert an elegant lattice file to the LatticeJSON format:

latticejson convert --to json /path/to/lattice.lte

Autoformat one or more LatticeJSON files:

latticejson autoformat /path/to/lattice.json ...

To activate Bash completion add

eval "$(_LATTICEJSON_COMPLETE=source latticejson)"

to your .bashrc. Or, create an activation script with:

_LATTICEJSON_COMPLETE=source latticejson >


GNU General Public License v3.0

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for LatticeJSON, version 0.1.5
Filename, size File type Python version Upload date Hashes
Filename, size LatticeJSON-0.1.5-py3-none-any.whl (28.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size LatticeJSON-0.1.5.tar.gz (10.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page