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
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032
00040
00043
00044
00045
00046
00047
00048
00049
00050
00051 #include <xsh_error.h>
00052
00053 #include <xsh_utils.h>
00054 #include <xsh_msg.h>
00055 #include <xsh_model_utils.h>
00056 #include <xsh_utils_scired_slit.h>
00057 #include <xsh_data_instrument.h>
00058 #include <xsh_data_spectrum1D.h>
00059
00060 #include <xsh_dfs.h>
00061 #include <xsh_pfits.h>
00062
00063 #include <xsh_drl.h>
00064 #include <xsh_drl_check.h>
00065
00066 #include <cpl.h>
00067
00068
00069
00070
00071
00072
00073 #define RECIPE_ID "xsh_scired_slit_nod"
00074 #define RECIPE_AUTHOR "P.Goldoni, L.Guglielmi, R. Haigron, F. Royer"
00075 #define RECIPE_CONTACT "amodigli@eso.org"
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 static int xsh_scired_slit_nod_create(cpl_plugin *);
00086 static int xsh_scired_slit_nod_exec(cpl_plugin *);
00087 static int xsh_scired_slit_nod_destroy(cpl_plugin *);
00088
00089
00090 static void xsh_scired_slit_nod(cpl_parameterlist *, cpl_frameset *);
00091
00092
00093
00094
00095 static char xsh_scired_slit_nod_description_short[] =
00096 "Reduce science frames in SLIT configuration and nod mode";
00097
00098 static char xsh_scired_slit_nod_description[] =
00099 "This recipe reduces science exposure in SLIT configuration and NOD mode\n\
00100 Input Frames : \n\
00101 - A set of n Science frames ( n even ), \
00102 Tag = OBJECT_SLIT_NOD_arm\n\
00103 - Spectral format table (Tag = SPECTRAL_FORMAT_TAB_arm)\n\
00104 - [UVB,VIS] A master bias frame (Tag = MASTER_BIAS_arm)\n\
00105 - A master flat frame (Tag = MASTER_FLAT_SLIT_arm)\n\
00106 - An order table frame(Tag = ORDER_TABLE_EDGES_SLIT_arm)\n\
00107 - [poly mode] A wave solution frame(Tag = WAVE_TAB_2D_arm)\n\
00108 - [poly mode] A wave map frame(Tag = WAVE_MAP_arm)\n\
00109 - [poly mode] A disp table frame(Tag = DISP_TAB_arm)\n\
00110 - [physical model mode]A model cfg table (Format = TABLE, Tag = XSH_MOD_CFG_TAB_arm)\n\
00111 - [OPTIONAL] A badpixel map (Tag = MASTER_BP_MAP_arm)\n\
00112 - [OPTIONAL] The instrument response table (Tag = RESPONSE_MERGE1D_SLIT_arm)\n\
00113 - [OPTIONAL] An atmospheric extinction table (Tag = ATMOS_EXT_arm)\n\
00114 Products : \n\
00115 - PREFIX_ORDER2D_arm (2 dimension)\n\
00116 - PREFIX_ORDER1D_arm (1 dimension)\n\
00117 - PREFIX_MERGE2D_arm (2 dimension)\n\
00118 - PREFIX_MERGE1D_arm (1 dimension)\n\
00119 - [OPTIONAL, if response and atm ext are provided] PREFIX_FLUXCAL2D_arm (2 dimension)\n\
00120 - [OPTIONAL, if response and atm ext are provided] PREFIX_FLUXCAL1D_arm (1 dimension)\n\
00121 - where PREFIX is SCI, FLUX, TELL if input raw DPR.TYPE contains OBJECT or FLUX or TELLURIC";
00122
00123
00124
00125
00134
00135
00136 int cpl_plugin_get_info(cpl_pluginlist *list) {
00137 cpl_recipe *recipe = NULL;
00138 cpl_plugin *plugin = NULL;
00139
00140 recipe = cpl_calloc(1, sizeof(*recipe));
00141 if ( recipe == NULL ){
00142 return -1;
00143 }
00144
00145 plugin = &recipe->interface ;
00146
00147 cpl_plugin_init(plugin,
00148 CPL_PLUGIN_API,
00149 XSH_BINARY_VERSION,
00150 CPL_PLUGIN_TYPE_RECIPE,
00151 RECIPE_ID,
00152 xsh_scired_slit_nod_description_short,
00153 xsh_scired_slit_nod_description,
00154 RECIPE_AUTHOR,
00155 RECIPE_CONTACT,
00156 xsh_get_license(),
00157 xsh_scired_slit_nod_create,
00158 xsh_scired_slit_nod_exec,
00159 xsh_scired_slit_nod_destroy);
00160
00161 cpl_pluginlist_append(list, plugin);
00162
00163 return (cpl_error_get_code() != CPL_ERROR_NONE);
00164 }
00165
00166
00167
00168
00169
00179
00180
00181 static int xsh_scired_slit_nod_create(cpl_plugin *plugin){
00182 cpl_parameter* p=NULL;
00183 cpl_recipe *recipe = NULL;
00184 xsh_remove_crh_single_param crh_single = { 0.1, 5.0, 2.0, 4} ;
00185 xsh_rectify_param rectify = { "default",
00186 CPL_KERNEL_DEFAULT,
00187 4,
00188 XSH_WAVE_BIN_SIZE_PIPE_NIR,
00189 XSH_SLIT_BIN_SIZE_PIPE_NIR,
00190 1,
00191 0,0. };
00192 xsh_localize_obj_param loc_obj =
00193 {10, 0.1, 0, 0, LOC_GAUSSIAN_METHOD, 0, 0.5,3,3, FALSE};
00194 xsh_extract_param extract_par =
00195 { NOD_METHOD};
00196 xsh_combine_nod_param nod_param = { 5, TRUE, 5, 2, 0.1, NULL, COMBINE_MEAN_METHOD} ;
00197 xsh_slit_limit_param slit_limit_param = { MIN_SLIT, MAX_SLIT, 0, 0 } ;
00198 xsh_clipping_param crh_clip_param = {5.0, 5, 0.7, 0, 0.3};
00199
00200
00201 xsh_init();
00202
00203
00204 nod_param.nod_min = 5;
00205 nod_param.nod_clip = TRUE;
00206 nod_param.nod_clip_sigma = 5.;
00207 nod_param.nod_clip_niter = 2;
00208 nod_param.nod_clip_diff = 0.1;
00209 nod_param.throwname = NULL;
00210
00211
00212 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00213
00214
00215 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00216 CPL_ERROR_TYPE_MISMATCH,
00217 "Plugin is not a recipe");
00218
00219 recipe = (cpl_recipe *)plugin;
00220
00221
00222 recipe->parameters = cpl_parameterlist_new();
00223 assure( recipe->parameters != NULL,
00224 CPL_ERROR_ILLEGAL_OUTPUT,
00225 "Memory allocation failed!");
00226
00227
00228 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
00229 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
00230
00231
00232 check(xsh_parameters_background_create(RECIPE_ID,recipe->parameters));
00233 check(p=xsh_parameters_find(recipe->parameters,RECIPE_ID,"background-method"));
00234 cpl_parameter_set_default_string(p,"poly");
00235
00236
00237 check( xsh_parameters_remove_crh_single_create( RECIPE_ID,
00238 recipe->parameters, crh_single));
00239
00240
00241 check(xsh_parameters_rectify_create(RECIPE_ID,recipe->parameters,
00242 rectify )) ;
00243 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
00244 "rectify-fast", TRUE,
00245 "Fast if TRUE (Rect[B-A] = -Rect[A-B]), in that case only entire pixel shifts are applied. "));
00246
00247
00248
00249 check(xsh_parameters_localize_obj_create(RECIPE_ID,recipe->parameters,
00250 loc_obj )) ;
00251
00252 check( xsh_parameters_new_double( recipe->parameters, RECIPE_ID,
00253 "localize-nod-throw", loc_obj.nod_step,
00254 "Step (arcsec) between A and B images in nodding mode."));
00255
00256
00257
00258 check(xsh_parameters_extract_create(RECIPE_ID,
00259 recipe->parameters,
00260 extract_par,NOD_METHOD )) ;
00261
00262 check(xsh_parameters_merge_ord_create(RECIPE_ID,
00263 recipe->parameters,
00264 WEIGHTED_MERGE_METHOD)) ;
00265
00266 check(xsh_parameters_combine_nod_create(RECIPE_ID,
00267 recipe->parameters,
00268 nod_param )) ;
00269
00270 check(xsh_parameters_slit_limit_create(RECIPE_ID,
00271 recipe->parameters,
00272 slit_limit_param )) ;
00273
00274 check(xsh_parameters_clipping_crh_create(RECIPE_ID,recipe->parameters,
00275 crh_clip_param));
00276
00277 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
00278 "compute-map", TRUE,
00279 "if TRUE recompute (wave and slit) maps from the dispersion solution. If sky-subtract is set to TRUE this must be set to TRUE."));
00280 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
00281 "do-flatfield", TRUE,
00282 "TRUE if we do the flatfielding"));
00283
00284 cleanup:
00285 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
00286 xsh_error_dump(CPL_MSG_ERROR);
00287 return 1;
00288 }
00289 else {
00290 return 0;
00291 }
00292 }
00293
00294
00300
00301
00302 static int xsh_scired_slit_nod_exec(cpl_plugin *plugin) {
00303 cpl_recipe *recipe = NULL;
00304
00305
00306
00307 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00308
00309
00310 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00311 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00312
00313 recipe = (cpl_recipe *)plugin;
00314
00315
00316 xsh_scired_slit_nod(recipe->parameters, recipe->frames);
00317
00318 cleanup:
00319 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
00320 xsh_error_dump(CPL_MSG_ERROR);
00321 xsh_error_reset();
00322 return 1;
00323 }
00324 else {
00325 return 0;
00326 }
00327 }
00328
00329
00335
00336 static int xsh_scired_slit_nod_destroy(cpl_plugin *plugin)
00337 {
00338 cpl_recipe *recipe = NULL;
00339
00340
00341 xsh_error_reset();
00342
00343 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00344
00345
00346 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00347 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00348
00349 recipe = (cpl_recipe *)plugin;
00350
00351 xsh_free_parameterlist(&recipe->parameters);
00352
00353 cleanup:
00354 if (cpl_error_get_code() != CPL_ERROR_NONE)
00355 {
00356 return 1;
00357 }
00358 else
00359 {
00360 return 0;
00361 }
00362 }
00363 #if 0
00364 static void change_file_name( cpl_frame * frame, const char * name )
00365 {
00366 const char * old_name ;
00367 char * cmd ;
00368
00369 old_name = cpl_frame_get_filename( frame ) ;
00370 cmd = xsh_stringcat_any( "mv ", old_name, " ", name, NULL ) ;
00371 cpl_frame_set_filename( frame, name ) ;
00372
00373 system( cmd ) ;
00374 XSH_FREE( cmd ) ;
00375 }
00376 #endif
00377
00378
00386 static void
00387 xsh_get_binning(cpl_frameset* raws,int* binx, int* biny)
00388 {
00389 cpl_frame* frame=NULL;
00390 const char* name=NULL;
00391 cpl_propertylist* plist=NULL;
00392 int nraw=0;
00393
00394 XSH_ASSURE_NOT_NULL_MSG(raws,"Null pointer for input raw frameset");
00395 nraw=cpl_frameset_get_size(raws);
00396
00397 XSH_ASSURE_NOT_ILLEGAL_MSG(nraw > 0,"nraw = 0 Provide at least a raw frame");
00398
00399 check(frame=cpl_frameset_get_first(raws));
00400 check(name=cpl_frame_get_filename(frame));
00401 check(plist=cpl_propertylist_load(name,0));
00402 check(*binx=xsh_pfits_get_binx(plist));
00403 check(*biny=xsh_pfits_get_biny(plist));
00404
00405 cleanup:
00406 xsh_free_propertylist(&plist);
00407
00408 return;
00409 }
00410
00411
00412
00420
00421
00422 static cpl_error_code
00423 xsh_params_bin_scale(int binx,int biny)
00424 {
00425
00426
00427 if(biny>1) {
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 }
00453
00454
00455 if(binx>1) {
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469 }
00470
00471
00472 return cpl_error_get_code();
00473
00474 }
00475
00476
00477
00478
00479
00480
00481
00482
00490
00491 static void xsh_scired_slit_nod( cpl_parameterlist* parameters,
00492 cpl_frameset* frameset)
00493 {
00494 const char* recipe_tags[3] = {XSH_OBJECT_SLIT_NOD,XSH_STD_TELL_SLIT_NOD,XSH_STD_FLUX_SLIT_NOD};
00495 int recipe_tags_size = 3;
00496
00497
00498 cpl_frameset *raws = NULL;
00499 cpl_frameset *raws_ord_set = NULL;
00500 cpl_frameset *calib = NULL;
00501
00502
00503 cpl_frame* bpmap = NULL;
00504 cpl_frame *master_bias = NULL;
00505 cpl_frame* master_flat = NULL;
00506 cpl_frame* order_tab_edges = NULL;
00507 cpl_frame * wave_tab = NULL ;
00508 cpl_frame * model_config_frame = NULL;
00509 cpl_frame * wavemap = NULL;
00510 cpl_frame * spectral_format = NULL;
00511
00512
00513 int rectify_fast = 0 ;
00514 xsh_clipping_param* crh_clipping_par = NULL;
00515 xsh_instrument* instrument = NULL;
00516 xsh_remove_crh_single_param * crh_single_par = NULL;
00517 xsh_rectify_param * rectify_par = NULL;
00518 xsh_localize_obj_param * loc_obj_par = NULL;
00519 xsh_merge_param* merge_par = NULL;
00520 xsh_extract_param * extract_par = NULL;
00521 xsh_combine_nod_param * combine_nod_par = NULL;
00522 xsh_slit_limit_param * slit_limit_par = NULL;
00523
00524 char comb_tag[80];
00525 int binx=0;
00526 int biny=0;
00527
00528 int nb_raw_frames;
00529 int nb_pairs ;
00530
00531
00532
00533
00534
00535
00536 cpl_frameset* raws_avg=NULL;
00537 cpl_frame* disp_tab_frame=NULL;
00538 cpl_frame* slitmap=NULL;
00539 cpl_frame *skymask_frame = NULL;
00540
00541 int do_computemap=0;
00542 int do_flatfield = CPL_TRUE;
00543 int even_nb ;
00544
00545 char *rec_prefix = NULL;
00546
00547 cpl_frameset *nod_set = NULL;
00548 cpl_frameset *comb_set = NULL;
00549 cpl_frameset *comb_eff_set = NULL;
00550 cpl_frame *comb_frame = NULL;
00551 cpl_frame *combeso_frame = NULL;
00552 cpl_frame *res2D_frame = NULL;
00553 cpl_frame *loc_table_frame = NULL;
00554 cpl_frame *res1D_frame = NULL;
00555 cpl_frame *res1Deso_frame = NULL;
00556 cpl_frame *s1D_frame = NULL;
00557 cpl_frame* response_ord_frame=NULL;
00558 cpl_frame * fluxcal_1D_frame = NULL ;
00559 cpl_frame * fluxcal_2D_frame = NULL ;
00560 cpl_frame * fluxcal_rect_1D_frame = NULL ;
00561 cpl_frame * fluxcal_rect_2D_frame = NULL ;
00562
00563 cpl_frame* frm_atmext=NULL;
00564 int pre_overscan_corr=0;
00565
00566
00567
00568
00569 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
00570 recipe_tags, recipe_tags_size, RECIPE_ID,
00571 XSH_BINARY_VERSION,
00572 xsh_scired_slit_nod_description_short));
00573
00574
00575 assure( instrument->mode == XSH_MODE_SLIT, CPL_ERROR_ILLEGAL_INPUT,
00576 "Instrument NOT in Slit Mode");
00577
00578 check(xsh_ensure_raws_number_is_even(raws));
00579
00580
00581
00582
00583 check( rec_prefix = xsh_set_recipe_file_prefix(raws,"xsh_scired_slit_nod"));
00584
00585
00586 check( nb_raw_frames = cpl_frameset_get_size( raws));
00587 check( raws_ord_set = xsh_order_frameset_by_date( raws));
00588
00589 xsh_msg_dbg_low( "Nb of Raw frames: %d", nb_raw_frames);
00590
00591 even_nb = nb_raw_frames % 2 ;
00592 XSH_ASSURE_NOT_ILLEGAL( even_nb == 0);
00593
00594 nb_pairs = nb_raw_frames/2 ;
00595 XSH_ASSURE_NOT_ILLEGAL( nb_pairs != 0 );
00596
00597
00598
00599
00600 check( crh_clipping_par = xsh_parameters_clipping_crh_get(RECIPE_ID,
00601 parameters));
00602 check( do_computemap = xsh_parameters_get_boolean( parameters, RECIPE_ID,
00603 "compute-map"));
00604 check( do_flatfield = xsh_parameters_get_boolean( parameters, RECIPE_ID,
00605 "do-flatfield"));
00606
00607 if ( xsh_instrument_get_arm(instrument) != XSH_ARM_NIR){
00608 xsh_get_binning(raws, &binx, &biny);
00609 } else {
00610 binx=1;
00611 biny=1;
00612 }
00613
00614 check( xsh_scired_nod_get_parameters( parameters,instrument,
00615 &crh_single_par, &rectify_par,
00616 &merge_par, &extract_par,
00617 &combine_nod_par,
00618 &slit_limit_par, &loc_obj_par,
00619 &rectify_fast, binx, biny,RECIPE_ID));
00620
00621 check( xsh_scired_slit_nod_get_calibs(raws,calib,instrument,
00622 &bpmap,&master_bias,&master_flat,
00623 &order_tab_edges,&wave_tab,
00624 &model_config_frame,&wavemap,&slitmap,
00625 &disp_tab_frame,
00626 &spectral_format,
00627 &skymask_frame,
00628 &response_ord_frame,
00629 &frm_atmext,
00630 do_computemap,
00631 loc_obj_par->use_skymask,
00632 rec_prefix));
00633
00634 if ( rectify_fast == CPL_FALSE && loc_obj_par->method == LOC_MANUAL_METHOD){
00635 xsh_error_msg( "Mode accurate can not be use with localize-method MANUAL");
00636 }
00637
00638
00639
00640
00641
00642 check( xsh_prepare( raws_ord_set, bpmap, master_bias, XSH_OBJECT_SLIT_NOD,
00643 instrument,pre_overscan_corr));
00644
00645
00646 #if 0
00647 check(offsets=xsh_get_offsets(raws_ord_set));
00648 check(offsets_dif=xsh_get_noffsets(offsets));
00649
00650
00651
00652
00653 ngroups=cpl_vector_get_size(offsets_dif);
00654 xsh_msg("ngroups=%d",ngroups);
00655 #endif
00656
00657 check( raws_avg = xsh_nod_group_by_reloff( raws_ord_set,
00658 instrument,crh_clipping_par));
00659 #if 0
00660 check( raws_avg = xsh_nod_prepare_set( raws_ord_set,
00661 instrument,crh_clipping_par));
00662
00663 noffs=cpl_frameset_get_size(raws_avg);
00664 even_nb = noffs % 2;
00665 xsh_msg("even_nb=%d nb_raw_frames=%d",even_nb,nb_raw_frames);
00666 xsh_msg("nb raws avg=%d",cpl_frameset_get_size(raws_avg));
00667 xsh_frameset_dump_nod_info(raws_avg);
00668 if (even_nb!=0 && nb_raw_frames ==4) {
00669 xsh_msg("special case even_nb!=0 && nb_raw_frames ==4");
00670
00671 xsh_free_frameset(&raws_avg);
00672 check(raws_avg=cpl_frameset_duplicate(raws_ord_set));
00673 } else {
00674 xsh_msg("ensure input nod positions number is even");
00675 check(xsh_ensure_raws_number_is_even(raws_avg));
00676 }
00677 #endif
00678
00679 #if 0
00680 check(raws_avg=xsh_avg_raws_same_off(raws_ord_set,offsets_dif,crh_clipping_par,instrument));
00681 xsh_classif(offsets,&ngroups);
00682 #endif
00683
00684 check( nod_set = xsh_subtract_sky_nod( raws_avg, instrument, rectify_fast));
00685
00686
00687 if ( rectify_fast ){
00688 comb_set=cpl_frameset_new();
00689
00690 check(xsh_scired_slit_nod_fast(
00691 nod_set,
00692 spectral_format,
00693 master_flat,
00694 order_tab_edges,
00695 wave_tab,
00696 model_config_frame,
00697 disp_tab_frame,
00698 wavemap,
00699 slitmap,
00700 instrument,
00701 crh_single_par,
00702 rectify_par,
00703 do_flatfield,1,
00704 rec_prefix,
00705 &comb_set,
00706 &comb_eff_set));
00707
00708 }
00709 else {
00710 check( comb_set = xsh_scired_slit_nod_accurate(
00711 nod_set,
00712 spectral_format,
00713 master_flat,
00714 order_tab_edges,
00715 wave_tab,
00716 model_config_frame,
00717 disp_tab_frame,
00718 wavemap,slitmap,
00719 skymask_frame,
00720 instrument,
00721 crh_single_par,
00722 rectify_par,
00723 loc_obj_par,
00724 slit_limit_par,
00725 combine_nod_par->throwname,
00726 do_flatfield,
00727 rec_prefix
00728 ));
00729
00730
00731 }
00732
00733
00734
00735 sprintf( comb_tag,"%s_%s",
00736 rec_prefix, XSH_GET_TAG_FROM_ARM( XSH_ORDER2D, instrument));
00737 check( comb_frame = xsh_combine_nod( comb_set, combine_nod_par,
00738 comb_tag, instrument, &combeso_frame));
00739
00740
00741 check( res2D_frame = xsh_merge_ord( comb_frame, instrument,
00742 merge_par,rec_prefix));
00743
00744
00745 if ( extract_par->method == LOCALIZATION_METHOD ) {
00746 xsh_msg( "Re-Localize before extraction" ) ;
00747 check( loc_table_frame = xsh_localize_obj( comb_frame, skymask_frame,instrument,
00748 loc_obj_par, slit_limit_par, "LOCALIZE.fits"));
00749 }
00750 xsh_msg( "Extract 1D order-by-order spectrum" ) ;
00751 check( res1D_frame = xsh_extract( comb_frame, loc_table_frame,
00752 instrument, extract_par, &res1Deso_frame, rec_prefix));
00753 xsh_msg( "Merge orders with 1D frame" ) ;
00754 check( s1D_frame = xsh_merge_ord( res1D_frame, instrument,
00755 merge_par,rec_prefix));
00756
00757
00758 if(response_ord_frame != NULL && frm_atmext != NULL) {
00759 check(xsh_flux_calibrate(combeso_frame,res1Deso_frame,frm_atmext,
00760 response_ord_frame,merge_par,instrument,rec_prefix,
00761 &fluxcal_rect_2D_frame,&fluxcal_rect_1D_frame,
00762 &fluxcal_2D_frame,&fluxcal_1D_frame));
00763 }
00764
00765
00766 check( xsh_add_product_image( combeso_frame, frameset,
00767 parameters, RECIPE_ID, instrument,
00768 cpl_frame_get_tag( combeso_frame)));
00769
00770 check( xsh_add_product_image( res1Deso_frame, frameset, parameters,
00771 RECIPE_ID, instrument,
00772 cpl_frame_get_tag(res1Deso_frame)));
00773
00774 check( xsh_add_product_pre( res2D_frame, frameset, parameters,
00775 RECIPE_ID, instrument));
00776 check(xsh_monitor_spectrum1D_flux(s1D_frame,instrument));
00777
00778 check( xsh_add_product_spectrum( s1D_frame, frameset, parameters,
00779 RECIPE_ID, instrument));
00780
00781 if ( do_computemap){
00782
00783 check( xsh_add_product_image( wavemap, frameset,
00784 parameters, RECIPE_ID, instrument,
00785 cpl_frame_get_tag(wavemap)));
00786
00787
00788 check( xsh_add_product_image( slitmap, frameset,
00789 parameters, RECIPE_ID, instrument,
00790 cpl_frame_get_tag(slitmap)));
00791 }
00792
00793 if(response_ord_frame != NULL && frm_atmext != NULL) {
00794 check( xsh_add_product_image(fluxcal_rect_2D_frame,frameset,parameters,
00795 RECIPE_ID, instrument,
00796 cpl_frame_get_filename(fluxcal_rect_2D_frame)));
00797 check( xsh_add_product_image(fluxcal_rect_1D_frame,frameset,parameters,
00798 RECIPE_ID, instrument,
00799 cpl_frame_get_filename(fluxcal_rect_1D_frame)));
00800
00801 check( xsh_add_product_spectrum( fluxcal_2D_frame, frameset, parameters,
00802 RECIPE_ID, instrument));
00803 check( xsh_add_product_spectrum( fluxcal_1D_frame, frameset, parameters,
00804 RECIPE_ID, instrument));
00805 }
00806
00807
00808 cleanup:
00809
00810 xsh_end( RECIPE_ID, frameset, parameters);
00811 xsh_instrument_free( &instrument);
00812 xsh_free_frameset( &raws);
00813 xsh_free_frameset( &calib);
00814 XSH_FREE( rec_prefix);
00815 xsh_free_frameset( &raws_ord_set);
00816 xsh_free_frameset( &raws_avg);
00817 xsh_free_frame( &wavemap);
00818 xsh_free_frame( &slitmap);
00819
00820
00821 XSH_FREE( rectify_par);
00822 XSH_FREE( crh_clipping_par);
00823 XSH_FREE( crh_single_par);
00824 XSH_FREE( loc_obj_par);
00825 XSH_FREE( slit_limit_par);
00826 XSH_FREE( combine_nod_par);
00827 XSH_FREE( extract_par);
00828 XSH_FREE( merge_par);
00829
00830
00831 xsh_free_frameset( &nod_set);
00832 xsh_free_frameset( &comb_set);
00833 xsh_free_frameset( &comb_eff_set);
00834 xsh_free_frame( &comb_frame);
00835 xsh_free_frame( &combeso_frame);
00836 xsh_free_frame( &res2D_frame);
00837 xsh_free_frame( &loc_table_frame);
00838 xsh_free_frame( &res1D_frame);
00839
00840 xsh_free_frame( &res1Deso_frame);
00841 xsh_free_frame( &s1D_frame);
00842 xsh_free_frame(&fluxcal_1D_frame) ;
00843 xsh_free_frame(&fluxcal_2D_frame) ;
00844 xsh_free_frame(&fluxcal_rect_1D_frame) ;
00845 xsh_free_frame(&fluxcal_rect_2D_frame) ;
00846
00847 return;
00848 }
00849