Coverage for tests/testPixelTransformer.py : 36%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import unittest
2import numpy as np
4import lsst.utils.tests
5from lsst.sims.coordUtils import DMtoCameraPixelTransformer
6from lsst.sims.coordUtils import lsst_camera
7from lsst.sims.coordUtils import pupilCoordsFromPixelCoords
8from lsst.afw.cameraGeom import FOCAL_PLANE, PIXELS
11def setup_module(module):
12 lsst.utils.tests.init()
15class PixelTransformerTestCase(unittest.TestCase):
16 """
17 This unit test TestCase will exercise the class that transforms between
18 DM pixels and Camera Team pixels.
20 Recall that their conventions differ in that
22 Camera +y = DM +x
23 Camera +x = DM -y
24 """
26 def test_camPixFromDMpix(self):
27 """
28 test that trasformation between Camera Team and DM pixels works
29 """
30 camera_wrapper = DMtoCameraPixelTransformer()
31 rng = np.random.RandomState()
32 camera = lsst_camera()
33 npts = 200
34 for det in camera:
35 det_name = det.getName()
36 cam_x_in = rng.random_sample(npts)*4000.0
37 cam_y_in = rng.random_sample(npts)*4000.0
38 dm_x, dm_y = camera_wrapper.dmPixFromCameraPix(cam_x_in, cam_y_in, det_name)
39 cam_x, cam_y = camera_wrapper.cameraPixFromDMPix(dm_x, dm_y, det_name)
40 np.testing.assert_array_almost_equal(cam_x_in, cam_x, decimal=10)
41 np.testing.assert_array_almost_equal(cam_y_in, cam_y, decimal=10)
44 center_point = camera[det_name].getCenter(FOCAL_PLANE)
45 pixel_system = camera[det_name].makeCameraSys(PIXELS)
46 center_pix = camera.transform(center_point, FOCAL_PLANE, pixel_system)
48 # test that DM and Camera Team pixels are correctly rotated
49 # with respect to each other
51 np.testing.assert_allclose(dm_x-center_pix.getX(),
52 cam_y-center_pix.getX(),
53 atol=1.0e-10, rtol=0.0)
54 np.testing.assert_allclose(dm_y-center_pix.getY(),
55 center_pix.getY()-cam_x,
56 atol=1.0e-10, rtol=0.0)
58 del camera_wrapper
59 del lsst_camera._lsst_camera
62class MemoryTestClass(lsst.utils.tests.MemoryTestCase):
63 pass
65if __name__ == "__main__": 65 ↛ 66line 65 didn't jump to line 66, because the condition on line 65 was never true
66 lsst.utils.tests.init()
67 unittest.main()