Functions | |
| static int | extract_order_simple (const cpl_image *image, const cpl_image *image_noise, const polynomial *order_locations, int order, int minorder, int spectrum_row, double offset, double slit_length, extract_method method, const cpl_image *weights, bool extract_partial, cpl_image *spectrum, cpl_image *spectrum_noise, cpl_binary *spectrum_badmap, cpl_table **info_tbl, double *sn) |
| Extract one order using linear, average or weighted extraction. | |
| static double | area_above_line (int y, double left, double right) |
| Calculate the area of a pixel that is above a line. | |
| static cpl_table * | opt_define_sky (const cpl_image *image, const cpl_image *weights, uves_iterate_position *pos) |
| Define sky/object rows. | |
| static cpl_image * | opt_extract_sky (const cpl_image *image, const cpl_image *image_noise, const cpl_image *weights, uves_iterate_position *pos, cpl_image *sky_spectrum, cpl_image *sky_spectrum_noise) |
| Extract and subtract sky. | |
| static cpl_image * | opt_subtract_sky (const cpl_image *image, const cpl_image *image_noise, const cpl_image *weights, uves_iterate_position *pos, const cpl_table *sky_map, cpl_image *sky_spectrum, cpl_image *sky_spectrum_noise) |
| Measure and subtract sky. | |
| static cpl_table ** | opt_sample_spatial_profile (const cpl_image *image, const cpl_image *weights, uves_iterate_position *pos, int stepx, int sampling_factor, int *nbins) |
| Sample spatial profile. | |
| static uves_extract_profile * | opt_measure_profile (const cpl_image *image, const cpl_image *image_noise, const cpl_image *weights, uves_iterate_position *pos, int chunk, int sampling_factor, int(*f)(const double x[], const double a[], double *result), int(*dfda)(const double x[], const double a[], double result[]), int M, const cpl_image *sky_spectrum, cpl_table *info_tbl, cpl_table **profile_global) |
| Measure spatial profile (all orders). | |
| static cpl_table * | opt_measure_profile_order (const cpl_image *image, const cpl_image *image_noise, const cpl_binary *image_bpm, uves_iterate_position *pos, int chunk, int(*f)(const double x[], const double a[], double *result), int(*dfda)(const double x[], const double a[], double result[]), int M, const cpl_image *sky_spectrum) |
| Measure spatial profile (analytical). | |
| static void | revise_noise (cpl_image *image_noise, const cpl_binary *image_bpm, const uves_propertylist *image_header, uves_iterate_position *pos, const cpl_image *spectrum, const cpl_image *sky_spectrum, const uves_extract_profile *profile, enum uves_chip chip) |
| Refine error bars. | |
| static int | opt_extract (cpl_image *image, const cpl_image *image_noise, uves_iterate_position *pos, const uves_extract_profile *profile, bool optimal_extract_sky, double kappa, cpl_table *cosmic_mask, int *cr_row, cpl_table *profile_table, int *prof_row, cpl_image *spectrum, cpl_image *spectrum_noise, cpl_image *weights, cpl_image *sky_spectrum, cpl_image *sky_spectrum_noise, double *sn) |
| Optimally extract order using the given the profile. | |
| static int | opt_get_order_width (const uves_iterate_position *pos) |
| Get width of order. | |
| static double | estimate_sn (const cpl_image *image, const cpl_image *image_noise, uves_iterate_position *pos) |
| Estimate the S/N of the input frame. | |
| static double | opt_get_sky (const double *image_data, const double *noise_data, const double *weights_data, uves_iterate_position *pos, const cpl_table *sky_map, double buffer_flux[], double buffer_noise[], double *sky_background_noise) |
| Measure sky level (median). | |
| static double | opt_get_noise_median (const double *noise_data, const cpl_binary *image_bpm, uves_iterate_position *pos, double noise_buffer[]) |
| Measure median noise level of extraction bin. | |
| static double | opt_get_flux_sky_variance (const double *image_data, const double *noise_data, double *weights_data, uves_iterate_position *pos, const uves_extract_profile *profile, bool optimal_extract_sky, double median_noise, double *variance, double *sky_background, double *sky_background_noise) |
| Get flux, sky and variances of current bin. | |
| static bool | opt_reject_outlier (const double *image_data, const double *noise_data, cpl_binary *image_bpm, double *weights_data, uves_iterate_position *pos, const uves_extract_profile *profile, double kappa, double flux, double sky_background, double red_chisq, cpl_table *cosmic_mask, int *cr_row, int *hot_pixels, int *cold_pixels) |
| Find and reject outlier pixel. | |
| static double | opt_get_redchisq (const uves_extract_profile *profile, const uves_iterate_position *pos) |
| Get reduced chi^2 for current bin. | |
| static polynomial * | repeat_orderdef (const cpl_image *image, const cpl_image *image_noise, const polynomial *guess_locations, int minorder, int maxorder, slit_geometry sg, cpl_table *info_tbl) |
| Refine order definition using the science frame. | |
| static double | detect_ripples (const cpl_image *spectrum, const uves_iterate_position *pos, double sn) |
| Try to detect and warn about any optimal extraction ripples (happening if oversampling factor is too small). | |
| cpl_parameterlist * | uves_extract_define_parameters (void) |
| Define recipe parameters used for extraction. | |
| extract_method | uves_get_extract_method (const cpl_parameterlist *parameters, const char *context, const char *subcontext) |
| Read extraction method from parameter list. | |
| cpl_image * | uves_extract (cpl_image *image, cpl_image *image_noise, const uves_propertylist *image_header, const cpl_table *ordertable, const polynomial *order_locations_raw, double slit_length, double offset, const cpl_parameterlist *parameters, const char *context, bool extract_partial, bool DEBUG, enum uves_chip chip, uves_propertylist **header, cpl_image **spectrum_noise, cpl_image **sky_spectrum, cpl_image **sky_spectrum_noise, cpl_table **cosmic_mask, cpl_image **cosmic_image, cpl_table **profile_table, cpl_image **weights, cpl_table **info_tbl, cpl_table **order_trace) |
| Extract a spectrum. | |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Extract one order using linear, average or weighted extraction.
Definition at line 1890 of file uves_extract.c. References area_above_line(), assure, check, passure, uves_max_double(), uves_max_int(), uves_min_double(), uves_min_int(), uves_polynomial_evaluate_2d(), and uves_round_double(). |
|
||||||||||||||||
|
Calculate the area of a pixel that is above a line.
To extend this function to also work with negative line slopes, a few cases more cases must be handled (see code). The extraction algorithm itself doesn't depend on the slope being positive. Definition at line 2286 of file uves_extract.c. References assure. Referenced by extract_order_simple(). |
|
||||||||||||||||
|
Define sky/object rows.
Definition at line 2539 of file uves_extract.c. References check, and opt_sample_spatial_profile(). Referenced by opt_extract_sky(). |
|
||||||||||||||||||||||||||||
|
Extract and subtract sky.
Definition at line 2490 of file uves_extract.c. References check, opt_define_sky(), opt_subtract_sky(), uves_msg, and uves_msg_low. Referenced by uves_extract(). |
|
||||||||||||||||||||||||||||||||
|
Measure and subtract sky.
The sky subtracted image has the same bpm as the input image. The sky is estimated as the median of the pixels defined by the sky map Definition at line 2788 of file uves_extract.c. References assure_mem, opt_get_sky(), uves_iterate_finished(), uves_iterate_increment(), uves_iterate_set_first(), and uves_round_double(). Referenced by opt_extract_sky(). |
|
||||||||||||||||||||||||||||
|
Sample spatial profile.
Bad pixels are taken into account Definition at line 2646 of file uves_extract.c. References assure, and assure_mem. Referenced by opt_define_sky(). |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Measure spatial profile (all orders).
Mukai, Koji: "Optimal extraction of cross-dispersed spectra" Astronomical Society of the Pacific, Publications (ISSN 0004-6280), vol. 102, Feb. 1990, p. 183-189. The center and width are allowed to vary as low-degree global polynomials as function of (x, order). For better statisics the signal is collapsed in chunks before applying the analytical fit. If f is NULL, the "virtual resampling" algorithm is used, as described in section 3 of Mukai(1990). Definition at line 2947 of file uves_extract.c. References assure_mem, check, opt_get_order_width(), passure, and uves_round_double(). Referenced by uves_extract(). |
|
||||||||||||||||||||||||||||||||||||||||
|
Measure spatial profile (analytical).
Next, center(x,order) and width(x,order) are estimated as 2d polynomials while rejecting outliers. Definition at line 4185 of file uves_extract.c. References assure_mem, check, passure, and uves_round_double(). |
|
||||||||||||||||||||||||||||||||||||
|
Refine error bars.
Definition at line 2385 of file uves_extract.c. References assure_mem, uves_iterate_finished(), uves_iterate_increment(), and uves_iterate_set_first(). |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Optimally extract order using the given the profile.
During extraction hot/cold pixels (usually cosmic rays and 'dead' detector columns) are defined as pixels deviating more than kappa*sigma*sqrt(chi^2/N) from the inferred profile, where sigma is the uncertainty of pixel flux, chi^2/N is the (globally modelled) reduced chi square at the current bin, and kappa is a dimensionless parameter. (Note: if chi^2/N == 1 (a good fit), this is just standard kappa-sigma-clipping. The extra factor sqrt(chi^2/N) is there to make the kappa-sigma-clipping robust against systematically over-/underestimated uncertainties.) For more details and pseudo-code, refer to the source code. Definition at line 5474 of file uves_extract.c. References assure, check, opt_get_order_width(), uves_round_double(), and uves_tostring_cpl_type(). Referenced by uves_extract(). |
|
|
Get width of order.
Definition at line 5328 of file uves_extract.c. References passure, uves_error_reset, uves_max_double(), uves_min_double(), uves_msg_debug, uves_msg_warning, uves_polynomial_evaluate_2d(), uves_polynomial_solve_2d(), and uves_round_double(). Referenced by opt_extract(), and opt_measure_profile(). |
|
||||||||||||||||
|
Estimate the S/N of the input frame.
Definition at line 1755 of file uves_extract.c. References assure, passure, uves_iterate_finished(), uves_iterate_increment(), uves_iterate_set_first(), uves_msg_debug, and uves_round_double(). Referenced by uves_extract(). |
|
||||||||||||||||||||||||||||||||||||
|
Measure sky level (median).
The computed sky level is *not* normalized to the full slit (which makes it easier to subtract the sky from each pixel). If there are no good pixels, the sky is set to zero, and the noise to 1. Definition at line 5808 of file uves_extract.c. References uves_max_double(), uves_min_double(), and uves_tools_get_median(). Referenced by opt_subtract_sky(). |
|
||||||||||||||||||||
|
Measure median noise level of extraction bin.
Definition at line 5924 of file uves_extract.c. References uves_tools_get_median(). |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Get flux, sky and variances of current bin.
F = [ sum_i (profile_i^2/variance_i * flux_i/profile_i) ] / [ sum_i (profile_i^2/variance_i) ] Variance = 1 / [ sum_i (profile_i^2/variance_i) ] If the optimal_extract_sky flag is set, generalized formulas are used for the optimal object and sky flux. Horne's formulas were derived by minimizing chi^2 = sum_i (flux_i - F * profile_i)^2/variance_i with respect to F, then using the error propagation formula to get the Variance while noting that Variance(flux_i) = variance_i. (profile_i and variance_i are assumed exactly known, i.e. to have zero variance). To generalize the formulas to include the optimal determination of the sky, we simply add a constant sky background, S, to the model and repeat the calculation. Then, minimization of chi^2 = sum (flux_i - (S + F * profile_i))^2/variance_i with respect to F and S leads to (the calculation is somewhat tedious but straightforward) F = [ (sum_i 1/variance_i ) sum_i profile_i flux_i / variance_i - (sum_i profile_i/variance_i) sum_i flux_i / variance_i ] / Denominator S = [ (sum_i profile_i^2/variance_i) sum_i flux_i / variance_i - (sum_i profile_i/variance_i) sum_i profile_i flux_i / variance_i ] / Denominator Variance(F) = (sum_i 1 / variance_i) / Denominator Variance(S) = (sum_i profile_i / variance_i) / Denominator where Denominator is short for (sum_i 1/variance_i) sum_i profile_i^2/variance_i - (sum_i profile_i/variance_i)^2 These formulas has been shown to give the same results as a two-parameter LM chi^2 minimization Definition at line 6028 of file uves_extract.c. |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Find and reject outlier pixel.
Definition at line 6174 of file uves_extract.c. References check, and uves_msg_debug. |
|
||||||||||||
|
Get reduced chi^2 for current bin.
Definition at line 6284 of file uves_extract.c. References uves_max_double(), uves_polynomial_evaluate_1d(), and uves_polynomial_evaluate_2d(). |
|
||||||||||||||||||||||||||||||||
|
Refine order definition using the science frame.
This implementation is very much simpler than the order-definition recipe, because we already know the approximate order location across the entire chip. (On the contrary, the order-definition recipe works ab nihil). Definition at line 6330 of file uves_extract.c. References assure, check, slit_geometry::length, uves_error_reset, uves_gauss(), uves_gauss_derivative(), uves_msg_debug, uves_polynomial_evaluate_2d(), and uves_round_double(). Referenced by uves_extract(). |
|
||||||||||||||||
|
Try to detect and warn about any optimal extraction ripples (happening if oversampling factor is too small).
Definition at line 1612 of file uves_extract.c. References check, uves_msg_debug, uves_polynomial_derivative_2d(), and uves_round_double(). |
|
|
Define recipe parameters used for extraction.
Definition at line 562 of file uves_extract.c. |
|
||||||||||||||||
|
Read extraction method from parameter list.
Definition at line 760 of file uves_extract.c. Referenced by uves_extract(), and uves_reduce(). |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Extract a spectrum.
Bad pixel handling: In average extraction mode, bad pixels are ignored (i.e. don't contribute to the average). In linear extraction mode, the good pixels are summed, and the flux is always normalized to the slit length. In optimal extraction mode, pixels with residuals larger than kappa sigma are rejected (sigma is the uncertainty of the pixel flux) If the flag extract_partial is true, an extraction bin which lies partially outside the image will be extracted (and the flux normalized to the full slit length in case of linear extraction). This flag should be set to false if the object spatial profile is not nearly constant across the extraction slit, otherwise an artificial increase/drop in flux will appear near the edge of the image. This flag is ignored for optimal extraction. Bins which are not extracted (outside the image) are set to 'bad' in the final spectrum image.
Definition at line 866 of file uves_extract.c. References assure, check, check_nomsg, estimate_sn(), slit_geometry::length, slit_geometry::offset, opt_extract(), opt_extract_sky(), opt_measure_profile(), passure, repeat_orderdef(), uves_gauss(), uves_gauss_derivative(), uves_get_extract_method(), uves_iterate_new(), uves_moffat(), uves_moffat_derivative(), uves_msg, uves_msg_low, uves_polynomial_duplicate(), uves_polynomial_get_dimension(), and uves_round_double(). Referenced by extract_ff_rebin_merge(), and test_extract(). |
1.4.6