Package astLib :: Module astImages
[show private | hide private]
[frames | no frames]

Module astLib.astImages

module for simple .fits image tasks (rotation, clipping out sections, making .pngs etc.)

(c) 2007 Matt Hilton

http://astlib.sourceforge.net

Some routines in this module will fail if, e.g., asked to clip a section from a .fits image at a position not found within the image (as determined using the WCS). Where this occurs, the function will return None. An error message will be printed to the console when this happens if astImages.REPORT_ERRORS=True (the default). Testing if an astImages function returns None can be used to handle errors in scripts.

In the documentation to this module, 'numerix array' refers to a numarray or numpy array. Note that this module will eventually be ported from numarray to numpy (http://numpy.scipy.org/).
Function Summary
numerix array clipImageSectionPix(imageData, XCoord, YCoord, clipSizePix)
Clips a square section from an image array at the given pixel coordinates.
dictionary clipImageSectionWCS(imageData, imageWCS, RADeg, DecDeg, clipSizeDeg)
Clips a square section from an image array at the given celestial coordinates.
numerix array clipRotatedImageSectionWCS(imageData, imageWCS, RADeg, decDeg, clipSizeDeg)
Clips a square section from an image array at the given celestial coordinates.
numerix array histEq(inputArray, numBins)
Performs histogram equalisation of the input numerix array.
  intensityCutImage(imageData, cutLevels, size, colourMapName)
Creates a matplotlib.pylab plot of an image array with the specified cuts in intensity applied.
  saveBitmap(outputFileName, imageData, cutLevels, size, colourMapName)
Makes a bitmap image from an image array; the image format is specified by the filename extension.
  saveContourOverlayBitmap(outputFileName, imageData, cutLevels, size, colourMapName, contourImageData, contourSmoothFactor, contourLevels, contourColour, contourWidth)
Makes a bitmap image from an image array, with a set of contours generated from a second image array overlaid.
  saveFITS(outputFileName, imageData, imageWCS)
Writes an image array to a new .fits file.

Function Details

clipImageSectionPix(imageData, XCoord, YCoord, clipSizePix)

Clips a square section from an image array at the given pixel coordinates.
Parameters:
imageData - image data array
           (type=numerix array)
XCoord - coordinate in pixel degrees
           (type=float)
YCoord - coordinate in pixel degrees
           (type=float)
clipSizePix - size of square clipped section in pixels
           (type=float)
Returns:
clipped image section
           (type=numerix array)

clipImageSectionWCS(imageData, imageWCS, RADeg, DecDeg, clipSizeDeg)

Clips a square section from an image array at the given celestial coordinates.
Parameters:
imageData - image data array
           (type=numerix array)
imageWCS - astWCS.WCS object
           (type=astWCS.WCS)
RADeg - coordinate in decimal degrees
           (type=float)
DecDeg - coordinate in decimal degrees
           (type=float)
clipSizeDeg - size of square clipped section in decimal degrees
           (type=float)
Returns:
clipped image section (numerix array), updated astWCS WCS object for clipped image section, in format {'clippedData', 'clippedHeader'}.
           (type=dictionary)

clipRotatedImageSectionWCS(imageData, imageWCS, RADeg, decDeg, clipSizeDeg)

Clips a square section from an image array at the given celestial coordinates. The resulting clip is rotated and/or flipped such that North is at the top, and East appears at the left.
Parameters:
imageData - image data array
           (type=numerix array)
imageWCS - astWCS.WCS object
           (type=astWCS.WCS)
RADeg - coordinate in decimal degrees
           (type=float)
decDeg - coordinate in decimal degrees
           (type=float)
clipSizeDeg - size of square clipped section in decimal degrees
           (type=float)
Returns:
clipped image section
           (type=numerix array)

Note: Returns 'None' if the requested position is not found within the image.

histEq(inputArray, numBins)

Performs histogram equalisation of the input numerix array.
Parameters:
inputArray - image data array
           (type=numerix array)
numBins - number of bins in which to perform the operation (e.g. 1024)
           (type=int)
Returns:
image data array
           (type=numerix array)

intensityCutImage(imageData, cutLevels, size, colourMapName)

Creates a matplotlib.pylab plot of an image array with the specified cuts in intensity applied. This routine is used by saveBitmap and saveContourOverlayBitmap, which both produce output as .png, .jpg, etc. images.
Parameters:
imageData - image data array
           (type=numerix array)
cutLevels - sets the image scaling - available options:
  • pixel values: cutLevels=[low value, high value].
  • histogram equalisation: cutLevels=["histEq", number of bins ( e.g. 1024)]
  • relative: cutLevels=["relative", cut per cent level (e.g. 99.5)]
  • smart: cutLevels=["smart", cut per cent level (e.g. 99.5)]
["smart", 99.5] seems to provide good scaling over a range of different images.
           (type=list)
size - size of output image in pixels
           (type=int)
colourMapName - name of a standard matplotlib colormap, e.g. "hot", "cool", "gray" etc. (do "help(pylab.colormaps)" in the Python interpreter to see available options)
           (type=string)

saveBitmap(outputFileName, imageData, cutLevels, size, colourMapName)

Makes a bitmap image from an image array; the image format is specified by the filename extension. (e.g. ".jpg" =JPEG, ".png"=PNG).
Parameters:
outputFileName - filename of output bitmap image
           (type=string)
imageData - image data array
           (type=numerix array)
cutLevels - sets the image scaling - available options:
  • pixel values: cutLevels=[low value, high value].
  • histogram equalisation: cutLevels=["histEq", number of bins ( e.g. 1024)]
  • relative: cutLevels=["relative", cut per cent level (e.g. 99.5)]
  • smart: cutLevels=["smart", cut per cent level (e.g. 99.5)]
["smart", 99.5] seems to provide good scaling over a range of different images.
           (type=list)
size - size of output image in pixels
           (type=int)
colourMapName - name of a standard matplotlib colormap, e.g. "hot", "cool", "gray" etc. (do "help(pylab.colormaps)" in the Python interpreter to see available options)
           (type=string)

saveContourOverlayBitmap(outputFileName, imageData, cutLevels, size, colourMapName, contourImageData, contourSmoothFactor, contourLevels, contourColour, contourWidth)

Makes a bitmap image from an image array, with a set of contours generated from a second image array overlaid. The image format is specified by the file extension (e.g. ".jpg"=JPEG, ".png"=PNG). The image array from which the contours are to be generated can optionally be pre-smoothed using a Gaussian filter.
Parameters:
outputFileName - filename of output bitmap image
           (type=string)
imageData - background image data array
           (type=numerix array)
cutLevels - sets the image scaling - available options:
  • pixel values: cutLevels=[low value, high value].
  • histogram equalisation: cutLevels=["histEq", number of bins ( e.g. 1024)]
  • relative: cutLevels=["relative", cut per cent level (e.g. 99.5)]
  • smart: cutLevels=["smart", cut per cent level (e.g. 99.5)]
["smart", 99.5] seems to provide good scaling over a range of different images.
           (type=list)
size - size of output image in pixels
           (type=int)
colourMapName - name of a standard matplotlib colormap, e.g. "hot", "cool", "gray" etc. (do "help(pylab.colormaps)" in the Python interpreter to see available options)
           (type=string)
contourImageData - image data array from which contours are to be generated
           (type=numerix array)
contourSmoothFactor - standard deviation (in pixels) of Gaussian filter for pre-smoothing of contour image data (set to 0 for no smoothing)
           (type=float)
contourLevels - sets the contour levels - available options:
  • values: contourLevels=[list of values specifying each level]
  • linear spacing: contourLevels=['linear', min level value, max level value, number of levels]
  • log spacing: contourLevels=['log', min level value, max level value, number of levels]
For linear and log spacing, the minimum contour level can either be set explicitly or have one of the following special values:
  • 'min': sets the minimum level automatically to the minimum value in contourImageData
  • ['mean', x]: sets the minimum level to x*the mean value of contourImageData
  • ['median', x]: sets the minimum level to x*the median value of contourImageData
  • ['mode', x]: sets the minimum level x*the mode value of the contourImageData (note that the mode is estimated using mode=3*median-2*mode: if mode<0 and log scaling is set, defaults to using x*median as the minimum contour level.)
Likewise, the maximum contour level can either be set explicitly or have the following special value:
  • 'max': sets the maximum level automatically to the maximum value of contourImageData

           (type=list)
contourColour - colour of the overlaid contours, specified by the name of a standard matplotlib colour, e.g., "black", "white", "cyan" etc. (do "help(pylab.colors)" in the Python interpreter to see available options)
           (type=string)
contourWidth - width of the overlaid contours
           (type=int)

saveFITS(outputFileName, imageData, imageWCS)

Writes an image array to a new .fits file.
Parameters:
outputFileName - filename of output FITS image
           (type=string)
imageData - image data array
           (type=numerix array)
imageWCS - image WCS object
           (type=astWCS.WCS object)

Note: If imageWCS=None, the FITS image will be written with a rudimentary header containing no meta data.


Generated by Epydoc 2.1 on Sun Oct 7 17:29:52 2007 http://epydoc.sf.net