MUSE Pipeline Reference Manual  1.0.2
Data Structures | Enumerations | Functions
CPL wrappers

Data Structures

struct  muse_cpltable_def
 Definition of a cpl table structure. More...
 

Enumerations

enum  muse_cplframework_type { MUSE_CPLFRAMEWORK_UNKNOWN = 0, MUSE_CPLFRAMEWORK_ESOREX = 1, MUSE_CPLFRAMEWORK_PYTHONCPL = 2, MUSE_CPLFRAMEWORK_GASGANO = 3 }
 Type for the framework that called the recipe. More...
 

Functions

cpl_error_code muse_cplimage_or (cpl_image *aTarget, const cpl_image *aImage, unsigned int mask)
 Provide an 'OR' operation of two integer images. More...
 
cpl_image * muse_cplimage_concat_y (const cpl_image *aImage1, const cpl_image *aImage2)
 Concatenate two images in y direction. More...
 
cpl_image * muse_cplimage_concat_x (const cpl_image *aImage1, const cpl_image *aImage2)
 Concatenate two images in x direction. More...
 
cpl_image * muse_cplimage_filter_median_subtract (cpl_image *aImage, unsigned int aNX, unsigned int aNY)
 Subtract a median-filtered version of the input image from itself. More...
 
cpl_vector * muse_cplimage_slope_window (const cpl_image *aImage, const cpl_size *aWindow)
 Compute slopes of an image, both horizontally and vertically. More...
 
double muse_cplimage_get_percentile (const cpl_image *aImage, double aFraction)
 Get the percentile of an image. More...
 
cpl_image * muse_cplimagelist_collapse_or_create (const cpl_imagelist *imlist)
 Compute the OR of an image list to a single image. More...
 
cpl_mask * muse_cplmask_adapt_to_image (const cpl_mask *aMask, const cpl_image *aImage)
 Adapt mask with masked region in one quadrant to size of an image. More...
 
double muse_cplvector_get_adev_const (const cpl_vector *aVector, double aCenter)
 Compute the average absolute deviation of a (constant) vector. More...
 
double muse_cplvector_get_median_dev (cpl_vector *aVector, double *aMedian)
 Compute the median and average absolute deviation against the median of a vector. More...
 
double muse_cplvector_get_semiquartile (cpl_vector *aVector)
 compute the semi-quartile range of a vector of elements More...
 
cpl_error_code muse_cplvector_threshold (cpl_vector *aVec, double aLoCut, double aHiCut, double aLoVal, double aHiVal)
 Threshold a vector to a given interval. More...
 
cpl_error_code muse_cplvector_erase_element (cpl_vector *aVector, int aElement)
 delete the given element from the input vector More...
 
cpl_size muse_cplvector_count_unique (const cpl_vector *aVector)
 Count the number of unique entries in a given vector. More...
 
cpl_vector * muse_cplvector_get_unique (const cpl_vector *aVector)
 Separate out all unique entries in a given vector into a new one. More...
 
cpl_table * muse_cpltable_new (const muse_cpltable_def *aDef, cpl_size aLength)
 Create an empty table according to the specified definition. More...
 
cpl_table * muse_cpltable_load (const char *aFile, const char *aExtension, const muse_cpltable_def aDefinition[])
 Load a table from disk (and check against definition). More...
 
cpl_error_code muse_cpltable_append_file (const cpl_table *aTable, const char *aFile, const char *aExtension, const muse_cpltable_def aDefinition[])
 Save a table to disk (into a FITS extension) More...
 
cpl_error_code muse_cpltable_check (const cpl_table *aTable, const muse_cpltable_def *aDef)
 Check whether the table contains the fields of the definition. More...
 
cpl_array * muse_cpltable_extract_column (cpl_table *aTable, const char *aColumn)
 Create an array from a section of a column. More...
 
cpl_error_code muse_cpltable_copy_array (cpl_table *aTable, const char *aColumn, const cpl_array *aArray)
 Copy an array into a table. More...
 
cpl_array * muse_cpltable_get_array_copy (cpl_table *aTable, const char *aColumn, cpl_size aRow)
 Return the copy of an array of a table cell. More...
 
cpl_size muse_cpltable_find_sorted (const cpl_table *aTable, const char *aColumn, double aValue)
 Find a row in a table. More...
 
cpl_array * muse_cplarray_new_from_image (const cpl_image *aImage)
 Copy the image data into an array. More...
 
cpl_error_code muse_cplarray_poly1d (cpl_array *aArray, const cpl_array *aCoeff)
 Apply a polynomial to an array. More...
 
double muse_cplarray_poly1d_double (double aDouble, const cpl_array *aCoeff)
 Apply a polynomial to a double value. More...
 
cpl_error_code muse_cplarray_dump_name (const cpl_array *aArray, const char *aName)
 Dump a numerical array to stdout with a name prefixed to each line. More...
 
cpl_error_code muse_cplarray_erase_invalid (cpl_array *aArray)
 Erase all invalid values from an array. More...
 
cpl_size muse_cplarray_erase_outliers (cpl_array *aArray, const cpl_bivector *aHistogram, cpl_size aGap, double aLimit)
 Erase outliers from an array using histogram information. More...
 
cpl_error_code muse_cplarray_sort (cpl_array *aArray, cpl_boolean aOrder)
 Sort float, int or double array by quicksort. More...
 
cpl_bivector * muse_cplarray_histogram (const cpl_array *aArray, double aWidth, double aMin, double aMax)
 Create a histogram for a numerical array. More...
 
cpl_size muse_cplarray_find_sorted (const cpl_array *aArray, double aValue)
 Find a row in an array. More...
 
cpl_boolean muse_cplarray_has_duplicate (const cpl_array *aArray)
 Check, if an array contains duplicate values. More...
 
cpl_array * muse_cplarray_extract (cpl_array *aArray, cpl_size aStart, cpl_size aCount)
 Create an array from a section of another array. More...
 
cpl_error_code muse_cplarray_add_window (cpl_array *aDest, cpl_size aStart, const cpl_array *aArray)
 Add the value of an array to a window of a table column. More...
 
cpl_array * muse_cplarray_diff (const cpl_array *aArray, int aOffset)
 Build the difference of any element and one of the next elements. More...
 
cpl_error_code muse_cplarray_erf (cpl_array *aArray)
 Compute the error function of array elements. More...
 
cpl_error_code muse_cplarray_exp (cpl_array *aArray)
 Compute the exponential function of array elements. More...
 
cpl_array * muse_cplarray_interpolate_linear (const cpl_array *aTargetAbscissa, const cpl_array *aSourceAbscissa, const cpl_array *aSourceOrdinate)
 Linear interpolation of a 1d array. More...
 
cpl_array * muse_cplarray_interpolate_table_linear (const cpl_array *aTargetAbscissa, const cpl_table *aSrcTable, const char *aSrcAbscissa, const char *aSrcOrdinate)
 Linear interpolation of a 1d column. More...
 
cpl_array * muse_cplarray_new_from_delimited_string (const char *aString, const char *aDelim)
 Convert a delimited string into an array of strings. More...
 
cpl_array * muse_cplarray_string_to_double (const cpl_array *aArray)
 Convert a string array into an array of type double. More...
 
cpl_parameter * muse_cplparamerterlist_find_prefix (cpl_parameterlist *aParameters, const char *aPrefix, const char *aName)
 Return the full recipe parameter belonging to prefix and shortname. More...
 
cpl_parameterlist * muse_cplparameterlist_from_propertylist (const cpl_propertylist *aHeader, int aRecNum)
 Recreate a cpl_parameterlist from the RECi headers of an output MUSE product. More...
 
cpl_parameterlist * muse_cplparameterlist_duplicate (const cpl_parameterlist *aPList)
 Duplicate a CPL parameter list. More...
 
cpl_error_code muse_cplpropertylist_update_long_long (cpl_propertylist *aHeader, const char *aKeyword, cpl_size aValue)
 Update an integer-like property irrespective of the real type. More...
 
cpl_error_code muse_cplframeset_erase_all (cpl_frameset *aFrames)
 Erase all frames in a frameset. More...
 
cpl_error_code muse_cplframeset_erase_duplicate (cpl_frameset *aFrames)
 Erase all duplicate frames from a frameset. More...
 
void muse_cplerrorstate_dump_some (unsigned aCurrent, unsigned aFirst, unsigned aLast)
 Dump some CPL errors. More...
 
muse_cplframework_type muse_cplframework (void)
 Return the CPL framework the recipe is run under. More...
 

Detailed Description

This group handles several utility functions that are convenient wrappers of CPL functions or functions that could extend CPL.

Currently there are functions that work on cpl_image, cpl_imagelist, cpl_vector, cpl_table, and cpl_array objects.

Enumeration Type Documentation

Type for the framework that called the recipe.

Enumerator
MUSE_CPLFRAMEWORK_UNKNOWN 

Unknown framework type

MUSE_CPLFRAMEWORK_ESOREX 

Recipe was called from EsoREX

MUSE_CPLFRAMEWORK_PYTHONCPL 

Recipe was called from python-cpl

MUSE_CPLFRAMEWORK_GASGANO 

Recipe was called from gasgano

Definition at line 73 of file muse_cplwrappers.h.

Function Documentation

cpl_error_code muse_cplarray_add_window ( cpl_array *  aDest,
cpl_size  aStart,
const cpl_array *  aArray 
)

Add the value of an array to a window of a table column.

Parameters
aDestPointer to destination array.
aStartFirst row to be added.
aArrayArray to be added.
Return values
CPL_ERROR_NONEEverything went OK
CPL_ERROR_NULL_INPUT(aDest && aArray) not fulfilled

The columns are summed element by element, and the result of the sum is stored in the target column. Only arrays of types CPL_TYPE_DOUBLE, CPL_TYPE_FLOAT, and CPL_TYPE_INT are supported. The validity of cells is ignored here.

Definition at line 1608 of file muse_cplwrappers.c.

References muse_cplarray_extract().

Referenced by muse_lsf_line_apply().

cpl_array* muse_cplarray_diff ( const cpl_array *  aArray,
int  aOffset 
)

Build the difference of any element and one of the next elements.

Parameters
aArrayInput array
aOffsetnumber of rows to step ahead.
Returns
The array with the differences.
Exceptions
set CPL_ERROR_NULL_INPUT, return NULL(aArray) not fulfilled
set CPL_ERROR_ILLEGAL_INPUT, return NULL(aOffset > 0) not fulfilled

Definition at line 1635 of file muse_cplwrappers.c.

cpl_error_code muse_cplarray_dump_name ( const cpl_array *  aArray,
const char *  aName 
)

Dump a numerical array to stdout with a name prefixed to each line.

Parameters
aArrayPointer to the array.
aNameName of the array.
Returns
CPL_ERROR_NONE or another CPL error on failure.
Exceptions
return CPL_ERROR_NULL_INPUTone of the input arguments is NULL

Definition at line 1166 of file muse_cplwrappers.c.

cpl_error_code muse_cplarray_erase_invalid ( cpl_array *  aArray)

Erase all invalid values from an array.

Parameters
aArrayPointer to the array.
Return values
CPL_ERROR_NULL_INPUT(aArray != NULL) not fulfilled

Definition at line 1185 of file muse_cplwrappers.c.

Referenced by muse_cplarray_erase_outliers(), muse_cplimage_get_percentile(), muse_geo_compute_pinhole_local_distance(), and muse_geo_refine_horizontal().

cpl_size muse_cplarray_erase_outliers ( cpl_array *  aArray,
const cpl_bivector *  aHistogram,
cpl_size  aGap,
double  aLimit 
)

Erase outliers from an array using histogram information.

Parameters
aArraythe input array
aHistogramhistogram to use
aGapsize of the gap in the histogram to separate outliers
aLimitthe limit below which values count as gap
Returns
The number of erased array entries of a negative value on failure.
Warning
Pre-existing invalid entries in aArray are erased and counted, too.
Exceptions
return CPL_ERROR_NULL_INPUT, return -1aArray or aHistogram are NULL
return CPL_ERROR_INVALID_TYPE, return -2aArray is not of numerical type (element zero cannot be read with cpl_array_get())

Definition at line 1227 of file muse_cplwrappers.c.

References muse_cplarray_erase_invalid().

Referenced by muse_geo_compute_pinhole_global_distance(), and muse_geo_refine_horizontal().

cpl_error_code muse_cplarray_erf ( cpl_array *  aArray)

Compute the error function of array elements.

Parameters
aArrayPointer to array.
Return values
CPL_ERROR_NONEEverything went OK
CPL_ERROR_NULL_INPUT(aArray) not fulfilled
CPL_ERROR_ILLEGAL_INPUT(Supported data type) not fulfilled

Each column element is replaced by its error function. This function only works with CPL_TYPE_DOUBLE and CPL_TYPE_FLOAT arrays. The validity of cells is ignored.

Definition at line 1668 of file muse_cplwrappers.c.

Referenced by muse_lsf_G().

cpl_error_code muse_cplarray_exp ( cpl_array *  aArray)

Compute the exponential function of array elements.

Parameters
aArrayPointer to array.
Return values
CPL_ERROR_NONEEverything went OK
CPL_ERROR_NULL_INPUT(aArray) not fulfilled
CPL_ERROR_ILLEGAL_INPUT(Supported data type) not fulfilled

Each column element is replaced by its exponential function. This function only works with CPL_TYPE_DOUBLE and CPL_TYPE_FLOAT arrays. The validity of cells is ignored.

Definition at line 1707 of file muse_cplwrappers.c.

Referenced by muse_lsf_G().

cpl_array* muse_cplarray_extract ( cpl_array *  aArray,
cpl_size  aStart,
cpl_size  aCount 
)

Create an array from a section of another array.

Parameters
aArrayInput array
aStartFirst element.
aCountNumber of elements
Return values
CPL_ERROR_NONEEverything went OK

This function is like cpl_array_extract and differs in that it uses the same data vector as the original one. So, changing values in the new array will also change these values in the original array. The new array should not be deleted, but unwrapped.

Definition at line 1571 of file muse_cplwrappers.c.

Referenced by muse_cplarray_add_window().

cpl_size muse_cplarray_find_sorted ( const cpl_array *  aArray,
double  aValue 
)

Find a row in an array.

Parameters
aArrayPointer to the array.
aValueValue to search.
Returns
The row index, or 0 on error.
Exceptions
set CPL_ERROR_NULL_INPUT, return 0(aArray != NULL) not fulfilled
set CPL_ERROR_ILLEGAL_INPUT, return 0(Supported data type) not fulfilled

This function assumes that the array is sorted. It then searches the last index where the value value is smaller than the specified value. The validity is ignored here.

Definition at line 1455 of file muse_cplwrappers.c.

Referenced by muse_cplarray_interpolate_linear(), muse_cpltable_find_sorted(), and muse_lsf_line_apply().

cpl_boolean muse_cplarray_has_duplicate ( const cpl_array *  aArray)

Check, if an array contains duplicate values.

Parameters
aArrayPointer to the array.
Returns
CPL_TRUE, if duplicates were detected, CPL_FALSE otherwise.

This is a very simple (and slow!) routine that just compares all values against all others, and stops when it detected a duplicate.

Note
This function currently only works for integer types.
Exceptions
set CPL_ERROR_NULL_INPUT, return CPL_FALSENULL input array
set CPL_ERROR_UNSUPPORTED_MODE, return CPL_FALSEarray is of non-integer type

Definition at line 1516 of file muse_cplwrappers.c.

Referenced by muse_wcs_solve().

cpl_bivector* muse_cplarray_histogram ( const cpl_array *  aArray,
double  aWidth,
double  aMin,
double  aMax 
)

Create a histogram for a numerical array.

Parameters
aArraythe input array
aWidththe bin width
aMinlower histogram limit, can be NAN
aMaxupper histogram limit, can be NAN
Returns
A bivector containing the histogram (x component contain the values, y component contains the histogram counts).
Note
aMin and aMax can be NAN to signify an automatic computation of the limits using the exreme value(s) of the input array.
Exceptions
return CPL_ERROR_NULL_INPUT, return NULLaArray is NULL
return CPL_ERROR_INVALID_TYPE, return NULLaArray is not of numerical type (element zero cannot be read with cpl_array_get())
return CPL_ERROR_ILLEGAL_INPUT, return NULLaMin is not less than aMax

Definition at line 1386 of file muse_cplwrappers.c.

Referenced by muse_geo_compute_pinhole_global_distance(), and muse_geo_refine_horizontal().

cpl_array* muse_cplarray_interpolate_linear ( const cpl_array *  aTargetAbscissa,
const cpl_array *  aSourceAbscissa,
const cpl_array *  aSourceOrdinate 
)

Linear interpolation of a 1d array.

Parameters
aTargetAbscissaTarget abscissa (x) array
aSourceAbscissaTarget abscissa (x) array
aSourceOrdinateTarget ordinate (y) array @return Target ordinate (y) array
Return values
CPL_ERROR_NULL_INPUT(aTargetAbscissa) not fulfilled
CPL_ERROR_NULL_INPUT(aSourceAbscissa) not fulfilled
CPL_ERROR_NULL_INPUT(aSourceOrdinate) not fulfilled
CPL_ERROR_ILLEGAL_INPUT(any data column is not double) not fulfilled

The linear interpolation will be done from the values in the source table to the abscissa points in the target table.

The abscissa points of both source and target tables must be growing.

The abscissa points of the target must be in range of those of the source (i.e. extrapolation is not allowed).

The source table must be of at least length 2.

Definition at line 1757 of file muse_cplwrappers.c.

References muse_cplarray_find_sorted().

Referenced by muse_cplarray_interpolate_table_linear().

cpl_array* muse_cplarray_interpolate_table_linear ( const cpl_array *  aTargetAbscissa,
const cpl_table *  aSrcTable,
const char *  aSrcAbscissa,
const char *  aSrcOrdinate 
)

Linear interpolation of a 1d column.

Parameters
aTargetAbscissaTarget abscissa (x) array
aSrcTableSource table
aSrcAbscissaTarget abscissa (x) column
aSrcOrdinateTarget ordinate (y) column @return Target ordinate (y) column

The linear interpolation will be done from the values in the source table to the abscissa points in the target table.

The abscissa points of both source and target tables must be growing.

The abscissa points of the target must be in range of those of the source (i.e. extrapolation is not allowed).

The source table must be of at least length 2.

Definition at line 1826 of file muse_cplwrappers.c.

References muse_cplarray_interpolate_linear(), and muse_cpltable_extract_column().

cpl_array* muse_cplarray_new_from_delimited_string ( const char *  aString,
const char *  aDelim 
)

Convert a delimited string into an array of strings.

Parameters
aStringthe input string
aDelimthe delimiting string
Returns
CPL_ERROR_NONE on success or a cpl_error_code on failure

This function acts a bit like strtok(), just that it finds all tokens in one go, and takes the aDelim as a single delimiter. It is hopefully threadsafe, unlike strtok(). Consecutive occurrences of aDelim are ignored, i.e. the output array does not contain empty strings.

Exceptions
return CPL_ERROR_NULL_INPUT, return NULLaString or aDelim are NULL

Definition at line 1857 of file muse_cplwrappers.c.

Referenced by muse_geo_refine_horizontal(), muse_postproc_check_save_param(), muse_postproc_cube_resample_and_collapse(), and muse_xcombine_tables().

cpl_array* muse_cplarray_new_from_image ( const cpl_image *  aImage)

Copy the image data into an array.

Parameters
aImageSource image
Returns
The created array, or NULL on error.

The validity of values will be copied, too.

Definition at line 1066 of file muse_cplwrappers.c.

Referenced by muse_cplimage_get_percentile().

cpl_error_code muse_cplarray_poly1d ( cpl_array *  aArray,
const cpl_array *  aCoeff 
)

Apply a polynomial to an array.

Parameters
aArrayPointer to array
aCoeffPolynomial coefficients. First coefficient is lowest order (constant).
Return values
CPL_ERROR_NONEEverything went OK.

If the length of the coefficient array is zero, all values of the value are are set to zero. No error is set in this case.

Exceptions
return CPL_ERROR_NULL_INPUTone of the input arguments is NULL

Definition at line 1101 of file muse_cplwrappers.c.

Referenced by muse_lsf_G(), and muse_sky_apply_lsf().

double muse_cplarray_poly1d_double ( double  aDouble,
const cpl_array *  aCoeff 
)

Apply a polynomial to a double value.

Parameters
aDoubleArgument.
aCoeffPolynomial coefficients. First coefficient is lowest order (constant).
Returns
The result
Exceptions
set CPL_ERROR_NULL_INPUT, return NAN(aCoeff) not fulfilled

If the length of the coefficient array is zero, 0.0 is returned. No error is set in this case.

Definition at line 1139 of file muse_cplwrappers.c.

Referenced by muse_lsf_line_apply().

cpl_error_code muse_cplarray_sort ( cpl_array *  aArray,
cpl_boolean  aOrder 
)

Sort float, int or double array by quicksort.

Parameters
aArrayPointer to the array.
aOrderSort order of the array, ascending if true
Return values
CPL_ERROR_NULL_INPUT(aArray != NULL) not fulfilled
CPL_ERROR_NULL_INPUT(!cpl_array_has_invalid(aArray)) not fulfilled

This function currently only works with arrays that have no invalid values.

Definition at line 1342 of file muse_cplwrappers.c.

Referenced by muse_cplimage_get_percentile().

cpl_array* muse_cplarray_string_to_double ( const cpl_array *  aArray)

Convert a string array into an array of type double.

Parameters
aArraythe input string array
Returns
a new array of CPL_TYPE_DOUBLE on success or NULL on failure

This function assumes that every element of the string array contains a number and does element-wise conversions using atof().

The returned array has to be deallocated using cpl_array_delete() after use.

Exceptions
return CPL_ERROR_NULL_INPUT, return NULLaArray is NULL
return CPL_ERROR_ILLEGAL_INPUT, return NULLaArray is not of type CPL_TYPE_STRING

Definition at line 1906 of file muse_cplwrappers.c.

void muse_cplerrorstate_dump_some ( unsigned  aCurrent,
unsigned  aFirst,
unsigned  aLast 
)

Dump some CPL errors.

Parameters
aCurrentThe number of the current error to be dumped
aFirstThe number of the first error to be dumped
aLastThe number of the last error to be dumped
See also
cpl_errorstate_dump_one

By default, the last 20 error messages are dumped. This can be changed by setting the environment variable MUSE_CPL_ERRORSTATE_NDUMP to a positive value.

Definition at line 2252 of file muse_cplwrappers.c.

Referenced by muse_postproc_process_exposure().

cpl_error_code muse_cplframeset_erase_all ( cpl_frameset *  aFrames)

Erase all frames in a frameset.

Parameters
aFramesthe frame set to clean out
Returns
CPL_ERROR_NONE on success another cpl_error_code on failure
Warning
This function is not threadsafe when used on the same frame set.
Exceptions
set and return CPL_ERROR_NULL_INPUTaFrames is NULL
propagate return codecpl_frameset_erase_frame() fails

Definition at line 2140 of file muse_cplwrappers.c.

cpl_error_code muse_cplframeset_erase_duplicate ( cpl_frameset *  aFrames)

Erase all duplicate frames from a frameset.

Parameters
aFramesthe frame set to clean up
Returns
CPL_ERROR_NONE on success another cpl_error_code on failure

This function loops through all frames except the last one in the input frameset and compares this "reference" frame to all following frames. If it finds a frame for which all properties match, it uses the reference frame to erase one. (If it erased one frame in this way, it stays are the same position, because CPL always erases the first frame that it finds.)

Warning
This function is not threadsafe when used on the same frame set.
Exceptions
set and return CPL_ERROR_NULL_INPUTaFrames is NULL
propagate return codecpl_frameset_erase_frame() fails

Definition at line 2171 of file muse_cplwrappers.c.

muse_cplframework_type muse_cplframework ( void  )

Return the CPL framework the recipe is run under.

Return values
MUSE_CPLFRAMEWORK_ESOREXThe recipe was called from EsoRex.
MUSE_CPLFRAMEWORK_PYTHONCPLThe recipe was called from python-cpl, or another Python-based framework.
MUSE_CPLFRAMEWORK_GASGANOThe recipe was called from Gasgano, or another Java-based framework.
MUSE_CPLFRAMEWORK_UNKNOWNThe framework is unknown.

This function currently works properly only under Linux. Under MacOSX, it will always return MUSE_CPLFRAMEWORK_UNKNOWN.

Definition at line 2299 of file muse_cplwrappers.c.

References MUSE_CPLFRAMEWORK_ESOREX, MUSE_CPLFRAMEWORK_GASGANO, MUSE_CPLFRAMEWORK_PYTHONCPL, and MUSE_CPLFRAMEWORK_UNKNOWN.

cpl_image* muse_cplimage_concat_x ( const cpl_image *  aImage1,
const cpl_image *  aImage2 
)

Concatenate two images in x direction.

Parameters
aImage1First image
aImage2Second image
Returns
Concatenated image
Exceptions
set CPL_ERROR_NULL_INPUT, return NULL(aImage1 || aImage2) not fulfilled
set CPL_ERROR_ILLEGAL_INPUT, return NULL(cpl_image_get_type(aImage1) == cpl_image_get_type(aImage2)) not fulfilled
set CPL_ERROR_ILLEGAL_INPUT, return NULL(cpl_image_get_size_y(aImage1) == cpl_image_get_size_y(aImage2)) not fulfilled

If one of the pointers is NULL, just return a copy of the other image. If both input images are NULL, fail. The returned image has to be deallocated using cpl_image_delete().

Definition at line 159 of file muse_cplwrappers.c.

Referenced by muse_resampling_image().

cpl_image* muse_cplimage_concat_y ( const cpl_image *  aImage1,
const cpl_image *  aImage2 
)

Concatenate two images in y direction.

Parameters
aImage1First image
aImage2Second image
Returns
Concatenated image
Exceptions
set CPL_ERROR_NULL_INPUT, return NULL(aImage1 || aImage2) not fulfilled
set CPL_ERROR_ILLEGAL_INPUT, return NULL(cpl_image_get_type(aImage1) == cpl_image_get_type(aImage2)) not fulfilled
set CPL_ERROR_ILLEGAL_INPUT, return NULL(cpl_image_get_size_x(aImage1) == cpl_image_get_size_x(aImage2)) not fulfilled

If one of the pointers is NULL, just return a copy of the other image. If both input images are NULL, fail. The returned image has to be deallocated using cpl_image_delete().

Definition at line 115 of file muse_cplwrappers.c.

cpl_image* muse_cplimage_filter_median_subtract ( cpl_image *  aImage,
unsigned int  aNX,
unsigned int  aNY 
)

Subtract a median-filtered version of the input image from itself.

Parameters
aImageImage to be filtered and subtracted from
aNXMedian filter width, has to be odd
aNYMedian filter height, has to be odd
Returns
The subtracted image or NULL on error.
Exceptions
set CPL_ERROR_NULL_INPUT, return NULLinput image is NULL
set CPL_ERROR_ILLEGAL_INPUT, return NULLaNX or aNY are even

Definition at line 203 of file muse_cplwrappers.c.

double muse_cplimage_get_percentile ( const cpl_image *  aImage,
double  aFraction 
)

Get the percentile of an image.

Parameters
aImageinput image
aFractionFraction of the total number of pixels
Returns
Threshold where the number of pixels below is the specified fraction of total valid pixels.
Exceptions
set CPL_ERROR_NULL_INPUT, return 0.0(aImage != NULL) not fulfilled

Definition at line 347 of file muse_cplwrappers.c.

References muse_cplarray_erase_invalid(), muse_cplarray_new_from_image(), and muse_cplarray_sort().

Referenced by muse_sky_create_skymask().

cpl_error_code muse_cplimage_or ( cpl_image *  aTarget,
const cpl_image *  aImage,
unsigned int  mask 
)

Provide an 'OR' operation of two integer images.

Parameters
aTargetthe first operand that will be the target image
aImagethe image that shall be appplied to the first
maskadditional mask to apply to each pixel.
Returns
CPL_ERROR_NONE if everything was OK
Remarks
This works only with data type CPL_TYPE_INT. The pixel mask is not used at all.
Exceptions
return CPL_ERROR_NULL_INPUTNULL input target or image
return CPL_ERROR_TYPE_MISMATCHthe passed image type is not CPL_TYPE_INT
return CPL_ERROR_ILLEGAL_INPUTthe input images have different sizes

Definition at line 77 of file muse_cplwrappers.c.

Referenced by muse_cplimagelist_collapse_or_create().

cpl_vector* muse_cplimage_slope_window ( const cpl_image *  aImage,
const cpl_size *  aWindow 
)

Compute slopes of an image, both horizontally and vertically.

Parameters
aImageImage to be investigated
aWindowImage window to use (integer array with 4 elements: xmin, xmax, ymin, ymax, see muse_quadrants_get_window())
Returns
A two-element cpl_vector * containing x- and y-slope or NULL on error.

Collapse the given image window along rows and columns, then fit a 1st-order polynomial to the values of both images to derive the slope in both directions.

Note
This function ignores any bad pixel mask set on the input image.
Exceptions
set CPL_ERROR_NULL_INPUT, return NULLaImage or aWindow are NULL
propagate error from cpl_image_collapse_window_create(), return NULLpositions given through aWindow are outside image
propagate error from cpl_polynomial_fit(), return NULLpolynomial fit fails

Definition at line 258 of file muse_cplwrappers.c.

cpl_image* muse_cplimagelist_collapse_or_create ( const cpl_imagelist *  imlist)

Compute the OR of an image list to a single image.

Parameters
imlistthe input images list
Returns
the image built by the OR operation of all images, or NULL in error case.

The returned image has to be deallocated with cpl_image_delete(). The input image list must be of type CPL_TYPE_INT.

Exceptions
set CPL_ERROR_NULL_INPUTany input pointer is NULL
set CPL_ERROR_ILLEGAL_INPUTthe input images have different sizes
set CPL_ERROR_INVALID_TYPEan image type is not CPL_TYPE_INT

Definition at line 379 of file muse_cplwrappers.c.

References muse_cplimage_or().

cpl_mask* muse_cplmask_adapt_to_image ( const cpl_mask *  aMask,
const cpl_image *  aImage 
)

Adapt mask with masked region in one quadrant to size of an image.

Parameters
aMaskmask to adapt
aImagereference imgae
Returns
a new mask on success, or NULL on error

If the input mask has a quadrant with many masked pixels (like a masked corner), this quadrant is extracted and copied into a new mask, so that its outer corner again comes to lie in the new corner.

Exceptions
set CPL_ERROR_NULL_INPUT, return NULLaMask and/or aImage are NULL
set CPL_ERROR_DATA_NOT_FOUND, return NULLaMask does not contain a quadrant with masked pixels
propagate CPL error, return NULLrelevant quadrant could not be copied into output mask of aImage-size

Definition at line 416 of file muse_cplwrappers.c.

cpl_parameter* muse_cplparamerterlist_find_prefix ( cpl_parameterlist *  aParameters,
const char *  aPrefix,
const char *  aName 
)

Return the full recipe parameter belonging to prefix and shortname.

Parameters
aParametersthe list of parameters
aPrefixthe prefix of the recipe
aNamename of this parameter
Returns
The parameter or NULL on error.

This function just concatenates aPrefix and aName with a dot in between and then searches for a parameter with this full name.

All error checking is already done inside cpl_parameterlist_find() which this function wraps.

Definition at line 1940 of file muse_cplwrappers.c.

Referenced by muse_basicproc_params_new(), and muse_combinepar_new().

cpl_parameterlist* muse_cplparameterlist_duplicate ( const cpl_parameterlist *  aPList)

Duplicate a CPL parameter list.

Parameters
aPListthe parameter list to duplicate
Returns
the duplicated parameter list or NULL on error.
Note
This function uses the CPL call cpl_parameterlist_get_next_const() to iterate through the list. The input list therefore must not be accessed at the same time from another thread.
Exceptions
set CPL_ERROR_NULL_INPUT, return NULLaPList is NULL

Definition at line 2074 of file muse_cplwrappers.c.

Referenced by muse_processing_new().

cpl_parameterlist* muse_cplparameterlist_from_propertylist ( const cpl_propertylist *  aHeader,
int  aRecNum 
)

Recreate a cpl_parameterlist from the RECi headers of an output MUSE product.

Parameters
aHeaderthe input FITS header
aRecNumthe number of the ESO.PRO.REC header, i.e. 1 for REC1
Returns
The parameterlist or NULL on error.

This takes ESO.PRO.RECi.ID and ESO.PRO.RECi.PIPE.ID to construct a context for parameters, and then loops through all ESO.PRO.RECi.PARAMj.{NAME,VALUE} keywords. It takes the content of the NAME keyword to set the parameter name, and then tries to determine the type of keyword from the contents of the string in VALUE and creates an entry in the parameterlist for each such entry.

Note
It may misidentify doubles as integers if the dot is missing!
It does currently not try to determine the parameter default value, hence the default of all parameters are unset!
Exceptions
set CPL_ERROR_NULL_INPUT, return NULLaHeader is NULL
set CPL_ERROR_ILLEGAL_INPUT, return NULLaRecNum is not positive
set CPL_ERROR_ILLEGAL_INPUT, return NULLno recipe name was found using ESO.PRO.RECi.ID
set CPL_ERROR_INCOMPATIBLE_INPUT, return NULLno muse pipeline ID was found using ESO.PRO.RECi.PIPE.ID

Definition at line 1976 of file muse_cplwrappers.c.

Referenced by muse_basicproc_params_new_from_propertylist().

cpl_error_code muse_cplpropertylist_update_long_long ( cpl_propertylist *  aHeader,
const char *  aKeyword,
cpl_size  aValue 
)

Update an integer-like property irrespective of the real type.

Parameters
aHeaderthe property list
aKeywordthe keyword to update
aValuethe value to set
Returns
CPL_ERROR_NONE on success another cpl_error_code on failure

Since cpl_propertylist_update_long_long() still fails if the type of the property in the list is CPL_TYPE_INT or CPL_TYPE_LONG instead of CPL_TYPE_LONG_LONG, this function makes it easier to update properties that can be any of those three. The user should take care that the value cannot overflow the actual variable type.

Exceptions
set and return CPL_ERROR_NULL_INPUTaHeader and/or aKeyword are NULL
set and return CPL_ERROR_DATA_NOT_FOUNDno property named aKeyword was found

Definition at line 2107 of file muse_cplwrappers.c.

Referenced by muse_pixtable_fix_exp_headers().

cpl_error_code muse_cpltable_append_file ( const cpl_table *  aTable,
const char *  aFile,
const char *  aExtension,
const muse_cpltable_def  aDefinition[] 
)

Save a table to disk (into a FITS extension)

Parameters
aTableTable to save.
aFileFile name
aExtensionExtension name
aDefinitionOptional table definition. If not NULL, table will be checked against this definition before saving.
Return values
CPL_ERROR_NONESuccess
CPL_ERROR_NULL_INPUT(aTable != NULL) not fulfilled
CPL_ERROR_NULL_INPUT(aFile != NULL) not fulfilled
CPL_ERROR_NULL_INPUT(aExtension != NULL) not fulfilled

This function saves the table as an extension. It requires that the file already exists with at least the main header.

Definition at line 859 of file muse_cplwrappers.c.

References muse_cpltable_check().

Referenced by muse_lsf_params_save(), muse_sky_lines_save(), and muse_sky_save_continuum().

cpl_error_code muse_cpltable_check ( const cpl_table *  aTable,
const muse_cpltable_def aDef 
)
cpl_error_code muse_cpltable_copy_array ( cpl_table *  aTable,
const char *  aColumn,
const cpl_array *  aArray 
)

Copy an array into a table.

Parameters
aTablePointer to table.
aColumnName of table column to be accessed.
aArrayArray to be copied
Return values
CPL_ERROR_NONEEverything went OK.
Exceptions
return CPL_ERROR_NULL_INPUTone of the input arguments is NULL

Definition at line 981 of file muse_cplwrappers.c.

Referenced by muse_sky_master_fit().

cpl_array* muse_cpltable_extract_column ( cpl_table *  aTable,
const char *  aColumn 
)

Create an array from a section of a column.

Parameters
aTableInput table
aColumnInput column name
Returns
Pointer to the array, or NULL in case or error.
Exceptions
set CPL_ERROR_NULL_INPUT, return NULL(aTable) not fulfilled
set CPL_ERROR_NULL_INPUT, return NULL(aColumn) not fulfilled
set CPL_ERROR_ILLEGAL_INPUT, return NULL(Supported data type) not fulfilled

The newly created array shares its data pointer with the original table, and should be deleted with cpl_array_unwrap(). If you need an independent array, duplicate it with cpl_array_duplicate().

Only column of type CPL_TYPE_DOUBLE, CPL_TYPE_FLOAT, and CPL_TYPE_INT are supported. The validity of cells is ignored here.

Definition at line 943 of file muse_cplwrappers.c.

Referenced by muse_cplarray_interpolate_table_linear(), muse_cpltable_find_sorted(), muse_lsf_params_fit(), muse_postproc_process_exposure(), muse_sky_apply_lsf(), and muse_sky_subtract_slice().

cpl_size muse_cpltable_find_sorted ( const cpl_table *  aTable,
const char *  aColumn,
double  aValue 
)

Find a row in a table.

Parameters
aTablePointer to the table.
aColumnName of table column to be accessed.
aValueValue to search.
Returns
The row index, or 0 on error.
Exceptions
set CPL_ERROR_NULL_INPUT, return 0(aTable != NULL) not fulfilled
set CPL_ERROR_ILLEGAL_INPUT, return 0(Supported data type) not fulfilled

This function assumes that the array is sorted. It then searches the last index where the value value is smaller than the specified value. The validity is ignored here.

Definition at line 1047 of file muse_cplwrappers.c.

References muse_cplarray_find_sorted(), and muse_cpltable_extract_column().

Referenced by muse_sky_mark_cosmic(), and muse_wave_lines_add_flux_for_lsf().

cpl_array* muse_cpltable_get_array_copy ( cpl_table *  aTable,
const char *  aColumn,
cpl_size  aRow 
)

Return the copy of an array of a table cell.

Parameters
aTablePointer to table.
aColumnName of table column to be accessed.
aRowPosition of element to be read.
Returns
Pointer to array. In case of an invalid column element, or in case of error, a NULL pointer is always returned.
Exceptions
set CPL_ERROR_NULL_INPUT, return NULL(aTable && aColumn) not fulfilled

Definition at line 1011 of file muse_cplwrappers.c.

Referenced by muse_lsf_params_load().

cpl_table* muse_cpltable_load ( const char *  aFile,
const char *  aExtension,
const muse_cpltable_def  aDefinition[] 
)

Load a table from disk (and check against definition).

Parameters
aFilefile name
aExtensionextension name
aDefinitionoptional table definition; if not NULL, the loaded table will be checked against it
Returns
Loaded CPL table, or NULL on error.
Exceptions
propagate error code from cpl_fits_find_extension(), return NULLextension with given name is not found

Definition at line 821 of file muse_cplwrappers.c.

References muse_cpltable_check().

Referenced by muse_lsf_params_load(), muse_sky_continuum_load(), muse_sky_lines_load(), and muse_sky_master_load().

cpl_table* muse_cpltable_new ( const muse_cpltable_def aDef,
cpl_size  aLength 
)

Create an empty table according to the specified definition.

Parameters
aDefColumn definitions.
aLengthLength of the table.
Returns
Empty table of lines.

This sets the depth of array columns (signified by CPL_TYPE_POINTER) to 2. If any other depth is required, use cpl_table_set_column_depth() to set it after this call.

Definition at line 776 of file muse_cplwrappers.c.

References muse_cpltable_def::format, muse_cpltable_def::name, muse_cpltable_def::type, and muse_cpltable_def::unit.

Referenced by muse_flux_get_response_table(), muse_flux_get_telluric_table(), muse_geo_measure_spots(), muse_geo_table_new(), muse_pixtable_create(), muse_quality_convert_dq(), muse_resampling_euro3d(), muse_resampling_spectrum(), muse_sky_master_fit(), muse_sky_spectrum_from_cube(), muse_table_load_filter(), muse_trace(), muse_wave_calib(), muse_wave_calib_lampwise(), muse_wave_line_handle_multiplet(), muse_wave_line_handle_singlet(), muse_wave_lines_search(), muse_wave_poly_fit(), and muse_wcs_locate_sources().

cpl_size muse_cplvector_count_unique ( const cpl_vector *  aVector)

Count the number of unique entries in a given vector.

Parameters
aVectorInput CPL vector.
Returns
The number of unique entries on success, a negative number on error.
Exceptions
set CPL_ERROR_NULL_INPUT, return -1aVector is NULL

Definition at line 717 of file muse_cplwrappers.c.

Referenced by muse_wave_calib(), and muse_wave_calib_lampwise().

cpl_error_code muse_cplvector_erase_element ( cpl_vector *  aVector,
int  aElement 
)

delete the given element from the input vector

Parameters
aVectorInput cpl_vector
aElementPosition of the element to remove
Returns
CPL_ERROR_NONE on success.

This function is similar to cpl_matrix_erase_columns() but for CPL vectors. A portion of the vector data is physically removed. The pointer to the vector data may change, therefore pointers previously retrieved by calling cpl_vector_get_data() should be discarded.

Definition at line 689 of file muse_cplwrappers.c.

Referenced by muse_trace_iterate_fit(), muse_utils_iterate_fit_polynomial(), muse_wave_lines_get(), and muse_wave_poly_fit().

double muse_cplvector_get_adev_const ( const cpl_vector *  aVector,
double  aCenter 
)

Compute the average absolute deviation of a (constant) vector.

Parameters
aVectorvector of values
aCenterpre-computed central value of the vector (e.g. the median)
Returns
The averaged absoluted deviation against aCenter or 0. on error
Exceptions
set CPL_ERROR_NULL_INPUT, return 0.aVector is NULL

Definition at line 521 of file muse_cplwrappers.c.

Referenced by muse_flux_get_response_table_smooth(), muse_geo_determine_horizontal_wmean(), muse_quality_bad_columns(), muse_trace_edgefinder(), muse_trace_iterate_fit(), and muse_trace_locate_slices().

double muse_cplvector_get_median_dev ( cpl_vector *  aVector,
double *  aMedian 
)

Compute the median and average absolute deviation against the median of a vector.

Parameters
aVectorvector of values
aMedianthe computed median (optional, can be NULL)
Returns
The median deviation of the elements or 0. on error.
Warning
This function is optimized for speed and hence re-orders the elements in the input vector, see cpl_vector_get_median().
Exceptions
set CPL_ERROR_NULL_INPUT, return 0.aVector is NULL

Definition at line 547 of file muse_cplwrappers.c.

Referenced by muse_combine_sigclip_create().

double muse_cplvector_get_semiquartile ( cpl_vector *  aVector)

compute the semi-quartile range of a vector of elements

Parameters
aVectorInput cpl_vector
Returns
the semi-quartile range of the elements

The semiquartile range is a measure similar to standard deviation but it employs the median and rejects outliers so that it is more robust in the case of a few outliers.

Algorithm: determine median, then the medians of the parts of the sorted vector above and below the median value, subtract them, and divide by two

Definition at line 578 of file muse_cplwrappers.c.

cpl_vector* muse_cplvector_get_unique ( const cpl_vector *  aVector)

Separate out all unique entries in a given vector into a new one.

Parameters
aVectorInput CPL vector.
Returns
A new cpl_vector * on success, NULL on failure.
Exceptions
set CPL_ERROR_NULL_INPUT, return -1aVector is NULL

Definition at line 744 of file muse_cplwrappers.c.

Referenced by muse_geo_compute_pinhole_local_distance(), muse_geo_determine_initial(), and muse_geo_refine_horizontal().

cpl_error_code muse_cplvector_threshold ( cpl_vector *  aVec,
double  aLoCut,
double  aHiCut,
double  aLoVal,
double  aHiVal 
)

Threshold a vector to a given interval.

Parameters
aVecVector to threshold.
aLoCutLower bound.
aHiCutHigher bound.
aLoValValue to assign to pixels below low bound.
aHiValValue to assign to pixels above high bound.
Returns
CPL_ERROR_NONE on success another cpl_error_code on failure

Elements outside of the provided interval are assigned the given values.

Use DBL_MIN and DBL_MAX for the aLoCut and aHiCut to avoid any element replacement.

aLoCut must be smaller than or equal to aHiCut.

Exceptions
return CPL_ERROR_NULL_INPUTNULL input vector
return CPL_ERROR_ILLEGAL_INPUTaLoCut is higher than aHiCut

Definition at line 656 of file muse_cplwrappers.c.