X-shooter Pipeline Reference Manual 3.8.15
xsh_remove_crh_multi.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2013-01-31 08:56:43 $
23 * $Revision: 1.133 $
24 * $Name: not supported by cvs2svn $
25 *
26 */
27
28#ifdef HAVE_CONFIG_H
29# include <config.h>
30#endif
31
32/*----------------------------------------------------------------------------*/
39/*----------------------------------------------------------------------------*/
42/*-----------------------------------------------------------------------------
43 Includes
44-----------------------------------------------------------------------------*/
45
46#include <math.h>
47
48#include <xsh_drl.h>
49#include <xsh_data_pre.h>
50#include <xsh_dfs.h>
51#include <xsh_pfits.h>
52#include <xsh_error.h>
53#include <xsh_msg.h>
54#include <cpl.h>
55#include <xsh_badpixelmap.h>
56#include <xsh_irplib_mkmaster.h>
57#include <xsh_utils_image.h>
58#include <xsh_utils_imagelist.h>
59
60/*-----------------------------------------------------------------------------
61 Functions prototypes
62 -----------------------------------------------------------------------------*/
63
64/*-----------------------------------------------------------------------------
65 Implementation
66 -----------------------------------------------------------------------------*/
67
68
69static int
70xsh_remove_cr (cpl_imagelist * datalist, cpl_imagelist * errslist,
71 cpl_image * median,
72 cpl_image * errs, cpl_mask * mask,
74{
75 int nx, ny, nimg, i;
76 cpl_image **pimg = NULL;
77 cpl_image **perrs = NULL;
78 int ix = 0,iy = 0;
79 int crcount = 0;
80 float* medvals = NULL;
81 float* mederrs = NULL;
82 cpl_binary *bpmdata = NULL;
83
84
85
86 check(nimg = cpl_imagelist_get_size (datalist));
87
88 /* create the array of pointers to images in list */
89 pimg = cpl_malloc (nimg * sizeof (cpl_image *));
90 assure (pimg != NULL, cpl_error_get_code (),
91 "Cant allocate memory for image pointers");
92 perrs = cpl_malloc (nimg * sizeof (cpl_image *));
93 assure (pimg != NULL, cpl_error_get_code (),
94 "Cant allocate memory for image pointers");
95
96 xsh_msg_dbg_low ("Nb of images: %d\n", nimg);
97
98 /* Populate images pointer array */
99 for (i = 0; i < nimg; i++){
100 *(pimg + i) = cpl_imagelist_get (datalist, i);
101 *(perrs + i) = cpl_imagelist_get (errslist, i);
102 }
103
104 /* get size from first image */
105 check(nx = cpl_image_get_size_x (*pimg));
106 check(ny = cpl_image_get_size_y (*pimg));
107
108 /* Loop over all pixels */
109 check(medvals = cpl_image_get_data_float(median));
110 check(mederrs = cpl_image_get_data_float(errs));
111 check(bpmdata = cpl_mask_get_data(mask));
112
113 for (iy = 1; iy <= ny; iy++){
114 for (ix = 1; ix <= nx; ix++) {
115 int k;
116 double medval;
117 double error;
118 int badpix = 0;
119 /* crh_clipping->sigma is what is usually called 'kappa' */
120 error = mederrs[ix-1+(iy-1)*nx] * crh_clipping->sigma;
121 //xsh_msg("errs=%g kappa=%g",mederrs[ix-1+(iy-1)*nx],crh_clipping->sigma);
122 medval = medvals[ix-1+(iy-1)*nx];
123 badpix = 0;
124
125
126 for (k = 0; k < nimg; k++) {
127 /* if good pixel, check if still good */
128 if (!bpmdata[ix-1+(iy-1)*nx]) {
129 double delta = 0.0, kvalue = 0.0;
130 int rej = 0;
131 kvalue = cpl_image_get (*(pimg + k), ix, iy, &rej);
132 if (rej != 0) {
133 xsh_msg_dbg_high ("Pixel %d,%d already bad in image %d", ix, iy, k);
134 continue;
135 }
136 delta = fabs(kvalue - medval);
137 /*
138 xsh_msg("error=%g kvalue=%g medval=%g delta=%g",
139 error,kvalue,medval,delta);
140 */
141 if (delta > error) {
142 cpl_image_reject (*(pimg + k), ix, iy);
143 cpl_image_reject (*(perrs + k), ix, iy);
144 if ( crcount < 10 )
145 xsh_msg ("CR Rejected for Pixel %d,%d [%d] (%lf vs %lf)",
146 ix, iy, k, medval, kvalue);
147
148 crcount++;
149 badpix = 1;
150 }
151 }
152 else {
153 xsh_msg_dbg_high("Pixel %d,%d already known as bad pixel in image %d", ix, iy,
154 k+1);
155 break;
156 }
157 }
158 /*TODO: simply bitwise or combine with code for CRH pix */
159 /* mask good pixel */
160 if (!badpix){
161 /*xsh_msg("add to mask %d %d",ix,iy);*/
162 bpmdata[ix-1+(iy-1)*nx] = CPL_BINARY_1;
163 }
164
165 }
166 }
167
168 cpl_free (pimg);
169 cpl_free(perrs);
170
171 cleanup:
172 return crcount;
173}
174
183static void
184add_qc_crh (xsh_pre* pre, int nbcrh, int nframes)
185{
186 double qc_crrate = 0.0;
187 float nbcr_avg ;
189 XSH_ASSURE_NOT_ILLEGAL(pre->pszx >0. && pre->pszy > 0);
191 /*
192 QC.CRRATE = avg_nb_of_crh_per_frame/(exposure_time*size_of_detector_in_cm2)
193 Nb of Cosmics per cm2 per second.
194 The whole size of the image in cm2 is given by pszx and pszy. These
195 values are in MICRONS.
196 */
197 xsh_msg_dbg_medium( "add_qc_crh - Exptime = %f", pre->exptime ) ;
198 qc_crrate =
199 (double) nbcrh / (((double) nframes) * (pre->exptime *
200 (pre->pszx / 10000.0) * (pre->pszy /10000.0) * pre->nx * pre->ny)) ;
201 nbcr_avg = (float)nbcrh/nframes ;
202
203 /*
204 Now set QC KW
205 */
206 check( xsh_pfits_set_qc_crrate( pre->data_header,qc_crrate) ) ;
207 check( xsh_pfits_set_qc_ncrh( pre->data_header, nbcrh) ) ;
208 check( xsh_pfits_set_qc_ncrh_mean( pre->data_header,nbcr_avg) ) ;
210 /* Same thing for the qual header */
211 check( xsh_pfits_set_qc_crrate( pre->qual_header,qc_crrate)) ;
213 check( xsh_pfits_set_qc_ncrh_mean( pre->qual_header,nbcr_avg) ) ;
214 cleanup:
215 return ;
216}
217
218static cpl_error_code
220 cpl_imagelist* dataList,
221 cpl_imagelist* errsList,cpl_mask* badpix_mask,xsh_instrument* instr,cpl_mask** crh_mask)
222{
223 long int nbpixcosmic=-1;
224 int nb_crh_total=0;
225 int iter=0;
226 int size=0;
227 /* TODO: we could drop rawFrames argument */
228 check( size = cpl_frameset_get_size( rawFrames));
229
230 /* loop to remove cosmics */
231 long nbpixtotal = cpl_frameset_get_size(rawFrames) * pre->nx * pre->ny;
232 double frac_accepted = 1;
233
234 while(iter < crh_clipping->niter && frac_accepted >= crh_clipping->frac
235 && (nbpixcosmic!=0) ) {
236
237
238 /* try to remove cosmics */
239 check(nbpixcosmic = xsh_remove_cr (dataList, errsList,pre->data,
240 pre->errs, badpix_mask, crh_clipping));
241 if(iter==0) {
242 *crh_mask=cpl_mask_duplicate(badpix_mask);
243 }
244
245 //AModigliani: here one have to use an and (or better an or) to coadd the
246 //bad pixels found on each iteration. Instead the actual bad pixel
247 //image saved on the QUAL part is the one coming from the last iteration
248 //which usually does not find any bad pixel. This is wrong. I propose
249 //to use the one which I save as crh_mask, even bettter if coming from
250 //an or coaddition: cpl_mask_or(...)
251 check(cpl_mask_and(*crh_mask,badpix_mask));
252 //check(crh_img=cpl_image_new_from_mask(badpix_mask));
253 //sprintf(name,"%s_ITER_%d%s","crh_ima_",iter,".fits");
254 //cpl_image_save (crh_img,name,CPL_BPP_32_SIGNED,NULL, CPL_IO_DEFAULT);
255 //xsh_free_image(&crh_img);
256
257 xsh_msg(" Iteration Nb %d/%d, new cosmic found %ld",
258 iter+1, crh_clipping->niter, nbpixcosmic);
259
260 /* computes fraction */
261 frac_accepted -= ((double)nbpixcosmic / (double)nbpixtotal);
262 xsh_msg_dbg_medium("accepted pixels / total pixels = %f)",frac_accepted);
263
264 /* recreate median image */
265 xsh_image_flag_bp(pre->data,pre->qual,instr);
266 check(xsh_bpmap_collapse_median(pre->data,dataList,*crh_mask));
267 //pre->data=xsh_irplib_mkmaster_median(dataList,5,5,1.e-5);
268 /* recreate errs image */
269 xsh_image_flag_bp(pre->errs,pre->qual,instr);
270 check(xsh_collapse_errs(pre->errs,errsList,0));
271 iter++;
272
273 /* Total nb of cosmics */
274 nb_crh_total += nbpixcosmic ;
275 }
276
277
278
279 //check( pre->data=xsh_imagelist_collapse_sigclip_iter_create(dataList,3,3,2));
280
281
282 xsh_msg("Nb of cosmics removed by frame stacking: %d ", nb_crh_total);
283
284 /* Add QC Keywords */
285 if (pre->exptime > 0){
286 check(add_qc_crh( pre, nb_crh_total, size));
287 }
288
289 cleanup:
290 return cpl_error_get_code();
291}
292
293cpl_error_code
294xsh_flag_cosmic_debug(xsh_pre* pre,cpl_imagelist* dataList)
295{
296
297 cpl_mask* cosmic_mask = NULL;
298 int imask=0;
299 int jmask=0;
300 int i=0;
301 cpl_image* img=NULL;
302 cpl_mask* img_mask=NULL;
303 int size=cpl_imagelist_get_size(dataList);
304
305 cosmic_mask = cpl_mask_new(pre->nx, pre->ny);
306 for(i=0;i< size; i++){
307 img = cpl_imagelist_get( dataList, i);
308 img_mask = cpl_image_get_bpm( img);
309 for(jmask=1; jmask<=pre->ny; jmask++){
310 for(imask=1; imask <= pre->nx; imask++){
311 if (cpl_mask_get(img_mask,imask, jmask) == CPL_BINARY_1){
312 cpl_mask_set(cosmic_mask, imask, jmask,CPL_BINARY_1);
313 }
314 }
315 }
316 }
317 //xsh_bpmap_mask_bad_pixel( pre->qual, cosmic_mask,
318 //QFLAG_COSMIC_RAY_REMOVED);
319 //AModigliani: I think here is the place one need to modify the BP map.
320 //xsh_bpmap_mask_bad_pixel( pre->qual, cpl_mask_threshold_image_create(crh_ima,-0.5,0.5),
321 // QFLAG_COSMIC_RAY_REMOVED);
322 cpl_mask_delete( cosmic_mask);
323
324 return cpl_error_get_code();
325}
326/*---------------------------------------------------------------------------*/
340static cpl_frame*
341xsh_remove_cosmics (cpl_frameset * rawFrames,
342 const char *result_tag,
343 xsh_stack_param* stack_par,
345 xsh_instrument* instr,
346 cpl_imagelist ** list,
347 cpl_image** crh_ima,
348 const int save_tmp )
349{
350 /* MUST BE DEALLOCATED in caller */
351 cpl_frame* medFrame = NULL;
352 cpl_imagelist *dataList = NULL;
353 cpl_image* qual_comb = NULL;
354
355 /* ALLOCATED locally */
356 cpl_imagelist *errsList = NULL;
357 xsh_pre* pre = NULL;
358 cpl_mask* badpix_mask = NULL;
359 cpl_mask* crh_mask = NULL;
360 /* Others */
361 cpl_frame *current = NULL;
362 int i=0, size = 0;
363
364 //cpl_image* crh_img=NULL;
365 char name[256];
366 char result_name[256];
367 const int mode_and = 0;
368 int ncrh_tot = 0;
369
370 /* Check parameters */
371 XSH_ASSURE_NOT_NULL( instr);
372 XSH_ASSURE_NOT_NULL( rawFrames);
373 XSH_ASSURE_NOT_NULL( result_tag);
374 check( size = cpl_frameset_get_size( rawFrames));
375 xsh_msg("size=%d",size);
376
378
379 /* Create the image lists */
380 check( dataList = cpl_imagelist_new());
381 check( errsList = cpl_imagelist_new());
382
383 /* Populate image lists with images in frame set */
384 cpl_mask* mask_comb;;
385 cpl_mask* mask_tmp;
386 for (i=0;i < size;i++){
387
388 check(current = cpl_frameset_get_frame(rawFrames,i));
389 /* Load pre file */
390 check(pre = xsh_pre_load(current,instr));
391
392 /* inject bad pixels to change statistics */
393 xsh_image_flag_bp(pre->data, pre->qual, instr);
394 xsh_image_flag_bp(pre->errs, pre->qual, instr);
395 mask_tmp=cpl_image_get_bpm(pre->data);
396
397 check_msg( cpl_imagelist_set(dataList,cpl_image_duplicate(pre->data),
398 i),"Can't add Data Image %d to imagelist", i) ;
399 check_msg( cpl_imagelist_set(errsList,cpl_image_duplicate(pre->errs),
400 i),"Can't add Data Image %d to imagelist", i) ;
401
402 if(cpl_propertylist_has(pre->data_header,XSH_QC_CRH_NUMBER)) {
403 ncrh_tot += xsh_pfits_get_qc_ncrh(pre->data_header);
404 }
405
406 /* combining bad pixels */
407 if (i == 0) {
408 mask_comb=cpl_mask_duplicate(mask_tmp);
409 qual_comb = cpl_image_duplicate(pre->qual);
410 } else {
411 xsh_badpixelmap_image_coadd(&qual_comb, pre->qual, mode_and);
412 cpl_mask_or(mask_comb,mask_tmp);
413 }
414
415 /* Free memory */
416 if (i < (size-1)) {
417 xsh_pre_free(&pre);
418 }
419 }
420 //xsh_bpmap_mask_bad_pixel(qual_comb,mask_comb,QFLAG_INCOMPLETE_DATA);
421 /*free memory on product extensions that will be re-allocated later on (errs is only modified) */
422 xsh_free_image(&pre->data);
423 xsh_free_image(&pre->qual);
424 cpl_mask_delete(mask_comb);
425
426
427
428 /* computes the median or sigma-clipped mean on data and errs */
429 if(strcmp(stack_par->stack_method,"median") == 0) {
431
432 check( xsh_collapse_errs(pre->errs,errsList,0));
433
434 } else {
435 pre->data=cpl_imagelist_collapse_sigclip_create(dataList,
436 stack_par->klow,stack_par->khigh,.1,CPL_COLLAPSE_MEAN,NULL);
437 check( xsh_collapse_errs(pre->errs,errsList,1));
438
439 }
440 int nrej=cpl_image_count_rejected(pre->data);
441 if(nrej>0) {
442 xsh_badpixel_flag_rejected(pre->data,qual_comb);
443 }
444
445 /* store combined bp map in qual extension of result */
446 pre->qual = cpl_image_duplicate(qual_comb);
447 xsh_free_image(&qual_comb);
448
449 /* loop to remove cosmics */
450 if ( size >= 3 && crh_clipping != NULL) {
451 check(badpix_mask = cpl_mask_duplicate(xsh_pre_get_bpmap(pre)));
452 check(xsh_find_cosmics(rawFrames,pre,crh_clipping,dataList,errsList,badpix_mask,instr,&crh_mask));
453 xsh_free_mask(&badpix_mask);
454 }
455
456 /* Add PRO KW */
457 //check( xsh_pfits_set_datancom( pre->data_header, size));
458
459 /* remove irrelevant KW */
460 check( cpl_propertylist_erase_regexp( pre->data_header, "PRO BIAS *", 0));
461
462 /* Now save the relevant frame of PRE
463 With: median image, errs image and bad pixel map
464 */
465 sprintf(result_name, "%s.fits", result_tag);
466 xsh_msg_dbg_high("save frame %s tag=%s", result_name, result_tag);
467
468 if(strstr(result_tag,"DARK") != NULL) {
469 if(!cpl_propertylist_has(pre->data_header,XSH_QC_CRH_NUMBER_TOT)) {
471 }
472 if(!cpl_propertylist_has(pre->data_header,XSH_QC_CRH_NUMBER_MEAN)) {
473 xsh_pfits_set_qc_ncrh_mean(pre->data_header,(float)ncrh_tot/size);
474 }
475 } else {
476 //if(!cpl_propertylist_has(pre->data_header,XSH_QC_CRH_NUMBER_TOT)) {
478 //}
479 //if(!cpl_propertylist_has(pre->data_header,XSH_QC_CRH_NUMBER_MEAN)) {
480 xsh_pfits_set_qc_ncrh_mean(pre->data_header,(float)ncrh_tot/size);
481 //}
482 }
483 check(medFrame = xsh_pre_save( pre, result_name, result_tag,save_tmp));
484 check(cpl_frame_set_tag(medFrame, result_tag));
485
486 //AMo: add crh map save for QC
487 if ((crh_mask != NULL) && ((crh_ima) != NULL)) {
488 xsh_free_image(crh_ima);
489 check(*crh_ima=cpl_image_new_from_mask(crh_mask));
490 cpl_mask_not(crh_mask);
492 //here good pixels are still flagged as '1'. To have proper code, '0',
493 //we make a threshold
494 cpl_image_threshold(*crh_ima, 1.1, DBL_MAX, 0, DBL_MAX);
495 check(sprintf(name,"%s.fits",XSH_GET_TAG_FROM_ARM(XSH_CRH_MAP,instr)));
496 //cpl_image_save (*crh_ima,name,CPL_BPP_32_SIGNED,NULL, CPL_IO_DEFAULT);
497 }
498
499 /* At this point, the images in dataList contain the "cpl bad pixel map"
500 with the locally found CRh ==> should be used in compute_noise
501 How should we return this list to the main recipe ==> in list
502 */
503
504 cleanup:
505 if (cpl_error_get_code () != CPL_ERROR_NONE) {
506 xsh_free_imagelist(&dataList);
507 xsh_free_frame(&medFrame);
508 if (list != NULL){
509 *list = NULL;
510 }
511 }
512 if (list != NULL){
513 *list = dataList;
514 }
515 else{
516 xsh_free_imagelist(&dataList);
517 }
518 //xsh_free_image(crh_ima);
519 xsh_free_mask(&crh_mask);
520 xsh_free_mask(&badpix_mask);
521 xsh_pre_free(&pre);
522 xsh_free_imagelist(&errsList) ;
523 return medFrame ;
524}
525
526cpl_frame*
527xsh_remove_crh_multiple (cpl_frameset * rawFrames,
528 const char *result_tag,
529 xsh_stack_param* stack_par,
532 cpl_imagelist ** list,
533 cpl_image** crh_ima,
534 const int save_tmp)
535{
536 cpl_frame * result = NULL ;
537
538 XSH_ASSURE_NOT_NULL( rawFrames ) ;
539 XSH_ASSURE_NOT_NULL( result_tag ) ;
540 XSH_ASSURE_NOT_NULL( stack_par ) ;
542 check( result = xsh_remove_cosmics( rawFrames, result_tag, stack_par,crh_clipping,
543 instrument, list, crh_ima,save_tmp ) ) ;
544 cleanup:
545 return result ;
546}
547
548cpl_frame*
549xsh_combine_offset(cpl_frameset * rawFrames, const char * result_tag,
550 xsh_stack_param* stack_par,
551 xsh_instrument * instrument, cpl_imagelist ** list, cpl_image** crh_ima,
552 const int save_tmp)
553{
554 cpl_frame * result = NULL ;
555
556 XSH_ASSURE_NOT_NULL( rawFrames ) ;
557 XSH_ASSURE_NOT_NULL( result_tag ) ;
558 XSH_ASSURE_NOT_NULL( stack_par ) ;
560
561 check( result = xsh_remove_cosmics( rawFrames, result_tag, stack_par,NULL,
562 instrument, list, crh_ima,save_tmp ) ) ;
563 cleanup:
564 return result ;
565}
566
static xsh_instrument * instrument
static xsh_clipping_param crh_clipping
void xsh_image_flag_bp(cpl_image *image, cpl_image *bpmap, xsh_instrument *inst)
void xsh_bpmap_collapse_median(cpl_image *median, cpl_imagelist *list, cpl_mask *bpmap)
cpl_error_code xsh_badpixelmap_image_coadd(cpl_image **self, const cpl_image *right, const int mode)
void xsh_bpmap_mask_bad_pixel(cpl_image *bpmap, cpl_mask *mask, int flag)
cpl_error_code xsh_badpixel_flag_rejected(cpl_image *qual, cpl_image *image)
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
Definition: xsh_data_pre.c:849
cpl_mask * xsh_pre_get_bpmap(const xsh_pre *pre)
Get bpmap of pre structure.
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
Definition: xsh_data_pre.c:823
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
#define XSH_ASSURE_NOT_ILLEGAL(cond)
Definition: xsh_error.h:107
#define assure(CONDITION, ERROR_CODE,...)
Definition: xsh_error.h:54
#define check(COMMAND)
Definition: xsh_error.h:71
#define check_msg(COMMAND,...)
Definition: xsh_error.h:62
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
int size
#define xsh_msg_dbg_medium(...)
Definition: xsh_msg.h:44
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define xsh_msg_dbg_low(...)
Definition: xsh_msg.h:48
#define xsh_msg_dbg_high(...)
Definition: xsh_msg.h:40
int xsh_pfits_get_qc_ncrh(const cpl_propertylist *plist)
Find out the QC NCRH value.
Definition: xsh_pfits_qc.c:74
void xsh_pfits_set_qc_ncrh_mean(cpl_propertylist *plist, const double value)
Write the QC.NCRH.AVG value.
Definition: xsh_pfits_qc.c:771
void xsh_pfits_set_qc_ncrh(cpl_propertylist *plist, int value)
Write the QC.NCRH value.
Definition: xsh_pfits_qc.c:754
void xsh_pfits_set_qc_crrate(cpl_propertylist *plist, double value)
Write the QC.CRRATE value.
Definition: xsh_pfits_qc.c:805
void xsh_pfits_set_qc_ncrh_tot(cpl_propertylist *plist, const int value)
Write the QC.NCRH.TOT value.
Definition: xsh_pfits_qc.c:788
cpl_frame * xsh_combine_offset(cpl_frameset *rawFrames, const char *result_tag, xsh_stack_param *stack_par, xsh_instrument *instrument, cpl_imagelist **list, cpl_image **crh_ima, const int save_tmp)
cpl_error_code xsh_flag_cosmic_debug(xsh_pre *pre, cpl_imagelist *dataList)
static void add_qc_crh(xsh_pre *pre, int nbcrh, int nframes)
static int xsh_remove_cr(cpl_imagelist *datalist, cpl_imagelist *errslist, cpl_image *median, cpl_image *errs, cpl_mask *mask, xsh_clipping_param *crh_clipping)
cpl_frame * xsh_remove_crh_multiple(cpl_frameset *rawFrames, const char *result_tag, xsh_stack_param *stack_par, xsh_clipping_param *crh_clipping, xsh_instrument *instrument, cpl_imagelist **list, cpl_image **crh_ima, const int save_tmp)
static cpl_error_code xsh_find_cosmics(cpl_frameset *rawFrames, xsh_pre *pre, xsh_clipping_param *crh_clipping, cpl_imagelist *dataList, cpl_imagelist *errsList, cpl_mask *badpix_mask, xsh_instrument *instr, cpl_mask **crh_mask)
static cpl_frame * xsh_remove_cosmics(cpl_frameset *rawFrames, const char *result_tag, xsh_stack_param *stack_par, xsh_clipping_param *crh_clipping, xsh_instrument *instr, cpl_imagelist **list, cpl_image **crh_ima, const int save_tmp)
Creates median, error and bad pixel map images from a set of frames.
void xsh_free_image(cpl_image **i)
Deallocate an image and set the pointer to NULL.
Definition: xsh_utils.c:2116
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
Definition: xsh_utils.c:2269
void xsh_free_mask(cpl_mask **m)
Deallocate an image mask and set the pointer to NULL.
Definition: xsh_utils.c:2149
void xsh_free_imagelist(cpl_imagelist **i)
Deallocate an image list and set the pointer to NULL.
Definition: xsh_utils.c:2164
cpl_image * qual
Definition: xsh_data_pre.h:71
float exptime
Definition: xsh_data_pre.h:92
float pszy
Definition: xsh_data_pre.h:88
cpl_propertylist * qual_header
Definition: xsh_data_pre.h:72
cpl_image * data
Definition: xsh_data_pre.h:65
cpl_propertylist * data_header
Definition: xsh_data_pre.h:66
cpl_image * errs
Definition: xsh_data_pre.h:68
float pszx
Definition: xsh_data_pre.h:88
const char * stack_method
#define QFLAG_COSMIC_RAY_REMOVED
int nx
int niter
Definition: xsh_detmon_lg.c:82
int ny
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
Definition: xsh_dfs.h:1548
#define XSH_CRH_MAP
Definition: xsh_dfs.h:298
#define XSH_QC_CRH_NUMBER_TOT
#define XSH_QC_CRH_NUMBER_MEAN
#define XSH_QC_CRH_NUMBER
cpl_error_code xsh_collapse_errs(cpl_image *errs, cpl_imagelist *list, const int mode)
cpl_image * xsh_imagelist_collapse_median_create(cpl_imagelist *iml)
Compute median on imagelist.