Optimal extraction handling
[DRL Functions]

Defines

#define SLIT_USEFUL_WINDOW_FACTOR   0.80
#define FIT_FWHM_LIMIT   30
#define OPT_EXTRACT_SLIT_SIZE   80
#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, double kappa, int niter, double frac_min)
static cpl_vector * xsh_vector_integrate (int biny, 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 biny, 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)
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, double kappa, int niter, double frac_min)
static void xsh_object_localize (cpl_frame *slitmap_frame, cpl_frame *loc_frame, int oversample, int box_hsize, int nlambdas, int ny_extract, double *extract_x_data, double *extract_y_data, 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_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)
 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, const int decode_bp, cpl_image **corr_img, cpl_vector **err_v, cpl_vector **qual_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, cpl_frame **orderoxt1d_eso_frame, cpl_frame **qc_subextract_frame, cpl_frame **qc_s2ddiv1d_frame, cpl_frame **qc_model_frame, cpl_frame **qc_weight_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, cpl_frame **res_frame_ext, cpl_frame **qc_subextract_frame, cpl_frame **qc_s2ddiv1d_frame, cpl_frame **qc_model_frame, cpl_frame **qc_weight_frame)
 Create a SPECTRUM 1D from a Science frame.

Define Documentation

#define FIT_FWHM_LIMIT   30

Definition at line 68 of file xsh_opt_extract.c.

Referenced by xsh_image_gaussian_fit_y().

#define FLUX_MODE   0

Definition at line 71 of file xsh_opt_extract.c.

Referenced by xsh_opt_extract_orders().

#define OPT_EXTRACT_SLIT_SIZE   80

Definition at line 69 of file xsh_opt_extract.c.

Referenced by xsh_opt_extract_orders().

#define REGDEBUG_INTEGRATE   0

Definition at line 75 of file xsh_opt_extract.c.

#define REGDEBUG_PIXELSIZE   0

Definition at line 74 of file xsh_opt_extract.c.

#define SLIT_USEFUL_WINDOW_FACTOR   0.80

Definition at line 67 of file xsh_opt_extract.c.

Referenced by xsh_opt_extract_orders().

#define WAVEMAP_MODE   1

Definition at line 72 of file xsh_opt_extract.c.

Referenced by xsh_interpolate_linear(), and xsh_wavemap_lambda_range().


Function Documentation

static cpl_image * xsh_image_create_gaussian_image ( cpl_image *  src,
cpl_polynomial *  centerp,
cpl_polynomial *  heightp,
cpl_polynomial *  widthp,
cpl_polynomial *  offsetp 
) [static]

Definition at line 985 of file xsh_opt_extract.c.

References check, nx, ny, width, XSH_ASSURE_NOT_NULL, xsh_free_image(), and XSH_MATH_SQRT_2.

Referenced by xsh_optextract_produce_model().

static cpl_image * xsh_image_create_model_image ( cpl_image *  src_img,
double *  x_data,
double *  y_data,
double  kappa,
int  niter,
double  frac_min 
) [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 
) [static]

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

Parameters:
image The data image to divide
err_img The error image associate with data
s1D The 1d spectrum
err_s1D The 1d error spectrum
[out] err_2dby1D_img The pointer on NEW ALLOCATED error associate with result
Returns:
The NEW ALLOCATED divided image

Definition at line 1141 of file xsh_opt_extract.c.

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

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,
const int  decode_bp,
cpl_image **  corr_img,
cpl_vector **  err_v,
cpl_vector **  qual_v 
) [static]

Do an optimal extraction on image.

Parameters:
img The image
errs_img The variance image
qual_img The bad pixels image
opt_par The optimal extraction parameters
model_img The reference model image
decode_bp bad pixel code
[out] corr_img The corrected image
[out] err_v The error vector associate with result
[out] qual_v The bad pixel vector associate with result
Returns:
NEW ALLOCATED Extracted positions vector

Definition at line 1230 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, n, nx, ny, QFLAG_COSMIC_RAY_REMOVED, sigma, XSH_ASSURE_NOT_NULL, XSH_CALLOC, xsh_debug_level_get(), XSH_DEBUG_LEVEL_MEDIUM, XSH_FREE, xsh_free_vector(), 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 data image
[in] err_img The error image
[in] qual_img The bad pixel image
[out] err_v The error vector associate with result
[out] qual_v The bad pixel vector associate with result
Returns:
NEW ALLOCATED Extracted positions vector

Definition at line 1060 of file xsh_opt_extract.c.

References check, nx, ny, xs_3::pix, 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] deg_poly The degree of polynomial fit
[in] oversample The oversample factor
[out] center The NEW ALLOCATED polynomial that describes gaussian center position along X axis
[out] height The NEW ALLOCATED polynomial that describes gaussian height along X axis
[out] width The NEW ALLOCATED polynomial that describes gaussian width along X axis
[out] offset The NEW ALLOCATED polynomial that describes gaussian offset along X axis

Definition at line 720 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 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  biny,
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  oversample,
int  box_hsize,
int  nlambdas,
int  ny_extract,
double *  extract_x_data,
double *  extract_y_data,
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,
cpl_frame **  orderoxt1d_eso_frame,
cpl_frame **  qc_subextract_frame,
cpl_frame **  qc_s2ddiv1d_frame,
cpl_frame **  qc_model_frame,
cpl_frame **  qc_weight_frame 
)

Create a SPECTRUM 1D from a Science frame.

Parameters:
sci_frame The science frame
orderlist_frame The order table Frame
wavesol_frame The wave solution frame
model_frame The model configuration frame
wavemap_frame The wave map frame
slitmap_frame The slit map frame
loc_frame The localization frame
spectralformat_frame The spectral format frame
masterflat_frame The master flat frame
instrument The instrument structure
opt_extract_par Parameters for optimal extraction
rec_prefix The recipe PREFIX to build output files name or NULL
[out] orderext1d_frame The orderext1d result
[out] orderoxt1d_frame The orderoxt1d result
[out] qc_subextract_frame The QC subextract image
[out] qc_s2ddiv1d_frame The QC S2ddiv1d image
[out] qc_model_frame The QC model image
[out] qc_weight_frame The QC weight image

Definition at line 1832 of file xsh_opt_extract.c.

References check, and xsh_opt_extract_orders().

Referenced by xsh_absorp(), 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,
cpl_frame **  res_frame_ext,
cpl_frame **  qc_subextract_frame,
cpl_frame **  qc_s2ddiv1d_frame,
cpl_frame **  qc_model_frame,
cpl_frame **  qc_weight_frame 
)

Create a SPECTRUM 1D from a Science frame.

Parameters:
sci_frame The science frame
orderlist_frame The order table Frame
wavesol_frame The wave solution frame
model_frame The model configuration frame
[in] wavemap_frame The wavemap frame
slitmap_frame The slit map 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
min_index The index of first order to extract
max_index The index of last order to extract
rec_prefix The recipe PREFIX to build output files name or NULL
[out] orderext1d_frame The orderext1d result
[out] orderoxt1d_frame The orderoxt1d result
[out] qc_subextract_frame The QC subextract image
[out] qc_s2ddiv1d_frame The QC S2ddiv1d image
[out] qc_model_frame The QC model image
[out] qc_weight_frame The QC weight image

Definition at line 1899 of file xsh_opt_extract.c.

References xsh_order::absorder, binx, xsh_instrument::binx, xsh_instrument::biny, biny, xsh_order::blazepoly, xsh_opt_extract_param::box_hsize, check, xsh_opt_extract_param::chunk_size, xsh_pre::conad, xsh_pre::data, xsh_rec::data1, xsh_pre::data_header, xsh_instrument::decode_bp, xsh_pre::errs, xsh_rec::errs1, FLUX_MODE, xsh_rec_list::header, kappa, xsh_rec::lambda, xsh_opt_extract_param::lambda_step, lambda_step, xsh_rec_list::list, xsh_order_list::list, xsh_opt_extract_param::method, mode, 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_add_temporary_file(), XSH_ARM_NIR, XSH_ASSURE_NOT_NULL, xsh_create_blaze(), xsh_debug_level_get(), XSH_DEBUG_LEVEL_MEDIUM, XSH_FREE, xsh_free_frame(), xsh_free_image(), xsh_free_propertylist(), 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_NEW_PROPERTYLIST, 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_extname(), 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_save2(), xsh_rec_list_set_data_size(), xsh_spectralformat_list_free(), xsh_spectralformat_list_load(), 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().

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,
double  kappa,
int  niter,
double  frac_min 
)
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 that define value to divide
[in] shift Shift between vector and polynomial
in] instr Instrument structure used to define ARM

Definition at line 665 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  biny,
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:
oversample Oversample factor
abs_order Absolute order
ref_pos The reference position orderby increasing values
step The step in wavelength
[in] ref_values The reference values
[in] err_values The error values
[in] qual_values The bad pixel values
[in] new_pos The search positions orderby increasing values
[out] spectrum_err The error valuea associate with result
[in] spectrum_qual The bad pixel values associate with result
Returns:
NEW ALLOCATED vector containing values for new positions

Definition at line 1535 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 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:
wavemap_frame The wave map frame
slitmap_frame The slit map frame
starty The first y position
endy The last y position
oversample The oversample factor in y
order_list The order table list
iorder Index of order
[out] xtab The array of x central positions
[out] ytab The array of y central positions
order The absolute order
spectralformat The spectral format list
[out] lambdatab The array of wavelength at central positions
[out] slitstab The array of slit at central positions
out] sizetab The array size of different tab
[in] instr The instrument structure

Definition at line 455 of file xsh_opt_extract.c.

References xsh_order::cenpoly, check, 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 13 Mar 2013 for X-shooter Pipeline Reference Manual by  doxygen 1.6.1