Visualize Twiss parameters for one- or two-dimensional grid scan of lattice parameters.
Project description
TwissGrid
This application performs one- or two-dimensional grid scans of lattice parameters and visualizes their effect on selected optics functions.
Installation
The application can be installed from the Python Package Index (PyPI):
pip install twissgrid
Usage
The application can be used from the command line in the following way:
python -m twissgrid /path/to/script.madx a_param
It expects at least two arguments:
- The file path to a MADX script.
- The name of a lattice parameter. It needs to be given as
label->attr
where the->attr
part is optional (it will be inferred from the element type). The corresponding element must be accessible in MADX via the providedlabel
(internally the parameter will be updated aslabel->attr = value;
so that must be an effective statement).
This example will create a 2D-plot of the beta functions in dependence on that parameter:
3D Plots
A second parameter can be provided, following the first one, in order to perform a two-dimensional parameter scan and create a corresponding 3D-plot:
python -m twissgrid /path/to/script.madx a_param b_param
Customization
The application supports various other arguments for customizing the parameter scan or the resulting plots.
The full set of available parameters can be found via --help
:
$ python -m twissgrid --help
usage: python -m twissgrid [-h] [--p1lb P1LB] [--p1ub P1UB]
[--p1delta P1DELTA] [--p1margin P1MARGIN]
[--p1n P1N] [--p2lb P2LB] [--p2ub P2UB]
[--p2delta P2DELTA] [--p2margin P2MARGIN]
[--p2n P2N] [--funcs FUNCS [FUNCS ...]]
[--target TARGET] [--beta0 BETA0]
[--threshold [THRESHOLD [THRESHOLD ...]]]
[--figsize FIGSIZE FIGSIZE]
script p1 [p2]
positional arguments:
script File path to MADX script
p1 Lattice parameter 1 (format: label[->attribute])
p2 Lattice parameter 2 (format: label[->attribute])
(default: None)
optional arguments:
-h, --help show this help message and exit
--funcs FUNCS [FUNCS ...]
Optics functions to plot (default: ('betx', 'bety'))
--target TARGET Label of the target element where optics functions are
observed (default: #e)
--beta0 BETA0 Label of BETA0 command (this must be part of the MADX
script) (default: None)
--threshold [THRESHOLD [THRESHOLD ...]]
Plot threshold line on each optics plot (default:
None)
--figsize FIGSIZE FIGSIZE
Figure size in inches (default: (14, 10))
Parameter 1:
--p1lb P1LB Lower boundary for parameter scan (default: None)
--p1ub P1UB Upper boundary for parameter scan (default: None)
--p1delta P1DELTA Compute missing boundaries as a distance to the
current value (i.e. "lb = value - delta" and "ub =
value + delta"); --delta takes precedence over
--margin (default: None)
--p1margin P1MARGIN Compute missing boundaries as a fraction of the
current value (i.e. "lb = (1 - margin)*value" and "ub
= (1 + margin)*value") (default: 0.01)
--p1n P1N Number of grid points for parameter scan (default:
100)
Parameter 2:
--p2lb P2LB Lower boundary for parameter scan (default: None)
--p2ub P2UB Upper boundary for parameter scan (default: None)
--p2delta P2DELTA Compute missing boundaries as a distance to the
current value (i.e. "lb = value - delta" and "ub =
value + delta"); --delta takes precedence over
--margin (default: None)
--p2margin P2MARGIN Compute missing boundaries as a fraction of the
current value (i.e. "lb = (1 - margin)*value" and "ub
= (1 + margin)*value") (default: 0.01)
--p2n P2N Number of grid points for parameter scan (default:
100)
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
File details
Details for the file TwissGrid-0.3.tar.gz
.
File metadata
- Download URL: TwissGrid-0.3.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/34.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4b472f6f308fde45599038b26fdca8d700d4c61f7b49f7964f7ce1b81309565 |
|
MD5 | 19f4f49fcde1c99864963997c641a1a4 |
|
BLAKE2b-256 | cdbc3e769689b68a3dde1d658a35c6d19309550a69e5ca472561e0bd63fbe0a7 |
File details
Details for the file TwissGrid-0.3-py3-none-any.whl
.
File metadata
- Download URL: TwissGrid-0.3-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/34.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b32936b001ad6ab56f089cd9859482e504c3e442c5219e74c656d6d4ce712902 |
|
MD5 | dc6d72d817b7175706e49b29f937899a |
|
BLAKE2b-256 | e197c1addfe4f2d88fafe224445bcd32192556c28418dd647fdf28a85a689025 |