at.load.json#

Handling of JSON files.

Functions

load_json(filename[, use, from_at, from_xsuite])

Create a Lattice from an AT or Xsuite JSON file.

save_json(ring[, filename, compact])

Save a Lattice as a JSON file.

load_json(filename, use=None, from_at=False, from_xsuite=False, **kwargs)[source]#

Create a Lattice from an AT or Xsuite JSON file.

The kind of file is derived from its contents. In case of ambiguity, the file kind can be explicitly selected with the from_at or from_xsuite keywords.

Parameters:
  • filename (str | Path) – Name of a JSON file

  • from_at (bool) – Force the selection of AT JSON file

  • from_xsuite (bool) – Force the selection of Xsuite JSON file

  • use (str | None) – Line name, for Xsuite files containing several lines. Default: ring

Keyword Arguments:

* – All keywords update the lattice properties

Returns:

lattice (Lattice) – New Lattice object

See also

Lattice.load() for a generic lattice-loading method.

save_json(ring, filename=None, compact=False)[source]#

Save a Lattice as a JSON file.

Parameters:
  • ring (Lattice) – Lattice description

  • filename (str | Path | None) – Name of the JSON file. Default: outputs on sys.stdout

  • compact (bool) – If False (default), the JSON file is pretty-printed with line feeds and indentation. Otherwise, the output is a single line.

See also

save_lattice() for a generic lattice-saving function. Lattice.save() for a generic lattice-saving method.