Rectify Image in pixel spaces following the
[DRL Functions]

Defines

#define SLIT_USEFUL_WINDOW_FACTOR   0.80
#define FIT_FWHM_LIMIT   30
#define OPT_EXTRACT_SLIT_SIZE   80
#define MSE_LIMIT   1
#define FLUX_MODE   0
#define WAVEMAP_MODE   1
#define REGDEBUG_PIXELSIZE   0
#define REGDEBUG_INTEGRATE   0

Functions

static void xsh_image_gaussian_fit_y (cpl_image *img, int chunk_size, int deg_poly, int oversample, cpl_polynomial **center, cpl_polynomial **height, cpl_polynomial **width, cpl_polynomial **offset)
 Do a gaussian fit of Y columns by chunk and fit the position by polynomials in X.
static cpl_image * xsh_image_create_gaussian_image (cpl_image *src, cpl_polynomial *centerp, cpl_polynomial *heightp, cpl_polynomial *widthp, cpl_polynomial *offsetp)
static cpl_image * xsh_image_create_model_image (cpl_image *src_img, double *x_data, double *y_data)
static cpl_vector * xsh_vector_interpolate_linear (cpl_vector *ref_pos, cpl_vector *ref_values, cpl_vector *err_values, cpl_vector *qual_values, cpl_vector *new_pos, cpl_vector **spectrum_err, cpl_vector **spectrum_qual)
 Interpolate values following given positions.
static cpl_vector * xsh_vector_integrate (int oversample, int absorder, cpl_vector *ref_pos, double step, cpl_vector *ref_values, cpl_vector *err_values, cpl_vector *qual_values, cpl_vector *new_pos, cpl_vector **spectrum_err, cpl_vector **spectrum_qual)
 Interpolate values following given positions.
static void xsh_interpolate_spectrum (int oversample, int absorder, double lambda_step, cpl_vector *init_pos, cpl_vector *std_flux, cpl_vector *std_err, cpl_vector *std_qual, cpl_vector *opt_flux, cpl_vector *opt_err, cpl_vector *opt_qual, cpl_vector **res_pos, cpl_vector **res_std_flux, cpl_vector **res_std_err, cpl_vector **res_std_qual, cpl_vector **res_opt_flux, cpl_vector **res_opt_err, cpl_vector **res_opt_qual)
static cpl_image * xsh_optextract_produce_model (cpl_image *s2Dby1D_img, int method, int chunk_ovsamp_size, int deg_poly, int oversample, double *extract_x_data, double *extract_y_data, int abs_order)
static void xsh_object_localize (cpl_frame *slitmap_frame, cpl_frame *loc_frame, int box_hsize, int nlambdas, int ny_extract, double *extract_x_data, double *extract_y_data, xsh_instrument *instr, int *ymin, int *ymax)
static int xsh_interpolate_linear (float *fluxtab, float *errtab, int *qualtab, int nx, int ny, float pos_x, float pos_y, double *flux, double *err, int *qual, int mode)
static void xsh_wavemap_lambda_range (cpl_frame *wavemap_frame, cpl_frame *slitmap_frame, int starty, int endy, int oversample, xsh_order_list *order_list, int iorder, double *xtab, double *ytab, int order, xsh_spectralformat_list *spectralformat, double *lambdastab, double *slitstab, int *sizetab, xsh_instrument *instr)
 Give the value of lambda and x central position for a given y.
static void xsh_vector_divide_poly (cpl_vector *vector, double oversample, cpl_polynomial *poly, int shift, xsh_instrument *instr)
 Divide vector values by a polynomial.
static cpl_image * create_blaze (cpl_frame *masterflat_frame, xsh_order_list *order_list, xsh_instrument *instrument)
 Normalize a master flat frame order by order.
static cpl_vector * xsh_image_extract_standard (cpl_image *img, cpl_image *err_img, cpl_image *qual_img, cpl_vector **err_v, cpl_vector **qual_v)
 Do a standard extraction on image.
static cpl_image * xsh_image_divide_1D (cpl_image *image, cpl_image *err_img, cpl_vector *s1D, cpl_vector *err_s1D, cpl_image **err_2dby1D_img, int abs_order)
 Divide an image by a 1D spectrum (same scale).
static cpl_image * xsh_image_mult_1D (cpl_image *image, cpl_vector *s1D)
 Divide an image by a 1D spectrum (same scale).
static cpl_vector * xsh_image_extract_optimal (cpl_image *img, cpl_image *errs_img, cpl_image *qual_img, xsh_opt_extract_param *opt_par, cpl_image *model_img, cpl_image **corr_img, cpl_vector **err_v)
 Do an optimal extraction on image.
void xsh_opt_extract (cpl_frame *sci_frame, cpl_frame *orderlist_frame, cpl_frame *wavesol_frame, cpl_frame *model_frame, cpl_frame *wavemap_frame, cpl_frame *slitmap_frame, cpl_frame *loc_frame, cpl_frame *spectralformat_frame, cpl_frame *masterflat_frame, xsh_instrument *instrument, xsh_opt_extract_param *opt_extract_par, const char *rec_prefix, cpl_frame **orderext1d_frame, cpl_frame **orderoxt1d_frame)
 Create a SPECTRUM 1D from a Science frame.
void xsh_opt_extract_orders (cpl_frame *sci_frame, cpl_frame *orderlist_frame, cpl_frame *wavesol_frame, cpl_frame *model_frame, cpl_frame *wavemap_frame, cpl_frame *slitmap_frame, cpl_frame *loc_frame, cpl_frame *spectralformat_frame, cpl_frame *masterflat_frame, xsh_instrument *instrument, xsh_opt_extract_param *opt_extract_par, int min_index, int max_index, const char *rec_prefix, cpl_frame **orderext1d_frame, cpl_frame **orderoxt1d_frame)
 Create a SPECTRUM 1D from a Science frame.

Detailed Description

lambda and the slit


Define Documentation

#define FIT_FWHM_LIMIT   30

Definition at line 69 of file xsh_opt_extract.c.

Referenced by xsh_image_gaussian_fit_y().

#define FLUX_MODE   0

Definition at line 73 of file xsh_opt_extract.c.

Referenced by xsh_opt_extract_orders().

#define MSE_LIMIT   1

Definition at line 71 of file xsh_opt_extract.c.

Referenced by create_blaze().

#define OPT_EXTRACT_SLIT_SIZE   80

Definition at line 70 of file xsh_opt_extract.c.

Referenced by xsh_opt_extract_orders().

#define REGDEBUG_INTEGRATE   0

Definition at line 77 of file xsh_opt_extract.c.

#define REGDEBUG_PIXELSIZE   0

Definition at line 76 of file xsh_opt_extract.c.

#define SLIT_USEFUL_WINDOW_FACTOR   0.80

Definition at line 68 of file xsh_opt_extract.c.

Referenced by xsh_opt_extract_orders().

#define WAVEMAP_MODE   1

Definition at line 74 of file xsh_opt_extract.c.

Referenced by xsh_interpolate_linear(), and xsh_wavemap_lambda_range().


Function Documentation

static cpl_image* create_blaze ( cpl_frame *  masterflat_frame,
xsh_order_list order_list,
xsh_instrument instrument 
) [static]

Normalize a master flat frame order by order.

Parameters:
[in] masterflat_frame The master flat frame
[in] order_list The order list given order position
[in] instrument The instrument structure
Returns:
The normalized master flat frame

Definition at line 754 of file xsh_opt_extract.c.

References xsh_order::absorder, xsh_order_list::bin_x, xsh_order_list::bin_y, xsh_pre::binx, xsh_pre::biny, xsh_order::blazepoly, xsh_order::cenpoly, check, xsh_pre::data, xsh_order::edglopoly, xsh_order::edguppoly, xsh_order_list::list, MSE_LIMIT, nx, ny, xsh_order_list::size, XSH_ASSURE_NOT_NULL, XSH_CMP_INT, XSH_FREE, xsh_free_image(), xsh_free_polynomial(), XSH_MALLOC, xsh_msg, xsh_msg_dbg_medium, xsh_order_list_eval_int(), xsh_order_list_get_endy(), xsh_order_list_get_starty(), xsh_polynomial_fit_1d_create(), xsh_pre_free(), xsh_pre_load(), xsh_unwrap_vector(), and y.

Referenced by xsh_opt_extract_orders().

static cpl_image * xsh_image_create_gaussian_image ( cpl_image *  src,
cpl_polynomial *  centerp,
cpl_polynomial *  heightp,
cpl_polynomial *  widthp,
cpl_polynomial *  offsetp 
) [static]
static cpl_image * xsh_image_create_model_image ( cpl_image *  src_img,
double *  x_data,
double *  y_data 
) [static]
static cpl_image* xsh_image_divide_1D ( cpl_image *  image,
cpl_image *  err_img,
cpl_vector *  s1D,
cpl_vector *  err_s1D,
cpl_image **  err_2dby1D_img,
int  abs_order 
) [static]

Divide an image by a 1D spectrum (same scale).

Parameters:
[in] image The image to divide
[in] s1D The 1d spectrum
Returns:
The divided image

Definition at line 1300 of file xsh_opt_extract.c.

References check, nx, ny, size, XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_NULL, xsh_free_image(), and xsh_msg.

Referenced by xsh_opt_extract_orders().

static cpl_vector* xsh_image_extract_optimal ( cpl_image *  img,
cpl_image *  errs_img,
cpl_image *  qual_img,
xsh_opt_extract_param opt_par,
cpl_image *  model_img,
cpl_image **  corr_img,
cpl_vector **  err_v 
) [static]

Do an optimal extraction on image.

Parameters:
[in] img The image
[in] errs The variance image
[in] center The polynomial that describes center position (GAUSSIAN fit)
[in] sigma_poly The polynomial that describes sigma (GAUSSIAN fit)
Returns:
NEW ALLOCATED Extracted positions vector

Definition at line 1441 of file xsh_opt_extract.c.

References check, xsh_opt_extract_param::clip_frac, xsh_opt_extract_param::clip_kappa, xsh_opt_extract_param::clip_niter, kappa, n, nx, ny, sigma, XSH_ASSURE_NOT_NULL, XSH_CALLOC, xsh_debug_level_get(), XSH_DEBUG_LEVEL_MEDIUM, XSH_FREE, xsh_free_vector(), XSH_GOOD_PIXEL_LEVEL, xsh_msg_dbg_medium, and xsh_unwrap_vector().

Referenced by xsh_opt_extract_orders().

static cpl_vector* xsh_image_extract_standard ( cpl_image *  img,
cpl_image *  err_img,
cpl_image *  qual_img,
cpl_vector **  err_v,
cpl_vector **  qual_v 
) [static]

Do a standard extraction on image.

Parameters:
[in] img The image
[in] box_hsize The half size of extraction box
[in] center The polynomial that dscribes center position (GAUSSIAN fit)
Returns:
NEW ALLOCATED Extracted positions vector

Definition at line 1233 of file xsh_opt_extract.c.

References check, nx, ny, XSH_ASSURE_NOT_NULL, and xsh_free_vector().

Referenced by xsh_opt_extract_orders().

static void xsh_image_gaussian_fit_y ( cpl_image *  img,
int  chunk_size,
int  deg_poly,
int  oversample,
cpl_polynomial **  center,
cpl_polynomial **  height,
cpl_polynomial **  width,
cpl_polynomial **  offset 
) [static]

Do a gaussian fit of Y columns by chunk and fit the position by polynomials in X.

Parameters:
[in] img The image
[in] chunk_size The size of chunk in pixels along X axis
[in] center The polynomial that dscribes center position (GAUSSIAN fit)
Returns:
NEW ALLOCATED Extracted positions vector

Definition at line 919 of file xsh_opt_extract.c.

References check, FIT_FWHM_LIMIT, nx, ny, sigma, XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_NULL, XSH_CALLOC, xsh_error_reset, XSH_FREE, xsh_free_polynomial(), xsh_free_vector(), XSH_MALLOC, xsh_msg, xsh_msg_dbg_medium, xsh_polynomial_fit_1d_create(), and xsh_unwrap_vector().

Referenced by xsh_optextract_produce_model().

static cpl_image* xsh_image_mult_1D ( cpl_image *  image,
cpl_vector *  s1D 
) [static]

Divide an image by a 1D spectrum (same scale).

Parameters:
[in] image The image to divide
[in] s1D The 1d spectrum
Returns:
The divided image

Definition at line 1386 of file xsh_opt_extract.c.

References check, nx, ny, size, XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_NULL, and xsh_free_image().

static int xsh_interpolate_linear ( float *  fluxtab,
float *  errtab,
int *  qualtab,
int  nx,
int  ny,
float  pos_x,
float  pos_y,
double *  flux,
double *  err,
int *  qual,
int  mode 
) [static]
static void xsh_interpolate_spectrum ( int  oversample,
int  absorder,
double  lambda_step,
cpl_vector *  init_pos,
cpl_vector *  std_flux,
cpl_vector *  std_err,
cpl_vector *  std_qual,
cpl_vector *  opt_flux,
cpl_vector *  opt_err,
cpl_vector *  opt_qual,
cpl_vector **  res_pos,
cpl_vector **  res_std_flux,
cpl_vector **  res_std_err,
cpl_vector **  res_std_qual,
cpl_vector **  res_opt_flux,
cpl_vector **  res_opt_err,
cpl_vector **  res_opt_qual 
) [static]
static void xsh_object_localize ( cpl_frame *  slitmap_frame,
cpl_frame *  loc_frame,
int  box_hsize,
int  nlambdas,
int  ny_extract,
double *  extract_x_data,
double *  extract_y_data,
xsh_instrument instr,
int *  ymin,
int *  ymax 
) [static]
void xsh_opt_extract ( cpl_frame *  sci_frame,
cpl_frame *  orderlist_frame,
cpl_frame *  wavesol_frame,
cpl_frame *  model_frame,
cpl_frame *  wavemap_frame,
cpl_frame *  slitmap_frame,
cpl_frame *  loc_frame,
cpl_frame *  spectralformat_frame,
cpl_frame *  masterflat_frame,
xsh_instrument instrument,
xsh_opt_extract_param opt_extract_par,
const char *  rec_prefix,
cpl_frame **  orderext1d_frame,
cpl_frame **  orderoxt1d_frame 
)

Create a SPECTRUM 1D from a Science frame.

Parameters:
[in] sci_frame The science frame
[in] order_table_frame The order table Frame
[in] wavesol_frame The wavesolution frame
[in] wavemap_frame The wavemap frame
[in] spectralformat_frame The spectral format frame
[in] masterflat_frame The master flat frame
[in] instrument The instrument structure
opt_extract_par Parameters for optimal extraction
[out] orderext1d_frame The orderext1d result
[out] orderoxt1d_frame The orderoxt1d result

Definition at line 2146 of file xsh_opt_extract.c.

References check, and xsh_opt_extract_orders().

Referenced by xsh_respon_slit_stare(), and xsh_scired_slit_stare().

void xsh_opt_extract_orders ( cpl_frame *  sci_frame,
cpl_frame *  orderlist_frame,
cpl_frame *  wavesol_frame,
cpl_frame *  model_frame,
cpl_frame *  wavemap_frame,
cpl_frame *  slitmap_frame,
cpl_frame *  loc_frame,
cpl_frame *  spectralformat_frame,
cpl_frame *  masterflat_frame,
xsh_instrument instrument,
xsh_opt_extract_param opt_extract_par,
int  min_index,
int  max_index,
const char *  rec_prefix,
cpl_frame **  orderext1d_frame,
cpl_frame **  orderoxt1d_frame 
)

Create a SPECTRUM 1D from a Science frame.

Parameters:
[in] sci_frame The science frame
[in] order_table_frame The order table Frame
[in] wavesol_frame The wavesolution frame
[in] wavemap_frame The wavemap frame
[in] spectralformat_frame The spectral format frame
[in] masterflat_frame The master flat frame
[in] instrument The instrument structure
opt_extract_par Parameters for optimal extraction
[out] orderext1d_frame The orderext1d result
[out] orderoxt1d_frame The orderoxt1d result

Definition at line 2200 of file xsh_opt_extract.c.

References xsh_order::absorder, xsh_instrument::binx, xsh_instrument::biny, xsh_order::blazepoly, xsh_opt_extract_param::box_hsize, check, xsh_opt_extract_param::chunk_size, xsh_pre::conad, create_blaze(), xsh_pre::data, xsh_rec::data1, xsh_pre::data_header, xsh_pre::errs, xsh_rec::errs1, FLUX_MODE, xsh_rec_list::header, xsh_rec::lambda, xsh_opt_extract_param::lambda_step, lambda_step, xsh_rec_list::list, xsh_order_list::list, xsh_opt_extract_param::method, xsh_opt_extract_param::niter, niter, xsh_pre::nx, nx, ny, xsh_pre::ny, OPT_EXTRACT_SLIT_SIZE, xsh_opt_extract_param::oversample, xsh_pre::qual, xsh_rec::qual1, xsh_rec_list::size, size, xs_3::slit, SLIT_USEFUL_WINDOW_FACTOR, x, XSH_ARM_NIR, XSH_ASSURE_NOT_NULL, xsh_debug_level_get(), XSH_DEBUG_LEVEL_MEDIUM, XSH_FREE, xsh_free_frame(), xsh_free_image(), xsh_free_vector(), xsh_get_slit_edges(), XSH_GET_TAG_FROM_ARM, xsh_image_divide_1D(), xsh_image_extract_optimal(), xsh_image_extract_standard(), xsh_instrument_get_arm(), xsh_interpolate_linear(), xsh_interpolate_spectrum(), XSH_MALLOC, xsh_model_binxy(), xsh_model_config_load_best(), xsh_model_get_xy(), xsh_msg, xsh_msg_dbg_high, xsh_msg_dbg_low, xsh_msg_warning, xsh_object_localize(), xsh_optextract_produce_model(), XSH_ORDER_EXT1D, xsh_order_list_free(), xsh_order_list_get_endy(), xsh_order_list_get_starty(), xsh_order_list_load(), XSH_ORDER_OXT1D, xsh_pfits_set_pcatg(), xsh_pfits_set_rectify_bin_lambda(), xsh_pfits_set_rectify_bin_space(), xsh_pfits_set_rectify_lambda_max(), xsh_pfits_set_rectify_lambda_min(), xsh_pfits_set_rectify_space_max(), xsh_pfits_set_rectify_space_min(), xsh_pre_free(), xsh_pre_load(), xsh_pre_multiply_image(), XSH_PRE_QUAL_BPP, xsh_pre_save(), xsh_rec_list_create(), xsh_rec_list_free(), xsh_rec_list_get_lambda_max(), xsh_rec_list_get_lambda_min(), xsh_rec_list_save(), xsh_rec_list_set_data_size(), xsh_spectralformat_list_free(), xsh_spectralformat_list_load(), xsh_stringcat_any(), xsh_unwrap_image(), xsh_unwrap_vector(), xsh_vector_divide_poly(), xsh_wavemap_lambda_range(), xsh_wavesol_eval_polx(), xsh_wavesol_eval_poly(), xsh_wavesol_free(), xsh_wavesol_load(), and y.

Referenced by main(), and xsh_opt_extract().

static cpl_image* xsh_optextract_produce_model ( cpl_image *  s2Dby1D_img,
int  method,
int  chunk_ovsamp_size,
int  deg_poly,
int  oversample,
double *  extract_x_data,
double *  extract_y_data,
int  abs_order 
) [static]
static void xsh_vector_divide_poly ( cpl_vector *  vector,
double  oversample,
cpl_polynomial *  poly,
int  shift,
xsh_instrument instr 
) [static]

Divide vector values by a polynomial.

Parameters:
in/out] vector The vector values
[in] oversample The oversample factor
[in] poly The polynomial function

Definition at line 709 of file xsh_opt_extract.c.

References check, size, XSH_ARM_NIR, XSH_ASSURE_NOT_NULL, and xsh_instrument_get_arm().

Referenced by xsh_opt_extract_orders().

static cpl_vector * xsh_vector_integrate ( int  oversample,
int  absorder,
cpl_vector *  ref_pos,
double  step,
cpl_vector *  ref_values,
cpl_vector *  err_values,
cpl_vector *  qual_values,
cpl_vector *  new_pos,
cpl_vector **  spectrum_err,
cpl_vector **  spectrum_qual 
) [static]

Interpolate values following given positions.

Parameters:
[in] ref_pos The reference position orderby increasing values
[in] ref_values The reference values
[in] new_pos The search positions orderby increasing values
Returns:
NEW ALLOCATED vector containing values for new positions

Definition at line 1791 of file xsh_opt_extract.c.

References check, size, x, XSH_ASSURE_NOT_NULL, xsh_debug_level_get(), XSH_DEBUG_LEVEL_MEDIUM, xsh_free_polynomial(), xsh_free_vector(), xsh_msg, xsh_msg_dbg_high, xsh_polynomial_fit_1d_create(), xsh_round_double(), and y.

Referenced by xsh_interpolate_spectrum().

static cpl_vector * xsh_vector_interpolate_linear ( cpl_vector *  ref_pos,
cpl_vector *  ref_values,
cpl_vector *  err_values,
cpl_vector *  qual_values,
cpl_vector *  new_pos,
cpl_vector **  spectrum_err,
cpl_vector **  spectrum_qual 
) [static]

Interpolate values following given positions.

Parameters:
[in] ref_pos The reference position orderby increasing values
[in] ref_values The reference values
[in] new_pos The search positions orderby increasing values
Returns:
NEW ALLOCATED vector containing values for new positions

Definition at line 2049 of file xsh_opt_extract.c.

References check, WAVELENGTH_PRECISION, x, XSH_ASSURE_NOT_NULL, xsh_free_vector(), and y.

static void xsh_wavemap_lambda_range ( cpl_frame *  wavemap_frame,
cpl_frame *  slitmap_frame,
int  starty,
int  endy,
int  oversample,
xsh_order_list order_list,
int  iorder,
double *  xtab,
double *  ytab,
int  order,
xsh_spectralformat_list spectralformat,
double *  lambdastab,
double *  slitstab,
int *  sizetab,
xsh_instrument instr 
) [static]

Give the value of lambda and x central position for a given y.

Parameters:
[in] wavemap_frame The wavemap containing lambda
[in] starty The first y position
[in] endy The last y position
[in] oversample The oversample factor in y
[in] fxcen The polynomial given xcen=f(ycen)
[out] xtab The array of x central positions
[out] lambdastab The array of lambda central positions
[out] size The array size

Definition at line 449 of file xsh_opt_extract.c.

References xsh_order::cenpoly, check, xsh_order::edglopoly, xsh_order::edguppoly, xsh_order_list::list, nx, ny, size, xs_3::slit, WAVEMAP_MODE, x, XSH_ARM_NIR, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, xsh_free_image(), xsh_instrument_get_arm(), xsh_interpolate_linear(), xsh_msg_dbg_high, xsh_msg_dbg_medium, xsh_order_list_eval(), xsh_spectralformat_list_get_lambda_max(), xsh_spectralformat_list_get_lambda_min(), and y.

Referenced by xsh_opt_extract_orders().


Generated on 9 Mar 2011 for X-shooter Pipeline Reference Manual by  doxygen 1.6.1