python接口和finesse工具

PyKat的Python项目详细描述


pykat是使用finesse(http://www.gwoptics.org/finesse)的包装器。 它旨在提供一个python工具集,用于自动化更复杂的任务 以及提供用于操作和查看模拟的gui 设置。

源代码托管在https://git.ligo.org/finesse/pykat

当与以下项一起使用时,请引用Pykat:

@Misc{Pykat,
  Title                    = {Pykat},
  Author                   = {Brown, Daniel David and Freise, Andreas},
  Month                    = {July},
  Note                     = {{\url{http://www.gwoptics.org/pykat}}},
  Year                     = {2017},
  Doi                      = {10.5281/zenodo.821389},
  Url                      = {http://www.gwoptics.org/pykat}
}

示例和教程可以在http://www.gwoptics.org/learn/

如果您有任何问题,请发电子邮件给finesse@star.sr.bham.ac.uk

安装

安装pykat的最简单方法是通过pypi或conda(推荐):

pip install pykat

conda install -c gwoptics pykat

conda安装的优点是它还将安装finesse二进制文件。

如果您是windows用户,也可以选择在https://pypi.python.org/pypi/PyKat下载安装程序。

现在您应该能够打开一个新的python终端并键入import pykat,输出应该是:

>>> import pykat
                                              ..-
    PyKat 0.1              _                  '(
                          \`.|\.__...-""""-_." )
       ..+-----.._        /  ' `            .-'
   . '            `:      7/* _/._\    \   (
  (        '::;;+;;:      `-"' =" /,`"" `) /
  L.        \`:::a:f            c_/     n_'
  ..`--...___`.  .    ,
   `^-....____:   +.      www.gwoptics.org/pykat
>>>

您还需要确保在您的计算机上安装了finesse的完整工作副本和安装程序。 有关这方面的详细信息,请访问http://www.gwoptics.org/finesse

必须设置2个环境变量:“finesse_dir”,其值是“kat”可执行文件所在的目录; “kat ini”,它声明了默认情况下在finesse中使用的kat.ini文件的目录和名称,更多信息请参见 关于这一点,我们可以找到精细手册。

用法

这并没有详细说明如何使用finesse本身,只是pykat。与finesse相关的查询应该 请直接阅读Finesse手册或邮件列表finesse@star.sr.bham.ac.uk

我们强烈建议使用ipython或jupyter笔记本运行pykat,它迄今为止提供了探索各种pykat对象和输出数据的最佳方法。 也可以使用ipythons交互matplotlib模式或pylab模式,这使得显示和交互多个图变得容易。 您可以使用以下命令从终端启动Pylab模式:

ipython -pylab

无论您使用哪种解释器,要开始使用pykat,您首先需要包括以下内容:

from pykat import finesse
from pykat.detectors import *
from pykat.components import *
from pykat.commands import *
from pykat.structs import *

这提供了您通常需要的所有各种finesse组件和命令。 运行模拟需要您已经知道如何编写精巧的文件,这超出了 本自述的范围。可以通过多种方式输入finesse命令:在previous.kat中读取 文件,创建表示各种finesse命令或通过编写finesse代码块的pykat对象 如下所示:

import matplotlib.pyplot as plt

# Here we write out any FINESSE commands we want to process
code = """
l l1 1 0 0 n1
s s1 10 1 n1 n2
m m1 0.5 0.5 0 n2 n3
s s2 10 1 n3 n4
m m2 0.5 0.5 0 n4 n5
s s3 10 1 n5 n6

pd pd_cav n4
xaxis m1 phi lin 0 360 360
yaxis abs:deg
"""

# this kat object represents one single simulation, it containts
# all the objects and their various states.
kat = finesse.kat()

# Currently the kat object is empty. We can fill it using a block
# string of normal FINESSE commands by parsing them.
kat.parse(code)

# Once we have some simulation built up we can run it simply by calling...
out = kat.run()

# This out object contains the results from this run of the simulation.
# Parameters can then be changed and kat.run() can be called again producing
# another output object. So if we wanted to change the reflectivity of m1 we can do
kat.m1.R = 0.2
kat.m1.T = 0.8
# now run it again...
out2 = kat.run()

# We can plot the output simply enough using pylab plotting.
plt.figure()
plt.plot(out.x, out["pd_cav"])
plt.xlabel(out.xlabel)
plt.ylabel("Intensity [W]")
plt.legend(out.ylabels)
plt.show()

上面演示了一种包装精细模拟(简单或复杂)的方法 在一个python脚本文件中包括任何后期处理和打印。或者你可以创建 kat文件单独生成python脚本来运行和处理它们,这个选择取决于 你,皮卡特提供了两种方法。

要加载到单独的finesse.kat文件中,我们可以使用以下命令:

kat = finesse.kat()
# load in a separate file in the same directory...
kat.load('test.kat')
# the kat object has now parsed all the commands in this file.

# We can alter and objects in there, e.g. if there was a mirror called m1
kat.m1.phi = 45

out = kat.run()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
orm如何在Java中实现规范化映射?   java以编程方式修改Xtext生成的Mwe2工作流   java正在覆盖外部文件中的现有数据,如何停止?   java在ANTLR BNF语法符号中epsilon的等价物是什么?   java如何使用Hibernate@Anyrelated注释?   代码生成生成java类并在运行时加载它   java Maven无法在本地jar文件中收集依赖项   java NetBeans IDE 8.2不显示错误消息   java Selenium web驱动程序找不到元素   java如何修复“拒绝访问属性”invoke“”的权限?   JavaApacheJClouds,从比日期更早的blob中删除blob的最佳方法   java如何比较和排序树集中的项目?   使用JavaSpring和无头/解耦CMS   java使用swagercodegen在不同的类中生成端点   Java外部Keylistener没有响应