X-shooter Pipeline Reference Manual 3.8.15
Macros | Functions
Create Master Files (xsh_create_master_dark/bias/flat)

Macros

#define RECIPE_ID   "xsh_mbias"
 
#define HIST_FACT   2.354820045
 

Functions

static cpl_error_code xsh_compute_ron_mbias (cpl_frameset *raws, xsh_pre *master, cpl_parameterlist *parameters)
 
static cpl_error_code xsh_compute_fpn_mbias (cpl_frameset *raws, xsh_pre *master, xsh_instrument *instrument, cpl_parameterlist *parameters)
 
static cpl_error_code xsh_mbias_get_fpn (const cpl_image *ima, cpl_parameterlist *parameters, double *fpn)
 
static double xsh_mdark_get_contam (xsh_pre *pre, cpl_parameterlist *params, xsh_instrument *instr)
 
cpl_error_code xsh_mdark_get_median_stdev (xsh_pre *preFrame, cpl_parameterlist *parameters, cpl_frame *crh_frm, cpl_frame *bpm_frm)
 
static cpl_error_code xsh_mdark_measure_fpn (xsh_pre *preFrame, cpl_parameterlist *parameters, xsh_instrument *instrument)
 
cpl_error_code xsh_mdark_measure_ron (xsh_pre *preFrame, cpl_parameterlist *parameters)
 
static void set_masterdark_qc (xsh_pre *preFrame, xsh_instrument *instrument, cpl_parameterlist *parameters, cpl_frame *crh_frm, cpl_frame *bpm_frm)
 
static cpl_error_code xsh_mdark_get_ron (xsh_pre *pre, cpl_parameterlist *params, cpl_propertylist *qc_log, xsh_instrument *instr)
 
static cpl_error_code xsh_mdark_compute_fpn (cpl_frameset *raws, cpl_parameterlist *params, cpl_propertylist *qclog, xsh_instrument *instrument)
 
cpl_frame * xsh_create_master_dark2 (cpl_frameset *raws, xsh_stack_param *stack_param, cpl_parameterlist *params, cpl_propertylist *qc_log, xsh_instrument *instr)
 
cpl_frame * xsh_create_master_dark (cpl_frame *medFrame, xsh_instrument *instr, cpl_parameterlist *parameters, cpl_frame *crh_frm, cpl_frame *bpm_frm)
 
static void reject_lo_hi (cpl_image *image, double min, double max)
 Reject outlier pixels.
 
static int count_good (const cpl_image *image)
 
static double get_masterbias_qc_structure_row_region (cpl_image *tima)
 
static double get_masterbias_qc_structure_col_region (cpl_image *tima)
 
static void set_masterbias_qc_xsh_structure_region (xsh_pre *master, const int llx, const int lly, const int urx, const int ury, const int ref_x, const int ref_y, const int reg_id)
 
static void set_masterbias_qc_structure_region (xsh_pre *master, const int llx, const int lly, const int urx, const int ury, const int ref_x, const int ref_y, const int reg_id)
 
static void set_masterbias_qc_structure (xsh_pre *master, cpl_parameterlist *parameters)
 
cpl_frame * xsh_create_master_bias2 (cpl_frameset *rawFrames, xsh_stack_param *stack_par, xsh_instrument *instr, const char *result_tag, const int method_code)
 Creates master bias.
 
cpl_frame * xsh_compute_qc_on_master_bias (cpl_frameset *raws, cpl_frame *frame, xsh_instrument *instr, cpl_parameterlist *params)
 Computes QC on a master bias frame.
 
cpl_frame * xsh_create_master_flat_with_mask (cpl_frame *frame, cpl_frame *edges, xsh_instrument *instr)
 
cpl_frame * xsh_create_master_flat (cpl_frame *frame, xsh_instrument *instr)
 
cpl_frame * xsh_create_master_dark_bpmap (cpl_frame *mdarkFrame, xsh_instrument *instr)
 
static cpl_image * xsh_flat_create_normalized_master (cpl_imagelist *flats, const cpl_table *ordertable, xsh_order_list *order_locations, xsh_stack_param *stack_param)
 Stack images using k-sigma clipping.
 
static cpl_image * xsh_flat_create_normalized_master2 (cpl_imagelist *flats, const cpl_table *ordertable, xsh_order_list *order_locations, const cpl_image *mflat, xsh_stack_param *stack_param, cpl_vector **vec_flux_stack)
 Stack images using k-sigma clipping.
 
cpl_frame * xsh_create_master_flat2 (cpl_frameset *set, cpl_frame *order_tab_cen, xsh_stack_param *stack_par, xsh_instrument *inst)
 Combine master frames.
 

Detailed Description

Macro Definition Documentation

◆ HIST_FACT

#define HIST_FACT   2.354820045

Definition at line 74 of file xsh_create_master.c.

◆ RECIPE_ID

#define RECIPE_ID   "xsh_mbias"

Definition at line 73 of file xsh_create_master.c.

Function Documentation

◆ count_good()

static int count_good ( const cpl_image *  image)
static

◆ get_masterbias_qc_structure_col_region()

static double get_masterbias_qc_structure_col_region ( cpl_image *  tima)
static

◆ get_masterbias_qc_structure_row_region()

static double get_masterbias_qc_structure_row_region ( cpl_image *  tima)
static

◆ reject_lo_hi()

static void reject_lo_hi ( cpl_image *  image,
double  min,
double  max 
)
static

Reject outlier pixels.

Parameters
imageimage with pixels
minreject pixels below this value
maxreject pixels abouve this value

Definition at line 861 of file xsh_create_master.c.

References assure_mem, max, and xsh_free_mask().

Referenced by get_masterbias_qc_structure_col_region(), and get_masterbias_qc_structure_row_region().

◆ set_masterbias_qc_structure()

static void set_masterbias_qc_structure ( xsh_pre master,
cpl_parameterlist *  parameters 
)
static

Calculates and sets QC parameters: Median, Average, Stdev and Slope, for primary image AND qual.

Parameters
masterMaster Bias Frame (PRE format)
parametersRecipe input parameters

Definition at line 1121 of file xsh_create_master.c.

References check, xsh_pre::data, and set_masterbias_qc_structure_region().

Referenced by xsh_compute_qc_on_master_bias().

◆ set_masterbias_qc_structure_region()

static void set_masterbias_qc_structure_region ( xsh_pre master,
const int  llx,
const int  lly,
const int  urx,
const int  ury,
const int  ref_x,
const int  ref_y,
const int  reg_id 
)
static

Calculates and sets QC parameters: Median, Average, Stdev and Slope, for primary image AND qual.

Parameters
masterMaster Bias Frame (PRE format)
llxlower left X
llylower left Y
urxupper right X
uryupper right Y
ref_xreference X
ref_yreference Y
reg_idregion id
Returns
void

Definition at line 1093 of file xsh_create_master.c.

References check, llx, lly, set_masterbias_qc_xsh_structure_region(), urx, and ury.

Referenced by set_masterbias_qc_structure().

◆ set_masterbias_qc_xsh_structure_region()

static void set_masterbias_qc_xsh_structure_region ( xsh_pre master,
const int  llx,
const int  lly,
const int  urx,
const int  ury,
const int  ref_x,
const int  ref_y,
const int  reg_id 
)
static

Calculates and sets QC parameters: Median, Average, Stdev and Slope, for primary image AND qual.

Parameters
masterMaster Bias Frame (PRE format)
llxlower left X
llylower left Y
urxupper right X
uryupper right Y
ref_xreference X
ref_yreference Y
reg_idregion id
dleveldebug level
Returns
void

Definition at line 990 of file xsh_create_master.c.

References check, xsh_pre::data, xsh_pre::data_header, get_masterbias_qc_structure_col_region(), get_masterbias_qc_structure_row_region(), llx, lly, urx, ury, xsh_free_image(), xsh_pfits_set_qc_mbiasavg(), xsh_pfits_set_qc_mbiasmed(), xsh_pfits_set_qc_mbiasrms(), xsh_pfits_set_qc_reg1_structx(), xsh_pfits_set_qc_reg1_structy(), xsh_pfits_set_qc_reg2_structx(), xsh_pfits_set_qc_reg2_structy(), and xsh_pre_median_mean_stdev_window().

Referenced by set_masterbias_qc_structure_region().

◆ set_masterdark_qc()

static void set_masterdark_qc ( xsh_pre preFrame,
xsh_instrument instrument,
cpl_parameterlist *  parameters,
cpl_frame *  crh_frm,
cpl_frame *  bpm_frm 
)
static

Calculates and sets QC parameters: Median, Average, Stdev and Slope, for primary image AND qual.

Parameters
preFrameMaster Dark Frame (PRE format)
instrumentPointer to the instrument description structure
parametersparameters of recipe
crh_frmCRH frame
bpm_frmBPM frame

Definition at line 438 of file xsh_create_master.c.

References xsh_instrument::arm, assure, check, xsh_pre::data_header, instrument, nx, ny, XSH_ARM_AGC, xsh_mdark_get_contam(), xsh_mdark_get_median_stdev(), xsh_mdark_measure_fpn(), xsh_pfits_set_qc_contamination(), xsh_pre_get_nx(), and xsh_pre_get_ny().

Referenced by xsh_create_master_dark().

◆ xsh_compute_fpn_mbias()

static cpl_error_code xsh_compute_fpn_mbias ( cpl_frameset *  raws,
xsh_pre master,
xsh_instrument instrument,
cpl_parameterlist *  parameters 
)
static

Definition at line 1749 of file xsh_create_master.c.

Referenced by xsh_compute_qc_on_master_bias().

◆ xsh_compute_qc_on_master_bias()

cpl_frame * xsh_compute_qc_on_master_bias ( cpl_frameset *  raws,
cpl_frame *  frame,
xsh_instrument instr,
cpl_parameterlist *  params 
)

Computes QC on a master bias frame.

Parameters
rawsThe raw frames
frameThe master bias frame
instrThe instrument containing the arm in use
parametersThe instrument recipe parameters (To be removed)
paramsAdditional params to compute QC
Returns
The master bias frame with QC parameters and PROCATG

Definition at line 1319 of file xsh_create_master.c.

References check, xsh_pre::data_header, set_masterbias_qc_structure(), XSH_ASSURE_NOT_NULL, xsh_compute_fpn_mbias(), xsh_compute_ron_mbias(), xsh_count_satpix(), XSH_GET_TAG_FROM_ARM, xsh_instrument_arm_tostring(), XSH_MASTER_BIAS, xsh_msg, xsh_pfits_set_pcatg(), xsh_pre_free(), xsh_pre_load(), and xsh_pre_save().

Referenced by main(), and xsh_mbias().

◆ xsh_compute_ron_mbias()

static cpl_error_code xsh_compute_ron_mbias ( cpl_frameset *  raws,
xsh_pre master,
cpl_parameterlist *  parameters 
)
static

Definition at line 1598 of file xsh_create_master.c.

References check, size, and XSH_ASSURE_NOT_ILLEGAL_MSG.

Referenced by xsh_compute_qc_on_master_bias().

◆ xsh_create_master_bias2()

cpl_frame * xsh_create_master_bias2 ( cpl_frameset *  rawFrames,
xsh_stack_param stack_par,
xsh_instrument instr,
const char *  result_tag,
const int  method_code 
)

Creates master bias.

Parameters
rawFramesPointer to the frameset
stack_parPointer to stack param structure
instrinstrument containing the arm , mode and lamp in use
result_tagproduct catg
Returns
the clean mean frame newly allocated

Definition at line 1191 of file xsh_create_master.c.

References assure, check, check_msg, xsh_pre::data, xsh_pre::data_header, xsh_pre::errs, xsh_stack_param::khigh, xsh_stack_param::klow, xsh_pre::qual, size, XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_NULL, xsh_badpixelmap_image_coadd(), xsh_collapse_errs(), xsh_free_frame(), xsh_free_image(), xsh_free_imagelist(), xsh_image_flag_bp(), xsh_irplib_mkmaster_mean(), xsh_irplib_mkmaster_median(), xsh_pfits_set_datancom(), xsh_pre_free(), xsh_pre_load(), and xsh_pre_save().

Referenced by main(), and xsh_mbias().

◆ xsh_create_master_dark()

cpl_frame * xsh_create_master_dark ( cpl_frame *  medFrame,
xsh_instrument instr,
cpl_parameterlist *  parameters,
cpl_frame *  crh_frm,
cpl_frame *  bpm_frm 
)

PELIMINARY: Creates a master dark frame from input frame. Input frame is in PRE format: medianFrame, errsFrame, bpmapFrame. Divide median frame by exposure time and calculate QC params.

Parameters
medFrameFrame in PRE format
instrinstrument containing the arm in use
parametersof the recipe
crh_frmCRH frame
bpm_frmBPM frame

Definition at line 775 of file xsh_create_master.c.

References xsh_instrument::arm, assure, check, check_msg, xsh_pre::data, xsh_pre::data_header, xsh_pre::errs, xsh_pre::errs_header, exptime, xsh_pre::exptime, set_masterdark_qc(), XSH_ARM_NIR, XSH_ASSURE_NOT_NULL, xsh_free_frame(), XSH_GET_TAG_FROM_ARM, xsh_instrument_arm_tostring(), xsh_instrument_get_arm(), XSH_MASTER_DARK, xsh_msg_dbg_high, xsh_pfits_set_exptime(), xsh_pre_free(), xsh_pre_load(), and xsh_pre_save().

Referenced by xsh_get_master_dark_opt(), and xsh_mdark().

◆ xsh_create_master_dark2()

cpl_frame * xsh_create_master_dark2 ( cpl_frameset *  raws,
xsh_stack_param stack_param,
cpl_parameterlist *  params,
cpl_propertylist *  qc_log,
xsh_instrument instr 
)

◆ xsh_create_master_dark_bpmap()

cpl_frame * xsh_create_master_dark_bpmap ( cpl_frame *  mdarkFrame,
xsh_instrument instr 
)

◆ xsh_create_master_flat()

cpl_frame * xsh_create_master_flat ( cpl_frame *  frame,
xsh_instrument instr 
)

◆ xsh_create_master_flat2()

cpl_frame * xsh_create_master_flat2 ( cpl_frameset *  set,
cpl_frame *  order_tab_cen,
xsh_stack_param stack_par,
xsh_instrument inst 
)

Combine master frames.

Parameters
raw_imagesThe input images
raw_headersAn array containing the input image headers. The ordering must be the same as the ordering of images in the input image list
master_flat_headerThis header is updated with the normalized exposure time
master_biasThe master bias image for this chip, or NULL
master_darkIf non-null this master dark frame is subtracted
mdark_headerThe header of the master dark frame (used only if master_dark is non-null).
ordertableThe order table for this chip. Used for background subtraction.
order_locationsPolynomial defining the order locations. Used for background subtraction.
flamesFLAMES reduction? In this case the background image is not computed/subtracted
parametersThe recipe parameter list
chipCCD chip
recipe_idname of calling recipe
DEBUGSave intermediate results to disk?
background(output) The background image which was subtracted
Returns
The master flat image

This function

  • subtracts from each input image the provided master bias,
  • rescales each input image to unit exposure time by dividing by the exposure time read from the image header.
  • computes the master flat image by taking the pixel-by-pixel median of all input frames,
  • optionally subtracts the normalized master dark frame, and
  • subtracts the background (see xsh_backsub_spline()) .

masterflat = median( (flat_i - masterbias)/exptime_i ) - masterdark/exptime_mdark - background

Dark subtraction is optional and is done only if the parameter master_dark is non-NULL.

Definition at line 2248 of file xsh_create_master.c.

Referenced by xsh_mflat_combine_flats().

◆ xsh_create_master_flat_with_mask()

cpl_frame * xsh_create_master_flat_with_mask ( cpl_frame *  frame,
cpl_frame *  edges,
xsh_instrument instr 
)

◆ xsh_flat_create_normalized_master()

static cpl_image * xsh_flat_create_normalized_master ( cpl_imagelist *  flats,
const cpl_table *  ordertable,
xsh_order_list order_locations,
xsh_stack_param stack_param 
)
static

Stack images using k-sigma clipping.

Parameters
flatsList of flats to stack
ordertableInput order table
order_locationspolynomial description of order locations
Returns
Stacked image.

The input list of flats is analized to compute for each flat for each order The median flux on a number of windows of given X * Y size. The mean flux of the values computed on each order is computed. endfor Finally the mean flux of all means is computed. The flat is normalized by the computed mean endfor

Definition at line 1887 of file xsh_create_master.c.

◆ xsh_flat_create_normalized_master2()

static cpl_image * xsh_flat_create_normalized_master2 ( cpl_imagelist *  flats,
const cpl_table *  ordertable,
xsh_order_list order_locations,
const cpl_image *  mflat,
xsh_stack_param stack_param,
cpl_vector **  vec_flux_stack 
)
static

Stack images using k-sigma clipping.

Parameters
flatsList of flats to stack
ordertableInput order table
order_locationspolynomial description of order locations
Returns
Stacked image.

The input list of flats is analyzed to compute for each flat for each order The median flux on a number of windows of given X * Y size. The mean flux of the values computed on each order is computed. endfor Finally the mean flux of all means is computed. The flat is normalized by the computed mean endfor

Definition at line 2036 of file xsh_create_master.c.

◆ xsh_mbias_get_fpn()

static cpl_error_code xsh_mbias_get_fpn ( const cpl_image *  ima,
cpl_parameterlist *  parameters,
double *  fpn 
)
static

Definition at line 1802 of file xsh_create_master.c.

◆ xsh_mdark_compute_fpn()

static cpl_error_code xsh_mdark_compute_fpn ( cpl_frameset *  raws,
cpl_parameterlist *  params,
cpl_propertylist *  qclog,
xsh_instrument instrument 
)
static

◆ xsh_mdark_get_contam()

static double xsh_mdark_get_contam ( xsh_pre pre,
cpl_parameterlist *  params,
xsh_instrument instr 
)
static

◆ xsh_mdark_get_median_stdev()

cpl_error_code xsh_mdark_get_median_stdev ( xsh_pre preFrame,
cpl_parameterlist *  parameters,
cpl_frame *  crh_frm,
cpl_frame *  bpm_frm 
)

◆ xsh_mdark_get_ron()

static cpl_error_code xsh_mdark_get_ron ( xsh_pre pre,
cpl_parameterlist *  params,
cpl_propertylist *  qc_log,
xsh_instrument instr 
)
static

◆ xsh_mdark_measure_fpn()

static cpl_error_code xsh_mdark_measure_fpn ( xsh_pre preFrame,
cpl_parameterlist *  parameters,
xsh_instrument instrument 
)
static

◆ xsh_mdark_measure_ron()

cpl_error_code xsh_mdark_measure_ron ( xsh_pre preFrame,
cpl_parameterlist *  parameters 
)

Definition at line 391 of file xsh_create_master.c.

References check, xsh_pre::data, and xsh_parameters_get_int().