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
00029 #ifdef HAVE_CONFIG_H
00030 #include <config.h>
00031 #endif
00032
00033
00041
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #include <xsh_error.h>
00054
00055 #include <xsh_utils.h>
00056 #include <xsh_msg.h>
00057
00058 #include <xsh_dfs.h>
00059 #include <xsh_drl_check.h>
00060
00061 #include <xsh_pfits.h>
00062 #include <xsh_data_order.h>
00063 #include <xsh_data_instrument.h>
00064 #include <xsh_drl.h>
00065 #include <xsh_model_kernel.h>
00066 #include <xsh_model_arm_constants.h>
00067
00068
00069 #include <cpl.h>
00070
00071
00072
00073
00074
00075 #define RECIPE_ID "xsh_flexcomp"
00076 #define RECIPE_AUTHOR "P.Goldoni, L.Guglielmi, R. Haigron, F. Royer"
00077 #define RECIPE_CONTACT "amodigli@eso.org"
00078
00079 #define XSH_AFC_UVB_XMIN 573
00080 #define XSH_AFC_UVB_YMIN 1501
00081 #define XSH_AFC_UVB_XMAX 1572
00082 #define XSH_AFC_UVB_YMAX 2500
00083 #define XSH_AFC_UVB_ORDER 18
00084
00085 #define XSH_AFC_VIS_XMIN 534
00086 #define XSH_AFC_VIS_YMIN 2301
00087 #define XSH_AFC_VIS_XMAX 1533
00088 #define XSH_AFC_VIS_YMAX 3300
00089 #define XSH_AFC_VIS_ORDER 26
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 static int xsh_flexcomp_create(cpl_plugin *);
00100 static int xsh_flexcomp_exec(cpl_plugin *);
00101 static int xsh_flexcomp_destroy(cpl_plugin *);
00102
00103
00104 static void xsh_flexcomp(cpl_parameterlist *, cpl_frameset *);
00105
00106
00107
00108
00109 static char xsh_flexcomp_description_short[] =
00110 "Compute the flexure of the instrument";
00111
00112 static char xsh_flexcomp_description[] =
00113 "This recipe computes the flexure of the instrument and correct CAL files.\n\
00114 Input Frames :\n\
00115 - [UVB, VIS] One RAW frame (Format = RAW, Tag = AFF_ATT_arm)\n\
00116 - [NIR] Two RAW frames ((Format = RAW, Tag = AFC_ATT_arm_ON,\
00117 AFC_ATT_arm_OFF)\n\
00118 - An arc line list (Format = TABLE, Tag = ARC_LINE_LIST_AFC_arm)\n\
00119 - A spectral format table frame (Format = TABLE, Tag = SPECTRAL_FORMAT_TAB_arm)\n\
00120 - [UVB,VIS] A master bias (Format = PRE, Tag = MASTER_BIAS_arm)\n\
00121 - [UVB,VIS] A master dark (Format = PRE, Tag = MASTER_DARK_arm)\n\
00122 - An order table frame (Format = TABLE, Tag = ORDER_TAB_EDGES_IFU_arm)\n\
00123 - [OPTIONAL] A non-linear badpixel map (Tag = BP_MAP_NL_arm)\n\
00124 - [OPTIONAL] A reference badpixel map (Tag = BP_MAP_RP_arm)\n\
00125 - [poly mode] A wave solution frame (Format = TABLE, Tag = WAVE_TAB_2D_arm)\n\
00126 - [physical model mode] A model cfg table (Format = TABLE, Tag = XSH_MOD_CFG_OPT_2D_arm)\n\
00127 Products : \n\
00128 - [poly mode] An updated wave solution frame (Format = TABLE, Tag = WAVE_TAB_AFC_arm)\n\
00129 - [physical model mode] An updated model cfg table (Format = TABLE, Tag = XSH_MOD_CFG_OPT_AFC_arm)\n\
00130 - An updated order table frame (Format = TABLE, Tag = ORDER_TAB_AFC_IFU_arm)\n\
00131 - [poly mode] A dispersion table frame (Format = TABLE, Tag = DISP_TAB_AFC_arm)\n";
00132
00133
00134
00135
00136
00145
00146
00147 int cpl_plugin_get_info(cpl_pluginlist *list) {
00148 cpl_recipe *recipe = NULL;
00149 cpl_plugin *plugin = NULL;
00150
00151 recipe = cpl_calloc(1, sizeof(*recipe));
00152 if ( recipe == NULL ){
00153 return -1;
00154 }
00155
00156 plugin = &recipe->interface ;
00157
00158 cpl_plugin_init(plugin,
00159 CPL_PLUGIN_API,
00160 XSH_BINARY_VERSION,
00161 CPL_PLUGIN_TYPE_RECIPE,
00162 RECIPE_ID,
00163 xsh_flexcomp_description_short,
00164 xsh_flexcomp_description,
00165 RECIPE_AUTHOR,
00166 RECIPE_CONTACT,
00167 xsh_get_license(),
00168 xsh_flexcomp_create,
00169 xsh_flexcomp_exec,
00170 xsh_flexcomp_destroy);
00171
00172 cpl_pluginlist_append(list, plugin);
00173
00174 return (cpl_error_get_code() != CPL_ERROR_NONE);
00175 }
00176
00177
00187
00188
00189 static int xsh_flexcomp_create(cpl_plugin *plugin){
00190 cpl_recipe *recipe = NULL;
00191 xsh_clipping_param detarc_clip_param = { 2.0, 10, 0.7, 0, 0.3};
00192 xsh_detect_arclines_param detarc_param = { 8, 2, 0, 5, 5, 0, 2, -1.0,
00193 XSH_GAUSSIAN_METHOD, FALSE};
00194 xsh_dispersol_param dispsol_param = { 5, 5 } ;
00195 char paramname[256];
00196 cpl_parameter* p=NULL;
00197
00198
00199 xsh_init();
00200
00201
00202 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00203
00204
00205 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00206 CPL_ERROR_TYPE_MISMATCH,
00207 "Plugin is not a recipe");
00208
00209 recipe = (cpl_recipe *)plugin;
00210
00211
00212 recipe->parameters = cpl_parameterlist_new();
00213 assure( recipe->parameters != NULL,
00214 CPL_ERROR_ILLEGAL_OUTPUT,
00215 "Memory allocation failed!");
00216
00217
00218 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
00219 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
00220
00221 check( xsh_parameters_new_boolean( recipe->parameters, RECIPE_ID,
00222 "compute-disptab",
00223 TRUE,
00224 "Compute the wavemap and the slitmap and the dispersion table."));
00225
00226
00227 check(xsh_parameters_detect_arclines_create(RECIPE_ID,recipe->parameters,
00228 detarc_param));
00229 check(xsh_parameters_clipping_detect_arclines_create(RECIPE_ID,
00230 recipe->parameters, detarc_clip_param));
00231
00232 check(xsh_parameters_dispersol_create(RECIPE_ID,
00233 recipe->parameters,
00234 dispsol_param ));
00235
00236
00237 check( xsh_parameters_new_int( recipe->parameters, RECIPE_ID,
00238 "model-maxit",1000,
00239 "Number/10 of annealing iterations "
00240 "if in physical model mode."));
00241
00242 check( xsh_parameters_new_double( recipe->parameters, RECIPE_ID,
00243 "model-anneal-factor",1.0,
00244 "Multiplier applied to the automatic "
00245 "parameter ranges (i.e. when scenario!=0). "
00246 "For routine operations should be 1.0. "
00247 "(physical model mode)."));
00248
00249
00250 sprintf(paramname,"xsh.%s.%s",RECIPE_ID,"model-scenario");
00251
00252 check(p=cpl_parameter_new_enum(paramname,CPL_TYPE_INT,
00253 "selects preset flag and range combinations "
00254 "appropriate to common scenarios: "
00255 "-1 - Only the position across the slit and"
00256 " camera focal length are open\n"
00257 " 0 - No scenario, input cfg flags and limits"
00258 " used."
00259 " 1 - scenario appropriate for the startup"
00260 " recipe (large ranges for parameters "
00261 " affecting single ph exposures, dist "
00262 " coeff fixed)"
00263 " 2 - Like 1, but includes parameters "
00264 " affecting all ph positions"
00265 " 3 - Scenario for use in fine tuning cfg"
00266 " to match routine wavecal exposures. All"
00267 " parameters affecting 1ph exposures"
00268 " except dist coeffs are included and"
00269 " parameter ranges are small. (For use by"
00270 " flexcomp in 1ph case)."
00271 " 4 - Like 3 but includes parameters"
00272 " affecting all ph positions (Standard for"
00273 " use by flexcomp in 9ph case and 2dmap)."
00274 " 5 - Like 4 but includes also dist coeffs"
00275 " 6 - Just dist coeffs (and chipx, chipy)",
00276 RECIPE_ID,3,9,-1,0,1,2,3,4,5,6,8));
00277
00278
00279 check(cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,
00280 "model-scenario"));
00281 check(cpl_parameterlist_append(recipe->parameters,p));
00282
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_flexcomp_exec(cpl_plugin *plugin) {
00303 cpl_recipe *recipe = NULL;
00304
00305
00306 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00307
00308
00309 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00310 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00311
00312 recipe = (cpl_recipe *)plugin;
00313
00314
00315 xsh_flexcomp(recipe->parameters, recipe->frames);
00316
00317 cleanup:
00318 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
00319 xsh_error_dump(CPL_MSG_ERROR);
00320 cpl_error_reset();
00321 return 1;
00322 }
00323 else {
00324 return 0;
00325 }
00326 }
00327
00328
00334
00335 static int xsh_flexcomp_destroy(cpl_plugin *plugin)
00336 {
00337 cpl_recipe *recipe = NULL;
00338
00339
00340 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00341
00342
00343 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00344 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00345
00346 recipe = (cpl_recipe *)plugin;
00347
00348 xsh_free_parameterlist(&recipe->parameters);
00349
00350 cleanup:
00351 if (cpl_error_get_code() != CPL_ERROR_NONE)
00352 {
00353 return 1;
00354 }
00355 else
00356 {
00357 return 0;
00358 }
00359 }
00360
00361 static cpl_error_code
00362 xsh_params_set_defaults(cpl_parameterlist* pars,
00363 xsh_instrument* inst,
00364 xsh_detect_arclines_param* detect_arclines_p)
00365 {
00366 cpl_parameter* p=NULL;
00367
00368 check(p=xsh_parameters_find(pars,RECIPE_ID,"detectarclines-min-sn"));
00369 if(cpl_parameter_get_double(p) <= 0) {
00370 if (xsh_instrument_get_arm(inst) == XSH_ARM_NIR){
00371
00372 cpl_parameter_set_double(p,4);
00373 detect_arclines_p->min_sn=4;
00374 } else {
00375 cpl_parameter_set_double(p,3);
00376 detect_arclines_p->min_sn=3;
00377 }
00378 }
00379
00380 cleanup:
00381
00382 return cpl_error_get_code();
00383
00384 }
00385
00386 static cpl_error_code
00387 xsh_frame_check_is_right_afcatt(cpl_frame* afcatt_frame,
00388 xsh_instrument* instrument)
00389 {
00390 cpl_propertylist* plist=NULL;
00391 const char* name=NULL;
00392 char* slit_value=NULL;
00393 name=cpl_frame_get_filename(afcatt_frame);
00394 plist=cpl_propertylist_load(name,0);
00395 check(slit_value=xsh_pfits_get_slit_value (plist,instrument));
00396 if (strcmp(slit_value,"Pin_0.5") != 0 ) {
00397 xsh_msg_error("INS OPTIi NAME value=%s",slit_value);
00398 xsh_msg_error("Your input AFC frame should be the 1st of the AFC sequence");
00399 xsh_msg_error("Its INS OPTIi NAME key value should be 'Pin_0.5'");
00400 cpl_error_set(cpl_func, CPL_ERROR_ILLEGAL_INPUT);
00401 }
00402
00403 cleanup:
00404 xsh_free_propertylist(&plist);
00405
00406 return cpl_error_get_code();
00407
00408
00409 }
00410
00411
00419
00420 static void xsh_flexcomp(cpl_parameterlist* parameters, cpl_frameset* frameset)
00421 {
00422 const char* recipe_tags[1] = {XSH_AFC_ATT};
00423 int recipe_tags_size = 1;
00424
00425
00426 xsh_clipping_param* detect_arclines_clipping = NULL;
00427 xsh_detect_arclines_param* detect_arclines_p = NULL;
00428 xsh_dispersol_param *dispsol_param = NULL ;
00429
00430
00431 cpl_frameset* raws = NULL;
00432 cpl_frameset* calib = NULL;
00433 xsh_instrument* instrument = NULL;
00434
00435 cpl_frame* arclist_frame = NULL;
00436 cpl_frame* afcatt_frame = NULL;
00437 cpl_frame* spectralformat_frame = NULL;
00438 cpl_frame* order_tab_edges_frame = NULL;
00439 cpl_frame* wave_tab_frame = NULL;
00440
00441 cpl_frame* wave_map_frame = NULL;
00442 cpl_frame* slit_map_frame = NULL;
00443
00444 cpl_frame* model_config_frame = NULL;
00445 cpl_frame* masterbias_frame = NULL;
00446 cpl_frame* masterdark_frame = NULL;
00447 cpl_frame* bpmap_frame = NULL;
00448
00449 cpl_frame *subbias_frame = NULL;
00450 cpl_frame *subdark_frame = NULL;
00451 int afc_xmin=1;
00452 int afc_xmax=1;
00453 int afc_ymin=1;
00454 int afc_ymax=1;
00455 int afc_order=0;
00456 cpl_frame* afcatt_rmbias = NULL;
00457 cpl_frame* afcatt_rmdark = NULL;
00458 cpl_frame* att_cleanlines = NULL;
00459 cpl_frame* att_resid_tab = NULL;
00460 cpl_frame *afcthetab_frame = NULL;
00461 const char *tag = NULL;
00462 char filename [256];
00463 cpl_frame *afc_wave_tab_frame = NULL;
00464 cpl_frame *afc_order_tab_edges_frame = NULL;
00465 cpl_frame *afc_disp_tab_frame = NULL;
00466 cpl_frame *afc_config_tab_frame = NULL;
00467 XSH_ARM arm = XSH_ARM_UNDEFINED;
00468 int pre_overscan_corr=0;
00469
00470 char wave_map_tag[80];
00471 char slit_map_tag[80];
00472 int compute_disp_tab=0;
00473 int nraws=0;
00474 cpl_boolean mode_phys;
00475
00476 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
00477 recipe_tags, recipe_tags_size,
00478 RECIPE_ID, XSH_BINARY_VERSION,
00479 xsh_flexcomp_description_short));
00480 nraws=cpl_frameset_get_size(raws);
00481 assure(nraws > 0, CPL_ERROR_NULL_INPUT, "Provide an input AFC_ATT_ARM frame");
00482
00483 xsh_recipe_params_check(parameters,instrument,RECIPE_ID);
00484
00485
00486
00487 mode_phys=xsh_mode_is_physmod(calib,instrument);
00488 check(bpmap_frame=xsh_check_load_master_bpmap(calib,instrument,RECIPE_ID));
00489 check( arclist_frame = xsh_find_frame_with_tag( calib,
00490 XSH_ARC_LINE_LIST_AFC,
00491 instrument));
00492 XSH_ASSURE_NOT_NULL_MSG( arclist_frame,
00493 "No input ARC_LINE_AFC_LIST_ARM arclines list provided");
00494 check( spectralformat_frame = xsh_find_frame_with_tag( calib,
00495 XSH_SPECTRAL_FORMAT, instrument));
00496 XSH_ASSURE_NOT_NULL_MSG( spectralformat_frame,
00497 "No spectral format provided");
00498 check( order_tab_edges_frame = xsh_find_order_tab_edges( calib,instrument));
00499 XSH_ASSURE_NOT_NULL_MSG( order_tab_edges_frame,
00500 "No input ORDER_TABLE_EDGES_MODE_ARM (MODE=IFU or SLIT) table provided");
00501
00502
00503 if(!mode_phys) {
00504 wave_tab_frame = xsh_find_wave_tab( calib, instrument);
00505 } else {
00506
00507 if ( (model_config_frame = xsh_find_frame_with_tag( calib,
00508 XSH_MOD_CFG_OPT_2D, instrument)) == NULL) {
00509 xsh_error_reset();
00510 if ((model_config_frame = xsh_find_frame_with_tag(calib,
00511 XSH_MOD_CFG_TAB, instrument)) == NULL) {
00512 xsh_error_reset();
00513 }
00514 }
00515 }
00516 if( (model_config_frame!=NULL) && (wave_tab_frame != NULL) ) {
00517
00518 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",
00519 XSH_WAVE_TAB_2D , XSH_MOD_CFG_TAB);
00520 goto cleanup;
00521 }
00522
00523 if((model_config_frame==NULL) && ( wave_tab_frame == NULL) ) {
00524 xsh_msg_error("You must provide either a %s or a %s frame",
00525 XSH_WAVE_TAB_2D, XSH_MOD_CFG_TAB);
00526 goto cleanup;
00527 }
00528
00529 check( arm = xsh_instrument_get_arm(instrument));
00530
00531 if ( arm != XSH_ARM_NIR){
00532 if((masterbias_frame = xsh_find_frame_with_tag(calib,XSH_MASTER_BIAS,
00533 instrument)) == NULL) {
00534
00535 xsh_msg_warning("Frame %s not provided",XSH_MASTER_BIAS);
00536 xsh_error_reset();
00537 }
00538
00539 if((masterdark_frame = xsh_find_frame_with_tag(calib,XSH_MASTER_DARK,
00540 instrument)) == NULL){
00541 xsh_msg_warning("Frame %s not provided",XSH_MASTER_DARK);
00542 xsh_error_reset();
00543 }
00544 }
00545 check( xsh_instrument_update_from_spectralformat( instrument,
00546 spectralformat_frame));
00547 check( pre_overscan_corr = xsh_parameters_get_int( parameters, RECIPE_ID,
00548 "pre-overscan-corr"));
00549
00550
00551
00552
00553 check(detect_arclines_clipping =
00554 xsh_parameters_clipping_detect_arclines_get(RECIPE_ID, parameters));
00555 check(detect_arclines_p = xsh_parameters_detect_arclines_get(RECIPE_ID,
00556 parameters));
00557 check( dispsol_param = xsh_parameters_dispersol_get( RECIPE_ID, parameters));
00558 check(xsh_params_set_defaults(parameters,instrument,detect_arclines_p));
00559
00560 check(compute_disp_tab = xsh_parameters_get_boolean( parameters,
00561 RECIPE_ID,
00562 "compute-disptab"));
00563
00564
00565
00566
00567
00568 if (arm != XSH_ARM_NIR){
00569
00570 if ( arm == XSH_ARM_VIS){
00571 afc_xmin = XSH_AFC_VIS_XMIN-10;
00572 afc_xmax = XSH_AFC_VIS_XMAX-10;
00573 afc_ymin = XSH_AFC_VIS_YMIN;
00574 afc_ymax = XSH_AFC_VIS_YMAX;
00575 afc_order = XSH_AFC_VIS_ORDER;
00576 }
00577 else {
00578 afc_xmin = 2145-XSH_AFC_UVB_XMAX-48;
00579 afc_xmax = 2145-XSH_AFC_UVB_XMIN-48;
00580 afc_ymin = 3001-XSH_AFC_UVB_YMAX;
00581 afc_ymax = 3001-XSH_AFC_UVB_YMIN;
00582 afc_order = XSH_AFC_UVB_ORDER;
00583 }
00584 xsh_msg("AFC pre coordinates (%d,%d, %d,%d)",afc_xmin,afc_ymin,
00585 afc_xmax,afc_ymax);
00586
00587 if ( masterbias_frame != NULL){
00588 check( subbias_frame = xsh_preframe_extract( masterbias_frame,
00589 afc_xmin, afc_ymin, afc_xmax, afc_ymax,
00590 "TEST_SUBBIAS.fits", instrument));
00591 }
00592
00593 if ( masterdark_frame != NULL){
00594 check( subdark_frame = xsh_preframe_extract( masterdark_frame,
00595 afc_xmin, afc_ymin, afc_xmax, afc_ymax,
00596 "TEST_SUBDARK.fits", instrument));
00597
00598 }
00599 }
00600 check( xsh_prepare( raws, bpmap_frame, subbias_frame, XSH_AFC_ATT,
00601 instrument,pre_overscan_corr));
00602
00603 check( afcatt_frame = cpl_frameset_get_first( raws));
00604 check( xsh_frame_check_is_right_afcatt(afcatt_frame,instrument));
00605
00606 if( subbias_frame != NULL) {
00607
00608 check( afcatt_rmbias = xsh_subtract_bias( afcatt_frame, subbias_frame,
00609 instrument,"AFC_ATT_",
00610 pre_overscan_corr,1));
00611 }
00612 else {
00613 afcatt_rmbias =cpl_frame_duplicate( afcatt_frame);
00614 }
00615
00616 if( subdark_frame != NULL) {
00617
00618 sprintf( filename, "AFCATT_DARK_%s.fits",
00619 xsh_instrument_arm_tostring( instrument));
00620 check( afcatt_rmdark = xsh_subtract_dark( afcatt_rmbias, subdark_frame,
00621 filename, instrument));
00622 }
00623 else {
00624 afcatt_rmdark =cpl_frame_duplicate( afcatt_rmbias);
00625 }
00626 check( afcthetab_frame = xsh_afcthetab_create( wave_tab_frame,
00627 model_config_frame, afc_order, spectralformat_frame,
00628 arclist_frame, afc_xmin, afc_ymin,
00629 instrument,1));
00630
00631
00632 check( xsh_detect_arclines( afcatt_rmdark, afcthetab_frame,
00633 arclist_frame, NULL, NULL,
00634 NULL, spectralformat_frame, NULL,
00635 &att_cleanlines, NULL, &att_resid_tab, XSH_SOLUTION_RELATIVE,
00636 detect_arclines_p,
00637 detect_arclines_clipping,
00638 instrument,RECIPE_ID,1,0));
00639
00640
00641 check( afc_wave_tab_frame = xsh_flexcor( afcatt_frame, wave_tab_frame,
00642 model_config_frame,
00643 order_tab_edges_frame, att_resid_tab,
00644 afc_xmin, afc_ymin, instrument,
00645 &afc_order_tab_edges_frame,
00646 &afc_config_tab_frame));
00647
00648 if(compute_disp_tab) {
00649 if(model_config_frame == NULL) {
00650
00651
00652 if ( wave_tab_frame != NULL){
00653 check( xsh_create_poly_wavemap( NULL, wave_tab_frame,
00654 afc_order_tab_edges_frame,
00655 spectralformat_frame,
00656 dispsol_param,
00657 instrument,
00658 "AFC_",
00659 &afc_disp_tab_frame, NULL));
00660
00661 tag = XSH_GET_TAG_FROM_ARM( XSH_DISP_TAB_AFC, instrument);
00662 check( cpl_frame_set_tag( afc_disp_tab_frame, tag));
00663 }
00664
00665 } else {
00666
00667 sprintf(slit_map_tag,"SLIT_MAP_%s",
00668 xsh_instrument_arm_tostring( instrument )) ;
00669
00670 sprintf(wave_map_tag,"WAVE_MAP_%s",
00671 xsh_instrument_arm_tostring( instrument )) ;
00672 check(xsh_create_model_map(model_config_frame,instrument,
00673 wave_map_tag,slit_map_tag,
00674 &wave_map_frame, &slit_map_frame,1));
00675
00676 check(afc_disp_tab_frame=xsh_create_dispersol_physmod(afcatt_rmdark,
00677 afc_order_tab_edges_frame,
00678 model_config_frame,
00679 wave_map_frame,
00680 slit_map_frame,
00681 dispsol_param,
00682 spectralformat_frame,
00683 instrument,1));
00684
00685 }
00686 }
00687
00688
00689
00690 xsh_msg("Saving products");
00691
00692 if ( afc_wave_tab_frame != NULL){
00693 check(xsh_add_product_table( afc_wave_tab_frame, frameset,
00694 parameters, RECIPE_ID, instrument,NULL));
00695 }
00696 if ( afc_config_tab_frame != NULL){
00697 check(xsh_add_product_table( afc_config_tab_frame, frameset,
00698 parameters, RECIPE_ID, instrument,NULL));
00699 }
00700
00701 if ( afc_order_tab_edges_frame != NULL){
00702 check(xsh_add_product_table( afc_order_tab_edges_frame, frameset,
00703 parameters, RECIPE_ID, instrument,NULL));
00704 }
00705 if (afc_disp_tab_frame != NULL){
00706 check( xsh_add_product_table( afc_disp_tab_frame, frameset,
00707 parameters,RECIPE_ID,instrument,NULL));
00708 }
00709
00710 xsh_msg("xsh_flexcomp success !!");
00711
00712 cleanup:
00713 xsh_end( RECIPE_ID, frameset, parameters);
00714
00715 XSH_FREE( detect_arclines_clipping);
00716 XSH_FREE( detect_arclines_p);
00717 XSH_FREE( dispsol_param);
00718
00719 xsh_free_frameset( &raws);
00720 xsh_free_frameset( &calib);
00721 xsh_free_frame( &wave_map_frame);
00722 xsh_free_frame( &slit_map_frame);
00723 xsh_free_frame( &subbias_frame);
00724 xsh_free_frame( &subdark_frame);
00725 xsh_free_frame( &afcatt_rmbias);
00726 xsh_free_frame( &afcatt_rmdark);
00727 xsh_free_frame( &att_resid_tab);
00728 xsh_free_frame( &att_cleanlines);
00729 xsh_free_frame( &afc_wave_tab_frame);
00730 xsh_free_frame( &afc_config_tab_frame);
00731 xsh_free_frame( &afc_order_tab_edges_frame);
00732 xsh_free_frame( &afc_disp_tab_frame);
00733 xsh_free_frame( &afcthetab_frame);
00734 xsh_instrument_free( &instrument);
00735 return;
00736 }
00737