utilities

Functions

cpl_image * sinfo_vector_to_image (const cpl_vector *vector, cpl_type type)
 Convert a vector to a 1d image.
long sinfo_round_double (double x)
 Round a number to the nearest integer.
int sinfo_parameter_get_default_flag (const cpl_parameter *p)
 Check if an input parameter has been changed by the user.

sinfo_fftn

N-dimensional FFT.

Parameters:
data N-dimensional data set stored in 1d.
nn Dimensions of the set.
ndim How many dimensions this set has.
isign Transform direction.
Returns:
void

This routine is a public domain FFT. See extract of Usenet article below. Found on { http://www.tu-chemnitz.de/~arndt/joerg.html}.

{verbatim} From: alee@tybalt.caltech.edu (Andrew Lee) Newsgroups: comp.sources.misc Subject: N-dimensional, Radix 2 FFT Routine Date: 17 Jul 87 22:26:29 GMT Approved: allbery@ncoast.UUCP X-Archive: comp.sources.misc/8707/48

[..] Now for the usage (finally): data[] is the array of complex numbers to be transformed, nn[] is the array giving the dimensions (I mean size) of the array, ndim is the number of dimensions of the array, and isign is +1 for a forward transform, and -1 for an inverse transform.

data[] and nn[] are stored in the "natural" order for C: nn[0] gives the number of elements along the leftmost index, nn[ndim - 1] gives the number of elements along the rightmost index, and data should be declared along the lines of struct (f)complex data[nn[0], nn[1], ..., nn[ndim - 1]]

Additional notes: The routine does NO NORMALIZATION, so if you do a forward, and then an inverse transform on an array, the result will be identical to the original array MULTIPLIED BY THE NUMBER OF ELEMENTS IN THE ARRAY. Also, of course, the dimensions of data[] must all be powers of 2. {verbatim}



void sinfo_fftn (dcomplex data[], unsigned nn[], int ndim, int isign)

sinfo_is_power_of_2

Find if a given integer is a power of 2.

Parameters:
p Integer to check.
Returns:
The corresponding power of 2, or -1.

If the given number is a power of 2, the power is returned. Otherwise -1 is returned.

Example: {verbatim} sinfo_is_power_of_2(1024) returns 10 sinfo_is_power_of_2(1023) returns -1 {verbatim}



int sinfo_is_power_of_2 (int p)

sinfo_file_exists

Find if a given file name corresponds to an existing file.

Parameters:
filename Name of the file to look up.
Returns:
int 1 if file exists, 0 if not

Find out if the given character string corresponds to a file that can be stat()'ed.



int sinfo_file_exists (const char *filename)

sinfo_ipow

Same as pow(x,y) but for integer values of y only (faster).

Parameters:
x A double number.
p An integer power.
Returns:
x to the power p.

This is much faster than the math function due to the integer. Some compilers make this optimization already, some do not.

p can be positive, negative or null.



double sinfo_ipow (double x, int p)

sinfo_create_mx

Allocates a new sinfo_eclipse_matrix.

Parameters:
nr Number of rows.
nc Number of columns.
Returns:
Pointer to newly allocated sinfo_eclipse_matrix.

Allocates a new sinfo_eclipse_matrix.



Matrix sinfo_create_mx (int nr, int nc)

sinfo_copy_mx

Copy a sinfo_eclipse_matrix.

Parameters:
a Matrix to copy.
Returns:
Pointer to newly allocated sinfo_eclipse_matrix.

Copy a sinfo_eclipse_matrix.



Matrix sinfo_copy_mx (Matrix a)

sinfo_close_mx

Frees memory associated to a sinfo_eclipse_matrix.

Parameters:
a Matrix to free.
Returns:
void

Free a sinfo_eclipse_matrix.



void sinfo_close_mx (Matrix a)

sinfo_mul_mx

Multiplies 2 matrices.

Parameters:
a Matrix on the left side of the multiplication.
b Matrix on the right side of the multiplication.
Returns:
Matrix a*b.

Multiply matrices.



Matrix sinfo_mul_mx (Matrix a, Matrix b)

sinfo_invert_mx

Inverts a sinfo_eclipse_matrix.

Parameters:
aa (Square) sinfo_eclipse_matrix to sinfo_invert
Returns:
Newly allocated sinfo_eclipse_matrix.

The sinfo_eclipse_matrix inversion procedure is hardcoded for optimized speed in the case of 1x1, 2x2 and 3x3 matrices. This function is not suitable for large matrices.



Matrix sinfo_invert_mx (Matrix aa)

sinfo_transp_mx

Transposes a sinfo_eclipse_matrix.

Parameters:
a Matrix to transpose.
Returns:
Newly allocated sinfo_eclipse_matrix.

Transpose a sinfo_eclipse_matrix.



Matrix sinfo_transp_mx (Matrix a)

sinfo_least_sq_mx

Compute the solution of an equation using a pseudo-inverse.

Parameters:
A Matrix.
B Matrix.
Returns:
Pointer to newly allocated sinfo_eclipse_matrix.

The equation is XA=B.

The pseudo-inverse solution to this equation is defined as: {verbatim} P = B.tA.inv(A.tA) {verbatim}

P is solving the equation using a least-squares criterion. Demonstration left to the reader.



Matrix sinfo_least_sq_mx (Matrix A, Matrix B)

sinfo_print_mx

Prints out a sinfo_eclipse_matrix on stdout.

Parameters:
M Matrix to print out
name Name of the sinfo_eclipse_matrix to print out.
Returns:
void

The sinfo_eclipse_matrix name is printed out, then all values row by row. Used for debugging purposes mostly.



void sinfo_print_mx (Matrix M, const char *name)

sinfo_kth_smallest

Find the kth smallest element in an array.

Parameters:
a Array to consider for sinfo_median search.
n Number of elements in the array.
k Rank of the element to find (between 0 and n-1).
Returns:
One element from the array.

Provide an array of n pixelvalues and the rank of the value you want to find. A rank of 0 means the minimum element, a rank of n-1 is the maximum element, and a rank of n/2 is the sinfo_median. Use the median_WIRTH macro to find the sinfo_median directly.

NB: The input array is modified. Some elements are swapped, until the requested value is found. The array is left in an undefined sorted state.

This algorithm was taken from the following book: {verbatim} Author: Wirth, Niklaus Title: Algorithms + data structures = programs Publisher: Englewood Cliffs: Prentice-Hall, 1976 Physical description: 366 p. Series: Prentice-Hall Series in Automatic Computation {verbatim}



pixelvalue sinfo_kth_smallest (pixelvalue a[], int n, int k)

sinfo_kth_smallest_double

Find the kth smallest element in a double array.

Parameters:
a Array to consider for sinfo_median search.
n Number of elements in the array.
k Rank of the element to find (between 0 and n-1).
Returns:
One element from the array.

See sinfo_kth_smallest() function in the same file.

NB: THE INPUT ARRAY IS MODIFIED.



double sinfo_kth_smallest_double (double a[], int n, int k)
#define PIX_SWAP(a, b)   { register pixelvalue t=(a);(a)=(b);(b)=t; }
#define PIX_SWAP(a, b)   { pixelvalue temp=(a);(a)=(b);(b)=temp; }
#define DBL_SWAP(a, b)   { register double t=(a);(a)=(b);(b)=t; }
#define PIX_SORT(a, b)   { if ((a)>(b)) PIX_SWAP((a),(b)); }

sinfo_opt_med3

Optimized search of the sinfo_median of 3 values.

Parameters:
p Array of 3 pixelvalues
Returns:
Median of the input values.

Found on sci.image.processing. Cannot go faster unless some assumptions are made about the nature of the input signal, or the underlying hardware.

The input array is modified.



pixelvalue sinfo_opt_med3 (pixelvalue *p)

sinfo_opt_med5

Optimized search of the sinfo_median of 5 values.

Parameters:
p Array of 5 pixelvalues
Returns:
Median of the input values.

Found on sci.image.processing. Cannot go faster unless some assumptions are made about the nature of the input signal, or the underlying hardware.

The input array is modified.



pixelvalue sinfo_opt_med5 (pixelvalue *p)

sinfo_opt_med7

Optimized search of the sinfo_median of 7 values.

Parameters:
p Array of 7 pixelvalues
Returns:
Median of the input values.

Found on sci.image.processing. Cannot go faster unless some assumptions are made about the nature of the input signal, or the underlying hardware.

The input array is modified.



pixelvalue sinfo_opt_med7 (pixelvalue *p)

sinfo_opt_med9

Optimized search of the sinfo_median of 9 values.

Parameters:
p Array of 9 pixelvalues
Returns:
Median of the input values.

Formula from: {verbatim} XILINX XCELL magazine, vol. 23 by John L. Smith {verbatim}

The result array is guaranteed to contain the sinfo_median value in middle position, but other elements are NOT sorted.

The input array is modified.



pixelvalue sinfo_opt_med9 (pixelvalue *p)

sinfo_opt_med25

Optimized search of the sinfo_median of 25 values.

Parameters:
p Array of 25 pixelvalues
Returns:
Median of the input values.

Formula from: {verbatim} Graphic Gems source code {verbatim}

The result array is guaranteed to contain the sinfo_median value in middle position, but other elements are NOT sorted.

The input array is modified.



pixelvalue sinfo_opt_med25 (pixelvalue *p)

sinfo_median_pixelvalue

Compute the sinfo_median pixel value of an array.

Parameters:
a Array to consider.
n Number of pixels in the array.
Returns:
The sinfo_median of the array.

This is the generic method that should be called to get the sinfo_median out of an array of pixelvalues. It calls in turn the most efficient method depending on the number of values in the array.

The input array is always modified.



pixelvalue sinfo_median_pixelvalue (pixelvalue *a, int n)

sinfo_sinfo_merge_images()

merges the rows of two image frames in a way that the resulting image has double length in y-direction

Parameters:
im1 image to merge,
im2 image to merge
res_image dummy for residual image
Note:
: first must have smaller wavelength than the second for the same pixel row.
Returns:
resulting merged image, final residual image


cpl_image * sinfo_sinfo_merge_images (cpl_image *im1, cpl_image *im2, cpl_image *res_image)

sinfo_new_remove_general_offset()

removes the offset between two images

Parameters:
im1 
im2 two images,
res_image result image
n number of rows from which the offset is determined.
Returns:
changed second image, residual image if wanted or needed

adds general offset between two frames to the second image and delivers the residual image, assuming that the background cancellation did not work perfectly well.



cpl_image * sinfo_new_remove_general_offset (cpl_image *im1, cpl_image *im2, cpl_image *res_image, int n)

sinfo_new_remove_regional_tilt()

removes a general tilt from the spectra , created e.g. by different emissivities of the telescope itself and delivers the residual image

Parameters:
im1 
im2 both images to merge,
res_image residual image (obligatory no NULL).
Returns:
changed second image, residual image


cpl_image * sinfo_new_remove_regional_tilt (cpl_image *im1, cpl_image *im2, cpl_image *res_image)

sinfo_new_remove_column_offset()

removes individual column offset, created e.g. by imperfect guiding. The offset is divided out. The ratio is derived from the medians of the contributions.

Parameters:
im1 first image
im2 already corrected second image to merge,
res_image residual image (obligatory no NULL).
Returns:
changed second image, residual image


cpl_image * sinfo_new_remove_column_offset (cpl_image *im1, cpl_image *im2, cpl_image *res_image)

sinfo_new_remove_residual_tilt()

removes a residual column tilt (determined from the residual image) created by previous operations

Parameters:
im2 second image to merge,
res_image residual image (obligatory no NULL).
Returns:
changed second image, residual image


cpl_image * sinfo_new_remove_residual_tilt (cpl_image *im2, cpl_image *res_image)

sinfo_new_remove_residual_offset()

removes the residual offset by adding the median of the residual image to each column

Parameters:
im2 second image that will be changed,
res_image residual image must be given.
Returns:
changed second image, residual image


cpl_image * sinfo_new_remove_residual_offset (cpl_image *im2, cpl_image *res_image)

sinfo_pixel_qsort

Sort an array of pixels by increasing pixelvalue.

Parameters:
pix_arr Array to sort.
npix Number of pixels in the array.
Returns:
void

Optimized implementation of a fast pixel sort. The input array is modified.



void sinfo_pixel_qsort (pixelvalue *pix_arr, int npix)
#define PIX_SWAP(a, b)   { pixelvalue temp=(a);(a)=(b);(b)=temp; }
#define PIX_STACK_SIZE   50

sinfo_poly2d_compute

Compute the value of a poly2d at a given point.

Parameters:
p Poly2d object.
x x coordinate.
y y coordinate.
Returns:
The value of the 2d polynomial at (x,y) as a double.

This computes the value of a poly2d in a single point. To compute many values in a row, see sinfo_poly2d_compute_array().



double sinfo_poly2d_compute (poly2d *p, double x, double y)

sinfo_table_shift_column_spline3

Parameters:
shift a table of an double shift
t input table
col input table's column
shift shift to be applied
Returns:
pointer to a new allocated shifted table


cpl_table * sinfo_table_shift_column_spline3 (cpl_table *t, const char *col, const double shift)

sinfo_table_shift_column_int

Parameters:
shift a table of an integer step
t input table
col input table's column
s shift to be applied
r shift rest
Returns:
pointer to a new allocated shifted table


cpl_table * sinfo_table_shift_column_int (const cpl_table *t, const char *col, const double s, double *r)

sinfo_table_shift_column_poly

Parameters:
shift a table of an double shift
t input table
col input table's column
shift shift to be applied
order polynomial order
Returns:
pointer to a new allocated shifted table


cpl_table * sinfo_table_shift_column_poly (cpl_table *t, const char *col, const double shift, const int order)
void sinfo_new_array_set_value (float *array, float value, int i)
float sinfo_new_array_get_value (float *array, int i)
void sinfo_new_destroy_array (float **array)
void sinfo_new_destroy_stringarray (char **array, int size_x)
void sinfo_new_destroy_2Dintarray (int ***array, int size_x)
void sinfo_new_intarray_set_value (int *array, int value, int i)
float sinfo_new_array2D_get_value (float **array, int x, int y)
int ** sinfo_new_2Dintarray (int size_x, int size_y)
float * sinfo_new_floatarray (int size)
void sinfo_new_destroy_2Dfloatarray (float ***array, int size_x)
void sinfo_new_destroy_2Ddoublearray (double ***array, int size_x)
void sinfo_new_array2D_set_value (float **array, float value, int x, int y)
double sinfo_new_doublearray_get_value (double *array, int i)
void sinfo_new_doublearray_set_value (double *array, double value, int i)
void sinfo_new_destroy_doublearray (double *array)
double * sinfo_new_doublearray (int size)
double ** sinfo_new_2Ddoublearray (int size_x, int size_y)
float ** sinfo_new_2Dfloatarray (int size_x, int size_y)
int * sinfo_new_intarray (int size)
void sinfo_new_destroy_intarray (int **array)
int sinfo_new_intarray_get_value (int *array, int i)
float sinfo_new_Stats_get_cleanstdev (Stats *stats)
float sinfo_new_Stats_get_cleanmean (Stats *stats)
char * sinfo_new_get_basename (const char *filename)
char * sinfo_new_get_rootname (const char *filename)
cpl_imagelist * sinfo_new_frameset_to_iset (cpl_frameset *fset)
 Convert a NACO frameset to an images set.
cpl_imagelist * sinfo_new_imagelist_load_frameset (const cpl_frameset *frameset, cpl_type type, int pnum, int extnum)
 Load an imagelist from a frameset.
char ** sinfo_new_frameset_to_filenames (cpl_frameset *set, int *nfiles)
 Get the list of filenames from a cpl_frameset.
double sinfo_spline_hermite (double xp, const double *x, const double *y, int n, int *istart)
 Spline interpolation based on Hermite polynomials.
cpl_error_code update_bad_pixel_map (cpl_image *im)
 Update the bad pixel map for the image - mark all pixels with NaN value as a bad.
cpl_polynomial * sinfo_polynomial_fit_2d_create (cpl_bivector *xy_pos, cpl_vector *values, int degree, double *mse)
cpl_polynomial * sinfo_polynomial_fit_1d_create (const cpl_vector *x_pos, const cpl_vector *values, int degree, double *mse)
cpl_image * sinfo_image_filter_median (const cpl_image *img, const cpl_matrix *mx)
cpl_image * sinfo_image_filter_linear (const cpl_image *img, const cpl_matrix *mx)

Detailed Description

TBD


Function Documentation

char** sinfo_new_frameset_to_filenames ( cpl_frameset *  set,
int *  nfiles 
)

Get the list of filenames from a cpl_frameset.

Parameters:
set input frame set
nfiles the number of file names returned
Returns:
the newly allocated list of filenames

Definition at line 822 of file sinfo_utilities.c.

Referenced by sinfo_new_frameset_to_iset().

cpl_imagelist* sinfo_new_frameset_to_iset ( cpl_frameset *  fset  ) 

Convert a NACO frameset to an images set.

Parameters:
fset input frames set
Returns:
the newly allocated images set or NULL in error case

The first plane of the primary unit of each frame is loaded

Definition at line 720 of file sinfo_utilities.c.

References sinfo_msg_error, sinfo_new_frameset_to_filenames(), and sinfo_new_imagelist_load_frameset().

cpl_imagelist* sinfo_new_imagelist_load_frameset ( const cpl_frameset *  frameset,
cpl_type  type,
int  pnum,
int  extnum 
)

Load an imagelist from a frameset.

Parameters:
frameset A frameset containing name(s) of image FITS files
type cpl_type
pnum The plane (FITS NAXIS3) number (0 for all planes)
extnum The required FITS extension (-1 for all)
Returns:
The newly created imagelist or NULL on error
See also:
cpl_imset_load()

Definition at line 763 of file sinfo_utilities.c.

Referenced by sinfo_new_frameset_to_iset().

int sinfo_parameter_get_default_flag ( const cpl_parameter *  p  ) 

Check if an input parameter has been changed by the user.

Parameters:
p input parameter
Returns:
if has not changed 0, else 1;

Definition at line 99 of file sinfo_utils.c.

long sinfo_round_double ( double  x  ) 

Round a number to the nearest integer.

Parameters:
x The number to round
Returns:
Nearest integer

This is implemented as a function rather than a macro to avoid multiple evaluations of expressions that have side effects.

Definition at line 89 of file sinfo_utils.c.

Referenced by sinfo_select_table_rows().

double sinfo_spline_hermite ( double  xp,
const double *  x,
const double *  y,
int  n,
int *  istart 
)

Spline interpolation based on Hermite polynomials.

Parameters:
xp x-value to interpolate
x x-values
y y-values
n array length
istart (input/output) initial row (set to 0 to search all row)
Returns:
The interpolated value.

The x column must be sorted (ascending or descending) and all x column values must be different.

Adopted from: Cristian Levin - ESO La Silla, 1-Apr-1991

Definition at line 879 of file sinfo_utilities.c.

cpl_image* sinfo_vector_to_image ( const cpl_vector *  vector,
cpl_type  type 
)

Convert a vector to a 1d image.

Parameters:
vector to convert
type of image
Returns:
a new allocated 1d image whose elements are the same as the vector The image need to be allocated .

Definition at line 47 of file sinfo_utilities.c.

References sinfo_free_image().

cpl_error_code update_bad_pixel_map ( cpl_image *  im  ) 

Update the bad pixel map for the image - mark all pixels with NaN value as a bad.

Parameters:
im Image with pixel-type float or double
Returns:
0 iff ok

Definition at line 944 of file sinfo_utilities.c.


Generated on 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1