Example #1
0
    def test_configurations(self):
        configurations = {
            "Mirror up": {
                "pole_pos": (458, 519),
                "focus_dist": 0.5e-3
            },
            "Mirror down": {
                "pole_pos": (634, 652),
                "focus_dist": -0.5e-3
            }
        }
        comp = static.OpticalLens("test",
                                  "lens",
                                  1,
                                  pole_pos=(458, 519),
                                  focus_dist=0.5e-3,
                                  configurations=configurations)
        self.assertEqual(comp.configuration.choices, set(configurations))

        #check the default configuration is "Mirror up"
        self.assertEqual(comp.configuration.value, "Mirror up")

        #change the configuration to "Mirror down" and check that the VAs that correspond to the attribute names are updated
        comp.configuration.value = "Mirror down"
        conf = configurations["Mirror down"]
        self.assertEqual(comp.polePosition.value, conf["pole_pos"])
        self.assertEqual(comp.focusDistance.value, conf["focus_dist"])

        comp.configuration.value = "Mirror up"
        conf = configurations["Mirror up"]
        self.assertEqual(comp.polePosition.value, conf["pole_pos"])
        self.assertEqual(comp.focusDistance.value, conf["focus_dist"])

        comp.terminate()
Example #2
0
 def test_mag_choices(self):
     mag_choices = [1, 1.5, 2.5]
     comp = static.OpticalLens("test", "lens", 1, mag_choices=mag_choices)
     self.assertEqual(1, comp.magnification.value)
     self.assertEqual(comp.magnification.choices, set(mag_choices))
     comp.magnification.value = 1.5  # should be allowed
     with self.assertRaises(IndexError):
         comp.magnification.value = 2.0
     comp.terminate()
Example #3
0
    def test_badconfigurations(self):
        configurations = {"conf unknown": {"booo": 43e-5, "focus_dist": 6e-3}}

        with self.assertRaises(ValueError):
            comp = static.OpticalLens("test",
                                      "lens",
                                      1,
                                      pole_pos=(458, 519),
                                      focus_dist=0.5e-3,
                                      configurations=configurations)

        configurations = {"conf missing": {"x_max": 43e-5, "focus_dist": 6e-3}}

        with self.assertRaises(ValueError):
            comp = static.OpticalLens("test",
                                      "lens",
                                      1,
                                      pole_pos=(458, 519),
                                      focus_dist=0.5e-3,
                                      configurations=configurations)
Example #4
0
 def test_simple(self):
     mag = 10.
     comp = static.OpticalLens("test", "lens", mag, pole_pos=(512.3, 400))
     self.assertEqual(mag, comp.magnification.value)
     comp.magnification.value = 1.5  # should be allowed
     comp.terminate()