|
X-shooter Pipeline Reference Manual 3.8.15
|
#include <complex.h>#include <math.h>#include <string.h>#include <assert.h>#include <float.h>#include <cpl.h>#include "xsh_ksigma_clip.h"#include "xsh_detmon_body.h"Go to the source code of this file.
Macros | |
| #define | CONCAT(a, b) a ## _ ## b |
| #define | CONCAT2X(a, b) CONCAT(a,b) |
| #define | CPL_TYPE double |
| #define | CPL_TYPE float |
| #define | CPL_TYPE int |
Functions | |
| static cpl_error_code | xsh_ksigma_clip_double (const double *pi, cpl_binary *pm, int llx, int lly, int urx, int ury, int nx, double var_sum, int npixs, double kappa, int nclip, double tolerance, double *mean, double *stdev) |
| static cpl_error_code | xsh_ksigma_clip_float (const float *pi, cpl_binary *pm, int llx, int lly, int urx, int ury, int nx, double var_sum, int npixs, double kappa, int nclip, double tolerance, double *mean, double *stdev) |
| static cpl_error_code | xsh_ksigma_clip_int (const int *pi, cpl_binary *pm, int llx, int lly, int urx, int ury, int nx, double var_sum, int npixs, double kappa, int nclip, double tolerance, double *mean, double *stdev) |
| cpl_error_code | xsh_ksigma_clip (const cpl_image *img, int llx, int lly, int urx, int ury, double kappa, int nclip, double tolerance, double *kmean, double *kstdev) |
| Apply kappa-sigma clipping on input image. | |
| #define CONCAT | ( | a, | |
| b | |||
| ) | a ## _ ## b |
Definition at line 230 of file xsh_ksigma_clip.c.
| #define CONCAT2X | ( | a, | |
| b | |||
| ) | CONCAT(a,b) |
Definition at line 231 of file xsh_ksigma_clip.c.
| #define CPL_TYPE double |
Definition at line 241 of file xsh_ksigma_clip.c.
| #define CPL_TYPE float |
Definition at line 241 of file xsh_ksigma_clip.c.
| #define CPL_TYPE int |
Definition at line 241 of file xsh_ksigma_clip.c.
| cpl_error_code xsh_ksigma_clip | ( | const cpl_image * | img, |
| int | llx, | ||
| int | lly, | ||
| int | urx, | ||
| int | ury, | ||
| double | kappa, | ||
| int | nclip, | ||
| double | tolerance, | ||
| double * | kmean, | ||
| double * | kstdev | ||
| ) |
Apply kappa-sigma clipping on input image.
| img | Input image |
| llx | Lower left x position (FITS convention) |
| lly | Lower left y position (FITS convention) |
| urx | Upper right x position (FITS convention) |
| ury | Upper right y position (FITS convention) |
| kappa | Kappa value for the clipping |
| nclip | Number of clipping iterations |
| kmean | Mean after clipping (output) |
| kstdev | Stdev after clipping (output) |
This function applies an iterative kappa-sigma clipping on the image and returns mean and stdev after the clipping.
The function takes as a starting point the "standard" values of mean and stdev from cpl_stats.
On each iteration, the contribution of pixels outside the range [mean - kappa * stdev, mean + kappa * stdev] is removed, the values of mean and stdev are updated, and so are the limits of the range to be used in the next iteration as well.
The algorithm stops after nclip iterations or when the variation of the range between two consecutive iterations is smaller (absolute value) than the tolerance.
The effectiveness of this function resides on the way the update of the values of mean and stdev is done.
The contribution of a single pixel in variance can be removed as follows:
\sum_{i=1}^{N-1} (x_i - \overline{x}_{n-1})^2 = \sum_{i=1}^ N (x_i - \overline{x}_n )^2 - \frac{N}{N-1} \,( \, \overline{x}_n - x_{n} )^2
For further details on the mathematical aspects, please refer to DFS05126.
Possible #_cpl_error_code_ set in this function:
The values of kmean and kstdev is undefined on error.
Definition at line 150 of file xsh_ksigma_clip.c.
References kappa, llx, lly, nx, ny, tolerance, urx, and ury.
|
static |
|
static |
|
static |