Coverage for python/lsst/afw/cameraGeom/fitsUtils.py : 81%
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
|
"""Wrapper for getting a value from a metadata object by key. @param[in] metadata metadata object to query for value @param[in] key key to use for value lookup @returns value associated with key, None if key does not exist """ else:
"""Wrapper for setting a value in a metadata object. Deals with case where the key already exists. @param[in, out] metadata metadata object ot modify in place. @param[in] key key to associate with value @param[in] value value to assign in the metadata object @param[in] clobber Clobber the value if the key already exisists? """
""" Class to hold mapping of header cards to attributes"""
"""Adds an entry to the registr @param[in] keyname Key used to retrieve the header record @param[in] attribute_name Name of the attribute to store the value in @param[jn] default Default velue to store if the header card is not available @param[in] transform Transform to apply to the header value before assigning it to the attribute. """ 'default': default, 'transform': transform})
"""Sets the attributes on the give object given a metadata object. @param[in, out] obj Object on which to operate in place @param[in] metadata Metadata object used for applying the mapping @param[in] doRaise Raise exceptions on calling methods on the input object that do not exist? """ # if attrDict['keyName'] == "RDCRNR" and value == 0: # import ipdb; ipdb.set_trace() else: # Only apply transform if the metadata has a value for this key # otherwise assume the default value is transformed. except Exception as e: if doRaise: raise else: warnings.warn('WARNING: Failed to set %s attribute with %s value: %s' % (key, value, str(e)))
raise NotImplementedError('Must be implemented in sub-class')
""" Class to hold mapping of header cards to AmpInfoTable attributes The amp info is stored using setters, thus calling the attribute as a function. """
""" Class to hold mapping of header cards to Detector attributes Detector information is stored as attributes on a Config object. """
radialCoeffs=(0., 1.), clobberMetadata=False, doRaise=True): ''' @param[in] detectorFileName FITS file containing the detector description. May use [] notation to specify an extension in an MEF. @param[in] ampFileNameList List of FITS file names to use in building the amps. May contain duplicate entries if the raw data are assembled. @param[in] inAmpCoords Boolean, True if raw data are in amp coordinates, False if raw data are assembled into pseudo detector pixel arrays @param[in] plateScale Nominal platescale (arcsec/mm) @param[in] radialCoeffs Radial distortion coefficients for a radial polynomial in normalized units. @param[in] clobberMetadata Clobber metadata from input files if overridden in the _sanitizeMetadata method @param[in] doRaise Raise exception if not all non-defaulted keywords are defined? Default is True. ''' self.detectorMetadata, clobber=clobberMetadata) self.ampMetadataList[-1], clobber=clobberMetadata)
"""This method is called for all metadata and gives an opportunity to add/modify header information for use downstream. Override this method if more than the default is needed. @param[in, out] metadata Metadata to read/modify @param[in] clobber Clobber keys that exist with default keys? """
"""Does the default sanitization of the header metadata. @param[in,out] metadata Header metadata to extend/modify @param[in] clobber Override values in existing header cards? """
# Deal with DTM to get flipX and flipY for assembly and add as 'FLIPX', 'FLIPY' # The DTM array is a transformation matrix. As I understand it, it transforms between # electronic and assembled coordintates. As such, a negative value in the DTM1_1 spot # corresponds to a flip of the x-axis and a negative value in the DTM2_2 spot # corresponds to a flip of the y-axis. setByKey(metadata, 'FLIPX', dtm1 < 0, clobber) setByKey(metadata, 'FLIPY', dtm2 < 0, clobber) afwTable.ReadoutCorner.LL), clobber) else: setByKey(metadata, 'FLIPX', False, clobber) setByKey(metadata, 'FLIPY', True, clobber) # I don't know how to figure out the read corner if already # assembled setByKey(metadata, 'RDCRNR', None, clobber)
# Deal with NAXIS1, NAXIS2 to make rawBBox as 'RAWBBOX' 1, xext, 1, yext), clobber) # Deal with DTV1, DTV2 to make 'XYOFF setByKey(metadata, 'XYOFF', [dtv1, dtv2], clobber) # map biassec[1] to HOSCAN # map biassec[3] to VOSCAN # map biassec[2] to PRESCAN keylist = ['HOSCAN', 'PRESCAN', 'VOSCAN'] biassecs = getByKey(metadata, 'BIASSEC') for i, biassec in enumerate(biassecs): setByKey(metadata, keylist[i], biassec, clobber) else: setByKey(metadata, 'HOSCAN', biassec, clobber)
"""Make the default map from header information to amplifier information @return The HeaderAmpMap object containing the mapping """ ('DETSEC', 'setBBox', None, self._makeBbox), ('GAIN', 'setGain', 1.), ('RDNOISE', 'setReadNoise', 0.), ('SATURATE', 'setSaturation', 2 << 15), ('RDCRNR', 'setReadoutCorner', int( afwTable.ReadoutCorner.LL), afwTable.ReadoutCorner), ('LINCOEFF', 'setLinearityCoeffs', [0., 1.]), ('LINTYPE', 'setLinearityType', 'POLY'), ('RAWBBOX', 'setRawBBox', None, self._makeBbox), ('DATASEC', 'setRawDataBBox', None, self._makeBbox), ('FLIPX', 'setRawFlipX', False), ('FLIPY', 'setRawFlipY', False), ('XYOFF', 'setRawXYOffset', lsst.geom.ExtentI(0, 0), self._makeExt), ('HOSCAN', 'setRawHorizontalOverscanBBox', emptyBBox, self._makeBbox), ('VOSCAN', 'setRawVerticalOverscanBBox', emptyBBox, self._makeBbox), ('PRESCAN', 'setRawPrescanBBox', emptyBBox, self._makeBbox), ]
"""Make the default map from header information to detector information @return The HeaderDetectorMap object containing the mapping """ ('DETSIZE', 'bbox_x0', 0, self._getBboxX0), ('DETSIZE', 'bbox_y0', 0, self._getBboxY0), ('DETSIZE', 'bbox_x1', 0, self._getBboxX1), ('DETSIZE', 'bbox_y1', 0, self._getBboxY1), ('DETID', 'id', 0), # DetectorConfig.detectorType is of type `int`, not # `DetectorType` ('OBSTYPE', 'detectorType', int( afwCameraGeom.DetectorType.SCIENCE)), ('SERSTR', 'serial', 'none'), ('XPOS', 'offset_x', 0.), ('YPOS', 'offset_y', 0.), ('XPIX', 'refpos_x', 0.), ('YPIX', 'refpos_y', 0.), ('YAWDEG', 'yawDeg', 0.), ('PITCHDEG', 'pitchDeg', 0.), ('ROLLDEG', 'rollDeg', 0.), ('XPIXSIZE', 'pixelSize_x', 1.), ('YPIXSIZE', 'pixelSize_y', 1.), ('TRNSPOSE', 'transposeDetector', False), ]
"""Helper function to make an extent from an array @param[in] extArr Length 2 array to use in creating the Extent object @return Extent2I constructed from the input list """ return lsst.geom.ExtentI(*extArr)
"""Helper funtion to make a bounding box from a string representing a FITS style bounding box @param[in] boxString String describing the bounding box @return Box2I for the bounding box """ # strip off brackets and split into parts '[:,]', boxString.strip()[1:-1])] # account for the difference between FITS convention and LSST convention for # index of LLC.
return self._makeBbox(boxString).getMinX()
return self._makeBbox(boxString).getMaxX()
return self._makeBbox(boxString).getMinY()
return self._makeBbox(boxString).getMaxY()
"""Helper function to get the radial transform given the radial polynomial coefficients given in the constructor. @param[in] radialCoeffs List of coefficients describing a polynomial radial distortion in normalized units. @return Transform object describing the radial distortion """
"""Take all the information and build a Detector object. The Detector object is necessary for doing things like assembly. @return Detector object """ return self.detector
detConfig, self.detectorMetadata, self.doRaise) detConfig, ampInfo, self.focalPlaneToField)
"""PLaceholder for subclasses to implement construction of a calib to associate with the exposure. @return empty afwImage.Calib object """
"""Method for constructing an exposure object from an image and the information contained in this class to construct the Detector and Calib objects. @param[in] im Image used to construct the exposure @param[in] mask Optional mask plane as a <askU @param[in] variance Optional variance plance as an image of the same type as im @param[out] Exposure object """ mask = afwImage.Mask(im.getDimensions()) variance = im
|