Coverage for python/lsst/sims/GalSimInterface/galSimDetector.py : 83%

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
""" This class uses methods from afw.geom and meas_astrom to fit a TAN-SIP WCS to an afw.cameraGeom.Detector and then wrap that WCS into something that GalSim can parse.
For documentation on the TAN-SIP WCS see
Shupe and Hook (2008) http://fits.gsfc.nasa.gov/registry/sip/SIP_distortion_v1_0.pdf """
""" @param [in] detectorName is the name of the detector as stored by afw
@param [in] cameraWrapper is an instantionat of a GalSimCameraWrapper
@param [in] obs_metadata is an instantiation of ObservationMetaData characterizing the telescope pointing
@param [in] epoch is the epoch in Julian years of the equinox against which RA and Dec are measured
@param [in] photParams is an instantiation of PhotometricParameters (it will contain information about gain, exposure time, etc.)
@param [in] wcs is a kwarg that is used by the method _newOrigin(). The wcs kwarg in this constructor method should not be used by users. """
raise RuntimeError("You must pass GalSim_afw_TanSipWCS an instantiation " "of GalSimCameraWrapper or one of its daughter " "classes")
else:
# this is needed to match the GalSim v1.5 API
isinstance(self.obs_metadata.bandpass, np.ndarray)):
# Add pointing information to FITS header.
""" This is a method required by the GalSim WCS API
Convert pixel coordinates into ra, dec coordinates. x and y already have crpix1 and crpix2 subtracted from them. Return ra, dec in radians.
Note: the color arg is ignored. It is only there to match the GalSim v1.5 API """
obs_metadata=self.obs_metadata, epoch=self.epoch)
else: return (ra[0], dec[0])
""" This is a method required by the GalSim WCS API
Convert ra, dec in radians into x, y in pixel space with crpix subtracted. """
chipNameList = [self.detectorName]
if type(ra) is np.ndarray: chipNameList = chipNameList * len(ra)
xx, yy = self.cameraWrapper._pixelCoordsFromRaDec(ra=ra, dec=dec, chipName=chipNameList, obs_metadata=self.obs_metadata, epoch=self.epoch)
if type(ra) is np.ndarray: return (xx-self.crpix1, yy-self.crpix2) else: return (xx[0]-self.crpix1, yy-self.crpix2)
""" This is a method required by the GalSim WCS API. It returns a copy of self, but with the pixel-space origin translated to a new position.
@param [in] origin is an instantiation of a galsim.PositionD representing the a point in pixel space to which you want to move the origin of the WCS
@param [out] _newWcs is a WCS identical to self, but with the origin in pixel space moved to the specified origin """ photParams=self.photParams, wcs=self._tanSipWcs)
""" This class stores information about individual detectors for use by the GalSimInterpreter """
""" @param [in] detectorName is the name of the detector as stored by afw
@param [in] cameraWrapper is an instantionat of a GalSimCameraWrapper
@param [in] photParams is an instantiation of the PhotometricParameters class that carries details about the photometric response of the telescope.
This class will generate its own internal variable self.fileName which is the name of the detector as it will appear in the output FITS files """
raise RuntimeError("You must pass GalSimDetector an instantiation " "of GalSimCameraWrapper or one of its daughter " "classes")
raise RuntimeError("detectorName needs to be in the camera wrapped by " "cameraWrapper when instantiating a GalSimDetector\n" "%s is not in your cameraWrapper.camera" % detectorName)
raise RuntimeError("You need to specify an instantiation of PhotometricParameters " + "when constructing a GalSimDetector")
# Default Tree Ring properties, i.e., no tree rings:
# We are transposing the coordinates because of the difference # between how DM defines pixel coordinates and how the # Camera team defines pixel coordinates
""" Format the name of the detector to add to the name of the FITS file """
""" Convert RA, Dec into pixel coordinates on this detector
@param [in] ra is a numpy array or a float indicating RA in radians
@param [in] dec is a numpy array or a float indicating Dec in radians
@param [out] xPix is a numpy array indicating the x pixel coordinate
@param [out] yPix is a numpy array indicating the y pixel coordinate """
else: raLocal = np.array([ra]) decLocal = np.array([dec])
obs_metadata=self._obs_metadata, epoch=self._epoch)
""" Convert pupil coordinates into pixel coordinates on this detector
@param [in] xPupil is a numpy array or a float indicating x pupil coordinates in radians
@param [in] yPupil a numpy array or a float indicating y pupil coordinates in radians
@param [out] xPix is a numpy array indicating the x pixel coordinate
@param [out] yPix is a numpy array indicating the y pixel coordinate """
else: xp = np.array([xPupil]) yp = np.array([yPupil])
""" Does a given RA, Dec fall on this detector?
@param [in] ra is a numpy array or a float indicating RA in radians
@param [in] dec is a numpy array or a float indicating Dec in radians
@param [out] answer is an array of booleans indicating whether or not the corresponding RA, Dec pair falls on this detector """
""" Does a given set of pupil coordinates fall on this detector?
@param [in] xPupil is a numpy array or a float indicating x pupil coordinates in radians
@param [in] yPupuil is a numpy array or a float indicating y pupil coordinates in radians
@param [out] answer is an array of booleans indicating whether or not the corresponding RA, Dec pair falls on this detector """
def xMinPix(self): """Minimum x pixel coordinate of the detector"""
def xMinPix(self, value): raise RuntimeError("You should not be setting xMinPix on the fly; " "just instantiate a new GalSimDetector")
def xMaxPix(self): """Maximum x pixel coordinate of the detector"""
def xMaxPix(self, value): raise RuntimeError("You should not be setting xMaxPix on the fly; " "just instantiate a new GalSimDetector")
def yMinPix(self): """Minimum y pixel coordinate of the detector"""
def yMinPix(self, value): raise RuntimeError("You should not be setting yMinPix on the fly; " "just instantiate a new GalSimDetector")
def yMaxPix(self): """Maximum y pixel coordinate of the detector"""
def yMaxPix(self, value): raise RuntimeError("You should not be setting yMaxPix on the fly; " "just instantiate a new GalSimDetector")
def xCenterPix(self): """Center x pixel coordinate of the detector"""
def xCenterPix(self, value): raise RuntimeError("You should not be setting xCenterPix on the fly; " "just instantiate a new GalSimDetector")
def yCenterPix(self): """Center y pixel coordinate of the detector"""
def yCenterPix(self, value): raise RuntimeError("You should not be setting yCenterPix on the fly; " "just instantiate a new GalSimDetector")
def xMaxArcsec(self): """Maximum x pupil coordinate of the detector in arcseconds"""
def xMaxArcsec(self, value): raise RuntimeError("You should not be setting xMaxArcsec on the fly; " "just instantiate a new GalSimDetector")
def xMinArcsec(self): """Minimum x pupil coordinate of the detector in arcseconds"""
def xMinArcsec(self, value): raise RuntimeError("You should not be setting xMinArcsec on the fly; " "just instantiate a new GalSimDetector")
def yMaxArcsec(self): """Maximum y pupil coordinate of the detector in arcseconds"""
def yMaxArcsec(self, value): raise RuntimeError("You should not be setting yMaxArcsec on the fly; " "just instantiate a new GalSimDetector")
def yMinArcsec(self): """Minimum y pupil coordinate of the detector in arcseconds"""
def yMinArcsec(self, value): raise RuntimeError("You should not be setting yMinArcsec on the fly; " "just instantiate a new GalSimDetector")
def xCenterArcsec(self): """Center x pupil coordinate of the detector in arcseconds""" return self._xCenterArcsec
def xCenterArcsec(self, value): raise RuntimeError("You should not be setting xCenterArcsec on the fly; " "just instantiate a new GalSimDetector")
def yCenterArcsec(self): """Center y pupil coordinate of the detector in arcseconds""" return self._yCenterArcsec
def yCenterArcsec(self, value): raise RuntimeError("You should not be setting yCenterArcsec on the fly; " "just instantiate a new GalSimDetector")
def epoch(self): """Epoch of the equinox against which RA and Dec are measured in Julian years"""
def epoch(self, value): raise RuntimeError("You should not be setting epoch on the fly; " "just instantiate a new GalSimDetector")
def obs_metadata(self): """ObservationMetaData instantiation describing the telescope pointing"""
def obs_metadata(self, value): raise RuntimeError("You should not be setting obs_metadata on the fly; " "just instantiate a new GalSimDetector")
def name(self): """Name of the detector"""
def name(self, value): raise RuntimeError("You should not be setting name on the fly; " "just instantiate a new GalSimDetector")
def camera_wrapper(self):
def camera_wrapper(self, value): raise RuntimeError("You should not be setting the camera_wrapper on the fly; " "just instantiate a new GalSimDetector")
def photParams(self): """PhotometricParameters instantiation characterizing the detector"""
def photParams(self, value): raise RuntimeError("You should not be setting photParams on the fly; " "just instantiate a new GalSimDetector")
def fileName(self): """Name of the FITS file corresponding to this detector"""
def fileName(self, value): raise RuntimeError("You should not be setting fileName on the fly; " "just instantiate a new GalSimDetector")
def wcs(self): """WCS corresponding to this detector""" self.obs_metadata, self.epoch, photParams=self.photParams)
# This is an LSST camera; format the FITS header to feed through DM code
self.obs_metadata.OpsimMetaData['obshistID'])
else:
def wcs(self, value): raise RuntimeError("You should not be setting wcs on the fly; " "just instantiate a new GalSimDetector")
def tree_rings(self): return self._tree_rings
def tree_rings(self, center_func_tuple): self._tree_rings = TreeRingInfo(*center_func_tuple)
obs_metadata, epoch=2000.0): """ Create a GalSimDetector object given the desired detector name.
Parameters ---------- camera_wrapper: lsst.sims.GalSimInterface.GalSimCameraWrapper An object representing the camera being simulated
detname: str The name of the detector in the LSST focal plane to create, e.g., "R:2,2 S:1,1".
phot_params: lsst.sims.photUtils.PhotometricParameters An object containing the physical parameters representing the photometric properties of the system
obs_metadata: lsst.sims.utils.ObservationMetaData Characterizing the pointing of the telescope
epoch: float Representing the Julian epoch against which RA, Dec are reckoned (default = 2000)
Returns ------- GalSimDetector """
centerPixel.getY()+1, detname, obs_metadata)
np.power(translationPupil[1]-centerPupil.getY(), 2))/np.sqrt(2.0)
# make a detector-custom photParams that copies all of the quantities # in the catalog photParams, except the platescale, which is # calculated above nexp=phot_params.nexp, effarea=phot_params.effarea, gain=phot_params.gain, readnoise=phot_params.readnoise, darkcurrent=phot_params.darkcurrent, othernoise=phot_params.othernoise, platescale=plateScale)
obs_metadata=obs_metadata, epoch=epoch, photParams=params) |