Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions sotodlib/coords/pointing_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ def apply_pointing_model_lat(vers, params, ancil):

if vers == 'lat_naive':
return _new_boresight(ancil.samps, az=az, el=el, roll=roll)

if vers == "lat_v1":
elif vers == "lat_v1":
az1, el1, roll1 = model_lat_v1(params, az, el, roll)
return _new_boresight(ancil.samps, az=az1, el=el1, roll=roll1)

else:
raise ValueError(f'Unimplemented pointing model "{vers}"')

Expand All @@ -156,6 +154,10 @@ def model_lat_v1(params, az, el, roll):
- mir_center_{xi,eta}0: The (xi,eta) coordinate in the El-structure-centered
focal plane that appears fixed when the mirrors are rotated about the ray from
sky that hits the center of both mirrors.
- base_tilt_{cos,sin}: Base tilt coefficients, in radians.
- el_sag_{quad,lin}: Dimensionless coefficients for the quadradtic
and linear components of the elevation sag.
- el_sag_pivot: The elevation in radians to treat as the sag's zero point.

"""
_p = dict(param_defaults['lat_v1'])
Expand Down Expand Up @@ -217,7 +219,26 @@ def model_lat_v1(params, az, el, roll):
* q_el_roll * q_el_axis_center
* q_cr_roll * q_cr_center
)
new_az, el, roll = quat.decompose_lonlat(q_hs)* np.array([-1, 1, 1])[..., None]
az, el, roll = quat.decompose_lonlat(q_hs)* np.array([-1, 1, 1])[..., None]
cr = el - roll - np.deg2rad(60)

# Base tilt
q_base_tilt = get_base_tilt_q(params['base_tilt_cos'], params['base_tilt_sin'])

# El sag
el_sag = params['el_sag_quad']*(el - params['el_sag_pivot'])**2
el_sag += params['el_sag_lin']*(el - params['el_sag_pivot'])
el += el_sag

# Lonlat rotation after v1 model and el sag is applied
q_lonlat = quat.rotation_lonlat(-1 * az, el) * quat.euler(2, roll)

# Horizon Coordinates
q_hs = q_base_tilt * q_lonlat
new_az, el, _ = quat.decompose_lonlat(q_hs)* np.array([-1, 1, 1])[..., None]

# Get new roll with the modified el
roll = el - cr - np.deg2rad(60)

# Make corrected az as close as possible to the input az.
change = ((new_az - az_orig) + np.pi) % (2 * np.pi) - np.pi
Expand Down Expand Up @@ -311,6 +332,22 @@ def model_sat_v1(params, az, el, roll):
'mir_center_xi0': 0,
'mir_center_eta0': 0,
},
'lat_v2' : {
'enc_offset_az': 0,
'enc_offset_el': 0,
'enc_offset_cr': 0,
'el_axis_center_xi0': 0,
'el_axis_center_eta0': 0,
'cr_center_xi0': 0,
'cr_center_eta0': 0,
'mir_center_xi0': 0,
'mir_center_eta0': 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete these -- this is still lat_v1.

As written, I believe the code will error if you pass it an old params dict. Because the updated defaults will not be loaded. A smoke test would be helpful here.

Please add LAT model test to tests/test_pointing_model.py, including backwards compatibility check.

'base_tilt_cos': 0,
'base_tilt_sin': 0,
'el_sag_quad': 0,
'el_sag_lin': 0,
'el_sag_pivot': np.pi/2.,
},
'sat_v1' : {
'enc_offset_az': 0.,
'enc_offset_el': 0.,
Expand Down