Commit 52efa5ef authored by Daniel Brown's avatar Daniel Brown
Browse files

more optivis integration

parent 9ca9dcba
import pykat
kat = pykat.finesse.kat(kat_file="/Users/ddb/git/geo-simulation/geo-files/geoHF_v48.kat")
#kat = pykat.finesse.kat(kat_file="/Users/ddb/git/geo-simulation/geo-files/geoHF_v48.kat")
gui, scene = kat.optivis()
kat = pykat.finesse.kat(kat_file="LLO_matched.kat")
gui = kat.optivis()
gui.show()
......@@ -15,8 +15,8 @@ m m2 1 0 0 n7a n7b
s s4 50 n5 n5a
m m3 1 0 0 n5a n5b
#s s4a 200 n5b n8a
#m m4 1 0 0 n8a n8b
s s4a 200 n5b n8a
m m4 1 0 0 n8a n8b
attr m1 Rc -500
attr m2 Rc 500
......@@ -30,6 +30,6 @@ out, tdata = kat.run(getTraceData=True)
gui = kat.optivis()
kat.optivis_updateTraceData(gui, tdata[0])
#kat.optivis_updateTraceData(gui, tdata[0])
gui.show()
......@@ -53,10 +53,12 @@ s rs7 $lrs7 nM6e nM7w
bs M7 1 0 0 49.39870535E0 nM7w nM7n dump dump
s rs8 $lrs8 nM7n nM1an
#attr M1a backscatter 0.6u
bs1 M1a 500u 0 0 $AoI nM1aw nM1an nM1ae nM1as
attr M1a Rc -7.91
attr M1a mass $MassM1
s rs12 1.315 nM3an nM1ae
s rs12 0.6575 nM3an nM1ae
bs1 M3a $T_ETM $L_ETM 0 $AoI2 nM3aw nM3an nM3aT1 nM3aT2
attr M3a mass $MassM23
s rs11 0.2 1. nM2an nM3aw
......@@ -79,6 +81,7 @@ s rs26 $lrs26 nM8n nM1bw
#################################################################
## Cavity b
#attr M1b backscatter 0.6u
bs1 M1b 500u 0 0 $AoI nM1bw nM1bn nM1be nM1bs
attr M1b Rc -7.91
attr M1b mass $MassM1
......@@ -112,11 +115,11 @@ s sl2 1n nl2 nl3
bs dHD .5 .5 0 0 nHD1 nout1 nout2 nl3
# homodyne detector, use 180 deg phase for normal use, i.e. output=nout1-nout2
#qhdS sens 180 nout1 nout2
qhdS sens 180 nout1 nout2
# re-scaling output to m/sqrt(Hz)
#scale meter sens
scale meter sens
%xaxis sig1 f log 100 100k 99
xaxis sig1 f log 100 100k 99
yaxis log abs
maxtem off
......
......@@ -24,6 +24,9 @@ from collections import OrderedDict
if HAS_OPTIVIS:
import optivis.bench.components as optivis_components
from optivis.view.canvas import OptivisCanvasItemDataType
from optivis.bench.labels import Label as optivis_label
from optivis.geometry import Coordinates as optivis_coord
import PyQt4
from pykat.SIfloat import *
from pykat.param import Param, AttrParam
......@@ -490,6 +493,10 @@ class mirror(AbstractMirrorComponent):
if self._optivis_component is None:
self._optivis_component = optivis_components.CavityMirror(name=self.name, aoi=0, tooltip=self.getOptivisTooltip, paramList=self.getOptivisParameterDict(), pykatObject=weakref.ref(self))
lbl = optivis_label(text="", position=optivis_coord(0, -1), item=self._optivis_component)
lbl.content["Name"] = self.name
self._optivis_component.labels.append(lbl)
return self._optivis_component
......@@ -1187,7 +1194,10 @@ class laser(Component):
if self._optivis_component is None:
self._optivis_component = optivis_components.Laser(name=self.name, tooltip=self.getOptivisTooltip, paramList=self.getOptivisParameterDict(), pykatObject=weakref.ref(self))
lbl = optivis_label(text="", position=optivis_coord(0, -1), item=self._optivis_component)
lbl.content["Name"] = self.name
self._optivis_component.labels.append(lbl)
return self._optivis_component
def getOptivisNode(self, mode, kat_node):
......
......@@ -1561,10 +1561,12 @@ class kat(object):
c.label_node1 = optivis_label(text="", position=optivis_coord(-0.5, 0), item=c._optivis_component)
c.label_node2 = optivis_label(text="", position=optivis_coord( 0.5, 0), item=c._optivis_component)
label_name = optivis_label(text="", position=optivis_coord(0, -0.5), item=c._optivis_component)
label_name.content["Name"] = c.name
c._optivis_component.labels.append(c.label_node1)
c._optivis_component.labels.append(c.label_node2)
c._optivis_component.labels.append(label_name)
scene.addLink(c._optivis_component)
gui = canvas.Full(scene=scene)
......@@ -1574,12 +1576,12 @@ class kat(object):
fileMenu = menubar.addMenu('&Pykat')
trace = PyQt4.QtGui.QAction('Trace', gui.qMainWindow)
trace.triggered.connect(self.optivis_updateTraceData)
trace.triggered.connect(lambda: self._optivis_doTrace(gui))
fileMenu.addAction(trace)
return gui
def optivis_updateTraceData(self, gui, tdata):
def _optivis_doTrace(self, gui, **kwargs):
"""
Change at some point to use a stored GUI reference
"""
......@@ -1587,10 +1589,23 @@ class kat(object):
print("Optivis is not installed")
return None
prev = self.noxaxis
self.noxaxis = True
out, tdata = self.run(getTraceData=True, **kwargs)
self.noxaxis = prev
# For now just select the first trace computed
# Later we could add some gui list to show the different ones
tdata = tdata[0]
for c in self.getComponents():
if not isinstance(c, pykat.components.space):
continue
if not (hasattr(c, "label_node1") and hasattr(c, "label_node2")):
continue
c.label_node1.content["w0_x"] = tdata[c.nodes[0].name][0].w0
c.label_node1.content["w_x"] = tdata[c.nodes[0].name][0].w
c.label_node1.content["z_x"] = tdata[c.nodes[0].name][0].z
......@@ -1603,6 +1618,18 @@ class kat(object):
c.label_node1.content["Rc_y"] = tdata[c.nodes[0].name][1].Rc
c.label_node1.content["Zr_y"] = tdata[c.nodes[0].name][1].zr
c.label_node2.content["w0_x"] = tdata[c.nodes[1].name][0].w0
c.label_node2.content["w_x"] = tdata[c.nodes[1].name][0].w
c.label_node2.content["z_x"] = tdata[c.nodes[1].name][0].z
c.label_node2.content["Rc_x"] = tdata[c.nodes[1].name][0].Rc
c.label_node2.content["Zr_x"] = tdata[c.nodes[1].name][0].zr
c.label_node2.content["w0_y"] = tdata[c.nodes[1].name][1].w0
c.label_node2.content["w_y"] = tdata[c.nodes[1].name][1].w
c.label_node2.content["z_y"] = tdata[c.nodes[1].name][1].z
c.label_node2.content["Rc_y"] = tdata[c.nodes[1].name][1].Rc
c.label_node2.content["Zr_y"] = tdata[c.nodes[1].name][1].zr
gui.draw()
def openGUI(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment