Skip to content

Commit

Permalink
Instrument can now calculate defocalOffset from batoidOffsetValue
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcrenshaw committed Jan 26, 2024
1 parent d491e92 commit 4b95d48
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
2 changes: 1 addition & 1 deletion policy/instruments/AuxTel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ focalLength: 21.6 # effective focal length in meters
defocalOffset: 32.8e-3 # defocal offset in meters
pixelSize: 10.0e-6 # pixel size in meters
wavelength: 677.0e-9 # effective wavelength, in meters
batoidModelName: AuxTel.yaml # name used to load the Batoid model
batoidModelName: AuxTel # name used to load the Batoid model
batoidOffsetValue: 0.8e-3 # batoid offset in meter (default = defocalOffset)
batoidOffsetOptic: M2 # the name of the batoid element to offset (default = Detector)

Expand Down
2 changes: 1 addition & 1 deletion policy/instruments/ComCam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ wavelength: # effective wavelength per band, in meters
i: 754.6e-9
z: 869.1e-9
y: 971.0e-9
batoidModelName: LSST_{band}.yaml # name used to load the Batoid model
batoidModelName: LSST_{band} # name used to load the Batoid model

maskParams: # center and radius are in meters, theta in degrees
M1Outer:
Expand Down
2 changes: 1 addition & 1 deletion policy/instruments/LsstCam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ wavelength: # effective wavelength per band, in meters
i: 754.6e-9
z: 869.1e-9
y: 971.0e-9
batoidModelName: LSST_{band}.yaml # name used to load the Batoid model
batoidModelName: LSST_{band} # name used to load the Batoid model

maskParams: # center and radius are in meters, theta in degrees
M1Outer:
Expand Down
53 changes: 50 additions & 3 deletions python/lsst/ts/wep/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,54 @@ def defocalOffset(self) -> float:
elif self._defocalOffsetBatoid is not None:
return self._defocalOffsetBatoid
elif self.batoidModelName is not None and self._batoidOffsetValue is not None:
raise NotImplementedError("NEED TO PUT THIS IN")
# Load the model and wavelength info
batoidModel = self.getBatoidModel()
offsetOptic = self.batoidOffsetOptic
eps = batoidModel.pupilObscuration
wavelength = self.wavelength[BandLabel.REF]

# Calculate dZ4 ratios
shift = np.array([0, 0, +1e-3])
dZ4optic = np.mean(
np.abs(
[
batoid.analysis.zernike(
batoidModel.withLocallyShiftedOptic(offsetOptic, +shift),
*np.zeros(2),
wavelength,
eps=eps,
)[4],
batoid.analysis.zernike(
batoidModel.withLocallyShiftedOptic(offsetOptic, -shift),
*np.zeros(2),
wavelength,
eps=eps,
)[4],
]
)
)
dZ4det = np.mean(
np.abs(
[
batoid.analysis.zernike(
batoidModel.withLocallyShiftedOptic("Detector", +shift),
*np.zeros(2),
wavelength,
eps=eps,
)[4],
batoid.analysis.zernike(
batoidModel.withLocallyShiftedOptic("Detector", -shift),
*np.zeros(2),
wavelength,
eps=eps,
)[4],
]
)
)

# Calculate and save value calculated from Z4 ratio
self._defocalOffsetBatoid = dZ4optic / dZ4det * self.batoidOffsetValue
return self._defocalOffsetBatoid
else:
raise ValueError(
"There is currently no defocalOffset set. "
Expand Down Expand Up @@ -444,7 +491,7 @@ def batoidModelName(self, value: Optional[str]) -> None:
"""Set the Batoid model name.
The Batoid model name is used to load the Batoid model via
batoid.Optic.fromYaml(batoidModelName)
batoid.Optic.fromYaml(batoidModelName + ".yaml")
The name must match one of the yaml files in the batoid/data directory:
https://github.com/jmeyers314/batoid/tree/main/batoid/data
Expand Down Expand Up @@ -588,7 +635,7 @@ def getBatoidModel(
batoidModelName = self.batoidModelName.format(band=band.value)

# Load the Batoid model
return batoid.Optic.fromYaml(batoidModelName)
return batoid.Optic.fromYaml(batoidModelName + ".yaml")

@lru_cache(100)
def _getIntrinsicZernikesCached(
Expand Down

0 comments on commit 4b95d48

Please sign in to comment.