Hide keyboard shortcuts

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 

3 

4import lsst.utils.tests 

5import lsst.obs.lsst.phosim as obs_lsst_phosim 

6from lsst.sims.coordUtils import DMtoCameraPixelTransformer 

7from lsst.sims.coordUtils import pupilCoordsFromPixelCoords 

8from lsst.afw.cameraGeom import FOCAL_PLANE, PIXELS 

9 

10 

11def setup_module(module): 

12 lsst.utils.tests.init() 

13 

14 

15class PixelTransformerTestCase(unittest.TestCase): 

16 """ 

17 This unit test TestCase will exercise the class that transforms between 

18 DM pixels and Camera Team pixels. 

19 

20 Recall that their conventions differ in that 

21 

22 Camera +y = DM +x 

23 Camera +x = DM -y 

24 """ 

25 

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 = obs_lsst_phosim.PhosimMapper().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) 

42 

43 

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) 

47 

48 # test that DM and Camera Team pixels are correctly rotated 

49 # with respect to each other 

50 

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) 

57 

58 del camera_wrapper 

59 del camera 

60 

61 

62class MemoryTestClass(lsst.utils.tests.MemoryTestCase): 

63 pass 

64 

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()