可视化Twiss参数,用于晶格参数的一维或二维网格扫描。
TwissGrid的Python项目详细描述
TwissGrid公司
此应用程序执行晶格参数的一维或二维网格扫描 并将它们对所选光学功能的影响可视化。在
安装
可以从Python包索引(PyPI)安装应用程序:
pip install twissgrid
使用
可以通过以下方式从命令行使用该应用程序:
^{pr2}$它至少需要两个参数:
- MADX脚本的文件路径。在
- 晶格参数的名称。它需要给出为
label->attr
,其中->attr
部分是可选的(它将从元素类型中推断)。必须通过提供的label
在MADX中访问相应的元素(参数在内部将更新为label->attr = value;
,因此必须是有效语句)。在
此示例将根据该参数创建beta函数的二维图:
3D绘图
可以在第一个参数之后提供第二个参数,以便执行二维参数扫描 并创建相应的3D打印:
python -m twissgrid /path/to/script.madx a_param b_param
定制
应用程序支持其他各种参数,用于自定义参数扫描或结果图。
{5>可通过 标签:$ 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)
推荐PyPI第三方库