Skip to content

Commit

Permalink
Merge pull request #34 from lsst-ts/tickets/DM-42848
Browse files Browse the repository at this point in the history
Tickets/DM-42848: fit up to zk28
  • Loading branch information
suberlak authored Mar 6, 2024
2 parents dcefae7 + d097315 commit f61f94f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
9 changes: 8 additions & 1 deletion doc/versionHistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
Version History
##################

=======
-------------
1.3.0
-------------

* Update to fit OPD up to zk28 like imsim.

-------------
1.2.1
-------------

* Update KMP_INIT_FORK to start only on darwin.

-------------
1.2.0
-------------

Expand Down
6 changes: 4 additions & 2 deletions python/lsst/ts/imsim/imsim_cmpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,10 @@ def _map_opd_to_zk(self, rot_opd_in_deg: float, num_opd: int) -> np.ndarray:
else:
opd_rot = opd

# z1 to z22 (22 terms)
zk = self.opd_metr.get_zk_from_opd(opd_map=opd_rot)[0]
# z1 to z28 (28 terms)
# this is to match imSim output that
# also fits up to zk28 by default
zk = self.opd_metr.get_zk_from_opd(opd_map=opd_rot, zk_terms=28)[0]

# Only need to collect z4 to z22
init_idx = 3
Expand Down
39 changes: 20 additions & 19 deletions tests/testData/opd/opd.zer
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# The followings are OPD in rotation angle of -0.00 degree in nm from z4 to z22:
191: [-4.15577837e+02 4.03053050e+02 6.19438978e+02 -4.44665578e+00
1.00741331e+01 3.55263409e+01 -9.61023230e+00 1.44900235e-01
-1.02512184e+00 -3.99302251e+01 9.81672032e+00 1.09511113e+02
-1.01009395e+00 -1.03280016e+00 2.30629852e+00 2.55961095e+01
-1.29456402e+00 3.40161544e+01 -1.13822260e+01]
195: [-407.96514385 -69.61576656 631.04232073 50.49126701 7.97330041
252.35981927 30.87974042 -3.93741576 17.25916179 25.49876989
19.17288935 113.36121766 2.97981464 -6.73377281 6.2956465
-31.79557922 -14.85384164 29.62548445 -10.81317459]
199: [-406.87545247 -43.41883523 678.05355873 3.63692016 -43.14243043
22.29089894 180.82275562 -5.65229654 -21.64993839 22.26986463
3.69490561 103.41585077 7.4490198 3.37207099 -42.23624375
17.04691 -4.30762799 23.83670381 -10.49902789]
203: [-3.89941394e+02 2.85791837e+02 6.41296675e+02 3.26727427e+01
-3.35857590e+01 1.90287712e+02 1.75210163e+02 -1.06136662e+01
-1.22732198e+01 -2.09839551e+01 4.17355247e-01 1.08153979e+02
5.16252005e+00 -1.42877583e+00 -3.38332003e+01 -2.19601267e+01
-5.94293965e+00 3.59018468e+01 -8.63500688e+00]
# The followings are OPD in rotation angle of 0.00 degree in nm from z4 to z22:
191: [-4.12984795e+02 3.97861340e+02 6.20953574e+02 -9.18211143e+00
1.57909999e+01 3.09916582e+01 -1.01412832e+01 5.16994880e+00
1.67671900e+00 -4.32129292e+01 6.58679408e+00 1.06763043e+02
1.83394287e+00 -1.77364978e+00 3.24442731e-01 2.10808693e+01
-4.69030145e+00 3.35001319e+01 -1.01425116e+01]
195: [-4.05881943e+02 -6.61577056e+01 6.28675755e+02 5.53831529e+01
1.08367930e+01 2.51208810e+02 2.71314595e+01 1.87480517e-02
1.41580410e+01 2.77429123e+01 1.81827986e+01 1.09939652e+02
3.42853630e+00 -4.02859587e+00 2.40471240e+00 -3.20263034e+01
-1.25116710e+01 2.76525919e+01 -9.49054535e+00]
199: [-4.06332989e+02 -4.15501820e+01 6.76578718e+02 6.25870973e-01
-4.50588829e+01 2.37614717e+01 1.82878056e+02 -3.02333134e+00
-2.39302442e+01 2.26779924e+01 3.66733144e+00 1.00935872e+02
7.97371859e+00 2.17383009e+00 -3.99416136e+01 1.72982538e+01
-6.57745773e+00 2.49815546e+01 -9.98807650e+00]
203: [-389.67876381 282.82840858 644.82900483 34.75488342 -38.53752871
194.97271673 172.19087951 -7.06751941 -7.51713016 -21.34462189
-0.92738878 102.56372579 3.51521073 -3.22731173 -34.91786544
-16.79592916 -1.7935068 39.25997429 -8.49566669]
10 changes: 5 additions & 5 deletions tests/test_opd_metrology.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ def _get_opd_dir(self):

def test_get_zk_from_opd(self):
opd_dir = self._get_opd_dir()
zk = self.metr.get_zk_from_opd(opd_fits_file=os.path.join(opd_dir, "opd.fits"))[
0
]
zk = self.metr.get_zk_from_opd(
opd_fits_file=os.path.join(opd_dir, "opd.fits"), zk_terms=28
)[0]

ans_opd_file_name = "opd.zer"
ans_opd_file_path = os.path.join(opd_dir, ans_opd_file_name)
all_opd_ans = get_zk_from_file(ans_opd_file_path)
self.assertLess(np.sum(np.abs(zk[3:] - all_opd_ans[191])), 1e-5)
self.assertLess(np.sum(np.abs(zk[3:22] - all_opd_ans[191])), 1e-5)

def test_rm_piston_tip_tilt_from_opd(self):
"""Test removal of piston (z1), x-tilt (z2), and y-tilt (z3)
Expand All @@ -126,7 +126,7 @@ def test_rm_piston_tip_tilt_from_opd(self):
)

# Flip OPD because it will be flipped inside get_zk_from_opd
zk_rm_ptt = self.metr.get_zk_from_opd(opd_map=opd_rm_ptt)[0]
zk_rm_ptt = self.metr.get_zk_from_opd(opd_map=opd_rm_ptt, zk_terms=28)[0]
zk_rm_ptt_in_um = np.sum(np.abs(zk_rm_ptt[0:3])) / 1e3
self.assertLess(zk_rm_ptt_in_um, 9e-2)

Expand Down

0 comments on commit f61f94f

Please sign in to comment.