MUSE Pipeline Reference Manual
2.1.1
|
Data Structures | |
struct | muse_cpl_optimize_control_t |
Optimization control parameters. More... | |
Typedefs | |
typedef cpl_error_code( | muse_cpl_evaluate_func) (void *aData, cpl_array *aPar, cpl_array *aRetval) |
User provided function to evaluate in muse_cpl_optimize_lvmq(). More... | |
Enumerations |
Functions | |
static void | muse_cpl_optimize_print (const char *func, int n_par, double *par, int m_dat, double *fvec, void *data, int iflag, int iter, int nfev) |
Default printout method adopted to CPL. More... | |
cpl_error_code | muse_cpl_optimize_lvmq (void *aData, cpl_array *aPar, int aSize, muse_cpl_evaluate_func *aFunction, muse_cpl_optimize_control_t *aCtrl) |
Minimize a function with the Levenberg-Marquardt algorithm. More... | |
const char * | muse_get_license (void) |
Get the pipeline copyright and license. More... | |
unsigned char | muse_utils_get_ifu (const cpl_propertylist *aHeaders) |
Find out the IFU/channel from which this header originated. More... | |
int | muse_utils_get_extension_for_ifu (const char *aFilename, unsigned char aIFU) |
Return extension number that corresponds to this IFU/channel number. More... | |
cpl_frameset * | muse_frameset_find (const cpl_frameset *aFrames, const char *aTag, unsigned char aIFU, cpl_boolean aInvert) |
return frameset containing data from an IFU/channel with a certain tag More... | |
cpl_frameset * | muse_frameset_find_tags (const cpl_frameset *aFrames, const cpl_array *aTags, unsigned char aIFU, cpl_boolean aInvert) |
return frameset containing data from an IFU/channel with the given tag(s) More... | |
cpl_frameset * | muse_frameset_check_raw (const cpl_frameset *aFrames, const cpl_array *aTags, unsigned char aIFU) |
return frameset containing good raw input data More... | |
cpl_frameset * | muse_frameset_sort_raw_other (const cpl_frameset *aFrames, int aIndex, const char *aDateObs, cpl_boolean aSequence) |
Create a new frameset containing all relevant raw frames first then all other frames. More... | |
cpl_frame * | muse_frameset_find_master (const cpl_frameset *aFrames, const char *aTag, unsigned char aIFU) |
find the master frame according to its CCD number and tag More... | |
cpl_error_code | muse_utils_frameset_merge_frames (cpl_frameset *aFrames, cpl_boolean aDelete) |
Merge IFU-specific files from a frameset to create multi-IFU outputs. More... | |
muse_table * | muse_table_load_filter (muse_processing *aProcessing, const char *aFilterName) |
Load a table for a given filter name. More... | |
double | muse_utils_filter_fraction (const muse_table *aFilter, double aLambda1, double aLambda2) |
Compute fraction of filter area covered by the data range. More... | |
cpl_error_code | muse_utils_filter_copy_properties (cpl_propertylist *aHeader, const muse_table *aFilter, double aFraction) |
Add/propagate filter properties to header of collapsed image. More... | |
char * | muse_utils_header_get_lamp_names (cpl_propertylist *aHeader, char aSep) |
Concatenate names of all active calibration lamps. More... | |
cpl_array * | muse_utils_header_get_lamp_numbers (cpl_propertylist *aHeader) |
List numbers of all active calibration lamps. More... | |
cpl_matrix * | muse_matrix_new_gaussian_2d (int aXHalfwidth, int aYHalfwidth, double aSigma) |
Create a matrix that contains a normalized 2D Gaussian. More... | |
cpl_image * | muse_utils_image_fit_polynomial (const cpl_image *aImage, unsigned short aXOrder, unsigned short aYOrder) |
Create a smooth version of a 2D image by fitting it with a 2D polynomial. More... | |
cpl_error_code | muse_utils_image_get_centroid_window (cpl_image *aImage, int aX1, int aY1, int aX2, int aY2, double *aX, double *aY, muse_utils_centroid_type aBgType) |
Compute centroid over an image window, optionally marginalizing over the background. More... | |
cpl_error_code | muse_utils_get_centroid (const cpl_matrix *aPositions, const cpl_vector *aValues, const cpl_vector *aErrors, double *aX, double *aY, muse_utils_centroid_type aBgType) |
Compute centroid of a two-dimensional dataset. More... | |
cpl_error_code | muse_utils_fit_multigauss_1d (const cpl_vector *aX, const cpl_bivector *aY, cpl_vector *aCenter, double *aSigma, cpl_vector *aFlux, cpl_vector *aPoly, double *aMSE, double *aRedChisq, cpl_matrix **aCovariance) |
Carry out a multi-Gaussian fit of data in a vector. More... | |
cpl_error_code | muse_utils_fit_moffat_2d (const cpl_matrix *aPositions, const cpl_vector *aValues, const cpl_vector *aErrors, cpl_array *aParams, cpl_array *aPErrors, const cpl_array *aPFlags, double *aRMS, double *aRedChisq) |
Fit a 2D Moffat function to a given set of data. More... | |
cpl_polynomial * | muse_utils_iterate_fit_polynomial (cpl_matrix *aPos, cpl_vector *aVal, cpl_vector *aErr, cpl_table *aExtra, const unsigned int aOrder, const double aRSigma, double *aMSE, double *aChiSq) |
Iterate a polynomial fit. More... | |
double | muse_utils_pixtable_fit_line_gaussian (muse_pixtable *aPixtable, double aLambda, double aHalfWidth, double aBinSize, float aLo, float aHi, unsigned char aIter, cpl_array *aResults, cpl_array *aErrors) |
Fit a 1D Gaussian to a given wavelength range in a pixel table. More... | |
cpl_error_code | muse_utils_copy_modified_header (cpl_propertylist *aH1, cpl_propertylist *aH2, const char *aKeyword, const char *aString) |
Copy a modified header keyword from one header to another. More... | |
cpl_error_code | muse_utils_set_hduclass (cpl_propertylist *aHeader, const char *aClass2, const char *aExtData, const char *aExtDQ, const char *aExtStat) |
Set HDU headers for the ESO FITS data format. More... | |
void | muse_utils_memory_dump (const char *aMarker) |
Display the current memory usage of the given program. More... | |
cpl_image * | muse_convolve_image (const cpl_image *aImage, const cpl_matrix *aKernel) |
Compute the convolution of an image with a kernel. More... | |
muse_image * | muse_fov_load (const char *aFilename) |
Load a FOV image into a MUSE image. More... | |
Variables | |
const muse_cpltable_def | muse_filtertable_def [] |
MUSE filter table definition. More... | |
This group handles several utility functions.
typedef cpl_error_code( muse_cpl_evaluate_func) (void *aData, cpl_array *aPar, cpl_array *aRetval) |
User provided function to evaluate in muse_cpl_optimize_lvmq().
aData | Data forwarded from the fit algorithm call. |
aPar | Current fit parameter |
aRetval | Return value vector |
cpl_error_code muse_evaluate_sample(void *aData, cpl_array *aPar, cpl_array *aRetval);
Definition at line 88 of file muse_optimize.h.
Background handling when computing centroids.
Enumerator | |
---|---|
MUSE_UTILS_CENTROID_NORMAL |
no background treatment |
MUSE_UTILS_CENTROID_MEAN |
subtract average as background |
MUSE_UTILS_CENTROID_MEDIAN |
subtract median value as background |
Definition at line 102 of file muse_utils.h.
cpl_image* muse_convolve_image | ( | const cpl_image * | aImage, |
const cpl_matrix * | aKernel | ||
) |
Compute the convolution of an image with a kernel.
aImage | The image to convolve. |
aKernel | The convolution kernel. |
NULL
if an error occurred.The function convolves the input image aImage with the convolution kernel aKernel using an FFT. If aImage has an odd number of pixels along the y-axis, the last image row is discarded to make it a size even, however, the size of aImage along the x-axis must be even and an error is returned if it is not.
set CPL_ERROR_NULL_INPUT, return NULL | a parameter is NULL |
set CPL_ERROR_IVALID_TYPE, return NULL | aImage is not if type double |
set CPL_ERROR_INCOMPATIBLE_INPUT, return NULL | invalid image size |
Definition at line 2748 of file muse_utils.c.
Referenced by muse_find_stars().
cpl_error_code muse_cpl_optimize_lvmq | ( | void * | aData, |
cpl_array * | aPar, | ||
int | aSize, | ||
muse_cpl_evaluate_func * | aFunction, | ||
muse_cpl_optimize_control_t * | aCtrl | ||
) |
Minimize a function with the Levenberg-Marquardt algorithm.
aData | Any data to be forwarded to the evaluation function. |
aPar | Array containing the fits parameters. |
aSize | Number of data points. |
aFunction | Function that evaluates the fit. |
aCtrl | Structure that controls the algorithm, or NULL for defaults. |
CPL_ERROR_NONE | Everything went OK. |
CPL_ERROR_NULL_INPUT | (aPar != NULL) not fulfilled |
CPL_ERROR_ILLEGAL_INPUT | (cpl_array_get_size(aPar) > 0) not fulfilled |
CPL_ERROR_ILLEGAL_INPUT | (aSize > 0) not fulfilled |
CPL_ERROR_NULL_INPUT | (aFunction != NULL) not fulfilled |
CPL_ERROR_SINGULAR_MATRIX | Return vector is orthogonal to the columns of the jacobian |
CPL_ERROR_CONTINUE | The algorithm did not converge. |
CPL_ERROR_ILLEGAL_OUTPUT | Memory allocation failed |
CPL_ERROR_NONE
, the minimization stops and returns with the return value of the evaluation function.The interface is loosely modeled after cpl_fit_lvmq(). However it can be used with functions that calc the whole result vector at once, it does not need to provide a dervitative, and in may forward any data to the evaluation function.
Definition at line 251 of file muse_optimize.c.
References muse_cpl_optimize_control_t::debug, muse_cpl_optimize_control_t::ftol, muse_cpl_optimize_control_t::gtol, muse_cpl_optimize_control_t::maxcall, muse_cpl_optimize_print(), and muse_cpl_optimize_control_t::xtol.
Referenced by muse_lsf_params_fit(), muse_sky_lines_fit(), muse_sky_lines_fit_old(), and muse_utils_fit_moffat_2d().
|
static |
Default printout method adopted to CPL.
func | Function name |
n_par | Number of parameters |
par | Vector of parameters |
m_dat | Number of datapoints |
fvec | Vector of datapoints |
data | For soft control of printout behaviour, add control variables to the data struct. |
iflag | 0 (init) 1 (outer loop) 2(inner loop) -1(terminated) |
iter | outer loop counter |
nfev | number of calls to *evaluate |
Definition at line 177 of file muse_optimize.c.
Referenced by muse_cpl_optimize_lvmq().
muse_image* muse_fov_load | ( | const char * | aFilename | ) |
Load a FOV image into a MUSE image.
aFilename | name of the file to load |
Load the DATA extension containing the FOV image data from the input file. Bad pixels may be encoded as NaN values in the image data directly, or, if a DQ extension is found in the input file, it is used to replace the bad pixels in the FOV image data with NaN values.
Alternatively, if the DATA extension is an extension with higher-dimensional data or no image content (NAXIS != 2), load the first 2D image extension. In that case, search for the related STAT and DQ extension by prefixing them with the filter name.
Definition at line 2864 of file muse_utils.c.
References muse_image::data, muse_image::dq, muse_image::header, muse_image_delete(), muse_image_dq_to_nan(), muse_image_new(), muse_pfits_get_bunit(), muse_pfits_get_extname(), muse_pfits_get_naxis(), MUSE_WCS_KEYS, and muse_image::stat.
cpl_frameset* muse_frameset_check_raw | ( | const cpl_frameset * | aFrames, |
const cpl_array * | aTags, | ||
unsigned char | aIFU | ||
) |
return frameset containing good raw input data
aFrames | the input frameset |
aTags | the required DFS tag(s) of the frame (optional) |
aIFU | the IFU/channel number |
Returns the good raw input data in form of a frameset. If aTag is NULL, tags are not checked.
Definition at line 284 of file muse_utils.c.
References muse_frameset_find_tags(), muse_pfits_get_binx(), muse_pfits_get_biny(), muse_pfits_get_chip_id(), muse_pfits_get_chip_name(), muse_pfits_get_read_id(), muse_pfits_get_read_name(), and muse_utils_get_extension_for_ifu().
Referenced by muse_basicproc_params_delete().
cpl_frameset* muse_frameset_find | ( | const cpl_frameset * | aFrames, |
const char * | aTag, | ||
unsigned char | aIFU, | ||
cpl_boolean | aInvert | ||
) |
return frameset containing data from an IFU/channel with a certain tag
aFrames | the input frameset |
aTag | the required DFS tag of the frame (optional) |
aIFU | the IFU/channel number to check for (optional) |
aInvert | if true, invert the selection |
Returns the data in form of a frameset. Note that this frameset may be empty (but non-NULL), if no frame matching the parameters was found! If aTag is NULL, tags are not checked. If aIFU is 0, the IFU number is not checked.
If aTag is MUSE_TAG_GEOMETRY_TABLE or MUSE_TAG_TWILIGHT_CUBE, then all frames with that tag are matched, irrespective of the IFU number found it the header of the corresponding file.
The IFU number is checked using muse_utils_get_ifu(). If this fails, then the respective file is expected to be a generic calibration file.
set CPL_ERROR_NULL_INPUT, return NULL | aFrames is NULL |
propagate error code, continue with next frame | header of a file cannot be loaded |
Definition at line 160 of file muse_utils.c.
References muse_pfits_get_pipefile(), muse_utils_get_extension_for_ifu(), and muse_utils_get_ifu().
Referenced by muse_basicproc_params_delete(), muse_frameset_find_master(), muse_frameset_find_tags(), muse_lsf_cube_load_all(), muse_postproc_cube_load_output_wcs(), muse_processing_check_input(), muse_processing_load_mask(), muse_processing_lsf_params_load(), muse_sky_continuum_load(), and muse_sky_lines_load().
cpl_frame* muse_frameset_find_master | ( | const cpl_frameset * | aFrames, |
const char * | aTag, | ||
unsigned char | aIFU | ||
) |
find the master frame according to its CCD number and tag
aFrames | the frames list |
aTag | the tag |
aIFU | the IFU/channel number |
The returned frame is duplicated from the input frameset and therefore has to be deallocated after use.
Definition at line 505 of file muse_utils.c.
References muse_frameset_find().
Referenced by muse_basicproc_params_delete(), muse_processing_load_header(), muse_processing_load_table(), and muse_table_load_filter().
cpl_frameset* muse_frameset_find_tags | ( | const cpl_frameset * | aFrames, |
const cpl_array * | aTags, | ||
unsigned char | aIFU, | ||
cpl_boolean | aInvert | ||
) |
return frameset containing data from an IFU/channel with the given tag(s)
aFrames | the input frameset |
aTags | the required DFS tag(s) of the frame |
aIFU | the IFU/channel number to check for (optional) |
aInvert | if true, invert the selection |
Returns the data in form of a frameset. Note that this frameset may be empty (but non-NULL), if no frame matching the parameters was found! If aIFU is 0, the IFU number is not checked.
This function just loops over muse_frameset_find() for all tags in aTags.
set CPL_ERROR_NULL_INPUT, return NULL | aFrames is NULL |
Definition at line 253 of file muse_utils.c.
References muse_frameset_find().
Referenced by muse_basicproc_combine_images_lampwise(), muse_basicproc_load_reduced(), and muse_frameset_check_raw().
cpl_frameset* muse_frameset_sort_raw_other | ( | const cpl_frameset * | aFrames, |
int | aIndex, | ||
const char * | aDateObs, | ||
cpl_boolean | aSequence | ||
) |
Create a new frameset containing all relevant raw frames first then all other frames.
aFrames | the frames list |
aIndex | the frame index (use a negative value to signify to take all raw frames or use aDateObs for comparison) |
aDateObs | the DATE-OBS string to search for (only when aIndex is negative, use NULL to signify to take all frames) |
aSequence | if target frame is part of a sequence |
Normal raw frames are sorted first, if their location in aFrames match the aIndex, or aDateObs is given and the DATE-OBS in their header match it. If aSequence is true, then it is expected that they are part of an exposure sequence (e.g. calibration flats), and they are taken irrespective of aIndex.
Raw frames tagged "ILLUM" also get a special handling, in that the first of them – i.e. the one that got used in muse_basicproc_get_illum() – is sorted into the output frameset after all other raw frames, but before all other frames.
The returned frameset is duplicated from the input frameset and therefore has to be deallocated using cpl_frameset_delete() after use.
set CPL_ERROR_NULL_INPUT, return NULL | input frameset was NULL |
Definition at line 418 of file muse_utils.c.
References muse_pfits_get_dateobs().
Referenced by muse_processing_append_used().
const char* muse_get_license | ( | void | ) |
Get the pipeline copyright and license.
The function wraps the cpl_get_license() macro and hence returns a pointer to the statically allocated license string. This string should not be modified using the returned pointer.
Definition at line 83 of file muse_utils.c.
cpl_matrix* muse_matrix_new_gaussian_2d | ( | int | aXHalfwidth, |
int | aYHalfwidth, | ||
double | aSigma | ||
) |
Create a matrix that contains a normalized 2D Gaussian.
aXHalfwidth | horizontal half width of the kernel matrix |
aYHalfwidth | vertical half width of the kernel matrix |
aSigma | sigma of Gaussian function |
The 2*halfwidth+1 gives the size of one side of the matrix, i.e. halfwidth=3 for a 7x7 matrix. The created matrix has to be deallocated by cpl_matrix_delete().
Definition at line 1099 of file muse_utils.c.
Referenced by muse_geo_measure_spots().
muse_table* muse_table_load_filter | ( | muse_processing * | aProcessing, |
const char * | aFilterName | ||
) |
Load a table for a given filter name.
aProcessing | the processing structure, includes the input frames list |
aFilterName | the filter name |
This function tries to find a filter table and in it an extension for the filter of the given name. The table from that extension is loaded.
A filter called "white" is built into this function, it covers the full MUSE wavelength range with constant throughput.
set CPL_ERROR_NULL_INPUT, return NULL | aFilterName is NULL |
return NULL (and output debug message) | aFilterName is "none" |
set CPL_ERROR_FILE_NOT_FOUND, return NULL | input frame with tag MUSE_TAG_FILTER_LIST was not found |
set CPL_ERROR_DATA_NOT_FOUND, return NULL | valid file with tag MUSE_TAG_FILTER_LIST does not contain filter named aFilterName |
propagate error code, return NULL | loading table for filter aFilterName from valid file with tag MUSE_TAG_FILTER_LIST failed |
Definition at line 799 of file muse_utils.c.
References muse_table::header, muse_processing::inframes, muse_cpltable_new(), muse_frameset_find_master(), muse_processing_append_used(), muse_table_delete(), muse_table_new(), and muse_table::table.
Referenced by muse_postproc_cube_resample_and_collapse(), muse_postproc_process_exposure(), and muse_wcs_locate_sources().
cpl_error_code muse_utils_copy_modified_header | ( | cpl_propertylist * | aH1, |
cpl_propertylist * | aH2, | ||
const char * | aKeyword, | ||
const char * | aString | ||
) |
Copy a modified header keyword from one header to another.
aH1 | input header |
aH2 | output header |
aKeyword | header keyword to copy |
aString | string to be used for the modification |
The keyword is modified by appending " (aString)" to it.
return CPL_ERROR_NULL_INPUT | one of the input arguments is NULL |
return CPL_ERROR_ILLEGAL_INPUT | the string in the input header cannot be read |
Definition at line 2570 of file muse_utils.c.
Referenced by muse_datacube_save(), muse_datacube_save_recimages(), and muse_postproc_cube_resample_and_collapse().
cpl_error_code muse_utils_filter_copy_properties | ( | cpl_propertylist * | aHeader, |
const muse_table * | aFilter, | ||
double | aFraction | ||
) |
Add/propagate filter properties to header of collapsed image.
aHeader | the header to add to |
aFilter | the filter response curve |
aFraction | the filter covering fraction |
set and return CPL_ERROR_NULL_INPUT | aHeader, aFilter, or the header component of aFilter are NULL |
Definition at line 934 of file muse_utils.c.
References muse_table::header.
Referenced by muse_datacube_collapse(), muse_euro3dcube_collapse(), and muse_resampling_collapse_pixgrid().
double muse_utils_filter_fraction | ( | const muse_table * | aFilter, |
double | aLambda1, | ||
double | aLambda2 | ||
) |
Compute fraction of filter area covered by the data range.
aFilter | the filter response curve |
aLambda1 | the starting (data) wavelength |
aLambda2 | the end (data) wavelength |
set CPL_ERROR_NULL_INPUT, return -1. | aFilter or its table component are NULL |
Definition at line 893 of file muse_utils.c.
References MUSE_FLUX_RESP_FILTER, muse_flux_response_interpolate(), and muse_table::table.
Referenced by muse_resampling_collapse_pixgrid().
cpl_error_code muse_utils_fit_moffat_2d | ( | const cpl_matrix * | aPositions, |
const cpl_vector * | aValues, | ||
const cpl_vector * | aErrors, | ||
cpl_array * | aParams, | ||
cpl_array * | aPErrors, | ||
const cpl_array * | aPFlags, | ||
double * | aRMS, | ||
double * | aRedChisq | ||
) |
Fit a 2D Moffat function to a given set of data.
aPositions | input image to use for the fit |
aValues | input values to use for the fit |
aErrors | input errors to use for the fit (can be NULL) |
aParams | parameter array (type double) |
aPErrors | parameter error double array (can be NULL) |
aPFlags | parameter flags integer array (can be NULL) |
aRMS | root mean square of the fit (can be NULL) |
aRedChisq | reduced chi^2 of the fit (can be NULL) |
This fits a Moffat (1969 A&A 3, 455, Eq. 7) function in two-dimensional cartesian form allowing for non-circular isophotes
moffat(x,y) = B + A (beta - 1) / (pi alphax alphay sqrt(1 - rho^2)) [ 1 + { ((x - xc) / alphax)^2 + 2 rho (x-xc)(y-yc) / (alphax alphay) + ((y - yc) / alphay)^2} / {1 - rho^2} ]^(-beta)
to the input data. The parameters and their starting values are
Valid inputs in aParams override the first-guess parameters given above. If only one valid alpha parameter was given, the other one is used as starting value.
In case of uniform data, no error will be returned but a flat Moffat function with undefined center and widths will be created.
References:
return CPL_ERROR_NULL_INPUT | aPositions, aValues, or aParams are NULL |
return CPL_ERROR_INCOMPATIBLE_INPUT | aPositions does not give the same number of positions as aValues |
return CPL_ERROR_INCOMPATIBLE_INPUT | aPositions does not contain two columns |
return CPL_ERROR_INCOMPATIBLE_INPUT | aErrors is given but does not have the same size as aValues |
return CPL_ERROR_INVALID_TYPE | aParams is not of type double |
return CPL_ERROR_INVALID_TYPE | aPErrors is given but not of type double |
return CPL_ERROR_INVALID_TYPE | aPFlags is given but not of type int |
return CPL_ERROR_DATA_NOT_FOUND | aPErrors and/or aRedChisq are given but aErrors is NULL |
return CPL_ERROR_SINGULAR_MATRIX | input data has less than 8 positions |
return CPL_ERROR_ILLEGAL_INPUT | aPFlags did not leave any parameter free |
return CPL_ERROR_ILLEGAL_INPUT | aPFlags was set to freeze a parameter but this parameter does not have an input value in aParams |
propagate return code of cpl_fit_lvmq() | the actual fit fails |
Definition at line 1878 of file muse_utils.c.
References muse_cpl_optimize_lvmq(), MUSE_UTILS_CENTROID_MEDIAN, and muse_utils_get_centroid().
Referenced by muse_dar_check(), muse_flux_response_interpolate(), and muse_wcs_centroid_stars().
cpl_error_code muse_utils_fit_multigauss_1d | ( | const cpl_vector * | aX, |
const cpl_bivector * | aY, | ||
cpl_vector * | aCenter, | ||
double * | aSigma, | ||
cpl_vector * | aFlux, | ||
cpl_vector * | aPoly, | ||
double * | aMSE, | ||
double * | aRedChisq, | ||
cpl_matrix ** | aCovariance | ||
) |
Carry out a multi-Gaussian fit of data in a vector.
aX | Positions to fit |
aY | Values and associated errors to fit |
aCenter | centers of the Gaussian peaks |
aSigma | the common Gaussian sigma of all peaks; use a negative value to have sigma be a fixed parameter in the fit |
aFlux | fluxes of the Gaussian peaks |
aPoly | coefficients of the background polynomial |
aMSE | computed mean squared error of the fit |
aRedChisq | reduced chi square of the fit |
aCovariance | output covariance matrix of the fit |
This function fits multiple Gaussians plus a background polynomial to the dataset given by aX and aY. The number of Gaussian peaks is determined by the length of the vector aCenter. It is mandatory to use it to give first-guess values for the centers of the peaks and an estimate of the expected Gaussian sigma in aSigma. aFlux has to be of the same length as aCenter, if given its values are also taken as first guesses of the areas of the Gaussian peaks (the fluxes). The background polynomial is defined using the aPoly vector, its contents are first-guess values for the polynomial coefficients, its length is used to define the order of the polynomial. If aPoly is NULL, the background is assumed to be a constant zero level.
If successful, fit results are returned in aCenter, aSigma, and – if given – aFlux. If aSigma was negative on input, the absolute value returned is same as the input, but positive. Then, the covariance matrix aCovariance is created and filled; it has to be deallocated using cpl_matrix_delete() after use. The order of parameters in the covariance matrix is the following: polynomial coefficients, sigma, centers, fluxes (where the number of elements, except for sigma, is determined by the lengths of the input objects).
This function is loosely modeled after cpl_vector_fit_gaussian(), it also uses cpl_fit_lvmq() to do that actual fit. But since computing first-guess parameters from the data is not possible in a meaningful way for multi-Gaussians, at least not without knowing the number of peaks, this function requires first guesses to be given, with the exception of the fluxes.
return CPL_ERROR_NULL_INPUT | aX, aY, aCenter, or aSigma are NULL |
return CPL_ERROR_INCOMPATIBLE_INPUT | aY contains a different number of points as aX |
return CPL_ERROR_INCOMPATIBLE_INPUT | aFlux is given but contains a different number of parameters (peaks) than aCenter |
return CPL_ERROR_ILLEGAL_INPUT | aRedChisq is not NULL but there are less points than parameters, so that it cannot be computed |
propagate error | cpl_fit_lvmq() fails |
Definition at line 1558 of file muse_utils.c.
Referenced by muse_wave_line_fit_multiple().
cpl_error_code muse_utils_frameset_merge_frames | ( | cpl_frameset * | aFrames, |
cpl_boolean | aDelete | ||
) |
Merge IFU-specific files from a frameset to create multi-IFU outputs.
aFrames | the frames list |
aDelete | if CPL_TRUE, delete input files from framesete after merging |
This function groups all frames in the input frameset regarding the base of the filenames (without -nn.fits), and then merges them, taking care to put IFU-specific information into the extension header (like QC and DRS parameters). The output filename for each group is the common basename of files (usually the PRO.CATG tag given to it by the pipeline during processing).
After all products were merged, the related files in the input frameset are physically removed from the filesystem and purged from aFrames.
The merged files in the frameset aFrames are set to the cpl_frame_group of CPL_FRAME_GROUP_PRODUCT, even if the input frames were not.
set and return CPL_ERROR_NULL_INPUT | aFrames is NULL |
set and return CPL_ERROR_ILLEGAL_INPUT | aFrames is empty |
Definition at line 589 of file muse_utils.c.
cpl_error_code muse_utils_get_centroid | ( | const cpl_matrix * | aPositions, |
const cpl_vector * | aValues, | ||
const cpl_vector * | aErrors, | ||
double * | aX, | ||
double * | aY, | ||
muse_utils_centroid_type | aBgType | ||
) |
Compute centroid of a two-dimensional dataset.
aPositions | matrix containing the positions |
aValues | vector containing the data values |
aErrors | vector containing the data errors (1 sigma, can be NULL) |
aX | computed horizontal centroid position |
aY | computed vertical centroid position |
aBgType | specifies how to handle the background |
This computes the center of gravity, using the data values and optionally the data errors as weights.
The input aPositions matrix must be for two-dimensional data, i.e. contain two columns, and the number of rows must be equal to the number of entries in both vectors.
return CPL_ERROR_NULL_INPUT | aPositions or aValues are NULL |
return CPL_ERROR_INCOMPATIBLE_INPUT | aPositions does not contain two columns |
return CPL_ERROR_INCOMPATIBLE_INPUT | aPositions does not give the same number of positions as aValues |
return CPL_ERROR_INCOMPATIBLE_INPUT | aValues does not contain the same number of positions as aErrors |
return CPL_ERROR_NULL_INPUT | both aX and aY are NULL so that the centroid cannot be returned |
return CPL_ERROR_ILLEGAL_INPUT | aBgType does not contain a valid centroid type |
Definition at line 1328 of file muse_utils.c.
References MUSE_UTILS_CENTROID_MEAN, MUSE_UTILS_CENTROID_MEDIAN, and MUSE_UTILS_CENTROID_NORMAL.
Referenced by muse_dar_check(), and muse_utils_fit_moffat_2d().
int muse_utils_get_extension_for_ifu | ( | const char * | aFilename, |
unsigned char | aIFU | ||
) |
Return extension number that corresponds to this IFU/channel number.
aFilename | name of the FITS file |
aIFU | the IFU/channel number |
Definition at line 118 of file muse_utils.c.
References muse_pfits_has_ifu().
Referenced by muse_basicproc_params_delete(), muse_frameset_check_raw(), muse_frameset_find(), and muse_table_load().
unsigned char muse_utils_get_ifu | ( | const cpl_propertylist * | aHeaders | ) |
Find out the IFU/channel from which this header originated.
aHeaders | property list/headers to read from |
This is a wrapper around muse_pfits_has_ifu().
Definition at line 98 of file muse_utils.c.
References muse_pfits_has_ifu().
Referenced by muse_basicproc_apply_illum(), muse_basicproc_apply_twilight(), muse_basicproc_get_illum(), muse_basicproc_load_reduced(), muse_basicproc_params_delete(), muse_basicproc_shift_pixtable(), muse_frameset_find(), muse_geo_measure_spots(), muse_imagelist_compute_ron(), muse_pixtable_create(), muse_processing_sort_exposures(), muse_quadrants_overscan_polyfit_vertical(), muse_quality_copy_badpix_table(), muse_trace(), muse_trace_horizontal_cut(), muse_utils_pixtable_fit_line_gaussian(), muse_wave_calib(), muse_wave_calib_lampwise(), muse_wave_line_handle_multiplet(), muse_wave_line_handle_singlet(), muse_wave_map(), and muse_wave_params_delete().
char* muse_utils_header_get_lamp_names | ( | cpl_propertylist * | aHeader, |
char | aSep | ||
) |
Concatenate names of all active calibration lamps.
aHeader | the FITS header to search for lamp entries |
aSep | the separator to use for name concatenation |
This function iterates through all lamp shutters found in the header, and for those where the lamp is switched on and the shutter is open appends the name to the output string. Prefixes of lamp names (currently only "CU-LAMP-") are cut off, e.g. "CU-LAMP-HgCd" becomes "HgCd". XXX to aid AIT, lamp names like "CU-LAMP[3-6]" are converted to the respective element names (Ne, Xe, HgCd).
The returned string has to be deallocated with cpl_free().
set CPL_ERROR_NULL_INPUT, return NULL | aHeader is NULL |
Definition at line 989 of file muse_utils.c.
References muse_pfits_get_lamp_name(), muse_pfits_get_lamp_status(), muse_pfits_get_lampnum(), and muse_pfits_get_shut_status().
Referenced by muse_lsf_create_arcpixtable(), and muse_wave_calib_lampwise().
cpl_array* muse_utils_header_get_lamp_numbers | ( | cpl_propertylist * | aHeader | ) |
List numbers of all active calibration lamps.
aHeader | the FITS header to search for lamp entries |
This function iterates through all lamp shutters found in the header, and for those where the lamp is switched on and the shutter is open appends the lamp number to the output array.
The lamp numbers are the i in the ESO.INS.LAMPi keywords in the MUSE FITS headers.
The returned array has to be deallocated with cpl_array_delete().
set CPL_ERROR_NULL_INPUT, return NULL | aHeader is NULL |
Definition at line 1056 of file muse_utils.c.
References muse_pfits_get_lamp_status(), muse_pfits_get_lampnum(), and muse_pfits_get_shut_status().
Referenced by muse_wave_calib_lampwise().
cpl_image* muse_utils_image_fit_polynomial | ( | const cpl_image * | aImage, |
unsigned short | aXOrder, | ||
unsigned short | aYOrder | ||
) |
Create a smooth version of a 2D image by fitting it with a 2D polynomial.
aImage | input image to fit |
aXOrder | polynomial order to use in x direction |
aYOrder | polynomial order to use in y direction |
This function transfers all pixels (their positions and values) into suitable structures and calls cpl_polynomial_fit(). If that polynomial fit succeeds, cpl_image_fill_polynomial() is used to create the output image. Rejected (bad) pixels in the input image are marked as rejected in the output image as well.
set CPL_ERROR_NULL_INPUT, return NULL | aImage is NULL |
set CPL_ERROR_DATA_NOT_FOUND, return NULL | aImage does not contain good pixels |
propagate error code, return NULL | cpl_polynomial_fit() fails |
Definition at line 1147 of file muse_utils.c.
cpl_error_code muse_utils_image_get_centroid_window | ( | cpl_image * | aImage, |
int | aX1, | ||
int | aY1, | ||
int | aX2, | ||
int | aY2, | ||
double * | aX, | ||
double * | aY, | ||
muse_utils_centroid_type | aBgType | ||
) |
Compute centroid over an image window, optionally marginalizing over the background.
aImage | input image to use |
aX1 | lower left x position of window |
aY1 | lower left y position of window |
aX2 | upper right x position of window |
aY2 | upper right y position of window |
aX | computed centroid in x-direction |
aY | computed centroid in x-direction |
aBgType | specifies how to handle the background |
This computes the ("marginal") centroid over an image window, similar to IRAF's imcentroid algorithm but without iterations. Before the normal centroid is actually computed, the average level of the image is subtracted. Only the positions with positive values are then used in the computation of the output centroid.
return CPL_ERROR_NULL_INPUT | aImage or both aXCen and aYCen are NULL |
propagate error code | cpl_image_extract() fails for the given coordinates |
return CPL_ERROR_ILLEGAL_INPUT | aBgType does not contain a valid centroid type |
Definition at line 1234 of file muse_utils.c.
References MUSE_UTILS_CENTROID_MEAN, MUSE_UTILS_CENTROID_MEDIAN, and MUSE_UTILS_CENTROID_NORMAL.
Referenced by muse_dar_check(), and muse_wcs_centroid_stars().
cpl_polynomial* muse_utils_iterate_fit_polynomial | ( | cpl_matrix * | aPos, |
cpl_vector * | aVal, | ||
cpl_vector * | aErr, | ||
cpl_table * | aExtra, | ||
const unsigned int | aOrder, | ||
const double | aRSigma, | ||
double * | aMSE, | ||
double * | aChiSq | ||
) |
Iterate a polynomial fit.
aPos | matrix with input positions |
aVal | vector with input values |
aErr | vector with input errors (optional, currently unused) |
aExtra | table with extra information (optional, same number of rows as aVal) |
aOrder | polynomial order to use for the fit |
aRSigma | rejection sigma |
aMSE | output mean squared error of final fit (optional) |
aChiSq | output chi square of final fit (optional) |
The position matrix aPos contains the same number of columns as the values vector aVal. The number of rows in aPos defines the number of dimensions of the output polynomial.
The table aExtra contains extra information, with each matrix row related to each entry in the aVal vector.
Infinite entries (NANs and INFs) in aVal are rejected at the start, so can be used as "bad pixel" markers. The procedure will fail, if only infinite values are present.
If an error occurs, both aChiSq and aMSE are set to high values (DBL_MAX).
set CPL_ERROR_NULL_INPUT, return NULL | aPos and/or aVal are NULL |
set CPL_ERROR_INCOMPATIBLE_INPUT, return NULL | the number of aPos does not match the size of aVal |
set CPL_ERROR_INCOMPATIBLE_INPUT, return NULL | aErr was specified but does not match the size of aVal |
set CPL_ERROR_INCOMPATIBLE_INPUT, return NULL | aExtra was specified but the number of its rows does not match the size of aVal |
set CPL_ERROR_ILLEGAL_INPUT, return NULL | aVal only contains infinite values |
set CPL_ERROR_ILLEGAL_OUTPUT, return NULL | the iterative procedure tries to remove the last vector/matrix element |
Definition at line 2234 of file muse_utils.c.
References muse_cplvector_erase_element().
Referenced by muse_dar_check(), muse_flux_response_interpolate(), muse_geo_finalize(), muse_quadrants_overscan_polyfit_vertical(), muse_quadrants_overscan_stats(), muse_trace_iterate_fit(), muse_wave_calib_lampwise(), and muse_wave_line_fit_iterate().
void muse_utils_memory_dump | ( | const char * | aMarker | ) |
Display the current memory usage of the given program.
aMarker | marker string to use in the debug output |
This function uses the cpl_memory_dump() function to list pointers allocated through CPL and the Unix ps command to display system information about the process.
Definition at line 2702 of file muse_utils.c.
Referenced by muse_resampling_cube(), and muse_xcombine_tables().
double muse_utils_pixtable_fit_line_gaussian | ( | muse_pixtable * | aPixtable, |
double | aLambda, | ||
double | aHalfWidth, | ||
double | aBinSize, | ||
float | aLo, | ||
float | aHi, | ||
unsigned char | aIter, | ||
cpl_array * | aResults, | ||
cpl_array * | aErrors | ||
) |
Fit a 1D Gaussian to a given wavelength range in a pixel table.
aPixtable | input pixel table |
aLambda | the wavelength around which to extract the range |
aHalfWidth | the half width of the range in wavelength to use |
aBinSize | the size of the bins in wavelength for the spectrum |
aLo | low sigma-clipping limit for the spectrum |
aHi | high sigma-clipping limit for the spectrum |
aIter | number of iterations for sigma-clipping the spectrum |
aResults | parameter error double array (can be NULL) |
aErrors | parameter flags integer array (can be NULL) |
This fits a 1D Gaussian of the form
gauss(x) = A / sqrt(2 pi sigma^2) * exp( -(x - xc)^2/(2 sigma^2)) + B
to the input pixel table. It does this by resampling the pixel table in the specified wavelength range into a temporary spectrum, sampled at aBinSize, using muse_resampling_spectrum(), which is then given to cpl_vector_fit_gaussian()
.
This function directly returns the center xc of the Gaussian fit. If the other properties are required, the optional inputs aResults (for the values) and aErrors (for the sigma values) need to be passed as CPL arrays of type CPL_TYPE_DOUBLE. These arrays are resized to 4 elements and overwritten with output. The Gaussian parameters are always written to aResults (if given), the errors returned in aErrors may be invalid, except for the 0th element (the centroid error) which is always written. The order of the elements is:
First-guess parameters cannot be given, but the wavelength range should be given to restrict the data to a set of data that contains one Gaussian-like peak.
set CPL_ERROR_NULL_INPUT, return 0. | aPixtable or one of its components is NULL |
set CPL_ERROR_DATA_NOT_FOUND, return 0. | aPixtable does not have data in the range |aLambda| +/- aHalfWidth |
propagate error code, return 0. | muse_resampling_spectrum() fails |
Definition at line 2442 of file muse_utils.c.
References muse_pixtable::header, MUSE_PIXTABLE_LAMBDA, muse_resampling_spectrum_iterate(), muse_utils_get_ifu(), and muse_pixtable::table.
Referenced by muse_basicproc_shift_pixtable().
cpl_error_code muse_utils_set_hduclass | ( | cpl_propertylist * | aHeader, |
const char * | aClass2, | ||
const char * | aExtData, | ||
const char * | aExtDQ, | ||
const char * | aExtStat | ||
) |
Set HDU headers for the ESO FITS data format.
aHeader | the FITS headers to modify |
aClass2 | type of class to set, i.e. contents of HDUCLAS2 |
aExtData | extension name for the data extension |
aExtDQ | extension name for the bad pixel extension (or NULL) |
aExtStat | extension name for the variance extension (or NULL) |
This function adds special FITS headers to support the ESO format. The information was taken from v2.5.1 (dated Feb. 15th, 2012) of the document "FITS format description for pipeline products with data, error and data quality information" and further info by Martin Kuemmel and Harald Kuntschner.
This function tries to set these header keywords directly after EXTNAME, if available, otherwise at the end of the input header.
return CPL_ERROR_NULL_INPUT | aHeader, aClass2, or aExtData are NULL |
return CPL_ERROR_ILLEGAL_INPUT | aClass2 is neither "DATA", "ERROR", nor "QUALITY" |
Definition at line 2611 of file muse_utils.c.
Referenced by muse_datacube_save(), muse_datacube_save_recimages(), and muse_image_save().
const muse_cpltable_def muse_filtertable_def[] |
MUSE filter table definition.
A MUSE filter table has the following columns:
Definition at line 768 of file muse_utils.c.