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

import numpy as np 

import lsst.sims.skybrightness as sb 

import unittest 

import lsst.utils.tests 

from lsst.sims.utils import Site, _raDecFromAltAz, _altAzPaFromRaDec, ObservationMetaData, haversine 

 

 

class TestAltAz(unittest.TestCase): 

 

def testradec2altaz(self): 

np.random.seed(42) 

ra = np.random.rand(100)*np.pi*2 

dec = np.random.rand(100)*np.pi-np.pi/2 

site = Site('LSST') 

mjd = 55000 

omd = ObservationMetaData(mjd=mjd, site=site) 

 

trueAlt, trueAz, pa = _altAzPaFromRaDec(ra, dec, omd) 

fastAlt, fastAz = sb.stupidFast_RaDec2AltAz(ra, dec, 

site.latitude_rad, 

site.longitude_rad, mjd) 

distanceDiff = haversine(trueAz, trueAlt, fastAz, fastAlt) 

 

degreeTol = 2. # 2-degree tolerance on the fast transform 

assert(np.degrees(distanceDiff.max()) < degreeTol) 

 

# make sure we don't have nans 

alt, az = sb.stupidFast_RaDec2AltAz(np.radians(np.array([0.])), np.radians(np.array([-90.])), 

np.radians(-30.2444), np.radians(-70.7494), 59582.05125) 

assert(~np.isnan(alt)) 

assert(~np.isnan(az)) 

 

def testaltaz2radec(self): 

np.random.seed(42) 

az = np.random.rand(100)*np.pi*2 

alt = np.random.rand(100)*np.pi-np.pi/2 

site = Site('LSST') 

mjd = 55000 

omd = ObservationMetaData(mjd=mjd, site=site) 

 

trueRA, trueDec = _raDecFromAltAz(alt, az, omd) 

fastRA, fastDec = sb.stupidFast_altAz2RaDec(alt, az, site.latitude_rad, 

site.longitude_rad, mjd) 

distanceDiff = haversine(trueRA, trueDec, fastRA, fastDec) 

degreeTol = 2. # 2-degree tolerance on the fast transform 

assert(np.degrees(distanceDiff.max()) < degreeTol) 

 

 

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

pass 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

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

lsst.utils.tests.init() 

unittest.main()