Coverage for python/lsst/sims/coordUtils/LsstZernikeFitter.py : 88%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Convert Observed RA, Dec into pupil coordinates
Parameters ---------- ra_obs is the observed RA in radians
dec_obs is the observed Dec in radians
ra0 is the RA of the boresite in radians
dec0 is the Dec of the boresite in radians
rotSkyPos is in radians
Returns -------- A numpy array whose first row is the x coordinate on the pupil in radians and whose second row is the y coordinate in radians """
"pupilCoordsFromObserved")
# palpy.ds2tp performs the gnomonic projection on ra_in and dec_in # with a tangent point at (pointingRA, pointingDec) # try: x, y = palpy.ds2tp(ra_obs, dec_obs, ra_pointing, dec_pointing) except: x = np.NaN y = np.NaN else: except: # apparently, one of your ra/dec values was improper; we will have to do this # element-wise, putting NaN in the place of the bad values x = [] y = [] for rr, dd in zip(ra_obs, dec_obs): try: xx, yy = palpy.ds2tp(rr, dd, ra_pointing, dec_pointing) except: xx = np.NaN yy = np.NaN x.append(xx) y.append(yy) x = np.array(x) y = np.array(y)
# rotate the result by rotskypos (rotskypos being "the angle of the sky relative to # camera coordinates" according to phoSim documentation) to account for # the rotation of the focal plane about the telescope pointing
""" This class will fit and then apply the Zernike polynomials needed to correct the FIELD_ANGLE to FOCAL_PLANE transformation for the filter-dependent part. """
# make it a little bigger to accommodate any slop in # the conversion from focal plane coordinates back to # pupil coordinates (in case the optical distortions # cause points to cross over the actual boundary of # the focal plane)
# 2018 May 8 # During development, I found that there was negligible # improvement in the fit when allowing n>4, so I am # hard-coding the limit of n=4 here.
""" Get the coefficients of the best fit Zernike Polynomial expansion that transforms from x_in, y_in to x_out, y_out.
Returns numpy arrays of the Zernike Polynomial expansion coefficients in x and y. Zernike Polynomials correspond to the radial and angular orders stored in self._n_grid and self._m_grid. """
for k2 in poly_keys])
for k2 in poly_keys])
""" Solve for and store the coefficients of the Zernike polynomial expansion of the difference between the naive and the bandpass-dependent optical distortions in the LSST camera. """ 'FocalPlaneData', 'CatSimData')
'FocalPlaneData', 'PhoSimData')
# the file which contains the input sky positions of the objects # that were given to PhoSim
('xpup', float), ('ypup', float), ('raObs', float), ('decObs', float)])
# convert from RA, Dec to pupil coors/FIELD_ANGLE np.radians(catsim_data['decObs']), ra0, dec0, rotSkyPos)
# convert from FIELD_ANGLE to FOCAL_PLANE without attempting to model # the optical distortions in the telescope
('xpix', float), ('ypix', float)])
# read in the actual pixel positions of the sources as realized # by PhoSim
# make sure that the data we are fitting to is not too close # to the edge of the detector
phosim_data['ypix'], det_name)
# solve for the coefficients of the Zernike expansions # necessary to model the optical transformations and go # from the naive focal plane positions (catsim_xmm, catsim_ymm) # to the PhoSim realized focal plane positions phosim_xmm, phosim_ymm)
# solve for the coefficients to the Zernike expansions # necessary to go back from the PhoSim realized focal plane # positions to the naive CatSim predicted focal plane # positions catsim_xmm, catsim_ymm)
""" Parameters ---------- tranformation_dict -- a dict containing the coefficients of the Zernike decomposition to be applied
xmm -- the input x position in mm
ymm -- the input y position in mm
band -- the filter in which we are operating (can be either a string or an int; 0=u, 1=g, 2=r, etc.)
Returns ------- dx -- the x offset resulting from the transformation
dy -- the y offset resulting from the transformation """ band = self._int_to_band[band]
else:
""" Apply the transformation necessary when going from pupil coordinates to focal plane coordinates.
The recipe to correctly use this method is
xf0, yf0 = focalPlaneCoordsFromPupilCoords(xpupil, ypupil, camera=lsst_camera())
dx, dy = LsstZernikeFitter().dxdy(xf0, yf0, band=band)
xf = xf0 + dx yf = yf0 + dy
xf and yf are now the actual position in millimeters on the LSST focal plane corresponding to xpupil, ypupil
Parameters ---------- xmm -- the naive x focal plane position in mm
ymm -- the naive y focal plane position in mm
band -- the filter in which we are operating (can be either a string or an int; 0=u, 1=g, 2=r, etc.)
Returns ------- dx -- the offset in the x focal plane position in mm
dy -- the offset in the y focal plane position in mm """
""" Apply the transformation necessary when going from focal plane coordinates to pupil coordinates.
The recipe to correctly use this method is
dx, dy = LsstZernikeFitter().dxdy_inverse(xf, yf, band=band)
xp, yp = pupilCoordsFromFocalPlaneCoords(xf+dx, yf+dy, camera=lsst_camera())
xp and yp are now the actual position in radians on the pupil corresponding to the focal plane coordinates xf, yf
Parameters ---------- xmm -- the naive x focal plane position in mm
ymm -- the naive y focal plane position in mm
band -- the filter in which we are operating (can be either a string or an int; 0=u, 1=g, 2=r, etc.)
Returns ------- dx -- the offset in the x focal plane position in mm
dy -- the offset in the y focal plane position in mm """ |