Skip to content

Commit cefb856

Browse files
committed
Merge remote-tracking branch 'origin/latpmv2' into depth1_mapmaker
2 parents 8795eb1 + c7d56f2 commit cefb856

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

sotodlib/coords/pointing_model.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,9 @@ def apply_pointing_model_lat(vers, params, ancil):
125125

126126
if vers == 'lat_naive':
127127
return _new_boresight(ancil.samps, az=az, el=el, roll=roll)
128-
129-
if vers == "lat_v1":
128+
elif vers == "lat_v1":
130129
az1, el1, roll1 = model_lat_v1(params, az, el, roll)
131130
return _new_boresight(ancil.samps, az=az1, el=el1, roll=roll1)
132-
133131
else:
134132
raise ValueError(f'Unimplemented pointing model "{vers}"')
135133

@@ -156,6 +154,10 @@ def model_lat_v1(params, az, el, roll):
156154
- mir_center_{xi,eta}0: The (xi,eta) coordinate in the El-structure-centered
157155
focal plane that appears fixed when the mirrors are rotated about the ray from
158156
sky that hits the center of both mirrors.
157+
- base_tilt_{cos,sin}: Base tilt coefficients, in radians.
158+
- el_sag_{quad,lin}: Dimensionless coefficients for the quadradtic
159+
and linear components of the elevation sag.
160+
- el_sag_pivot: The elevation in radians to treat as the sag's zero point.
159161
160162
"""
161163
_p = dict(param_defaults['lat_v1'])
@@ -217,7 +219,26 @@ def model_lat_v1(params, az, el, roll):
217219
* q_el_roll * q_el_axis_center
218220
* q_cr_roll * q_cr_center
219221
)
220-
new_az, el, roll = quat.decompose_lonlat(q_hs)* np.array([-1, 1, 1])[..., None]
222+
az, el, roll = quat.decompose_lonlat(q_hs)* np.array([-1, 1, 1])[..., None]
223+
cr = el - roll - np.deg2rad(60)
224+
225+
# Base tilt
226+
q_base_tilt = get_base_tilt_q(params['base_tilt_cos'], params['base_tilt_sin'])
227+
228+
# El sag
229+
el_sag = params['el_sag_quad']*(el - params['el_sag_pivot'])**2
230+
el_sag += params['el_sag_lin']*(el - params['el_sag_pivot'])
231+
el += el_sag
232+
233+
# Lonlat rotation after v1 model and el sag is applied
234+
q_lonlat = quat.rotation_lonlat(-1 * az, el) * quat.euler(2, roll)
235+
236+
# Horizon Coordinates
237+
q_hs = q_base_tilt * q_lonlat
238+
new_az, el, _ = quat.decompose_lonlat(q_hs)* np.array([-1, 1, 1])[..., None]
239+
240+
# Get new roll with the modified el
241+
roll = el - cr - np.deg2rad(60)
221242

222243
# Make corrected az as close as possible to the input az.
223244
change = ((new_az - az_orig) + np.pi) % (2 * np.pi) - np.pi
@@ -318,6 +339,11 @@ def model_sat_v1(params, az, el, roll):
318339
'cr_center_eta0': 0,
319340
'mir_center_xi0': 0,
320341
'mir_center_eta0': 0,
342+
'base_tilt_cos': 0,
343+
'base_tilt_sin': 0,
344+
'el_sag_quad': 0,
345+
'el_sag_lin': 0,
346+
'el_sag_pivot': np.pi/2.,
321347
},
322348
'sat_v1' : {
323349
'enc_offset_az': 0.,

tests/test_pointing_model.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,22 @@ def tpoint_base_tilt(an, aw, az, el):
145145
assert(abs(sig_meas - sig * DEG) < .001*DEG)
146146

147147

148+
def test_lat_v1(self):
149+
az, el, roll = full_vectors(az=np.linspace(-90, 90, 100),
150+
el=60)
151+
params = {'version': 'lat_v1'}
152+
az1, el1, roll1 = to_deg(*pm.model_lat_v1(params, *to_rad(az, el, roll)))
153+
154+
# Backwards compatibility for not providing el sag or base tilt
155+
params['enc_offset_az'] = 1. * DEG
156+
az1, el1, roll1 = to_deg(*pm.model_lat_v1(params, *to_rad(az, el, roll)))
157+
assert np.all(center_branch(az1 - az) > 0)
158+
159+
# Try an el sag
160+
params['el_sag_lin'] = 1
161+
az2, el2, roll2 = to_deg(*pm.model_lat_v1(params, *to_rad(az, el, roll)))
162+
assert np.all(np.isclose(el/el2, 2))
163+
164+
148165
if __name__ == '__main__':
149166
unittest.main()

0 commit comments

Comments
 (0)