Esempio n. 1
0
class Optic(Traceable):
    abstract=True
    n_inside = Complex(1.0+0.0j) #refractive
    n_outside = Complex(1.0+0.0j)
    
    all_rays = Bool(False, desc="trace all reflected rays")
    
    vtkproperty = tvtk.Property(opacity = 0.4,
                             color = (0.8,0.8,1.0))
                             
    def _material_default(self):
        m = cmaterials.FullDielectricMaterial(n_inside = self.n_inside,
                                    n_outside = self.n_outside)
        return m
    
    def calc_refractive_index(self, wavelengths):
        """
        Evaluates an array of (complex) refractive indices.
        @param wavelengths: a shape=(N,1) array of wavelengths
        @returns: a 2-tuple representing the inside and outside
        refractive indices respectively. The items in the tuple can be
        either 1) an arrays with the same shape as wavelengths and with
                    dtype=numpy.complex128
            or 2) a complex scalar
        """
        return self.n_inside, self.n_outside
    
    @on_trait_change("n_inside, n_outside")
    def n_changed(self):
        self.material.n_inside = self.n_inside
        self.material.n_outside = self.n_outside
        self.update = True
Esempio n. 2
0
class TestTraits(HasTraits):
    b = Bool(False)
    i = Int(7)
    l = Int(12345678901234567890)
    f = Float(math.pi)
    c = Complex(complex(1.01234, 2.3))
    n = Any
    s = Str('String')
    u = Unicode(u'Unicode')
    inst = Instance(A)
    tuple = Tuple
    list = List
    pure_list = List(list(range(5)))
    dict = Dict
    numeric = Array(value=numpy.ones((2, 2, 2), 'f'))
    ref = Array
    if TVTK_AVAILABLE:
        _tvtk = Instance(tvtk.Property, ())

    def __init__(self):
        self.inst = A()
        self.tuple = (1, 2, 'a', A())
        self.list = [1, 1.1, 'a', 1j, self.inst]
        self.dict = {'a': 1, 'b': 2, 'ref': self.inst}
        self.ref = self.numeric
class TestTraits(HasTraits):
    b = Bool(False)
    i = Int(7)
    longi = Int(12345678901234567890)
    f = Float(math.pi)
    c = Complex(complex(1.01234, 2.3))
    n = Any
    s = Str("String")
    u = Str("Unicode")
    inst = Instance(A)
    tuple = Tuple
    list = List
    pure_list = List(list(range(5)))
    dict = Dict
    numeric = Array(value=numpy.ones((2, 2, 2), "f"))
    ref = Array
    if TVTK_AVAILABLE:
        _tvtk = Instance(tvtk.Property, ())

    def __init__(self):
        self.inst = A()
        self.tuple = (1, 2, "a", A())
        self.list = [1, 1.1, "a", 1j, self.inst]
        self.dict = {"a": 1, "b": 2, "ref": self.inst}
        self.ref = self.numeric
Esempio n. 4
0
class Test2(HasTraits):
    var = Complex(default_value="sdf")  # E: arg-type
Esempio n. 5
0
class Test(HasTraits):
    var = Complex()