示例#1
0
    def main():
        "Main code for demo purposes"
        logging.basicConfig(level=logging.DEBUG)

        mysys = OpticalSystem(name="s")
        mysys.lst = []
        mysys.lst.append({})
        mysys.lst.append({})
        mysys.lst[0]["a"] = FloatOptimizableVariable(FixedState(3.0),
                                                     name="v1")
        mysys.lst[1]["b"] = FloatOptimizableVariable(VariableState(7.0),
                                                     name="v2")

        mysys.rootcoordinatesystem.decz = FloatOptimizableVariable(
            FixedState(-99.0), name="decz")

        listOptimizableVariables(mysys)

        confmanager = ConfigManager(mysys, name="mc")

        [mysys2, mysys3] = confmanager.set_optimizable_variables(
            ("s2", "s3"), {
                "s.global.decz":
                (("pickup", lambda x: x + 2.0), ("pickup", lambda x: x + 3.0)),
                "s.global.decy": (("fixed", -2.), ("fixed", -3.))
            })
        mysys.rootcoordinatesystem.decx.setvalue(-98.0)
        for syscopy in (mysys2, mysys3):
            mydict = listOptimizableVariables(syscopy)
            print(mydict)
示例#2
0
    def initDemoSystem(self):
        s = OpticalSystem()

        lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0), refname=s.rootcoordinatesystem.name)
        lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=2.0), refname=lc0.name) # objectDist
        lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=3.0), refname=lc1.name)
        lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3", decz=5.0, tiltx=0.0*math.pi/180.0), refname=lc2.name)
        lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf4", decz=3.0), refname=lc3.name)
        lc5 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf5", decz=3.0), refname=lc4.name)
        lc6 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf6", decz=2.0), refname=lc5.name)
        lc7 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf7", decz=3.0), refname=lc6.name)
        lc8 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=19.0), refname=lc7.name)


        objectsurf = Surface(lc0)
        surf1 = Surface(lc1, shape=Conic(lc1, curv=1/-5.922))
        surf2 = Surface(lc2, shape=Conic(lc2, curv=1/-3.160))
        surf3 = Surface(lc3, shape=Conic(lc3, curv=1/15.884))
        surf4 = Surface(lc4, shape=Conic(lc4, curv=1/-12.756))
        stopsurf = Surface(lc5)
        surf6 = Surface(lc6, shape=Conic(lc6, curv=1/3.125))
        surf7 = Surface(lc7, shape=Conic(lc7, curv=1/1.479))
        image = Surface(lc8)


        elem = OpticalElement(lc0, label="lenssystem")

        glass = material_isotropic.ConstantIndexGlass(lc0, n=1.7)
        glass2 = material_isotropic.ConstantIndexGlass(lc0, n=1.5)

        elem.addMaterial("glass", glass)
        elem.addMaterial("glass2", glass2)

        elem.addSurface("object", objectsurf, (None, None))
        elem.addSurface("surf1", surf1, (None, "glass"))
        elem.addSurface("surf2", surf2, ("glass", None))
        elem.addSurface("surf3", surf3, (None, "glass"))
        elem.addSurface("surf4", surf4, ("glass", None))
        elem.addSurface("stop", stopsurf, (None, None))
        elem.addSurface("surf6", surf6, (None, "glass2"))
        elem.addSurface("surf7", surf7, ("glass2", None))
        elem.addSurface("image", image, (None, None))

        s.addElement("lenssys", elem)

        return s
示例#3
0
from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.globalconstants import canonical_ey

import math
import logging
logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

wave_red = 0.700e-3
wave_blue = 0.470e-3

# definition of optical system
s = OpticalSystem() 

deg = math.pi/180.

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=0.0), refname=s.rootcoordinatesystem.name)
lccomprism = s.addLocalCoordinateSystem(LocalCoordinates(name="prismcenter", decz=50.0), refname=lc0.name)

lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=-10.0, tiltx=30.*deg), refname=lccomprism.name) # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=10.0, tiltx=-30.*deg), refname=lccomprism.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=50.0), refname=lccomprism.name)


stopsurf = Surface(lc0)
frontsurf = Surface(lc1, shape=surfShape.Conic(lc1, curv=0), apert=CircularAperture(lc1, 20.0))
rearsurf = Surface(lc2, shape=surfShape.Conic(lc2, curv=0), apert=CircularAperture(lc2, 20.0))
image = Surface(lc3)
示例#4
0
from pyrateoptics.raytracer.globalconstants import canonical_ey

import math
import logging
logging.basicConfig(level=logging.DEBUG)

import pyrateoptics.raytracer.helpers

wavelength = 0.5876e-3

# definition of optical system

#v = np.ones(3)# + 0.001*np.random.random(3)
#myeps = np.diag(v)

s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)

#air = AnisotropicMaterial(lc0, myeps)  # tests for anisotropic mirror
air = ConstantIndexGlass(lc0, 1.0)
s.material_background = air

lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="m1",
                                                  decz=50.0,
                                                  tiltx=-math.pi / 8),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="m2_stop",
                                                  decz=-50.0,
                                                  decy=-20,
示例#5
0
from pyrateoptics.raytracer.optical_system import OpticalSystem

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates
from pyrateoptics.raytracer.globalconstants import degree


from pyrateoptics import draw, raytrace

logging.basicConfig(level=logging.DEBUG)


wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem(name='os')

lc0 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="stop", decz=1.0),
        refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="surf1", decz=10.0), refname=lc0.name)
lc2 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="surf2", decz=5.0, tiltx=10*math.pi/180.0),
        refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="image", decz=-5.0, tiltx=-10*math.pi/180.0),
        refname=lc2.name)


stopsurf = Surface(lc0)
示例#6
0
    OpticalSystemAnalysis

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

rnd_data1 = np.random.random((3, 3))  # np.eye(3)
rnd_data2 = np.random.random((3, 3))  # np.zeros((3, 3))#
lc = LocalCoordinates.p("1")
myeps = np.eye(3) + 0.1 * rnd_data1 + 0.01 * complex(0, 1) * rnd_data2
# aggressive complex choice of myeps
# myeps = np.eye(3) + 0.01*np.random.random((3, 3))
crystal = AnisotropicMaterial.p(lc, myeps)

# definition of optical system
s = OpticalSystem.p(matbackground=crystal)

lc0 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="m1",
                                                    decz=50.0,
                                                    tiltx=-math.pi / 8),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="m2_stop",
                                                    decz=-50.0,
                                                    decy=-20,
                                                    tiltx=math.pi / 16),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="m3",
                                                    decz=50.0,
                                                    decy=-30,
示例#7
0
from pyrateoptics.raytracer.globalconstants import degree, standard_wavelength

from pyrateoptics import draw

from pyrateoptics.analysis.optical_system_analysis import OpticalSystemAnalysis
from pyrateoptics.raytracer.helpers import build_pilotbundle_complex

# definition of optical system

# Design: US patent no. 5701202 A, inventor: Koichi Takahashi
# and also: Bo Chen, Alois M. Herkommer, Opt. Express 24, 26999 (2016)

logging.basicConfig(level=logging.INFO)

s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)

air = ConstantIndexGlass(lc0, 1.0)
glass = ConstantIndexGlass(lc0, 1.492)
s.material_background = air

si = -1.

lcD1 = s.addLocalCoordinateSystem(LocalCoordinates(name="D1", decz=30.002),
                                  refname=lc0.name)
lcS1 = s.addLocalCoordinateSystem(LocalCoordinates(name="S1",
                                                   decy=-24.028,
                                                   decz=26.360,
示例#8
0
from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.globalconstants import degree
from pyrateoptics import raytrace, draw

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

wave_red = 0.700e-3
wave_blue = 0.470e-3

# definition of optical system
s = OpticalSystem()

dropletradius = 0.1

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lccomprism = s.addLocalCoordinateSystem(LocalCoordinates(name="dropletcenter",
                                                         decz=2. *
                                                         dropletradius),
                                        refname=lc0.name)

lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1",
                                                  decz=-dropletradius),
                                 refname=lccomprism.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2",
                                                  decz=dropletradius),
示例#9
0
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.globalconstants import canonical_ey, degree, standard_wavelength

import math

import pyrateoptics.raytracer.helpers

# definition of optical system

# Design: US patent no. 5701202 A, inventor: Koichi Takahashi
# and also: Bo Chen, Alois M. Herkommer, Opt. Express 24, 26999 (2016)

logging.basicConfig(level=logging.INFO)

s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)

air = ConstantIndexGlass(lc0, 1.0)
glass = ConstantIndexGlass(lc0, 1.492)
s.material_background = air

si = -1.

lcD1 = s.addLocalCoordinateSystem(LocalCoordinates(name="D1", decz=30.002),
                                  refname=lc0.name)
lcS1 = s.addLocalCoordinateSystem(LocalCoordinates(name="S1",
                                                   decy=-24.028,
                                                   decz=26.360,
示例#10
0
from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.globalconstants import degree
from pyrateoptics import raytrace, draw

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

wave_red = 0.700e-3
wave_blue = 0.470e-3

# definition of optical system
s = OpticalSystem()

dropletradius = 0.1

lc0 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="stop", decz=0.0),
            refname=s.rootcoordinatesystem.name)
lccomprism = s.addLocalCoordinateSystem(
            LocalCoordinates(name="dropletcenter", decz=2.*dropletradius),
            refname=lc0.name)

lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1",
                                                  decz=-dropletradius),
                                 refname=lccomprism.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="surf2", decz=dropletradius),
示例#11
0
from pyrateoptics import draw

from pyrateoptics.raytracer.globalconstants import degree

from pyrateoptics.raytracer.aim import Aimy

logging.basicConfig(level=logging.INFO)

wavelength = 0.5876e-3

# definition of optical system

# v = np.ones(3)# + 0.001*np.random.random(3)
# myeps = np.diag(v)

s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)

# air = AnisotropicMaterial(lc0, myeps)  # tests for anisotropic mirror
air = ConstantIndexGlass(lc0, 1.0)
s.material_background = air

lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="m1",
                                                  decz=50.0,
                                                  tiltx=-math.pi / 8),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="m2_stop",
                                                  decz=-50.0,
                                                  decy=-20,
示例#12
0
                                else:
                                    self.warning("Unknown type for multi config values")
                        else:
                            self.debug("Reseting %s" % (key,))
                            instance.resetVariable(key, self.base_instance.getVariable(key))
                    # set names of the new instances accordingly
                    self.debug("Setting name of instance %s" % (names_tuple[index]))
                    instance.setName(names_tuple[index])

        return instance_list

if __name__ == "__main__":

    logging.basicConfig(level=logging.DEBUG)

    s = OpticalSystem(name="s")
    s.lst = []
    s.lst.append({})
    s.lst.append({})
    s.lst[0]["a"] = OptimizableVariable(variable_type="fixed", name="v1", value=3.0)
    s.lst[1]["b"] = OptimizableVariable(variable_type="variable", name="v2", value=7.0)

    s.rootcoordinatesystem.decz = OptimizableVariable(name="decz", value=-99.0)

    listOptimizableVariables(s)

    m = ConfigManager(s, name="mc")

    [s2, s3] = m.setOptimizableVariables(("s2", "s3"),
                {"s.global.decz": (("pickup", lambda x: x + 2.0),
                                   ("pickup", lambda x: x + 3.0)),
示例#13
0
文件: demo_grin.py 项目: joha2/pyrate
from pyrateoptics.raytracer.surface_shape import Conic
from pyrateoptics.raytracer.optical_element import OpticalElement
from pyrateoptics.raytracer.surface import Surface
from pyrateoptics.raytracer.optical_system import OpticalSystem

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics import raytrace, draw

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="obj", decz=0.0),
            refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="surf1", decz=10.0, tiltx=5.*math.pi/180.0),
            refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="surf2", decz=20.0, tiltx=10.*math.pi/180.0),
            refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="image", decz=10.0), refname=lc2.name)


stopsurf = Surface(lc0)
示例#14
0
from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.globalconstants import canonical_ey, degree

import math
import logging
logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

wave_red = 0.700e-3
wave_blue = 0.470e-3

# definition of optical system
s = OpticalSystem()

dropletradius = 0.1

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lccomprism = s.addLocalCoordinateSystem(LocalCoordinates(name="dropletcenter",
                                                         decz=2. *
                                                         dropletradius),
                                        refname=lc0.name)

lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1",
                                                  decz=-dropletradius),
                                 refname=lccomprism.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2",
                                                  decz=dropletradius),
示例#15
0
from pyrateoptics.raytracer.optical_system import OpticalSystem
from pyrateoptics.raytracer.ray import RayBundle

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.globalconstants import canonical_ey

import math
import logging
logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem(name='os')

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=1.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=10.0),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2",
                                                  decz=5.0,
                                                  tiltx=10 * math.pi / 180.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="image",
                                                  decz=-5.0,
                                                  tiltx=-10 * math.pi / 180.0),
                                 refname=lc2.name)

stopsurf = Surface(lc0)
示例#16
0
from pyrateoptics.raytracer.optical_system import OpticalSystem

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.analysis.optical_system_analysis import\
    OpticalSystemAnalysis

from pyrateoptics import draw

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem(name='os')

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=-1.048),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=4.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3", decz=2.5),
                                 refname=lc2.name)
lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=97.2),
                                 refname=lc3.name)

stopsurf = Surface(lc0, name="stopsurf")
frontsurf = Surface(lc1,
                    name="frontsurf",
示例#17
0
from pyrateoptics.raytracer.surface import Surface

from pyrateoptics.raytracer.globalconstants import canonical_ey, degree

from pyrateoptics.analysis.optical_system_analysis import OpticalSystemAnalysis
from pyrateoptics.analysis.surfShape_analysis import ShapeAnalysis
from pyrateoptics.sampling2d.raster import RandomGrid

from pyrateoptics.analysis.optical_system_analysis import OpticalSystemAnalysis

wavelength = standard_wavelength

logging.basicConfig(level=logging.DEBUG)

# definition of optical system
s = OpticalSystem()  # objectDistance = 2.0

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=2.0),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=3.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3",
                                                  decz=5.0,
                                                  tiltx=2.5 * degree),
                                 refname=lc2.name)
lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf4", decz=3.0),
                                 refname=lc3.name)
lc5 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf5", decz=3.0),
                                 refname=lc4.name)
示例#18
0
from pyrateoptics.analysis.optical_system_analysis import OpticalSystemAnalysis

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

rnd_data1 = np.random.random((3, 3))  # np.eye(3)
rnd_data2 = np.random.random((3, 3))  # np.zeros((3, 3))#
lc = LocalCoordinates("1")
myeps = np.eye(3) + 0.1 * rnd_data1 + 0.01 * complex(0, 1) * rnd_data2
# aggressive complex choice of myeps
# myeps = np.eye(3) + 0.01*np.random.random((3, 3))
crystal = AnisotropicMaterial(lc, myeps)

# definition of optical system
s = OpticalSystem(matbackground=crystal)

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="m1",
                                                  decz=50.0,
                                                  tiltx=-math.pi / 8),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="m2_stop",
                                                  decz=-50.0,
                                                  decy=-20,
                                                  tiltx=math.pi / 16),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="m3",
                                                  decz=50.0,
                                                  decy=-30,
示例#19
0
文件: demo_hud.py 项目: joha2/pyrate
from pyrateoptics.raytracer.globalconstants import degree, standard_wavelength

from pyrateoptics import draw

from pyrateoptics.analysis.optical_system_analysis import OpticalSystemAnalysis
from pyrateoptics.raytracer.helpers import build_pilotbundle_complex

# definition of optical system

# Design: US patent no. 5701202 A, inventor: Koichi Takahashi
# and also: Bo Chen, Alois M. Herkommer, Opt. Express 24, 26999 (2016)

logging.basicConfig(level=logging.INFO)

s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)

air = ConstantIndexGlass(lc0, 1.0)
glass = ConstantIndexGlass(lc0, 1.492)
s.material_background = air

si = -1.

lcD1 = s.addLocalCoordinateSystem(LocalCoordinates(name="D1", decz=30.002), refname=lc0.name)
lcS1 = s.addLocalCoordinateSystem(LocalCoordinates(name="S1",               decy=-24.028,   decz=26.360, tiltx=-si*14.7*degree, tiltThenDecenter=False), refname=lc0.name)
lcD1prime = s.addLocalCoordinateSystem(LocalCoordinates(name="D1prime",     decy=0.,        decz=30.002, tiltx=-si*1.066*degree, tiltThenDecenter=False), refname=lc0.name)
lcD2 = s.addLocalCoordinateSystem(LocalCoordinates(name="D2",               decy=-0.251,    decz=43.485, tiltx=-si*1.066*degree, tiltThenDecenter=False), refname=lc0.name)
lcS2 = s.addLocalCoordinateSystem(LocalCoordinates(name="S2",               decy=19.109,    decz=33.339, tiltx=si*36.660*degree, tiltThenDecenter=False), refname=lc0.name)
示例#20
0
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
"""

import jsonpickle
import logging
logging.basicConfig(level=logging.DEBUG)

from pyrateoptics.raytracer.optical_system import OpticalSystem

# definition of optical system

s = OpticalSystem()

print("pickle dump")
frozen = jsonpickle.encode(s)

with open('optical_sys.jpkl', 'w') as output:
    output.write(frozen)

# WARNING: code is operational, but not tested
示例#21
0
    def initDemoSystem(self):
        s = OpticalSystem.p()

        lc0 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="object",
                                                            decz=0.0),
                                         refname=s.rootcoordinatesystem.name)
        lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf1",
                                                            decz=2.0),
                                         refname=lc0.name)  # objectDist
        lc2 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf2",
                                                            decz=3.0),
                                         refname=lc1.name)
        lc3 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf3",
                                                            decz=5.0,
                                                            tiltx=0.0 *
                                                            math.pi / 180.0),
                                         refname=lc2.name)
        lc4 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf4",
                                                            decz=3.0),
                                         refname=lc3.name)
        lc5 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf5",
                                                            decz=3.0),
                                         refname=lc4.name)
        lc6 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf6",
                                                            decz=2.0),
                                         refname=lc5.name)
        lc7 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf7",
                                                            decz=3.0),
                                         refname=lc6.name)
        lc8 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="image",
                                                            decz=19.0),
                                         refname=lc7.name)

        objectsurf = Surface.p(lc0)
        surf1 = Surface.p(lc1,
                          shape=Conic.p(lc1, curv=1 / -5.922),
                          aperture=CircularAperture.p(lc1, maxradius=10.0))
        surf2 = Surface.p(lc2,
                          shape=Conic.p(lc2, curv=1 / -3.160),
                          aperture=CircularAperture.p(lc2, maxradius=10.0))
        surf3 = Surface.p(lc3,
                          shape=Conic.p(lc3, curv=1 / 15.884),
                          aperture=CircularAperture.p(lc3, maxradius=10.0))
        surf4 = Surface.p(lc4,
                          shape=Conic.p(lc4, curv=1 / -12.756),
                          aperture=CircularAperture.p(lc4, maxradius=10.0))
        stopsurf = Surface.p(lc5,
                             aperture=CircularAperture.p(lc5, maxradius=10.0))
        surf6 = Surface.p(lc6,
                          shape=Conic.p(lc6, curv=1 / 3.125),
                          aperture=CircularAperture.p(lc6, maxradius=10.0))
        surf7 = Surface.p(lc7,
                          shape=Conic.p(lc7, curv=1 / 1.479),
                          aperture=CircularAperture.p(lc7, maxradius=10.0))
        image = Surface.p(lc8)

        elem = OpticalElement.p(lc0, name="lenssystem")

        glass = material_isotropic.ConstantIndexGlass.p(lc0, n=1.7)
        glass2 = material_isotropic.ConstantIndexGlass.p(lc0, n=1.5)

        elem.addMaterial("glass", glass)
        elem.addMaterial("glass2", glass2)

        elem.addSurface("object", objectsurf, (None, None))
        elem.addSurface("surf1", surf1, (None, "glass"))
        elem.addSurface("surf2", surf2, ("glass", None))
        elem.addSurface("surf3", surf3, (None, "glass"))
        elem.addSurface("surf4", surf4, ("glass", None))
        elem.addSurface("stop", stopsurf, (None, None))
        elem.addSurface("surf6", surf6, (None, "glass2"))
        elem.addSurface("surf7", surf7, ("glass2", None))
        elem.addSurface("image", image, (None, None))

        for mysurf in elem.surfaces.values():
            print(mysurf.aperture.annotations)

        s.addElement("lenssys", elem)

        return s
示例#22
0
 def create():
     s = OpticalSystem.p()
     return s
示例#23
0
from pyrateoptics.raytracer.optical_system import OpticalSystem
from pyrateoptics.raytracer.surface import Surface

from pyrateoptics.raytracer.globalconstants import canonical_ey, degree

from pyrateoptics.analysis.optical_system_analysis import OpticalSystemAnalysis
from pyrateoptics.analysis.surface_shape_analysis import ShapeAnalysis
from pyrateoptics.sampling2d.raster import RandomGrid


wavelength = standard_wavelength

logging.basicConfig(level=logging.DEBUG)

# definition of optical system
s = OpticalSystem()  # objectDistance = 2.0

lc0 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="object", decz=0.0),
            refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="surf1", decz=2.0), refname=lc0.name)
# objectDist
lc2 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="surf2", decz=3.0), refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="surf3", decz=5.0, tiltx=2.5*degree),
            refname=lc2.name)
lc4 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="surf4", decz=3.0), refname=lc3.name)
lc5 = s.addLocalCoordinateSystem(
示例#24
0
        exec(compile("self" + deref + " = var", "<string>", "exec"))

    def getVariable(self, key):
        """
        Gets variable from short key.
        """
        dict_of_vars = self.getAllVariables()
        variable = dict_of_vars["vars"][key]
        return variable
'''

if __name__ == "__main__":

    logging.basicConfig(level=logging.DEBUG)

    s = OpticalSystem(name="s")
    s.lst = []
    s.lst.append({})
    s.lst.append({})
    s.lst[0]["a"] = FloatOptimizableVariable(FixedState(3.0), name="v1")
    s.lst[1]["b"] = FloatOptimizableVariable(VariableState(7.0), name="v2")

    s.rootcoordinatesystem.decz = FloatOptimizableVariable(FixedState(-99.0),
                                                           name="decz")

    listOptimizableVariables(s)

    m = ConfigManager(s, name="mc")

    [s2, s3] = m.setOptimizableVariables(
        ("s2", "s3"), {
示例#25
0
                            self.debug("Reseting %s" % (key, ))
                            instance.resetVariable(
                                key, self.base_instance.getVariable(key))
                    # set names of the new instances accordingly
                    self.debug("Setting name of instance %s" %
                               (names_tuple[index]))
                    instance.setName(names_tuple[index])

        return instance_list


if __name__ == "__main__":

    logging.basicConfig(level=logging.DEBUG)

    s = OpticalSystem(name="s")
    s.lst = []
    s.lst.append({})
    s.lst.append({})
    s.lst[0]["a"] = OptimizableVariable(variable_type="fixed",
                                        name="v1",
                                        value=3.0)
    s.lst[1]["b"] = OptimizableVariable(variable_type="variable",
                                        name="v2",
                                        value=7.0)

    s.rootcoordinatesystem.decz = OptimizableVariable(name="decz", value=-99.0)

    listOptimizableVariables(s)

    m = ConfigManager(s, name="mc")
示例#26
0
    def __init__(self, doc, name):
        self.__doc = doc
        obj = doc.addObject("App::FeaturePython", name)
        self.__obj = obj
        obj.Proxy = self

        self.__NameOSGroup = Group_OS_Label + "_" + uuidToName(uuid.uuid4())
        self.__NameSurfaceGroup = Group_Surface_Label + "_" + uuidToName(uuid.uuid4())
        self.__NameFunctionsGroup = Group_Functions_Label + "_" + uuidToName(uuid.uuid4())
        self.__NameCoordinatesGroup = Group_Coordinates_Label + "_" + uuidToName(uuid.uuid4())

        self.__group = doc.addObject("App::DocumentObjectGroup", self.__NameOSGroup)
        self.__group.addObject(obj)

        self.__surfacegroup = doc.addObject("App::DocumentObjectGroup", self.__NameSurfaceGroup)
        self.__functionsgroup = doc.addObject("App::DocumentObjectGroup", self.__NameFunctionsGroup)
        self.__coordinatesgroup = doc.addObject("App::DocumentObjectGroup", self.__NameCoordinatesGroup)


        self.__group.addObject(self.__surfacegroup)
        self.__group.addObject(self.__functionsgroup)
        self.__group.addObject(self.__coordinatesgroup)

        self.__functionsgroup.Label = Group_Functions_Label + "_" + name
        self.__surfacegroup.Label = Group_Surface_Label + "_" + name
        self.__coordinatesgroup.Label = Group_Coordinates_Label + "_" + name
        self.__group.Label = Group_OS_Label + "_" + name


        # TODO: all properties are not really operational

        # group links

        obj.addProperty("App::PropertyString", "NameOSGroup", "Groups", "Name of OS Group").NameOSGroup = self.__NameOSGroup
        obj.addProperty("App::PropertyString", "NameFunctionsGroup", "Groups", "Name of Functions Group").NameFunctionsGroup = self.__NameFunctionsGroup
        obj.addProperty("App::PropertyString", "NameSurfaceGroup", "Groups", "Name of Surface Group").NameSurfaceGroup = self.__NameSurfaceGroup
        obj.addProperty("App::PropertyString", "NameCoordinatesGroup", "Groups", "Name of Coordinates Group").NameCoordinatesGroup = self.__NameCoordinatesGroup

        obj.setEditorMode("NameOSGroup", 1) # readonly
        obj.setEditorMode("NameFunctionsGroup", 1) # readonly
        obj.setEditorMode("NameSurfaceGroup", 1) # readonly
        obj.setEditorMode("NameCoordinatesGroup", 1) # readonly


        # OS Properties

        obj.addProperty("App::PropertyPythonObject",
                        "osclass",
                        "OS",
                        "os class interface").osclass = OpticalSystem()






        obj.addProperty("App::PropertyPythonObject",
                        "coords",
                        "OS",
                        "os coords interface").coords = LC(None, obj.osclass.rootcoordinatesystem, doc, self.__coordinatesgroup)
        obj.addProperty("App::PropertyFloatList",
                        "wavelengths",
                        "OS",
                        "wavelengths list").wavelengths = [550.0e-6]
        obj.addProperty("App::PropertyLinkList", "surfaces", "OS", "surface list").surfaces = []


        # Field properties

        obj.addProperty("App::PropertyPythonObject",
                        "fieldpoints",
                        "Field",
                        "Field points").fieldpoints = np.array([[0, 0]])
        obj.addProperty("App::PropertyPythonObject",
                        "fieldpointsbool",
                        "Field",
                        "Field points used?").fieldpointsbool = np.array([True], dtype=bool)
        obj.addProperty("App::PropertyEnumeration",
                        "fieldtype",
                        "Field",
                        "Type of field?").fieldtype = \
                                ["ObjectHeight",
                                 "ObjectChiefAngle",
                                 "ParaxialImageHeight"]


        # Aiming properties

        obj.addProperty("App::PropertyInteger",
                        "stopposition",
                        "Aiming",
                        "Which surface is stop?").stopposition = 0
        obj.addProperty("App::PropertyEnumeration",
                        "pupiltype",
                        "Aiming",
                        "Type of pupil?").pupiltype = \
                                        ["EntrancePupilDiameter",
                                        "EntrancePupilRadius",
                                        "StopDiameter",
                                        "StopRadius",
                                        "ExitPupilDiameter",
                                        "ExitPupilRadius",
                                        "InfiniteConjugateImageSpaceFNumber",
                                        "InfiniteConjugateObjectSpaceFNumber",
                                        "WorkingImageSpaceFNumber",
                                        "WorkingObjectSpaceFNumber",
                                        "ObjectSpaceNA",
                                        "ImageSpaceNA"]
        obj.addProperty("App::PropertyDistance",
                        "pupilsize",
                        "Aiming",
                        "Pupil size?").pupilsize = 1.0
        obj.addProperty("App::PropertyEnumeration",
                        "rastertype",
                        "Aiming",
                        "Type of pupil rasterization?").rastertype = \
                                                            ["RectGrid",
                                                             "HexGrid",
                                                             "RandomGrid",
                                                             "PoissonDiskSampling",
                                                             "MeridionalFan",
                                                             "SagitalFan",
                                                             "ChiefAndComa",
                                                             "Single"]
                                                             # TODO: -> text file
        obj.addProperty("App::PropertyInteger",
                        "numrays",
                        "Aiming",
                        "How many rays to be drawn?").numrays = 10
示例#27
0
from pyrateoptics.raytracer.globalconstants import degree

from pyrateoptics.raytracer.aim import Aimy

logging.basicConfig(level=logging.INFO)


wavelength = 0.5876e-3

# definition of optical system

# v = np.ones(3)# + 0.001*np.random.random(3)
# myeps = np.diag(v)


s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)

# air = AnisotropicMaterial(lc0, myeps)  # tests for anisotropic mirror
air = ConstantIndexGlass(lc0, 1.0)
s.material_background = air

lc1 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="m1", decz=50.0, tiltx=-math.pi/8),
            refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(
            LocalCoordinates(name="m2_stop",
                             decz=-50.0,
                             decy=-20,
示例#28
0
from pyrateoptics.raytracer.surface_shape import Conic
from pyrateoptics.raytracer.optical_element import OpticalElement
from pyrateoptics.raytracer.surface import Surface
from pyrateoptics.raytracer.optical_system import OpticalSystem

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics import raytrace, draw

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="obj", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1",
                                                  decz=10.0,
                                                  tiltx=5. * math.pi / 180.0),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2",
                                                  decz=20.0,
                                                  tiltx=10. * math.pi / 180.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=10.0),
                                 refname=lc2.name)

stopsurf = Surface(lc0)
示例#29
0
from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics import raytrace, draw
from pyrateoptics.raytracer.globalconstants import degree

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

wave_red = 0.700e-3
wave_blue = 0.470e-3

# definition of optical system
s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lccomprism = s.addLocalCoordinateSystem(LocalCoordinates(name="prismcenter",
                                                         decz=50.0),
                                        refname=lc0.name)

lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1",
                                                  decz=-10.0,
                                                  tiltx=30. * degree),
                                 refname=lccomprism.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2",
                                                  decz=10.0,
                                                  tiltx=-30. * degree),
                                 refname=lccomprism.name)
示例#30
0
from pyrateoptics.raytracer.optical_system import OpticalSystem

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.analysis.optical_system_analysis import OpticalSystemAnalysis

from pyrateoptics import draw

logging.basicConfig(level=logging.DEBUG)


wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem(name='os')

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=-1.048),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=4.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3", decz=2.5),
                                 refname=lc2.name)
lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=97.2),
                                 refname=lc3.name)

stopsurf = Surface(lc0, name="stopsurf")
frontsurf = Surface(lc1, name="frontsurf",
                    shape=Conic(lc1, curv=1./62.8, name='conic1'),
示例#31
0
from pyrateoptics.raytracer.optical_element import OpticalElement
from pyrateoptics.raytracer.surface import Surface
from pyrateoptics.raytracer.optical_system import OpticalSystem

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates
from pyrateoptics.raytracer.globalconstants import degree

from pyrateoptics import draw, raytrace

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem(name='os')

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=1.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=10.0),
                                 refname=lc0.name)
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2",
                                                  decz=5.0,
                                                  tiltx=10 * math.pi / 180.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="image",
                                                  decz=-5.0,
                                                  tiltx=-10 * math.pi / 180.0),
                                 refname=lc2.name)

stopsurf = Surface(lc0)
from pyrateoptics.raytracer.optical_system import OpticalSystem
from pyrateoptics.raytracer.ray import RayBundle

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.globalconstants import canonical_ey

import math
import logging
logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem(name='os')

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=-1.048),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=4.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf3", decz=2.5),
                                 refname=lc2.name)
lc4 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=97.2),
                                 refname=lc3.name)

stopsurf = Surface(lc0, name="stopsurf")
frontsurf = Surface(lc1,
                    name="frontsurf",
示例#33
0
from pyrateoptics.raytracer import surfShape
from pyrateoptics.raytracer.optical_element import OpticalElement
from pyrateoptics.raytracer.surface import Surface
from pyrateoptics.raytracer.optical_system import OpticalSystem
from pyrateoptics.raytracer.ray import RayBundle

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates
from pyrateoptics.raytracer.globalconstants import degree

from pyrateoptics import draw, raytrace

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="stop", decz=1.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1", decz=10.0),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2", decz=5.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=10.0),
                                 refname=lc2.name)

stopsurf = Surface(lc0)
frontsurf = Surface(lc1,
                    shape=surfShape.Conic(lc1, curv=0),
                    apert=CircularAperture(lc1, 10.0))
rearsurf = Surface(lc2,
示例#34
0
    ShapeAnalysis

from pyrateoptics.sampling2d.raster import RandomGrid

from pyrateoptics.optimize.optimize import Optimizer
from pyrateoptics.optimize.optimize_backends import (ScipyBackend,
                                                     Newton1DBackend,
                                                     ParticleSwarmBackend,
                                                     SimulatedAnnealingBackend)

wavelength = standard_wavelength

logging.basicConfig(level=logging.DEBUG)

# definition of optical system
s = OpticalSystem.p()  # objectDistance = 2.0

lc0 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf1", decz=2.0),
                                 refname=lc0.name)
# objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf2", decz=3.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf3",
                                                    decz=5.0,
                                                    tiltx=2.5 * degree),
                                 refname=lc2.name)
lc4 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf4", decz=3.0),
                                 refname=lc3.name)
lc5 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf5", decz=3.0),
示例#35
0
from pyrateoptics.raytracer.optical_system import OpticalSystem
from pyrateoptics.raytracer.ray import RayBundle

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates

from pyrateoptics.raytracer.globalconstants import canonical_ey

import math
import logging
logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem()

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="obj", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf1",
                                                  decz=10.0,
                                                  tiltx=5. * math.pi / 180.0),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="surf2",
                                                  decz=20.0,
                                                  tiltx=10. * math.pi / 180.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="image", decz=10.0),
                                 refname=lc2.name)

stopsurf = Surface(lc0)
示例#36
0
from pyrateoptics.raytracer.optical_element import OpticalElement
from pyrateoptics.raytracer.surface import Surface
from pyrateoptics.raytracer.optical_system import OpticalSystem

from pyrateoptics.raytracer.aperture import CircularAperture
from pyrateoptics.raytracer.localcoordinates import LocalCoordinates
from pyrateoptics.raytracer.globalconstants import degree

from pyrateoptics import draw, raytrace

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

# definition of optical system
s = OpticalSystem.p(name='os')

lc0 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="stop", decz=1.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf1", decz=10.0),
                                 refname=lc0.name)
lc2 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf2",
                                                    decz=5.0,
                                                    tiltx=10 * math.pi /
                                                    180.0),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="image",
                                                    decz=-5.0,
                                                    tiltx=-10 * math.pi /
                                                    180.0),
                                 refname=lc2.name)
示例#37
0
logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

rnd_data1 = np.random.random((3, 3))  # np.eye(3)
rnd_data2 = np.random.random((3, 3))  # np.zeros((3, 3))#
lc = LocalCoordinates("1")
myeps = np.eye(3) + 0.1*rnd_data1 + 0.01*complex(0, 1)*rnd_data2
# aggressive complex choice of myeps
# myeps = np.eye(3) + 0.01*np.random.random((3, 3))
crystal = AnisotropicMaterial(lc, myeps)


# definition of optical system
s = OpticalSystem(matbackground=crystal)

lc0 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="object", decz=0.0),
        refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="m1", decz=50.0, tiltx=-math.pi/8),
        refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="m2_stop", decz=-50.0, decy=-20,
                         tiltx=math.pi/16), refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="m3", decz=50.0, decy=-30, tiltx=3*math.pi/32),
        refname=lc2.name)
lc4 = s.addLocalCoordinateSystem(
        LocalCoordinates(name="image1", decz=-50, decy=-15, tiltx=-math.pi/16),
示例#38
0
from pyrateoptics.core.base_ui import UIInterfaceClassWithOptimizableVariables
from pyrateoptics.core.serializer import Serializer


from pyrateoptics.raytracer.globalconstants import degree
from pyrateoptics import raytrace, draw

logging.basicConfig(level=logging.DEBUG)

wavelength = 0.5876e-3

wave_red = 0.700e-3
wave_blue = 0.470e-3

# definition of optical system
s = OpticalSystem.p()

dropletradius = 0.1

lc0 = s.addLocalCoordinateSystem(
            LocalCoordinates.p(name="stop", decz=0.0),
            refname=s.rootcoordinatesystem.name)
lccomprism = s.addLocalCoordinateSystem(
            LocalCoordinates.p(name="dropletcenter", decz=2.*dropletradius),
            refname=lc0.name)

lc1 = s.addLocalCoordinateSystem(LocalCoordinates.p(name="surf1",
                                                    decz=-dropletradius),
                                 refname=lccomprism.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(
            LocalCoordinates.p(name="surf2", decz=dropletradius),
示例#39
0
logging.basicConfig(level=logging.DEBUG)

import pyrateoptics.raytracer.helpers

wavelength = 0.5876e-3

rnd_data1 = np.random.random((3, 3))  #np.eye(3)
rnd_data2 = np.random.random((3, 3))  #np.zeros((3, 3))#
lc = LocalCoordinates("1")
myeps = np.eye(3) + 0.1 * rnd_data1 + 0.01 * complex(
    0, 1) * rnd_data2  # aggressive complex choice of myeps
#myeps = np.eye(3) + 0.01*np.random.random((3, 3))
crystal = AnisotropicMaterial(lc, myeps)

# definition of optical system
s = OpticalSystem(matbackground=crystal)

lc0 = s.addLocalCoordinateSystem(LocalCoordinates(name="object", decz=0.0),
                                 refname=s.rootcoordinatesystem.name)
lc1 = s.addLocalCoordinateSystem(LocalCoordinates(name="m1",
                                                  decz=50.0,
                                                  tiltx=-math.pi / 8),
                                 refname=lc0.name)  # objectDist
lc2 = s.addLocalCoordinateSystem(LocalCoordinates(name="m2_stop",
                                                  decz=-50.0,
                                                  decy=-20,
                                                  tiltx=math.pi / 16),
                                 refname=lc1.name)
lc3 = s.addLocalCoordinateSystem(LocalCoordinates(name="m3",
                                                  decz=50.0,
                                                  decy=-30,