ifw-odp  2.0.0-alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
clipm_priv_array.c File Reference
#include "clipm_priv_array.h"
#include "clipm_math.h"
#include "clipm_compatibility_replacements.h"
#include "clipm_priv_checks.h"
#include "clipm_priv_error.h"
#include "clipm_priv_image.h"
#include <string.h>

Functions

cpl_array * clipm_priv_array_new_from_image_row (const cpl_image *image, cpl_size row_ndx)
 Extract an image row and store it in an array. More...
 
cpl_array * clipm_priv_array_new_from_image_col (const cpl_image *image, cpl_size col_ndx)
 Extract an image column and store it in an array. More...
 
double clipm_priv_array_estimate_fwhm (const cpl_array *input, double centre, double bg_level, cpl_size *out_maxindex, double *out_middlepos, double *out_edgeslope)
 Search maximum from given centre position and find FWHM. More...
 
void clipm_priv_array_null (cpl_array **a)
 Delete a CPL array object and set the pointer to NULL. More...
 

Function Documentation

double clipm_priv_array_estimate_fwhm ( const cpl_array *  input,
double  centre,
double  bg_level,
cpl_size *  out_maxindex,
double *  out_middlepos,
double *  out_edgeslope 
)

Search maximum from given centre position and find FWHM.

Parameters
inputInput vector
centreCentre position
bg_levelBackground level
out_maxindex(Optional output) index of found maximum value, can be NULL
out_middlepos(Optional output) middle position between left and right FWHM edges, can be NULL
out_edgeslope(Optional output) steepness of the edges, returns -1.0 if unsuccessful, can be NULL
Returns
Full-width-half-maximum, -1.0 in the case of error
Principle:
  • The maximum is searched in ascending direction.
  • From the maximum's position, the borders where the signal falls below the mean of the maximum and bg_level are searched.
  • If out_edgeslope is given, then the steepness is measured between the 30% and 70% percent levels. This is done for both end, if one fails, then the other value is returned, otherwise the mean of both.
Note
  • out_maxindex does not return the position of the maximum value of the whole input vector, but of the maximum found by starting at centre.
  • This function jumps over "bad" flagges regions.
  • The FWHM is interpolated using non-bad values.
  • If out_edgeslope can not be computed, NO error is set
Error Handling:
  • In the case of error, all output values are set to -1.
  • The following error codes can be set by this function:
    • CPL_ERROR_NULL_INPUT: input vector is NULL
    • CPL_ERROR_ACCESS_OUT_OF_RANGE: centre is outside the input vector range
    • CPL_ERROR_INVALID_TYPE: input is not of type CPL_TYPE_INT, CPL_TYPE_FLOAT or CPL_TYPE_DOUBLE
    • CPL_ERROR_CONTINUE: the FWHM could not be found, or the peak is not brighter than bg_level
    • CPL_ERROR_DATA_NOT_FOUND: too many bad pixels prevent the computation of the FWHM
Todo:
  • Force _clipm_priv_vector_find_limits() to fail in unit test
  • Check out_edgeslope in unit test, also with flat object
cpl_array* clipm_priv_array_new_from_image_col ( const cpl_image *  image,
cpl_size  col_ndx 
)

Extract an image column and store it in an array.

Parameters
imageInput image
col_ndxColumn index (FITS convention)
Returns
The new array
Bad Pixel Handling:
  • Bad pixels will lead to invalid entried in the output array.
Error Handling:
The following errors can occur:
  • CPL_ERROR_NULL_INPUT: image is NULL
  • CPL_ERROR_INVALID_TYPE: image is not of type CPL_TYPE_INT, CPL_TYPE_FLOAT or CPL_TYPE_DOUBLE
  • CPL_ERROR_ACCESS_OUT_OF_RANGE: col_ndx is outside the horizontal image range
cpl_array* clipm_priv_array_new_from_image_row ( const cpl_image *  image,
cpl_size  row_ndx 
)

Extract an image row and store it in an array.

Parameters
imageInput image
row_ndxRow index (FITS convention)
Returns
The new array
Bad Pixel Handling:
  • Bad pixels will lead to invalid entried in the output array.
Error Handling:
The following errors can occur:
  • CPL_ERROR_NULL_INPUT: image is NULL
  • CPL_ERROR_INVALID_TYPE: image is not of type CPL_TYPE_INT, CPL_TYPE_FLOAT or CPL_TYPE_DOUBLE
  • CPL_ERROR_ACCESS_OUT_OF_RANGE: row_ndx is outside the vertical image range
void clipm_priv_array_null ( cpl_array **  a)

Delete a CPL array object and set the pointer to NULL.

Parameters
aPointer to array pointer
Returns
Nothing

The following code is executed:

if (a != NULL)
{
cpl_array_delete(*a); // checks for NULL pointer
*a = NULL;
}
*
Error Handling:
No error can occur here.