X-shooter Pipeline Reference Manual 3.8.15
xsh_mdark.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-04-29 10:00:50 $
23 * $Revision: 1.183 $
24*/
25
26#ifdef HAVE_CONFIG_H
27#include <config.h>
28#endif
29
30/*----------------------------------------------------------------------------*/
38/*----------------------------------------------------------------------------*/
41/*-----------------------------------------------------------------------------
42 Includes
43 ----------------------------------------------------------------------------*/
44
45
46/* DRL steps */
47
48/* Error handling */
49#include <xsh_error.h>
50/* Utility fonctions */
51#include <xsh_utils.h>
52#include <xsh_utils_image.h>
53#include <xsh_msg.h>
54/* DFS functions */
55#include <xsh_dfs.h>
56/* DRL functions */
57#include <xsh_drl.h>
58/* Header functions */
59#include <xsh_pfits.h>
60/* Library */
61#include <cpl.h>
62/* CRH Remove */
63#include <xsh_drl_check.h>
65#include <xsh_badpixelmap.h>
66
67/*-----------------------------------------------------------------------------
68 Defines
69 ----------------------------------------------------------------------------*/
70
71#define RECIPE_ID "xsh_mdark"
72#define RECIPE_AUTHOR "P.Goldoni, L.Guglielmi, R. Haigron, F. Royer, D. Bramich, A. Modigliani"
73#define RECIPE_CONTACT "amodigli@eso.org"
74
75/*-----------------------------------------------------------------------------
76 Functions prototypes
77 ----------------------------------------------------------------------------*/
78
79/*
80 * Plugin initalization, execute and cleanup handlers
81 */
82
83static int xsh_mdark_create(cpl_plugin *);
84static int xsh_mdark_exec(cpl_plugin *);
85static int xsh_mdark_destroy(cpl_plugin *);
86
87/* The actual executor function */
88static void xsh_mdark(cpl_parameterlist *, cpl_frameset *);
89
90/*-----------------------------------------------------------------------------
91 Static variables
92 ----------------------------------------------------------------------------*/
94"Create the master dark frame";
95
96static char xsh_mdark_description[] =
97"This recipe creates a master dark frame\n\
98Input Frames : \n\
99 - A set of n RAW frames (Format=RAW, n >=3, Tag = DARK_arm)\n\
100 - [UVB,VIS] A master bias frame (Format=PRE, Tag = MASTER_BIAS_arm)\n\
101 - [OPTIONAL] A map of non linear bad pixels (Format=QUP, Tag = BP_MAP_NL_arm)\n\
102 - [OPTIONAL] A map of reference bad pixels (Format = QUP,RAW, Tag = BP_MAP_RP_arm)\n\
103Products : \n\
104 - A master dark frame (Format=PRE, PRO.CATG = MASTER_DARK_arm)\n\
105 A dark frame, (Format=PRE, PRO.CATG = DARK_arm)\n";
106
107/*
108 - [VIS && bp-output=yes] A badpixel map (Format=QUP, \n\
109 PRO.CATG = MASTER_BP_MAP_DARK_arm)\n\
110 - If an input master bad pixel map or a map of non linear pixels is provided \n\
111
112 - A map frame containing CRHs (PRO.CATG = CRH_MAP_arm)\n\
113*/
114/*-----------------------------------------------------------------------------
115 Functions code
116 ----------------------------------------------------------------------------*/
117/*----------------------------------------------------------------------------*/
126/*----------------------------------------------------------------------------*/
127
128int cpl_plugin_get_info(cpl_pluginlist *list) {
129 cpl_recipe *recipe = NULL;
130 cpl_plugin *plugin = NULL;
131
132 recipe = cpl_calloc(1, sizeof(*recipe));
133 if ( recipe == NULL ){
134 return -1;
135 }
136
137 plugin = &recipe->interface ;
138
139 cpl_plugin_init(plugin,
140 CPL_PLUGIN_API, /* Plugin API */
141 XSH_BINARY_VERSION, /* Plugin version */
142 CPL_PLUGIN_TYPE_RECIPE, /* Plugin type */
143 RECIPE_ID, /* Plugin name */
144 xsh_mdark_description_short, /* Short help */
145 xsh_mdark_description, /* Detailed help */
146 RECIPE_AUTHOR, /* Author name */
147 RECIPE_CONTACT, /* Contact address */
148 xsh_get_license(), /* Copyright */
152
153 cpl_pluginlist_append(list, plugin);
154
155 return (cpl_error_get_code() != CPL_ERROR_NONE);
156}
157
158/*----------------------------------------------------------------------------*/
168/*----------------------------------------------------------------------------*/
169
170static int xsh_mdark_create(cpl_plugin *plugin){
171 cpl_recipe *recipe = NULL;
172 xsh_clipping_param crh_clip_param = {-1.0, 3, 0.7, 0, 0.3};
173 xsh_clipping_param noise_clip_param = {9.0, 5, 0.7, 0, 0.3};
174 xsh_fpn_param fpn_param = {-1,-1,-1,-1,4,100};
175 xsh_ref_param ref_param = {-1,-1,-1,-1};
176 xsh_ron_dark_param ron_param = {-1,-1,-1,-1,4,100};
177 xsh_stack_param stack_param = {"median",5.,5.};
178 int ival=DECODE_BP_FLAG_DEF;
179 /* Reset library state */
180 xsh_init();
181
182 /* Check input */
183 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
184
185 /* Get the recipe out of the plugin */
186 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
187 CPL_ERROR_TYPE_MISMATCH,
188 "Plugin is not a recipe");
189
190 recipe = (cpl_recipe *)plugin;
191
192 /* Create the parameter list in the cpl_recipe object */
193 recipe->parameters = cpl_parameterlist_new();
194 assure( recipe->parameters != NULL,
195 CPL_ERROR_ILLEGAL_OUTPUT,
196 "Memory allocation failed!");
197
198 /* Set generic parameters (common to all recipes) */
199 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
200 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,ival);
201 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
202 check(xsh_parameters_stack_create(RECIPE_ID,recipe->parameters,stack_param));
203
204 /* Set bp_output param */
205 check(xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
206 "bp-output", false,
207 "Flag indicating whether the noise bad pixel map is to be computed"));
208
209 /* crh clipping params */
211 crh_clip_param));
212
213 /* noise clipping params */
215 recipe->parameters,
216 noise_clip_param));
217
218 check(xsh_parameters_new_double( recipe->parameters,RECIPE_ID,
219 "noise-lower-rejection", 10.,
220 "Lower rejection percentile to flag bad pixels via noise"));
221
222 check(xsh_parameters_new_double( recipe->parameters, RECIPE_ID,
223 "noise-higher-rejection", 10.,
224 "Upper rejection percentile to flag bad pixels via noise"));
225
226
227 check(xsh_parameters_ref1_create(RECIPE_ID,recipe->parameters,
228 ref_param));
229
230
232 ron_param));
233
234 check(xsh_parameters_fpn_create(RECIPE_ID,recipe->parameters,
235 fpn_param));
236
237
238
239 cleanup:
240 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
241 xsh_error_dump(CPL_MSG_ERROR);
242 return 1;
243 }
244 else {
245 return 0;
246 }
247}
248
249/*----------------------------------------------------------------------------*/
255/*----------------------------------------------------------------------------*/
256
257static int xsh_mdark_exec(cpl_plugin *plugin) {
258 cpl_recipe *recipe = NULL;
259
260 /* Check parameter */
261
262 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
263
264 /* Get the recipe out of the plugin */
265 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
266 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
267
268 recipe = (cpl_recipe *)plugin;
269
270 /* Check recipe */
271 xsh_mdark(recipe->parameters, recipe->frames);
272
273 cleanup:
274 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
275 xsh_error_dump(CPL_MSG_ERROR);
277 return 1;
278 }
279 else {
280 return 0;
281 }
282}
283
284/*----------------------------------------------------------------------------*/
290/*----------------------------------------------------------------------------*/
291static int xsh_mdark_destroy(cpl_plugin *plugin)
292{
293 cpl_recipe *recipe = NULL;
294
295 /* reset error state before detroying recipe */
297 /* Check parameter */
298 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
299
300 /* Get the recipe out of the plugin */
301 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
302 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
303 recipe = (cpl_recipe *)plugin;
304
305 xsh_free_parameterlist(&recipe->parameters);
306
307 cleanup:
308 if (cpl_error_get_code() != CPL_ERROR_NONE)
309 {
310 return 1;
311 }
312 else
313 {
314 return 0;
315 }
316}
317
318static cpl_error_code
319xsh_params_set_defaults(cpl_parameterlist* pars,
320 xsh_instrument* inst)
321{
322 cpl_parameter* p=NULL;
323
324 check(p=xsh_parameters_find(pars,RECIPE_ID,"crh-clip-kappa"));
325 if(cpl_parameter_get_double(p) <= 0) {
327 cpl_parameter_set_double(p,11.);
328 } else {
329 cpl_parameter_set_double(p,9.);
330 }
331 }
332
333 cleanup:
334
335 return cpl_error_get_code();
336
337}
338
339
340
341static cpl_frame*
342xsh_get_master_dark_nir_via_noise(cpl_imagelist* dataList, cpl_frame* medFrame,
343 cpl_parameterlist* parameters, xsh_clipping_param* noise_clipping,
344 xsh_instrument* instrument,cpl_frame** noisyFrame) {
345 cpl_frame* nirFrame = NULL;
346
347 cpl_parameter* p = NULL;
348 int llx = 0;
349 int lly = 0;
350 int urx = 0;
351 int ury = 0;
352 int iter = 0;
353 int low_rej = 0;
354 int high_rej = 0;
355 cpl_image* noise_image = NULL;
356 cpl_mask* bp_map_noise = NULL;
357 cpl_propertylist* plist = NULL;
358 const char* bp_map_noise_pro_catg = NULL;
359 char bp_map_noise_name[256];
360
361
363 "Noise parameters: Sigma %lf, Niteration %d, \
364 Fraction %lf, Diff %lf", noise_clipping->sigma, noise_clipping->niter, noise_clipping->frac, noise_clipping->diff);
365
366 nirFrame = xsh_compute_noise_map(dataList, medFrame, noise_clipping,
367 instrument,noisyFrame);
368
369
370 p = cpl_parameterlist_find(parameters, "xsh.xsh_mdark.ref1_llx");
371 llx = cpl_parameter_get_int(p);
372 p = cpl_parameterlist_find(parameters, "xsh.xsh_mdark.ref1_lly");
373 lly = cpl_parameter_get_int(p);
374 p = cpl_parameterlist_find(parameters, "xsh.xsh_mdark.ref1_urx");
375 urx = cpl_parameter_get_int(p);
376 p = cpl_parameterlist_find(parameters, "xsh.xsh_mdark.ref1_ury");
377 ury = cpl_parameter_get_int(p);
378 p = cpl_parameterlist_find(parameters, "xsh.xsh_mdark.noise-clip-niter");
379 iter = cpl_parameter_get_int(p);
380 p = cpl_parameterlist_find(parameters, "xsh.xsh_mdark.noise-lower-rejection");
381 low_rej = cpl_parameter_get_double(p);
382 p = cpl_parameterlist_find(parameters, "xsh.xsh_mdark.noise-higher-rejection");
383 high_rej = cpl_parameter_get_double(p);
384
385 noise_image = xsh_image_search_bad_pixels_via_noise(dataList, iter, low_rej,
386 high_rej, llx, lly, urx, ury);
387 bp_map_noise = cpl_mask_threshold_image_create(noise_image,
389 xsh_free_image(&noise_image);
390 noise_image = cpl_image_new_from_mask(bp_map_noise);
391 cpl_mask_not(bp_map_noise);
392 xsh_bpmap_mask_bad_pixel(noise_image, bp_map_noise, QFLAG_HOT_PIXEL);
393
394//here good pixels are still flagged as '1'. To have proper code, '0',
395//we make a threshold
396 cpl_image_threshold(noise_image, 1.1, DBL_MAX, 0, DBL_MAX);
397
398 plist = cpl_propertylist_new();
399 bp_map_noise_pro_catg = XSH_GET_TAG_FROM_ARM(XSH_BP_MAP_NP, instrument);
400 sprintf(bp_map_noise_name, "%s.fits", bp_map_noise_pro_catg);
401 xsh_pfits_set_pcatg(plist, bp_map_noise_pro_catg);
402 check(cpl_image_save(noise_image,bp_map_noise_name,CPL_BPP_IEEE_FLOAT, plist,CPL_IO_DEFAULT));
403 xsh_add_temporary_file(bp_map_noise_name);
404
405
406 cleanup:
407 xsh_free_mask(&bp_map_noise);
408 xsh_free_propertylist(&plist);
409 xsh_free_image(&noise_image);
410 return nirFrame;
411
412}
413
414static cpl_frame*
415xsh_get_master_dark_opt(cpl_frame* medFrame, cpl_frame* master_bias,
416 cpl_parameterlist* parameters,
417 cpl_frame* crh_frm, cpl_frame* bp_map_noise_frm, xsh_instrument* instrument,
418 const int pre_overscan_corr) {
419 cpl_frame* resFrame = NULL;
420 cpl_frame* rmbias = NULL;
421 if (master_bias != NULL) {
422 xsh_msg("Subtract bias");
423 check(
424 rmbias = xsh_subtract_bias(medFrame,master_bias,instrument,"DARK_",pre_overscan_corr,0));
425
426 xsh_msg( "Generates master dark");
427 check_msg(
428 resFrame=xsh_create_master_dark(rmbias, instrument,parameters, crh_frm,bp_map_noise_frm),
429 "Error in create master dark");
430 } else {
431 check(resFrame=cpl_frame_duplicate(medFrame));
432 }
433
434 cleanup:
435 xsh_free_frame(&rmbias);
436 return resFrame;
437}
438
439static cpl_frame*
441 char* crh_name = NULL;
442 char* crh_pro_catg = NULL;
443 cpl_frame* crh_frm = NULL;
444 char *prefix = NULL;
445
446 crh_name = cpl_sprintf("%s_%s.fits", XSH_CRH_MAP,
448
449 if (crh_ima != NULL) {
450 /* crh_ima is created only if nraws>=3 */
452 crh_frm = xsh_frame_product(crh_name, crh_pro_catg, CPL_FRAME_TYPE_IMAGE,
453 CPL_FRAME_GROUP_PRODUCT, CPL_FRAME_LEVEL_FINAL);
454
455 XSH_PREFIX(prefix, "CRH_MAP", instrument);
456 cpl_image_save(crh_ima, crh_name, CPL_BPP_32_SIGNED, NULL, CPL_IO_DEFAULT);
457 xsh_add_temporary_file(crh_name);
458
459 }
460 cleanup:
461 XSH_FREE(crh_name);
462 XSH_FREE(prefix);
463 return crh_frm;
464}
465
466
467/*----------------------------------------------------------------------------*/
475/*----------------------------------------------------------------------------*/
476static void xsh_mdark(cpl_parameterlist* parameters, cpl_frameset* frameset) {
477
478 const char* recipe_tags[1] = { XSH_DARK };
479 int recipe_tags_size = 1;
480
481 cpl_frameset* raws = NULL;
482 cpl_frameset* calib = NULL;
483 cpl_frame* bpmap = NULL;
484 cpl_frame* master_bias = NULL;
485 cpl_frame* rmbias = NULL;
488 xsh_clipping_param* noise_clipping = NULL;
489 cpl_imagelist * dataList = NULL;
490
491 /* Intermediate frames */
492 cpl_frame * medFrame = NULL;
493 cpl_frame * nirFrame = NULL;
494 cpl_frame * noisyFrame = NULL;
495
496 /* Product frames */
497 cpl_frame * resFrame = NULL;
498
499 cpl_image* crh_ima = NULL;
500 const int mode_or=1;
501
502 cpl_frame* crh_frm = NULL;
503 xsh_pre* pre=NULL;
504 char name[256];
505
506 cpl_propertylist* plist = NULL;
507 char med_frame_tag[256];
508
509
510 cpl_frame* dark_on = NULL;
511 cpl_frame* dark_qc = NULL;
512
513 int pre_overscan_corr = 0;
514 xsh_stack_param* stack_par = NULL;
515
516 char pcatg[256];
517 cpl_propertylist* qc_log = NULL;
518 int nraws;
519 int sz=0;
520
521 /**************************************************************************/
522 /* DFS management */
523 /**************************************************************************/
524 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
525 recipe_tags, recipe_tags_size,
526 RECIPE_ID, XSH_BINARY_VERSION,
528
530
531 /**************************************************************************/
532 /* Recipe frames */
533 /**************************************************************************/
534 XSH_ASSURE_NOT_ILLEGAL((nraws=cpl_frameset_get_size(raws)) >= 1);
536
537
538 /* In UVB and VIS mode only read master bias if exist */
541 }
542
543 sprintf(med_frame_tag, "DARK_REMOVE_CRH_%s",
545
546 /**************************************************************************/
547 /* Recipe parameters */
548 /**************************************************************************/
550 check(
551 pre_overscan_corr = xsh_parameters_get_int( parameters, RECIPE_ID, "pre-overscan-corr"));
552 stack_par = xsh_stack_frames_get(RECIPE_ID, parameters);
553
555 noise_clipping = xsh_parameters_clipping_noise_get(RECIPE_ID, parameters);
556
557 /**************************************************************************/
558 /* Recipe code */
559 /**************************************************************************/
560
561 /* prepare RAW frames in XSH format */
562 check(xsh_prepare(raws, bpmap, master_bias, XSH_DARK, instrument,pre_overscan_corr,CPL_TRUE));
563 /* make sure each input raw frame has the same exp time */
565
566 /* QC master dark: computes frame median with CRH clip (multi) */
567 xsh_msg( "Calling xsh_remove_crh_multiple" );
568 check_msg( medFrame = xsh_remove_crh_multiple( raws,med_frame_tag,stack_par,crh_clipping,
569 instrument,&dataList,&crh_ima,1 ),"Error in xsh_remove_crh" );
570
571 check(crh_frm=xsh_get_crh_frame(crh_ima,instrument));
572
573 /* NIR arm */
575 check(nirFrame=xsh_get_master_dark_nir_via_noise(dataList,medFrame,parameters,noise_clipping,instrument,&noisyFrame));
576 xsh_msg( "Create master dark");
577 /* create master dark XSH consortium way */
578 check_msg(
579 resFrame=xsh_create_master_dark(nirFrame,instrument,parameters,crh_frm,bpmap ),
580 "Error in create master dark");
581 } else {
582 // UVB and VIS : no noise map
583 check(
584 resFrame=xsh_get_master_dark_opt(medFrame,master_bias,parameters,crh_frm,bpmap, instrument,pre_overscan_corr));
585 }
586
587 /* we extract the QC computed by previous algorithm - CRH multi-
588 and inject in the next one for backward
589 * compatibility (to keep same QC as original mdark creation algorithm)
590 */
591 qc_log = xsh_frame_head_extract_qc(resFrame);
592
593 /* end QC */
594
595
596 /* create master dark reflex way */
597 xsh_free_frame(&resFrame);
598 check(resFrame=xsh_create_master_dark2(raws,stack_par,parameters,qc_log,instrument));
599
600
602 /* only in NIR we may generate a noisy BP map, in which case we bitwise-or
603 combine */
604 if(noisyFrame != NULL) {
605 cpl_frame* frm=NULL;
606 cpl_image* bpm=cpl_image_load(cpl_frame_get_filename(noisyFrame),
607 CPL_TYPE_INT,0,0);
608 pre=xsh_pre_load(resFrame,instrument);
609 xsh_badpixelmap_image_coadd(&(pre->qual),bpm,mode_or);
610 frm=xsh_pre_save( pre, cpl_frame_get_filename(resFrame),cpl_frame_get_tag(resFrame), 0);
611 xsh_free_image(&bpm);
612 xsh_pre_free(&pre);
613 xsh_free_frame(&frm);
614 }
615 }
616
618 /* saving products */
619 xsh_msg( "Save products" );
620 check(xsh_add_product_image( resFrame, frameset, parameters,RECIPE_ID, instrument,NULL));
621
622
623
624 /* save 1st frame in PRE format for QC */
625 dark_on = cpl_frameset_get_frame(raws, 0);
626 sprintf(pcatg, "DARK_ON");
627 sprintf(name, "%s.fits", pcatg);
628 xsh_add_product_image(dark_on,frameset,parameters,RECIPE_ID,instrument,pcatg);
629
630
631 /* save last frame in PRE format for QC */
632 sz=cpl_frameset_get_size(raws);
633 dark_qc = cpl_frameset_get_frame(raws, sz-1);
634 sprintf(pcatg, "DARK_QC");
635 sprintf(name, "%s.fits", pcatg);
636 xsh_add_product_image(dark_qc,frameset,parameters,RECIPE_ID,instrument,pcatg);
637
638
639 cleanup: xsh_end(RECIPE_ID, frameset, parameters);
641 XSH_FREE(noise_clipping);
642 XSH_FREE(stack_par);
644 xsh_free_frameset(&raws);
645 xsh_free_frameset(&calib);
646
647 xsh_free_imagelist(&dataList);
648 xsh_free_frame(&medFrame);
649 xsh_free_frame(&nirFrame);
650 xsh_free_frame(&resFrame);
651 xsh_free_frame(&rmbias);
652 xsh_free_frame(&crh_frm);
653 xsh_free_frame(&bpmap);
654 xsh_free_frame(&noisyFrame);
655 xsh_free_image(&crh_ima);
656 xsh_free_propertylist(&plist);
657 xsh_free_propertylist(&qc_log);
658
659 return;
660}
661
cpl_frame * xsh_create_master_dark(cpl_frame *medFrame, xsh_instrument *instr, cpl_parameterlist *parameters, cpl_frame *crh_frm, cpl_frame *bpm_frm)
cpl_frame * xsh_create_master_dark2(cpl_frameset *raws, xsh_stack_param *stack_param, cpl_parameterlist *params, cpl_propertylist *qc_log, xsh_instrument *instr)
static xsh_instrument * instrument
static xsh_clipping_param crh_clipping
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_badpixelmap_fill_bp_pattern_holes(cpl_frame *frm)
cpl_frame * xsh_compute_noise_map(cpl_imagelist *dataList, cpl_frame *medFrame, xsh_clipping_param *noise_clipping, xsh_instrument *instr, cpl_frame **noisyFrame)
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
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.
void xsh_prepare(cpl_frameset *frames, cpl_frame *bpmap, cpl_frame *mbias, const char *prefix, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
This function transform RAW frames dataset in PRE frames dataset attaching the default bad pixel map ...
Definition: xsh_prepare.c:122
#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 xsh_error_dump(level)
Definition: xsh_error.h:92
#define check_msg(COMMAND,...)
Definition: xsh_error.h:62
#define xsh_error_reset()
Definition: xsh_error.h:87
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
XSH_ARM xsh_instrument_get_arm(xsh_instrument *i)
Get an arm on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
#define RECIPE_CONTACT
Definition: xsh_mdark.c:73
static int xsh_mdark_create(cpl_plugin *)
Setup the recipe options.
Definition: xsh_mdark.c:170
static int xsh_mdark_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
Definition: xsh_mdark.c:291
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
Definition: xsh_mdark.c:128
static char xsh_mdark_description_short[]
Definition: xsh_mdark.c:93
static int xsh_mdark_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
Definition: xsh_mdark.c:257
static cpl_frame * xsh_get_master_dark_opt(cpl_frame *medFrame, cpl_frame *master_bias, cpl_parameterlist *parameters, cpl_frame *crh_frm, cpl_frame *bp_map_noise_frm, xsh_instrument *instrument, const int pre_overscan_corr)
Definition: xsh_mdark.c:415
static cpl_frame * xsh_get_crh_frame(cpl_image *crh_ima, xsh_instrument *instrument)
Definition: xsh_mdark.c:440
static char xsh_mdark_description[]
Definition: xsh_mdark.c:96
static void xsh_mdark(cpl_parameterlist *, cpl_frameset *)
Interpret the command line options and execute the data processing.
Definition: xsh_mdark.c:476
static cpl_frame * xsh_get_master_dark_nir_via_noise(cpl_imagelist *dataList, cpl_frame *medFrame, cpl_parameterlist *parameters, xsh_clipping_param *noise_clipping, xsh_instrument *instrument, cpl_frame **noisyFrame)
Definition: xsh_mdark.c:342
#define RECIPE_ID
Definition: xsh_mdark.c:71
#define RECIPE_AUTHOR
Definition: xsh_mdark.c:72
static cpl_error_code xsh_params_set_defaults(cpl_parameterlist *pars, xsh_instrument *inst)
Definition: xsh_mdark.c:319
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
#define xsh_msg_dbg_low(...)
Definition: xsh_msg.h:48
void xsh_pfits_set_pcatg(cpl_propertylist *plist, const char *value)
Write the PCATG value.
Definition: xsh_pfits.c:1008
cpl_frame * xsh_remove_crh_multiple(cpl_frameset *rawFrames, const char *name, xsh_stack_param *stack_param, xsh_clipping_param *crh_clipping, xsh_instrument *inst, cpl_imagelist **, cpl_image **, const int save_tmp)
cpl_frame * xsh_subtract_bias(cpl_frame *frame, cpl_frame *bias, xsh_instrument *instr, const char *type, const int pre_overscan_corr, const int save_tmp)
Subtract the master bias frame from PRE frame.
Definition: xsh_subtract.c:120
void xsh_free_parameterlist(cpl_parameterlist **p)
Deallocate a parameter list and set the pointer to NULL.
Definition: xsh_utils.c:2224
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_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
Definition: xsh_utils.c:2254
void xsh_free_mask(cpl_mask **m)
Deallocate an image mask and set the pointer to NULL.
Definition: xsh_utils.c:2149
const char * xsh_get_license(void)
Get the pipeline copyright and license.
Definition: xsh_utils.c:1193
void xsh_init(void)
Reset library state.
Definition: xsh_utils.c:1160
cpl_error_code xsh_begin(cpl_frameset *frames, const cpl_parameterlist *parameters, xsh_instrument **instrument, cpl_frameset **raws, cpl_frameset **calib, const char *tag_list[], int tag_list_size, const char *recipe_id, unsigned int binary_version, const char *short_descr)
Recipe initialization.
Definition: xsh_utils.c:1244
void xsh_free_propertylist(cpl_propertylist **p)
Deallocate a property list and set the pointer to NULL.
Definition: xsh_utils.c:2179
cpl_error_code xsh_end(const char *recipe_id, cpl_frameset *frames, cpl_parameterlist *parameters)
Recipe termination.
Definition: xsh_utils.c:1519
void xsh_free_imagelist(cpl_imagelist **i)
Deallocate an image list and set the pointer to NULL.
Definition: xsh_utils.c:2164
void xsh_add_temporary_file(const char *name)
Add temporary file to temprary files list.
Definition: xsh_utils.c:1432
cpl_image * qual
Definition: xsh_data_pre.h:71
#define QFLAG_HOT_PIXEL
@ XSH_ARM_NIR
int lly
Definition: xsh_detmon_lg.c:86
int llx
Definition: xsh_detmon_lg.c:85
int urx
Definition: xsh_detmon_lg.c:87
int ury
Definition: xsh_detmon_lg.c:88
void xsh_add_product_image(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instrument, const char *final_prefix)
Definition: xsh_dfs.c:2965
cpl_propertylist * xsh_frame_head_extract_qc(cpl_frame *frm)
Definition: xsh_dfs.c:4401
cpl_frame * xsh_frame_product(const char *fname, const char *tag, cpl_frame_type type, cpl_frame_group group, cpl_frame_level level)
Creates a frame with given characteristics.
Definition: xsh_dfs.c:930
cpl_frame * xsh_find_frame_with_tag(cpl_frameset *frames, const char *tag, xsh_instrument *instr)
Find frame with a given tag.
Definition: xsh_dfs.c:3347
cpl_error_code xsh_frameset_check_uniform_exptime(cpl_frameset *raws, xsh_instrument *inst)
Definition: xsh_dfs.c:5119
#define XSH_MASTER_BIAS
Definition: xsh_dfs.h:549
#define XSH_BP_MAP_NP
Definition: xsh_dfs.h:343
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
Definition: xsh_dfs.h:1548
#define XSH_DARK
Definition: xsh_dfs.h:220
#define XSH_CRH_MAP
Definition: xsh_dfs.h:298
cpl_frame * xsh_check_load_master_bpmap(cpl_frameset *calib, xsh_instrument *inst, const char *rec_id)
Definition: xsh_drl_check.c:51
cpl_parameter * xsh_parameters_find(cpl_parameterlist *list, const char *recipe_id, const char *name)
find a parameter
void xsh_parameters_pre_overscan(const char *recipe_id, cpl_parameterlist *plist)
void xsh_parameters_new_boolean(cpl_parameterlist *list, const char *recipe_id, const char *name, int value, const char *comment)
void xsh_parameters_stack_create(const char *recipe_id, cpl_parameterlist *list, xsh_stack_param sp)
create the RON determination parameters in a parameters list
xsh_stack_param * xsh_stack_frames_get(const char *recipe_id, cpl_parameterlist *list)
get the detect arclines parameters in a parameters list
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_new_double(cpl_parameterlist *list, const char *recipe_id, const char *name, double value, const char *comment)
void xsh_parameters_clipping_crh_create(const char *recipe_id, cpl_parameterlist *list, xsh_clipping_param p)
create the crh clipping parameters in a parameters list
void xsh_parameters_clipping_noise_create(const char *recipe_id, cpl_parameterlist *list, xsh_clipping_param noise_param)
create the crh noise clipping parameters in a parameters list
void xsh_parameters_fpn_create(const char *recipe_id, cpl_parameterlist *list, xsh_fpn_param p)
create the FPN parameters in a parameters list
void xsh_parameters_ron_dark_create(const char *recipe_id, cpl_parameterlist *list, xsh_ron_dark_param p)
create the RON determination parameters in a parameters list
void xsh_parameters_ref1_create(const char *recipe_id, cpl_parameterlist *list, xsh_ref_param p)
create the reference region definition parameters in a parameters list
int xsh_parameters_get_int(const cpl_parameterlist *list, const char *recipe_id, const char *name)
xsh_clipping_param * xsh_parameters_clipping_noise_get(const char *recipe_id, cpl_parameterlist *list)
get the noise clipping parameters in a parameters list
xsh_clipping_param * xsh_parameters_clipping_crh_get(const char *recipe_id, cpl_parameterlist *list)
get the crh clipping parameters in a parameters list
void xsh_parameters_generic(const char *recipe_id, cpl_parameterlist *plist)
cpl_error_code xsh_recipe_params_check(cpl_parameterlist *parameters, xsh_instrument *instrument, const char *rec_id)
#define DECODE_BP_FLAG_DEF
#define XSH_FREE(POINTER)
Definition: xsh_utils.h:92
#define XSH_PREFIX(prefix, name, instr)
Definition: xsh_utils.h:96
cpl_image * xsh_image_search_bad_pixels_via_noise(cpl_imagelist *darks, float thresh_sigma_factor, float low_threshold, float high_threshold, int llx, int lly, int urx, int ury)
search bad pixels