Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkalmbach committed Nov 16, 2023
1 parent c863a4a commit 5137181
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/lsst/ts/imsim/opd_metrology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 9 additions & 5 deletions tests/test_closed_loop_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 = [
Expand All @@ -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]
Expand Down
15 changes: 10 additions & 5 deletions tests/test_imsim_cmpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
get_module_path,
get_zk_from_file,
)
from lsst.ts.wep.utils import CamType


class TestImsimCmpt(unittest.TestCase):
Expand Down Expand Up @@ -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())
Expand All @@ -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)
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_opd_metrology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_sky_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@

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):
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):
Expand Down
5 changes: 3 additions & 2 deletions tests/utils/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
get_policy_path,
get_zk_from_file,
)
from lsst.ts.wep.utils import CamType


class TestUtility(unittest.TestCase):
Expand All @@ -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())

Expand Down

0 comments on commit 5137181

Please sign in to comment.