X-shooter Pipeline Reference Manual 3.8.15
Functions
XSH Specific Bad Pixel Mask Functions

Functions

void xsh_badpixelmap_or (xsh_pre *self, const xsh_pre *right)
 
cpl_frame * xsh_badpixelmap_crea_master_from_bpmap (cpl_frame *bpmap, xsh_instrument *inst)
 
static cpl_error_code xsh_flag_ima_bad_pix (cpl_image **image, int *bppix, const int decode_bp)
 
cpl_mask * xsh_bpm_filter (const cpl_mask *input_mask, cpl_size kernel_nx, cpl_size kernel_ny, cpl_filter_mode filter)
 Allows the growing and shrinking of bad pixel masks. It can be used to e.g. set pixels to bad if the pixel is surrounded by other bad pixels.
 
cpl_mask * xsh_code_is_in_qual (cpl_image *qual, const int code)
 
cpl_mask * xsh_qual_to_cpl_mask (cpl_image *qual, const int decode_bp)
 
void xsh_set_image_cpl_bpmap (cpl_image *image, cpl_image *bpmap, const int decode_bp)
 
void xsh_image_flag_bp (cpl_image *image, cpl_image *bpmap, xsh_instrument *inst)
 
void xsh_bpmap_bitwise_to_flag (cpl_image *bpmap, int flag)
 
void xsh_bpmap_mask_bad_pixel (cpl_image *bpmap, cpl_mask *mask, int flag)
 
void xsh_bpmap_set_bad_pixel (cpl_image *bpmap, int ix, int iy, int flag)
 
cpl_image * xsh_bpmap_collapse_bpmap_create (cpl_imagelist *liste, const int decode_bp)
 
int xsh_bpmap_count (cpl_image *bpmap, int nx, int ny)
 
void xsh_bpmap_collapse_median (cpl_image *median, cpl_imagelist *list, cpl_mask *bpmap)
 
void xsh_bpmap_collapse_mean (cpl_image *mean, cpl_imagelist *list, cpl_mask *bpmap)
 
cpl_error_code xsh_badpixel_flag_rejected (cpl_image *qual, cpl_image *image)
 
cpl_error_code xsh_badpixelmap_image_coadd (cpl_image **self, const cpl_image *right, const int mode)
 
cpl_error_code xsh_badpixelmap_coadd (cpl_frame *self, const cpl_frame *right, const int mode)
 
cpl_error_code xsh_frame_qual_update (cpl_frame *frame, const cpl_frame *bpmap, xsh_instrument *inst)
 
static cpl_error_code xsh_image_get_hot_cold_maps (cpl_image *masterbias, const double kappa_low, const double kappa_high, const int low_niter, const int high_niter, cpl_mask **bpmhot, int *hotpix_nb, cpl_mask **bpmcold, int *coldpix_nb, cpl_propertylist **hplist, cpl_propertylist **cplist)
 
cpl_error_code xsh_image_get_hot_cold_pixs (cpl_frame *frame_image, xsh_instrument *instrument, const double ks_low, const int cold_niter, const double ks_high, const int hot_niter, cpl_frame **cpix_frm, cpl_frame **hpix_frm)
 
cpl_frame * xsh_image_local_cold_pixs (cpl_image *ima, const double kappa, const int r, xsh_instrument *instr)
 
cpl_frame * xsh_image_local_hot_pixs (cpl_image *ima, const double kappa, const int r, xsh_instrument *instr)
 
cpl_error_code xsh_image_clean_mask_pixs (cpl_image **ima, cpl_image *msk, const int r)
 
static cpl_error_code xsh_image_coadd (cpl_image **self, const cpl_image *add)
 
cpl_image * xsh_image_flag_bptype_with_crox (cpl_image *ima)
 
cpl_error_code xsh_count_crh (xsh_pre *pre, xsh_instrument *instr, const int datancom)
 
cpl_error_code xsh_count_satpix (xsh_pre *pre, xsh_instrument *instr, const int datancom)
 
cpl_error_code xsh_badpixelmap_flag_saturated_pixels (xsh_pre *pre, xsh_instrument *instr, const double cor_val, const int flag, const int is_flat, int *nsat)
 
cpl_error_code xsh_badpixelmap_count_range_pixels (xsh_pre *pre, const double thresh_min, const double thresh_max, const double cor_val, int *nrange, double *frange)
 
cpl_error_code xsh_badpixelmap_count_sat_pixels (xsh_pre *pre, const double sat_thresh, const double cor_val, int *nsat, double *frac_sat)
 
cpl_error_code xsh_badpixelmap_fill_bp_pattern_holes (cpl_frame *frm)
 
cpl_frame * xsh_badpixelmap_extract (cpl_frame *frame, int xmin, int ymin, int xmax, int ymax)
 This function create a sub bad pixel map frame from input bad pixel map frame. the sub frame is described by a box.
 

Detailed Description

This module contains functions used to handle Xshooter version of Bad pixel mask (each pixel is marked with a set of bits describing why the pixel has been considered BAD).

Function Documentation

◆ xsh_badpixel_flag_rejected()

cpl_error_code xsh_badpixel_flag_rejected ( cpl_image *  qual,
cpl_image *  image 
)

Create In the rare case input image has some flagged pixel flag them in the qual

Parameters
qualinput pixel quality image
imageinput image (with possibly flagged pixels)

Definition at line 692 of file xsh_badpixelmap.c.

References assure, nx, ny, and QFLAG_ALL_PIX_BAD.

Referenced by xsh_remove_cosmics().

◆ xsh_badpixelmap_coadd()

cpl_error_code xsh_badpixelmap_coadd ( cpl_frame *  self,
const cpl_frame *  right,
const int  mode 
)

Create coadd a mask frame with another

Parameters
selfinput bp map frame
rightinput bp map frame

Definition at line 786 of file xsh_badpixelmap.c.

References assure, check, mode, xsh_add_temporary_file(), xsh_badpixelmap_image_coadd(), xsh_free_image(), xsh_free_propertylist(), and xsh_msg.

Referenced by xsh_check_load_master_bpmap(), and xsh_util_bpmap_coadd().

◆ xsh_badpixelmap_count_range_pixels()

cpl_error_code xsh_badpixelmap_count_range_pixels ( xsh_pre pre,
const double  thresh_min,
const double  thresh_max,
const double  cor_val,
int *  nrange,
double *  frange 
)

Definition at line 1518 of file xsh_badpixelmap.c.

References xsh_pre::data, xsh_pre::nx, xsh_pre::ny, and size.

Referenced by xsh_pre_create().

◆ xsh_badpixelmap_count_sat_pixels()

cpl_error_code xsh_badpixelmap_count_sat_pixels ( xsh_pre pre,
const double  sat_thresh,
const double  cor_val,
int *  nsat,
double *  frac_sat 
)

Definition at line 1543 of file xsh_badpixelmap.c.

References xsh_pre::data, xsh_pre::nx, xsh_pre::ny, and size.

◆ xsh_badpixelmap_crea_master_from_bpmap()

cpl_frame * xsh_badpixelmap_crea_master_from_bpmap ( cpl_frame *  bpmap,
xsh_instrument inst 
)

Create the master bad pixel map (cpl format) from a Bad Pixel Map image

Parameters
bpmapXSH format bad pixel map
instXSH instrumnent (arm/ifu) setting

Definition at line 109 of file xsh_badpixelmap.c.

References xsh_add_temporary_file(), xsh_free_image(), xsh_free_propertylist(), xsh_instrument_arm_tostring(), XSH_MASTER_BP_MAP_FLAT, xsh_pfits_set_pcatg(), and XSH_PRE_QUAL_BPP.

◆ xsh_badpixelmap_extract()

cpl_frame * xsh_badpixelmap_extract ( cpl_frame *  frame,
int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

This function create a sub bad pixel map frame from input bad pixel map frame. the sub frame is described by a box.

Parameters
[in]frameA bad pixel map frame
[in]xmin
The x coordinate of the low-left corner of the box
[in]yminThe y coordinate of the low-left corner of the box
[in]xmax
The x coordinate of the up-right corner of the box
[in]ymaxThe y coordinate of the up-right corner of the box
[in]nameThe name of the sub frame
[in]instrInstrument containing the arm , mode and lamp in use

Definition at line 1652 of file xsh_badpixelmap.c.

References check, xsh_add_temporary_file(), XSH_ASSURE_NOT_NULL, xsh_free_frame(), xsh_free_image(), xsh_free_propertylist(), and XSH_PRE_DATA_BPP.

Referenced by xsh_flexcomp().

◆ xsh_badpixelmap_fill_bp_pattern_holes()

cpl_error_code xsh_badpixelmap_fill_bp_pattern_holes ( cpl_frame *  frm)

◆ xsh_badpixelmap_flag_saturated_pixels()

cpl_error_code xsh_badpixelmap_flag_saturated_pixels ( xsh_pre pre,
xsh_instrument instr,
const double  cor_val,
const int  flag,
const int  is_flat,
int *  nsat 
)

◆ xsh_badpixelmap_image_coadd()

cpl_error_code xsh_badpixelmap_image_coadd ( cpl_image **  self,
const cpl_image *  right,
const int  mode 
)

Create coadd a mask frame with another

Parameters
selfinput bp map image
rightinput bp map image
modeBitwise AND or Bitwise OR

Definition at line 728 of file xsh_badpixelmap.c.

References assure, check, mode, nx, and ny.

Referenced by xsh_badpixelmap_coadd(), xsh_create_master_bias2(), xsh_create_master_dark2(), xsh_frame_qual_update(), xsh_hdrl_remove_crh_single(), xsh_iml_merge_wgt(), xsh_mdark(), xsh_pre_create(), and xsh_remove_cosmics().

◆ xsh_badpixelmap_or()

void xsh_badpixelmap_or ( xsh_pre self,
const xsh_pre right 
)

Make an "OR" between 2 bad QUAL images.

Parameters
selfInout bad pixel map (modified)
rightSecondary bpmap (unchanged)

Definition at line 80 of file xsh_badpixelmap.c.

References check, xsh_pre::nx, xsh_pre::ny, xsh_pre::qual, XSH_ASSURE_NOT_ILLEGAL, and XSH_ASSURE_NOT_NULL.

Referenced by xsh_pre_add(), and xsh_pre_subtract().

◆ xsh_bpm_filter()

cpl_mask * xsh_bpm_filter ( const cpl_mask *  input_mask,
cpl_size  kernel_nx,
cpl_size  kernel_ny,
cpl_filter_mode  filter 
)

Allows the growing and shrinking of bad pixel masks. It can be used to e.g. set pixels to bad if the pixel is surrounded by other bad pixels.

Parameters
input_maskinput mask
kernel_nxsize in x-direction of the filtering kernel
kernel_nysize in y-direction of the filtering kernel
filterfilter modes as defined in cpl - see below Supported modes: CPL_FILTER_EROSION, CPL_FILTER_DILATION, CPL_FILTER_OPENING, CPL_FILTER_CLOSING

The returned mask must be deallocated using cpl_mask_delete(). The algorithm assumes, that all pixels outside the mask are good, i.e. it enlarges the mask by the kernel size and marks this border as good. It applies on the enlarged mask the operation and extract the original-size mask at the very end.

Definition at line 178 of file xsh_badpixelmap.c.

References filter.

◆ xsh_bpmap_bitwise_to_flag()

void xsh_bpmap_bitwise_to_flag ( cpl_image *  bpmap,
int  flag 
)

Definition at line 359 of file xsh_badpixelmap.c.

References check, nx, and ny.

Referenced by xsh_bpmap_2pre(), xsh_lingain(), and xsh_util_bpmap2rp().

◆ xsh_bpmap_collapse_bpmap_create()

cpl_image * xsh_bpmap_collapse_bpmap_create ( cpl_imagelist *  liste,
const int  decode_bp 
)

Create a bad pixel map image by a union of all the bpmap images of the liste.

Parameters
listeList of bpmap images
decode_bpbad pixel code
Returns
an image, the union of all the bpmap images in the list

< first image is the result

Definition at line 443 of file xsh_badpixelmap.c.

References assure, nx, ny, xsh_flag_ima_bad_pix(), xsh_msg, and xsh_msg_dbg_low.

Referenced by xsh_compute_linearity().

◆ xsh_bpmap_collapse_mean()

void xsh_bpmap_collapse_mean ( cpl_image *  mean,
cpl_imagelist *  list,
cpl_mask *  bpmap 
)

Create a mean image from a list of images, taking into account a mask given pixel to compute

Parameters
meanthe result average of the images collapse
listList of images to collapse
bpmapmask given pixels to compute CPL_BINARY_0 ==> compute the median for this pixel

Definition at line 612 of file xsh_badpixelmap.c.

References assure, check, nx, ny, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, XSH_MALLOC, and xsh_unwrap_vector().

◆ xsh_bpmap_collapse_median()

void xsh_bpmap_collapse_median ( cpl_image *  median,
cpl_imagelist *  list,
cpl_mask *  bpmap 
)

Create a median image from a list of images, taking into account a mask given pixel to compute

Parameters
medianthe result median of the images collapse
listList of images to collapse
bpmapmask given pixels to compute CPL_BINARY_0 ==> compute the median for this pixel

Definition at line 531 of file xsh_badpixelmap.c.

References assure, check, nx, ny, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, XSH_MALLOC, and xsh_unwrap_vector().

Referenced by xsh_find_cosmics().

◆ xsh_bpmap_count()

int xsh_bpmap_count ( cpl_image *  bpmap,
int  nx,
int  ny 
)

Count the number of bad pixels in a bad pixel map image.

Parameters
bpmapBad pixel map image
nxNumber of pixels along X axis
nyNumber of pixels along Y axis
Returns
Tne number of bad pixels

Definition at line 505 of file xsh_badpixelmap.c.

References assure, nx, and ny.

Referenced by verifCr(), and verify_noisy().

◆ xsh_bpmap_mask_bad_pixel()

void xsh_bpmap_mask_bad_pixel ( cpl_image *  bpmap,
cpl_mask *  mask,
int  flag 
)

Definition at line 384 of file xsh_badpixelmap.c.

References assure, check, nx, and ny.

Referenced by xsh_get_master_dark_nir_via_noise(), and xsh_remove_cosmics().

◆ xsh_bpmap_set_bad_pixel()

void xsh_bpmap_set_bad_pixel ( cpl_image *  bpmap,
int  ix,
int  iy,
int  flag 
)

Definition at line 429 of file xsh_badpixelmap.c.

Referenced by flag_noisy_pixels(), and xsh_compute_linearity().

◆ xsh_code_is_in_qual()

cpl_mask * xsh_code_is_in_qual ( cpl_image *  qual,
const int  code 
)

Create the bad pixel map (cpl format) attached to the XSH format Bad Pixel Map image

Parameters
imagethe image on which attaches the cpl bpmap
bpmapXSH format bad pixel map
decode_bpbad pixel code to be rejected

Definition at line 248 of file xsh_badpixelmap.c.

References assure, nx, ny, and size.

◆ xsh_count_crh()

cpl_error_code xsh_count_crh ( xsh_pre pre,
xsh_instrument instr,
const int  datancom 
)

◆ xsh_count_satpix()

cpl_error_code xsh_count_satpix ( xsh_pre pre,
xsh_instrument instr,
const int  datancom 
)

◆ xsh_flag_ima_bad_pix()

static cpl_error_code xsh_flag_ima_bad_pix ( cpl_image **  image,
int *  bppix,
const int  decode_bp 
)
static

Definition at line 135 of file xsh_badpixelmap.c.

References nx, and ny.

Referenced by xsh_bpmap_collapse_bpmap_create(), and xsh_set_image_cpl_bpmap().

◆ xsh_frame_qual_update()

cpl_error_code xsh_frame_qual_update ( cpl_frame *  frame,
const cpl_frame *  bpmap,
xsh_instrument inst 
)

Create coadd a mask frame with another

Parameters
frameinput frame
bpmapbp map frame to be combined

Definition at line 844 of file xsh_badpixelmap.c.

References assure, check, xsh_pre::qual, xsh_badpixelmap_image_coadd(), xsh_free_frame(), xsh_free_image(), xsh_pre_free(), xsh_pre_load(), and xsh_pre_save().

◆ xsh_image_clean_mask_pixs()

cpl_error_code xsh_image_clean_mask_pixs ( cpl_image **  ima,
cpl_image *  msk,
const int  r 
)

Definition at line 1256 of file xsh_badpixelmap.c.

References check, nx, and ny.

◆ xsh_image_coadd()

static cpl_error_code xsh_image_coadd ( cpl_image **  self,
const cpl_image *  add 
)
static

Definition at line 1288 of file xsh_badpixelmap.c.

References check, XSH_ASSURE_NOT_NULL, and xsh_msg.

Referenced by xsh_image_flag_bptype_with_crox().

◆ xsh_image_flag_bp()

void xsh_image_flag_bp ( cpl_image *  image,
cpl_image *  bpmap,
xsh_instrument inst 
)

◆ xsh_image_flag_bptype_with_crox()

cpl_image * xsh_image_flag_bptype_with_crox ( cpl_image *  ima)

Definition at line 1325 of file xsh_badpixelmap.c.

References check, xsh_free_image(), and xsh_image_coadd().

Referenced by xsh_lingain().

◆ xsh_image_get_hot_cold_maps()

static cpl_error_code xsh_image_get_hot_cold_maps ( cpl_image *  masterbias,
const double  kappa_low,
const double  kappa_high,
const int  low_niter,
const int  high_niter,
cpl_mask **  bpmhot,
int *  hotpix_nb,
cpl_mask **  bpmcold,
int *  coldpix_nb,
cpl_propertylist **  hplist,
cpl_propertylist **  cplist 
)
static

◆ xsh_image_get_hot_cold_pixs()

cpl_error_code xsh_image_get_hot_cold_pixs ( cpl_frame *  frame_image,
xsh_instrument instrument,
const double  ks_low,
const int  cold_niter,
const double  ks_high,
const int  hot_niter,
cpl_frame **  cpix_frm,
cpl_frame **  hpix_frm 
)

◆ xsh_image_local_cold_pixs()

cpl_frame * xsh_image_local_cold_pixs ( cpl_image *  ima,
const double  kappa,
const int  r,
xsh_instrument instr 
)

◆ xsh_image_local_hot_pixs()

cpl_frame * xsh_image_local_hot_pixs ( cpl_image *  ima,
const double  kappa,
const int  r,
xsh_instrument instr 
)

◆ xsh_qual_to_cpl_mask()

cpl_mask * xsh_qual_to_cpl_mask ( cpl_image *  qual,
const int  decode_bp 
)

Create the bad pixel map (cpl format) attached to the XSH format Bad Pixel Map image

Parameters
imagethe image on which attaches the cpl bpmap
bpmapXSH format bad pixel map
decode_bpbad pixel code to be rejected

Definition at line 279 of file xsh_badpixelmap.c.

References assure, nx, ny, and size.

Referenced by xsh_hdrl_remove_crh_single(), and xsh_rectify_orders().

◆ xsh_set_image_cpl_bpmap()

void xsh_set_image_cpl_bpmap ( cpl_image *  image,
cpl_image *  bpmap,
const int  decode_bp 
)

Create the bad pixel map (cpl format) attached to the XSH format Bad Pixel Map image

Parameters
imagethe image on which attaches the cpl bpmap
bpmapXSH format bad pixel map
decode_bpbad pixel code to be rejected

Definition at line 310 of file xsh_badpixelmap.c.

References assure, check, and xsh_flag_ima_bad_pix().

Referenced by xsh_compute_linearity(), xsh_compute_noise_map(), and xsh_follow_arclines().