X-shooter Pipeline Reference Manual 3.8.15
xsh_badpixelmap.h
Go to the documentation of this file.
1/* $Id: xsh_badpixelmap.h,v 1.49 2012-11-21 15:47:34 amodigli Exp $
2 *
3 * This file is part of the X-shooter Pipeline
4 * Copyright (C) 2006 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: amodigli $
23 * $Date: 2012-11-21 15:47:34 $
24 * $Revision: 1.49 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifndef XSH_BADPIXELMAP_H
29#define XSH_BADPIXELMAP_H
30
31/*------------------------------------------------------------------------
32 Includes
33 -------------------------------------------------------------------------*/
34#include <xsh_cpl_size.h>
35#include <xsh_data_instrument.h>
36#include <xsh_data_pre.h>
37#include <string.h>
38#include <cpl.h>
39
40/*-------------------------------------------------------------------------
41 Define
42 -------------------------------------------------------------------------*/
43
44/*
45 Quality Flags in the bad pixel maps
46
47 Bad pixel maps are 32 bits int images
48
49*/
50#define QFLAG_GOOD_PIXEL 0
51#define QFLAG_TELLURIC_CORRECTED 1
52#define QFLAG_TELLURIC_UNCORRECTED 0x2
53#define QFLAG_GHOST_STRAY_LIGHT 0x4
54#define QFLAG_ELECTRONIC_PICKUP 0x8
55#define QFLAG_COSMIC_RAY_REMOVED 0x10
56
57/* the last good pixel level */
58#define XSH_GOOD_PIXEL_LEVEL QFLAG_COSMIC_RAY_REMOVED
59#define XSH_BAD_PIXEL XSH_GOOD_PIXEL_LEVEL+1
60
61//#define XSH_GOOD_PIXEL_LEVEL QFLAG_GHOST_STRAY_LIGHT
62/* first really pixel not used */
63#define QFLAG_COSMIC_RAY_UNREMOVED 0x20
64#define QFLAG_LOW_QE_PIXEL 0x40
65#define QFLAG_CALIB_FILE_DEFECT 0x80
66#define QFLAG_HOT_PIXEL 0x100
67#define QFLAG_DARK_PIXEL 0x200
68#define QFLAG_QUESTIONABLE_PIXEL 0x400
69#define QFLAG_WELL_SATURATION 0x800
70#define QFLAG_ADC_SATURATION 0x1000
71#define QFLAG_CAMERA_DEFECT 0x2000
72#define QFLAG_OTHER_BAD_PIXEL 0x4000
73 /* Room for user defined bad pixel codes */
74#define QFLAG_NON_LINEAR_PIXEL 0x8000 /* 2e16 => 32 768 */
75#define QFLAG_NON_SPATIAL_UNIFORMITY 0x10000 /* 2e17 65 536 */
76#define QFLAG_DIVISOR_ZERO 0x20000 /* 2e18 131 072 */
77#define QFLAG_OUT_OF_NOD 0x40000 /* 2e19 262 144 */
78/*Not in rectified shifted frame */
79/* ... */
80#define QFLAG_MISSING_DATA 0x80000 /* 2e19 524 288 */
81#define QFLAG_SATURATED_DATA 0x100000 /* 2e20 1 048 576 */
82#define QFLAG_NEGATIVE_DATA 0x200000 /* 2e21 2 097 152 */
83#define QFLAG_INTERPOL_FLUX 0x400000 /* 2e22 4 194 304 */
84#define QFLAG_SKY_MODEL_BAD_FIT 0x800000 /* 2e23 8 388 608 */
85#define QFLAG_SKY_MODEL_BAD_PIX 0x1000000 /* 2e24 16 777 216 */
86#define QFLAG_ALL_PIX_BAD 0x2000000 /* 2e25 33 554 432 */
87#define QFLAG_INCOMPLETE_DATA 0x4000000 /* 2e26 67 108 864 */
88#define QFLAG_INCOMPLETE_NOD 0x8000000 /* 2e27 134 217 728 */
89#define QFLAG_SCALED_NOD 0x10000000 /* 2e28 268 435 456 */
90#define QFLAG_OUTSIDE_DATA_RANGE 0x40000000 /* 2e30 1 073 741 824 */
91 /*} PIXEL_QUALITY_FLAG ; */
92
93/*------------------------------------------------------------------------
94 Functions prototypes
95 -------------------------------------------------------------------------*/
96
97double cpl_tools_get_median_double( double *, int ) ;
98
99void xsh_bpmap_set_bad_pixel( cpl_image * bpmap, int ix, int iy,
100 int flag ) ;
101void xsh_bpmap_mask_bad_pixel(cpl_image * bpmap, cpl_mask* mask,
102 int flag ) ;
103cpl_mask* xsh_qual_to_cpl_mask(cpl_image * qual, const int decode_bp);
104cpl_mask*
105xsh_code_is_in_qual(cpl_image * qual, const int code) ;
106cpl_frame*
108
109cpl_image * xsh_bpmap_collapse_bpmap_create( cpl_imagelist *list,const int decode_bp ) ;
110cpl_mask * xsh_bpm_filter(
111 const cpl_mask * input_mask,
112 cpl_size kernel_nx,
113 cpl_size kernel_ny,
114 cpl_filter_mode filter);
115
116int xsh_bpmap_count( cpl_image *bpmap, int nx, int ny ) ;
117void xsh_bpmap_collapse_median(cpl_image* median, cpl_imagelist *list,
118 cpl_mask *mask ) ;
119void xsh_bpmap_collapse_mean( cpl_image * mean, cpl_imagelist *list,
120 cpl_mask *mask ) ;
121void xsh_set_image_cpl_bpmap( cpl_image * image,
122 cpl_image *bpmap, const int decode_bp ) ;
123void xsh_badpixelmap_or( xsh_pre *self, const xsh_pre *right ) ;
124void xsh_bpmap_bitwise_to_flag(cpl_image * bpmap,int flag );
125cpl_error_code xsh_badpixelmap_coadd(cpl_frame *self, const cpl_frame *right,const int mode ) ;
126
127cpl_error_code
128xsh_count_satpix(xsh_pre* pre, xsh_instrument* instr, const int datancom);
129cpl_error_code
130xsh_count_crh(xsh_pre* pre, xsh_instrument* instr,const int datancom);
131
132cpl_error_code
133xsh_image_clean_badpixel(cpl_frame* in);
134
135cpl_error_code
136xsh_frame_qual_update(cpl_frame *frame, const cpl_frame *bpmap,xsh_instrument* instrument );
137
138cpl_error_code
139xsh_image_get_hot_cold_pixs(cpl_frame* frame_image,
141 const double ks_low,
142 const int cold_niter,
143 const double ks_high,
144 const int hot_niter,
145 cpl_frame** cpix_frm,
146 cpl_frame** hpix_frm);
147
148cpl_error_code
149xsh_badpixel_flag_rejected(cpl_image* qual, cpl_image* image);
150
151cpl_frame*
152xsh_image_local_cold_pixs(cpl_image* ima,
153 const double kappa,
154 const int r,
155 xsh_instrument* instr);
156
157cpl_frame*
158xsh_image_local_hot_pixs(cpl_image* ima,
159 const double kappa,
160 const int r,
161 xsh_instrument* instr);
162void
163xsh_image_flag_bp(cpl_image * image,cpl_image * mask, xsh_instrument* inst);
164
165cpl_error_code
166xsh_image_clean_mask_pixs(cpl_image** ima,cpl_image* msk,const int r);
167cpl_image* xsh_image_flag_bptype_with_crox(cpl_image* ima);
168cpl_error_code
170 const double cor_val, const int flag, const int is_flat, int* nsat);
171cpl_error_code
173cpl_error_code
174xsh_badpixelmap_image_coadd(cpl_image **self, const cpl_image *right,const int mode );
175cpl_frame* xsh_badpixelmap_extract(cpl_frame* frame, int xmin, int ymin,
176 int xmax, int ymax);
177cpl_error_code
179 const double thresh_min,
180 const double thresh_max,
181 const double cor_val,
182 int* nrange,
183 double* frange);
184#endif
static char mode[32]
static xsh_instrument * instrument
cpl_error_code xsh_count_crh(xsh_pre *pre, xsh_instrument *instr, const int datancom)
cpl_mask * xsh_qual_to_cpl_mask(cpl_image *qual, const int decode_bp)
void xsh_badpixelmap_or(xsh_pre *self, const xsh_pre *right)
cpl_mask * xsh_code_is_in_qual(cpl_image *qual, const int code)
cpl_error_code xsh_frame_qual_update(cpl_frame *frame, const cpl_frame *bpmap, xsh_instrument *instrument)
cpl_error_code xsh_image_clean_mask_pixs(cpl_image **ima, cpl_image *msk, const int r)
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_image * xsh_image_flag_bptype_with_crox(cpl_image *ima)
cpl_image * xsh_bpmap_collapse_bpmap_create(cpl_imagelist *list, const int decode_bp)
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_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 ...
void xsh_image_flag_bp(cpl_image *image, cpl_image *mask, xsh_instrument *inst)
void xsh_bpmap_collapse_mean(cpl_image *mean, cpl_imagelist *list, cpl_mask *mask)
void xsh_bpmap_collapse_median(cpl_image *median, cpl_imagelist *list, cpl_mask *mask)
void xsh_bpmap_bitwise_to_flag(cpl_image *bpmap, int flag)
int xsh_bpmap_count(cpl_image *bpmap, int nx, int ny)
cpl_error_code xsh_badpixelmap_image_coadd(cpl_image **self, const cpl_image *right, const int mode)
void xsh_bpmap_set_bad_pixel(cpl_image *bpmap, int ix, int iy, int flag)
cpl_frame * xsh_image_local_cold_pixs(cpl_image *ima, const double kappa, const int r, xsh_instrument *instr)
cpl_frame * xsh_badpixelmap_crea_master_from_bpmap(cpl_frame *bpmap, xsh_instrument *inst)
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_coadd(cpl_frame *self, const cpl_frame *right, const int mode)
cpl_error_code xsh_count_satpix(xsh_pre *pre, xsh_instrument *instr, const int datancom)
void xsh_bpmap_mask_bad_pixel(cpl_image *bpmap, cpl_mask *mask, int flag)
void xsh_set_image_cpl_bpmap(cpl_image *image, cpl_image *bpmap, const int decode_bp)
cpl_frame * xsh_image_local_hot_pixs(cpl_image *ima, const double kappa, const int r, xsh_instrument *instr)
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 descr...
cpl_error_code xsh_badpixelmap_fill_bp_pattern_holes(cpl_frame *frm)
cpl_error_code xsh_badpixel_flag_rejected(cpl_image *qual, cpl_image *image)
double cpl_tools_get_median_double(double *, int)
cpl_error_code xsh_image_clean_badpixel(cpl_frame *in)
int nx
double kappa
Definition: xsh_detmon_lg.c:81
int ny
int filter