UVES Pipeline Reference Manual  5.4.0
Functions
Utility functions (low level)

Functions

static cpl_image * filter_median (const cpl_image *image, int radx, int rady, bool extrapolate_border)
 Median filter.
const cpl_property * uves_find_property_const (const uves_propertylist *plist, const char *name, int number)
 Find named property.
cpl_property * uves_find_property (uves_propertylist *plist, const char *name, int number)
cpl_error_code uves_filter_image_average (cpl_image *image, int radius_x, int radius_y)
 Average filter.
cpl_error_code uves_filter_image_median (cpl_image **image, int xwindow, int ywindow, bool extrapolate_border)
 Median filter.
double uves_utils_get_kth_double (double *a, int n, int k)
 returns the kth value of an array
double uves_tools_get_median (double *a, int n)
 returns median (not CPL median) of an array
cpl_error_code uves_fit_gaussian_2d_image (const cpl_image *image, const cpl_image *noise, int x1, int y_1, int x2, int y2, double *x0, double *y_0, double *sigmax, double *sigmay, double *amplitude, double *dx0, double *dy0)
 Fit a 2d gaussian to an image sub-window.

Detailed Description

This module contains low level library functions that can be removed if/when the corresponding functionality is in the CPL.


Function Documentation

static cpl_image * filter_median ( const cpl_image *  image,
int  radx,
int  rady,
bool  extrapolate_border 
)
static

Median filter.

Parameters:
imageImage to filter
radxx-radius of median window
radyy-radius of median window
extrapolate_borderIf false (which should be considered the default value), a smaller window is used at the image borders (where the full window would be partially outside of the image). If true, the median is calculated only for points where the full window is inside the image, and the border region is obtained by constant extrapolation.
Returns:
Filtered image, or NULL on error.

Apply a radx by rady median filter to the input image. Each pixel is replaced by the median of a local window of size (2* radx + 1)* (2 * rady + 1) centered on the pixel.

Definition at line 516 of file uves_utils_cpl.c.

References assure_mem, uves_tostring_cpl_type(), and uves_utils_get_kth_double().

Referenced by uves_filter_image_median().

const cpl_property* uves_find_property_const ( const uves_propertylist plist,
const char *  name,
int  number 
)

Find named property.

Parameters:
plistpropertylist to search
nameproperty name
numbernumber of property to find (counting from zero). E.g. setting number=1 would return the 2nd property with matching name
Returns:
first property with given name, or NULL if not found

No error is set if the property is not found

Definition at line 199 of file uves_utils_cpl.c.

References uves_propertylist_get_const(), and uves_propertylist_get_size().

cpl_error_code uves_filter_image_average ( cpl_image *  image,
int  radius_x,
int  radius_y 
)

Average filter.

Parameters:
imageImage to filter
radius_xwidth of filter window is 2*radius_x + 1
radius_yheight of filter window is 2*radius_y + 1
Returns:
CPL_ERROR_NONE iff OK.

The image must be of type CPL_TYPE_DOUBLE.

There is currently no handling of bad pixels.

Definition at line 250 of file uves_utils_cpl.c.

References uves_msg_debug, and uves_tostring_cpl_type().

cpl_error_code uves_filter_image_median ( cpl_image **  image,
int  xwindow,
int  ywindow,
bool  extrapolate_border 
)

Median filter.

Parameters:
imageImage to filter
xwindowx-radius of filter window
ywindowy-radius of filter window
extrapolate_borderSee filter_median()
Returns:
CPL_ERROR_NONE iff OK.

If the median window is large, this function is rather inefficient, because cpl_image_get_median_window() is called for each pixel. A more clever implementation would keep track of the running window.

Definition at line 375 of file uves_utils_cpl.c.

References check, and filter_median().

Referenced by uves_get_blaze_ratio(), uves_rcosmic(), and uves_response_efficiency().

double uves_utils_get_kth_double ( double *  a,
int  n,
int  k 
)

returns the kth value of an array

Parameters:
aarray
narray size
kcomponent to evaluate

The array is modified

Definition at line 439 of file uves_utils_cpl.c.

Referenced by filter_median(), and uves_tools_get_median().

double uves_tools_get_median ( double *  a,
int  n 
)

returns median (not CPL median) of an array

Parameters:
aarray
narray size

The array is modified

Definition at line 475 of file uves_utils_cpl.c.

References uves_utils_get_kth_double().

Referenced by opt_get_noise_median(), and opt_get_sky().

cpl_error_code uves_fit_gaussian_2d_image ( const cpl_image *  image,
const cpl_image *  noise,
int  x1,
int  y_1,
int  x2,
int  y2,
double *  x0,
double *  y_0,
double *  sigmax,
double *  sigmay,
double *  amplitude,
double *  dx0,
double *  dy0 
)

Fit a 2d gaussian to an image sub-window.

Parameters:
imageThe image to fit.
noiseThe uncertainty (one sigma, gaussian errors assumed) associated with the image. If NULL, constant uncertainties are assumed, and then dx0 and dy0 cannot be determined.
x1Lower left corner (inclusive, FITS convention).
y_1Lower left corner (inclusive, FITS convention).
x2Upper right corner (inclusive, FITS convention).
y2Upper right corner (inclusive, FITS convention).
x0(output) x-center of best fit gaussian.
y_0(output) y-center of best fit gaussian.
sigmax(output) x-width of best fit gaussian. Positive on success.
sigmay(output) y-width of best fit gaussian. Positive on success.
amplitude(output) Height of the best fit gaussian, relative to the background level. May be NULL.
dx0(output) Uncertainty of x0. May be NULL.
dy0(output) Uncertainty of y_0. May be NULL.

The function does not make a 2d gaussian fit, but fits a one-dimensional gaussian to the marginal distributions in x and y. See also uves_fit_gaussian_1d_image().

Note:
A CPL_ERROR_CONTINUE is set in the case (and only in that case) that the fitting algorithm fails to converge or converges to a non-sensical result.

Definition at line 644 of file uves_utils_cpl.c.

References check, uves_gauss(), and uves_gauss_derivative().

Referenced by test_gaussian_fitting().