|
OPERA
1.0
Open source echelle spectrograph reduction pipeline
|
Fitting library. More...
#include <stdio.h>#include <math.h>#include <stdlib.h>#include "libraries/operaLMFit.h"#include "libraries/operaFit.h"
Data Structures | |
| struct | poly2Ddata_struct |
| poly2Ddata_struct - a data structure to transmit model data to function evaluation More... | |
| struct | gauss2Ddata_struct |
| gauss2Ddata_struct - a data structure to transmit model data to function evalution More... | |
Namespaces | |
| namespace | operaFit |
Defines | |
| #define | NRANSI |
| #define | NR_END 1 |
| #define | FREE_ARG char* |
| #define | EPS 1.0e-7 |
| #define | SWAP(a, b) temp=(a);(a)=(b);(b)=temp; |
| #define | SIGN(a, b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) |
Functions | |
| double | PolynomialFunction (double x, const double *p, int n_par) |
| This function returns the value of a given polynomial function. | |
| void | operaLMFitPolynomial (unsigned m_dat, double *x, double *y, int n_par, double *par, double *chi2, int verbose) |
| This function performs Polynomial Fitting using the Levenberg-Marquardt method. | |
| double | GaussianFunction (double x, const double *p, int n_par) |
| This function returns the value for a Gaussian: f(x) = A*exp(-((x-x0)/sqrt(2)*sig)^2) | |
| void | operaLMFitGaussian (unsigned m_dat, double *x, double *y, double *a, double *x0, double *sig, double *chi2, int verbose) |
| This function performs Gaussian Fitting using the Levenberg-Marquardt method. | |
| double | Polynomial2DFunction (double x, double y, const double *p, int n_par) |
| This function returns the value of a given 2D polynomial surface function. | |
| void | evaluate_surface (int n_par, const double *par, int m_dat, const void *data, double *fvec, int *info) |
| This function performs 2D polynomial function evaluation, determination of residues. | |
| void | operaLMFit2DPolynomial (unsigned m_dat, double *x, double *y, double *fxy, int n_par, double *par, double *chi2, int verbose) |
| This function performs 2D Polynomial Fitting using the Levenberg-Marquardt method. | |
| double | Gaussian2DFunction (double x, double y, const double *p, int n_par) |
| This function returns the value for a 2D Gaussian: f(x,y) = A*exp(-(((x-x0)/sqrt(2)*sigx)^2 + ((y-y0)/sqrt(2)*sigy)^2)) | |
| void | evaluate_2DGaussian (int n_par, const double *par, int m_dat, const void *data, double *fvec, int *info) |
| This function performs 2D Gaussian function evaluation, determination of residues. | |
| void | operaLMFit2DGaussian (unsigned m_dat, double *x, double *y, double *fxy, double *a, double *x0, double *y0, double *sigx, double *sigy, double *chi2, int verbose) |
| This function performs 2D Gaussian Fitting using the Levenberg-Marquardt method. | |
| void | operaFitSpline (unsigned nin, float *xin, float *yin, unsigned nout, float *xout, float *yout) |
| This function performs interpolation of an input array using a sufficiently smooth piecewise-polynomial function (cubic spline) | |
| void | operaFit2DSpline (unsigned nxin, float *xin, unsigned nyin, float *yin, double *fxyin, unsigned nxout, float *xout, unsigned nyout, float *yout, float *fxyout) |
| This function performs interpolation of an input 2D-array using a sufficiently smooth piecewise-polynomial function (cubic spline) | |
| void | spline (float x[], float y[], int n, float yp1, float ypn, float y2[]) |
| void | splint (float xa[], float ya[], float y2a[], int n, float x, float *y) |
| void | splin2 (float x1a[], float x2a[], float **ya, float **y2a, int m, int n, float x1, float x2, float *y) |
| void | splie2 (float x1a[], float x2a[], float **ya, int m, int n, float **y2a) |
| float ** | matrix (long nrl, long nrh, long ncl, long nch) |
| void | free_matrix (float **m, long nrl, long nrh, long ncl, long nch) |
| void | operaMedfit (float xin[], float yin[], int ndata, float *a, float *b, float *abdev) |
| This function performs robust linear fit: f(x) = a + b*x. | |
| float | rofunc (float b) |
| This function ... | |
| float | select_nr (unsigned long k, unsigned long n, float arr[]) |
| This function ... | |
| void | free_vector (float *v, long nl, long nh) |
| This function frees a float vector allocated with vector(). | |
| float * | vector (long nl, long nh) |
| This function allocates a float vector with subscript range v[nl..nh]. | |
| void | nrerror (char error_text[]) |
Variables | |
| static int | verbose = 0 |
| Fitting library. | |
| static int | debug = 0 |
| int | ndatat |
| float * | xt |
| float * | yt |
| float | aa |
| float | abdevt |
Fitting library.
| #define EPS 1.0e-7 |
| #define FREE_ARG char* |
| #define NR_END 1 |
| #define NRANSI |
| #define SIGN | ( | a, | |
| b | |||
| ) | ((b) >= 0.0 ? fabs(a) : -fabs(a)) |
| #define SWAP | ( | a, | |
| b | |||
| ) | temp=(a);(a)=(b);(b)=temp; |
| void evaluate_2DGaussian | ( | int | n_par, |
| const double * | par, | ||
| int | m_dat, | ||
| const void * | data, | ||
| double * | fvec, | ||
| int * | info | ||
| ) |
This function performs 2D Gaussian function evaluation, determination of residues.
| n_par | is an unsigned that .., |
| par | is a double pointer that .., |
| m_dat | is an int that .., |
| data | is a double pointer that .., |
| fvec | is a double pointer that .., |
| info | is an int pointer that .., |
| void evaluate_surface | ( | int | n_par, |
| const double * | par, | ||
| int | m_dat, | ||
| const void * | data, | ||
| double * | fvec, | ||
| int * | info | ||
| ) |
This function performs 2D polynomial function evaluation, determination of residues.
| n_par | is an int that .., |
| par | is a double pointer that .., |
| m_dat | is an int that .., |
| data | is a double pointer that .., |
| fvex | is a double pointer that .., |
| info | is a double pointer that .., |
| void free_matrix | ( | float ** | m, |
| long | nrl, | ||
| long | nrh, | ||
| long | ncl, | ||
| long | nch | ||
| ) |
| void free_vector | ( | float * | v, |
| long | nl, | ||
| long | nh | ||
| ) |
This function frees a float vector allocated with vector().
fvoid free_vector(float *v, long nl, long nh)
| v | is a double pointer that .., |
| nl | is a long that .., |
| nh | is a long that .., |
| double Gaussian2DFunction | ( | double | x, |
| double | y, | ||
| const double * | p, | ||
| int | n_par | ||
| ) |
This function returns the value for a 2D Gaussian: f(x,y) = A*exp(-(((x-x0)/sqrt(2)*sigx)^2 + ((y-y0)/sqrt(2)*sigy)^2))
double Gaussian2DFunction(double x, double y, const double *p, int n_par)
| x | is a double input x-value for which the given 2D Gaussian is evaluated |
| y | is a double input y-value for which the given 2D Gaussian is evaluated |
| p | is a const double pointer for the coefficients of the 2D Gaussian |
| n_par | is an int for the number of coefficients (must be 5!) |
| double GaussianFunction | ( | double | x, |
| const double * | p, | ||
| int | n_par | ||
| ) |
This function returns the value for a Gaussian: f(x) = A*exp(-((x-x0)/sqrt(2)*sig)^2)
double GaussianFunction(double x, const double *p, int n_par)
| x | is a double input value for which the given Gaussian is evaluated |
| p | is a const double pointer for the coefficients of the Gaussian |
| n_par | is an int for the number of coefficients (must be 3!) |
| float** matrix | ( | long | nrl, |
| long | nrh, | ||
| long | ncl, | ||
| long | nch | ||
| ) |

| void nrerror | ( | char | error_text[] | ) |
| void operaFit2DSpline | ( | unsigned | nxin, |
| float * | xin, | ||
| unsigned | nyin, | ||
| float * | yin, | ||
| double * | fxyin, | ||
| unsigned | nxout, | ||
| float * | xout, | ||
| unsigned | nyout, | ||
| float * | yout, | ||
| float * | fxyout | ||
| ) |
This function performs interpolation of an input 2D-array using a sufficiently smooth piecewise-polynomial function (cubic spline)
void operaFitSpline(unsigned nin, float *xin,float *yin, unsigned nout, float *xout, float *yout)
| nxin | is an unsigned for the number of x input data points |
| xin | is a float array for the input x data points |
| nyin | is an unsigned for the number of y input data points |
| yin | is a float array for the input y data points |
| fxyin | is a float array for the input fxy data points |
| nxout | is an unsigned for the number of x output data points. |
| xout | is a float array for the output x data points, which should be provided. |
| nyout | is an unsigned for the number of y output data points. |
| yout | is a float array for the output y data points, which should be provided. |
| fxyout | is a float array for the output interpolated fxy data points, which is calculated |

| void operaFitSpline | ( | unsigned | nin, |
| float * | xin, | ||
| float * | yin, | ||
| unsigned | nout, | ||
| float * | xout, | ||
| float * | yout | ||
| ) |
This function performs interpolation of an input array using a sufficiently smooth piecewise-polynomial function (cubic spline)
void operaFitSpline(unsigned nin, float *xin,float *yin, unsigned nout, float *xout, float *yout)
| nin | is an unsigned for the number of input data points |
| xin | is a float array for the input x data points |
| yin | is a float array for the input y data points |
| nout | is an unsigned for the number of output data points |
| xout | is a float array for the output x data points, which should be provided. |
| yout | is a float array for the output interpolated y data points, which is calculated |

| void operaLMFit2DGaussian | ( | unsigned | m_dat, |
| double * | x, | ||
| double * | y, | ||
| double * | fxy, | ||
| double * | a, | ||
| double * | x0, | ||
| double * | y0, | ||
| double * | sigx, | ||
| double * | sigy, | ||
| double * | chi2, | ||
| int | verbose | ||
| ) |
This function performs 2D Gaussian Fitting using the Levenberg-Marquardt method.
| m_dat | is an unsigned for the number of data points |
| x | is a double pointer with x data values |
| y | is a double pointer with y data values |
| a | is a double pointer for the amplitude of the Gaussian |
| x0 | is a double pointer for the x-center of the Gaussian |
| y0 | is a double pointer for the y-center of the Gaussian |
| sigx | is a double pointer for the spread of the Gaussian in the x-direction |
| sigy | is a double pointer for the spread of the Gaussian in the y-direction |
| chi2 | is a double pointer that returns the reduced chi-square of the fit |
| verbose | is an int that controls print option: 1=on, 0=off |

| void operaLMFit2DPolynomial | ( | unsigned | m_dat, |
| double * | x, | ||
| double * | y, | ||
| double * | fxy, | ||
| int | n_par, | ||
| double * | par, | ||
| double * | chi2, | ||
| int | verbose | ||
| ) |
This function performs 2D Polynomial Fitting using the Levenberg-Marquardt method.
| m_dat | is an unsigned for the number of data points |
| x | is a double pointer with x data values |
| y | is a double pointer with y data values |
| fxy | is a double pointer with f(x,y) data values |
| n_par | is an int for the order of the 2D polynomial to be fit |
| par | is a double pointer for the coefficients of the 2D polynomial |
| chi2 | is a double pointer that returns the reduced chi-square of the fit |
| verbose | is an int that controls print option: 1=on, 0=off |

| void operaLMFitGaussian | ( | unsigned | m_dat, |
| double * | x, | ||
| double * | y, | ||
| double * | a, | ||
| double * | x0, | ||
| double * | sig, | ||
| double * | chi2, | ||
| int | verbose | ||
| ) |
This function performs Gaussian Fitting using the Levenberg-Marquardt method.
| m_dat | is an unsigned for the number of data points |
| x | is a double pointer with x data values |
| y | is a double pointer with y data values |
| a | is a double pointer for the amplitude of the Gaussian |
| x0 | is a double pointer for the center of the Gaussian |
| sig | is a double pointer for the spread of the Gaussian |
| chi2 | is a double pointer that returns the reduced chi-square of the fit |
| verbose | is an int that controls print option: 1=on, 0=off |

| void operaLMFitPolynomial | ( | unsigned | m_dat, |
| double * | x, | ||
| double * | y, | ||
| int | n_par, | ||
| double * | par, | ||
| double * | chi2, | ||
| int | verbose | ||
| ) |
This function performs Polynomial Fitting using the Levenberg-Marquardt method.
| m_dat | is an unsigned for the number of data points |
| x | is a double pointer with x data values |
| y | is a double pointer with y data values |
| n_par | is an int for the order of the polynomial to be fit |
| par | is a double pointer for the coefficients of the polynomial |
| chi2 | is a double pointer that returns the reduced chi-square of the fit |
| verbose | is an int that controls print option: 1=on, 0=off |

| void operaMedfit | ( | float | xin[], |
| float | yin[], | ||
| int | ndata, | ||
| float * | a, | ||
| float * | b, | ||
| float * | abdev | ||
| ) |
This function performs robust linear fit: f(x) = a + b*x.
void operaMedfit(float xin[], float yin[], int ndata, float *a, float *b, float *abdev)
| xin | is a float array with data values |
| yin | is a float array with data values |
| ndata | is an int for the number of data points |
| a | is a double pointer for the linear coefficient |
| b | is a double pointer for the angular coefficient |
| abdev | is a double pointer for the absolute deviation (~chi-square) |

| double Polynomial2DFunction | ( | double | x, |
| double | y, | ||
| const double * | p, | ||
| int | n_par | ||
| ) |
This function returns the value of a given 2D polynomial surface function.
double Polynomial2DFunction(double x, double y, const double *p, int n_par)
| x | is a double input value for which the given polynomial is evaluated |
| y | is a double input value for which the given polynomial is evaluated |
| p | is a const double pointer that contains the coefficients of the given 2D polynomial |
| n_par | is an int that defines the order of the 2D polynomial |
| double PolynomialFunction | ( | double | x, |
| const double * | p, | ||
| int | n_par | ||
| ) |
This function returns the value of a given polynomial function.
double PolynomialFunction(double x, const double *p, int n_par)
| x | is a double input value for which the given polynomial is evaluated |
| p | is a const double pointer that contains the coefficients of the given polynomial |
| n_par | is an int that defines the order of the polynomial |
| float rofunc | ( | float | b | ) |
This function ...
float rofunc(float b)
| b | is a double that .., |

| float select_nr | ( | unsigned long | k, |
| unsigned long | n, | ||
| float | arr[] | ||
| ) |
This function ...
float select_nr(unsigned long k, unsigned long n, float arr[])
| k | is an unsigned long that .., |
| n | is an unsigned long that .., |
| arr | is a double pointer that .., |
| void splie2 | ( | float | x1a[], |
| float | x2a[], | ||
| float ** | ya, | ||
| int | m, | ||
| int | n, | ||
| float ** | y2a | ||
| ) |

| void splin2 | ( | float | x1a[], |
| float | x2a[], | ||
| float ** | ya, | ||
| float ** | y2a, | ||
| int | m, | ||
| int | n, | ||
| float | x1, | ||
| float | x2, | ||
| float * | y | ||
| ) |

| void spline | ( | float | x[], |
| float | y[], | ||
| int | n, | ||
| float | yp1, | ||
| float | ypn, | ||
| float | y2[] | ||
| ) |

| void splint | ( | float | xa[], |
| float | ya[], | ||
| float | y2a[], | ||
| int | n, | ||
| float | x, | ||
| float * | y | ||
| ) |

| float* vector | ( | long | nl, |
| long | nh | ||
| ) |
This function allocates a float vector with subscript range v[nl..nh].
float *vector(long nl, long nh)
| nl | is a long that .., |
| nh | is a long that .., |
| float aa |
| float abdevt |
| int ndatat |
| float* xt |
| float * yt |