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

68

69

70

71

72

73

74

from builtins import zip 

from builtins import range 

import numpy as np 

import unittest 

import lsst.utils.tests 

 

from lsst.sims.utils import ObservationMetaData, _observedFromICRS 

from lsst.sims.utils import haversine, arcsecFromRadians 

from lsst.sims.catUtils.mixins import PhoSimAstrometryBase 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

class DePrecessionTest(unittest.TestCase): 

 

def test_de_precession(self): 

""" 

test de-precession by de-precessing a list of RA, Dec 

and verifying that the distance between the de-precessed 

points is the same as the distance between the input points. 

 

Also verify that the observed boresite gets de-precessed correctly 

""" 

rng = np.random.RandomState(12) 

n_samples = 5 

pra = 34.0 

pdec = 65.0 

obs = ObservationMetaData(pointingRA=pra, 

pointingDec=pdec, 

mjd=58324.1) 

 

raObs, decObs = _observedFromICRS(np.array([np.radians(pra)]), 

np.array([np.radians(pdec)]), 

obs_metadata=obs, epoch=2000.0, 

includeRefraction=False) 

 

ra_list = [] 

dec_list = [] 

ra_list.append(raObs[0]) 

dec_list.append(decObs[0]) 

for rr, dd in zip(rng.random_sample(n_samples)*2.0*np.pi, 

(rng.random_sample(n_samples)-0.5)*np.pi): 

 

ra_list.append(rr) 

dec_list.append(dd) 

 

ra_list = np.array(ra_list) 

dec_list = np.array(dec_list) 

 

raDecTransformed = PhoSimAstrometryBase()._dePrecess(ra_list, dec_list, obs) 

dd = arcsecFromRadians(haversine(np.radians(pra), np.radians(pdec), 

raDecTransformed[0][0], raDecTransformed[1][0])) 

self.assertLess(dd, 1.0e-6) 

dd0 = arcsecFromRadians(haversine(raObs[0], decObs[0], np.radians(pra), np.radians(pdec))) 

self.assertLess(dd, dd0) 

 

for ix in range(n_samples+1): 

for iy in range(n_samples+1): 

if ix != iy: 

dd1 = arcsecFromRadians(haversine(ra_list[ix], dec_list[ix], ra_list[iy], dec_list[iy])) 

dd2 = arcsecFromRadians(haversine(raDecTransformed[0][ix], raDecTransformed[1][ix], 

raDecTransformed[0][iy], raDecTransformed[1][iy])) 

 

self.assertAlmostEqual(dd1, dd2, delta=6) 

 

 

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

pass 

 

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

lsst.utils.tests.init() 

unittest.main()