Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tickets/dm 41629 #24

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions doc/versionHistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
Version History
##################

-------------
0.9.0
-------------

* Remove ZCS coordinate system and transition to CCS.
* Update bending modes to latest versions in batoid_rubin.

-------------
0.8.4
-------------
Expand Down
2 changes: 0 additions & 2 deletions policy/config/input/telescope/lsstCamDefault.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ telescope:
# There's a whole suite of FEA perturbations available (same as ts_phosim)
# Details in the telescope_loader.py file linked above.
fea:
bend_dir: bend_legacy
fea_dir: fea_legacy
m1m3_gravity: # gravitational flexure of M1M3
zenith: *zenith
m1m3_temperature:
Expand Down
2 changes: 0 additions & 2 deletions policy/config/input/telescope/lsstCamLargePert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ telescope:
# There's a whole suite of FEA perturbations available (same as ts_phosim)
# Details in the telescope_loader.py file linked above.
fea:
bend_dir: bend_legacy
fea_dir: fea_legacy
m1m3_gravity: # gravitational flexure of M1M3
zenith: *zenith
m1m3_temperature:
Expand Down
2 changes: 0 additions & 2 deletions policy/config/input/telescope/lsstCamNoPert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ telescope:
# There's a whole suite of FEA perturbations available (same as ts_phosim)
# Details in the telescope_loader.py file linked above.
fea:
bend_dir: bend_legacy
fea_dir: fea_legacy
m1m3_gravity: # gravitational flexure of M1M3
zenith: *zenith
m1m3_temperature:
Expand Down
53 changes: 12 additions & 41 deletions python/lsst/ts/imsim/closed_loop_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,14 @@ def _run_sim(
[sensor_wfe.sensor_name for sensor_wfe in list_of_wf_err]
)

# Only include the fwhm data from sensor we are simulating
# (e.g. only raft centers instead of full FAM).
if self.use_ccd_img:
fwhm_idx = [
ref_sensor_name_list.index(sens_name) for sens_name in sensor_names
]
fwhm = fwhm[fwhm_idx]

# Pass data to OFC
self.ofc_calc.set_fwhm_data(fwhm, sensor_names)

Expand All @@ -579,7 +587,7 @@ def _run_sim(
sensor_names=sensor_names,
filter_name=obs_metadata.band.upper(),
gain=-1,
rotation_angle=-obs_metadata.rotator_angle,
rotation_angle=obs_metadata.rotator_angle,
)

# Set the new aggregated DOF to phosimCmpt
Expand Down Expand Up @@ -900,52 +908,15 @@ def run_wep(
)

sensor_wavefront_data = SensorWavefrontError()
# Rotate from CCS to ZCS/PCS (Phosim Coordinate System)
rotated_name = self.rotate_det_name_ccs_to_zcs(
det_id_map[dataset.dataId["detector"]].getName()
)
sensor_wavefront_data.sensor_name = rotated_name
sensor_wavefront_data.sensor_id = det_name_map[rotated_name].getId()
sensor_name = det_id_map[dataset.dataId["detector"]].getName()
sensor_wavefront_data.sensor_name = sensor_name
sensor_wavefront_data.sensor_id = det_name_map[sensor_name].getId()
sensor_wavefront_data.annular_zernike_poly = zer_coeff

list_of_wf_err.append(sensor_wavefront_data)

return list_of_wf_err

def rotate_det_name_ccs_to_zcs(self, det_name: str) -> str:
"""Rotate the sensor name from CCS (Camera Coordinate System)
to the ZCS (Zemax Coordinate System) that OFC expects.

Parameters
----------
det_name : str
Detector name in CCS.

Returns
-------
str
Detector expected at that location in ZCS.
"""
raft, sensor = det_name.split("_")
cam_rx = int(raft[1]) - 2
cam_ry = int(raft[2]) - 2

zcs_rx = -cam_rx
zcs_ry = cam_ry

zcs_raft = f"R{zcs_rx + 2}{zcs_ry + 2}"

if sensor.startswith("SW"):
zcs_sensor = sensor
else:
cam_sx = int(sensor[1]) - 1
cam_sy = int(sensor[2]) - 1
zcs_sx = -cam_sx
zcs_sy = cam_sy
zcs_sensor = f"S{zcs_sx + 1}{zcs_sy + 1}"

return f"{zcs_raft}_{zcs_sensor}"

def write_wep_configuration(
self, inst_name: str, pipeline_yaml_path: str, filter_type_name: str
) -> None:
Expand Down
18 changes: 0 additions & 18 deletions python/lsst/ts/imsim/opd_metrology.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ def set_default_lsst_wfs_gq(self) -> None:
self.wt = np.array([1.0, 1.0, 1.0, 1.0])
wfs_field_x, wfs_field_y, sensor_ids = self.get_default_lsst_wfs_gq()
self.field_x, self.field_y = (wfs_field_x, wfs_field_y)
# Convert from CCS to ZCS for current OFC
# TODO: Remove this conversion when ts_ofc
# sensitivity matrix is updated.
self.field_x = -1.0 * np.array(self.field_x)
self.sensor_ids = sensor_ids

def get_default_lsst_wfs_gq(self) -> tuple[list[float], list[float], list[int]]:
Expand Down Expand Up @@ -170,18 +166,13 @@ def set_wgt_and_field_xy_of_gq(self, inst_name: str) -> None:
field_x.append(np.degrees(det_center[1]))
self.field_x = np.array(field_x)
self.field_y = np.array(field_y)
# Convert from CCS to ZCS for current OFC
# TODO: Remove this conversion when ts_ofc
# sensitivity matrix is updated.
self.field_x = -1.0 * self.field_x

def get_zk_from_opd(
self,
opd_fits_file: str | None = None,
opd_map: np.ndarray | None = None,
zk_terms: int = 22,
obscuration: float = 0.61,
flip_lr: bool = True,
) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
"""Get the wavefront error of OPD in the basis of annular Zernike
polynomials.
Expand All @@ -199,12 +190,6 @@ def get_zk_from_opd(
is 22.)
obscuration : float, optional
Obscuration of annular Zernike polynomial. (the default is 0.61.)
flip_lr : bool, optional
Flip the opd image in the left-right direction. Currently
this flip is needed in the closed loop because ts_ofc
has a sensitivity matrix in the Zemax Coordinate System
instead of the Camera Coordinate System. This will be removed
when ts_ofc changes to use the CCS. (the default is True.)

Returns
-------
Expand All @@ -228,9 +213,6 @@ def get_zk_from_opd(
opd = fits.getdata(opd_fits_file)
elif opd_map is not None:
opd = opd_map.copy()
# TODO: Remove when OFC moves to CCS instead of ZCS
if flip_lr is True:
opd = np.fliplr(opd)

# Check the x, y dimensions of OPD are the same
if np.unique(opd.shape).size != 1:
Expand Down
10 changes: 4 additions & 6 deletions tests/testData/imsimConfig/imsimConfigLsstCam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ input:
# There's a whole suite of FEA perturbations available (same as ts_phosim)
# Details in the telescope_loader.py file linked above.
fea:
bend_dir: bend_legacy
fea_dir: fea_legacy
m1m3_gravity: # gravitational flexure of M1M3
zenith: *zenith
m1m3_temperature:
Expand Down Expand Up @@ -369,11 +367,11 @@ output:
# Coordinates are parallel to the OCS (https://sitcomtn-003.lsst.io/#the-optical-coordinate-system)
# when rotTelPos just above is set to zero, or parallel to the CCS when rotTelPos is set
# to the camera rotator angle.
- thx: 1.1902777777777778 deg
thy: -1.1902777777777778 deg
- thx: 1.1902777777777778 deg
thy: 1.1902777777777778 deg
- thx: -1.1902777777777778 deg
thy: -1.1902777777777778 deg
- thx: -1.1902777777777778 deg
thy: 1.1902777777777778 deg
- thx: 1.1902777777777778 deg
thy: -1.1902777777777778 deg
- thx: 1.1902777777777778 deg
thy: 1.1902777777777778 deg
36 changes: 18 additions & 18 deletions tests/testData/opd/opd.zer
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# 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]
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]
4 changes: 2 additions & 2 deletions tests/test_imsim_cmpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_format_opd_text_lsst_cam(self):
self.assertTrue(opd_text.startswith(" opd:"))
self.assertTrue(
opd_text.endswith(
"- {thx: -1.1902777777777778 deg, thy: 1.1902777777777778 deg}\n"
"- {thx: 1.1902777777777778 deg, thy: 1.1902777777777778 deg}\n"
)
)

Expand Down Expand Up @@ -242,7 +242,7 @@ def test_rotate_opd_data(self):
)

np.testing.assert_almost_equal(
galsim_zernikes.rotate(np.deg2rad(-rotation_angle)).coef[4:],
galsim_zernikes.rotate(np.deg2rad(rotation_angle)).coef[4:],
zerinkes_rotation_0[idx, :],
decimal=1,
)
Expand Down
Loading