Skip to content
Snippets Groups Projects
Commit 4350b768 authored by Daniel Brown's avatar Daniel Brown
Browse files

Adding in map reading/writing class and updates to various gui components,...

Adding in map reading/writing class and updates to various gui components, trying to get rotation working but failing so far
parent fcdb904f
No related branches found
No related tags found
No related merge requests found
......@@ -11,20 +11,23 @@ s s1 10 1 n1 n2
m m1 1 0 0 n2 n3
pd refl n2
gauss g1 m1 n2 1e-3 0
xaxis m1 r_ap lin 0.1e-3 2e-3 10
"""
kat = finesse.kat()
kat.parseCommands(code)
maxtem = np.linspace(0, 1, 2)
maxtem = np.arange(0, 4)
kat.m1.n2.q = gauss_param(w0=1e-3, z=0)
#kat.m1.n2.q = gauss_param(w0=1e-3, z=0)
kat.verbose = False
for tem in maxtem:
print "Calculating maxtem ", tem, "..."
kat.maxtem = tem
r = kat.run()
pl.plot(r.x/1e-3, r.y, label="maxtem={0}".format(tem))
......
......@@ -8,7 +8,7 @@ import numpy as np
import pylab as pl
code = """
l l1 1 0 0 n1 ### test
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
......@@ -25,7 +25,6 @@ attr m1 Rc 1
"""
kat = finesse.kat()
kat.parseCommands(code)
kat.add(xaxis("lin", [0, 360], kat.m2.phi, 100))
......@@ -37,11 +36,6 @@ kat.m2.Rcy = 1000.0
kat.maxtem = 0
out = kat.run(printout=0,printerr=0)
out = kat.run()
out.plot()
pl.figure()
pl.plot(out.x, out.y)
pl.xlabel(out.xlabel)
pl.ylabel("Intensity [W]")
pl.legend(out.ylabels)
pl.show()
......@@ -466,7 +466,7 @@ class beamSplitter(AbstractMirrorComponent):
def getQGraphicsItem(self):
if self._svgItem == None:
# FIXME: make proper SVG component for beam splitter
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg", self ,[(-4,24,self.nodes[0]), (-4,6,self.nodes[1]), (14,6,self.nodes[2]), (14,24,self.nodes[3])])
return self._svgItem
......@@ -592,6 +592,7 @@ class grating(Component):
self.__eta_3 = AttrParam("eta_3", self, SIfloat(eta_3))
self.__rho_0 = AttrParam("rho_0", self, SIfloat(rho_0))
self.__alpha = AttrParam("alpha", self, SIfloat(alpha))
self._svgItem = None
@property
def n(self): return Param('n', self.__n)
......@@ -686,10 +687,10 @@ class grating(Component):
return rtn
def getQGraphicsItem(self):
if self._QItem == None:
self._QItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make SVG graphic for grating
if self._svgItem == None:
self._svgItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make SVG graphic for grating
return self._QItem
return self._svgItem
class isolator(Component):
def __init__(self, name, node1, node2, S = 0, node3="dump"):
......@@ -698,6 +699,7 @@ class isolator(Component):
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
self._requested_node_names.append(node3)
self._svgItem = None
self.__S = Param("S",self,SIfloat(S))
......@@ -731,18 +733,18 @@ class isolator(Component):
return rtn
def getQGraphicsItem(self):
if self._QItem == None:
self._QItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make isolator graphic
if self._svgItem == None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/isolator.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1]), (14,24,self.nodes[2])])
return self._QItem
return self._svgItem
class lens(Component):
def __init__(self, name, node1, node2, f):
def __init__(self, name, node1, node2, f=1):
Component.__init__(self, name)
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
self._svgItem = None
self.__f = Param("f", self, SIfloat(f))
@property
......@@ -773,18 +775,18 @@ class lens(Component):
return rtn
def getQGraphicsItem(self):
if self._QItem == None:
self._QItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make lens graphic
if self._svgItem == None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/lens.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
return self._QItem
return self._svgItem
class modulator(Component):
def __init__(self, name, f, midx, order, modulation_type, node1, node2, phase=0):
def __init__(self, name, node1, node2, f, midx, order, modulation_type='pm', phase=0):
Component.__init__(self, name)
self._requested_node_names.append(node1)
self._requested_node_names.append(node2)
self._svgItem = None
self.__f = Param("f", self, SIfloat(f))
self.__midx = Param("midx", self, SIfloat(midx))
self.__phase = Param("phase", self, SIfloat(phase))
......@@ -835,9 +837,9 @@ class modulator(Component):
v.pop(0) # remove initial value
if len(v) == 7:
return modulator(v[0], v[1], v[2], v[3], v[4], v[5], v[6])
return modulator(v[0], v[5], v[6], v[1], v[2], v[3], v[4])
if len(v) == 8:
return modulator(v[0], v[1], v[2], v[3], v[4], v[6], v[7], phase=v[5])
return modulator(v[0], v[6], v[7], v[1], v[2], v[3], v[4], phase=v[5])
else:
raise pkex.BasePyKatException("Modulator Finesse code format incorrect '{0}'".format(text))
......@@ -850,10 +852,10 @@ class modulator(Component):
return rtn
def getQGraphicsItem(self):
if self._QItem == None:
self._QItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make lens graphic
if self._svgItem == None:
self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/modulator.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
return self._QItem
return self._svgItem
class laser(Component):
def __init__(self,name,node,P=1,f_offset=0,phase=0):
......@@ -865,6 +867,7 @@ class laser(Component):
self.__f_offset = Param("f", self, SIfloat(f_offset), canFsig=True, fsig_name="f")
self.__phase = Param("phase", self, SIfloat(phase), canFsig=True, fsig_name="phase")
self.__noise = AttrParam("noise", self, None)
self._svgItem = None
@property
def P(self): return self.__power
......
......@@ -157,6 +157,14 @@ class katRun(object):
self.katVersion = None
self.yaxis = None
def plot(self):
import pylab
pylab.plot(self.x, self.y)
pylab.legend(self.ylabels,0)
pylab.xlabel(self.xlabel)
pylab.show()
def savekatRun(self, filename):
with open(filename,'w') as outfile:
pickle.dump(self, outfile)
......@@ -865,6 +873,7 @@ class kat(object):
[out,errpipe] = p.communicate()
if printout == 1:
print out
else:
......@@ -905,6 +914,7 @@ class kat(object):
r.xlabel = hdr[0]
r.ylabel = hdr[1]
r.zlabels = map(str.strip, hdr[2:])
else:
[r.x,r.y,hdr] = self.readOutFile(outfile)
......@@ -1169,17 +1179,14 @@ class kat(object):
if self.noxaxis == True:
out.append("noxaxis\n")
<<<<<<< HEAD
if self.yaxis != None:
out.append("yaxis {0}\n".format(self.yaxis))
# ensure we don't do any plotting. That should be handled
# by user themselves
out.append("gnuterm no\n")
out.append("pyterm no\n")
=======
>>>>>>> a76f88c16370e3db396376d1b684d24aa7f00c89
#out.append("gnuterm no\n")
#out.append("pyterm no\n")
return out
......
......@@ -52,7 +52,6 @@ class SpaceQGraphicsItem(QGraphicsLineItem):
item = QGraphicsTextItem(self.__space.name, self)
rect = item.boundingRect()
item.setPos(-0.5*rect.width(),0*rect.height())
self.refresh()
@property
......@@ -142,13 +141,20 @@ class SpaceQGraphicsItem(QGraphicsLineItem):
self.setPen(QPen(Qt.red, 3))
class ComponentQGraphicsItem(QtSvg.QGraphicsSvgItem):
class ComponentQGraphicsItem(QGraphicsObject): #(QtSvg.QGraphicsSvgItem):
def __init__(self, svgfile, component, nodes):
QGraphicsSvgItem.__init__(self,svgfile)
#QGraphicsSvgItem.__init__(self,svgfile)
QGraphicsObject.__init__(self)
self.__svggraphic = QGraphicsSvgItem(svgfile)
rect = self.__svggraphic.boundingRect()
self.__nodeGraphics = []
self.__component = weakref.ref(component)
# self.setRotation(432.34234)
# this signals the itemChange() method when this item is moved
# used for refreshing the spaces between components
self.setFlags(QGraphicsItem.ItemSendsGeometryChanges)
......@@ -171,6 +177,14 @@ class ComponentQGraphicsItem(QtSvg.QGraphicsSvgItem):
self.installEventFilter(self)
self.setHandlesChildEvents(True)
def boundingRect(self):
return self.__svggraphic.boundingRect()
def paint(self, arg1, arg2, arg3):
self.__svggraphic.rotate(45)
self.__svggraphic.paint( arg1, arg2, arg3)
@property
def component(self): return self.__component()
......
......@@ -121,6 +121,14 @@ class pyKatGUI(QtGui.QMainWindow, qt_gui.Ui_MainWindow):
self.kat.add(m)
self.addComponentToScene(m,x,y)
def addBeamsplitter(self, x, y):
name = self.kat.getNewComponentName('bs')
n = self.kat.getNewNodeNames('n', 4)
m = pykat.components.beamSplitter(name,n[0],n[1],n[2],n[3],R=0.5,T=0.5)
self.kat.add(m)
self.addComponentToScene(m,x,y)
def addSpace(self, x,y):
name = self.kat.getNewComponentName('s')
n = self.kat.getNewNodeNames('n',2)
......@@ -137,6 +145,30 @@ class pyKatGUI(QtGui.QMainWindow, qt_gui.Ui_MainWindow):
self.kat.add(l)
self.addComponentToScene(l,x,y)
def addModulator(self, x,y):
name = self.kat.getNewComponentName('mod')
n = self.kat.getNewNodeNames('n',2)
l = pykat.components.modulator(name, n[0], n[1], 1e6, 0.1, 1)
self.kat.add(l)
self.addComponentToScene(l,x,y)
def addLens(self, x,y):
name = self.kat.getNewComponentName('lens')
n = self.kat.getNewNodeNames('n',2)
l = pykat.components.lens(name, n[0], n[1])
self.kat.add(l)
self.addComponentToScene(l,x,y)
def addIsolator(self, x,y):
name = self.kat.getNewComponentName('isol')
n = self.kat.getNewNodeNames('n',3)
l = pykat.components.isolator(name, n[0], n[1], node3=n[2])
self.kat.add(l)
self.addComponentToScene(l,x,y)
def addPhotodiode(self, x, y):
name = self.kat.getNewDetectorName('pd')
n = self.kat.getNewNodeNames('n',1)
......@@ -219,9 +251,21 @@ class pyKatGraphicsView(QGraphicsView):
action = addmenu.addAction("Mirror")
action.triggered.connect(functools.partial(gui.addMirror, pt.x(), pt.y()))
action = addmenu.addAction("Beamsplitter")
action.triggered.connect(functools.partial(gui.addBeamsplitter, pt.x(), pt.y()))
action = addmenu.addAction("Laser")
action.triggered.connect(functools.partial(gui.addLaser, pt.x(), pt.y()))
action = addmenu.addAction("Lens")
action.triggered.connect(functools.partial(gui.addLens, pt.x(), pt.y()))
action = addmenu.addAction("Isolator")
action.triggered.connect(functools.partial(gui.addIsolator, pt.x(), pt.y()))
action = addmenu.addAction("Modulator")
action.triggered.connect(functools.partial(gui.addModulator, pt.x(), pt.y()))
action = addmenu.addAction("Photodiode")
action.triggered.connect(functools.partial(gui.addPhotodiode, pt.x(), pt.y()))
......
This diff is collapsed.
......@@ -4,6 +4,9 @@
<file>resources/laser.svg</file>
<file>resources/mirror_flat.svg</file>
<file>resources/mirror_curve.svg</file>
<file>resources/modulator.svg</file>
<file>resources/lens.svg</file>
<file>resources/isolator.svg</file>
<file>resources/photodiode_green.svg</file>
<file>resources/photodiode_red.svg</file>
</qresource>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="51.78125"
height="23.4375"
id="svg18505"
version="1.1"
inkscape:version="0.48.2 r9819"
sodipodi:docname="modulator.svg">
<defs
id="defs18507">
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4599"
id="linearGradient8910"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.8,0,0,0.8,-34.8284,-61.1108)"
x1="43.5355"
y1="107.446"
x2="43.5355"
y2="85.247253" />
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-35.0284,-61.5817)"
y2="86.302696"
x2="63.7393"
y1="107.5635"
x1="63.7393"
gradientUnits="userSpaceOnUse"
id="linearGradient4599">
<stop
id="stop4569"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop4571"
style="stop-color:#FFFF99"
offset="0.2501" />
<stop
id="stop4573"
style="stop-color:#FFFF58"
offset="0.428" />
<stop
id="stop4575"
style="stop-color:#FFFF3E"
offset="0.5112" />
<stop
id="stop4577"
style="stop-color:#FFFF53"
offset="0.581" />
<stop
id="stop4579"
style="stop-color:#FFFF89"
offset="0.7253" />
<stop
id="stop4581"
style="stop-color:#FFFFE0"
offset="0.9301" />
<stop
id="stop4583"
style="stop-color:#FFFFFF"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.4636" />
<a:midPointStop
style="stop-color:#FFFF3E"
offset="0.5112" />
<a:midPointStop
style="stop-color:#FFFF3E"
offset="0.5441" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5654"
id="linearGradient5672"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.8,0,0,-0.8,-254.9407,-236.2836)"
x1="-364.73962"
y1="-319.32449"
x2="-383.39462"
y2="-300.66949" />
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="83.771004"
x2="59.4697"
y1="101.4873"
x1="41.753399"
gradientUnits="userSpaceOnUse"
id="linearGradient5654">
<stop
id="stop5609"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop5611"
style="stop-color:#89A4B6"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5647"
id="linearGradient5674"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.8,0,0,-0.8,-254.9407,-236.2836)"
x1="-318.67587"
y1="-319.32449"
x2="-337.32837"
y2="-300.66949" />
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="83.769798"
x2="105.5344"
y1="101.4873"
x1="87.816902"
gradientUnits="userSpaceOnUse"
id="linearGradient5647">
<stop
id="stop5598"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop5600"
style="stop-color:#89A4B6"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5660"
id="linearGradient5676"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.8,0,0,-0.8,-254.9407,-236.2836)"
x1="-365.67712"
y1="-324.6395"
x2="-365.67712"
y2="-295.35449" />
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="78.454102"
x2="73.643097"
y1="106.8008"
x1="73.643097"
gradientUnits="userSpaceOnUse"
id="linearGradient5660">
<stop
id="stop5618"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop5620"
style="stop-color:#C4C4C4"
offset="0.1314" />
<stop
id="stop5622"
style="stop-color:#5C5C5C"
offset="0.3752" />
<stop
id="stop5624"
style="stop-color:#1A1A1A"
offset="0.5444" />
<stop
id="stop5626"
style="stop-color:#000000"
offset="0.6236" />
<stop
id="stop5628"
style="stop-color:#151515"
offset="0.6657" />
<stop
id="stop5630"
style="stop-color:#4C4C4C"
offset="0.7529" />
<stop
id="stop5632"
style="stop-color:#A2A2A2"
offset="0.8765" />
<stop
id="stop5634"
style="stop-color:#FFFFFF"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.4636" />
<a:midPointStop
style="stop-color:#000000"
offset="0.6236" />
<a:midPointStop
style="stop-color:#000000"
offset="0.5441" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="1" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.6203867"
inkscape:cx="-2.4397146"
inkscape:cy="-2.1865349"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="483"
inkscape:window-height="454"
inkscape:window-x="20"
inkscape:window-y="20"
inkscape:window-maximized="0" />
<metadata
id="metadata18510">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-420.5203,-554.15138)">
<g
style="display:inline;enable-background:new"
i:rgbTrio="#4F008000FFFF"
i:dimmedPercent="50"
i:layer="yes"
id="g5643"
transform="translate(420.5203,554.15138)">
<g
id="g5593">
<g
id="g5595">
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="83.769798"
x2="105.5344"
y1="101.4873"
x1="87.816902"
gradientUnits="userSpaceOnUse"
id="linearGradient18773">
<stop
id="stop18775"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop18777"
style="stop-color:#89A4B6"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="1" />
</linearGradient>
<rect
id="rect5602"
height="14.174"
width="14.174"
i:knockout="Off"
y="4.6269999"
x="37.226002"
style="fill:url(#linearGradient5672);fill-opacity:1;stroke:#000000;stroke-width:0.75" />
<line
id="line5604"
y2="18.801001"
x2="51.400002"
y1="4.6269999"
x1="37.226002"
i:knockout="Off"
style="fill:none;stroke:#000000;stroke-width:0.75" />
</g>
<g
id="g5606">
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="83.771004"
x2="59.4697"
y1="101.4873"
x1="41.753399"
gradientUnits="userSpaceOnUse"
id="linearGradient18782">
<stop
id="stop18784"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop18786"
style="stop-color:#89A4B6"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="1" />
</linearGradient>
<rect
id="rect5613"
height="14.174"
width="14.172"
i:knockout="Off"
y="4.6269999"
x="0.375"
style="fill:url(#linearGradient5674);fill-opacity:1;stroke:#000000;stroke-width:0.75" />
<line
id="line5615"
y2="18.801001"
x2="14.547"
y1="4.6269999"
x1="0.375"
i:knockout="Off"
style="fill:none;stroke:#000000;stroke-width:0.75" />
</g>
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="78.454102"
x2="73.643097"
y1="106.8008"
x1="73.643097"
gradientUnits="userSpaceOnUse"
id="linearGradient18790">
<stop
id="stop18792"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop18794"
style="stop-color:#C4C4C4"
offset="0.1314" />
<stop
id="stop18796"
style="stop-color:#5C5C5C"
offset="0.3752" />
<stop
id="stop18798"
style="stop-color:#1A1A1A"
offset="0.5444" />
<stop
id="stop18800"
style="stop-color:#000000"
offset="0.6236" />
<stop
id="stop18802"
style="stop-color:#151515"
offset="0.6657" />
<stop
id="stop18804"
style="stop-color:#4C4C4C"
offset="0.7529" />
<stop
id="stop18806"
style="stop-color:#A2A2A2"
offset="0.8765" />
<stop
id="stop18808"
style="stop-color:#FFFFFF"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.4636" />
<a:midPointStop
style="stop-color:#000000"
offset="0.6236" />
<a:midPointStop
style="stop-color:#000000"
offset="0.5441" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="1" />
</linearGradient>
<rect
id="rect5636"
height="22.677999"
width="22.676001"
i:knockout="Off"
y="0.375"
x="14.55"
style="fill:url(#linearGradient5676);fill-opacity:1;stroke:#000000;stroke-width:0.75" />
</g>
</g>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="9.25"
height="23.4375"
id="svg18505"
version="1.1"
inkscape:version="0.48.2 r9819"
sodipodi:docname="isolator.svg">
<defs
id="defs18507">
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-35.0284,-61.5817)"
y2="86.302696"
x2="63.7393"
y1="107.5635"
x1="63.7393"
gradientUnits="userSpaceOnUse"
id="linearGradient4599">
<stop
id="stop4569"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop4571"
style="stop-color:#FFFF99"
offset="0.2501" />
<stop
id="stop4573"
style="stop-color:#FFFF58"
offset="0.428" />
<stop
id="stop4575"
style="stop-color:#FFFF3E"
offset="0.5112" />
<stop
id="stop4577"
style="stop-color:#FFFF53"
offset="0.581" />
<stop
id="stop4579"
style="stop-color:#FFFF89"
offset="0.7253" />
<stop
id="stop4581"
style="stop-color:#FFFFE0"
offset="0.9301" />
<stop
id="stop4583"
style="stop-color:#FFFFFF"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.4636" />
<a:midPointStop
style="stop-color:#FFFF3E"
offset="0.5112" />
<a:midPointStop
style="stop-color:#FFFF3E"
offset="0.5441" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5654"
id="linearGradient5672"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.8,0,0,-0.8,-254.9407,-236.2836)"
x1="-364.73962"
y1="-319.32449"
x2="-383.39462"
y2="-300.66949" />
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="83.771004"
x2="59.4697"
y1="101.4873"
x1="41.753399"
gradientUnits="userSpaceOnUse"
id="linearGradient5654">
<stop
id="stop5609"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop5611"
style="stop-color:#89A4B6"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5647"
id="linearGradient5674"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.8,0,0,-0.8,-254.9407,-236.2836)"
x1="-318.67587"
y1="-319.32449"
x2="-337.32837"
y2="-300.66949" />
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="83.769798"
x2="105.5344"
y1="101.4873"
x1="87.816902"
gradientUnits="userSpaceOnUse"
id="linearGradient5647">
<stop
id="stop5598"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop5600"
style="stop-color:#89A4B6"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5660"
id="linearGradient5676"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.8,0,0,-0.8,-254.9407,-236.2836)"
x1="-365.67712"
y1="-324.6395"
x2="-365.67712"
y2="-295.35449" />
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-33.0283,-62.3896)"
y2="78.454102"
x2="73.643097"
y1="106.8008"
x1="73.643097"
gradientUnits="userSpaceOnUse"
id="linearGradient5660">
<stop
id="stop5618"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop5620"
style="stop-color:#C4C4C4"
offset="0.1314" />
<stop
id="stop5622"
style="stop-color:#5C5C5C"
offset="0.3752" />
<stop
id="stop5624"
style="stop-color:#1A1A1A"
offset="0.5444" />
<stop
id="stop5626"
style="stop-color:#000000"
offset="0.6236" />
<stop
id="stop5628"
style="stop-color:#151515"
offset="0.6657" />
<stop
id="stop5630"
style="stop-color:#4C4C4C"
offset="0.7529" />
<stop
id="stop5632"
style="stop-color:#A2A2A2"
offset="0.8765" />
<stop
id="stop5634"
style="stop-color:#FFFFFF"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.4636" />
<a:midPointStop
style="stop-color:#000000"
offset="0.6236" />
<a:midPointStop
style="stop-color:#000000"
offset="0.5441" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3748"
id="linearGradient3754"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.8,0,0,0.8,-34.8284,-61.1108)"
x1="43.5355"
y1="105.67225"
x2="43.5355"
y2="76.388496" />
<linearGradient
y2="0.37450001"
x2="4.6269999"
y1="23.0518"
x1="4.6269999"
gradientUnits="userSpaceOnUse"
id="linearGradient3748">
<stop
id="stop3733"
style="stop-color:#89A4B6"
offset="0.0056" />
<stop
id="stop3735"
style="stop-color:#FFFFFF"
offset="0.5" />
<stop
id="stop3737"
style="stop-color:#89A4B6"
offset="1" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="0.0056" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="0.5" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="1" />
</linearGradient>
<linearGradient
y2="76.388496"
x2="43.5355"
y1="105.67225"
x1="43.5355"
gradientTransform="matrix(0.8,0,0,0.8,-34.8284,-61.1108)"
gradientUnits="userSpaceOnUse"
id="linearGradient18948"
xlink:href="#linearGradient3748"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.6203867"
inkscape:cx="-9.6898946"
inkscape:cy="15.890375"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="483"
inkscape:window-height="454"
inkscape:window-x="20"
inkscape:window-y="20"
inkscape:window-maximized="0" />
<metadata
id="metadata18510">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-427.77048,-572.22829)">
<g
style="display:inline;enable-background:new"
i:rgbTrio="#4F008000FFFF"
i:dimmedPercent="50"
i:layer="yes"
id="g3746"
transform="translate(427.77048,572.22829)">
<linearGradient
y2="0.37450001"
x2="4.6269999"
y1="23.0518"
x1="4.6269999"
gradientUnits="userSpaceOnUse"
id="linearGradient18939">
<stop
id="stop18941"
style="stop-color:#89A4B6"
offset="0.0056" />
<stop
id="stop18943"
style="stop-color:#FFFFFF"
offset="0.5" />
<stop
id="stop18945"
style="stop-color:#89A4B6"
offset="1" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="0.0056" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="0.5" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.5" />
<a:midPointStop
style="stop-color:#89A4B6"
offset="1" />
</linearGradient>
<path
id="path3739"
d="m 7.17,0.375 -5.086,0 C 1.049,2.96 0.375,7.07 0.375,11.714 c 0,4.644 0.674,8.754 1.709,11.338 l 5.086,0 C 8.207,20.468 8.879,16.358 8.879,11.714 8.879,7.07 8.205,2.96 7.17,0.375 z"
i:knockout="Off"
style="fill:url(#linearGradient18948);fill-opacity:1;stroke:#000000;stroke-width:0.75"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="31.9375"
height="31.9375"
id="svg18505"
version="1.1"
inkscape:version="0.48.2 r9819"
sodipodi:docname="New document 4">
<defs
id="defs18507">
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4599"
id="linearGradient8910"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.8,0,0,0.8,-34.8284,-61.1108)"
x1="43.5355"
y1="107.446"
x2="43.5355"
y2="85.247253" />
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-35.0284,-61.5817)"
y2="86.302696"
x2="63.7393"
y1="107.5635"
x1="63.7393"
gradientUnits="userSpaceOnUse"
id="linearGradient4599">
<stop
id="stop4569"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop4571"
style="stop-color:#FFFF99"
offset="0.2501" />
<stop
id="stop4573"
style="stop-color:#FFFF58"
offset="0.428" />
<stop
id="stop4575"
style="stop-color:#FFFF3E"
offset="0.5112" />
<stop
id="stop4577"
style="stop-color:#FFFF53"
offset="0.581" />
<stop
id="stop4579"
style="stop-color:#FFFF89"
offset="0.7253" />
<stop
id="stop4581"
style="stop-color:#FFFFE0"
offset="0.9301" />
<stop
id="stop4583"
style="stop-color:#FFFFFF"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.4636" />
<a:midPointStop
style="stop-color:#FFFF3E"
offset="0.5112" />
<a:midPointStop
style="stop-color:#FFFF3E"
offset="0.5441" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="1" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.6203867"
inkscape:cx="-5.9539146"
inkscape:cy="5.7011251"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="483"
inkscape:window-height="454"
inkscape:window-x="20"
inkscape:window-y="20"
inkscape:window-maximized="0" />
<metadata
id="metadata18510">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-424.0345,-553.53904)">
<g
style="display:inline;enable-background:new"
i:rgbTrio="#4F008000FFFF"
i:dimmedPercent="50"
i:layer="yes"
id="g4596"
transform="translate(424.0345,553.53904)">
<g
id="g4566">
<linearGradient
gradientTransform="matrix(0.8,0,0,0.8,-35.0284,-61.5817)"
y2="86.302696"
x2="63.7393"
y1="107.5635"
x1="63.7393"
gradientUnits="userSpaceOnUse"
id="linearGradient18578">
<stop
id="stop18580"
style="stop-color:#FFFFFF"
offset="0" />
<stop
id="stop18582"
style="stop-color:#FFFF99"
offset="0.2501" />
<stop
id="stop18584"
style="stop-color:#FFFF58"
offset="0.428" />
<stop
id="stop18586"
style="stop-color:#FFFF3E"
offset="0.5112" />
<stop
id="stop18588"
style="stop-color:#FFFF53"
offset="0.581" />
<stop
id="stop18590"
style="stop-color:#FFFF89"
offset="0.7253" />
<stop
id="stop18592"
style="stop-color:#FFFFE0"
offset="0.9301" />
<stop
id="stop18594"
style="stop-color:#FFFFFF"
offset="1" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="0.4636" />
<a:midPointStop
style="stop-color:#FFFF3E"
offset="0.5112" />
<a:midPointStop
style="stop-color:#FFFF3E"
offset="0.5441" />
<a:midPointStop
style="stop-color:#FFFFFF"
offset="1" />
</linearGradient>
<rect
id="rect4585"
height="17.009001"
width="31.18"
i:knockout="Off"
y="7.4619999"
x="0.375"
style="fill:url(#linearGradient8910);fill-opacity:1;stroke:#000000;stroke-width:0.75" />
<rect
id="rect4587"
height="4.2519999"
width="31.181"
i:knockout="Off"
y="0.375"
x="0.375"
style="fill:#8a644a;stroke:#000000;stroke-width:0.75" />
<rect
id="rect4589"
height="4.2519999"
width="31.181"
i:knockout="Off"
y="27.305"
x="0.375"
style="fill:#8a644a;stroke:#000000;stroke-width:0.75" />
</g>
</g>
</g>
</svg>
import numpy
class surfacemap:
def __init__(self, name, maptype, size, center, step_size, scaling, data=None):
self.name = name
self.type = maptype
self.center = center
self.size = size
self.step_size = step_size
self.scaling = scaling
self.data = data
def write_map(self, filename):
with open(filename,'w') as mapfile:
mapfile.write("% Surface map\n")
mapfile.write("% Name: {0}\n".format(self.name))
mapfile.write("% Type: {0}\n".format(self.type))
mapfile.write("% Size: {0} {1}\n".format(self.size[0], self.size[1]))
mapfile.write("% Optical center (x,y): {0} {1}\n".format(self.center[0], self.center[1]))
mapfile.write("% Step size (x,y): {0} {1}\n".format(self.step_size[0], self.step_size[1]))
mapfile.write("% Scaling: {0}\n".format(float(self.scaling)))
mapfile.write("\n\n")
for i in range(0, self.data.shape[0]):
for j in range(0, self.data.shape[1]):
mapfile.write("%.15g " % self.data[i,j])
mapfile.write("\n")
def plot(self):
import pylab
xrange = 100*self.step_size[0] * (numpy.array(range(0, self.data.shape[0]))- self.center[0])
yrange = 100*self.step_size[1] * (numpy.array(range(0, self.data.shape[1]))- self.center[1])
fig = pylab.figure()
axes = pylab.imshow(self.data, extent=[min(xrange),max(xrange),min(yrange),max(yrange)])
pylab.xlabel('x [cm]')
pylab.ylabel('y [cm]')
pylab.title('Surface map {0}, type {1}'.format(self.name, self.type))
cbar = fig.colorbar(axes)
pylab.show()
def read_map(filename):
with open(filename, 'r') as f:
f.readline()
name = f.readline().split(':')[1].strip()
maptype = f.readline().split(':')[1].strip()
size = tuple(map(lambda x: int(x), f.readline().split(':')[1].strip().split()))
center = tuple(map(lambda x: float(x), f.readline().split(':')[1].strip().split()))
step = tuple(map(lambda x: float(x), f.readline().split(':')[1].strip().split()))
scaling = float(f.readline().split(':')[1].strip())
data = numpy.loadtxt(filename, dtype=numpy.float64, skiprows=9,ndmin=2)
return surfacemap(name,maptype,size,center,step,scaling,data)
\ No newline at end of file
import numpy as np
import matplotlib
BACKEND = 'Qt4Agg'
matplotlib.use(BACKEND)
from matplotlib import rc
import matplotlib.pyplot as plt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment