LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Private Member Functions | List of all members
lsst.afw.cameraGeom.fitsUtils.HeaderMap Class Reference
Inheritance diagram for lsst.afw.cameraGeom.fitsUtils.HeaderMap:
lsst.afw.cameraGeom.fitsUtils.HeaderAmpMap lsst.afw.cameraGeom.fitsUtils.HeaderDetectorMap

Public Member Functions

def addEntry
 
def setAttributes
 

Private Member Functions

def _applyVal
 

Detailed Description

Class to hold mapping of header cards to attributes

Definition at line 31 of file fitsUtils.py.

Member Function Documentation

def lsst.afw.cameraGeom.fitsUtils.HeaderMap._applyVal (   self,
  obj,
  value,
  attrName,
  transform 
)
private

Definition at line 68 of file fitsUtils.py.

68 
69  def _applyVal(self, obj, value, attrName, transform):
70  raise NotImplementedError('Must be implemented in sub-class')
def lsst.afw.cameraGeom.fitsUtils.HeaderMap.addEntry (   self,
  keyname,
  attribute_name,
  default = None,
  transform = lambda x: x 
)
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.

Definition at line 33 of file fitsUtils.py.

33 
34  def addEntry(self, keyname, attribute_name, default=None, transform=lambda x: x):
35  """Adds an entry to the registr
36  @param[in] keyname Key used to retrieve the header record
37  @param[in] attribute_name Name of the attribute to store the value in
38  @param[jn] default Default velue to store if the header card is not available
39  @param[in] transform Transform to apply to the header value before assigning it to the
40  attribute.
41  """
42  self.__setitem__(attribute_name, {'keyName':keyname,
43  'default':default,
44  'transform':transform})
def lsst.afw.cameraGeom.fitsUtils.HeaderMap.setAttributes (   self,
  obj,
  metadata,
  doRaise = True 
)
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?

Definition at line 45 of file fitsUtils.py.

45 
46  def setAttributes(self, obj, metadata, doRaise=True):
47  """Sets the attributes on the give object given a metadata object.
48  @param[in, out] obj Object on which to operate in place
49  @param[in] metadata Metadata object used for applying the mapping
50  @param[in] doRaise Raise exceptions on calling methods on the input object that do not exist?
51  """
52  for key, attrDict in self.iteritems():
53  try:
54  value = getByKey(metadata, attrDict['keyName'])
55  if value is not None:
56  self._applyVal(obj, value, key, attrDict['transform'])
57  else:
58  #Only apply transform if the metadata has a value for this key
59  #otherwise assume the default value is transformed.
60  value = attrDict['default']
61  self._applyVal(obj, value, key, lambda x: x)
62  except Exception, e:
63  if doRaise:
64  raise
65  else:
66  warnings.warn('WARNING: Failed to set %s attribute with %s value: %s'%
67  (key, value, e.message))

The documentation for this class was generated from the following file: