components.py 36.6 KB
Newer Older
Daniel Brown's avatar
Daniel Brown committed
1
2
3
4
5
6
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 28 11:10:01 2013

@author: Daniel
"""
7
8
9
10
11
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

12
from pykat import USE_GUI, NoGUIException
13
14
15
16
17
18

import pykat.external.six as six

if six.PY2:
	import exceptions

Daniel Brown's avatar
Daniel Brown committed
19
20
21
22
23
import pykat.exceptions as pkex
import pykat
from pykat.node_network import *
from pykat.exceptions import *
import abc
Daniel Brown's avatar
Daniel Brown committed
24

Daniel Brown's avatar
Daniel Brown committed
25
26
from pykat.SIfloat import *
from pykat.param import Param, AttrParam
27
import weakref
28
import pykat.exceptions as pkex
29
from copy import deepcopy
Daniel Brown's avatar
Daniel Brown committed
30
31
next_component_id = 1

32
33
from pykat import USE_GUI, NoGUIException

34
35
36
37
38
if USE_GUI:
    import pykat.gui.resources
    import pykat.gui.graphics
    from pykat.gui.graphics import *

Daniel Brown's avatar
Daniel Brown committed
39
40
class NodeGaussSetter(object):
    def __init__(self, component, node):                
41
42
        self.__comp = weakref.ref(component)
        self.__node = weakref.ref(node)
Daniel Brown's avatar
Daniel Brown committed
43
44
45
46
47
48
49
50
51
        self.__name = None
        
    @property
    def name(self):
        return self.__name
        
    @name.setter
    def name(self, value):
        self.__name = str(value)
Daniel Brown's avatar
Daniel Brown committed
52
53
54
    
    @property
    def node(self):
55
        return self.__node()
Daniel Brown's avatar
Daniel Brown committed
56
57
58
    
    @property
    def q(self):
59
        return self.__node().qx
Daniel Brown's avatar
Daniel Brown committed
60
61
62
        
    @q.setter
    def q(self, value):
63
        self.__node().setGauss(self.__comp(), complex(value))
Daniel Brown's avatar
Daniel Brown committed
64
65
66
        
    @property
    def qx(self):
67
        return self.__node().qx
Daniel Brown's avatar
Daniel Brown committed
68
69
    @qx.setter
    def qx(self, value):
70
        self.__node().setGauss(self.__comp(), complex(value))
Daniel Brown's avatar
Daniel Brown committed
71
72
73
    
    @property
    def qy(self):
74
        return self.__node().qy
Daniel Brown's avatar
Daniel Brown committed
75
76
    @qy.setter
    def qy(self, value):
77
        self.__node().setGauss(self.__comp(), self.qx, complex(value))
Daniel Brown's avatar
Daniel Brown committed
78
79
80
        
class Component(object):
    __metaclass__ = abc.ABCMeta
81
82
    
    def __init__(self, name):
Daniel Brown's avatar
Daniel Brown committed
83
84
85
86
87
88
        self.__name = name
        self._svgItem = None
        self._requested_node_names = []
        self._kat = None
        self.tag = None
        self._params = []
89
        self.__removed = False
Daniel Brown's avatar
Daniel Brown committed
90
        self._default_fsig_param = None
Daniel Brown's avatar
Daniel Brown committed
91
92
93
94
95
96
        
        # store a unique ID for this component
        global next_component_id
        self.__id = next_component_id
        next_component_id += 1
        
97
98
99
100
101
102
        # This creates an instance specific class for the component
        # this enables us to add properties to instances rather than
        # all classes
        cls = type(self)
        self.__class__ = type(cls.__name__, (cls,), {})
    
Daniel Brown's avatar
Daniel Brown committed
103
104
    def _register_param(self, param):
        self._params.append(param)
Daniel Brown's avatar
Daniel Brown committed
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
    
    def _default_fsig(self):
        """
        Returns what Finesse internally determines as the default 
        fsig parameter. This is used mainly for parsing fsig command
        lines where no target parameter is stated.
        """
        if self._default_fsig_param != None:
            if not self._default_fsig_param.canFsig:
                raise pkex.BasePyKatException("Default fsig parameter %s is not possible to fsig" % (self.__default_fsig_param.name))
            else:
                return self._default_fsig_param
        else:
            return None
    
Daniel Brown's avatar
Daniel Brown committed
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
    def _on_kat_add(self, kat):
        """
        Called when this component has been added to a kat object.
        kat is the finesse.kat object which it now belongs to and
        node_array is an array specific to this object which contains
        references to the nodes that are attached to it.
        """
        if self._kat != None:
            raise pkex.BasePyKatException("Component has already been added to a finesse.kat object")
            
        self._kat = kat
        
        kat.nodes.registerComponentNodes(self, self._requested_node_names, self.__on_node_change)
        
    def __on_node_change(self):
        # need to update the node gauss parameter setter members 
        self.__update_node_setters()
        
    def __update_node_setters(self):
        # check if any node setters have already been added. If so we
        # need to remove them. This function should get called if the nodes
        # are updated, either by some function call or the GUI
        key_rm = [k for k in self.__dict__ if k.startswith("__nodesetter_", 0, 13)]
        
        # now we have a list of which to remove
        for key in key_rm:
            ns = self.__dict__[key]
            delattr(self, '__nodesetter_' + ns.node.name)
            delattr(self.__class__, ns.node.name)
149
            
Daniel Brown's avatar
Daniel Brown committed
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
        for node in self.nodes:
            if type(node) != pykat.node_network.DumpNode:
                ns = NodeGaussSetter(self, node)
                self.__add_node_setter(ns)
        
    def __add_node_setter(self, ns):

        if not isinstance(ns, NodeGaussSetter):
            raise exceptions.ValueError("Argument is not of type NodeGaussSetter")
        
        name = ns.node.name
        fget = lambda self: self.__get_node_setter(name)
        
        setattr(self.__class__, name, property(fget))
        setattr(self, '__nodesetter_' + name, ns)                   

    def __get_node_setter(self, name):
        return getattr(self, '__nodesetter_' + name)   
        
    @staticmethod
    @abc.abstractmethod
    def parseFinesseText(text):
        """Parses Finesse syntax"""
        raise NotImplementedError("This function is not implemented")

    @abc.abstractmethod
    def getFinesseText(self):
        """ Base class for individual Finesse optical components """    
        raise NotImplementedError("This function is not implemented")

    @abc.abstractmethod
    def getQGraphicsItem(self):    
182
183
184
        if not USE_GUI:
            raise NoGUIException
            
Daniel Brown's avatar
Daniel Brown committed
185
186
        return None      
    
187
188
189
    @property
    def removed(self): return self.__removed
    
Daniel Brown's avatar
Daniel Brown committed
190
191
192
193
194
195
196
197
198
199
200
    @property
    def nodes(self): return self._kat.nodes.getComponentNodes(self) 
    
    @property    
    def name(self): return self.__name      
    
    @property
    def id(self): return self.__id
    
    def __str__(self): return self.name
    
201
202
203
    def remove(self):
        self._kat.remove(self)
        
204
205
206
207
208
        # inform all parameters that we have removed its owner
        # so that it can then warn about any puts/vars/xaxis
        for p in self._params:
            p._onOwnerRemoved()
        
209
210
211
        del self._params[:]

        self.__removed = True
212
            
Daniel Brown's avatar
Daniel Brown committed
213
214
class AbstractMirrorComponent(Component):
    __metaclass__ = abc.ABCMeta
215
        
Daniel Brown's avatar
Daniel Brown committed
216
    def __init__(self, name, R=None, T=None, L=None, phi=0, Rcx=None, Rcy=None, xbeta=None, ybeta=None, mass=None, r_ap=None, Ix=None, Iy=None, zmech=None, rxmech=None, rymech=None):
Daniel Brown's avatar
Daniel Brown committed
217
        super(AbstractMirrorComponent, self).__init__(name)
218
 
Daniel Brown's avatar
Daniel Brown committed
219
        if (L != None and R != None and T != None) and SIfloat(R)+SIfloat(T)+SIfloat(L) != 1: 
220
            raise pkex.BasePyKatException('L+R+T must equal 1 if all are specified at {0}'.format(self.name))
221
        elif (R != None and L is None and T != None):
Daniel Brown's avatar
Daniel Brown committed
222
            L = 1- (SIfloat(R)+SIfloat(T))
223
        elif (R is None and L != None and T != None):
Daniel Brown's avatar
Daniel Brown committed
224
            R = 1 - (SIfloat(L)+SIfloat(T))
225
        elif (R != None and L != None and T is None):
Daniel Brown's avatar
Daniel Brown committed
226
            T = 1 - (SIfloat(L)+SIfloat(R))
227
        elif (L is None and R is None and T is None):
228
229
            raise pkex.BasePyKatException('Must specify at least two of L, R or T')
        
Daniel Brown's avatar
Daniel Brown committed
230
231
        self.__R = Param("R", self, SIfloat(R))
        self.__T = Param("T", self, SIfloat(T))
232
233
        self.__L = Param("L", self, SIfloat(L))
        
234
        self.__phi = Param("phi", self, SIfloat(phi), canFsig=True, fsig_name="phase")
Daniel Brown's avatar
Daniel Brown committed
235
236
        self.__Rcx = AttrParam("Rcx", self, SIfloat(Rcx))
        self.__Rcy = AttrParam("Rcy", self, SIfloat(Rcy))
237
238
        self.__xbeta = AttrParam("xbeta", self, SIfloat(xbeta), canFsig=True, fsig_name="x")
        self.__ybeta = AttrParam("ybeta", self, SIfloat(ybeta), canFsig=True, fsig_name="y")
Daniel Brown's avatar
Daniel Brown committed
239
        self.__mass = AttrParam("mass", self, SIfloat(mass))
Daniel Brown's avatar
Daniel Brown committed
240
241
        self.__Ix = AttrParam("Ix", self, SIfloat(Ix))
        self.__Iy = AttrParam("Iy", self, SIfloat(Iy))
Daniel Brown's avatar
Daniel Brown committed
242
        self.__r_ap = AttrParam("r_ap", self, SIfloat(r_ap))
243
    
Daniel Brown's avatar
Daniel Brown committed
244
245
246
247
        self.__zmech = AttrParam("zmech", self, zmech)
        self.__rxmech = AttrParam("rxmech", self, rxmech)
        self.__rymech = AttrParam("rymech", self, rymech)
        
248
249
250
251
252
253
        self.__z = Param("z", self, 0, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="z")
        self.__rx = Param("rx", self, 0, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="rx")
        self.__ry = Param("ry", self, 0, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="ry")
        self.__Fz = Param("Fz", self, 0, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="Fz")
        self.__Frx = Param("Frx", self, 0, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="Frx")
        self.__Fry = Param("Fry", self, 0, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="Fry")
254
        
Daniel Brown's avatar
Daniel Brown committed
255
256
        self._default_fsig_param = self.__phi
        
257
258
259
260
261
262
263
264
265
266
267
268
269
    @property
    def z(self): return self.__z
    @property
    def Fz(self): return self.__Fz
    @property
    def rx(self): return self.__rx
    @property
    def Frx(self): return self.__Frx
    @property
    def ry(self): return self.__ry
    @property
    def Fry(self): return self.__Fry
    
270
271
272
    @property
    def L(self): return self.__L
    @L.setter
273
    def L(self,value): self.__L.value = SIfloat(value)       
Daniel Brown's avatar
Daniel Brown committed
274
275
276
277
278
279
280
281
282
283
284
        
    @property
    def r_ap(self): return self.__r_ap
    @r_ap.setter
    def r_ap(self,value): self.__r_ap.value = SIfloat(value)

    @property
    def mass(self): return self.__mass
    @mass.setter
    def mass(self,value): self.__mass.value = SIfloat(value)
    
Daniel Brown's avatar
Daniel Brown committed
285
286
287
288
289
290
291
292
293
294
    @property
    def Ix(self): return self.__Ix
    @Ix.setter
    def Ix(self,value): self.__Ix.value = SIfloat(value)
    
    @property
    def Iy(self): return self.__Iy
    @Iy.setter
    def Iy(self,value): self.__Iy.value = SIfloat(value)
    
Daniel Brown's avatar
Daniel Brown committed
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
    @property
    def R(self): return self.__R
    @R.setter
    def R(self,value): self.__R.value = SIfloat(value)
    
    @property
    def T(self): return self.__T
    @T.setter
    def T(self,value): self.__T.value = SIfloat(value)
        
    @property
    def phi(self): return self.__phi
    @phi.setter
    def phi(self,value): self.__phi.value = SIfloat(value)
    
    @property
    def Rcx(self): return self.__Rcx
    @Rcx.setter
    def Rcx(self,value): self.__Rcx.value = SIfloat(value)
    
    @property
    def Rcy(self): return self.__Rcy
    @Rcy.setter
    def Rcy(self,value): self.__Rcy.value = SIfloat(value)
    
    @property
    def xbeta(self): return self.__xbeta
    @xbeta.setter
    def xbeta(self,value): self.__xbeta.value = SIfloat(value)
    
    @property
    def ybeta(self): return self.__ybeta
    @ybeta.setter
    def ybeta(self,value): self.__ybeta.value = SIfloat(value)
    
Daniel Brown's avatar
Daniel Brown committed
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
    @property
    def zmech(self): return self.__zmech
    @zmech.setter
    def zmech(self,value): self.__zmech.value = value
    
    @property
    def rxmech(self): return self.__rxmech
    @rxmech.setter
    def rxmech(self,value): self.__rxmech.value = value
    
    @property
    def rymech(self): return self.__rymech
    @rymech.setter
    def rymech(self,value): self.__rymech.value = value
    
Daniel Brown's avatar
Daniel Brown committed
345
346
347
348
349
350
351
352
353
354
355
356
    @property
    def Rc(self):
        if self.Rcx == self.Rcy:
            return self.Rcx
        else:
            return [self.Rcx, self.Rcy]
    
    @Rc.setter
    def Rc(self,value):
        self.Rcx.value = SIfloat(value)
        self.Rcy.value = SIfloat(value)

Daniel Brown's avatar
Daniel Brown committed
357
358
359
360
361
362
363
    def parseAttribute(self, key, value):
        if key in ["Rcx", "Rx", "ROCx", "rx", "rcx", "rocx"]:
            self.Rcx = value
        elif key in ["Rcy", "Ry", "ROCy", "ry", "rcy", "rocy"]:
            self.Rcy = value
        elif key in ["Rc", "ROC", "r", "rc", "roc"]:
            self.Rc = value
Daniel Brown's avatar
Daniel Brown committed
364
        elif key in ["M","m", "Mass", "mass"]:
Daniel Brown's avatar
Daniel Brown committed
365
            self.mass = value
Daniel Brown's avatar
Daniel Brown committed
366
        elif key in ["xbeta", "xBeta"]:
Daniel Brown's avatar
Daniel Brown committed
367
            self.xbeta = value
Daniel Brown's avatar
Daniel Brown committed
368
        elif key in ["ybeta","yBeta"]:
Daniel Brown's avatar
Daniel Brown committed
369
370
371
372
373
374
375
            self.ybeta = value
        elif key in ["x_off"]:
            self.x_offset = value
        elif key in ["y_off"]:
            self.y_offset = value
        elif key in ["r_ap"]:
            self.r_ap = value
Daniel Brown's avatar
Daniel Brown committed
376
377
378
379
        elif key in ["Ix","ix"]:
            self.Ix = value
        elif key in ["Iy","iy"]:
            self.Iy = value
Daniel Brown's avatar
Daniel Brown committed
380
381
382
383
384
385
        elif key in ["zmech", "mech"]:
            self.zmech = value
        elif key in ["rxmech"]:
            self.rxmech = value
        elif key in ["rymech"]:
            self.rymech = value
Daniel Brown's avatar
Daniel Brown committed
386
387
388
389
390
        else:
            return False
            
        return True
        
Daniel Brown's avatar
Daniel Brown committed
391
class mirror(AbstractMirrorComponent):
392
    def __init__(self,name,node1,node2,R=None,T=None,L=None,phi=0,Rcx=None,Rcy=None,xbeta=None,ybeta=None,mass=None, r_ap=None):
Daniel Brown's avatar
Daniel Brown committed
393
        super(mirror, self).__init__(name, R, T, L, phi, Rcx, Rcy, xbeta, ybeta, mass, r_ap)
Daniel Brown's avatar
Daniel Brown committed
394
395
396
        
        self._requested_node_names.append(node1)
        self._requested_node_names.append(node2)
Daniel Brown's avatar
Daniel Brown committed
397
398
399
400
401
402
403

    def parseAttributes(self, values):
        
        for key in values.keys():
            if not self.parseAttribute(key, values[key]):
                raise pkex.BasePyKatException("No attribute {0} for mirrors".format(key))
        
Daniel Brown's avatar
Daniel Brown committed
404
405
    @staticmethod
    def parseFinesseText(text):
406
        values = text.split()
Daniel Brown's avatar
Daniel Brown committed
407
408

        if values[0] != "m" and values[0] != "m1" and values[0] != "m2":
409
            raise pkex.BasePyKatException("'{0}' not a valid Finesse mirror command".format(text))
Daniel Brown's avatar
Daniel Brown committed
410
411
        
        if len(values) != 7:
412
            raise pkex.BasePyKatException("Mirror Finesse code format incorrect '{0}'".format(text))
Daniel Brown's avatar
Daniel Brown committed
413
414
415

        if len(values[0])==1:
            values.pop(0) # remove initial value
Daniel Brown's avatar
Daniel Brown committed
416
            return mirror(values[0], values[4], values[5], L=None, R=values[1], T=values[2], phi=values[3])
Daniel Brown's avatar
Daniel Brown committed
417
418
419
        else:
            if values[0][1]=="1":
                values.pop(0) # remove initial value
Daniel Brown's avatar
Daniel Brown committed
420
                return mirror(values[0], values[4], values[5], R=None, L=values[2], T=values[1], phi=values[3])
Daniel Brown's avatar
Daniel Brown committed
421
422
            else:
                values.pop(0) # remove initial value
Daniel Brown's avatar
Daniel Brown committed
423
                return mirror(values[0], values[4], values[5], T=None, R=values[1], L=values[2], phi=values[3])
Daniel Brown's avatar
Daniel Brown committed
424

425
    def getFinesseText(self):
Daniel Brown's avatar
Daniel Brown committed
426
        if self.R+self.T+self.L > 1:
427
428
            raise pkex.BasePyKatException("Mirror {0} has R+T+L > 1".format(self.name))        
        
Daniel Brown's avatar
Daniel Brown committed
429
430
431
432
433
434
435
436
437
438
439
440
        rtn = []
            
        rtn.append('m {0} {1} {2} {3} {4} {5}'.format(
                self.name, self.R.value, self.T.value, self.phi.value,
                self.nodes[0].name, self.nodes[1].name))

        for p in self._params:
            rtn.extend(p.getFinesseText())
                    
        return rtn
        
    def getQGraphicsItem(self):
441
442
443
        if not USE_GUI:
            raise NoGUIException
            
Daniel Brown's avatar
Daniel Brown committed
444
445
446
447
448
449
        if self._svgItem == None:
            self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
            
        return self._svgItem

class beamSplitter(AbstractMirrorComponent):
450
451
    def __init__(self, name, node1, node2, node3, node4, R = None, T = None, L=None, phi = 0, alpha = 0, Rcx = None, Rcy = None, xbeta = None, ybeta = None, mass = None, r_ap = None):
        super(beamSplitter, self).__init__(name, R, T, L, phi, Rcx, Rcy, xbeta, ybeta, mass, r_ap)
Daniel Brown's avatar
Daniel Brown committed
452
453
454
455
456
        
        self._requested_node_names.append(node1)
        self._requested_node_names.append(node2)
        self._requested_node_names.append(node3)
        self._requested_node_names.append(node4)
Daniel Brown's avatar
Daniel Brown committed
457
        self.__alpha = Param("alpha", self, SIfloat(alpha))
458
        
Daniel Brown's avatar
Daniel Brown committed
459
460
461
462
463
    @property
    def alpha(self): return self.__alpha
    @alpha.setter
    def alpha(self,value): self.__alpha.value = SIfloat(value)
    
Daniel Brown's avatar
Daniel Brown committed
464
465
466
467
468
469
470
471
    def parseAttributes(self, values):
        
        for key in values.keys():
            if not self.parseAttribute(key, values[key]):
                if key == "alpha":
                    self.alpha = values[key]
                else:
                    raise pkex.BasePyKatException("No attribute {0} for mirrors".format(key))
472
                
Daniel Brown's avatar
Daniel Brown committed
473
474
    @staticmethod
    def parseFinesseText(text):
475
        values = text.split()
Daniel Brown's avatar
Daniel Brown committed
476
477

        if values[0] != "bs" and values[0] != "bs1" and values[0] != "bs2":
478
            raise pkex.BasePyKatException("'{0}' not a valid Finesse beam splitter command".format(text))
Daniel Brown's avatar
Daniel Brown committed
479
480
        
        if len(values) != 10:
481
            raise pkex.BasePyKatException("Beam splitter Finesse code format incorrect '{0}'".format(text))
Daniel Brown's avatar
Daniel Brown committed
482

483
        if len(values[0])==2:
Daniel Brown's avatar
Daniel Brown committed
484
            values.pop(0) # remove initial value
Daniel Brown's avatar
Daniel Brown committed
485
486
            return beamSplitter(values[0], values[5], values[6], values[7], values[8],
                                values[1], values[2], None, values[3], values[4])
487
488
        elif values[0][2]=="1":
            values.pop(0) # remove initial value
Daniel Brown's avatar
Daniel Brown committed
489
490
            return beamSplitter(values[0], values[5], values[6], values[7], values[8],
                                None, values[1], values[2], values[3], values[4])
Daniel Brown's avatar
Daniel Brown committed
491
        else:
492
            values.pop(0) # remove initial value
Daniel Brown's avatar
Daniel Brown committed
493
494
            return beamSplitter(values[0], values[5], values[6], values[7], values[8],
                                values[1], None, values[2], values[3], values[4])
495
        
Daniel Brown's avatar
Daniel Brown committed
496
    def getFinesseText(self):
Daniel Brown's avatar
Daniel Brown committed
497
498
499
        if self.R+self.T+self.L > 1:
            raise pkex.BasePyKatException("Beamsplitter {0} has R+T+L > 1".format(self.name))

Daniel Brown's avatar
Daniel Brown committed
500
501
502
        rtn = []
            
        rtn.append('bs {0} {1} {2} {3} {4} {5} {6} {7} {8}'.format(
503
504
                self.name, self.R.value, self.T.value, self.phi.value,
                self.alpha.value, self.nodes[0].name,
Daniel Brown's avatar
Daniel Brown committed
505
506
507
508
509
510
511
512
513
                self.nodes[1].name, self.nodes[2].name,
                self.nodes[3].name))

        for p in self._params:
            rtn.extend(p.getFinesseText())
            
        return rtn
        
    def getQGraphicsItem(self):
514
515
516
        if not USE_GUI:
            raise NoGUIException
            
Daniel Brown's avatar
Daniel Brown committed
517
518
        if self._svgItem == None:
            # FIXME: make proper SVG component for beam splitter
519
            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])])
Daniel Brown's avatar
Daniel Brown committed
520
521
522
523
            
        return self._svgItem
   
class space(Component):
524
    def __init__(self, name, node1, node2, L = 0, n = 1, g = None, gx = None, gy = None):
Daniel Brown's avatar
Daniel Brown committed
525
526
527
528
529
        Component.__init__(self, name)
        
        self._requested_node_names.append(node1)
        self._requested_node_names.append(node2)
        self._QItem = None
Daniel Brown's avatar
Daniel Brown committed
530
        self.__L = Param("L", self, SIfloat(L), canFsig=True, fsig_name="phase")
Daniel Brown's avatar
Daniel Brown committed
531
        self.__n = Param("n", self, SIfloat(n))
532

533
534
        self.__gx = AttrParam("gx", self, gx)
        self.__gy = AttrParam("gy", self, gy)
Daniel Brown's avatar
Daniel Brown committed
535
        
Daniel Brown's avatar
Daniel Brown committed
536
537
        self._default_fsig_param = self.__L
        
Daniel Brown's avatar
Daniel Brown committed
538
539
540
    @property
    def L(self): return self.__L
    @L.setter
Andreas Freise's avatar
Andreas Freise committed
541
    def L(self,value): self.__L.value = SIfloat(value)
Daniel Brown's avatar
Daniel Brown committed
542
543
544
545
    @property
    def n(self): return self.__n
    @n.setter
    def n(self,value): self.__n.value = SIfloat(value)
546
547

    @property
Daniel Brown's avatar
Daniel Brown committed
548
549
550
551
552
553
    def g(self):
        if self.__gx.value == self.__gy.value: 
            return self.__g
        else:
            raise pkex.BasePyKatException("Gouy phase in x and y directions are different, use gx and gy properties instead")
            
554
    @g.setter
Daniel Brown's avatar
Daniel Brown committed
555
556
557
558
    def g(self,value):
        self.__gx.value = SIfloat(value)
        self.__gy.value = SIfloat(value)
        
559
560
561
562
563
564
565
566
567
    @property
    def gx(self): return self.__gx
    @gx.setter
    def gx(self,value): self.__gx.value = SIfloat(value)

    @property
    def gy(self): return self.__gy
    @gy.setter
    def gy(self,value): self.__gy.value = SIfloat(value)
Daniel Brown's avatar
Daniel Brown committed
568
    
Daniel Brown's avatar
Daniel Brown committed
569
570
571
572
573
574
575
    def parseAttributes(self, values):
        
        for key in values.keys():
            if key in ["gx","gouyx"]:
                self.__gx.value = values[key]
            elif key in ["gy", "gouyy"]:
                self.__gy.value = values[key]
576
            elif key in ["g","gouy"]:
Daniel Brown's avatar
Daniel Brown committed
577
578
579
580
581
                self.__gx.value = values[key]
                self.__gy.value = values[key]
            else:
                raise pkex.BasePyKatException("No attribute {0} for spaces".format(key))
                
Daniel Brown's avatar
Daniel Brown committed
582
583
    @staticmethod
    def parseFinesseText(text):
584
        values = text.split()
Daniel Brown's avatar
Daniel Brown committed
585
586

        if values[0] != "s":
587
            raise pkex.BasePyKatException("'{0}' not a valid Finesse space command".format(text))
Daniel Brown's avatar
Daniel Brown committed
588
589
590
591
592
593
594
595

        values.pop(0) # remove initial value
        
        if len(values) == 5:
            return space(values[0], values[3], values[4], values[1], values[2])
        elif len(values) == 4:
            return space(values[0], values[2], values[3], values[1])
        else:
596
            raise pkex.BasePyKatException("Space Finesse code format incorrect '{0}'".format(text))
Daniel Brown's avatar
Daniel Brown committed
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
        
    def getFinesseText(self):
        rtn = []
        
        if self.__n == 1:
            rtn.append('s {0} {1} {2} {3}'.format(self.name, self.__L.value, self.nodes[0].name, self.nodes[1].name))
        else:
            rtn.append('s {0} {1} {2} {3} {4}'.format(self.name, self.__L.value, self.__n.value, self.nodes[0].name, self.nodes[1].name))
       
        for p in self._params:
            rtn.extend(p.getFinesseText())
            
        return rtn
        
    def getQGraphicsItem(self):
612
613
614
        if not USE_GUI:
            raise NoGUIException
            
Daniel Brown's avatar
Daniel Brown committed
615
616
617
618
619
620
        if self._QItem == None:
            self._QItem = pykat.gui.graphics.SpaceQGraphicsItem(self)
        
        return self._QItem

class grating(Component):
621
    def __init__(self, name, node1, node2, node3 = None, node4 = None, n = 2, d = 0, eta_0 = None, eta_1 = None, eta_2 = None, eta_3 = None, rho_0 = None, alpha = None): # TODO: implement Rcx, Rcy and Rc
Daniel Brown's avatar
Daniel Brown committed
622
623
624
625
626
627
628
629
630
        Component.__init__(self, name)
        
        self._requested_node_names.append(node1)
        self._requested_node_names.append(node2)

        if n > 2:
            if node3 != None:
                self._requested_node_names.append(node3)
            else:
631
                raise pkex.BasePyKatException("Grating node 3 not specified")
Daniel Brown's avatar
Daniel Brown committed
632
633
634
635
636

        if n > 3:
            if node4 != None:
                self._requested_node_names.append(node4)
            else:
637
                raise pkex.BasePyKatException("Grating node 4 not specified")
Daniel Brown's avatar
Daniel Brown committed
638
639

        if n > 4 or n < 2:
640
            raise pkex.BasePyKatException("Grating must have between 2 and 4 ports")
Daniel Brown's avatar
Daniel Brown committed
641
642
643
644
645
646
647
648
649
        
        self.__n = n
        self.__d = Param("d", self, SIfloat(d))
        self.__eta_0 = AttrParam("eta_0", self, SIfloat(eta_0))
        self.__eta_1 = AttrParam("eta_1", self, SIfloat(eta_1))
        self.__eta_2 = AttrParam("eta_2", self, SIfloat(eta_2))
        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))
650
651
        self._svgItem = None
        
Daniel Brown's avatar
Daniel Brown committed
652
653
654
655
656
    @property
    def n(self): return Param('n', self.__n)
    @n.setter
    def n(self, value):
        if value < 2 or value > 4:
657
            raise pkex.BasePyKatException("Grating must have between 2 and 4 ports")
Daniel Brown's avatar
Daniel Brown committed
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
        else:
            self.__n = value
    
    @property
    def d(self): return self.__d
    @d.setter
    def d(self, value): self.__d.value = SIfloat(value)
    
    @property
    def eta_0(self): return self.__eta_0
    @eta_0.setter
    def eta_0(self, value): self.__eta_0.value = SIfloat(value)
    
    @property
    def eta_1(self): return self.__eta_1
    @eta_1.setter
    def eta_1(self, value): self.__eta_1.value = SIfloat(value)
    
    @property
    def eta_2(self): return self.__eta_2
    @eta_2.setter
    def eta_2(self, value): self.__eta_2.value = SIfloat(value)
    
    @property
    def eta_3(self): return self.__eta_3
    @eta_3.setter
    def eta_3(self, value): self.__eta_3.value = SIfloat(value)
    
    @property
    def rho_0(self): return self.__rho_0
    @rho_0.setter
    def rho_0(self, value): self.__rho_0.value = SIfloat(value)
    
    @property
    def alpha(self): return self.__alpha
    @alpha.setter
    def alpha(self, value): self.__alpha.value = SIfloat(value)
    
    @staticmethod
    def parseFinesseText(text):
698
        values = text.split()
Daniel Brown's avatar
Daniel Brown committed
699
700

        if values[0][0 : 2] != "gr":
701
            raise pkex.BasePyKatException("'{0}' not a valid Finesse grating command".format(text))
Daniel Brown's avatar
Daniel Brown committed
702
703
704

        if len(values[0]) > 2:
            if int(values[0][2]) > 4 or int(values[0][2]) < 2:
705
                raise pkex.BasePyKatException("Grating must have between 2 and 4 ports")
Daniel Brown's avatar
Daniel Brown committed
706
707
708
709
710
711
712
713
714
            else:
                n = int(values[0][2])
        else:
            n = 2

        values.pop(0) # remove initial value
        
        if n == 2:
            if len(values) != 4:
715
                raise pkex.BasePyKatException("Two port grating must have 2 nodes defined")
Daniel Brown's avatar
Daniel Brown committed
716
717
718
719

            return grating(values[0], values[2], values[3], None, None, n, values[1])
        elif n == 3:
            if len(values) != 5:
720
                raise pkex.BasePyKatException("Three port grating must have 3 nodes defined")
Daniel Brown's avatar
Daniel Brown committed
721
722
723
724
            
            return grating(values[0], values[2], values[3], values[4], None, n, values[1])
        else:
            if len(values) != 6:
725
                raise pkex.BasePyKatException("Four port grating must have 4 nodes defined")
Daniel Brown's avatar
Daniel Brown committed
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
            
            return grating(values[0], values[2], values[3], values[4], values[5], n, values[1])
        
    def getFinesseText(self):
        rtn = []
        
        if self.__n == 2:
            rtn.append('gr{0} {1} {2} {3} {4}'.format(self.__n, self.name, self.__d.value, self.nodes[0].name, self.nodes[1].name))
        elif self.__n == 3:
            rtn.append('gr{0} {1} {2} {3} {4} {5}'.format(self.__n, self.name, self.__d.value, self.nodes[0].name, self.nodes[1].name, self.nodes[2].name))
        else:
            rtn.append('gr{0} {1} {2} {3} {4} {5} {6}'.format(self.__n, self.name, self.__d.value, self.nodes[0].name, self.nodes[1].name, self.nodes[2].name, self.nodes[3].name))
        
        for p in self._params:
            rtn.extend(p.getFinesseText())
        
        return rtn
       
    def getQGraphicsItem(self):
745
746
747
        if not USE_GUI:
            raise NoGUIException
            
748
749
        if self._svgItem == None:
            self._svgItem = pykat.gui.graphics.SpaceQGraphicsItem(self) # TODO: make SVG graphic for grating
Daniel Brown's avatar
Daniel Brown committed
750
        
751
        return self._svgItem
Daniel Brown's avatar
Daniel Brown committed
752
753

class isolator(Component):
754
    def __init__(self, name, node1, node2, S = 0, node3="dump"):
Daniel Brown's avatar
Daniel Brown committed
755
756
757
758
        Component.__init__(self, name)
        
        self._requested_node_names.append(node1)
        self._requested_node_names.append(node2)
759
        self._requested_node_names.append(node3)
760
        self._svgItem = None
Daniel Brown's avatar
Daniel Brown committed
761
762
763
764
765
766
767
768
769
770
        
        self.__S = Param("S",self,SIfloat(S))
        
    @property
    def S(self): return self.__S
    @S.setter
    def S(self, value): self.__S.value = SIfloat(value)
    
    @staticmethod
    def parseFinesseText(text):
771
        values = text.split()
Daniel Brown's avatar
Daniel Brown committed
772
773

        if values[0] != "isol":
774
            raise pkex.BasePyKatException("'{0}' not a valid Finesse isolator command".format(text))
Daniel Brown's avatar
Daniel Brown committed
775
776
777
778
779

        values.pop(0) # remove initial value
        
        if len(values) == 4:
            return isolator(values[0], values[2], values[3], values[1])
780
        elif len(values) == 5:
781
            return isolator(values[0], values[2], values[3], node3=values[4], S=values[1])
Daniel Brown's avatar
Daniel Brown committed
782
        else:
783
            raise pkex.BasePyKatException("Isolator Finesse code format incorrect '{0}'".format(text))
Daniel Brown's avatar
Daniel Brown committed
784
785
        
    def getFinesseText(self):
786
        rtn = ['isol {0} {1} {2} {3} {4}'.format(self.name, self.S.value, self.nodes[0].name, self.nodes[1].name, self.nodes[2].name)]
Daniel Brown's avatar
Daniel Brown committed
787
788
789
790
791
        
        for p in self._params:
            rtn.extend(p.getFinesseText())
            
        return rtn
792

Daniel Brown's avatar
Daniel Brown committed
793
    def getQGraphicsItem(self):
794
795
796
        if not USE_GUI:
            raise NoGUIException
            
797
798
        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])])
Daniel Brown's avatar
Daniel Brown committed
799
        
800
        return self._svgItem
Daniel Brown's avatar
Daniel Brown committed
801
802

class lens(Component):
803
    def __init__(self, name, node1, node2, f=1):
Daniel Brown's avatar
Daniel Brown committed
804
805
806
807
        Component.__init__(self, name)
        
        self._requested_node_names.append(node1)
        self._requested_node_names.append(node2)
808
        self._svgItem = None
Daniel Brown's avatar
Daniel Brown committed
809
810
811
812
813
814
815
816
817
        self.__f = Param("f", self, SIfloat(f))
        
    @property
    def f(self): return self.__f
    @f.setter
    def f(self, value): self.__f.value = SIfloat(value)
    
    @staticmethod
    def parseFinesseText(text):
818
        values = text.split()
Daniel Brown's avatar
Daniel Brown committed
819
820

        if values[0] != "lens":
821
            raise pkex.BasePyKatException("'{0}' not a valid Finesse lens command".format(text))
Daniel Brown's avatar
Daniel Brown committed
822
823
824
825
826
827

        values.pop(0) # remove initial value
        
        if len(values) == 4:
            return lens(values[0], values[2], values[3], values[1])
        else:
828
            raise pkex.BasePyKatException("Lens Finesse code format incorrect '{0}'".format(text))
Daniel Brown's avatar
Daniel Brown committed
829
830
831
832
833
834
835
836
        
    def getFinesseText(self):
        rtn = ['lens {0} {1} {2} {3}'.format(self.name, self.f.value, self.nodes[0].name, self.nodes[1].name)]
        
        for p in self._params:
            rtn.extend(p.getFinesseText())
            
        return rtn
Daniel Brown's avatar
Daniel Brown committed
837
        
Daniel Brown's avatar
Daniel Brown committed
838
    def getQGraphicsItem(self):
839
840
841
        if not USE_GUI:
            raise NoGUIException
            
842
843
        if self._svgItem == None:
            self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/lens.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
Daniel Brown's avatar
Daniel Brown committed
844
        
845
        return self._svgItem
Daniel Brown's avatar
Daniel Brown committed
846
847
        
class modulator(Component):
848
    def __init__(self, name, node1, node2, f, midx, order, modulation_type='pm', phase=0):
Daniel Brown's avatar
Daniel Brown committed
849
850
851
852
        Component.__init__(self, name)
        
        self._requested_node_names.append(node1)
        self._requested_node_names.append(node2)
853
        self._svgItem = None
Daniel Brown's avatar
Daniel Brown committed
854
855
        self.__f = Param("f", self, SIfloat(f))
        self.__midx = Param("midx", self, SIfloat(midx))
Daniel Brown's avatar
Daniel Brown committed
856
        self.__phase = Param("phase", self, SIfloat(phase), canFsig=True, fsig_name="phase")
Daniel Brown's avatar
Daniel Brown committed
857
858
859
        self.__order = order
        self.type = modulation_type
        
Daniel Brown's avatar
Daniel Brown committed
860
        self._default_fsig_param = self.__phase
Daniel Brown's avatar
Daniel Brown committed
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
            
    @property 
    def f(self): return self.__f
    @f.setter
    def f(self, value): self.__f.value = SIfloat(value)
    
    @property 
    def midx(self): return self.__midx
    @midx.setter
    def midx(self, value): self.__midx.value = SIfloat(value)
    
    @property 
    def phase(self): return self.__phase
    @phase.setter
    def phase(self, value): self.__phase.value = SIfloat(value)
    
    @property 
    def order(self): return self.__order
    @order.setter
    def order(self, value):
881
        if value <= 1 and value > 6:
Daniel Brown's avatar
Daniel Brown committed
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
            raise pkex.BasePyKatException("modulator order must be between 1 and 6")
            
        self.__order = int(value)
    
    @property 
    def type(self): return self.__type
    @type.setter
    def type(self, value):
        if value != "am" and value != "pm":
            raise pkex.BasePyKatException("Modulator type must be am (amplitude modulation) or pm (phase modulation)")
            
        self.__type = str(value)
    
    @staticmethod
    def parseFinesseText(text):
897
        v = text.split()
Daniel Brown's avatar
Daniel Brown committed
898
899

        if v[0] != "mod":
900
            raise pkex.BasePyKatException("'{0}' not a valid Finesse modulator command".format(text))
Daniel Brown's avatar
Daniel Brown committed
901
902
903
904

        v.pop(0) # remove initial value
        
        if len(v) == 7:
905
            return modulator(v[0], v[5], v[6], v[1], v[2], v[3], v[4])
Daniel Brown's avatar
Daniel Brown committed
906
        if len(v) == 8:
907
            return modulator(v[0], v[6], v[7], v[1], v[2], v[3], v[4], phase=v[5])
Daniel Brown's avatar
Daniel Brown committed
908
909
910
911
912
913
914
915
916
917
918
919
        else:
            raise pkex.BasePyKatException("Modulator Finesse code format incorrect '{0}'".format(text))
        
    def getFinesseText(self):
        rtn = ['mod {0} {1} {2} {3} {4} {5} {6} {7}'.format(self.name, self.f, self.midx, self.order, self.type, self.phase, self.nodes[0].name, self.nodes[1].name)]
        
        for p in self._params:
            rtn.extend(p.getFinesseText())
            
        return rtn
        
    def getQGraphicsItem(self):
920
921
922
        if not USE_GUI:
            raise NoGUIException
            
923
924
        if self._svgItem == None:
            self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/modulator.svg", self ,[(-4,15,self.nodes[0]), (14,15,self.nodes[1])])
Daniel Brown's avatar
Daniel Brown committed
925
        
926
        return self._svgItem
Daniel Brown's avatar
Daniel Brown committed
927
928

class laser(Component):
929
    def __init__(self, name, node, P=1, f=0, phase=0):
Daniel Brown's avatar
Daniel Brown committed
930
931
932
933
        Component.__init__(self,name)
        
        self._requested_node_names.append(node)
        
934
        self.__power = Param("P", self, SIfloat(P), canFsig=True, fsig_name="amp")
935
        self.__f_offset = Param("f", self, SIfloat(f), canFsig=True, fsig_name="f")
936
        self.__phase = Param("phase", self, SIfloat(phase), canFsig=True, fsig_name="phase")
937
        self.__noise = AttrParam("noise", self, None)
938
        self._svgItem = None
Daniel Brown's avatar
Daniel Brown committed
939
        
Daniel Brown's avatar
Daniel Brown committed
940
941
        self._default_fsig_param = self.__f_offset
        
Daniel Brown's avatar
Daniel Brown committed
942
    @property
943
944
945
    def P(self): return self.__power
    @P.setter
    def P(self,value): self.__power.value = float(value)
Daniel Brown's avatar
Daniel Brown committed
946
947
948
949
950
951
952
953
954
955
956
    
    @property
    def f(self): return self.__f_offset
    @f.setter
    def f(self,value): self.__f_offset.value = float(value)
    
    @property
    def phase(self): return self.__phase
    @phase.setter
    def phase(self,value): self.__phase.value = float(value)
    
Daniel Brown's avatar
Daniel Brown committed
957
958
959
960
961
962
963
964
    def parseAttributes(self, values):
        
        for key in values.keys():
            if key == "noise":
                self.__noise.value = values[key]
            else:
                raise pkex.BasePyKatException("No attribute {0} at laser".format(key))
    
Daniel Brown's avatar
Daniel Brown committed
965
966
    @staticmethod
    def parseFinesseText(text):
967
        values = text.split()
Daniel Brown's avatar
Daniel Brown committed
968
969

        if values[0] != "l":
970
            raise pkex.BasePyKatException("'{0}' not a valid Finesse laser command".format(text))
Daniel Brown's avatar
Daniel Brown committed
971
972
973
974

        values.pop(0) # remove initial value
        
        if len(values) == 5:
975
            return laser(values[0],values[4],P=values[1],f=values[2],phase=values[3])
Daniel Brown's avatar
Daniel Brown committed
976
        elif len(values) == 4:
977
            return laser(values[0],values[3],P=values[1],f=values[2], phase=0)
Daniel Brown's avatar
Daniel Brown committed
978
979
980
981
982
983
984
985
986
987
        else:
            raise exceptions.FinesseParse("Laser Finesse code format incorrect '{0}'".format(text))
    
    def getFinesseText(self):
        rtn = ['l {0} {1} {2} {3} {4}'.format(self.name, self.__power.value, self.__f_offset.value, self.__phase.value, self.nodes[0].name)]
        
        for p in self._params:
            rtn.extend(p.getFinesseText())
        
        return rtn
988
         
Daniel Brown's avatar
Daniel Brown committed
989
    def getQGraphicsItem(self):
990
991
992
        if not USE_GUI:
            raise NoGUIException
            
Daniel Brown's avatar
Daniel Brown committed
993
994
995
996
        if self._svgItem == None:
            self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/laser.svg", self, [(65,25,self.nodes[0])])
            
        return self._svgItem
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055

class squeezer(Component):
    def __init__(self, name, node, f=0, db=0, angle=0, phase=0):
        Component.__init__(self,name)
        
        self._requested_node_names.append(node)
        
        self.__f = Param("f", self, SIfloat(f), canFsig=True, fsig_name="f")
        self.__phase = Param("phase", self, SIfloat(phase), canFsig=True, fsig_name="phase")
        self.__db = Param("db", self, SIfloat(db), canFsig=False, fsig_name="r")
        self.__angle = Param("angle", self, SIfloat(angle), canFsig=False, fsig_name="angle")
        self._svgItem = None
        
    @property
    def db(self): return self.__db
    @db.setter
    def db(self,value): self.__db.value = float(value)
    
    @property
    def angle(self): return self.__angle
    @angle.setter
    def angle(self,value): self.__angle.value = float(value)
    
    @property
    def f(self): return self.__f
    @f.setter
    def f(self,value): self.__f.value = float(value)
    
    @property
    def phase(self): return self.__phase
    @phase.setter
    def phase(self,value): self.__phase.value = float(value)
    
    def parseAttributes(self, values):
        pass
    
    @staticmethod
    def parseFinesseText(text):
        values = text.split()

        if values[0] != "sq":
            raise pkex.BasePyKatException("'{0}' not a valid Finesse squeezer command".format(text))

        values.pop(0) # remove initial value
        
        if len(values) == 5:
            return squeezer(values[0], values[4], f=values[1], db=values[2], angle=values[3])
        else:
            raise exceptions.FinesseParse("Squeezer Finesse code format incorrect '{0}'".format(text))
    
    def getFinesseText(self):
        rtn = ['sq {0} {1} {2} {3} {4}'.format(self.name, self.f.value, self.db.value, self.angle.value, self.nodes[0].name)]
        
        for p in self._params:
            rtn.extend(p.getFinesseText())
        
        return rtn
         
    def getQGraphicsItem(self):
1056
1057
1058
        if not USE_GUI:
            raise NoGUIException
            
1059
1060
1061
1062
        if self._svgItem == None:
            self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/laser.svg", self, [(65,25,self.nodes[0])])
            
        return self._svgItem
Daniel Brown's avatar
Daniel Brown committed
1063