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 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031
00039
00042
00043
00044
00045
00046
00047
00048
00049
00050 #include <xsh_error.h>
00051
00052 #include <xsh_utils.h>
00053 #include <xsh_utils_ifu.h>
00054 #include <xsh_utils_image.h>
00055 #include <xsh_model_utils.h>
00056 #include <xsh_model_io.h>
00057 #include <xsh_msg.h>
00058
00059 #include <xsh_dfs.h>
00060 #include <xsh_pfits.h>
00061
00062 #include <xsh_drl.h>
00063 #include <xsh_drl_check.h>
00064 #include <xsh_model_arm_constants.h>
00065
00066 #include <cpl.h>
00067
00068
00069
00070
00071
00072
00073 #define RECIPE_ID "xsh_scired_ifu_stare"
00074 #define RECIPE_AUTHOR "A.Modigliani, J.Vernet, P. Bristow"
00075 #define RECIPE_CONTACT "Andrea.Modigliani@eso.org"
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 static int xsh_scired_ifu_stare_create(cpl_plugin *);
00086 static int xsh_scired_ifu_stare_exec(cpl_plugin *);
00087 static int xsh_scired_ifu_stare_destroy(cpl_plugin *);
00088
00089
00090 static void xsh_scired_ifu_stare(cpl_parameterlist *, cpl_frameset *);
00091
00092
00093
00094
00095 static char xsh_scired_ifu_stare_description_short[] =
00096 "Reduce science IFU stare exposures and build a 3D cube";
00097
00098 static char xsh_scired_ifu_stare_description[] =
00099 "This recipe reduce science IFU stare exposures with 3D cube generation\n\
00100 Input Frames : \n\
00101 - A set of n Science frames ( n == 1 or >=3, \
00102 Tag = OBJECT_IFU_STARE_UVB)\n\
00103 - A spectral format table frame (Tag = SPECTRAL_FORMAT_TAB_arm)\n\
00104 - [UVB,VIS] A master bias frame (Tag = MASTER_BIAS_arm)\n\
00105 - A master dark frame (Tag = MASTER_DARK_arm)\n\
00106 - A master flat frame (Tag = MASTER_FLAT_IFU_arm)\n\
00107 - An order edges table frame(Tag = ORDER_TAB_EDGES_IFU_arm)\n\
00108 - [physmod] An AFC corrected model cfg frame (Tag = XSH_MOD_CFG_OPT_AFC_arm)\n\
00109 - [poly] An AFC corrected model wavesol frame (Tag = WAVE_TAB_AFC_arm)\n\
00110 - [OPTIONAL] A non-linear badpixel map (Tag = BP_MAP_NL_arm)\n\
00111 - [OPTIONAL] A reference badpixel map (Tag = BP_MAP_RP_arm)\n\
00112 Products : \n\
00113 - Merged 3D data cube (PREFIX_MERGE3D_DATA_OBJ_arm)\n\
00114 - QC Traces of 3D data cube (PREFIX_MERGE3D_TRACE_OBJ_arm)\n\
00115 - Order by order 3D data cube (PREFIX_ORDER3D_DATA_OBJ_arm)\n\
00116 - Order by order 3D qual cube (IFU_CFG_COR_arm)\n\
00117 - Order by order 3D qual cube (PREFIX_MERGE3D_DATA_SKY_arm)\n\
00118 - where PREFIX is SCI, FLUX, TELL if input raw DPR.TYPE contains OBJECT or FLUX or TELLURIC\n";
00119
00120
00121
00122
00123
00124
00133
00134
00135 int cpl_plugin_get_info(cpl_pluginlist *list) {
00136 cpl_recipe *recipe = NULL;
00137 cpl_plugin *plugin = NULL;
00138
00139 recipe = cpl_calloc(1, sizeof(*recipe));
00140 if ( recipe == NULL ){
00141 return -1;
00142 }
00143
00144 plugin = &recipe->interface ;
00145
00146 cpl_plugin_init(plugin,
00147 CPL_PLUGIN_API,
00148 XSH_BINARY_VERSION,
00149 CPL_PLUGIN_TYPE_RECIPE,
00150 RECIPE_ID,
00151 xsh_scired_ifu_stare_description_short,
00152 xsh_scired_ifu_stare_description,
00153 RECIPE_AUTHOR,
00154 RECIPE_CONTACT,
00155 xsh_get_license(),
00156 xsh_scired_ifu_stare_create,
00157 xsh_scired_ifu_stare_exec,
00158 xsh_scired_ifu_stare_destroy);
00159
00160 cpl_pluginlist_append(list, plugin);
00161
00162 return (cpl_error_get_code() != CPL_ERROR_NONE);
00163 }
00164
00165
00175
00176
00177 static int xsh_scired_ifu_stare_create(cpl_plugin *plugin){
00178 cpl_recipe *recipe = NULL;
00179 xsh_clipping_param crh_clip_param = {5.0, 5, 0.7, 0,0.3};
00180
00181 xsh_rectify_param rectify = { "tanh",
00182 CPL_KERNEL_DEFAULT, 2,
00183 -1.,
00184 -1.,
00185 1, 0, 0 };
00186 xsh_stack_param stack_param = {"median",5.,5.};
00187
00188
00189
00190
00191
00192
00193 xsh_init();
00194
00195
00196 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00197
00198
00199 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00200 CPL_ERROR_TYPE_MISMATCH,
00201 "Plugin is not a recipe");
00202
00203 recipe = (cpl_recipe *)plugin;
00204
00205
00206 recipe->parameters = cpl_parameterlist_new();
00207 assure( recipe->parameters != NULL,
00208 CPL_ERROR_ILLEGAL_OUTPUT,
00209 "Memory allocation failed!");
00210
00211
00212 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
00213 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,-1);
00214 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
00215 check(xsh_parameters_stack_create(RECIPE_ID,recipe->parameters,stack_param));
00216
00217 check(xsh_parameters_clipping_crh_create(RECIPE_ID,recipe->parameters,
00218 crh_clip_param));
00219
00220
00221 check(xsh_parameters_background_create(RECIPE_ID,recipe->parameters));
00222
00223
00224 check(xsh_parameters_rectify_create(RECIPE_ID,recipe->parameters,
00225 rectify )) ;
00226
00227
00228
00229
00230
00231
00232 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
00233 "compute-map", FALSE,
00234 "if TRUE recompute (wave and slit) maps from the dispersion solution. If sky-subtract is set to TRUE this must be set to TRUE."));
00235
00236 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
00237 "trace-obj", FALSE,
00238 "if TRUE trace object position on each IFU slice. In this case order TAB edges is required"));
00239
00240
00241 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
00242 "check-afc", TRUE,
00243 "Input AFC corrected model/wave solution and science frame check. If TRUE the recipe verify that the input mode/wave solution is AFC corrected, its INS.OPTIi.NAME is 'Pin_0.5 ', and its OBS.ID and OBS.TARG.NAME values matches with the corresponding values of the science frame."));
00244
00245
00246 cleanup:
00247 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
00248 xsh_error_dump(CPL_MSG_ERROR);
00249 return 1;
00250 }
00251 else {
00252 return 0;
00253 }
00254 }
00255
00263
00264
00265 static cpl_error_code
00266 xsh_params_bin_scale(cpl_frameset* raws,
00267 xsh_background_param* backg)
00268 {
00269
00270 cpl_frame* frame=NULL;
00271 const char* name=NULL;
00272 cpl_propertylist* plist=NULL;
00273 int binx=0;
00274 int biny=0;
00275
00276 check(frame=cpl_frameset_get_first(raws));
00277 check(name=cpl_frame_get_filename(frame));
00278 check(plist=cpl_propertylist_load(name,0));
00279 check(binx=xsh_pfits_get_binx(plist));
00280 check(biny=xsh_pfits_get_biny(plist));
00281 xsh_free_propertylist(&plist);
00282
00283 if(biny>1) {
00284
00285
00286
00287
00288
00289
00290 backg->radius_y=backg->radius_y/biny;
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 }
00317
00318
00319 if(binx>1) {
00320
00321 backg->radius_x=backg->radius_x/binx;
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 }
00342
00343 cleanup:
00344 xsh_free_propertylist(&plist);
00345 return cpl_error_get_code();
00346
00347 }
00348
00349
00355
00356
00357 static int xsh_scired_ifu_stare_exec(cpl_plugin *plugin) {
00358 cpl_recipe *recipe = NULL;
00359
00360
00361
00362 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00363
00364
00365 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00366 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00367
00368 recipe = (cpl_recipe *)plugin;
00369
00370
00371 xsh_scired_ifu_stare(recipe->parameters, recipe->frames);
00372
00373 cleanup:
00374 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
00375 xsh_error_dump(CPL_MSG_ERROR);
00376 xsh_error_reset();
00377 return 1;
00378 }
00379 else {
00380 return 0;
00381 }
00382 }
00383
00384
00390
00391 static int xsh_scired_ifu_stare_destroy(cpl_plugin *plugin)
00392 {
00393 cpl_recipe *recipe = NULL;
00394
00395
00396 xsh_error_reset();
00397
00398 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00399
00400 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00401 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00402
00403 recipe = (cpl_recipe *)plugin;
00404
00405 xsh_free_parameterlist(&recipe->parameters);
00406
00407 cleanup:
00408 if (cpl_error_get_code() != CPL_ERROR_NONE)
00409 {
00410 return 1;
00411 }
00412 else
00413 {
00414 return 0;
00415 }
00416 }
00417 static cpl_error_code
00418 xsh_params_monitor(xsh_background_param* backg,
00419 xsh_rectify_param * rectify_par)
00420 {
00421
00422
00423 xsh_msg_dbg_low("bkg params: sampley=%d radius_y=%d",
00424 backg->sampley,backg->radius_y);
00425
00426 xsh_msg_dbg_low("bkg params: radius_x=%d",
00427 backg->radius_x);
00428
00429 xsh_msg_dbg_low("rectify params: radius=%g bin_lambda=%g bin_space=%g",
00430 rectify_par->rectif_radius,rectify_par->rectif_bin_lambda,
00431 rectify_par->rectif_bin_space);
00432
00433 return cpl_error_get_code();
00434
00435 }
00436
00437
00445
00446 static void xsh_scired_ifu_stare(cpl_parameterlist* parameters,
00447 cpl_frameset* frameset)
00448 {
00449
00450 const char* recipe_tags[3] = {XSH_OBJECT_IFU_STARE,
00451 XSH_STD_TELL_IFU_STARE,
00452 XSH_STD_FLUX_IFU_STARE};
00453
00454 int recipe_tags_size = 3;
00455
00456
00457 cpl_frameset *raws = NULL;
00458 cpl_frameset *calib = NULL;
00459
00460
00461
00462 cpl_frame *spectral_format_frame = NULL;
00463 cpl_frame *ifu_cfg_tab_frame = NULL ;
00464 cpl_frame *ifu_cfg_cor_frame = NULL ;
00465
00466
00467
00468
00469 cpl_frame *bpmap = NULL;
00470 cpl_frame *master_bias = NULL;
00471 cpl_frame *master_dark = NULL;
00472 cpl_frame *masterflat_frame = NULL;
00473 cpl_frame *order_tab_edges = NULL;
00474 cpl_frame *model_config_frame = NULL ;
00475 cpl_frame *wavemap_frame = NULL ;
00476 cpl_frame *slitmap_frame = NULL ;
00477 cpl_frame *disp_tab_frame = NULL;
00478
00479
00480 xsh_background_param *backg_par = NULL;
00481 xsh_rectify_param *rectify_par = NULL ;
00482 xsh_stack_param* stack_par=NULL;
00483
00484
00485 int do_compute_map = 0;
00486 int do_trace_obj = 0;
00487
00488 int recipe_use_model = FALSE;
00489 int check_afc = TRUE;
00490
00491 xsh_instrument* instrument = NULL;
00492 int nb_raw_frames;
00493
00494
00495 #if 0
00496 cpl_frameset * on = NULL, * off = NULL ;
00497 #endif
00498 cpl_frame * crhm_frame = NULL ;
00499 cpl_frame * rmbias = NULL;
00500 cpl_frame * rmdark = NULL;
00501 cpl_frame * rmbkg = NULL ;
00502 cpl_frame *div_frame = NULL ;
00504
00505 cpl_frame* grid_backg=NULL;
00506 cpl_frame* frame_backg=NULL;
00507
00508 const char* ftag=NULL;
00509 char rec_prefix[256];
00510
00511
00512 char tag[256];
00513 char name[256];
00514 cpl_frame* wavesol_frame=NULL;
00515 cpl_frame* order_tab_edges_frame=NULL;
00516
00517 char wave_map_tag[256];
00518 char slit_map_tag[256];
00519 char* prefix=NULL;
00520 int pre_overscan_corr=0;
00521 cpl_frame* ifu_sky_map=NULL;
00522
00523
00524
00525 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
00526 recipe_tags, recipe_tags_size,RECIPE_ID, XSH_BINARY_VERSION,
00527 xsh_scired_ifu_stare_description_short));
00528
00529 assure( instrument->mode == XSH_MODE_IFU, CPL_ERROR_ILLEGAL_INPUT,
00530 "Instrument NOT in IFU Mode");
00531
00532 xsh_recipe_params_check(parameters,instrument,RECIPE_ID);
00533
00534
00535 check( nb_raw_frames = cpl_frameset_get_size( raws ) ) ;
00536 XSH_ASSURE_NOT_ILLEGAL( nb_raw_frames == 1 || nb_raw_frames >= 3 ) ;
00537 prefix=xsh_set_recipe_file_prefix(raws,"xsh_scired_ifu_stare");
00538 check(strcpy(rec_prefix,(const char*)prefix));
00539 XSH_FREE(prefix);
00540
00541
00542
00543 check(bpmap=xsh_check_load_master_bpmap(calib,instrument,RECIPE_ID));
00544
00545 if ( xsh_instrument_get_arm(instrument) != XSH_ARM_NIR){
00546
00547 check( master_bias = xsh_find_master_bias(calib,instrument));
00548 }
00549 #if 0
00550
00551
00552 else {
00553
00554 xsh_msg( "Calling xsh_dfs_split_nir" ) ;
00555 check(xsh_dfs_split_nir(raws, &on, &off));
00556 xsh_msg( " Nb ON: %d, OFF: %d", cpl_frameset_get_size(on),
00557 cpl_frameset_get_size(off) ) ;
00558 XSH_ASSURE_NOT_ILLEGAL(cpl_frameset_get_size(on) >= 3);
00559 XSH_ASSURE_NOT_ILLEGAL(cpl_frameset_get_size(off) >= 3);
00560 }
00561 #endif
00562
00563
00564
00565
00566 check(ifu_cfg_tab_frame=xsh_find_frame_with_tag(calib,XSH_IFU_CFG_TAB,instrument));
00567 check(ifu_cfg_cor_frame=xsh_find_frame_with_tag(calib,XSH_IFU_CFG_COR,instrument));
00568 check(spectral_format_frame=xsh_find_spectral_format( calib, instrument ) ) ;
00569
00570
00571
00572
00573 check( order_tab_edges = xsh_find_order_tab_edges( calib, instrument));
00574
00575
00576 check(model_config_frame=xsh_find_frame_with_tag(calib,XSH_MOD_CFG_OPT_AFC,
00577 instrument));
00578
00579
00580 if(model_config_frame==NULL) {
00581 check(wavesol_frame=xsh_find_frame_with_tag(calib,XSH_WAVE_TAB_AFC,
00582 instrument));
00583 }
00584
00585
00586
00587
00588
00589
00590
00591 if ( model_config_frame == NULL){
00592 xsh_msg("RECIPE USE WAVE SOLUTION");
00593 recipe_use_model = FALSE;
00594 }
00595 else{
00596 xsh_msg("RECIPE USE MODEL");
00597 recipe_use_model = TRUE;
00598 }
00599
00600 if( (model_config_frame!=NULL) && (wavesol_frame != NULL) ) {
00601
00602 xsh_msg_error("You cannot provide both a %s and a %s frame. Decide if you are in poly or physical model mode. We exit",
00603 XSH_WAVE_TAB_2D , XSH_MOD_CFG_TAB);
00604 goto cleanup;
00605 }
00606
00607 if((model_config_frame==NULL) && ( wavesol_frame == NULL) ) {
00608 xsh_msg_error("You must provide either a %s or a %s frame",
00609 XSH_WAVE_TAB_AFC, XSH_MOD_CFG_TAB);
00610 goto cleanup;
00611 }
00612
00613 if ( (master_dark = xsh_find_master_dark( calib, instrument ) ) == NULL ){
00614 xsh_msg_warning("Frame %s not provided",XSH_MASTER_DARK);
00615 xsh_error_reset();
00616 }
00617
00618 check( masterflat_frame = xsh_find_master_flat( calib, instrument));
00619
00620
00621
00622
00623
00624 recipe_use_model = ( model_config_frame != NULL);
00625
00626 check( stack_par = xsh_stack_frames_get( RECIPE_ID, parameters));
00627
00628 check( backg_par = xsh_parameters_background_get(RECIPE_ID,
00629 parameters));
00630
00631
00632
00633
00634
00635 check( rectify_par = xsh_parameters_rectify_get(RECIPE_ID,
00636 parameters));
00637 rectify_par->conserve_flux=FALSE;
00638
00639 check( do_compute_map = xsh_parameters_get_boolean( parameters, RECIPE_ID,
00640 "compute-map"));
00641
00642 check( check_afc = xsh_parameters_get_boolean( parameters, RECIPE_ID,
00643 "check-afc"));
00644
00645 check( do_trace_obj = xsh_parameters_get_boolean( parameters, RECIPE_ID,
00646 "trace-obj"));
00647
00648 if ( do_compute_map && recipe_use_model==FALSE){
00649 check( disp_tab_frame = xsh_find_disp_tab( calib, instrument));
00650 }
00651 check(xsh_rectify_params_set_defaults(parameters,RECIPE_ID,instrument,rectify_par));
00652
00653
00654 if ( xsh_instrument_get_arm( instrument ) != XSH_ARM_NIR ) {
00655 check(xsh_params_bin_scale(raws,backg_par));
00656 }
00657 check(xsh_params_monitor(backg_par,rectify_par));
00658
00659
00660
00661
00662
00663
00664
00665
00666 xsh_msg( "---Prepare raws frames");
00667 check( xsh_prepare( raws, bpmap, master_bias, XSH_OBJECT_IFU_STARE,
00668 instrument,pre_overscan_corr,CPL_TRUE));
00669
00670
00671
00672 if ( nb_raw_frames >= 3 ) {
00673 xsh_msg( "---Remove cosmics");
00674
00675 ftag=XSH_GET_TAG_FROM_ARM(XSH_SLIT_STARE_REMOVE_CRH,instrument);
00676 check_msg( crhm_frame = xsh_remove_crh_multiple( raws,
00677 ftag,stack_par,NULL,
00678 instrument, NULL,NULL,0 ),
00679 "Error in xsh_remove_crh" ) ;
00680 }
00681 else {
00682
00683 check( crhm_frame = cpl_frame_duplicate(cpl_frameset_get_first( raws )));
00684 }
00685 xsh_msg( "created %s", cpl_frame_get_filename( crhm_frame));
00686
00687
00688 if (recipe_use_model){
00689 int found_temp=true;
00690 xsh_msg("correct for temperature");
00691 check(xsh_model_temperature_update_frame(&model_config_frame,crhm_frame,
00692 instrument,&found_temp));
00693 }
00694
00695 if ( do_compute_map){
00696 check(xsh_mode_set(instrument,XSH_MODE_IFU));
00697
00698 if (recipe_use_model){
00699
00700
00701 sprintf(wave_map_tag,"%s_%s",rec_prefix,XSH_WAVE_MAP_MODEL);
00702 sprintf(slit_map_tag,"%s_%s",rec_prefix,XSH_SLIT_MAP_MODEL);
00703 check( xsh_create_model_map( model_config_frame, instrument,
00704 wave_map_tag,slit_map_tag,
00705 &wavemap_frame, &slitmap_frame,0));
00706
00707 }
00708 else{
00709 xsh_msg( "Compute the wave map and the slit map");
00710 check( xsh_create_map( disp_tab_frame, order_tab_edges,
00711 crhm_frame, instrument,
00712 &wavemap_frame, &slitmap_frame,rec_prefix));
00713 }
00714 cpl_frameset_insert( calib, wavemap_frame);
00715 cpl_frameset_insert( calib, slitmap_frame);
00716 }
00717 else{
00718 check( wavemap_frame = xsh_find_wavemap( calib, instrument));
00719 slitmap_frame = xsh_find_slitmap(calib, instrument);
00720 }
00721
00722
00723 check( rmbias = xsh_check_subtract_bias( crhm_frame, master_bias,
00724 instrument, rec_prefix,
00725 pre_overscan_corr,0));
00726
00727 xsh_add_temporary_file(cpl_frame_get_filename(rmbias));
00728
00729
00730
00731
00732 if(check_afc) {
00733 if(model_config_frame!=NULL) {
00734 check(xsh_frame_check_model_cfg_is_afc_corrected(model_config_frame));
00735 check(xsh_frame_check_model_cfg_is_proper_for_sci(model_config_frame,
00736 rmbias,instrument));
00737 } else {
00738 check(xsh_frame_check_model_cfg_is_afc_corrected(wavesol_frame));
00739 check(xsh_frame_check_model_cfg_is_proper_for_sci(wavesol_frame,
00740 rmbias,instrument));
00741 }
00742 }
00743
00744
00745 if ( master_dark != NULL ) {
00746 xsh_msg( "---Subtract_dark");
00747 sprintf(name, "%s_DARK_%s.fits",
00748 rec_prefix,xsh_instrument_arm_tostring(instrument));
00749 check( rmdark = xsh_subtract_dark(rmbias, master_dark,
00750 name,instrument));
00751 }
00752 else {
00753 xsh_msg( "No Master Dark" ) ;
00754 check( rmdark = cpl_frame_duplicate( rmbias ) ) ;
00755 }
00756 xsh_free_frame(&rmbias);
00757
00758
00759
00760 xsh_msg("---Subtract_background");
00761 check( rmbkg = xsh_subtract_background( rmdark,
00762 order_tab_edges, backg_par, instrument, rec_prefix,&grid_backg,
00763 &frame_backg,0,0,0 ));
00764 xsh_free_frame(&rmdark);
00765
00766
00767 xsh_msg("---Do flatfielding");
00768 sprintf( tag, "%s_FF_%s",
00769 rec_prefix,xsh_instrument_arm_tostring(instrument));
00770 sprintf(name,"%s.fits",tag);
00771 check( div_frame = xsh_divide_flat( rmbkg, masterflat_frame,
00772 tag, instrument));
00773 xsh_add_temporary_file(name);
00774
00775 xsh_free_frame( &rmbkg);
00776
00777 if(do_trace_obj && do_compute_map) {
00778 check(xsh_mode_set(instrument,XSH_MODE_IFU));
00779 check(order_tab_edges_frame = xsh_find_order_tab_edges(calib,instrument));
00780 check(xsh_mode_set(instrument,XSH_MODE_SLIT));
00781 check(xsh_ifu_trace_object_calibrate(cpl_frame_get_filename(div_frame),
00782 cpl_frame_get_filename(order_tab_edges_frame),
00783 cpl_frame_get_filename(slitmap_frame),
00784 cpl_frame_get_filename(wavemap_frame)));
00785 }
00786
00787 check(xsh_build_ifu_cube(div_frame,ifu_cfg_tab_frame,ifu_cfg_cor_frame,
00788 spectral_format_frame,
00789 model_config_frame,
00790 wavesol_frame,
00791 instrument,
00792 frameset,
00793 parameters,rectify_par,RECIPE_ID,rec_prefix,1));
00794
00795 if(do_compute_map) {
00796 check(ifu_sky_map=xsh_build_ifu_map(div_frame,wavemap_frame,slitmap_frame,model_config_frame,instrument));
00797 check( xsh_add_product_image( ifu_sky_map, frameset,parameters, RECIPE_ID, instrument,NULL));
00798 }
00799 cleanup:
00800
00801 xsh_end( RECIPE_ID, frameset, parameters );
00802 xsh_instrument_free( &instrument);
00803 xsh_free_frameset( &raws);
00804 xsh_free_frameset( &calib);
00805
00806 xsh_free_frame( &crhm_frame);
00807 xsh_free_frame(&rmbias);
00808 xsh_free_frame(&div_frame);
00809 xsh_free_frame(&rmdark);
00810 xsh_free_frame( &rmbkg);
00811 xsh_free_frame( &grid_backg);
00812 xsh_free_frame( &frame_backg);
00813
00814 XSH_FREE(stack_par);
00815 XSH_FREE(backg_par);
00816 XSH_FREE(rectify_par);
00817
00818
00819 return;
00820 }
00821