Skip to content

Commit

Permalink
Started tests for new stuff. Added plotting utils for pupil masks and…
Browse files Browse the repository at this point in the history
… ImageMapper round trip.
  • Loading branch information
jfcrenshaw committed Dec 14, 2023
1 parent 3b0feb4 commit 096d2a7
Show file tree
Hide file tree
Showing 31 changed files with 1,227 additions and 5,113 deletions.
1 change: 0 additions & 1 deletion policy/estimation/tie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ compSequence: [4, 4, 6, 6, 13, 13, 13, 13, 22, 22, 22, 22, 22, 22]
compGain: 0.6
centerTol: 10.0e-9
centerBinary: True
centerSubPixel: False
convergeTol: 10.0e-9
saveHistory: False
72 changes: 36 additions & 36 deletions policy/instruments/LsstCam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ obscuration: 0.612 # fractional obscuration
focalLength: 10.312 # effective focal length in meters
defocalOffset: 1.5e-3 # defocal offset in meters
pixelSize: 10.0e-6 # pixel size in meters
refBand: r # band to use for BandLabel.REF
wavelength: # effective wavelength per band, in meters
u: 367.1e-9
g: 482.7e-9
Expand All @@ -15,62 +16,61 @@ wavelength: # effective wavelength per band, in meters
z: 869.1e-9
y: 971.0e-9
batoidModelName: LSST_{band}.yaml # name used to load the Batoid model
batoidRefBand: r # band to use with Batoid when band == BandLabel.REF

maskParams: # center and radius are in meters, theta in degrees
M1Outer:
thetaMin: 0.00
center: [-7.890e-17, 2.013e-16, 1.768e-10, 2.978e-17]
radius: [-1.098e-16, -2.652e-15, 5.961e-15, 4.180e+00]
thetaMin: 0.0
center: [-7.88971e-17, 2.01334e-16, 1.76752e-10, 2.97835e-17]
radius: [-1.09847e-16, -2.65166e-15, 5.96051e-15, 4.18000e+00]
M1Inner:
thetaMin: 0.00
center: [-1.834e-17, 1.314e-16, -4.792e-03, 8.014e-17]
radius: [-1.181e-15, 2.582e-15, -1.030e-15, 2.558e+00]
thetaMin: 0.0
center: [-1.83436e-17, 1.31384e-16, -4.79254e-03, 8.01445e-17]
radius: [-1.18085e-15, 2.58188e-15, -1.02954e-15, 2.55800e+00]
M2Outer:
thetaMin: 0.67
center: [-2.971e-05, 1.195e-03, -2.902e-01, -2.017e-04]
radius: [-1.274e-04, 8.016e-04, -1.107e-03, 4.497e+00]
center: [-2.97063e-05, 1.19495e-03, -2.90176e-01, -2.01690e-04]
radius: [-1.27356e-04, 8.01567e-04, -1.10665e-03, 4.49700e+00]
M2Inner:
thetaMin: 0.00
center: [-1.623e-04, -8.488e-04, -2.909e-01, -2.258e-06]
radius: [2.317e-05, 2.541e-04, 1.269e-04, 2.371e+00]
thetaMin: 0.0
center: [-1.62275e-04, -8.48813e-04, -2.90949e-01, -2.25777e-06]
radius: [2.31676e-05, 2.54062e-04, 1.26852e-04, 2.37089e+00]
M3Outer:
thetaMin: 1.14
center: [-1.030e-03, -6.107e-03, -7.955e-01, 2.908e-05]
radius: [1.351e-04, -5.517e-04, 3.607e-03, 5.216e+00]
center: [-1.03001e-03, -6.10645e-03, -7.95453e-01, 2.90781e-05]
radius: [1.35117e-04, -5.51696e-04, 3.60650e-03, 5.21560e+00]
M3Inner:
thetaMin: 1.15
center: [-1.798e-03, 3.392e-03, -9.378e-01, 1.100e-03]
radius: [-6.097e-04, 5.360e-04, 1.755e-04, 1.222e+00]
center: [-1.79773e-03, 3.39167e-03, -9.37836e-01, 1.10023e-03]
radius: [-6.09716e-04, 5.36056e-04, 1.75529e-04, 1.22190e+00]
L1Entrance:
thetaMin: 1.48
center: [-7.045e-02, 8.504e-02, -1.800e+00, 1.875e-01]
radius: [6.528e-02, -2.652e-01, 4.832e-01, 6.473e+00]
center: [-7.04511e-02, 8.50359e-02, -1.80035e+00, 1.87490e-01]
radius: [6.52778e-02, -2.65192e-01, 4.83170e-01, 6.47299e+00]
L1Exit:
thetaMin: 1.54
center: [-1.096e-01, 2.800e-01, -2.139e+00, 3.921e-01]
radius: [1.021e-01, -4.587e-01, 8.313e-01, 6.387e+00]
center: [-1.09578e-01, 2.80004e-01, -2.13912e+00, 3.92063e-01]
radius: [1.02073e-01, -4.58671e-01, 8.31328e-01, 6.38674e+00]
L2Entrance:
thetaMin: 1.59
center: [-2.447e-01, 1.346e-01, -2.243e+00, -4.267e-02]
radius: [2.696e-01, -8.131e-01, 1.018e+00, 7.909e+00]
center: [-2.44731e-01, 1.34591e-01, -2.24336e+00, -4.26719e-02]
radius: [2.69553e-01, -8.13070e-01, 1.01816e+00, 7.90902e+00]
L2Exit:
thetaMin: 1.77
center: [-3.232e-02, -1.602e+00, 1.699e+00, -2.806e+00]
radius: [8.600e-03, 1.014e+00, -2.945e+00, 1.130e+01]
L3Entrance:
thetaMin: 1.81
center: [-6.929e+03, 3.837e+04, -7.093e+04, 4.373e+04]
radius: [6.991e+03, -3.876e+04, 7.169e+04, -4.421e+04]
L3Exit:
thetaMin: 1.88
center: [-7.625e+04, 4.382e+05, -8.394e+05, 5.361e+05]
radius: [7.651e+04, -4.398e+05, 8.428e+05, -5.383e+05]
center: [-3.23226e-02, -1.60235e+00, 1.69902e+00, -2.80647e+00]
radius: [8.59956e-03, 1.01450e+00, -2.94477e+00, 1.12953e+01]
filterEntrance:
thetaMin: 1.68
center: [-1.412e+02, 7.083e+02, -1.209e+03, 6.906e+02]
radius: [1.468e+02, -7.457e+02, 1.276e+03, -7.200e+02]
center: [-1.41191e+02, 7.08362e+02, -1.20873e+03, 6.90596e+02]
radius: [1.46814e+02, -7.45712e+02, 1.27571e+03, -7.19975e+02]
filterExit:
thetaMin: 1.72
center: [-2.332e+02, 1.201e+03, -2.090e+03, 1.218e+03]
radius: [2.407e+02, -1.251e+03, 2.184e+03, -1.265e+03]
center: [-2.33154e+02, 1.20100e+03, -2.09045e+03, 1.21830e+03]
radius: [2.40674e+02, -1.25103e+03, 2.18395e+03, -1.26502e+03]
L3Entrance:
thetaMin: 1.81
center: [-6.92919e+03, 3.83751e+04, -7.09271e+04, 4.37325e+04]
radius: [6.99082e+03, -3.87585e+04, 7.16872e+04, -4.42130e+04]
L3Exit:
thetaMin: 1.88
center: [-7.62502e+04, 4.38171e+05, -8.39431e+05, 5.36106e+05]
radius: [7.65102e+04, -4.39797e+05, 8.42756e+05, -5.38333e+05]
34 changes: 0 additions & 34 deletions python/lsst/ts/wep/estimation/tie.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ class TIEAlgorithm(WfAlgorithm):
centerBinary : bool, optional
Whether to use a binary template when centering the image.
Using a binary template is typically less accurate, but faster.
centerSubPixel : bool, optional
Whether to center the images with sub-pixel resolution.
In good conditions (i.e. low noise and good seeing), using a binary
template is typically less accurate, but faster.
convergeTol : float, optional
The maximum absolute change in any Zernike amplitude (in meters) between
subsequent TIE iterations below which convergence is declared and iteration
Expand All @@ -94,7 +90,6 @@ def __init__(
compGain: Optional[float] = None,
centerTol: Optional[float] = None,
centerBinary: Optional[bool] = None,
centerSubPixel: Optional[bool] = None,
convergeTol: Optional[float] = None,
saveHistory: Optional[bool] = None,
) -> None:
Expand All @@ -107,7 +102,6 @@ def __init__(
compGain=compGain,
centerTol=centerTol,
centerBinary=centerBinary,
centerSubPixel=centerSubPixel,
convergeTol=convergeTol,
saveHistory=saveHistory,
)
Expand Down Expand Up @@ -306,32 +300,6 @@ def centerBinary(self, value: bool) -> None:

self._centerBinary = value

@property
def centerSubPixel(self) -> bool:
"""Whether to center the donut with sub-pixel resolution."""
return self._centerSubPixel

@centerSubPixel.setter
def centerSubPixel(self, value: bool) -> None:
"""Set whether to center the donut with sub-pixel resolution.
Parameters
----------
value : bool
Whether to center the images with sub-pixel resolution.
In good conditions (i.e. low noise and good seeing), using a binary
template is typically less accurate, but faster.
Raises
------
TypeError
If the value is not a boolean
"""
if not isinstance(value, bool):
raise TypeError("centerSubPixel must be a boolean.")

self._centerSubPixel = value

@property
def convergeTol(self) -> float:
"""Mean abs. deviation in Zernikes (meters) at which the TIE loop terminates."""
Expand Down Expand Up @@ -585,13 +553,11 @@ def estimateWf(
intra,
zkCenter,
binary=self.centerBinary,
subPixel=self.centerSubPixel,
)
extraCent = imageMapper.centerOnProjection(
extra,
zkCenter,
binary=self.centerBinary,
subPixel=self.centerSubPixel,
)

# Compensate images using the Zernikes
Expand Down
10 changes: 6 additions & 4 deletions python/lsst/ts/wep/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class Image(object):
defocalType : DefocalType or str
Whether the image is intra- or extra-focal.
Can be specified using a DefocalType Enum or the corresponding string.
bandLabel : BandLabel or str
bandLabel : BandLabel or str, optional
Photometric band for the exposure.
Can be specified using a BandLabel Enum or the corresponding string.
(the default is BandLabel.REF)
planeType : PlaneType or str, optional
Whether the image is on the image plane or the pupil plane.
Can be specified using a PlaneType Enum, or the corresponding string.
Expand All @@ -64,7 +65,7 @@ def __init__(
image: np.ndarray,
fieldAngle: Union[np.ndarray, tuple, list],
defocalType: Union[DefocalType, str],
bandLabel: Union[BandLabel, str],
bandLabel: Union[BandLabel, str] = BandLabel.REF,
planeType: Union[PlaneType, str] = PlaneType.Image,
blendOffsets: Union[np.ndarray, tuple, list] = np.zeros((2, 0)),
mask: Optional[np.ndarray] = None,
Expand Down Expand Up @@ -250,11 +251,12 @@ def mask(self) -> Union[np.ndarray, None]:
def mask(self, value: Optional[np.ndarray]) -> None:
"""Set the image mask.
Note that mask creation is meant to be handled by the ImageMapper class.
Parameters
----------
mask : np.ndarray
The mask for the image. Mask creation is meant to be handled by the
ImageMapper class.
The mask for the image.
Raises
------
Expand Down
18 changes: 5 additions & 13 deletions python/lsst/ts/wep/imageMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@
import numpy as np
from lsst.ts.wep.image import Image
from lsst.ts.wep.instrument import Instrument
from lsst.ts.wep.utils import (
DefocalType,
PlaneType,
centerWithTemplate,
configClass,
mergeConfigWithFile,
polygonContains,
zernikeGradEval,
)
from lsst.ts.wep.utils.enumUtils import DefocalType, PlaneType
from lsst.ts.wep.utils.ioUtils import configClass, mergeConfigWithFile
from lsst.ts.wep.utils.miscUtils import centerWithTemplate, polygonContains
from lsst.ts.wep.utils.zernikeUtils import zernikeGradEval
from scipy.interpolate import interpn


Expand Down Expand Up @@ -858,7 +853,6 @@ def centerOnProjection(
image: Image,
zkCoeff: np.ndarray = np.zeros(1),
binary: bool = True,
subPixel: bool = True,
rMax: float = 10,
) -> Image:
"""Center the stamp on a projection of the pupil.
Expand All @@ -875,8 +869,6 @@ def centerOnProjection(
otherwise a forward model of the image is used. The latter will
likely result in a more accurate center, but takes longer to
calculate. (the default is True)
subPixel : bool, optional
Whether to center with sub-pixel resolution. (the default is True)
rMax : float, optional
The maximum pixel distance the image can be shifted.
(the default is 10)
Expand All @@ -891,7 +883,7 @@ def centerOnProjection(
template = self.mapPupilToImage(stamp, zkCoeff).image

# Center the image
stamp.image = centerWithTemplate(stamp.image, template, subPixel, rMax)
stamp.image = centerWithTemplate(stamp.image, template, rMax)

return stamp

Expand Down
Loading

0 comments on commit 096d2a7

Please sign in to comment.