Skip to content

Commit 2c2e70f

Browse files
committed
Add rotated arg to utils functions
1 parent a26a34c commit 2c2e70f

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

fact/coordinates/utils.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ def arrays_to_altaz(zenith, azimuth, obstime=None):
1919
)
2020

2121

22-
def arrays_to_camera(x, y, pointing_direction, obstime=None):
22+
def arrays_to_camera(x, y, pointing_direction, obstime=None, rotated=True):
2323
if obstime is not None:
2424
obstime = to_astropy_time(obstime)
25-
frame = CameraFrame(pointing_direction=pointing_direction, obstime=obstime)
25+
frame = CameraFrame(
26+
pointing_direction=pointing_direction,
27+
obstime=obstime,
28+
rotated=rotated,
29+
)
2630
return SkyCoord(
2731
x=np.asanyarray(x) * u.mm,
2832
y=np.asanyarray(y) * u.mm,
@@ -63,7 +67,7 @@ def to_astropy_time(series_or_array):
6367
return Time(time, scale='utc')
6468

6569

66-
def equatorial_to_camera(ra, dec, zd_pointing, az_pointing, obstime):
70+
def equatorial_to_camera(ra, dec, zd_pointing, az_pointing, obstime, rotated=True):
6771
'''
6872
Convert sky coordinates from the equatorial frame to FACT camera
6973
coordinates.
@@ -80,6 +84,11 @@ def equatorial_to_camera(ra, dec, zd_pointing, az_pointing, obstime):
8084
Azimuth of the telescope pointing direction in degree
8185
obstime: datetime or np.datetime64
8286
Time of the observations
87+
rotated: bool
88+
True means x points right and y points up when looking on the camera
89+
from the dish, which is the efinition of FACT-Tools >= 1.0 and Mars.
90+
False means x points up and y points left,
91+
which is definition in the original FACTPixelMap file.
8392
8493
Returns
8594
-------
@@ -93,13 +102,13 @@ def equatorial_to_camera(ra, dec, zd_pointing, az_pointing, obstime):
93102
eq_coordinates = arrays_to_equatorial(ra, dec, obstime=obstime)
94103
pointing_direction = arrays_to_altaz(zd_pointing, az_pointing, obstime)
95104

96-
camera_frame = CameraFrame(pointing_direction=pointing_direction)
105+
camera_frame = CameraFrame(pointing_direction=pointing_direction, rotated=rotated)
97106
cam_coordinates = eq_coordinates.transform_to(camera_frame)
98107

99108
return cam_coordinates.x.to(u.mm).value, cam_coordinates.y.to(u.mm).value
100109

101110

102-
def camera_to_equatorial(x, y, zd_pointing, az_pointing, obstime):
111+
def camera_to_equatorial(x, y, zd_pointing, az_pointing, obstime, rotated=True):
103112
'''
104113
Convert FACT camera coordinates to sky coordinates in the equatorial (icrs)
105114
frame.
@@ -118,6 +127,11 @@ def camera_to_equatorial(x, y, zd_pointing, az_pointing, obstime):
118127
Azimuth of the telescope pointing direction in degree
119128
obstime: datetime or np.datetime64
120129
Time of the observations
130+
rotated: bool
131+
True means x points right and y points up when looking on the camera
132+
from the dish, which is the efinition of FACT-Tools >= 1.0 and Mars.
133+
False means x points up and y points left,
134+
which is definition in the original FACTPixelMap file.
121135
122136
Returns
123137
-------
@@ -127,13 +141,15 @@ def camera_to_equatorial(x, y, zd_pointing, az_pointing, obstime):
127141
Declination in degrees
128142
'''
129143
pointing_direction = arrays_to_altaz(zd_pointing, az_pointing, obstime)
130-
cam_coordinates = arrays_to_camera(x, y, pointing_direction, obstime=obstime)
144+
cam_coordinates = arrays_to_camera(
145+
x, y, pointing_direction, obstime=obstime, rotated=True
146+
)
131147
eq_coordinates = cam_coordinates.transform_to(ICRS)
132148

133149
return eq_coordinates.ra.hourangle, eq_coordinates.dec.deg
134150

135151

136-
def horizontal_to_camera(zd, az, zd_pointing, az_pointing):
152+
def horizontal_to_camera(zd, az, zd_pointing, az_pointing, rotated=True):
137153
'''
138154
Convert sky coordinates from the equatorial frame to FACT camera
139155
coordinates.
@@ -148,6 +164,11 @@ def horizontal_to_camera(zd, az, zd_pointing, az_pointing):
148164
Zenith distance of the telescope pointing direction in degree
149165
az_pointing: number or array-like
150166
Azimuth of the telescope pointing direction in degree
167+
rotated: bool
168+
True means x points right and y points up when looking on the camera
169+
from the dish, which is the efinition of FACT-Tools >= 1.0 and Mars.
170+
False means x points up and y points left,
171+
which is definition in the original FACTPixelMap file.
151172
152173
Returns
153174
-------
@@ -161,13 +182,15 @@ def horizontal_to_camera(zd, az, zd_pointing, az_pointing):
161182
altaz = arrays_to_altaz(zd, az)
162183
pointing_direction = arrays_to_altaz(zd_pointing, az_pointing)
163184

164-
camera_frame = CameraFrame(pointing_direction=pointing_direction)
185+
camera_frame = CameraFrame(
186+
pointing_direction=pointing_direction, rotated=rotated
187+
)
165188
cam_coordinates = altaz.transform_to(camera_frame)
166189

167190
return cam_coordinates.x.to(u.mm).value, cam_coordinates.y.to(u.mm).value
168191

169192

170-
def camera_to_horizontal(x, y, zd_pointing, az_pointing):
193+
def camera_to_horizontal(x, y, zd_pointing, az_pointing, rotated=True):
171194
'''
172195
Convert FACT camera coordinates to sky coordinates in the equatorial (icrs)
173196
frame.
@@ -184,6 +207,11 @@ def camera_to_horizontal(x, y, zd_pointing, az_pointing):
184207
Zenith distance of the telescope pointing direction in degree
185208
az_pointing: number or array-like
186209
Azimuth of the telescope pointing direction in degree
210+
rotated: bool
211+
True means x points right and y points up when looking on the camera
212+
from the dish, which is the efinition of FACT-Tools >= 1.0 and Mars.
213+
False means x points up and y points left,
214+
which is definition in the original FACTPixelMap file.
187215
188216
Returns
189217
-------
@@ -193,7 +221,9 @@ def camera_to_horizontal(x, y, zd_pointing, az_pointing):
193221
Declination in degrees
194222
'''
195223
pointing_direction = arrays_to_altaz(zd_pointing, az_pointing)
196-
cam_coordinates = arrays_to_camera(x, y, pointing_direction)
224+
cam_coordinates = arrays_to_camera(
225+
x, y, pointing_direction, rotated=rotated
226+
)
197227
altaz = cam_coordinates.transform_to(AltAz(location=LOCATION))
198228

199229
return altaz.zen.deg, altaz.az.deg

0 commit comments

Comments
 (0)