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 = { 6, 3, 0, 5, 5, 0, 2, 5.0,
00193 XSH_GAUSSIAN_METHOD, FALSE};
00194 xsh_dispersol_param dispsol_param = { 4, 5 } ;
00195 char paramname[256];
00196 cpl_parameter* p=NULL;
00197 int ival=DECODE_BP_FLAG_DEF;
00198
00199
00200 xsh_init();
00201
00202
00203 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00204
00205
00206 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00207 CPL_ERROR_TYPE_MISMATCH,
00208 "Plugin is not a recipe");
00209
00210 recipe = (cpl_recipe *)plugin;
00211
00212
00213 recipe->parameters = cpl_parameterlist_new();
00214 assure( recipe->parameters != NULL,
00215 CPL_ERROR_ILLEGAL_OUTPUT,
00216 "Memory allocation failed!");
00217
00218
00219 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
00220 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,ival);
00221 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
00222
00223
00224
00225
00226
00227
00228
00229 check(xsh_parameters_detect_arclines_create(RECIPE_ID,recipe->parameters,
00230 detarc_param));
00231 check(xsh_parameters_clipping_detect_arclines_create(RECIPE_ID,
00232 recipe->parameters, detarc_clip_param));
00233
00234 check(xsh_parameters_dispersol_create(RECIPE_ID,
00235 recipe->parameters,
00236 dispsol_param ));
00237
00238
00239 check( xsh_parameters_new_int( recipe->parameters, RECIPE_ID,
00240 "model-maxit",1000,
00241 "Number/10 of annealing iterations "
00242 "if in physical model mode."));
00243
00244 check( xsh_parameters_new_double( recipe->parameters, RECIPE_ID,
00245 "model-anneal-factor",1.0,
00246 "Multiplier applied to the automatic "
00247 "parameter ranges (i.e. when scenario!=0). "
00248 "For routine operations should be 1.0. "
00249 "(physical model mode)."));
00250
00251
00252 sprintf(paramname,"xsh.%s.%s",RECIPE_ID,"model-scenario");
00253
00254 check(p=cpl_parameter_new_enum(paramname,CPL_TYPE_INT,
00255 "selects preset flag and range combinations "
00256 "appropriate to common scenarios: "
00257 "-1 - Only the position across the slit and"
00258 " camera focal length are open\n"
00259 " 0 - No scenario, input cfg flags and limits"
00260 " used."
00261 " 1 - scenario appropriate for the startup"
00262 " recipe (large ranges for parameters "
00263 " affecting single ph exposures, dist "
00264 " coeff fixed)"
00265 " 2 - Like 1, but includes parameters "
00266 " affecting all ph positions"
00267 " 3 - Scenario for use in fine tuning cfg"
00268 " to match routine wavecal exposures. All"
00269 " parameters affecting 1ph exposures"
00270 " except dist coeffs are included and"
00271 " parameter ranges are small. (For use by"
00272 " flexcomp in 1ph case)."
00273 " 4 - Like 3 but includes parameters"
00274 " affecting all ph positions (Standard for"
00275 " use by flexcomp in 9ph case and 2dmap)."
00276 " 5 - Like 4 but includes also dist coeffs"
00277 " 6 - Just dist coeffs (and chipx, chipy)",
00278 RECIPE_ID,3,9,-1,0,1,2,3,4,5,6,8));
00279
00280
00281 check(cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,
00282 "model-scenario"));
00283 check(cpl_parameterlist_append(recipe->parameters,p));
00284
00285
00286 cleanup:
00287 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
00288 xsh_error_dump(CPL_MSG_ERROR);
00289 return 1;
00290 }
00291 else {
00292 return 0;
00293 }
00294 }
00295
00296
00302
00303
00304 static int xsh_flexcomp_exec(cpl_plugin *plugin) {
00305 cpl_recipe *recipe = NULL;
00306
00307
00308 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00309
00310
00311 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00312 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00313
00314 recipe = (cpl_recipe *)plugin;
00315
00316
00317 xsh_flexcomp(recipe->parameters, recipe->frames);
00318
00319 cleanup:
00320 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
00321 xsh_error_dump(CPL_MSG_ERROR);
00322 cpl_error_reset();
00323 return 1;
00324 }
00325 else {
00326 return 0;
00327 }
00328 }
00329
00330
00336
00337 static int xsh_flexcomp_destroy(cpl_plugin *plugin)
00338 {
00339 cpl_recipe *recipe = NULL;
00340
00341
00342 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00343
00344
00345 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00346 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00347
00348 recipe = (cpl_recipe *)plugin;
00349
00350 xsh_free_parameterlist(&recipe->parameters);
00351
00352 cleanup:
00353 if (cpl_error_get_code() != CPL_ERROR_NONE)
00354 {
00355 return 1;
00356 }
00357 else
00358 {
00359 return 0;
00360 }
00361 }
00362
00363 static cpl_error_code
00364 xsh_params_set_defaults(cpl_parameterlist* pars,
00365 xsh_instrument* inst,
00366 xsh_detect_arclines_param* detect_arclines_p)
00367 {
00368 cpl_parameter* p=NULL;
00369
00370 check(p=xsh_parameters_find(pars,RECIPE_ID,"detectarclines-min-sn"));
00371 if(cpl_parameter_get_double(p) <= 0) {
00372 if (xsh_instrument_get_arm(inst) == XSH_ARM_NIR){
00373
00374 cpl_parameter_set_double(p,4);
00375 detect_arclines_p->min_sn=4;
00376 } else {
00377 cpl_parameter_set_double(p,3);
00378 detect_arclines_p->min_sn=3;
00379 }
00380 }
00381
00382 cleanup:
00383
00384 return cpl_error_get_code();
00385
00386 }
00387
00388 static cpl_error_code
00389 xsh_frame_check_is_right_afcatt(cpl_frame* afcatt_frame,
00390 xsh_instrument* instrument)
00391 {
00392 cpl_propertylist* plist=NULL;
00393 const char* name=NULL;
00394 char* slit_value=NULL;
00395 name=cpl_frame_get_filename(afcatt_frame);
00396 plist=cpl_propertylist_load(name,0);
00397 check(slit_value=xsh_pfits_get_slit_value (plist,instrument));
00398 if (strcmp(slit_value,"Pin_0.5") != 0 ) {
00399 xsh_msg_error("INS OPTIi NAME value=%s",slit_value);
00400 xsh_msg_error("Your input AFC frame should be the 1st of the AFC sequence");
00401 xsh_msg_error("Its INS OPTIi NAME key value should be 'Pin_0.5'");
00402 cpl_error_set(cpl_func, CPL_ERROR_ILLEGAL_INPUT);
00403 }
00404
00405 cleanup:
00406 xsh_free_propertylist(&plist);
00407
00408 return cpl_error_get_code();
00409
00410
00411 }
00412
00413
00421
00422 static void xsh_flexcomp(cpl_parameterlist* parameters, cpl_frameset* frameset)
00423 {
00424 const char* recipe_tags[1] = {XSH_AFC_ATT};
00425 int recipe_tags_size = 1;
00426
00427
00428 xsh_clipping_param* detect_arclines_clipping = NULL;
00429 xsh_detect_arclines_param* detect_arclines_p = NULL;
00430 xsh_dispersol_param *dispsol_param = NULL ;
00431
00432
00433 cpl_frameset* raws = NULL;
00434 cpl_frameset* calib = NULL;
00435 xsh_instrument* instrument = NULL;
00436
00437 cpl_frame* arclist_frame = NULL;
00438 cpl_frame* afcatt_frame = NULL;
00439 cpl_frame* spectralformat_frame = NULL;
00440 cpl_frame* order_tab_edges_frame = NULL;
00441 cpl_frame* wave_tab_frame = NULL;
00442
00443 cpl_frame* wave_map_frame = NULL;
00444 cpl_frame* slit_map_frame = NULL;
00445
00446 cpl_frame* model_config_frame = NULL;
00447 cpl_frame* masterbias_frame = NULL;
00448 cpl_frame* masterdark_frame = NULL;
00449 cpl_frame* bpmap_frame = NULL;
00450
00451 cpl_frame *subbpmap_frame = NULL;
00452 cpl_frame *subbias_frame = NULL;
00453 cpl_frame *subdark_frame = NULL;
00454 int afc_xmin=1;
00455
00456 int afc_ymin=1;
00457
00458 int afc_order=0;
00459 cpl_frame* afcatt_rmbias = NULL;
00460 cpl_frame* afcatt_rmdark = NULL;
00461 cpl_frame* att_cleanlines = NULL;
00462 cpl_frame* att_resid_tab = NULL;
00463 cpl_frame *afcthetab_frame = NULL;
00464 const char *tag = NULL;
00465 char filename [256];
00466 cpl_frame *afc_wave_tab_frame = NULL;
00467 cpl_frame *afc_order_tab_edges_frame = NULL;
00468 cpl_frame *afc_disp_tab_frame = NULL;
00469 cpl_frame *afc_config_tab_frame = NULL;
00470 XSH_ARM arm = XSH_ARM_UNDEFINED;
00471 int pre_overscan_corr=0;
00472
00473 char wave_map_tag[256];
00474 char slit_map_tag[256];
00475 int nraws=0;
00476 cpl_boolean mode_phys;
00477
00478 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
00479 recipe_tags, recipe_tags_size,
00480 RECIPE_ID, XSH_BINARY_VERSION,
00481 xsh_flexcomp_description_short));
00482 nraws=cpl_frameset_get_size(raws);
00483 assure(nraws > 0, CPL_ERROR_NULL_INPUT, "Provide an input AFC_ATT_ARM frame");
00484
00485 xsh_recipe_params_check(parameters,instrument,RECIPE_ID);
00486
00487
00488
00489 mode_phys=xsh_mode_is_physmod(calib,instrument);
00490 check(bpmap_frame=xsh_check_load_master_bpmap(calib,instrument,RECIPE_ID));
00491 check( arclist_frame = xsh_find_frame_with_tag( calib,
00492 XSH_ARC_LINE_LIST_AFC,
00493 instrument));
00494 XSH_ASSURE_NOT_NULL_MSG( arclist_frame,
00495 "No input ARC_LINE_AFC_LIST_ARM arclines list provided");
00496 check( spectralformat_frame = xsh_find_frame_with_tag( calib,
00497 XSH_SPECTRAL_FORMAT, instrument));
00498 XSH_ASSURE_NOT_NULL_MSG( spectralformat_frame,
00499 "No spectral format provided");
00500 check( order_tab_edges_frame = xsh_find_order_tab_edges( calib,instrument));
00501 XSH_ASSURE_NOT_NULL_MSG( order_tab_edges_frame,
00502 "No input ORDER_TABLE_EDGES_MODE_ARM (MODE=IFU or SLIT) table provided");
00503
00504
00505 if(!mode_phys) {
00506 wave_tab_frame = xsh_find_wave_tab( calib, instrument);
00507 } else {
00508
00509 if ( (model_config_frame = xsh_find_frame_with_tag( calib,
00510 XSH_MOD_CFG_OPT_2D, instrument)) == NULL) {
00511 xsh_error_reset();
00512 if ((model_config_frame = xsh_find_frame_with_tag(calib,
00513 XSH_MOD_CFG_TAB, instrument)) == NULL) {
00514 xsh_error_reset();
00515 }
00516 }
00517 }
00518 if( (model_config_frame!=NULL) && (wave_tab_frame != NULL) ) {
00519
00520 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",
00521 XSH_WAVE_TAB_2D , XSH_MOD_CFG_TAB);
00522 goto cleanup;
00523 }
00524
00525 if((model_config_frame==NULL) && ( wave_tab_frame == NULL) ) {
00526 xsh_msg_error("You must provide either a %s or a %s frame",
00527 XSH_WAVE_TAB_2D, XSH_MOD_CFG_TAB);
00528 goto cleanup;
00529 }
00530
00531 check( arm = xsh_instrument_get_arm(instrument));
00532
00533 if ( arm != XSH_ARM_NIR){
00534 if((masterbias_frame = xsh_find_frame_with_tag(calib,XSH_MASTER_BIAS,
00535 instrument)) == NULL) {
00536
00537 xsh_msg_warning("Frame %s not provided",XSH_MASTER_BIAS);
00538 xsh_error_reset();
00539 }
00540
00541 if((masterdark_frame = xsh_find_frame_with_tag(calib,XSH_MASTER_DARK,
00542 instrument)) == NULL){
00543 xsh_msg_warning("Frame %s not provided",XSH_MASTER_DARK);
00544 xsh_error_reset();
00545 }
00546 }
00547 check( xsh_instrument_update_from_spectralformat( instrument,
00548 spectralformat_frame));
00549 check( pre_overscan_corr = xsh_parameters_get_int( parameters, RECIPE_ID,
00550 "pre-overscan-corr"));
00551
00552
00553
00554
00555 check(detect_arclines_clipping =
00556 xsh_parameters_clipping_detect_arclines_get(RECIPE_ID, parameters));
00557 check(detect_arclines_p = xsh_parameters_detect_arclines_get(RECIPE_ID,
00558 parameters));
00559 check( dispsol_param = xsh_parameters_dispersol_get( RECIPE_ID, parameters));
00560 check(xsh_params_set_defaults(parameters,instrument,detect_arclines_p));
00561
00562
00563
00564
00565 int afc_xmax=1;
00566 int afc_ymax=1;
00567 if (arm != XSH_ARM_NIR){
00568
00569 if ( arm == XSH_ARM_VIS){
00570 afc_xmin = XSH_AFC_VIS_XMIN-10;
00571 afc_xmax = XSH_AFC_VIS_XMAX-10;
00572 afc_ymin = XSH_AFC_VIS_YMIN;
00573 afc_ymax = XSH_AFC_VIS_YMAX;
00574 afc_order = XSH_AFC_VIS_ORDER;
00575 }
00576 else {
00577 afc_xmin = 2145-XSH_AFC_UVB_XMAX-48;
00578 afc_xmax = 2145-XSH_AFC_UVB_XMIN-48;
00579 afc_ymin = 3001-XSH_AFC_UVB_YMAX;
00580 afc_ymax = 3001-XSH_AFC_UVB_YMIN;
00581 afc_order = XSH_AFC_UVB_ORDER;
00582 }
00583 xsh_msg("AFC pre coordinates (%d,%d, %d,%d)",afc_xmin,afc_ymin,
00584 afc_xmax,afc_ymax);
00585
00586 if ( bpmap_frame != NULL){
00587 check( subbpmap_frame = xsh_badpixelmap_extract( bpmap_frame,
00588 afc_xmin, afc_ymin, afc_xmax, afc_ymax));
00589 }
00590
00591 if ( masterbias_frame != NULL){
00592 check( subbias_frame = xsh_preframe_extract( masterbias_frame,
00593 afc_xmin, afc_ymin, afc_xmax, afc_ymax,
00594 "TEST_SUBBIAS.fits", instrument));
00595 }
00596
00597 if ( masterdark_frame != NULL){
00598 check( subdark_frame = xsh_preframe_extract( masterdark_frame,
00599 afc_xmin, afc_ymin, afc_xmax, afc_ymax,
00600 "TEST_SUBDARK.fits", instrument));
00601
00602 }
00603 }
00604 check( xsh_prepare( raws, subbpmap_frame, subbias_frame, XSH_AFC_ATT,
00605 instrument,pre_overscan_corr,CPL_TRUE));
00606
00607 check( afcatt_frame = cpl_frameset_get_first( raws));
00608 check( xsh_frame_check_is_right_afcatt(afcatt_frame,instrument));
00609
00610 if( subbias_frame != NULL) {
00611
00612 check( afcatt_rmbias = xsh_subtract_bias( afcatt_frame, subbias_frame,
00613 instrument,"AFC_ATT_",
00614 pre_overscan_corr,1));
00615 }
00616 else {
00617 afcatt_rmbias =cpl_frame_duplicate( afcatt_frame);
00618 }
00619
00620 if( subdark_frame != NULL) {
00621
00622 sprintf( filename, "AFCATT_DARK_%s.fits",
00623 xsh_instrument_arm_tostring( instrument));
00624 check( afcatt_rmdark = xsh_subtract_dark( afcatt_rmbias, subdark_frame,
00625 filename, instrument));
00626 }
00627 else {
00628 afcatt_rmdark =cpl_frame_duplicate( afcatt_rmbias);
00629 }
00630 check( afcthetab_frame = xsh_afcthetab_create( wave_tab_frame,
00631 model_config_frame, afc_order, spectralformat_frame,
00632 arclist_frame, afc_xmin, afc_ymin,
00633 instrument,1));
00634
00635
00636 check( xsh_detect_arclines( afcatt_rmdark, afcthetab_frame,
00637 arclist_frame, NULL, NULL,
00638 NULL, spectralformat_frame, NULL,
00639 &att_cleanlines, NULL, &att_resid_tab, XSH_SOLUTION_RELATIVE,
00640 detect_arclines_p,
00641 detect_arclines_clipping,
00642 instrument,RECIPE_ID,1,0));
00643
00644
00645 check( afc_wave_tab_frame = xsh_flexcor( afcatt_frame, wave_tab_frame,
00646 model_config_frame,
00647 order_tab_edges_frame, att_resid_tab,
00648 afc_xmin, afc_ymin, instrument,
00649 &afc_order_tab_edges_frame,
00650 &afc_config_tab_frame));
00651
00652 if(model_config_frame == NULL) {
00653
00654
00655 if ( wave_tab_frame != NULL){
00656 check( xsh_create_poly_wavemap( NULL, wave_tab_frame,
00657 afc_order_tab_edges_frame,
00658 spectralformat_frame,
00659 dispsol_param,
00660 instrument,
00661 "AFC_",
00662 &afc_disp_tab_frame, NULL));
00663
00664 tag = XSH_GET_TAG_FROM_ARM( XSH_DISP_TAB_AFC, instrument);
00665 check( cpl_frame_set_tag( afc_disp_tab_frame, tag));
00666 }
00667
00668 } else {
00669
00670 sprintf(slit_map_tag,"SLIT_MAP_%s",
00671 xsh_instrument_arm_tostring( instrument )) ;
00672
00673 sprintf(wave_map_tag,"WAVE_MAP_%s",
00674 xsh_instrument_arm_tostring( instrument )) ;
00675 check(xsh_create_model_map(model_config_frame,instrument,
00676 wave_map_tag,slit_map_tag,
00677 &wave_map_frame, &slit_map_frame,1));
00678
00679 check(afc_disp_tab_frame=xsh_create_dispersol_physmod(afcatt_rmdark,
00680 afc_order_tab_edges_frame,
00681 model_config_frame,
00682 wave_map_frame,
00683 slit_map_frame,
00684 dispsol_param,
00685 spectralformat_frame,
00686 instrument,1));
00687
00688 }
00689
00690
00691
00692
00693 xsh_msg("Saving products");
00694
00695 if ( afc_wave_tab_frame != NULL){
00696 check(xsh_add_product_table( afc_wave_tab_frame, frameset,
00697 parameters, RECIPE_ID, instrument,NULL));
00698 }
00699 if ( afc_config_tab_frame != NULL){
00700 check(xsh_add_product_table( afc_config_tab_frame, frameset,
00701 parameters, RECIPE_ID, instrument,NULL));
00702 }
00703
00704 if ( afc_order_tab_edges_frame != NULL){
00705 check(xsh_add_product_table( afc_order_tab_edges_frame, frameset,
00706 parameters, RECIPE_ID, instrument,NULL));
00707 }
00708 if (afc_disp_tab_frame != NULL){
00709 check( xsh_add_product_table( afc_disp_tab_frame, frameset,
00710 parameters,RECIPE_ID,instrument,NULL));
00711 }
00712
00713 xsh_msg("xsh_flexcomp success !!");
00714
00715 cleanup:
00716 xsh_end( RECIPE_ID, frameset, parameters);
00717
00718 XSH_FREE( detect_arclines_clipping);
00719 XSH_FREE( detect_arclines_p);
00720 XSH_FREE( dispsol_param);
00721
00722 xsh_free_frameset( &raws);
00723 xsh_free_frameset( &calib);
00724 xsh_free_frame( &bpmap_frame);
00725 xsh_free_frame( &wave_map_frame);
00726 xsh_free_frame( &slit_map_frame);
00727 xsh_free_frame( &subbpmap_frame);
00728 xsh_free_frame( &subbias_frame);
00729 xsh_free_frame( &subdark_frame);
00730 xsh_free_frame( &afcatt_rmbias);
00731 xsh_free_frame( &afcatt_rmdark);
00732 xsh_free_frame( &att_resid_tab);
00733 xsh_free_frame( &att_cleanlines);
00734 xsh_free_frame( &afc_wave_tab_frame);
00735 xsh_free_frame( &afc_config_tab_frame);
00736 xsh_free_frame( &afc_order_tab_edges_frame);
00737 xsh_free_frame( &afc_disp_tab_frame);
00738 xsh_free_frame( &afcthetab_frame);
00739 xsh_instrument_free( &instrument);
00740 return;
00741 }
00742