Coverage for python/lsst/sims/GalSimInterface/galSimCameraWrapper.py : 92%

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 module provides wrappers for afwCameraGeom camera objects. This is necessary because of a 90-degree rotation between how the LSST Data Management software team defines coordinate axes on the focal plane and how the LSST Camera team defines coorindate axes on the focal plane. Specifically
Camera +y = DM +x Camera +x = DM -y
Because we want ImSim images to have the same WCS conventions as PhoSim e-images, we need to apply this rotation to the mappings between RA, Dec and pixel coordinates. We may not wish to do that for arbitrary cameras, so we will give users the ability to apply a no-op wrapper to their cameras.
The class LSSTCameraWrapper applies this transformation. In cases where users do not wish to apply any transformation to their pixel coordinate system, the class GalSimCameraWrapper provides the same API as LSSTCamerWrapper, but treats the software-based pixel coordinates as truth.
In order to implement your own camera wrapper, create a python class that inherits from GalSimCameraWrapper. This class will need:
- a property self.camera that is an afwCamerGeom camera object
- a method getBBox() that returns the bounding box in pixel space of a detector, given that detector's name
- a method getCenterPixel() that returns the central pixel of a detector, given that detector's name
- a method getCenterPupil() that returns the pupil coordinates (or field angle) in radians of the center of a detector given that detector's name
- a method getCornerPupilList that returns the pupil coordinates (or field angles) in radians of the corners of a detector given that detector's name
- a method getTanPixelBounds() that returns the minimum and maximum x and y pixel values of a detector, ignoring radial distortions, given that detector's name
- wrappers to the corresponding methods in lsst.sims.coordUtils that use the self.camera property and apply the necessary transformations to pixel space coordinates: pixelCoordsFromPupilCoords() pupilCoordsFromPixelCoords() pixelCoordsFromRaDec() _pixelCoordsFromRaDec() raDecFromPixelCoords() _raDecFromPixelCoords() """
""" This is a no-op camera wrapper. """
""" Parameters ---------- camera is an instantiation of an afwCameraGeom camera """
def camera(self):
def focal_to_field(self): """ Transformation to go from FOCAL_PLANE to FIELD_ANGLE """
""" Return the bounding box for the detector named by detector_name """
""" Return the central pixel for the detector named by detector_name """
""" Return the pupil coordinates of the center of the named detector as an afwGeom.Point2D """
""" Return a list of the pupil coordinates of the corners of the named detector as a list of afwGeom.Point2D objects """
""" Return the min and max pixel values of a detector, assuming all radial distortions are set to zero (i.e. using the afwCameraGeom TAN_PIXELS coordinate system)
Parameters ---------- detector_name is a string denoting the name of the detector
Returns ------- xmin, xmax, ymin, ymax pixel values """
includeDistortion=True): """ Get the pixel positions (or nan if not on a chip) for objects based on their pupil coordinates.
Parameters --------- xPupil is the x pupil coordinates in radians. Can be either a float or a numpy array.
yPupil is the y pupil coordinates in radians. Can be either a float or a numpy array.
chipName designates the names of the chips on which the pixel coordinates will be reckoned. Can be either single value, an array, or None. If an array, there must be as many chipNames as there are (RA, Dec) pairs. If a single value, all of the pixel coordinates will be reckoned on the same chip. If None, this method will calculate which chip each(RA, Dec) pair actually falls on, and return pixel coordinates for each (RA, Dec) pair on the appropriate chip.
obs_metadata is an ObservationMetaData characterizing the telescope pointing.
includeDistortion is a boolean. If True (default), then this method will return the true pixel coordinates with optical distortion included. If False, this method will return TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the x pixel coordinate and the second row is the y pixel coordinate """ raise RuntimeError("Must pass obs_metdata to " "cameraWrapper.pixelCoordsFromPupilCoords")
camera=self._camera, includeDistortion=includeDistortion)
includeDistortion=True):
""" Convert pixel coordinates into pupil coordinates
Parameters ---------- xPix is the x pixel coordinate of the point. Can be either a float or a numpy array.
yPix is the y pixel coordinate of the point. Can be either a float or a numpy array.
chipName is the name of the chip(s) on which the pixel coordinates are defined. This can be a list (in which case there should be one chip name for each (xPix, yPix) coordinate pair), or a single value (in which case, all of the (xPix, yPix) points will be reckoned on that chip).
obs_metadata is an ObservationMetaData characterizing the telescope pointing.
includeDistortion is a boolean. If True (default), then this method will expect the true pixel coordinates with optical distortion included. If False, this method will expect TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the x pupil coordinate and the second row is the y pupil coordinate (both in radians) """
camera=self._camera, includeDistortion=includeDistortion)
epoch=2000.0, includeDistortion=True): """ Convert pixel coordinates into RA, Dec
Parameters ---------- xPix is the x pixel coordinate. It can be either a float or a numpy array.
yPix is the y pixel coordinate. It can be either a float or a numpy array.
chipName is the name of the chip(s) on which the pixel coordinates are defined. This can be a list (in which case there should be one chip name for each (xPix, yPix) coordinate pair), or a single value (in which case, all of the (xPix, yPix) points will be reckoned on that chip).
obs_metadata is an ObservationMetaData defining the pointing
epoch is the mean epoch in years of the celestial coordinate system. Default is 2000.
includeDistortion is a boolean. If True (default), then this method will expect the true pixel coordinates with optical distortion included. If False, this method will expect TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the RA coordinate and the second row is the Dec coordinate (both in radians; in the International Celestial Reference System)
WARNING: This method does not account for apparent motion due to parallax. This method is only useful for mapping positions on a theoretical focal plane to positions on the celestial sphere. """
camera=self._camera, obs_metadata=obs_metadata, epoch=epoch, includeDistortion=includeDistortion)
epoch=2000.0, includeDistortion=True):
""" Convert pixel coordinates into RA, Dec
Parameters ---------- xPix is the x pixel coordinate. It can be either a float or a numpy array.
yPix is the y pixel coordinate. It can be either a float or a numpy array.
chipName is the name of the chip(s) on which the pixel coordinates are defined. This can be a list (in which case there should be one chip name for each (xPix, yPix) coordinate pair), or a single value (in which case, all of the (xPix, yPix) points will be reckoned on that chip).
obs_metadata is an ObservationMetaData defining the pointing
epoch is the mean epoch in years of the celestial coordinate system. Default is 2000.
includeDistortion is a boolean. If True (default), then this method will expect the true pixel coordinates with optical distortion included. If False, this method will expect TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the RA coordinate and the second row is the Dec coordinate (both in degrees; in the International Celestial Reference System)
WARNING: This method does not account for apparent motion due to parallax. This method is only useful for mapping positions on a theoretical focal plane to positions on the celestial sphere. """
camera=self._camera, obs_metadata=obs_metadata, epoch=2000.0, includeDistortion=True)
parallax=None, v_rad=None, obs_metadata=None, chipName=None, epoch=2000.0, includeDistortion=True): """ Get the pixel positions (or nan if not on a chip) for objects based on their RA, and Dec (in radians)
Parameters ---------- ra is in radians in the International Celestial Reference System. Can be either a float or a numpy array.
dec is in radians in the International Celestial Reference System. Can be either a float or a numpy array.
pm_ra is proper motion in RA multiplied by cos(Dec) (radians/yr) Can be a numpy array or a number or None (default=None).
pm_dec is proper motion in dec (radians/yr) Can be a numpy array or a number or None (default=None).
parallax is parallax in radians Can be a numpy array or a number or None (default=None).
v_rad is radial velocity (km/s) Can be a numpy array or a number or None (default=None).
obs_metadata is an ObservationMetaData characterizing the telescope pointing.
epoch is the epoch in Julian years of the equinox against which RA is measured. Default is 2000.
chipName designates the names of the chips on which the pixel coordinates will be reckoned. Can be either single value, an array, or None. If an array, there must be as many chipNames as there are (RA, Dec) pairs. If a single value, all of the pixel coordinates will be reckoned on the same chip. If None, this method will calculate which chip each(RA, Dec) pair actually falls on, and return pixel coordinates for each (RA, Dec) pair on the appropriate chip. Default is None.
includeDistortion is a boolean. If True (default), then this method will return the true pixel coordinates with optical distortion included. If False, this method will return TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the x pixel coordinate and the second row is the y pixel coordinate """
parallax=parallax, v_rad=v_rad, obs_metadata=obs_metadata, chipName=chipName, camera=self._camera, epoch=epoch, includeDistortion=includeDistortion)
obs_metadata=None, chipName=None, camera=None, epoch=2000.0, includeDistortion=True): """ Get the pixel positions (or nan if not on a chip) for objects based on their RA, and Dec (in degrees)
Parameters ---------- ra is in degrees in the International Celestial Reference System. Can be either a float or a numpy array.
dec is in degrees in the International Celestial Reference System. Can be either a float or a numpy array.
pm_ra is proper motion in RA multiplied by cos(Dec) (arcsec/yr) Can be a numpy array or a number or None (default=None).
pm_dec is proper motion in dec (arcsec/yr) Can be a numpy array or a number or None (default=None).
parallax is parallax in arcsec Can be a numpy array or a number or None (default=None).
v_rad is radial velocity (km/s) Can be a numpy array or a number or None (default=None).
obs_metadata is an ObservationMetaData characterizing the telescope pointing.
epoch is the epoch in Julian years of the equinox against which RA is measured. Default is 2000.
chipName designates the names of the chips on which the pixel coordinates will be reckoned. Can be either single value, an array, or None. If an array, there must be as many chipNames as there are (RA, Dec) pairs. If a single value, all of the pixel coordinates will be reckoned on the same chip. If None, this method will calculate which chip each(RA, Dec) pair actually falls on, and return pixel coordinates for each (RA, Dec) pair on the appropriate chip. Default is None.
includeDistortion is a boolean. If True (default), then this method will return the true pixel coordinates with optical distortion included. If False, this method will return TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the x pixel coordinate and the second row is the y pixel coordinate """
parallax=parallax, v_rad=v_rad, obs_metadata=obs_metadata, chipName=chipName, camera=self._camera, epoch=epoch, includeDistortion=includeDistortion)
GalSimCameraWrapper):
""" Return the min and max pixel values of a detector, assuming all radial distortions are set to zero (i.e. using the afwCameraGeom TAN_PIXELS coordinate system)
Parameters ---------- detector_name is a string denoting the name of the detector
Returns ------- xmin, xmax, ymin, ymax pixel values """
includeDistortion=True): """ Get the pixel positions (or nan if not on a chip) for objects based on their pupil coordinates.
Paramters --------- xPupil is the x pupil coordinates in radians. Can be either a float or a numpy array.
yPupil is the y pupil coordinates in radians. Can be either a float or a numpy array.
chipName designates the names of the chips on which the pixel coordinates will be reckoned. Can be either single value, an array, or None. If an array, there must be as many chipNames as there are (RA, Dec) pairs. If a single value, all of the pixel coordinates will be reckoned on the same chip. If None, this method will calculate which chip each(RA, Dec) pair actually falls on, and return pixel coordinates for each (RA, Dec) pair on the appropriate chip.
obs_metadata is an ObservationMetaData characterizing the telescope pointing.
includeDistortion is a boolean. If True (default), then this method will return the true pixel coordinates with optical distortion included. If False, this method will return TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the x pixel coordinate and the second row is the y pixel coordinate. These pixel coordinates are defined in the Camera team system, rather than the DM system. """ dm_y_pix) = coordUtils.pixelCoordsFromPupilCoordsLSST(xPupil, yPupil, chipName=chipName, band=obs_metadata.bandpass, includeDistortion=includeDistortion)
else: else:
includeDistortion=True): """ Convert pixel coordinates into pupil coordinates
Parameters ---------- xPix is the x pixel coordinate of the point. Can be either a float or a numpy array. Defined in the Camera team system (not the DM system).
yPix is the y pixel coordinate of the point. Can be either a float or a numpy array. Defined in the Camera team system (not the DM system).
chipName is the name of the chip(s) on which the pixel coordinates are defined. This can be a list (in which case there should be one chip name for each (xPix, yPix) coordinate pair), or a single value (in which case, all of the (xPix, yPix) points will be reckoned on that chip).
obs_metadata is an ObservationMetaData characterizing the telescope pointing.
includeDistortion is a boolean. If True (default), then this method will expect the true pixel coordinates with optical distortion included. If False, this method will expect TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the x pupil coordinate and the second row is the y pupil coordinate (both in radians) """ dm_yPix = np.zeros(len(xPix)) for ix, (det_name, xx) in enumerate(zip(chipName, xPix)): came_center_pix = self.getCenterPixel(det_name) dm_yPix[ix] = 2.0*cam_center_pix.getX()-xPix[ix] else: band=obs_metadata.bandpass, includeDistortion=includeDistortion)
epoch=2000.0, includeDistortion=True): """ Convert pixel coordinates into RA, Dec
Parameters ---------- xPix is the x pixel coordinate. It can be either a float or a numpy array. Defined in the Camera team system (not the DM system).
yPix is the y pixel coordinate. It can be either a float or a numpy array. Defined in the Camera team system (not the DM system).
chipName is the name of the chip(s) on which the pixel coordinates are defined. This can be a list (in which case there should be one chip name for each (xPix, yPix) coordinate pair), or a single value (in which case, all of the (xPix, yPix) points will be reckoned on that chip).
obs_metadata is an ObservationMetaData defining the pointing
epoch is the mean epoch in years of the celestial coordinate system. Default is 2000.
includeDistortion is a boolean. If True (default), then this method will expect the true pixel coordinates with optical distortion included. If False, this method will expect TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the RA coordinate and the second row is the Dec coordinate (both in radians; in the International Celestial Reference System)
WARNING: This method does not account for apparent motion due to parallax. This method is only useful for mapping positions on a theoretical focal plane to positions on the celestial sphere. """
else:
obs_metadata=obs_metadata, band=obs_metadata.bandpass, epoch=epoch, includeDistortion=includeDistortion)
epoch=2000.0, includeDistortion=True): """ Convert pixel coordinates into RA, Dec
Parameters ---------- xPix is the x pixel coordinate. It can be either a float or a numpy array. Defined in the Camera team system (not the DM system).
yPix is the y pixel coordinate. It can be either a float or a numpy array. Defined in the Camera team system (not the DM system).
chipName is the name of the chip(s) on which the pixel coordinates are defined. This can be a list (in which case there should be one chip name for each (xPix, yPix) coordinate pair), or a single value (in which case, all of the (xPix, yPix) points will be reckoned on that chip).
obs_metadata is an ObservationMetaData defining the pointing
epoch is the mean epoch in years of the celestial coordinate system. Default is 2000.
includeDistortion is a boolean. If True (default), then this method will expect the true pixel coordinates with optical distortion included. If False, this method will expect TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the RA coordinate and the second row is the Dec coordinate (both in degrees; in the International Celestial Reference System)
WARNING: This method does not account for apparent motion due to parallax. This method is only useful for mapping positions on a theoretical focal plane to positions on the celestial sphere. """
obs_metadata=obs_metadata, epoch=2000.0, includeDistortion=True)
obs_metadata=None, chipName=None, epoch=2000.0, includeDistortion=True): """ Get the pixel positions (or nan if not on a chip) for objects based on their RA, and Dec (in radians)
Parameters ---------- ra is in radians in the International Celestial Reference System. Can be either a float or a numpy array.
dec is in radians in the International Celestial Reference System. Can be either a float or a numpy array.
pm_ra is proper motion in RA multiplied by cos(Dec) (radians/yr) Can be a numpy array or a number or None (default=None).
pm_dec is proper motion in dec (radians/yr) Can be a numpy array or a number or None (default=None).
parallax is parallax in radians Can be a numpy array or a number or None (default=None).
v_rad is radial velocity (km/s) Can be a numpy array or a number or None (default=None).
obs_metadata is an ObservationMetaData characterizing the telescope pointing.
epoch is the epoch in Julian years of the equinox against which RA is measured. Default is 2000.
chipName designates the names of the chips on which the pixel coordinates will be reckoned. Can be either single value, an array, or None. If an array, there must be as many chipNames as there are (RA, Dec) pairs. If a single value, all of the pixel coordinates will be reckoned on the same chip. If None, this method will calculate which chip each(RA, Dec) pair actually falls on, and return pixel coordinates for each (RA, Dec) pair on the appropriate chip. Default is None.
includeDistortion is a boolean. If True (default), then this method will return the true pixel coordinates with optical distortion included. If False, this method will return TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the x pixel coordinate and the second row is the y pixel coordinate. These pixel coordinates are defined in the Camera team system, rather than the DM system. """
pm_ra=pm_ra, pm_dec=pm_dec, parallax=parallax, v_rad=v_rad, obs_metadata=obs_metadata, chipName=chipName, band=obs_metadata.bandpass, epoch=epoch, includeDistortion=includeDistortion)
obs_metadata=None, chipName=None, epoch=2000.0, includeDistortion=True): """ Get the pixel positions (or nan if not on a chip) for objects based on their RA, and Dec (in degrees)
Parameters ---------- ra is in degrees in the International Celestial Reference System. Can be either a float or a numpy array.
dec is in degrees in the International Celestial Reference System. Can be either a float or a numpy array.
pm_ra is proper motion in RA multiplied by cos(Dec) (arcsec/yr) Can be a numpy array or a number or None (default=None).
pm_dec is proper motion in dec (arcsec/yr) Can be a numpy array or a number or None (default=None).
parallax is parallax in arcsec Can be a numpy array or a number or None (default=None).
v_rad is radial velocity (km/s) Can be a numpy array or a number or None (default=None).
obs_metadata is an ObservationMetaData characterizing the telescope pointing.
epoch is the epoch in Julian years of the equinox against which RA is measured. Default is 2000.
chipName designates the names of the chips on which the pixel coordinates will be reckoned. Can be either single value, an array, or None. If an array, there must be as many chipNames as there are (RA, Dec) pairs. If a single value, all of the pixel coordinates will be reckoned on the same chip. If None, this method will calculate which chip each(RA, Dec) pair actually falls on, and return pixel coordinates for each (RA, Dec) pair on the appropriate chip. Default is None.
includeDistortion is a boolean. If True (default), then this method will return the true pixel coordinates with optical distortion included. If False, this method will return TAN_PIXEL coordinates, which are the pixel coordinates with estimated optical distortion removed. See the documentation in afw.cameraGeom for more details.
Returns ------- a 2-D numpy array in which the first row is the x pixel coordinate and the second row is the y pixel coordinate. These pixel coordinates are defined in the Camera team system, rather than the DM system. """
pm_ra_out = simsUtils.radiansFromArcsec(pm_ra) else:
pm_dec_out = simsUtils.radiansFromArcsec(pm_dec) else:
parallax_out = simsUtils.radiansFromArcsec(parallax) else:
pm_ra=pm_ra_out, pm_dec=pm_dec_out, parallax=parallax_out, v_rad=v_rad, chipName=chipName, obs_metadata=obs_metadata, epoch=2000.0, includeDistortion=includeDistortion) |