diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 711ced1..d5649af 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -17,6 +17,7 @@ jobs: - name: Install run: | + $CONDA/bin/conda install python=3.11 $CONDA/bin/conda install -c lsstts -y ts-pre-commit-config">=0.9.2" $CONDA/bin/conda install -c conda-forge pre-commit -y $CONDA/bin/generate_pre_commit_conf --skip-pre-commit-install diff --git a/doc/versionHistory.rst b/doc/versionHistory.rst index 830869a..327f78c 100644 --- a/doc/versionHistory.rst +++ b/doc/versionHistory.rst @@ -6,6 +6,25 @@ Version History ################## +------------- +1.3.1 +------------- + +* Change imSim camera name LsstComCam to LsstComCamSim. +* Fix stamp size when using LSST_Silicon. + +------------- +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 ------------- diff --git a/policy/config/input/telescope/lsstComCamLargePert.yaml b/policy/config/input/telescope/lsstComCamLargePert.yaml index 3d5481a..b6edf27 100644 --- a/policy/config/input/telescope/lsstComCamLargePert.yaml +++ b/policy/config/input/telescope/lsstComCamLargePert.yaml @@ -1,5 +1,5 @@ telescope: - camera: LsstComCam + camera: LsstComCamSim file_name: type: FormattedStr format: ComCam_%s.yaml diff --git a/policy/config/input/telescope/lsstComCamNoPert.yaml b/policy/config/input/telescope/lsstComCamNoPert.yaml index bf687ac..475d7cb 100644 --- a/policy/config/input/telescope/lsstComCamNoPert.yaml +++ b/policy/config/input/telescope/lsstComCamNoPert.yaml @@ -1,5 +1,5 @@ telescope: - camera: LsstComCam + camera: LsstComCamSim file_name: type: FormattedStr format: ComCam_%s.yaml diff --git a/policy/config/output/lsstComCamDefault.yaml b/policy/config/output/lsstComCamDefault.yaml index 046625d..131afcd 100644 --- a/policy/config/output/lsstComCamDefault.yaml +++ b/policy/config/output/lsstComCamDefault.yaml @@ -7,7 +7,7 @@ output: mjd: *mjd seqnum: *seqnum - camera: LsstComCam + camera: LsstComCamSim exptime: $exptime diff --git a/policy/config/stamp/lsstCamLsstSilicon.yaml b/policy/config/stamp/lsstCamLsstSilicon.yaml index 7bc27e4..67fbb9c 100644 --- a/policy/config/stamp/lsstCamLsstSilicon.yaml +++ b/policy/config/stamp/lsstCamLsstSilicon.yaml @@ -1,4 +1,5 @@ stamp: + size: 500 type: LSST_Silicon det_name: "$det_name" world_pos: diff --git a/policy/config/stamp/lsstCamLsstSiliconWithDiffraction.yaml b/policy/config/stamp/lsstCamLsstSiliconWithDiffraction.yaml index 346c6ac..ee644d1 100644 --- a/policy/config/stamp/lsstCamLsstSiliconWithDiffraction.yaml +++ b/policy/config/stamp/lsstCamLsstSiliconWithDiffraction.yaml @@ -1,4 +1,5 @@ stamp: + size: 500 type: LSST_Silicon det_name: "$det_name" world_pos: diff --git a/python/lsst/ts/imsim/closed_loop_task.py b/python/lsst/ts/imsim/closed_loop_task.py index ee6a04e..d4d1f45 100644 --- a/python/lsst/ts/imsim/closed_loop_task.py +++ b/python/lsst/ts/imsim/closed_loop_task.py @@ -775,7 +775,7 @@ def _get_butler_inst_name(self, cam_type: CamType) -> str: if cam_type in [CamType.LsstCam, CamType.LsstFamCam]: butler_inst_name = "Cam" elif cam_type == CamType.ComCam: - butler_inst_name = "ComCam" + butler_inst_name = "ComCamSim" return butler_inst_name diff --git a/python/lsst/ts/imsim/imsim_cmpt.py b/python/lsst/ts/imsim/imsim_cmpt.py index cf935a1..f7acdee 100644 --- a/python/lsst/ts/imsim/imsim_cmpt.py +++ b/python/lsst/ts/imsim/imsim_cmpt.py @@ -22,6 +22,7 @@ __all__ = ["ImsimCmpt"] import os +import sys from typing import Any import numpy as np @@ -327,13 +328,20 @@ def run_imsim(self, config_file_path: str, imsim_log_file: str = "") -> None: # this variable gets set when sklearn is imported, which happens inside # of ts_wep before ever getting to this method, so we can't just unset # it in the environment ahead of time. - with ModifiedEnvironment(KMP_INIT_AT_FORK=None): - if imsim_log_file == "": - runProgram(f"galsim {config_file_path}") - else: - runProgram( - f"galsim {config_file_path} -l {os.path.join(self.output_dir, imsim_log_file)} -v 2" - ) + if imsim_log_file == "": + cmd = f"galsim {config_file_path}" + else: + cmd = f"galsim {config_file_path} -l {os.path.join(self.output_dir, imsim_log_file)} -v 2" + # Disabling the KMP_INIT_AT_FORK env variable only for OSX. + # This line checks whether the platform identifies itself as OSX. + # For all other environments (eg. linux) this is not needed; + # and indeed was found to cause issues for mag=12 and brighter + # source on USDF. + if sys.platform.startswith("darwin"): + with ModifiedEnvironment(KMP_INIT_AT_FORK=None): + runProgram(cmd) + else: + runProgram(cmd) def write_yaml_and_run_imsim( self, @@ -636,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 diff --git a/tests/testData/imsimConfig/imsimConfigLsstCam.yaml b/tests/testData/imsimConfig/imsimConfigLsstCam.yaml index b1d0a11..f5412e2 100644 --- a/tests/testData/imsimConfig/imsimConfigLsstCam.yaml +++ b/tests/testData/imsimConfig/imsimConfigLsstCam.yaml @@ -274,6 +274,7 @@ psf: stamp: + size: 500 type: LSST_Silicon det_name: "$det_name" world_pos: diff --git a/tests/testData/opd/opd.zer b/tests/testData/opd/opd.zer index f9be892..ae38ae9 100644 --- a/tests/testData/opd/opd.zer +++ b/tests/testData/opd/opd.zer @@ -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] diff --git a/tests/test_closed_loop_task.py b/tests/test_closed_loop_task.py index 3ff62aa..a6b1ce4 100644 --- a/tests/test_closed_loop_task.py +++ b/tests/test_closed_loop_task.py @@ -183,4 +183,4 @@ def test_get_butler_inst_name(self): self.assertEqual(lsstcam_str, "Cam") self.assertEqual(lsstfam_str, "Cam") - self.assertEqual(comcam_str, "ComCam") + self.assertEqual(comcam_str, "ComCamSim") diff --git a/tests/test_opd_metrology.py b/tests/test_opd_metrology.py index 4f50961..7438340 100644 --- a/tests/test_opd_metrology.py +++ b/tests/test_opd_metrology.py @@ -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) @@ -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)