diff --git a/python/lsst/ts/imsim/opd_metrology.py b/python/lsst/ts/imsim/opd_metrology.py index 95afbe4..6b98925 100644 --- a/python/lsst/ts/imsim/opd_metrology.py +++ b/python/lsst/ts/imsim/opd_metrology.py @@ -108,7 +108,7 @@ def get_default_lsst_wfs_gq(self) -> tuple[list[float], list[float], list[int]]: # These will be chosen at the center of the extra-intra # focal pairs of wavefront sensors. det_ids = [191, 195, 199, 203] - camera = get_camera("lsst") + camera = get_camera(CamType.LsstCam) field_x = [] field_y = [] det_map = camera.getIdMap() diff --git a/tests/test_closed_loop_task.py b/tests/test_closed_loop_task.py index c761a2f..91e1b21 100644 --- a/tests/test_closed_loop_task.py +++ b/tests/test_closed_loop_task.py @@ -51,7 +51,7 @@ def test_config_sky_sim_with_error(self): ) def test_config_sky_sim_no_sky_file_lsst(self): - self.closed_loop_task.config_sky_sim("lsst", self.obs_metadata) + self.closed_loop_task.config_sky_sim(CamType.LsstCam, self.obs_metadata) sky_sim = self.closed_loop_task.sky_sim self.assertEqual(len(sky_sim.star_id), 8) @@ -61,7 +61,7 @@ def test_config_sky_sim_with_sky_file(self): get_module_path(), "tests", "testData", "sky", "wfsStar.txt" ) self.closed_loop_task.config_sky_sim( - "lsst", self.obs_metadata, path_sky_file=test_sky_file + CamType.LsstCam, self.obs_metadata, path_sky_file=test_sky_file ) sky_sim = self.closed_loop_task.sky_sim @@ -73,7 +73,7 @@ def test_config_ofc_calc(self): self.closed_loop_task.config_ofc_calc(cam_type) ofc_calc = self.closed_loop_task.ofc_calc - self.assertEqual(ofc_calc.ofc_data.name, cam_type) + self.assertEqual(ofc_calc.ofc_data.name, "lsst") def test_map_filter_ref_to_g(self): # test that the reference filter @@ -184,7 +184,9 @@ def test_set_img_parser(self): self.assertEqual(args.star_mag, 15.0) def test_get_sensor_name_list_of_field_lsst_wfs(self): - sensor_name_list = self.closed_loop_task.get_sensor_name_list_of_fields("lsst") + sensor_name_list = self.closed_loop_task.get_sensor_name_list_of_fields( + CamType.LsstCam + ) self.assertEqual(len(sensor_name_list), 8) sensor_name_list_ans = [ @@ -200,7 +202,9 @@ def test_get_sensor_name_list_of_field_lsst_wfs(self): self.assertCountEqual(sensor_name_list, sensor_name_list_ans) def test_get_sensor_id_list_of_fields(self): - sensor_id_list = self.closed_loop_task.get_sensor_id_list_of_fields("lsst") + sensor_id_list = self.closed_loop_task.get_sensor_id_list_of_fields( + CamType.LsstCam + ) self.assertEqual(len(sensor_id_list), 8) sensor_id_list_ans = [191, 192, 195, 196, 199, 200, 203, 204] diff --git a/tests/test_imsim_cmpt.py b/tests/test_imsim_cmpt.py index dfbea0d..e870809 100644 --- a/tests/test_imsim_cmpt.py +++ b/tests/test_imsim_cmpt.py @@ -34,6 +34,7 @@ get_module_path, get_zk_from_file, ) +from lsst.ts.wep.utils import CamType class TestImsimCmpt(unittest.TestCase): @@ -83,7 +84,7 @@ def tearDown(self): shutil.rmtree(self.output_dir) def _map_sensor_name_and_id(self, sensor_name_list): - camera = get_camera("lsst") + camera = get_camera(CamType.LsstCam) return dict( [ (camera[detector].getName(), camera[detector].getId()) @@ -108,7 +109,9 @@ def test_verify_pointer_file_raises_error(self): def test_assemble_config(self): full_config_yaml = self.imsim_cmpt.assemble_config_yaml( - self.obs_metadata_test, self.config_pointer_default_lsst_cam, "lsst" + self.obs_metadata_test, + self.config_pointer_default_lsst_cam, + CamType.LsstCam, ) self.full_test_yaml["output"]["dir"] = self.imsim_cmpt.output_img_dir self.assertDictEqual(full_config_yaml, self.full_test_yaml) @@ -124,7 +127,9 @@ def test_convert_obs_metadata_to_text(self): self.assertDictEqual(yaml.safe_load(obs_variables_text), default_vars) def test_format_opd_text_lsst_cam(self): - opd_text = self.imsim_cmpt.format_opd_text(self.obs_metadata_test, "lsst") + opd_text = self.imsim_cmpt.format_opd_text( + self.obs_metadata_test, CamType.LsstCam + ) self.assertTrue(opd_text.startswith(" opd:")) self.assertTrue( opd_text.endswith( @@ -253,7 +258,7 @@ def _analyze_lsst_cam_opd_data(self, rot_opd_in_deg=0.0): self.imsim_cmpt.output_img_dir, ) self.imsim_cmpt.analyze_opd_data( - "lsst", + CamType.LsstCam, zk_file_name=self.zk_file_name, rot_opd_in_deg=rot_opd_in_deg, pssn_file_name=self.pssn_file_name, @@ -343,7 +348,7 @@ def test_reorder_and_save_wf_err_file(self): sensor_id_list = list(map_sensor_name_and_id.values()) zk_file_name = "testZk.zer" - camera = get_camera("lsst") + camera = get_camera(CamType.LsstCam) self.imsim_cmpt.reorder_and_save_wf_err_file( list_of_wf_err, ref_sensor_name_list, camera, zk_file_name=zk_file_name ) diff --git a/tests/test_opd_metrology.py b/tests/test_opd_metrology.py index 3bd6ffa..159341a 100644 --- a/tests/test_opd_metrology.py +++ b/tests/test_opd_metrology.py @@ -28,6 +28,7 @@ from lsst.afw.cameraGeom import FIELD_ANGLE from lsst.ts.imsim import OpdMetrology from lsst.ts.imsim.utils.utility import get_module_path, get_zk_from_file +from lsst.ts.wep.utils import CamType class TestOpdMetrology(unittest.TestCase): @@ -50,7 +51,7 @@ def test_set_weighting_ratio(self): self.assertEqual(str(context.exception), "All weighting ratios should be >= 0.") def test_set_wgt_and_field_xy_of_gq_lsst_fam(self): - self.metr.set_wgt_and_field_xy_of_gq("lsstfam") + self.metr.set_wgt_and_field_xy_of_gq(CamType.LsstFamCam) field_x = self.metr.field_x self.assertEqual(len(field_x), 189) @@ -60,7 +61,7 @@ def test_set_wgt_and_field_xy_of_gq_lsst_fam(self): def test_set_wgt_and_field_xy_of_gq_err(self): self.assertRaises( - RuntimeError, self.metr.set_wgt_and_field_xy_of_gq, "NoThisInstName" + ValueError, self.metr.set_wgt_and_field_xy_of_gq, "NoThisInstName" ) def test_set_default_lsst_wfs_gq(self): diff --git a/tests/test_sky_sim.py b/tests/test_sky_sim.py index 7cb83e9..e41f941 100644 --- a/tests/test_sky_sim.py +++ b/tests/test_sky_sim.py @@ -24,6 +24,7 @@ from lsst.ts.imsim import SkySim from lsst.ts.imsim.utils.utility import get_module_path +from lsst.ts.wep.utils import CamType class TestSkySim(unittest.TestCase): @@ -31,7 +32,7 @@ def setUp(self): self.sky_sim = SkySim() def test_set_camera(self): - self.sky_sim.set_camera("lsstfam") + self.sky_sim.set_camera(CamType.LsstFamCam) self.assertEqual(self.sky_sim._camera.getName(), "LSSTCam") def test_add_star_by_ra_dec_in_deg(self): diff --git a/tests/utils/test_utility.py b/tests/utils/test_utility.py index fb8c33c..0152343 100644 --- a/tests/utils/test_utility.py +++ b/tests/utils/test_utility.py @@ -32,6 +32,7 @@ get_policy_path, get_zk_from_file, ) +from lsst.ts.wep.utils import CamType class TestUtility(unittest.TestCase): @@ -50,11 +51,11 @@ def test_get_config_dir(self): ) def test_get_camera(self): - lsst_fam_cam = get_camera("lsstfam") + lsst_fam_cam = get_camera(CamType.LsstFamCam) self.assertIsInstance(lsst_fam_cam, cameraGeom.Camera) self.assertEqual(lsst_fam_cam.getName(), LsstCam.getCamera().getName()) - lsst_cam = get_camera("lsst") + lsst_cam = get_camera(CamType.LsstCam) self.assertIsInstance(lsst_cam, cameraGeom.Camera) self.assertEqual(lsst_cam.getName(), LsstCam.getCamera().getName())