00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include <config.h>
00028 #endif
00029
00030
00038
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include <xsh_error.h>
00050
00051 #include <xsh_utils.h>
00052 #include <xsh_utils_image.h>
00053 #include <xsh_msg.h>
00054
00055 #include <xsh_dfs.h>
00056
00057 #include <xsh_drl.h>
00058
00059 #include <xsh_pfits.h>
00060
00061 #include <cpl.h>
00062
00063 #include <xsh_drl_check.h>
00064
00065
00066
00067
00068
00069 #define RECIPE_ID "xsh_mdark"
00070 #define RECIPE_AUTHOR "P.Goldoni, L.Guglielmi, R. Haigron, F. Royer, A. Modigliani"
00071 #define RECIPE_CONTACT "amodigli@eso.org"
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 static int xsh_mdark_create(cpl_plugin *);
00082 static int xsh_mdark_exec(cpl_plugin *);
00083 static int xsh_mdark_destroy(cpl_plugin *);
00084
00085
00086 static void xsh_mdark(cpl_parameterlist *, cpl_frameset *);
00087
00088
00089
00090
00091 static char xsh_mdark_description_short[] =
00092 "Create the master dark frame";
00093
00094 static char xsh_mdark_description[] =
00095 "This recipe creates a master dark frame\n\
00096 Input Frames : \n\
00097 - A set of n RAW frames (Format=RAW, n >=3, Tag = DARK_arm)\n\
00098 - [UVB,VIS] A master bias frame (Format=PRE, Tag = MASTER_BIAS_arm)\n\
00099 - [OPTIONAL] A badpixel map (Format=QUP, Tag = MASTER_BP_MAP_arm)\n\
00100 - [OPTIONAL] A map of non linear pixel (Format = QUP,RAW, Tag = BP_MAP_NL_arm)\n\
00101 Products : \n\
00102 - A map frame containing CRHs (PRO.CATG = CRH_MAP_arm)\n\
00103 - A master dark frame (Format=PRE, PRO.CATG = MASTER_DARK_arm)\n\
00104 - [VIS && bp-output=yes] A badpixel map (Format=QUP, \n\
00105 PRO.CATG = MASTER_BP_MAP_arm)\n\
00106 - If an input master bad pixel map or a map of non linear pixels is provided \n\
00107 A master bad pixel map image, PRO.CATG = MASTER_BP_MAP_arm\n";
00108
00109
00110
00111
00112
00121
00122
00123 int cpl_plugin_get_info(cpl_pluginlist *list) {
00124 cpl_recipe *recipe = NULL;
00125 cpl_plugin *plugin = NULL;
00126
00127 recipe = cpl_calloc(1, sizeof(*recipe));
00128 if ( recipe == NULL ){
00129 return -1;
00130 }
00131
00132 plugin = &recipe->interface ;
00133
00134 cpl_plugin_init(plugin,
00135 CPL_PLUGIN_API,
00136 XSH_BINARY_VERSION,
00137 CPL_PLUGIN_TYPE_RECIPE,
00138 RECIPE_ID,
00139 xsh_mdark_description_short,
00140 xsh_mdark_description,
00141 RECIPE_AUTHOR,
00142 RECIPE_CONTACT,
00143 xsh_get_license(),
00144 xsh_mdark_create,
00145 xsh_mdark_exec,
00146 xsh_mdark_destroy);
00147
00148 cpl_pluginlist_append(list, plugin);
00149
00150 return (cpl_error_get_code() != CPL_ERROR_NONE);
00151 }
00152
00153
00163
00164
00165 static int xsh_mdark_create(cpl_plugin *plugin){
00166 cpl_recipe *recipe = NULL;
00167 xsh_clipping_param crh_clip_param = {9.0, 3, 0.7, 0, 0.3};
00168 xsh_clipping_param noise_clip_param = {9.0, 5, 0.7, 0, 0.3};
00169 xsh_fpn_param fpn_param = {-1,-1,-1,-1,2,1000};
00170 xsh_ref_param ref_param = {-1,-1,-1,-1};
00171 xsh_ron_dark_param ron_param = {-1,-1,-1,-1,4,100};
00172
00173 xsh_init();
00174
00175
00176 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00177
00178
00179 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00180 CPL_ERROR_TYPE_MISMATCH,
00181 "Plugin is not a recipe");
00182
00183 recipe = (cpl_recipe *)plugin;
00184
00185
00186 recipe->parameters = cpl_parameterlist_new();
00187 assure( recipe->parameters != NULL,
00188 CPL_ERROR_ILLEGAL_OUTPUT,
00189 "Memory allocation failed!");
00190
00191
00192 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
00193
00194 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
00195
00196
00197 check(xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
00198 "bp-output", false,
00199 "Flag indicating whether the noise bad pixel map is to be computed"));
00200
00201
00202 check(xsh_parameters_clipping_crh_create(RECIPE_ID,recipe->parameters,
00203 crh_clip_param));
00204
00205
00206 check(xsh_parameters_clipping_noise_create(RECIPE_ID,
00207 recipe->parameters,
00208 noise_clip_param));
00209
00210 check(xsh_parameters_new_double( recipe->parameters,RECIPE_ID,
00211 "noise-lower-rejection", 10.,
00212 "Lower rejection percentile to flag bad pixels via noise"));
00213
00214 check(xsh_parameters_new_double( recipe->parameters, RECIPE_ID,
00215 "noise-higher-rejection", 10.,
00216 "Upper rejection percentile to flag bad pixels via noise"));
00217
00218
00219 check(xsh_parameters_ref1_create(RECIPE_ID,recipe->parameters,
00220 ref_param));
00221
00222
00223 check(xsh_parameters_ron_dark_create(RECIPE_ID,recipe->parameters,
00224 ron_param));
00225
00226 check(xsh_parameters_fpn_create(RECIPE_ID,recipe->parameters,
00227 fpn_param));
00228
00229
00230 cleanup:
00231 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
00232 xsh_error_dump(CPL_MSG_ERROR);
00233 return 1;
00234 }
00235 else {
00236 return 0;
00237 }
00238 }
00239
00240
00246
00247
00248 static int xsh_mdark_exec(cpl_plugin *plugin) {
00249 cpl_recipe *recipe = NULL;
00250
00251
00252
00253 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00254
00255
00256 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00257 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00258
00259 recipe = (cpl_recipe *)plugin;
00260
00261
00262 xsh_mdark(recipe->parameters, recipe->frames);
00263
00264 cleanup:
00265 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
00266 xsh_error_dump(CPL_MSG_ERROR);
00267 xsh_error_reset();
00268 return 1;
00269 }
00270 else {
00271 return 0;
00272 }
00273 }
00274
00275
00281
00282 static int xsh_mdark_destroy(cpl_plugin *plugin)
00283 {
00284 cpl_recipe *recipe = NULL;
00285
00286
00287 xsh_error_reset();
00288
00289 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00290
00291
00292 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00293 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00294 recipe = (cpl_recipe *)plugin;
00295
00296 xsh_free_parameterlist(&recipe->parameters);
00297
00298 cleanup:
00299 if (cpl_error_get_code() != CPL_ERROR_NONE)
00300 {
00301 return 1;
00302 }
00303 else
00304 {
00305 return 0;
00306 }
00307 }
00308
00309 static cpl_error_code
00310 xsh_params_set_defaults(cpl_parameterlist* pars,
00311 xsh_instrument* inst)
00312 {
00313 cpl_parameter* p=NULL;
00314
00315 if (xsh_instrument_get_arm(inst) == XSH_ARM_NIR){
00316 check(p=xsh_parameters_find(pars,RECIPE_ID,"crh-clip-kappa"));
00317 if(xsh_parameter_get_default_flag(p) == 0) {
00318
00319 cpl_parameter_set_double(p,11.);
00320 }
00321 }
00322
00323
00324 cleanup:
00325
00326 return cpl_error_get_code();
00327
00328 }
00329
00330
00331
00339
00340 static void xsh_mdark(cpl_parameterlist* parameters, cpl_frameset* frameset){
00341
00342 const char* recipe_tags[1] = {XSH_DARK};
00343 int recipe_tags_size = 1;
00344
00345 cpl_frameset* raws = NULL;
00346 cpl_frameset* calib = NULL;
00347 cpl_frame* bpmap = NULL;
00348 cpl_frame* master_bias = NULL;
00349 cpl_frame* rmbias = NULL;
00350 xsh_instrument* instrument = NULL;
00351 xsh_clipping_param* crh_clipping = NULL;
00352 xsh_clipping_param* noise_clipping = NULL;
00353 int bp_output = 0;
00354 cpl_imagelist * dataList = NULL;
00355 cpl_image* noise_image=NULL;
00356 cpl_parameter* p=NULL;
00357
00358
00359 cpl_frame * medFrame = NULL ;
00360 cpl_frame * nirFrame = NULL ;
00361 #if defined(PICKUP_NOISE_HOT_PIXEL_MAP)
00362 cpl_frame * noisyFrame = NULL ;
00363 #endif
00364
00365 cpl_frame * resFrame = NULL ;
00366 cpl_frame * bpmapFrame = NULL ;
00367
00368 char *prefix = NULL ;
00369 cpl_image* crh_ima=NULL;
00370 char* crh_name=NULL;
00371 const char* drs_name=NULL;
00372
00373 cpl_frame* crh_frm=NULL;
00374 const char* crh_pro_catg=NULL;
00375 const char* pro_catg=NULL;
00376 char name[80];
00377 int binx=0;
00378 int biny=0;
00379 cpl_frame* dark_frm=NULL;
00380 cpl_propertylist* plist=NULL;
00381 char med_frame_tag[256];
00382 const char* bp_map_noise_pro_catg=NULL;
00383 char bp_map_noise_name[256];
00384 cpl_frame* bp_map_noise_frm=NULL;
00385 int llx=0;
00386 int lly=0;
00387 int urx=0;
00388 int ury=0;
00389 int iter=0;
00390 double low_rej=0;
00391 double high_rej=0;
00392 cpl_mask* bp_map_noise=NULL;
00393 int nraws=0;
00394 cpl_frame* frm_dark=NULL;
00395 cpl_frame* frm_drs=NULL;
00396 cpl_table* tbl_drs=NULL;
00397 cpl_parameterlist* drs_params=NULL;
00398 int pre_overscan_corr=0;
00399 cpl_frame* coadd_bp_map=NULL;
00400 cpl_image* ima=NULL;
00401 cpl_propertylist* head=NULL;
00402
00403
00404
00405 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
00406 recipe_tags, recipe_tags_size,
00407 RECIPE_ID, XSH_BINARY_VERSION,
00408 xsh_mdark_description_short ) ) ;
00409
00410
00411
00412
00413
00414
00415
00416
00417 XSH_ASSURE_NOT_ILLEGAL((nraws=cpl_frameset_get_size(raws)) >= 1);
00418
00419 check(bpmap=xsh_check_load_master_bpmap(calib,instrument));
00420
00421 if((frm_drs=xsh_find_frame_with_tag(calib,XSH_DRS_MDARK,instrument))==NULL) {
00422 xsh_msg_warning("Frame %s not provided. Skip QC data reduction",
00423 XSH_DRS_MDARK);
00424 frm_drs=NULL;
00425 } else {
00426 check(drs_name=cpl_frame_get_filename(frm_drs));
00427 check(tbl_drs=cpl_table_load(drs_name,1,0));
00428 check(drs_params=xsh_parameters_create_from_drs_table(tbl_drs,RECIPE_ID));
00429 }
00430 xsh_free_table(&tbl_drs);
00431
00432
00433 if ( xsh_instrument_get_arm(instrument) != XSH_ARM_NIR){
00434
00435 if((master_bias = xsh_find_frame_with_tag(calib,XSH_MASTER_BIAS,
00436 instrument)) == NULL) {
00437 xsh_msg_error("%s_%s is required input for error computation",
00438 XSH_MASTER_BIAS,xsh_instrument_arm_tostring (instrument));
00439 goto cleanup;
00440 }
00441 check(dark_frm=cpl_frameset_get_first(raws));
00442 check(plist=cpl_propertylist_load(cpl_frame_get_filename(dark_frm),0));
00443 check(binx=xsh_pfits_get_binx(plist));
00444 check(biny=xsh_pfits_get_biny(plist));
00445 xsh_free_propertylist(&plist);
00446
00447 sprintf(med_frame_tag,"DARK_REMOVE_CRH_%s",
00448 xsh_instrument_arm_tostring (instrument));
00449
00450
00451
00452 }
00453
00454 else {
00455 sprintf(med_frame_tag,"DARK_REMOVE_CRH_%s",
00456 xsh_instrument_arm_tostring (instrument));
00457
00458
00459
00460
00461
00462
00463
00464
00465 }
00466
00467
00468
00469
00470
00471 check(xsh_params_set_defaults(parameters,instrument));
00472 check( crh_clipping = xsh_parameters_clipping_crh_get(RECIPE_ID,
00473 parameters));
00474 check( noise_clipping = xsh_parameters_clipping_noise_get(RECIPE_ID,
00475 parameters));
00476 check( bp_output = xsh_parameters_get_boolean( parameters,RECIPE_ID,
00477 "bp-output"));
00478
00479 check( pre_overscan_corr = xsh_parameters_get_int( parameters, RECIPE_ID,
00480 "pre-overscan-corr"));
00481
00482
00483
00484
00485
00486
00487 check(xsh_prepare(raws, bpmap, master_bias, XSH_DARK, instrument,pre_overscan_corr));
00488
00489
00490 xsh_msg( "Calling xsh_remove_crh_multiple" ) ;
00491 xsh_msg_dbg_medium( " CRH parameters: Sigma %f, Niteration %d, Fraction %f",
00492 crh_clipping->sigma, crh_clipping->niter, crh_clipping->frac ) ;
00493
00494 check(crh_name=cpl_sprintf("crh_map_dark_%s.fits",
00495 xsh_instrument_arm_tostring( instrument))) ;
00496 cpl_frameset_dump(raws,stdout);
00497 check_msg( medFrame = xsh_remove_crh_multiple( raws,
00498 med_frame_tag,
00499 crh_clipping,
00500 instrument,
00501 &dataList,
00502 &crh_ima ),
00503 "Error in xsh_remove_crh" ) ;
00504
00505 if(crh_ima!=NULL) {
00506
00507 check(crh_pro_catg=XSH_GET_TAG_FROM_ARM(XSH_CRH_MAP,instrument));
00508 check(crh_frm=xsh_frame_product(crh_name,crh_pro_catg,
00509 CPL_FRAME_TYPE_IMAGE,
00510 CPL_FRAME_GROUP_PRODUCT,
00511 CPL_FRAME_LEVEL_FINAL));
00512
00513 XSH_PREFIX(prefix,"CRH_MAP",instrument);
00514 check(cpl_image_save(crh_ima,crh_name,CPL_BPP_32_SIGNED,NULL,CPL_IO_DEFAULT));
00515
00516 }
00517
00518
00519 xsh_msg_dbg_low( "MedFrame created \"%s\"", cpl_frame_get_filename( medFrame ) ) ;
00520 xsh_msg( "MedFrame created \"%s\"", cpl_frame_get_filename( medFrame ) ) ;
00521
00522
00523
00524 if ( xsh_instrument_get_arm(instrument) == XSH_ARM_NIR ) {
00525 if (bp_output) {
00526 xsh_msg_dbg_low("Noise parameters: Sigma %lf, Niteration %d, \
00527 Fraction %lf, Diff %lf",
00528 noise_clipping->sigma, noise_clipping->niter,
00529 noise_clipping->frac, noise_clipping->diff ) ;
00530
00531
00532 #if defined(PICKUP_NOISE_HOT_PIXEL_MAP)
00533 check( nirFrame = xsh_compute_noise_map( dataList, medFrame,
00534 noise_clipping,instrument,
00535 &noisyFrame ));
00536
00537 #else
00538 check( nirFrame = xsh_compute_noise_map( dataList, medFrame,
00539 noise_clipping,instrument));
00540 #endif
00541
00542 check(p = cpl_parameterlist_find(parameters,"xsh.xsh_mdark.ref1_llx"));
00543 check(llx=cpl_parameter_get_int(p));
00544 check(p = cpl_parameterlist_find(parameters,"xsh.xsh_mdark.ref1_lly"));
00545 check(lly=cpl_parameter_get_int(p));
00546 check(p = cpl_parameterlist_find(parameters,"xsh.xsh_mdark.ref1_urx"));
00547 check(urx=cpl_parameter_get_int(p));
00548 check(p = cpl_parameterlist_find(parameters,"xsh.xsh_mdark.ref1_ury"));
00549 check(ury=cpl_parameter_get_int(p));
00550 check(p = cpl_parameterlist_find(parameters,
00551 "xsh.xsh_mdark.noise-clip-niter"));
00552 check(iter=cpl_parameter_get_int(p));
00553 check(p = cpl_parameterlist_find(parameters,
00554 "xsh.xsh_mdark.noise-lower-rejection"));
00555 check(low_rej=cpl_parameter_get_double(p));
00556 check(p = cpl_parameterlist_find(parameters,
00557 "xsh.xsh_mdark.noise-higher-rejection"));
00558 check(high_rej=cpl_parameter_get_double(p));
00559
00560 check(noise_image=xsh_image_search_bad_pixels_via_noise(dataList,
00561 iter,
00562 low_rej,high_rej,
00563 llx,lly,
00564 urx,ury));
00565
00566 check(bp_map_noise=cpl_mask_threshold_image_create(noise_image,
00567 QFLAG_HOT_PIXEL-1,
00568 QFLAG_HOT_PIXEL+1));
00569
00570 xsh_free_image(&noise_image);
00571 check(noise_image=cpl_image_new_from_mask(bp_map_noise));
00572 cpl_mask_not(bp_map_noise);
00573
00574 xsh_bpmap_mask_bad_pixel(noise_image,bp_map_noise,QFLAG_HOT_PIXEL);
00575
00576
00577
00578 cpl_image_threshold(noise_image,1.1,DBL_MAX,0,DBL_MAX);
00579 xsh_free_mask(&bp_map_noise);
00580 check(plist=cpl_propertylist_new());
00581 check(bp_map_noise_pro_catg=XSH_GET_TAG_FROM_ARM(XSH_BP_MAP_NP,
00582 instrument));
00583 sprintf(bp_map_noise_name,"%s.fits",bp_map_noise_pro_catg);
00584 check(xsh_pfits_set_pcatg(plist,bp_map_noise_pro_catg));
00585 check(cpl_image_save(noise_image,bp_map_noise_name,CPL_BPP_IEEE_FLOAT,
00586 plist,CPL_IO_DEFAULT));
00587 xsh_msg("saving noise map");
00588 check(bp_map_noise_frm=xsh_frame_product(bp_map_noise_name,
00589 bp_map_noise_pro_catg,
00590 CPL_FRAME_TYPE_IMAGE,
00591 CPL_FRAME_GROUP_PRODUCT,
00592 CPL_FRAME_LEVEL_FINAL));
00593 xsh_free_propertylist(&plist);
00594 }
00595 else {
00596 nirFrame = medFrame;
00597 medFrame = NULL;
00598 }
00599 xsh_msg( "Create master dark" ) ;
00600 check_msg(resFrame=xsh_create_master_dark(nirFrame,instrument,
00601 parameters,drs_params,
00602 crh_frm,bp_map_noise_frm ),
00603 "Error in create master dark" ) ;
00604
00605 }
00606 else {
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 if(master_bias != NULL) {
00623 xsh_msg("Subtract bias");
00624 check(rmbias = xsh_subtract_bias(medFrame,master_bias,instrument,"DARK_",pre_overscan_corr));
00625
00626 xsh_msg( "Generates master dark" ) ;
00627 check_msg(resFrame=xsh_create_master_dark(rmbias, instrument,
00628 parameters,drs_params,
00629 crh_frm,bp_map_noise_frm),
00630 "Error in create master dark" ) ;
00631 } else {
00632 check(resFrame=cpl_frame_duplicate(medFrame));
00633 }
00634 }
00635
00636
00637 xsh_msg( "Save products" ) ;
00638 check( xsh_add_product_pre( resFrame, frameset, parameters,RECIPE_ID,
00639 instrument));
00640
00641
00642 if(crh_ima!=NULL) {
00643
00644 check(xsh_add_product_image(crh_frm, frameset,parameters,
00645 RECIPE_ID, instrument, prefix ));
00646 xsh_add_temporary_file(crh_name);
00647 }
00648
00649
00650 check(bpmapFrame = xsh_create_master_bpmap(resFrame, instrument));
00651
00652 XSH_ASSURE_NOT_NULL(bpmapFrame);
00653
00654 if(bp_map_noise_frm!=NULL) {
00655 check( xsh_add_product_image(bp_map_noise_frm, frameset, parameters,
00656 RECIPE_ID, instrument,
00657 cpl_frame_get_filename( bp_map_noise_frm)));
00658
00659 xsh_msg( "Coadd bp map noise frames: %s and %s",
00660 cpl_frame_get_filename(bpmapFrame),
00661 cpl_frame_get_filename(bp_map_noise_frm) ) ;
00662 check(xsh_badpixelmap_coadd(bpmapFrame,bp_map_noise_frm));
00663 }
00664 XSH_PREFIX(prefix, XSH_MASTER_BP_MAP, instrument);
00665 xsh_add_temporary_file(cpl_frame_get_filename(bpmapFrame));
00666 check( xsh_add_product_bpmap( bpmapFrame, frameset, parameters,
00667 RECIPE_ID, instrument, prefix ));
00668
00669 frm_dark=cpl_frameset_get_frame(raws,0);
00670 check(pro_catg=XSH_GET_TAG_FROM_ARM(XSH_DARK,instrument));
00671 sprintf(name,"%s",pro_catg);
00672 check( xsh_add_product_image(frm_dark, frameset, parameters,
00673 RECIPE_ID, instrument, name ));
00674
00675
00676 if ( xsh_instrument_get_arm(instrument) == XSH_ARM_NIR ) {
00677 if(bp_output) {
00678 #if defined(PICKUP_NOISE_HOT_PIXEL_MAP)
00679 XSH_PREFIX(prefix, XSH_BP_MAP_PN, instrument ) ;
00680 check( xsh_add_product_image( noisyFrame, frameset, parameters,
00681 RECIPE_ID, instrument, prefix ));
00682 xsh_add_temporary_file(cpl_frame_get_filename(noisyFrame));
00683 #else
00684 check( xsh_add_product_pre( nirFrame, frameset, parameters,
00685 RECIPE_ID, instrument));
00686 #endif
00687 }
00688 }
00689
00690 if(bpmap!=NULL) {
00691 if(bp_map_noise_frm!=NULL) {
00692 xsh_msg( "Coadd noise and input bp map frames" ) ;
00693 check(coadd_bp_map=cpl_frame_duplicate(bpmap));
00694 sprintf(name,cpl_frame_get_filename(bpmap));
00695 check(ima=cpl_image_load(name,CPL_TYPE_FLOAT,0,0));
00696 check(head=cpl_propertylist_load(name,0));
00697 check(pro_catg=XSH_GET_TAG_FROM_ARM(XSH_MASTER_BP_MAP,instrument));
00698 sprintf(name,"%s.fits",pro_catg);
00699 check(cpl_image_save(ima,name,CPL_BPP_IEEE_FLOAT,head,CPL_IO_DEFAULT));
00700 check(cpl_frame_set_filename(coadd_bp_map,name));
00701 check(cpl_frame_set_tag(coadd_bp_map,pro_catg));
00702 check(xsh_badpixelmap_coadd(coadd_bp_map,bp_map_noise_frm));
00703 check( xsh_add_product_bpmap(coadd_bp_map, frameset, parameters,
00704 RECIPE_ID, instrument, pro_catg ));
00705 xsh_free_frame(&coadd_bp_map);
00706 xsh_free_image(&ima);
00707 xsh_free_propertylist(&head);
00708 }
00709 }
00710
00711
00712 cleanup:
00713 xsh_end( RECIPE_ID, frameset, parameters );
00714 XSH_FREE(crh_clipping);
00715 XSH_FREE(noise_clipping);
00716 xsh_instrument_free(&instrument );
00717 xsh_free_frameset(&raws);
00718 xsh_free_frameset(&calib);
00719 xsh_free_imagelist( &dataList );
00720 xsh_free_frame( &medFrame ) ;
00721 xsh_free_frame( &nirFrame ) ;
00722 xsh_free_frame( &resFrame ) ;
00723 xsh_free_frame(&rmbias);
00724 xsh_free_frame(&bpmapFrame);
00725 xsh_free_frame(&crh_frm);
00726 xsh_free_image(&crh_ima);
00727 xsh_free_propertylist(&plist);
00728 xsh_free_table(&tbl_drs);
00729 xsh_free_parameterlist(&drs_params);
00730 XSH_FREE(prefix) ;
00731 XSH_FREE(crh_name) ;
00732
00733 return;
00734 }
00735