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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

import unittest 

import numpy as np 

 

import lsst.utils.tests 

from lsst.sims.coordUtils import DMtoCameraPixelTransformer 

from lsst.sims.coordUtils import lsst_camera 

from lsst.sims.coordUtils import pupilCoordsFromPixelCoords 

from lsst.afw.cameraGeom import FOCAL_PLANE, PIXELS 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

class PixelTransformerTestCase(unittest.TestCase): 

""" 

This unit test TestCase will exercise the class that transforms between 

DM pixels and Camera Team pixels. 

 

Recall that their conventions differ in that 

 

Camera +y = DM +x 

Camera +x = DM -y 

""" 

 

def test_camPixFromDMpix(self): 

""" 

test that trasformation between Camera Team and DM pixels works 

""" 

camera_wrapper = DMtoCameraPixelTransformer() 

rng = np.random.RandomState() 

camera = lsst_camera() 

npts = 200 

for det in camera: 

det_name = det.getName() 

cam_x_in = rng.random_sample(npts)*4000.0 

cam_y_in = rng.random_sample(npts)*4000.0 

dm_x, dm_y = camera_wrapper.dmPixFromCameraPix(cam_x_in, cam_y_in, det_name) 

cam_x, cam_y = camera_wrapper.cameraPixFromDMPix(dm_x, dm_y, det_name) 

np.testing.assert_array_almost_equal(cam_x_in, cam_x, decimal=10) 

np.testing.assert_array_almost_equal(cam_y_in, cam_y, decimal=10) 

 

 

center_point = camera[det_name].getCenter(FOCAL_PLANE) 

pixel_system = camera[det_name].makeCameraSys(PIXELS) 

center_pix = camera.transform(center_point, FOCAL_PLANE, pixel_system) 

 

# test that DM and Camera Team pixels are correctly rotated 

# with respect to each other 

 

np.testing.assert_allclose(dm_x-center_pix.getX(), 

cam_y-center_pix.getX(), 

atol=1.0e-10, rtol=0.0) 

np.testing.assert_allclose(dm_y-center_pix.getY(), 

center_pix.getY()-cam_x, 

atol=1.0e-10, rtol=0.0) 

 

del camera_wrapper 

del lsst_camera._lsst_camera 

 

 

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

pass 

 

65 ↛ 66line 65 didn't jump to line 66, because the condition on line 65 was never trueif __name__ == "__main__": 

lsst.utils.tests.init() 

unittest.main()