LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker Class Reference

Public Member Functions

def __init__ (self, inputSkyWcs)
 
def makeWcs (self, crvalOffset, affMatrix)
 

Public Attributes

 frameDict
 
 frameIdxs
 
 frameMin
 
 frameMax
 
 mapFrom
 
 mapTo
 
 lastMapBeforeSky
 
 origin
 

Detailed Description

Convenience class for appending a shifting an input SkyWcs on sky and
appending an affine transform.

The class assumes that all frames are sequential and are mapped one to the
next.

Parameters
----------
input_sky_wcs : `lsst.afw.geom.SkyWcs`
    WCS to decompose and append affine matrix and shift in on sky
    location to.

Definition at line 247 of file fitAffineWcs.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.__init__ (   self,
  inputSkyWcs 
)

Definition at line 261 of file fitAffineWcs.py.

261  def __init__(self, inputSkyWcs):
262  self.frameDict = inputSkyWcs.getFrameDict()
263 
264  # Grab the order of the frames by index.
265  # TODO: DM-20825
266  # Change the frame the transform is appended to to be explicitly
267  # the FIELD_ANGLE->IWC transform. Requires related tickets to be
268  # completed.
269  domains = self.frameDict.getAllDomains()
270  self.frameIdxs = np.sort([self.frameDict.getIndex(domain)
271  for domain in domains])
272  self.frameMin = np.min(self.frameIdxs)
273  self.frameMax = np.max(self.frameIdxs)
274 
275  # Find frame just before the final mapping to sky and store those
276  # indices and mappings for later.
277  self.mapFrom = self.frameMax - 2
278  if self.mapFrom < self.frameMin:
279  self.mapFrom = self.frameMin
280  self.mapTo = self.frameMax - 1
281  if self.mapTo <= self.mapFrom:
282  self.mapTo = self.frameMax
283  self.lastMapBeforeSky = self.frameDict.getMapping(
284  self.mapFrom, self.mapTo)
285 
286  # Get the original WCS sky location.
287 
288  self.origin = inputSkyWcs.getSkyOrigin()
289 

Member Function Documentation

◆ makeWcs()

def lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.makeWcs (   self,
  crvalOffset,
  affMatrix 
)
Apply a shift and affine transform to the WCS internal to this
class.

A new SkyWcs with these transforms applied is returns.

Parameters
----------
crval_shift : `numpy.ndarray`, (2,)
    Shift in radians to apply to the Wcs origin/crvals.
aff_matrix : 'numpy.ndarray', (3, 3)
    Affine matrix to apply to the mapping/transform to add to the
    WCS.

Returns
-------
outputWcs : `lsst.afw.geom.SkyWcs`
    Wcs with a final shift and affine transform applied.

Definition at line 290 of file fitAffineWcs.py.

290  def makeWcs(self, crvalOffset, affMatrix):
291  """Apply a shift and affine transform to the WCS internal to this
292  class.
293 
294  A new SkyWcs with these transforms applied is returns.
295 
296  Parameters
297  ----------
298  crval_shift : `numpy.ndarray`, (2,)
299  Shift in radians to apply to the Wcs origin/crvals.
300  aff_matrix : 'numpy.ndarray', (3, 3)
301  Affine matrix to apply to the mapping/transform to add to the
302  WCS.
303 
304  Returns
305  -------
306  outputWcs : `lsst.afw.geom.SkyWcs`
307  Wcs with a final shift and affine transform applied.
308  """
309  # Create a WCS that only maps from IWC to Sky with the shifted
310  # Sky origin position. This is simply the final undistorted tangent
311  # plane to sky. The PIXELS to SKY map will be become our IWC to SKY
312  # map and gives us our final shift position.
313  iwcsToSkyWcs = makeSkyWcs(
314  Point2D(0., 0.),
315  self.origin.offset(crvalOffset[0] * degrees,
316  crvalOffset[1] * arcseconds),
317  np.array([[1., 0.], [0., 1.]]))
318  iwcToSkyMap = iwcsToSkyWcs.getFrameDict().getMapping("PIXELS", "SKY")
319 
320  # Append a simple affine Matrix transform to the current to the
321  # second to last frame mapping. e.g. the one just before IWC to SKY.
322  newMapping = self.lastMapBeforeSky.then(astshim.MatrixMap(affMatrix))
323 
324  # Create a new frame dict starting from the input_sky_wcs's first
325  # frame. Append the correct mapping created above and our new on
326  # sky location.
327  outputFrameDict = astshim.FrameDict(
328  self.frameDict.getFrame(self.frameMin))
329  for frameIdx in self.frameIdxs:
330  if frameIdx == self.mapFrom:
331  outputFrameDict.addFrame(
332  self.mapFrom,
333  newMapping,
334  self.frameDict.getFrame(self.mapTo))
335  elif frameIdx >= self.mapTo:
336  continue
337  else:
338  outputFrameDict.addFrame(
339  frameIdx,
340  self.frameDict.getMapping(frameIdx, frameIdx + 1),
341  self.frameDict.getFrame(frameIdx + 1))
342  # Append the final sky frame to the frame dict.
343  outputFrameDict.addFrame(
344  self.frameMax - 1,
345  iwcToSkyMap,
346  iwcsToSkyWcs.getFrameDict().getFrame("SKY"))
347 
348  return SkyWcs(outputFrameDict)
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition: SkyWcs.cc:521
Point< double, 2 > Point2D
Definition: Point.h:324
std::shared_ptr< afw::geom::SkyWcs > makeWcs(SipForwardTransform const &sipForward, SipReverseTransform const &sipReverse, geom::SpherePoint const &skyOrigin)
Create a new TAN SIP Wcs from a pair of SIP transforms and the sky origin.

Member Data Documentation

◆ frameDict

lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.frameDict

Definition at line 262 of file fitAffineWcs.py.

◆ frameIdxs

lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.frameIdxs

Definition at line 270 of file fitAffineWcs.py.

◆ frameMax

lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.frameMax

Definition at line 273 of file fitAffineWcs.py.

◆ frameMin

lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.frameMin

Definition at line 272 of file fitAffineWcs.py.

◆ lastMapBeforeSky

lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.lastMapBeforeSky

Definition at line 283 of file fitAffineWcs.py.

◆ mapFrom

lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.mapFrom

Definition at line 277 of file fitAffineWcs.py.

◆ mapTo

lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.mapTo

Definition at line 280 of file fitAffineWcs.py.

◆ origin

lsst.meas.astrom.fitAffineWcs.TransformedSkyWcsMaker.origin

Definition at line 288 of file fitAffineWcs.py.


The documentation for this class was generated from the following file: