Beispiel #1
0
    def setUp(self):
        p = 'pychron/stage/tests/data/221-hole.txt'
        if not os.path.isfile(p):
            base = os.path.dirname(os.path.abspath(__file__))
            p = os.path.join(base, 'data', '221-hole.txt')

        self.sm = LaserStageMap(file_path=p)
Beispiel #2
0
    def setUp(self):
        p = 'pychron/stage/tests/data/221-hole.txt'
        if not os.path.isfile(p):
            base = os.path.dirname(os.path.abspath(__file__))
            p = os.path.join(base, 'data', '221-hole.txt')

        self.sm = LaserStageMap(file_path=p)
Beispiel #3
0
def _load_tray_map(db, p, name):
    from pychron.stage.maps.laser_stage_map import LaserStageMap

    sm = LaserStageMap(file_path=p)

    r = sm.g_dimension
    blob = ''.join([struct.pack('>fff', si.x, si.y, r)
                    for si in sm.sample_holes])
    db.add_load_holder(name, geometry=blob)
Beispiel #4
0
        def create_map(name):
            if name:
                if not name.endswith('.txt'):
                    name = '{}.txt'.format(name)
                name = os.path.join(paths.map_dir, name)

                if os.path.isfile(name):
                    sm = LaserStageMap(file_path=name)
                    mv = MapView(stage_map=sm)
                    return mv
Beispiel #5
0
class StageMapTestCase(unittest.TestCase):
    def setUp(self):
        p = 'pychron/stage/tests/data/221-hole.txt'
        if not os.path.isfile(p):
            base = os.path.dirname(os.path.abspath(__file__))
            p = os.path.join(base, 'data', '221-hole.txt')

        self.sm = LaserStageMap(file_path=p)

    def test_generate_interpolation(self):
        sm = self.sm
        h1 = sm.get_hole('1')
        h3 = sm.get_hole('3')
        h5 = sm.get_hole('5')

        h1.corrected = True
        h1.x_cor = 0
        h1.y_cor = 0

        h3.corrected = True
        h3.x_cor = 2
        h3.y_cor = 4

        h5.corrected = True
        h5.x_cor = 4
        h5.y_cor = 8

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((1, 2, 3, 6), (
            h2.x_cor,
            h2.y_cor,
            h4.x_cor,
            h4.y_cor,
        ))

    def test_generate_interpolation_no_mid(self):
        sm = self.sm
        h1 = sm.get_hole('1')
        h5 = sm.get_hole('5')

        h1.corrected = True
        h1.x_cor = 0
        h1.y_cor = 0

        h5.corrected = True
        h5.x_cor = 4
        h5.y_cor = 8

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((1, 2, 3, 6), (
            h2.x_cor,
            h2.y_cor,
            h4.x_cor,
            h4.y_cor,
        ))

    def test_generate_interpolation_no_end(self):
        sm = self.sm
        h1 = sm.get_hole('1')
        h3 = sm.get_hole('3')

        h1.corrected = True
        h1.x_cor = 0
        h1.y_cor = 0

        h3.corrected = True
        h3.x_cor = 2
        h3.y_cor = 4

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((1, 2, 3, 6), (
            h2.x_cor,
            h2.y_cor,
            h4.x_cor,
            h4.y_cor,
        ))

    def test_generate_interpolation_no_start(self):
        sm = self.sm
        h3 = sm.get_hole('3')
        h5 = sm.get_hole('5')

        h3.corrected = True
        h3.x_cor = 2
        h3.y_cor = 4

        h5.corrected = True
        h5.x_cor = 4
        h5.y_cor = 8

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((1, 2, 3, 6), (
            h2.x_cor,
            h2.y_cor,
            h4.x_cor,
            h4.y_cor,
        ))

    def test_generate_interpolation_no_points(self):
        sm = self.sm

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((0, 0, 0, 0), (
            h2.x_cor,
            h2.y_cor,
            h4.x_cor,
            h4.y_cor,
        ))

    def test_row_ends(self):
        holes = list(self.sm.row_ends())
        hs = [hi.id for hi in holes[:6]]

        self.assertListEqual(['1', '5', '6', '14', '15', '25'], hs)

    def test_row_ends2(self):
        holes = list(self.sm.row_ends(alternate=True))

        hs = [hi.id for hi in holes[:6]]

        self.assertListEqual(['1', '5', '14', '6', '15', '25'], hs)

    def test_circumference_holes(self):
        holes = list(self.sm.circumference_holes())
        hs = [hi.id for hi in holes[:6]]
        self.assertListEqual(['1', '6', '15', '26', '39', '54'], hs)

    def test_circumference_holes2(self):
        holes = list(self.sm.circumference_holes())
        hs = [hi.id for hi in holes[-6:]]
        self.assertListEqual(['68', '53', '38', '25', '14', '5'], hs)

    def test_mid_holes(self):
        holes = list(self.sm.mid_holes())
        hs = [hi.id for hi in holes[:6]]
        self.assertListEqual(['3', '10', '20', '32', '46', '61'], hs)
                 title='Stage Visualizer',
                 resizable=True)
        return v


if __name__ == '__main__':
    from pychron.core.helpers.logger_setup import logging_setup

    paths.build('_dev')
    logging_setup('sv', use_archiver=False, use_file=False)

    p = '/Users/ross/Programming/github/support_pychron/setupfiles/tray_maps' \
        '/221-hole.txt'
    # p = '/Users/argonlab3/Pychron_co2/setupfiles/tray_maps/221-small_hole.txt'

    sm = LaserStageMap(file_path=p)

    sv = StageVisualizer()
    results = [((-3.9878, 15.9512), True),
               ((-1.9939, 15.5), False),
               ((0, 15.9512), True)]


    class CO:
        rotation = 1
        center = -2, 0


    sv.set_stage_map(sm, results, CO())

    sv.configure_traits()
Beispiel #7
0
        d = self.scatter.color_data.get_data()
        d[holenum] = state
        self.scatter.color_data.set_data(d)

    def set_hole_labnumber(self, ai):
        ln = ai.labnumber
        hs = ai.get_position_list()
        for hi in hs:
            if isinstance(hi, int):
                self.labnumbers[hi - 1] = ln
                self.set_hole_state(hi - 1, -1.1)


# self.scatter.states[holenum - 1] = 1

if __name__ == '__main__':
    import random

    sm = LaserStageMap(file_path=os.path.join(paths.map_dir, '221-hole.txt'))
    mv = MapView(stage_map=sm)

    for i in range(0, 210, 1):
        mv.set_hole_labnumber(i, str(i))

    for i in range(0, 100, 1):
        r = random.random() * 10
        mv.set_hole_state(i, r)

    mv.configure_traits()
# ============= EOF =============================================
Beispiel #8
0
    def setUp(self):
        p = 'pychron/stage/tests/data/221-hole.txt'
        if not os.path.isfile(p):
            p = './data/221-hole.txt'

        self.sm = LaserStageMap(file_path=p)
Beispiel #9
0
class StageMapTestCase(unittest.TestCase):
    def setUp(self):
        p = 'pychron/stage/tests/data/221-hole.txt'
        if not os.path.isfile(p):
            p = './data/221-hole.txt'

        self.sm = LaserStageMap(file_path=p)

    def test_generate_interpolation(self):
        sm = self.sm
        h1 = sm.get_hole('1')
        h3 = sm.get_hole('3')
        h5 = sm.get_hole('5')

        h1.corrected = True
        h1.x_cor = 0
        h1.y_cor = 0

        h3.corrected = True
        h3.x_cor = 2
        h3.y_cor = 4

        h5.corrected = True
        h5.x_cor = 4
        h5.y_cor = 8

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((1, 2, 3, 6),
                              (h2.x_cor, h2.y_cor,
                               h4.x_cor, h4.y_cor,))

    def test_generate_interpolation_no_mid(self):
        sm = self.sm
        h1 = sm.get_hole('1')
        h5 = sm.get_hole('5')

        h1.corrected = True
        h1.x_cor = 0
        h1.y_cor = 0

        h5.corrected = True
        h5.x_cor = 4
        h5.y_cor = 8

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((1, 2, 3, 6),
                              (h2.x_cor, h2.y_cor,
                               h4.x_cor, h4.y_cor,))

    def test_generate_interpolation_no_end(self):
        sm = self.sm
        h1 = sm.get_hole('1')
        h3 = sm.get_hole('3')

        h1.corrected = True
        h1.x_cor = 0
        h1.y_cor = 0

        h3.corrected = True
        h3.x_cor = 2
        h3.y_cor = 4

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((1, 2, 3, 6),
                              (h2.x_cor, h2.y_cor,
                               h4.x_cor, h4.y_cor,))

    def test_generate_interpolation_no_start(self):
        sm = self.sm
        h3 = sm.get_hole('3')
        h5 = sm.get_hole('5')

        h3.corrected = True
        h3.x_cor = 2
        h3.y_cor = 4

        h5.corrected = True
        h5.x_cor = 4
        h5.y_cor = 8

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((1, 2, 3, 6),
                              (h2.x_cor, h2.y_cor,
                               h4.x_cor, h4.y_cor,))

    def test_generate_interpolation_no_points(self):
        sm = self.sm

        sm.generate_row_interpolated_corrections(dump_corrections=False)

        h2 = sm.get_hole('2')
        h4 = sm.get_hole('4')
        self.assertTupleEqual((0, 0, 0, 0),
                              (h2.x_cor, h2.y_cor,
                               h4.x_cor, h4.y_cor,))

    def test_row_ends(self):
        holes = list(self.sm.row_ends())
        hs = [hi.id for hi in holes[:6]]

        self.assertListEqual(['1', '5', '6', '14', '15', '25'], hs)

    def test_row_ends2(self):
        holes = list(self.sm.row_ends(alternate=True))

        hs = [hi.id for hi in holes[:6]]

        self.assertListEqual(['1', '5', '14', '6', '15', '25'], hs)

    def test_circumference_holes(self):
        holes = list(self.sm.circumference_holes())
        hs = [hi.id for hi in holes[:6]]
        self.assertListEqual(['1', '6', '15', '26', '39', '54'], hs)

    def test_circumference_holes2(self):
        holes = list(self.sm.circumference_holes())
        hs = [hi.id for hi in holes[-6:]]
        self.assertListEqual(['68', '53', '38', '25', '14', '5'], hs)

    def test_mid_holes(self):
        holes = list(self.sm.mid_holes())
        hs = [hi.id for hi in holes[:6]]
        self.assertListEqual(['3', '10', '20', '32', '46', '61'], hs)
Beispiel #10
0
 def _stage_map_default(self):
     p = os.path.join(paths.map_dir, '61-hole.txt')
     sm = LaserStageMap(file_path=p)
     sm.load_correction_file()
     return sm
Beispiel #11
0
    def setUp(self):
        p = 'pychron/stage/tests/data/221-hole.txt'
        if not os.path.isfile(p):
            p = './data/221-hole.txt'

        self.sm = LaserStageMap(file_path=p)