eclipse.image
index
/astro-wise/AWEHOME/x86_64/AWBASE/astro/lib/python2.5/site-packages/eclipse/image.py

 
Modules
       
eclipse.c_eclipse

 
Classes
       
__builtin__.object
image

 
class image(__builtin__.object)
     Methods defined here:
__add__(self, other)
__del__(self)
__div__(self, other)
__iadd__(self, other)
__idiv__(self, other)
__imul__(self, other)
__init__(self, filename=None, extension=0, plane=0, readonly=0)
A 2D FITS image
 
filename -- The name of a FITS file
extnumber -- The extension (default 0)
plane -- The plane in a 3D image stack (default 0)
readonly -- Indicate that the FITS file is readonly (default 0)
 
This is the basic object used to manipulate FITS images. This
object interfaces image objects in the eclipse image
processing library to provide image manipulation at C speeds.
 
The image object provides several classes of operations
 
Introspection
=============
 
>>> xsize, ysize = image.xsize(), image.ysize()
 
Arithmetic
==========
 
Given two images, one can:
 
>>> newima = ima1 + ima2    # add them
>>> newima = ima1 - ima2    # subtract them
>>> newima = ima1 * ima2    # multiply them
>>> newima = ima1 / ima2    # divide them
 
One can also use constants in arithmetic operations:
 
>>> newima = ima + 2.5 
>>> newima = ima - 3.2
>>> newima = ima * 1.7
>>> newima = ima / 1.11111
>>> newima = ima ** 2       # squared image
 
Note that arithmetic operations copy results. It might be more
efficient to perform in-place operations
 
>>> ima1 += ima2
>>> ima1 **= 0.5            # a sqrt image
 
However, in-place operations cannot be performed on images
that are read-only.
 
Image extraction
================
 
One can use
 
>>> newima = ima.extract_region(x0, y0, x1, y1)
 
to extract a sub region from 
 
Statistics
==========
 
A number of operations allow one to obtain statstics for an
image or some specified part of an image
 
>>> image.stat(domedian=1)
 
is used to obtain a common.statstruct object (q.v.) containg
statistics values (a.o.: mean, median, minimum, and maximum)
 
>>> image.get_mean()
>>> image.get_median()
 
return just the mean and median respectively
 
>>> image.stat_opts(...)
 
allows one to specify a pixelmap of valid pixels and/or an
area of valid data and/or a range of valid pixel values to
specify which data should be included when computing
statistics
 
 
Filtering
=========
 
>>> image.filter_mean(xsize, ysize)
>>> image.filter_median(xsize, ysize)
 
Can be used to produce mean and median filters useing
rectangular kernels of arbitrary size (in both cases the
default size is 3x3). In addition a number of named filters
can be used: filter_dx(), filter_dy(), filter_dx2(), filter_dy2()
filter_contour1(), filter_contour2(), filter_contour3(), and
filter_contrast1()
 
 
Normalization
=============
 
Using the stat method and in_place multiplication, a number of
normalization methods have been defined.
 
>>> image.normalize_mean()
>>> image.normalize_median()
>>> image.normalize_flux()
>>> image.normalize_absolute_flux()
 
normalize the image to a mean, median, flux or absolute flux
of 1.  (other scales are possible too) It is possible to
specify relevant regions the same way as in image.stat_opts()
__ipow__(self, other, modulo=None)
__isub__(self, other)
__mul__(self, other)
__neg__(self)
__pow__(self, other)
__radd__(self, other)
__rdiv__(self, other)
__rmul__(self, other)
__rpow__(self, other)
__rsub__(self, other)
__sub__(self, other)
arithmetic_operation(self, other, opcode)
clean_bad_pixels(self, pixmap, boxsize)
Interpolate the bad pixels in an image
 
Arguments
pixmap -- A pixelmap (good=1, bad=0)
boxsize -- width of interpolation region
copy(self)
Copy the data to a new image() object
 
No arguments
extract_region(self, x0, y0, x1, y1)
Extract a sub-image from this image
 
Arguments
x0, y0 -- lower lefthand corner
x1, y1 -- upper righthand corner
 
These coordinates follow FITS coordinates. Hence the
x0, y0 = 1,1 is equivalent to the lower left corner of the
input image, and the dimeson of the resulting image will be
(x1-x0)+1 x (y1-y0)+1
filter_contour1(self)
Convolve with a kernel
 1  0 -1
 0  0  0
-1  0  1
filter_contour2(self)
Convolve with a kernel
-1  0  1
 2  0 -2
-1  0  1
filter_contour3(self)
Convolve with a kernel
-1  2 -1
 0  0  0
 1 -2  1
filter_contrast1(self)
Convolve with a kernel
1  1  1
1  4  1
1  1  1
filter_dx(self)
First derivative in x, convolve with a kernel
-1 0 1
-1 0 1
-1 0 1
filter_dx2(self)
Second derivative in x, convolve with a kernel
1 -2 1
1 -2 1
1 -2 1
filter_dy(self)
First derivative in y, convolve with a kernel
-1 -1 -1
 0  0  0
 1  1  1
filter_dy2(self)
Second derivative in y, convolve with a kernel
 1  1  1
-2 -2 -2
 1  1  1
filter_mean(self, xsize=3, ysize=3)
Return a mean filtered image over a rectangular kernel
 
Arguments:
xsize -- width of filter (default=3)
ysize -- height of filter (default=3)
filter_median(self, xsize=3, ysize=3)
Do a median filtering over a rectangular area
 
Arguments:
xsize -- width of filter (default=3)
ysize -- height of filter (default=3)
get_mean(self)
Reurn the mean of this image
get_median(self)
Return the median of this image
get_p_ima(self)
Getter function for image pointer
hough_transform(self, threshold)
Make a Hough transform of the image
in_place_operation(self, other, opcode)
inverse_hough_transform(self, threshold, lx, ly)
iter_stat(self, max_iter=5, threshold=5.0)
Compute the statistics iteratively
 
Arguments:
   max_iter  -- maximum number of iterations (default 5)
   threshold -- rejection threshold for bad pixels (default 5 sigma)
   
Iteratively approximate the image statistics by rejecting
outliers from the interval [median-threshold*stdev,
median+thresold*stdev]
 
Returns a statstruct object. Adds an attribute 'convergence' to
the statstruct object. The value of this attribute is 1 if the
iteration converged, 0 otherwise
iter_stat_opts(self, pixmap=None, zone=None, max_iter=5, threshold=5.0)
Compute the statistics iteratively
 
Arguments:
  pixmap   -- map of valid pixels (default=None)
  zone     -- a valid zone (x0, y0, x1, y1) (default=None)
  max_iter  -- maximum number of iterations (default 5)
  threshold -- rejection threshold for bad pixels (default 5 sigma)
   
Iteratively approximate the image statistics by rejecting
outliers from the interval [median-threshold*stdev,
median+thresold*stdev]
 
Returns a statstruct object. Adds an attribute 'convergence' to
the statstruct object. The value of this attribute is 1 if the
iteration converged, 0 otherwise
mirror_edges(self, xedge, yedge)
Mirror the edges of the image to create a new image
 
Arguments
xedge -- The size of the sides to be mirrored
yedge -- The size of the top/bottom to be mirrored
normalize_absolute_flux(self, pixmap=None, pixrange=None, zone=None, scale=1.0)
Normalize the image to an absolute flux of 1.0.
 
The absolute flux can be computed in a restricted area. This
function modifies the image in-place
 
Arguments:
pixmap -- map of valid pixelsd (default=None)
pixrange -- a range of valid values [low, high] (default=None)
zone -- a valid zone [xmin, xmax, ymin, ymax]
scale -- normalize to a different scale (default=1.0)
normalize_flux(self, pixmap=None, pixrange=None, zone=None, scale=1.0)
Normalize the image to a flux of 1.0.
 
The flux can be computed in a restricted area. This function
modifies the image in-place
 
Arguments:
pixmap -- map of valid pixelsd (default=None)
pixrange -- a range of valid values [low, high] (default=None)
zone -- a valid zone [xmin, xmax, ymin, ymax]
scale -- normalize to a different scale (default=1.0)
normalize_mean(self, pixmap=None, pixrange=None, zone=None, scale=1.0)
Normalize the image to a mean of 1.0.
 
The mean can be computed in a restricted area. This function
modifies the image in-place
 
Arguments:
pixmap -- map of valid pixelsd (default=None)
pixrange -- a range of valid values [low, high] (default=None)
zone -- a valid zone [xmin, xmax, ymin, ymax]
scale -- normalize to a different scale (default=1.0)
normalize_median(self, pixmap=None, pixrange=None, zone=None, scale=1.0)
Normalize the image to a median of 1.0.
 
The median can be computed in a restricted area. This function
modifies the image in-place
 
Arguments:
pixmap -- map of valid pixelsd (default=None)
pixrange -- a range of valid values [low, high] (default=None)
zone -- a valid zone [xmin, xmax, ymin, ymax]
scale -- normalize to a different scale (default=1.0)
normalize_range(self, pixmap=None, pixrange=None, zone=None, scale=1.0)
Normalize the image to a range of values between 0.0 and 1.0.
 
The range can be computed in a restricted area. This function
modifies the image in-place
 
Arguments:
pixmap -- map of valid pixelsd (default=None)
pixrange -- a range of valid values [low, high] (default=None)
zone -- a valid zone [xmin, xmax, ymin, ymax]
scale -- normalize to a different maximum (default=1.0)
pcheck(self, msg)
Check if image pointer exists, otherwise raise exception
run_counttest(self, Threshold)
Quality control tool  
 
This test is useful the see the number of pixel out a fixed
threshold. It can produce two different output: the sum of all
pixel out the threshold or simple the number; morover produce
a flag image of pixel out the range.
 
Arguments
 
Threshold
 
 
Returns a quality index.
run_flatfittingtest(self, nwx, nwy, nfwx, nfwy)
Quality control tool for Twilight 
 
It can be used on flat images to see if there is a gradient,
works in two steps, before use the bicubic spline
interpolation to produce an image and after split this image
in a number of subwindows; then for each subwindows compute
the root means square and return the max rms value.
 
Arguments
 
nwx  - number of subwindows in x
nwy  - number of subwindows in y
nfwx - number of subwindows in x for fitting
nfwy - number of subwindows in y for fitting
 
Returns a quality index.
run_flattest(self, nwx, nwy)
Quality control tool for Dome 
 
This test works an Flatfielded images.  
 
The image is normalised by its median value.The medians of a
number of sub-windows of the normalized image are determined.
The minimum median is subtracted from the maximum median and
the result is given as output.
 
Arguments
 
nwx - number of subwindows in x
nwy - number of subwindows in y
 
 
Returns a quality index.
run_imsurfit(self, nwx, nwy)
Tool for fitting surface  
 
The common technique for obtaining smoothness in
two-dimensional interpolation is the bicubic spline.
Actually, this is equivalent to a special case of bicubic
interpolation: Bicubic splines are usually implemented in a
form that looks rather different from the above bicubic
interpolation routines: To interpolate one functional value,
one performs m one-dimensional splines across the rows of the
table, followed by one additional one-dimensional spline down
the newly created column. It is a matter of taste (and
trade-off between time and memory) as to how much of this
process one wants to precompute and store. Instead of
precomputing and storing all the derivative information (as in
bicubic interpolation), spline users typically precompute and
store only one auxiliary table, of second derivatives in one
direction only. Then one need only do spline evaluations (not
constructions) for the m row splines; one must still do a
construction and an evaluation for the final column spline
 
Arguments
 
nwx - number of subwindows in x for fitting
nwy - number of subwindows in y for fitting
 
Returns a surface fitting image.
run_signtest(self, nwx, nwy, Threshold=5)
Quality control tool for Bias 
 
The algorithm splits the input frame in a number of subwindows
(parameter in input) and then counts, for each, the elements
greaters of median frame value;if this number is not out of
binomial distribution, then the subwindow is flagged. Finally
the number of bad windows is compared with the theorical number
of windows expected; the quality index, then is defined as
(N_BAD-N_EXPECTED)/sigma
 
Arguments
 
nwx - number of subwindows in x
nwy - number of subwindows in y
Threshold
--
 
Returns a quality index.
save(self, filename=None, header=None)
Save the current image.  If filename is specified, save the
current image _as_ filename.  If header is specified, save
current image with this header.
set_p_ima(self, p_ima)
Setter for image pointer
set_zero(self)
stat(self, domedian=1)
Compute the statistics
 
domedian -- If true compute median (default=1)
 
Returns a statstruct (q.v.) object
stat_opts(self, pixmap=None, pixrange=None, zone=None, domedian=1)
Compute the statistics, using a pixmap and/or a pixrange
and/or a zone to define included pixels
 
Arguments:
pixmap   -- map of valid pixels (default=None)
pixrange -- a range of valid values [low, high] (default=None)
zone     -- a valid zone (x0, y0, x1, y1) (default=None)
domedian -- if true, compute median (default=1)
 
The zone uses FITS coordinates
Returns a statstruct (q.v.) object
subtract_oscan_rows(self, x0, x1, smooth=0)
Subtract median of overscan rows
 
Arguments
x0, x1 -- start and end column of overscan region
smooth -- size of rectangular box smoothing function
thresh_to_pixmap(self, low_cut, hi_cut)
Produce a pixelmap mapping pixels with values between
low_cut and hi_cut
threshold(self, lv, hv, sl, sh)
This tool takes all pixels major than hl and assign them the value sh, then
it takes all pixels less than lv and assign them the value sl.
 
Arguments
 
lv - low  value
hv - high value 
sl - low  new value
sh - high new value
xsize(self)
ysize(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
p_ima
Getter function for image pointer

Data and other attributes defined here:
filters = {'contour1': [1.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0], 'contour2': [-1.0, 0.0, 1.0, 2.0, 0.0, -2.0, -1.0, 0.0, 1.0], 'contour3': [-1.0, -2.0, -1.0, 0.0, 0.0, 0.0, 1.0, -2.0, 1.0], 'contrast1': [1.0, 1.0, 1.0, 1.0, 4.0, 1.0, 1.0, 1.0, 1.0], 'dx': [-1.0, 0.0, 1.0, -1.0, 0.0, 1.0, -1.0, 0.0, 1.0], 'dx2': [1.0, -2.0, 1.0, 1.0, -2.0, 1.0, 1.0, -2.0, 1.0], 'dy': [-1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0], 'dy2': [1.0, 1.0, 1.0, -2.0, -2.0, -2.0, 1.0, 1.0, 1.0], 'mean3': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 'mean5': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, ...]}
in_place_op_map = {'*': <built-in function image_mul_local>, '+': <built-in function image_add_local>, '-': <built-in function image_sub_local>, '/': <built-in function image_div_local>}
operator_map = {'*': <built-in function image_mul>, '+': <built-in function image_add>, '-': <built-in function image_sub>, '/': <built-in function image_div>}
pointer_count = 0

 
Functions
       
fft(real, imaginary=None, direction=-1)
Do a Fast Fourier Transorm
 
Arguments:
real -- An image containing the real values
image -- An image containing the imaginary values (default=None)
direction -- -1 (forward, default) or inverse (1)
 
Returns a tuple of images representing the real and imaginary part
of the fourier transformed data
make_image(xsize, ysize)
Generate a new image
 
Arguments
xsize, ysize -- the dimension of the image

 
Data
        FAILURE = -1