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

import unittest 

 

import numpy as np 

 

import lsst.utils.tests 

import lsst.geom 

import lsst.afw.image as afwImage 

from lsst.afw.image.testUtils import makeRampImage 

 

 

class MakeRampImageTestCase(lsst.utils.tests.TestCase): 

"""!Unit tests for makeRampImage""" 

 

def testUnitInterval(self): 

"""!Test small ramp images with unit interval for known values 

""" 

for imageClass in (afwImage.ImageU, afwImage.ImageF, afwImage.ImageD): 

dim = lsst.geom.Extent2I(7, 9) 

box = lsst.geom.Box2I(lsst.geom.Point2I(-1, 3), dim) 

numPix = dim[0]*dim[1] 

for start in (-5, 0, 4): 

if imageClass == afwImage.ImageU and start < 0: 

continue 

predStop = start + numPix - 1 # for integer steps 

for stop in (None, predStop): 

rampImage = makeRampImage( 

bbox=box, start=start, stop=predStop, imageClass=imageClass) 

predArr = np.arange(start, predStop+1) 

self.assertEqual(len(predArr), numPix) 

predArr.shape = (dim[1], dim[0]) 

self.assertImagesAlmostEqual(rampImage, predArr) 

 

def testNonUnitIntervals(self): 

"""!Test a small ramp image with non-integer increments 

""" 

for imageClass in (afwImage.ImageU, afwImage.ImageF, afwImage.ImageD): 

dim = lsst.geom.Extent2I(7, 9) 

box = lsst.geom.Box2I(lsst.geom.Point2I(-1, 3), dim) 

numPix = dim[0]*dim[1] 

for start in (-5.1, 0, 4.3): 

if imageClass == afwImage.ImageU and start < 0: 

continue 

for stop in (7, 1001.5, 5.4): 

rampImage = makeRampImage( 

bbox=box, start=start, stop=stop, imageClass=imageClass) 

dtype = rampImage.getArray().dtype 

predArr = np.linspace( 

start, stop, num=numPix, endpoint=True, dtype=dtype) 

predArr.shape = (dim[1], dim[0]) 

self.assertImagesAlmostEqual(rampImage, predArr) 

 

 

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

pass 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

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

lsst.utils.tests.init() 

unittest.main()