Defines | |
| #define | REQ_CPL_MAJOR 3 |
| Check compile time and runtime library versions. | |
| #define | REQ_CPL_MINOR 1 |
| #define | REQ_CPL_MICRO 0 |
| #define | REQ_QF_MAJOR 6 |
| #define | REQ_QF_MINOR 2 |
| #define | REQ_QF_MICRO 0 |
Functions | |
| static cpl_error_code | uves_cosrout (cpl_image *ima, cpl_image **msk, const double ron, const double gain, const int ns, const double sky, const double rc, cpl_image **flt, cpl_image **out) |
| Remove cosmic ray events on single ccd exposure and replace them by interpolation on neighbourhood pixels. | |
| static cpl_error_code | uves_find_next (cpl_image **msk, const int first_y, int *next_x, int *next_y) |
| static cpl_error_code | uves_sort (const int kmax, float *inp, int *ord) |
| cpl_error_code | uves_rcosmic (cpl_image *ima, cpl_image **flt, cpl_image **out, cpl_image **msk, const double sky, const double ron, const double gain, const int ns, const double rc) |
| Remove cosmic ray events on single ccd exposure and replace them by interpolation on neighbourhood pixels. | |
| cpl_parameterlist * | uves_parameterlist_duplicate (const cpl_parameterlist *pin) |
| Extract frames with given tag from frameset. | |
| const char * | uves_string_toupper (char *s) |
| Convert all lowercase characters in a string into uppercase characters. | |
| const char * | uves_string_tolower (char *s) |
| Convert all uppercase characters in a string into lowercase characters. | |
| cpl_frameset * | uves_frameset_extract (const cpl_frameset *frames, const char *tag) |
| Extract frames with given tag from frameset. | |
| double | uves_pow_int (double x, int y) |
| Calculate x to the y'th. | |
| long | uves_round_double (double x) |
| Round a number to the nearest integer. | |
| double | uves_max_double (double x, double y) |
| Maximum of two numbers. | |
| int | uves_max_int (int x, int y) |
| Maximum of two numbers. | |
| double | uves_min_double (double x, double y) |
| Minimum of two numbers. | |
| int | uves_min_int (int x, int y) |
| Minimum of two numbers. | |
| double | uves_error_fraction (double x, double y, double dx, double dy) |
| Get uncertainty of division. | |
| cpl_error_code | uves_get_version (int *major, int *minor, int *micro) |
| Get UVES library version number. | |
| int | uves_get_version_binary (void) |
| Get UVES library binary version number. | |
| const char * | uves_get_license (void) |
| Get the pipeline copyright and license. | |
| void | uves_check_version (void) |
| cpl_error_code | uves_end (const char *recipe_id, const cpl_frameset *frames) |
| Recipe termination. | |
| char * | uves_initialize (cpl_frameset *frames, const cpl_parameterlist *parlist, const char *recipe_id, const char *short_descr) |
| Recipe initialization. | |
| cpl_image * | uves_average_images (const cpl_image *image1, const cpl_image *noise1, const cpl_image *image2, const cpl_image *noise2, cpl_image **noise) |
| Optimally average images. | |
| uves_propertylist * | uves_initialize_image_header (const char *ctype1, const char *ctype2, const char *bunit, double crval1, double crval2, double crpix1, double crpix2, double cdelt1, double cdelt2) |
| Initialize image header. | |
| cpl_image * | uves_define_noise (const cpl_image *image, const uves_propertylist *image_header, int ncom, enum uves_chip chip) |
| Create noise image. | |
| cpl_error_code | uves_subtract_bias (cpl_image *image, const cpl_image *master_bias) |
| Subtract bias. | |
| cpl_error_code | uves_subtract_dark (cpl_image *image, const uves_propertylist *image_header, const cpl_image *master_dark, const uves_propertylist *mdark_header) |
| Subtract dark. | |
| int | uves_absolute_order (int first_abs_order, int last_abs_order, int relative_order) |
| Get the absolute order number. | |
| double | uves_average_reject (cpl_table *t, const char *column, const char *residual2, double kappa) |
| Get average with iterative rejection. | |
| polynomial * | uves_polynomial_regression_1d (cpl_table *t, const char *X, const char *Y, const char *sigmaY, int degree, const char *polynomial_fit, const char *residual_square, double *mean_squared_error, double kappa) |
| Fit a 1d polynomial to two table columns. | |
| polynomial * | uves_polynomial_regression_2d (cpl_table *t, const char *X1, const char *X2, const char *Y, const char *sigmaY, int degree1, int degree2, const char *polynomial_fit, const char *residual_square, const char *variance_fit, double *mse, double *red_chisq, polynomial **variance, double kappa, double min_reject) |
| Fit a 2d polynomial to three table columns. | |
| polynomial * | uves_polynomial_regression_2d_autodegree (cpl_table *t, const char *X1, const char *X2, const char *Y, const char *sigmaY, const char *polynomial_fit, const char *residual_square, const char *variance_fit, double *mean_squared_error, double *red_chisq, polynomial **variance, double kappa, int maxdeg1, int maxdeg2, double min_rms, double min_reject, bool verbose, const double *min_val, const double *max_val, int npos, double positions[][2]) |
| Fit a 2d polynomial to three table columns. | |
| const char * | uves_remove_string_prefix (const char *s, const char *prefix) |
| Remove named prefix from string. | |
| double | uves_gaussrand (void) |
| Pseudo-random gaussian distributed number. | |
| double | uves_spline_hermite_table (double xp, const cpl_table *t, const char *column_x, const char *column_y, int *istart) |
| Spline interpolation based on Hermite polynomials. | |
| double | uves_spline_hermite (double xp, const double *x, const double *y, int n, int *istart) |
| Spline interpolation based on Hermite polynomials. | |
| double | uves_spline_cubic (double xp, double *x, float *y, float *y2, int n, int *kstart) |
| Natural cubic-spline interpolation. | |
| bool | uves_table_is_sorted_double (const cpl_table *t, const char *column, const bool reverse) |
| Determine if a table is sorted. | |
| cpl_table * | uves_ordertable_traces_new (void) |
| Create the table that describes fibre traces. | |
| cpl_error_code | uves_ordertable_traces_add (cpl_table *traces, int fibre_ID, double fibre_offset, int fibre_mask) |
| Add a trace. | |
| static void | fmoffa_i (float x, const double a[], double *y, double dyda[]) |
| This subroutine gives the value of the Moffat (beta=4)+ linear functions at pixel of coordinates x estimated at one point. | |
| static void | fmoffa_c (float x, const double a[], double *y, double dyda[]) |
| Moffat profile. | |
| int | uves_moffat (const double x[], const double a[], double *result) |
| Evaluate a Moffat. | |
| int | uves_moffat_derivative (const double x[], const double a[], double result[]) |
| Evaluate Moffat derivative. | |
| int | uves_gauss (const double x[], const double a[], double *result) |
| Evaluate a gaussian. | |
| int | uves_gauss_derivative (const double x[], const double a[], double result[]) |
| Evaluate the derivatives of a gaussian. | |
| int | uves_gauss_linear (const double x[], const double a[], double *result) |
| Evaluate a gaussian with linear background. | |
| int | uves_gauss_linear_derivative (const double x[], const double a[], double result[]) |
| Evaluate the derivatives of a gaussian with linear background. | |
| cpl_image * | uves_create_image (uves_iterate_position *pos, enum uves_chip chip, const cpl_image *spectrum, const cpl_image *sky, const cpl_image *cosmic_image, const uves_extract_profile *profile, cpl_image **image_noise, uves_propertylist **image_header) |
| Reconstruct echelle image from spectrum. | |
| void | uves_frameset_dump (cpl_frameset *set) |
| #define REQ_CPL_MAJOR 3 |
Check compile time and runtime library versions.
This function should be called from "make check" to verify an installation
Definition at line 1498 of file uves_utils.c.
Referenced by uves_check_version().
| static cpl_error_code uves_cosrout | ( | cpl_image * | ima, | |
| cpl_image ** | msk, | |||
| const double | ron, | |||
| const double | gain, | |||
| const int | ns, | |||
| const double | sky, | |||
| const double | rc, | |||
| cpl_image ** | flt, | |||
| cpl_image ** | out | |||
| ) | [static] |
Remove cosmic ray events on single ccd exposure and replace them by interpolation on neighbourhood pixels.
| ima | input image | |
| flt | median filter of input image | |
| out | output image | |
| bkg | mean value of the background | |
| ron | Readout noise in ADU units. | |
| gain | Inverse gain factor (e-/ADU) | |
| ns | threshold for the detection of cosmic rays | |
| nc | critical ratio for discrimination of objects and cosmic rays | |
| msk | name of an optional frame containing the value 1 for cosmic rays and 0 for all other pixels |
Definition at line 540 of file uves_utils.c.
References check_nomsg, uves_find_next(), uves_msg_debug, uves_msg_warning, and uves_sort().
Referenced by uves_rcosmic().
| cpl_error_code uves_rcosmic | ( | cpl_image * | ima, | |
| cpl_image ** | flt, | |||
| cpl_image ** | out, | |||
| cpl_image ** | msk, | |||
| const double | sky, | |||
| const double | ron, | |||
| const double | gain, | |||
| const int | ns, | |||
| const double | rc | |||
| ) |
Remove cosmic ray events on single ccd exposure and replace them by interpolation on neighbourhood pixels.
| ima | input image | |
| flt | median filter of input image | |
| out | output image | |
| bkg | mean value of the background | |
| ron | Readout noise in ADU units. | |
| gain | Inverse gain factor (e-/ADU) | |
| ns | threshold for the detection of cosmic rays | |
| nc | critical ratio for discrimination of objects and cosmic rays | |
| msk | name of an optional frame containing the value 1 for cosmic rays and 0 for all other pixels |
Definition at line 412 of file uves_utils.c.
References check_nomsg, uves_cosrout(), and uves_filter_image_median().
Referenced by uves_filter_cosmic_test().
| cpl_parameterlist* uves_parameterlist_duplicate | ( | const cpl_parameterlist * | pin | ) |
Extract frames with given tag from frameset.
| pin | input parameterlist |
Definition at line 1152 of file uves_utils.c.
| const char* uves_string_toupper | ( | char * | s | ) |
Convert all lowercase characters in a string into uppercase characters.
| s | The string to convert. |
Definition at line 1184 of file uves_utils.c.
Referenced by uves_reduce_mflat(), and uves_reduce_scired().
| const char* uves_string_tolower | ( | char * | s | ) |
Convert all uppercase characters in a string into lowercase characters.
| s | The string to convert. |
Definition at line 1216 of file uves_utils.c.
| cpl_frameset* uves_frameset_extract | ( | const cpl_frameset * | frames, | |
| const char * | tag | |||
| ) |
Extract frames with given tag from frameset.
| frames | frame set | |
| tag | to search for |
Definition at line 1244 of file uves_utils.c.
References assure.
Referenced by uves_msflats().
| double uves_pow_int | ( | double | x, | |
| int | y | |||
| ) |
Calculate x to the y'th.
| x | ||
| y | The exponent. May be positive or zero or negative. |
Definition at line 1280 of file uves_utils.c.
Referenced by opt_measure_profile_order(), uves_polynomial_fit_1d(), and uves_polynomial_fit_2d().
| long uves_round_double | ( | double | x | ) |
Round a number to the nearest integer.
| x | The number to round |
Definition at line 1326 of file uves_utils.c.
Referenced by create_line_table(), deg2hms(), detect_lines(), detect_ripples(), estimate_sn(), estimate_threshold(), extract_ff_rebin_merge(), extract_order_simple(), find_centroid(), get_offset(), get_orderlength(), get_xcenter(), get_ycenter(), identify_lines(), integrate_flux(), opt_extract(), opt_get_order_width(), opt_measure_profile(), opt_measure_profile_order(), opt_sample_spatial_profile(), opt_subtract_sky(), repeat_orderdef(), subtract_sky(), subtract_sky_row(), update_max(), uves_draw_orders(), uves_extract(), uves_hough(), uves_iterate_increment(), uves_iterate_set_first(), uves_merge_orders(), uves_pfits_get_firstabsorder(), uves_pfits_get_lastabsorder(), uves_pfits_get_ordpred(), uves_pfits_get_traceid(), uves_pfits_get_windownumber(), uves_qclog_add_sci(), uves_rebin(), uves_reduce(), uves_reduce_scired(), and uves_wavecal_identify_lines_ppm().
| double uves_max_double | ( | double | x, | |
| double | y | |||
| ) |
Maximum of two numbers.
| x | First number | |
| y | Second number |
uves_round_double() .
Definition at line 1342 of file uves_utils.c.
Referenced by estimate_threshold(), extract_order_simple(), identify_lines(), integrate_flux(), opt_get_order_width(), opt_get_redchisq(), opt_get_sky(), subtract_sky_row(), uves_align(), uves_define_noise(), uves_locate_orders(), uves_rebin(), and uves_reduce().
| int uves_max_int | ( | int | x, | |
| int | y | |||
| ) |
Maximum of two numbers.
| x | First number | |
| y | Second number |
uves_round_double() .
Definition at line 1357 of file uves_utils.c.
Referenced by detect_lines(), estimate_threshold(), extract_order_simple(), filter_median(), find_centroid(), fit_order_linear(), get_offset(), identify_lines(), integrate_flux(), opt_measure_profile(), tflat_qclog(), trace_order(), uves_draw_lines(), uves_initialize(), uves_merge_orders(), uves_physmod_regress_echelle(), uves_polynomial_add_2d(), uves_qclog_add_sci(), uves_rebin(), uves_reduce(), and xcenter().
| double uves_min_double | ( | double | x, | |
| double | y | |||
| ) |
Minimum of two numbers.
| x | First number | |
| y | Second number |
uves_round_double() .
Definition at line 1373 of file uves_utils.c.
Referenced by extract_order_simple(), identify_lines(), integrate_flux(), opt_define_sky(), opt_get_order_width(), opt_get_sky(), subtract_sky_row(), uves_align(), uves_rebin(), and uves_reduce().
| int uves_min_int | ( | int | x, | |
| int | y | |||
| ) |
Minimum of two numbers.
| x | First number | |
| y | Second number |
uves_round_double() .
Definition at line 1388 of file uves_utils.c.
Referenced by detect_lines(), estimate_threshold(), extract_order_simple(), filter_median(), find_centroid(), get_offset(), identify_lines(), integrate_flux(), opt_measure_profile(), tflat_qclog(), trace_order(), uves_draw_lines(), uves_merge_orders(), uves_qclog_add_sci(), and xcenter().
| double uves_error_fraction | ( | double | x, | |
| double | y, | |||
| double | dx, | |||
| double | dy | |||
| ) |
Get uncertainty of division.
| x | numerator | |
| y | denominator | |
| dx | uncertainty (one sigma) of x | |
| dy | uncertainty (one sigma) of y | |
| MIDAS | implement MIDAS formula |
Definition at line 1406 of file uves_utils.c.
Referenced by uves_flatfielding().
| cpl_error_code uves_get_version | ( | int * | major, | |
| int * | minor, | |||
| int * | micro | |||
| ) |
Get UVES library version number.
| major | (output) If non-null, the major version number | |
| minor | (output) If non-null, the minor version number | |
| micro | (output) If non-null, the micro version number |
Definition at line 1427 of file uves_utils.c.
| int uves_get_version_binary | ( | void | ) |
Get UVES library binary version number.
Definition at line 1446 of file uves_utils.c.
| const char* uves_get_license | ( | void | ) |
Get the pipeline copyright and license.
Definition at line 1462 of file uves_utils.c.
Referenced by cpl_plugin_get_info().
| cpl_error_code uves_end | ( | const char * | recipe_id, | |
| const cpl_frameset * | frames | |||
| ) |
Recipe termination.
| recipe_id | Name of calling recipe | |
| frames | The output frame set |
uves_initialize().
Definition at line 1626 of file uves_utils.c.
References assure_mem, check_nomsg, uves_msg_get_warnings(), and uves_msg_warning.
| char* uves_initialize | ( | cpl_frameset * | frames, | |
| const cpl_parameterlist * | parlist, | |||
| const char * | recipe_id, | |||
| const char * | short_descr | |||
| ) |
Recipe initialization.
| frames | The input frame set | |
| parlist | The input parameter list | |
| recipe_id | Name of the recipe, e.g. uves_mbias | |
| short_descr | A short description of what the recipe does | |
| frames | The input frame set |
uves_dfs_set_groups()), andDefinition at line 1695 of file uves_utils.c.
References check, uves_check_version(), uves_max_int(), uves_msg, uves_msg_debug, uves_msg_low, uves_msg_set_level(), and uves_print_cpl_frameset().
Referenced by test_save_frame().
| cpl_image* uves_average_images | ( | const cpl_image * | image1, | |
| const cpl_image * | noise1, | |||
| const cpl_image * | image2, | |||
| const cpl_image * | noise2, | |||
| cpl_image ** | noise | |||
| ) |
Optimally average images.
| image1 | First image | |
| noise1 | Noise (one sigma) of first image | |
| image2 | Second image | |
| noise2 | Noise (one sigma) of second image | |
| noise | (Output) Combined noise image. This may not be NULL. |
and the combined noise is
1/sigma^2 = 1 / sigma_1^2 + 1 / sigma_2^2.
Bad pixels are properly propagated (i.e. a resulting pixel is marked bad if both inputs are bad ; if only one input is good, this input is used as the output and the 'bad' input is ignored).
Definition at line 1831 of file uves_utils.c.
References assure.
Referenced by subtract_sky_row().
| uves_propertylist* uves_initialize_image_header | ( | const char * | ctype1, | |
| const char * | ctype2, | |||
| const char * | bunit, | |||
| double | crval1, | |||
| double | crval2, | |||
| double | crpix1, | |||
| double | crpix2, | |||
| double | cdelt1, | |||
| double | cdelt2 | |||
| ) |
Initialize image header.
| ctype1 | Value of CTYPE1 keyword | |
| ctype2 | Value of CTYPE2 keyword | |
| bunit | Value of BUNIT keyword | |
| crval1 | Value of CRVAL1 keyword | |
| crval2 | Value of CRVAL2 keyword | |
| crpix1 | Value of CRPIX1 keyword | |
| crpix2 | Value of CRPIX2 keyword | |
| cdelt1 | Value of CDELT1 keyword | |
| cdelt2 | Value of CDELT2 keyword |
Definition at line 1958 of file uves_utils.c.
References check, uves_pfits_set_bunit(), uves_pfits_set_cdelt1(), uves_pfits_set_cdelt2(), uves_pfits_set_crpix1(), uves_pfits_set_crpix2(), uves_pfits_set_crval1(), uves_pfits_set_crval2(), uves_pfits_set_ctype1(), uves_pfits_set_ctype2(), and uves_propertylist_new().
Referenced by uves_merge_orders(), uves_rebin(), and uves_scired_process_chip().
| cpl_image* uves_define_noise | ( | const cpl_image * | image, | |
| const uves_propertylist * | image_header, | |||
| int | ncom, | |||
| enum uves_chip | chip | |||
| ) |
Create noise image.
| image | Input image | |
| image_header | Input image header | |
| ncom | Number of combined frames | |
| chip | CCD chip |
The noise decreases accordingly if the number of combined frames, ncom, is more than one. Those frames are assumed to have been median stacked.
(See source code for the exact error propagation formulas).
Definition at line 2001 of file uves_utils.c.
References assure, assure_mem, check, uves_max_double(), uves_pfits_get_gain(), uves_pfits_get_ron_adu(), and uves_tostring_cpl_type().
Referenced by revise_noise(), and uves_reduce().
| cpl_error_code uves_subtract_bias | ( | cpl_image * | image, | |
| const cpl_image * | master_bias | |||
| ) |
Subtract bias.
| image | The image to be de-biased | |
| master_bias | The bias image to subtract |
Definition at line 2127 of file uves_utils.c.
References check, and passure.
Referenced by uves_mflat_process_chip(), and uves_reduce().
| cpl_error_code uves_subtract_dark | ( | cpl_image * | image, | |
| const uves_propertylist * | image_header, | |||
| const cpl_image * | master_dark, | |||
| const uves_propertylist * | mdark_header | |||
| ) |
Subtract dark.
| image | The image to be dark-subtracted | |
| image_header | The image header | |
| master_dark | The dark image to subtract | |
| mdark_header | The master dark header |
Definition at line 2171 of file uves_utils.c.
References check, passure, uves_msg, and uves_pfits_get_exptime().
Referenced by uves_mflat_process_chip(), and uves_reduce().
| int uves_absolute_order | ( | int | first_abs_order, | |
| int | last_abs_order, | |||
| int | relative_order | |||
| ) |
Get the absolute order number.
| first_abs_order | Absolute order number of row number 1 in the spectrum image | |
| last_abs_order | Absolute order number of the highest row in the spectrum image | |
| relative_order | Relative order number (row number in spectrum image) |
Definition at line 2221 of file uves_utils.c.
Referenced by uves_rebin(), and uves_response_efficiency().
| double uves_average_reject | ( | cpl_table * | t, | |
| const char * | column, | |||
| const char * | residual2, | |||
| double | kappa | |||
| ) |
Get average with iterative rejection.
| t | table, rows with outliers are removed | |
| column | with data values | |
| residual2 | name of temporary column used to store the squared residuals (this column must not already exist) | |
| kappa | rejection parameter |
Definition at line 2243 of file uves_utils.c.
References check_nomsg, and median().
Referenced by uves_average_reject_test(), and uves_delete_bad_lines().
| polynomial* uves_polynomial_regression_1d | ( | cpl_table * | t, | |
| const char * | X, | |||
| const char * | Y, | |||
| const char * | sigmaY, | |||
| int | degree, | |||
| const char * | polynomial_fit, | |||
| const char * | residual_square, | |||
| double * | mean_squared_error, | |||
| double | kappa | |||
| ) |
Fit a 1d polynomial to two table columns.
| t | Table | |
| X | Name of table column containing independent variable | |
| Y | Name of table column containing dependent variable | |
| sigmaY | Uncertainty of dependent variable. If NULL, constant uncertainties are assumed. | |
| degree | Degree of polynomial fit | |
| polynomial_fit | Name of column to add | |
| residual_square | Name of column to add | |
| mean_squared_error | Mean squared error of the residuals | |
| kappa | If positive, the value of kappa used in a kappa sigma-clipping. Ignored if negative. |
If non-NULL the columns specified by the parameters polynomial_fit and residual_square are added to the table (containing the fitted value and the squared residual for each point). If any of these columns already exist, an error is set.
If kappa is positive, a kappa-sigma clipping is performed (iteratively, until there are no points with residuals worse than kappa*sigma). The rejected points (rows) are physically removed from the table.
Note that rows with invalid values are not handled properly (the garbage values are used for the fitting). Therefore the input table should not have invalid rows.
Definition at line 2320 of file uves_utils.c.
References assure, check, uves_msg_debug, uves_polynomial_delete(), uves_polynomial_evaluate_1d(), uves_polynomial_fit_1d(), and uves_tostring_cpl_type().
Referenced by fit_order_linear(), opt_measure_profile(), opt_measure_profile_order(), uves_get_blaze_ratio(), and uves_physmod_calmap().
| polynomial* uves_polynomial_regression_2d | ( | cpl_table * | t, | |
| const char * | X1, | |||
| const char * | X2, | |||
| const char * | Y, | |||
| const char * | sigmaY, | |||
| int | degree1, | |||
| int | degree2, | |||
| const char * | polynomial_fit, | |||
| const char * | residual_square, | |||
| const char * | variance_fit, | |||
| double * | mse, | |||
| double * | red_chisq, | |||
| polynomial ** | variance, | |||
| double | kappa, | |||
| double | min_reject | |||
| ) |
Fit a 2d polynomial to three table columns.
| t | The table | |
| X1 | Name of table column containing 1st independent variable | |
| X2 | Name of table column containing 2nd independent variable | |
| Y | Name of table column containing dependent variable | |
| sigmaY | Uncertainty of dependent variable. If NULL, constant uncertainties are assumed. | |
| degree1 | Degree of polynomial fit (1st variable) | |
| degree2 | Degree of polynomial fit (2nd variable) | |
| polynomial_fit | If non-NULL, name of column to add. The fitted value. | |
| residual_square | If non-NULL, name of column to add. The squared residual of the fit. | |
| variance_fit | If non-NULL, name of column to add. Variance of the fitted value. | |
| mean_squared_error | (out) Mean squared error of the residuals. May be NULL. | |
| red_chisq | (out) Reduced chi square of the fit. May be NULL. | |
| variance | (out) Variance of the fit-polynomial (which is in itself a polynomial; see also uves_polynomial_fit_2d() ). May be NULL. | |
| kappa | If positive, the value of kappa used in a kappa sigma-clipping. Ignored if negative. | |
| min_reject | Minimum number of outliers worth rejecting. Stop iterating (for efficiency) if less than this relative number of outliers (e.g. 0.001) are detected. Negative to disable |
If non-NULL the columns specified by the parameters polynomial_fit, residual_square and variance_fit are added to the table (containing the fitted value, the squared residual and the variance of the fitted value, for each point).
If non-NULL, the mean_squared_error and red_chisq (reduced chi square) are calculated.
If non-NULL the parameter variance will contain the polynomial that defines the variance of the fit (i.e. as function of x1 and x2 ).
To calculate variances or reduced chi square, the parameter sigmaY must be non-NULL.
If kappa is positive, a kappa-sigma clipping is performed (iteratively, until there are no points with residuals worse than kappa*sigma). The rejected points (rows) are physically removed from the table.
Also see uves_polynomial_regression_1d() .
Definition at line 2593 of file uves_utils.c.
References assure, check, uves_msg_debug, uves_polynomial_delete(), uves_polynomial_evaluate_2d(), uves_polynomial_fit_2d(), and uves_tostring_cpl_type().
Referenced by calibrate_global(), create_line_table(), opt_measure_profile(), uves_locate_orders(), uves_physmod_calmap(), uves_physmod_msrawxy(), uves_physmod_regress_echelle(), and uves_polynomial_regression_2d_autodegree().
| polynomial* uves_polynomial_regression_2d_autodegree | ( | cpl_table * | t, | |
| const char * | X1, | |||
| const char * | X2, | |||
| const char * | Y, | |||
| const char * | sigmaY, | |||
| const char * | polynomial_fit, | |||
| const char * | residual_square, | |||
| const char * | variance_fit, | |||
| double * | mean_squared_error, | |||
| double * | red_chisq, | |||
| polynomial ** | variance, | |||
| double | kappa, | |||
| int | maxdeg1, | |||
| int | maxdeg2, | |||
| double | min_rms, | |||
| double | min_reject, | |||
| bool | verbose, | |||
| const double * | min_val, | |||
| const double * | max_val, | |||
| int | npos, | |||
| double | positions[][2] | |||
| ) |
Fit a 2d polynomial to three table columns.
| t | The table | |
| X1 | Name of table column containing 1st independent variable | |
| X2 | Name of table column containing 2nd independent variable | |
| Y | Name of table column containing dependent variable | |
| sigmaY | Uncertainty of dependent variable. If NULL, constant uncertainties are assumed. | |
| polynomial_fit | If non-NULL, name of column to add. The fitted value. | |
| residual_square | If non-NULL, name of column to add. The squared residual of the fit. | |
| variance_fit | If non-NULL, name of column to add. Variance of the fitted value. | |
| mean_squared_error | (out) Mean squared error of the residuals. May be NULL. | |
| red_chisq | (out) Reduced chi square of the fit. May be NULL. | |
| variance | (out) Variance of the fit-polynomial (which is in itself a polynomial; see also uves_polynomial_fit_2d() ). May be NULL. | |
| kappa | If positive, the value of kappa used in a kappa sigma-clipping. Ignored if negative. | |
| maxdeg1 | Maximum degree of 1st independent variable | |
| maxdeg2 | Maximum degree of 2nd independent variable | |
| min_rms | Minimum RMS to aim for. Stop iterating (for efficiency) if this precision is achieved. Set to negative to disable. | |
| min_reject | Minimum number of outliers worth rejecting. Stop iterating (for efficiency) if less than this relative number of outliers (e.g. 0.001) are detected. Negative to disable | |
| verbose | print messages at info level (true) or debug level (false) | |
| min_val | minimum allowed value. A fit producing a value lower than this number will be rejected. Set to NULL to disable | |
| max_val | maximum allowed value | |
| npos | size of positions array | |
| positions | positions where the fitted solution must be inside the limits given by min_val / max_val (for the solution to be accepted) |
uves_polynomial_regression_2d() except it automatically selects the best polynomial degrees based on the RMS of the fit.
Definition at line 3025 of file uves_utils.c.
References assure, assure_mem, check, check_nomsg, uves_error_reset, uves_msg_debug, uves_msg_low, uves_polynomial_delete(), uves_polynomial_evaluate_2d(), and uves_polynomial_regression_2d().
Referenced by calibrate_global(), opt_measure_profile(), and repeat_orderdef().
| const char* uves_remove_string_prefix | ( | const char * | s, | |
| const char * | prefix | |||
| ) |
Remove named prefix from string.
| s | string | |
| prefix | the prefix to remove |
Definition at line 3332 of file uves_utils.c.
References assure.
Referenced by tflat_qclog(), uves_qclog_add_common_wave(), and uves_qclog_init().
| double uves_gaussrand | ( | void | ) |
Pseudo-random gaussian distributed number.
Definition at line 3365 of file uves_utils.c.
Referenced by uves_average_reject_test().
| double uves_spline_hermite_table | ( | double | xp, | |
| const cpl_table * | t, | |||
| const char * | column_x, | |||
| const char * | column_y, | |||
| int * | istart | |||
| ) |
Spline interpolation based on Hermite polynomials.
| xp | x-value to interpolate | |
| t | Table containing the columns to interpolate | |
| column_x | Column of x-values | |
| column_y | Column of y-values | |
| istart | (input/output) initial row (set to 0 to search all row) |
Definition at line 3403 of file uves_utils.c.
References check, and uves_spline_hermite().
Referenced by uves_calculate_response(), uves_normalize_spectrum(), and uves_scired_process_chip().
| double uves_spline_hermite | ( | double | xp, | |
| const double * | x, | |||
| const double * | y, | |||
| int | n, | |||
| int * | istart | |||
| ) |
Spline interpolation based on Hermite polynomials.
| xp | x-value to interpolate | |
| x | x-values | |
| y | y-values | |
| n | array length | |
| istart | (input/output) initial row (set to 0 to search all row) |
Adopted from: Cristian Levin - ESO La Silla, 1-Apr-1991
Definition at line 3441 of file uves_utils.c.
Referenced by uves_spline_hermite_table().
| double uves_spline_cubic | ( | double | xp, | |
| double * | x, | |||
| float * | y, | |||
| float * | y2, | |||
| int | n, | |||
| int * | kstart | |||
| ) |
Natural cubic-spline interpolation.
| xp | x-value to interpolate | |
| x | x-array [1..n], must be sorted ascending | |
| y | y-array [1..n] | |
| y2 | y2-array [1..n] (2-nd derivatives) | |
| n | array size | |
| kstart | Start search index. Contains on output index of largest x less than xp. |
Definition at line 3513 of file uves_utils.c.
References assure, and assure_nomsg.
| bool uves_table_is_sorted_double | ( | const cpl_table * | t, | |
| const char * | column, | |||
| const bool | reverse | |||
| ) |
Determine if a table is sorted.
| t | Table | |
| column | Column name, type must be double | |
| reverse | Flag indicating to check for ascending (false) or descending (true) sort order |
Definition at line 3567 of file uves_utils.c.
References passure.
| cpl_table* uves_ordertable_traces_new | ( | void | ) |
Create the table that describes fibre traces.
cpl_table_delete() . Definition at line 3618 of file uves_utils.c.
References check.
| cpl_error_code uves_ordertable_traces_add | ( | cpl_table * | traces, | |
| int | fibre_ID, | |||
| double | fibre_offset, | |||
| int | fibre_mask | |||
| ) |
Add a trace.
| traces | The table containing information on the position of fibre traces (FLAMES/UVES) | |
| fibre_ID | The fibre ID number | |
| fibre_offset | Offset of this fibre | |
| fibre_mask | 0 if fibre is disabled, 1 if it is enabled |
Definition at line 3645 of file uves_utils.c.
| static void fmoffa_i | ( | float | x, | |
| const double | a[], | |||
| double * | y, | |||
| double | dyda[] | |||
| ) | [static] |
This subroutine gives the value of the Moffat (beta=4)+ linear functions at pixel of coordinates x estimated at one point.
| x | input pixel coordinates | |
| a | profile coefficients | |
| y | Moffat profile values | |
| dyda | errors associated to y |
Definition at line 3697 of file uves_utils.c.
Referenced by fmoffa_c().
| static void fmoffa_c | ( | float | x, | |
| const double | a[], | |||
| double * | y, | |||
| double | dyda[] | |||
| ) | [static] |
Moffat profile.
| x | input pixel coordinates | |
| a | profile coefficients | |
| y | Moffat profile values | |
| dyda | errors associated to y |
Definition at line 3766 of file uves_utils.c.
References fmoffa_i().
Referenced by uves_moffat(), and uves_moffat_derivative().
| int uves_moffat | ( | const double | x[], | |
| const double | a[], | |||
| double * | result | |||
| ) |
Evaluate a Moffat.
| x | The evaluation point | |
| a | The parameters defining the gaussian | |
| result | The function value |
Definition at line 3832 of file uves_utils.c.
References fmoffa_c().
Referenced by eval_gauss(), and uves_extract().
| int uves_moffat_derivative | ( | const double | x[], | |
| const double | a[], | |||
| double | result[] | |||
| ) |
Evaluate Moffat derivative.
| x | The evaluation point | |
| a | The parameters defining the gaussian | |
| result | The function value |
Definition at line 3851 of file uves_utils.c.
References fmoffa_c().
Referenced by uves_extract().
| int uves_gauss | ( | const double | x[], | |
| const double | a[], | |||
| double * | result | |||
| ) |
Evaluate a gaussian.
| x | The evaluation point | |
| a | The parameters defining the gaussian | |
| result | The function value |
a3 + a2 / sqrt(2 pi a1^2) * exp( -(x0 - a0)^2/(2 a1^2)).
where a0, ..., a3 are the first four elements of a, and x0 is the first element of x .
The function never fails.
Definition at line 3883 of file uves_utils.c.
Referenced by find_centroid(), repeat_orderdef(), test_extract(), uves_extract(), uves_fit_gaussian_2d_image(), and xcenter().
| int uves_gauss_derivative | ( | const double | x[], | |
| const double | a[], | |||
| double | result[] | |||
| ) |
Evaluate the derivatives of a gaussian.
| x | The evaluation point | |
| a | The parameters defining the gaussian | |
| result | The derivatives wrt to parameters |
The function never returns failure.
Definition at line 3938 of file uves_utils.c.
Referenced by find_centroid(), repeat_orderdef(), test_extract(), uves_extract(), uves_fit_gaussian_2d_image(), and xcenter().
| int uves_gauss_linear | ( | const double | x[], | |
| const double | a[], | |||
| double * | result | |||
| ) |
Evaluate a gaussian with linear background.
| x | The evaluation point | |
| a | The parameters defining the gaussian | |
| result | The function value |
a3 + a4*(x0 - a0) + a2 / sqrt(2 pi a1^2) * exp( -(x0 - a0)^2/(2 a1^2)).
where a0, ..., a4 are the first five elements of a, and x0 is the first element of x .
The function never fails.
Definition at line 4003 of file uves_utils.c.
Referenced by xcenter().
| int uves_gauss_linear_derivative | ( | const double | x[], | |
| const double | a[], | |||
| double | result[] | |||
| ) |
Evaluate the derivatives of a gaussian with linear background.
| x | The evaluation point | |
| a | The parameters defining the gaussian | |
| result | The derivatives wrt to parameters |
f(x0,a) = a3 + a4*(x0 - a0) + a2 / sqrt(2 pi a1^2) * exp( -(x0 - a0)^2/(2 a1^2))
with respect to a0, ..., a4. On successful evaluation, the i'th element of the result vector contains df/da_i.
The function never returns failure.
Definition at line 4062 of file uves_utils.c.
Referenced by xcenter().
| cpl_image* uves_create_image | ( | uves_iterate_position * | pos, | |
| enum uves_chip | chip, | |||
| const cpl_image * | spectrum, | |||
| const cpl_image * | sky, | |||
| const cpl_image * | cosmic_image, | |||
| const uves_extract_profile * | profile, | |||
| cpl_image ** | image_noise, | |||
| uves_propertylist ** | image_header | |||
| ) |
Reconstruct echelle image from spectrum.
| pos | position iterator | |
| chip | CCD chip (for header) | |
| spectrum | object spectrum | |
| sky | sky spectrum | |
| cosmic_image | if non-NULL, image of cosmic rays. Values > 0 mark CR hits | |
| image_noise | (output) error bars | |
| image_header | (output) describing the output image |
Definition at line 4126 of file uves_utils.c.
References assure_mem, uves_iterate_finished(), uves_iterate_increment(), uves_iterate_set_first(), uves_propertylist_append_double(), and uves_propertylist_new().
Referenced by test_extract().
1.5.1