# Base ImageObject Classes

A class which makes image objects for each input filename.

A class which makes image objects for each input filename.

Authors: | Warren Hack
License: | http://www.stsci.edu/resources/software_hardware/pyraf/LICENSE

class `drizzlepac.imageObject.``baseImageObject`(filename)

  Bases: `object`

  Base ImageObject which defines the primary set of methods.

  Methods

  `buildERRmask`(chip, dqarr, scale) | Builds a weight mask from an input DQ array and an ERR array associated with the input image.
  `buildEXPmask`(chip, dqarr) | Builds a weight mask from an input DQ array and the exposure time per pixel for this chip.
  `buildIVMmask`(chip, dqarr, scale) | Builds a weight mask from an input DQ array and either an IVM array provided by the user or a self-generated IVM array derived from the flat-field reference file associated with the input image.
  `buildMask`(chip[, bits, write]) | Build masks as specified in the user parameters found in the configObj object.
  `clean`() | Deletes intermediate products generated for this imageObject.
  `close`() | Close the object nicely and release all the data arrays from memory YOU CANT GET IT BACK, the pointers and data are gone so use the getData method to get the data array returned for future use.
  `findExtNum`([extname, extver]) | Find the extension number of the give extname and extver.
  `find_DQ_extension`() | Return the suffix for the data quality extension and the name of the file which that DQ extension should be read from.
  `getAllData`([extname, exclude]) | This function is meant to make it easier to attach ALL the data extensions of the image object so that we can write out copies of the original image nicer.
  `getData`([exten]) | Return just the data array from the specified extension fileutil is used instead of fits to account for non- FITS input images.
  `getExtensions`([extname, section]) | Return the list of EXTVER values for extensions with name specified in extname.
  `getHeader`([exten]) | Return just the specified header extension fileutil is used instead of fits to account for non-FITS input images.
  `getInstrParameter`(value, header, keyword) | This method gets a instrument parameter from a pair of task parameters: a value, and a header keyword.
  `getKeywordList`(kw) | Return lists of all attribute values for all active chips in the imageObject.
  `getNumpyType`(irafType) | Return the corresponding numpy data type.
  `getOutputName`(name) | Return the name of the file or PyFITS object associated with that name, depending on the setting of self.inmemory.
  `getReadNoiseImage`(chip) |
  `getdarkcurrent`() |
  `getdarkimg`(chip) |

  `getexptimeimg`(chip)

  Returns: |

  `getflat`(chip) | Method for retrieving a detector’s flat field.
  `getskyimg`(chip) |
  `info`() | Return fits information on the _image.

  `putData`([data, exten])

  Now that we are removing the data from the object to save memory, we need something that cleanly puts the data array back into the object so that we can write out everything together using something like fits.writeto….this method is an attempt to make sure that when you add an array back to the .data section of the hdu it still matches the header information for that section ( ie.

  `returnAllChips`([extname, exclude]) | Returns a list containing all the chips which match the extname given minus those specified for exclusion (if any).
  `saveVirtualOutputs`(outdict) | Assign in-memory versions of generated products for this imageObject based on dictionary ‘outdict’.
  `set_mt_wcs`(image) | Reset the WCS for this image based on the WCS information from another imageObject.
  `set_units`() | Record the units for this image, both BUNITS from header and in_units as needed internally.
  `set_wtscl`(chip, wtscl_par) | Sets the value of the wt_scl parameter as needed for drizzling.
  `updateContextImage`(contextpar) | Reset the name of the context image to None if parameter `context` == False.
  `updateData`(exten, data) | Write out updated data and header to the original input file for this object.
  `updateIVMName`(ivmname) | Update outputNames for image with user-supplied IVM filename.
  `updateOutputValues`(output_wcs) | Copy info from output WCSObject into outputnames for each chip for use in creating outputimage object.

  getGain |

  `buildERRmask`(chip, dqarr, scale)

    Builds a weight mask from an input DQ array and an ERR array associated with the input image.

  `buildEXPmask`(chip, dqarr)

    Builds a weight mask from an input DQ array and the exposure time per pixel for this chip.

  `buildIVMmask`(chip, dqarr, scale)

    Builds a weight mask from an input DQ array and either an IVM array provided by the user or a self-generated IVM array derived from the flat-field reference file associated with the input image.

  `buildMask`(chip, bits=0, write=False)

    Build masks as specified in the user parameters found in the configObj object.

    We should overload this function in the instrument specific implementations so that we can add other stuff to the badpixel mask? Like vignetting areas and chip boundries in nicmos which are camera dependent? these are not defined in the DQ masks, but should be masked out to get the best results in multidrizzle.

  `clean`()

    Deletes intermediate products generated for this imageObject.

  `close`()

    Close the object nicely and release all the data arrays from memory YOU CANT GET IT BACK, the pointers and data are gone so use the getData method to get the data array returned for future use. You can use putData to reattach a new data array to the imageObject.

  `findExtNum`(extname=None, extver=1)

    Find the extension number of the give extname and extver.

  `find_DQ_extension`()

    Return the suffix for the data quality extension and the name of the file which that DQ extension should be read from.

  `getAllData`(extname=None, exclude=None)

    This function is meant to make it easier to attach ALL the data extensions of the image object so that we can write out copies of the original image nicer.

    If no extname is given, the it retrieves all data from the original file and attaches it. Otherwise, give the name of the extensions you want and all of those will be restored.

    Ok, I added another option. If you want to get all the data extensions EXCEPT a particular one, leave extname=NONE and set exclude=EXTNAME. This is helpfull cause you might not know all the extnames the image has, this will find out and exclude the one you do not want overwritten.

  `getData`(exten=None)

    Return just the data array from the specified extension fileutil is used instead of fits to account for non- FITS input images. openImage returns a fits object.

  `getExtensions`(extname='SCI', section=None)

    Return the list of EXTVER values for extensions with name specified in extname.

  `getGain`(exten)
  `getHeader`(exten=None)

    Return just the specified header extension fileutil is used instead of fits to account for non-FITS input images. openImage returns a fits object.

  `getInstrParameter`(value, header, keyword)

    This method gets a instrument parameter from a pair of task parameters: a value, and a header keyword.

    The default behavior is:
      - if the value and header keyword are given, raise an exception.
      - if the value is given, use it.
      - if the value is blank and the header keyword is given, use the header keyword.
      - if both are blank, or if the header keyword is not found, return None.
  `getKeywordList`(kw)

    Return lists of all attribute values for all active chips in the imageObject.

  `getNumpyType`(irafType)

    Return the corresponding numpy data type.

  `getOutputName`(name)

    Return the name of the file or PyFITS object associated with that name, depending on the setting of self.inmemory.

  `getReadNoiseImage`(chip)

    Notes

    Method for returning the readnoise image of a detector (in electrons).

    The method will return an array of the same shape as the image.

    Units: | electrons

  `getdarkcurrent`()

    Notes

    Return the dark current for the detector. This value will be contained within an instrument specific keyword. The value in the image header will be converted to units of electrons.

    Units: | electrons

  `getdarkimg`(chip)

    Notes

    Return an array representing the dark image for the detector.

    The method will return an array of the same shape as the image.

    Units: | electrons

  `getexptimeimg`(chip)

    Returns:

    exptimeimg : numpy array

      The method will return an array of the same shape as the image.

    Notes

    Return an array representing the exposure time per pixel for the detector. This method will be overloaded for IR detectors which have their own EXP arrays, namely, WFC3/IR and NICMOS images.

    Units: | None

  `getflat`(chip)

    Method for retrieving a detector’s flat field.

    Returns:

    flat: array

      This method will return an array the same shape as the image in units of electrons.

  `getskyimg`(chip)

    Notes

    Return an array representing the sky image for the detector. The value of the sky is what would actually be subtracted from the exposure by the skysub step.

    Units: | electrons

  `info`()

    Return fits information on the _image.

  `putData`(data=None, exten=None)

    Now that we are removing the data from the object to save memory, we need something that cleanly puts the data array back into the object so that we can write out everything together using something like fits.writeto….this method is an attempt to make sure that when you add an array back to the .data section of the hdu it still matches the header information for that section ( ie. update the bitpix to reflect the datatype of the array you are adding). The other header stuff is up to you to verify.

    Data should be the data array exten is where you want to stick it, either extension number or a string like ‘sci,1’

  `returnAllChips`(extname=None, exclude=None)

    Returns a list containing all the chips which match the extname given minus those specified for exclusion (if any).

  `saveVirtualOutputs`(outdict)

    Assign in-memory versions of generated products for this imageObject based on dictionary ‘outdict’.

  `set_mt_wcs`(image)

    Reset the WCS for this image based on the WCS information from another imageObject.

  `set_units`()

    Record the units for this image, both BUNITS from header and in_units as needed internally. This method will be defined specifically for each instrument.

  `set_wtscl`(chip, wtscl_par)

    Sets the value of the wt_scl parameter as needed for drizzling.

  `updateContextImage`(contextpar)

    Reset the name of the context image to None if parameter `context` == False.

  `updateData`(exten, data)

    Write out updated data and header to the original input file for this object.

  `updateIVMName`(ivmname)

    Update outputNames for image with user-supplied IVM filename.

  `updateOutputValues`(output_wcs)

    Copy info from output WCSObject into outputnames for each chip for use in creating outputimage object.

class `drizzlepac.imageObject.``imageObject`(filename, group=None, inmemory=False)

  Bases: `drizzlepac.imageObject.baseImageObject`

  This returns an imageObject that contains all the necessary information to run the image file through any multidrizzle function. It is essentially a PyFits object with extra attributes.

  There will be generic keywords which are good for the entire image file, and some that might pertain only to the specific chip.

  Methods

  `buildERRmask`(chip, dqarr, scale) | Builds a weight mask from an input DQ array and an ERR array associated with the input image.
  `buildEXPmask`(chip, dqarr) | Builds a weight mask from an input DQ array and the exposure time per pixel for this chip.
  `buildIVMmask`(chip, dqarr, scale) | Builds a weight mask from an input DQ array and either an IVM array provided by the user or a self-generated IVM array derived from the flat-field reference file associated with the input image.
  `buildMask`(chip[, bits, write]) | Build masks as specified in the user parameters found in the configObj object.
  `clean`() | Deletes intermediate products generated for this imageObject.
  `close`() | Close the object nicely and release all the data arrays from memory YOU CANT GET IT BACK, the pointers and data are gone so use the getData method to get the data array returned for future use.
  `compute_wcslin`([undistort]) | Compute the undistorted WCS based solely on the known distortion model information associated with the WCS.
  `findExtNum`([extname, extver]) | Find the extension number of the give extname and extver.
  `find_DQ_extension`() | Return the suffix for the data quality extension and the name of the file which that DQ extension should be read from.
  `getAllData`([extname, exclude]) | This function is meant to make it easier to attach ALL the data extensions of the image object so that we can write out copies of the original image nicer.
  `getData`([exten]) | Return just the data array from the specified extension fileutil is used instead of fits to account for non- FITS input images.
  `getExtensions`([extname, section]) | Return the list of EXTVER values for extensions with name specified in extname.
  `getHeader`([exten]) | Return just the specified header extension fileutil is used instead of fits to account for non-FITS input images.
  `getInstrParameter`(value, header, keyword) | This method gets a instrument parameter from a pair of task parameters: a value, and a header keyword.
  `getKeywordList`(kw) | Return lists of all attribute values for all active chips in the imageObject.
  `getNumpyType`(irafType) | Return the corresponding numpy data type.
  `getOutputName`(name) | Return the name of the file or PyFITS object associated with that name, depending on the setting of self.inmemory.
  `getReadNoiseImage`(chip) |
  `getdarkcurrent`() |
  `getdarkimg`(chip) |

  `getexptimeimg`(chip)

  Returns: |

  `getflat`(chip) | Method for retrieving a detector’s flat field.
  `getskyimg`(chip) |
  `info`() | Return fits information on the _image.

  `putData`([data, exten])

  Now that we are removing the data from the object to save memory, we need something that cleanly puts the data array back into the object so that we can write out everything together using something like fits.writeto….this method is an attempt to make sure that when you add an array back to the .data section of the hdu it still matches the header information for that section ( ie.

  `returnAllChips`([extname, exclude]) | Returns a list containing all the chips which match the extname given minus those specified for exclusion (if any).
  `saveVirtualOutputs`(outdict) | Assign in-memory versions of generated products for this imageObject based on dictionary ‘outdict’.
  `setInstrumentParameters`(instrpars) | Define instrument-specific parameters for use in the code.
  `set_mt_wcs`(image) | Reset the WCS for this image based on the WCS information from another imageObject.
  `set_units`(chip) | Define units for this image.
  `set_wtscl`(chip, wtscl_par) | Sets the value of the wt_scl parameter as needed for drizzling.
  `updateContextImage`(contextpar) | Reset the name of the context image to None if parameter `context` == False.
  `updateData`(exten, data) | Write out updated data and header to the original input file for this object.
  `updateIVMName`(ivmname) | Update outputNames for image with user-supplied IVM filename.
  `updateOutputValues`(output_wcs) | Copy info from output WCSObject into outputnames for each chip for use in creating outputimage object.

  getGain |

  `compute_wcslin`(undistort=True)

    Compute the undistorted WCS based solely on the known distortion model information associated with the WCS.

  `setInstrumentParameters`(instrpars)

    Define instrument-specific parameters for use in the code. By definition, this definition will need to be overridden by methods defined in each instrument’s sub-class.

  `set_units`(chip)

    Define units for this image.

class `drizzlepac.imageObject.``WCSObject`(filename, suffix='_drz')

  Bases: `drizzlepac.imageObject.baseImageObject`

  Methods

  `buildERRmask`(chip, dqarr, scale) | Builds a weight mask from an input DQ array and an ERR array associated with the input image.
  `buildEXPmask`(chip, dqarr) | Builds a weight mask from an input DQ array and the exposure time per pixel for this chip.
  `buildIVMmask`(chip, dqarr, scale) | Builds a weight mask from an input DQ array and either an IVM array provided by the user or a self-generated IVM array derived from the flat-field reference file associated with the input image.
  `buildMask`(chip[, bits, write]) | Build masks as specified in the user parameters found in the configObj object.
  `clean`() | Deletes intermediate products generated for this imageObject.
  `close`() | Close the object nicely and release all the data arrays from memory YOU CANT GET IT BACK, the pointers and data are gone so use the getData method to get the data array returned for future use.
  `findExtNum`([extname, extver]) | Find the extension number of the give extname and extver.
  `find_DQ_extension`() | Return the suffix for the data quality extension and the name of the file which that DQ extension should be read from.
  `getAllData`([extname, exclude]) | This function is meant to make it easier to attach ALL the data extensions of the image object so that we can write out copies of the original image nicer.
  `getData`([exten]) | Return just the data array from the specified extension fileutil is used instead of fits to account for non- FITS input images.
  `getExtensions`([extname, section]) | Return the list of EXTVER values for extensions with name specified in extname.
  `getHeader`([exten]) | Return just the specified header extension fileutil is used instead of fits to account for non-FITS input images.
  `getInstrParameter`(value, header, keyword) | This method gets a instrument parameter from a pair of task parameters: a value, and a header keyword.
  `getKeywordList`(kw) | Return lists of all attribute values for all active chips in the imageObject.
  `getNumpyType`(irafType) | Return the corresponding numpy data type.
  `getOutputName`(name) | Return the name of the file or PyFITS object associated with that name, depending on the setting of self.inmemory.
  `getReadNoiseImage`(chip) |
  `getdarkcurrent`() |
  `getdarkimg`(chip) |

  `getexptimeimg`(chip)

  Returns: |

  `getflat`(chip) | Method for retrieving a detector’s flat field.
  `getskyimg`(chip) |
  `info`() | Return fits information on the _image.

  `putData`([data, exten])

  Now that we are removing the data from the object to save memory, we need something that cleanly puts the data array back into the object so that we can write out everything together using something like fits.writeto….this method is an attempt to make sure that when you add an array back to the .data section of the hdu it still matches the header information for that section ( ie.

  `returnAllChips`([extname, exclude]) | Returns a list containing all the chips which match the extname given minus those specified for exclusion (if any).
  `saveVirtualOutputs`(outdict) | Assign in-memory versions of generated products for this imageObject based on dictionary ‘outdict’.
  `set_mt_wcs`(image) | Reset the WCS for this image based on the WCS information from another imageObject.
  `set_units`() | Record the units for this image, both BUNITS from header and in_units as needed internally.
  `set_wtscl`(chip, wtscl_par) | Sets the value of the wt_scl parameter as needed for drizzling.
  `updateContextImage`(contextpar) | Reset the name of the context image to None if parameter `context` == False.
  `updateData`(exten, data) | Write out updated data and header to the original input file for this object.
  `updateIVMName`(ivmname) | Update outputNames for image with user-supplied IVM filename.
  `updateOutputValues`(output_wcs) | Copy info from output WCSObject into outputnames for each chip for use in creating outputimage object.

  getGain |
  restore_wcs |

  `restore_wcs`()