1
|
|
|
# Licensed under a 3-clause BSD style license - see LICENSE.rst |
2
|
|
|
from numpy.testing import assert_allclose |
3
|
|
|
from astropy.time import Time |
4
|
|
|
from ...utils.testing import requires_data, assert_time_allclose |
5
|
|
|
from ..pointing import FixedPointingInfo, PointingInfo |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
@requires_data("gammapy-data") |
9
|
|
|
class TestFixedPointingInfo: |
10
|
|
|
@classmethod |
11
|
|
|
def setup_class(cls): |
12
|
|
|
filename = "$GAMMAPY_DATA/tests/hess_event_list.fits" |
13
|
|
|
cls.fpi = FixedPointingInfo.read(filename) |
14
|
|
|
|
15
|
|
|
def test_location(self): |
16
|
|
|
lon, lat, height = self.fpi.location.geodetic |
17
|
|
|
assert_allclose(lon.deg, 16.5002222222222) |
18
|
|
|
assert_allclose(lat.deg, -23.2717777777778) |
19
|
|
|
assert_allclose(height.value, 1834.999999999783) |
20
|
|
|
|
21
|
|
|
def test_time_ref(self): |
22
|
|
|
expected = Time(51910.00074287037, format="mjd", scale="tt") |
23
|
|
|
assert_time_allclose(self.fpi.time_ref, expected) |
24
|
|
|
|
25
|
|
|
def test_time_start(self): |
26
|
|
|
time = self.fpi.time_start |
27
|
|
|
expected = Time(53025.826414166666, format="mjd", scale="tt") |
28
|
|
|
assert_time_allclose(time, expected) |
29
|
|
|
|
30
|
|
|
def test_time_stop(self): |
31
|
|
|
time = self.fpi.time_stop |
32
|
|
|
expected = Time(53025.844770648146, format="mjd", scale="tt") |
33
|
|
|
assert_time_allclose(time, expected) |
34
|
|
|
|
35
|
|
|
def test_duration(self): |
36
|
|
|
duration = self.fpi.duration |
37
|
|
|
assert_allclose(duration.sec, 1586.0000000044238) |
38
|
|
|
|
39
|
|
|
def test_radec(self): |
40
|
|
|
pos = self.fpi.radec |
41
|
|
|
assert_allclose(pos.ra.deg, 83.633333333333) |
42
|
|
|
assert_allclose(pos.dec.deg, 24.51444444) |
43
|
|
|
assert pos.name == "icrs" |
44
|
|
|
|
45
|
|
|
def test_altaz(self): |
46
|
|
|
pos = self.fpi.altaz |
47
|
|
|
assert_allclose(pos.az.deg, 7.48272) |
48
|
|
|
assert_allclose(pos.alt.deg, 41.84191) |
49
|
|
|
assert pos.name == "altaz" |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
|
53
|
|
|
@requires_data("gammapy-data") |
54
|
|
|
class TestPointingInfo: |
55
|
|
|
@classmethod |
56
|
|
|
def setup_class(cls): |
57
|
|
|
filename = "$GAMMAPY_DATA/tests/hess_event_list.fits" |
58
|
|
|
cls.pointing_info = PointingInfo.read(filename) |
59
|
|
|
|
60
|
|
|
def test_str(self): |
61
|
|
|
ss = str(self.pointing_info) |
62
|
|
|
assert "Pointing info" in ss |
63
|
|
|
|
64
|
|
|
def test_location(self): |
65
|
|
|
lon, lat, height = self.pointing_info.location.geodetic |
66
|
|
|
assert_allclose(lon.deg, 16.5002222222222) |
67
|
|
|
assert_allclose(lat.deg, -23.2717777777778) |
68
|
|
|
assert_allclose(height.value, 1834.999999999783) |
69
|
|
|
|
70
|
|
|
def test_time_ref(self): |
71
|
|
|
expected = Time(51910.00074287037, format="mjd", scale="tt") |
72
|
|
|
assert_time_allclose(self.pointing_info.time_ref, expected) |
73
|
|
|
|
74
|
|
|
def test_table(self): |
75
|
|
|
assert len(self.pointing_info.table) == 100 |
76
|
|
|
|
77
|
|
|
def test_time(self): |
78
|
|
|
time = self.pointing_info.time |
79
|
|
|
assert len(time) == 100 |
80
|
|
|
expected = Time(53025.826414166666, format="mjd", scale="tt") |
81
|
|
|
assert_time_allclose(time[0], expected) |
82
|
|
|
|
83
|
|
|
def test_duration(self): |
84
|
|
|
duration = self.pointing_info.duration |
85
|
|
|
assert_allclose(duration.sec, 1586.0000000044238) |
86
|
|
|
|
87
|
|
|
def test_radec(self): |
88
|
|
|
pos = self.pointing_info.radec[0] |
89
|
|
|
assert_allclose(pos.ra.deg, 83.633333333333) |
90
|
|
|
assert_allclose(pos.dec.deg, 24.51444444) |
91
|
|
|
assert pos.name == "icrs" |
92
|
|
|
|
93
|
|
|
def test_altaz(self): |
94
|
|
|
pos = self.pointing_info.altaz[0] |
95
|
|
|
assert_allclose(pos.az.deg, 11.45751357) |
96
|
|
|
assert_allclose(pos.alt.deg, 41.34088901) |
97
|
|
|
assert pos.name == "altaz" |
98
|
|
|
|
99
|
|
|
def test_altaz_from_table(self): |
100
|
|
|
pos = self.pointing_info.altaz_from_table[0] |
101
|
|
|
assert_allclose(pos.az.deg, 11.20432353385406) |
102
|
|
|
assert_allclose(pos.alt.deg, 41.37921408774436) |
103
|
|
|
assert pos.name == "altaz" |
104
|
|
|
|
105
|
|
|
def test_altaz_interpolate(self): |
106
|
|
|
time = self.pointing_info.time[0] |
107
|
|
|
pos = self.pointing_info.altaz_interpolate(time) |
108
|
|
|
assert_allclose(pos.az.deg, 11.45751357) |
109
|
|
|
assert_allclose(pos.alt.deg, 41.34088901) |
110
|
|
|
assert pos.name == "altaz" |
111
|
|
|
|