21"""A class to project the focal plane in arbitrary rotations for fgcm.
23This file contains a class used by fgcm ...
25from functools
import lru_cache
32from lsst.obs.base
import createInitialSkyWcs
34__all__ = [
'FocalPlaneProjector']
39 Class to project the focal plane onto the sky.
44 Camera from the butler.
45 defaultOrientation : `int`
46 Default camera orientation
in degrees. This angle
is the position
47 angle of the focal plane +Y
with respect to north.
49 def __init__(self, camera, defaultOrientation):
57 def _makeWcsDict(self, orientation):
59 Make a dictionary of WCSs at the reference boresight position.
64 Orientation in degrees. This angle
is the position
65 angle of the focal plane +Y
with respect to north.
70 Dictionary of WCS,
with the detector id
as the key.
72 _orientation = orientation*geom.degrees
75 boresightRotAngle=_orientation,
76 rotType=afwImage.RotType.SKY)
80 for detector
in self.
camera:
81 detectorId = detector.getId()
82 wcsDict[detectorId] = createInitialSkyWcs(visitInfo, detector, self.
flipX)
86 def __call__(self, orientation, nstep=100, use_cache=True):
88 Make a focal plane projection mapping for use
with fgcm.
92 orientation : `float`
or `int`
93 Camera orientation
in degrees. This angle
is the position
94 angle of the focal plane +Y
with respect to north.
96 Number of steps
in x/y per detector
for the mapping.
97 use_cache : `bool`, optional
98 Use integerized cached lookup.
102 projectionMapping : `np.ndarray`
103 A projection mapping object
with x, y, x_size, y_size,
104 delta_ra_cent, delta_dec_cent, delta_ra, delta_dec
for
107 if not np.isfinite(orientation):
108 warnings.warn(
'Encountered non-finite orientation; using default.')
111 _orientation = orientation % 360
114 _orientation = int(_orientation)
120 @lru_cache(maxsize=360)
121 def _compute_cached_projection(self, orientation, nstep=50):
123 Compute the focal plane projection, with caching.
128 Camera orientation
in degrees. This angle
is the position
129 angle of the focal plane +Y
with respect to north.
131 Number of steps
in x/y per detector
for the mapping.
135 projectionMapping : `np.ndarray`
136 A projection mapping object
with x, y, x_size, y_size,
137 delta_ra_cent, delta_dec_cent, delta_ra, delta_dec
for
142 def _compute_projection(self, orientation, nstep=50):
144 Compute the focal plane projection.
148 orientation : `float` or `int`
149 Camera orientation
in degrees. This angle
is the position
150 angle of the focal plane +Y
with respect to north.
152 Number of steps
in x/y per detector
for the mapping.
156 projectionMapping : `np.ndarray`
157 A projection mapping object
with x, y, x_size, y_size,
158 delta_ra_cent, delta_dec_cent, delta_ra, delta_dec
for
164 deltaMapper = np.zeros(len(self.
camera), dtype=[(
'id',
'i4'),
165 (
'x',
'f8', nstep**2),
166 (
'y',
'f8', nstep**2),
169 (
'delta_ra_cent',
'f8'),
170 (
'delta_dec_cent',
'f8'),
171 (
'delta_ra',
'f8', nstep**2),
172 (
'delta_dec',
'f8', nstep**2)])
174 for detector
in self.
camera:
175 detectorId = detector.getId()
177 deltaMapper[
'id'][detectorId] = detectorId
179 xSize = detector.getBBox().getMaxX()
180 ySize = detector.getBBox().getMaxY()
182 xValues = np.linspace(0.0, xSize, nstep)
183 yValues = np.linspace(0.0, ySize, nstep)
185 deltaMapper[
'x'][detectorId, :] = np.repeat(xValues, yValues.size)
186 deltaMapper[
'y'][detectorId, :] = np.tile(yValues, xValues.size)
187 deltaMapper[
'x_size'][detectorId] = xSize
188 deltaMapper[
'y_size'][detectorId] = ySize
190 radec = wcsDict[detector.getId()].pixelToSkyArray(deltaMapper[
'x'][detectorId, :],
191 deltaMapper[
'y'][detectorId, :],
194 deltaMapper[
'delta_ra'][detectorId, :] = radec[0] - self.
boresight.getRa().asDegrees()
195 deltaMapper[
'delta_dec'][detectorId, :] = radec[1] - self.
boresight.getDec().asDegrees()
197 detCenter = wcsDict[detector.getId()].pixelToSky(detector.getCenter(afwCameraGeom.PIXELS))
198 deltaMapper[
'delta_ra_cent'][detectorId] = (detCenter.getRa()
200 deltaMapper[
'delta_dec_cent'][detectorId] = (detCenter.getDec()
An immutable representation of a camera.
Information about a single exposure of an imaging camera.
def _compute_projection(self, orientation, nstep=50)
def __call__(self, orientation, nstep=100, use_cache=True)
def __init__(self, camera, defaultOrientation)
def _compute_cached_projection(self, orientation, nstep=50)
def _makeWcsDict(self, orientation)
Point in an unspecified spherical coordinate system.