Coverage for python/lsst/sims/coordUtils/LsstCameraUtils.py : 91%

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
"pupilCoordsFromFocalPlaneCoordsLSST", "chipNameFromPupilCoordsLSST", "_chipNameFromRaDecLSST", "chipNameFromRaDecLSST", "pixelCoordsFromPupilCoordsLSST", "pupilCoordsFromPixelCoordsLSST", "_pixelCoordsFromRaDecLSST", "pixelCoordsFromRaDecLSST", "_raDecFromPixelCoordsLSST", "raDecFromPixelCoordsLSST", "clean_up_lsst_camera"]
""" Delete member objects associated with the methods below """
""" Get the focal plane coordinates for all objects in the catalog.
Parameters ---------- xPupil -- the x pupil coordinates in radians. Can be a float or a numpy array.
yPupil -- the y pupil coordinates in radians. Can be a float or a numpy array.
band -- the filter being simulated (default='r')
Returns -------- a 2-D numpy array in which the first row is the x focal plane coordinate and the second row is the y focal plane coordinate (both in millimeters) """
""" Convert mm on the focal plane to radians on the pupil.
Note: round-tripping through focalPlaneCoordsFromPupilCoordsLSST and pupilCoordsFromFocalPlaneCoordsLSST introduces a residual of up to 2.18e-6 mm that accumulates with each round trip.
Parameters ---------- xmm -- x coordinate in millimeters on the focal plane
ymm -- y coordinate in millimeters on the focal plane
band -- the filter we are simulating (default='r')
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) """
""" Build a map of focal plane coordinates on the LSST focal plane. Returns _lsst_focal_coord_map, which is a dict. _lsst_focal_coord_map['name'] contains a list of the names of each chip in the lsst camera _lsst_focal_coord_map['xx'] contains the x focal plane coordinate of the center of each chip (mm) _lsst_focal_coord_map['yy'] contains the y focal plane coordinate of the center of each chip (mm) _lsst_focal_coord_map['dp'] contains the radius (in mm) of the circle containing each chip """
x_mm_list[ix+2] + x_mm_list[ix+3])
y_mm_list[ix+2] + y_mm_list[ix+3])
np.power(yy-y_mm_list[ix+ii], 2)) for ii in range(4)]).sum()
allow_multiple_chips=False): """!Find the detectors that cover a list of points specified by x and y coordinates in any system
This is based one afw.camerGeom.camera.findDetectorsList. It has been optimized for the LSST camera in the following way:
- it accepts a limited list of detectors to check in advance (this list should be constructed by comparing the pupil coordinates in question and comparing to the pupil coordinates of the center of each detector)
- it will stop looping through detectors one it has found one that is correct (the LSST camera does not allow an object to fall on more than one detector)
@param[in] focalPointList a list of points in FOCAL_PLANE coordinates
@param[in] detectorList is a list of the afwCameraGeom detector objects being considered
@param[in] possible_points is a list of lists. possible_points[ii] is a list of integers corresponding to the indices in focalPointList of the pupilPoints that may be on detectorList[ii].
@param [in] allow_multiple_chips is a boolean (default False) indicating whether or not this method will allow objects to be visible on more than one chip. If it is 'False' and an object appears on more than one chip, only the first chip will appear in the list of chipNames but NO WARNING WILL BE EMITTED. If it is 'True' and an object falls on more than one chip, a list of chipNames will appear for that object.
@return outputNameList is a numpy array of the names of the detectors """ # transform the points to the native coordinate system # # The conversion to a numpy array looks a little clunky. # The problem, if you do the naive thing (nativePointList = np.array(lsst_camera().....), # the conversion to a numpy array gets passed down to the contents of nativePointList # and they end up in a form that the afwCameraGeom code does not know how to handle
# initialize output and some caching lists
# Figure out if any of these (RA, Dec) pairs could be # on more than one chip. This is possible on the # wavefront sensors, since adjoining wavefront sensors # are kept one in focus, one out of focus. # See figure 2 of arXiv:1506.04839v2 # (This might actually be a bug in obs_lsstSim # I opened DM-8075 on 25 October 2016 to investigate) for ipt in range(len(focalPointList)): for det in detectorList[ipt]: if det.getType() == WAVEFRONT: could_be_multiple[ipt] = True
# t_assemble_list = 0.0 # loop over detectors
raise RuntimeError("Somehow, unfound_pts = %d in _findDetectorsListLSST" % unfound_pts) # we have already found all of the (RA, Dec) pairs outputNameList[ix] = str(name)
# find all of the pupil points that could be on this detector
# because this (RA, Dec) pair is not marked as could_be_multiple, # the fact that this (RA, Dec) pair is on the current chip # means this (RA, Dec) pair no longer needs to be considered. # You can set chip_has_found[ix] to unity. else: # Since this (RA, Dec) pair has been makred could_be_multiple, # finding this (RA, Dec) pair on the chip does not remove the # (RA, Dec) pair from contention. if outputNameList[ix] is None: outputNameList[ix] = detector.getName() elif isinstance(outputNameList[ix], list): outputNameList[ix].append(detector.getName()) else: outputNameList[ix] = [outputNameList[ix], detector.getName()]
# convert entries corresponding to multiple chips into strings # (i.e. [R:2,2 S:0,0, R:2,2 S:0,1] becomes `[R:2,2 S:0,0, R:2,2 S:0,1]`) outputNameList[ix] = str(name)
# print('t_assemble %.2e' % t_assemble_list)
""" Return the names of LSST detectors that see the object specified by either (xPupil, yPupil).
@param [in] xPupil_in is the x pupil coordinate in radians. Must be a numpy array.
@param [in] yPupil_in is the y pupil coordinate in radians. Must be a numpy array.
@param [in] allow_multiple_chips is a boolean (default False) indicating whether or not this method will allow objects to be visible on more than one chip. If it is 'False' and an object appears on more than one chip, only the first chip will appear in the list of chipNames and warning will be emitted. If it is 'True' and an object falls on more than one chip, a list of chipNames will appear for that object.
@param[in] band is the bandpass being simulated (default='r')
@param [out] a numpy array of chip names
""" not hasattr(chipNameFromPupilCoordsLSST, '_detector_arr') or len(chipNameFromPupilCoordsLSST._detector_arr) == 0):
# build a Box2D that contains all of the detectors in the camera
(yy-chipNameFromPupilCoordsLSST._y_focal_center)**2)
"chipNameFromPupilCoordsLSST")
(yFocal-chipNameFromPupilCoordsLSST._y_focal_center)**2)
############################################################ # in the code below, we will only consider those points which # passed the 'good_radii' test above; the other points will # be added in with chipName == None at the end # for i_pt in good_radii[0]]
# Loop through every detector on the camera. For each detector, assemble a list of points # whose centers are within 1.1 detector radii of the center of the detector.
enumerate(zip(x_cam_list, y_cam_list, rrsq_lim_list)):
(yFocal_good - y_cam)**2) < rrsq_lim)[0]
chipNameFromPupilCoordsLSST._detector_arr, possible_points, allow_multiple_chips=allow_multiple_chips)
#################################################################### # initialize output as an array of Nones, effectively adding back in # the points which failed the initial radius cut
obs_metadata=None, epoch=2000.0, allow_multiple_chips=False, band='r'): """ Return the names of detectors on the LSST camera that see the object specified by (RA, Dec) in radians.
@param [in] ra in radians (a numpy array or a float). In the International Celestial Reference System.
@param [in] dec in radians (a numpy array or a float). In the International Celestial Reference System.
@param [in] 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).
@param [in] pm_dec is proper motion in dec (radians/yr) Can be a numpy array or a number or None (default=None).
@param [in] parallax is parallax in radians Can be a numpy array or a number or None (default=None).
@param [in] v_rad is radial velocity (km/s) Can be a numpy array or a number or None (default=None).
@param [in] obs_metadata is an ObservationMetaData characterizing the telescope pointing
@param [in] epoch is the epoch in Julian years of the equinox against which RA and Dec are measured. Default is 2000.
@param [in] allow_multiple_chips is a boolean (default False) indicating whether or not this method will allow objects to be visible on more than one chip. If it is 'False' and an object appears on more than one chip, only the first chip will appear in the list of chipNames but NO WARNING WILL BE EMITTED. If it is 'True' and an object falls on more than one chip, a list of chipNames will appear for that object.
@param [in] band is the filter we are simulating (Default=r)
@param [out] the name(s) of the chips on which ra, dec fall (will be a numpy array if more than one) """
raise RuntimeError("You need to pass an epoch into chipName")
pm_ra=pm_ra, pm_dec=pm_dec, parallax=parallax, v_rad=v_rad, obs_metadata=obs_metadata, epoch=epoch)
band=band)
obs_metadata=None, epoch=2000.0, allow_multiple_chips=False, band='r'): """ Return the names of detectors on the LSST camera that see the object specified by (RA, Dec) in degrees.
@param [in] ra in degrees (a numpy array or a float). In the International Celestial Reference System.
@param [in] dec in degrees (a numpy array or a float). In the International Celestial Reference System.
@param [in] 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).
@param [in] pm_dec is proper motion in dec (arcsec/yr) Can be a numpy array or a number or None (default=None).
@param [in] parallax is parallax in arcsec Can be a numpy array or a number or None (default=None).
@param [in] v_rad is radial velocity (km/s) Can be a numpy array or a number or None (default=None).
@param [in] obs_metadata is an ObservationMetaData characterizing the telescope pointing
@param [in] epoch is the epoch in Julian years of the equinox against which RA and Dec are measured. Default is 2000.
@param [in] allow_multiple_chips is a boolean (default False) indicating whether or not this method will allow objects to be visible on more than one chip. If it is 'False' and an object appears on more than one chip, only the first chip will appear in the list of chipNames but NO WARNING WILL BE EMITTED. If it is 'True' and an object falls on more than one chip, a list of chipNames will appear for that object.
@param [in] band is the filter that we are simulating (Default=r)
@param [out] the name(s) of the chips on which ra, dec fall (will be a numpy array if more than one) """ else:
else:
else:
pm_ra=pm_ra_out, pm_dec=pm_dec_out, parallax=parallax_out, v_rad=v_rad, obs_metadata=obs_metadata, epoch=epoch, allow_multiple_chips=allow_multiple_chips, band=band)
includeDistortion=True): """ Convert pixel coordinates into radians on the pupil
Parameters ---------- xPix -- the x pixel coordinate
yPix -- the y pixel coordinate
chipName -- the name(s) of the chips on which xPix, yPix are reckoned
band -- the filter we are simulating (default=r)
includeDistortion -- a boolean which turns on or off optical distortions (default=True)
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) """
return pupilCoordsFromPixelCoords(xPix, yPix, chipName=chipName, camera=lsst_camera(), includeDistortion=includeDistortion)
chipNameList = _validate_inputs_and_chipname([xPix, yPix], ['xPix', 'yPix'], "pupilCoordsFromPixelCoords", chipName, chipname_can_be_none=False)
for ii in local_valid[0]]
for pt in focal_pt_arr]).transpose()
else: else:
includeDistortion=True): """ Convert radians on the pupil into pixel coordinates.
Parameters ---------- xPupil -- is the x coordinate on the pupil in radians
yPupil -- is the y coordinate on the pupil in radians
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 (xPupil, yPupil) 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(xPupil, yPupil) pair actually falls on, and return pixel coordinates for each (xPupil, yPupil) pair on the appropriate chip. Default is None.
band -- the filter we are simulating (default=r)
includeDistortion -- a boolean which turns on and off optical distortions (default=True)
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 """
camera=lsst_camera(), includeDistortion=includeDistortion)
chipNameList = _validate_inputs_and_chipname([xPupil, yPupil], ['xPupil', 'yPupil'], 'pixelCoordsFromPupilCoordsLSST', chipName)
else: chipNameList = np.array([chipNameList])
continue
continue for ii in local_valid[0]] for pp in pixel_pt_arr]).transpose()
else: else:
obs_metadata=None, chipName=None, camera=None, epoch=2000.0, includeDistortion=True, band='r'): """ Get the pixel positions on the LSST camera (or nan if not on a chip) for objects based on their RA, and Dec (in radians)
@param [in] ra is in radians in the International Celestial Reference System. Can be either a float or a numpy array.
@param [in] dec is in radians in the International Celestial Reference System. Can be either a float or a numpy array.
@param [in] 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).
@param [in] pm_dec is proper motion in dec (radians/yr) Can be a numpy array or a number or None (default=None).
@param [in] parallax is parallax in radians Can be a numpy array or a number or None (default=None).
@param [in] v_rad is radial velocity (km/s) Can be a numpy array or a number or None (default=None).
@param [in] obs_metadata is an ObservationMetaData characterizing the telescope pointing.
@param [in] epoch is the epoch in Julian years of the equinox against which RA is measured. Default is 2000.
@param [in] 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.
@param [in] camera is an afwCameraGeom object specifying the attributes of the camera. This is an optional argument to be passed to chipName.
@param [in] 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.
@param [in] band is the filter we are simulating ('u', 'g', 'r', etc.) Default='r'
@param [out] 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("You need to pass an epoch into pixelCoordsFromRaDec")
"pixelCoordsFromRaDec")
"pixelCoordsFromRaDec")
pm_ra=pm_ra, pm_dec=pm_dec, parallax=parallax, v_rad=v_rad, obs_metadata=obs_metadata, epoch=epoch)
includeDistortion=includeDistortion)
obs_metadata=None, chipName=None, epoch=2000.0, includeDistortion=True, band='r'): """ Get the pixel positions on the LSST camera (or nan if not on a chip) for objects based on their RA, and Dec (in degrees)
@param [in] ra is in degrees in the International Celestial Reference System. Can be either a float or a numpy array.
@param [in] dec is in degrees in the International Celestial Reference System. Can be either a float or a numpy array.
@param [in] 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).
@param [in] pm_dec is proper motion in dec (arcsec/yr) Can be a numpy array or a number or None (default=None).
@param [in] parallax is parallax in arcsec Can be a numpy array or a number or None (default=None).
@param [in] v_rad is radial velocity (km/s) Can be a numpy array or a number or None (default=None).
@param [in] obs_metadata is an ObservationMetaData characterizing the telescope pointing.
@param [in] epoch is the epoch in Julian years of the equinox against which RA is measured. Default is 2000.
@param [in] 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.
@param [in] 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.
@param [in] band is the filter we are simulating ('u', 'g', 'r', etc.) Default='r'
@param [out] a 2-D numpy array in which the first row is the x pixel coordinate and the second row is the y pixel coordinate """
else:
else:
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, band=band)
obs_metadata=None, epoch=2000.0, includeDistortion=True): """ Convert pixel coordinates into RA, Dec
@param [in] xPix is the x pixel coordinate. It can be either a float or a numpy array.
@param [in] yPix is the y pixel coordinate. It can be either a float or a numpy array.
@param [in] 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).
@param [in] band is the filter we are simulating (default=r)
@param [in] obs_metadata is an ObservationMetaData defining the pointing
@param [in] epoch is the mean epoch in years of the celestial coordinate system. Default is 2000.
@param [in] 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.
@param [out] 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. """
chipNameList = _validate_inputs_and_chipname([xPix, yPix], ['xPix', 'yPix'], 'raDecFromPixelCoords', chipName, chipname_can_be_none=False)
raise RuntimeError("You cannot call raDecFromPixelCoords without specifying an epoch")
raise RuntimeError("You cannot call raDecFromPixelCoords without an ObservationMetaData")
raise RuntimeError("The ObservationMetaData in raDecFromPixelCoords must have an mjd")
raise RuntimeError("The ObservationMetaData in raDecFromPixelCoords must have a rotSkyPos")
chipNameList, band=band, includeDistortion=includeDistortion)
obs_metadata=obs_metadata, epoch=epoch)
obs_metadata=None, epoch=2000.0, includeDistortion=True): """ Convert pixel coordinates into RA, Dec
@param [in] xPix is the x pixel coordinate. It can be either a float or a numpy array.
@param [in] yPix is the y pixel coordinate. It can be either a float or a numpy array.
@param [in] 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).
@param [in] band is the filter we are simulating (default=r)
@param [in] obs_metadata is an ObservationMetaData defining the pointing
@param [in] epoch is the mean epoch in years of the celestial coordinate system. Default is 2000.
@param [in] 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.
@param [out] 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=epoch, includeDistortion=includeDistortion)
|