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
00044
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #include <xsh_error.h>
00057
00058 #include <xsh_utils.h>
00059 #include <xsh_msg.h>
00060
00061 #include <xsh_dfs.h>
00062 #include <xsh_pfits.h>
00063 #include <xsh_utils_table.h>
00064 #include <xsh_data_resid_tab.h>
00065
00066 #include <xsh_data_order.h>
00067 #include <xsh_drl.h>
00068 #include <xsh_drl_check.h>
00069 #include <xsh_model_kernel.h>
00070 #include <xsh_model_arm_constants.h>
00071
00072
00073
00074 #include <cpl.h>
00075
00076
00077
00078
00079
00080 #define RECIPE_ID "xsh_predict"
00081 #define RECIPE_AUTHOR "P.Goldoni, L.Guglielmi, R. Haigron, F. Royer"
00082 #define RECIPE_CONTACT "amodigli@eso.org"
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 static int xsh_predict_create(cpl_plugin *);
00093 static int xsh_predict_exec(cpl_plugin *);
00094 static int xsh_predict_destroy(cpl_plugin *);
00095
00096
00097 static void xsh_predict(cpl_parameterlist *, cpl_frameset *);
00098
00099
00100
00101
00102 static char xsh_predict_description_short[] =
00103 "Compute a first guess dispersion solution and order table";
00104
00105 static char xsh_predict_description[] =
00106 "This recipe creates a wavelength solution and an order table.\n\
00107 Input Frames :\n\
00108 - [UVB, VIS] One RAW frame (Format = RAW, Tag = FMTCHK_arm)\n\
00109 - [NIR] Two RAW frames ((Format = RAW, Tag = FMTCHK_arm_ON,\
00110 FMTCHK_arm_OFF)\n\
00111 - A spectral format table (Format = PRE, Tag = SPECTRAL_FORMAT_TAB_arm)\n\
00112 - An arc line list (Format = TABLE, Tag = ARC_LINE_LIST_arm)\n\
00113 - [UVB,VIS,OPTIONAL] A master bias (Format = PRE, Tag = MASTER_BIAS_arm)\n\
00114 - [UVB,VIS,OPTIONAL] A master dark (Format = PRE, Tag = MASTER_DARK_arm)\n\
00115 - [OPTIONAL] A reference badpixel map (Format = QUP, Tag = BP_MAP_RP_arm)\n\
00116 - [OPTIONAL] A non-linear badpixel map (Format = QUP, Tag = BP_MAP_NL_arm)\n\
00117 - [OPTIONAL] Reference list to monitor line intensity (Tag = ARC_LINE_LIST_INTMON_arm)\n \
00118 - [poly mode] A theoretical map (Format = TABLE, Tag = THEO_TAB_SING_arm)\n\
00119 - [physical model mode] A model cfg table (Format = TABLE, Tag = XSH_MOD_CFG_TAB_arm)\n\
00120 Products : \n\
00121 - An updated clean arc line list, PRO.CATG=ARC_LINE_LIST_PREDICT_arm.\n\
00122 - [poly mode] A wavelength solution (Format = TABLE, PRO.CATG = \
00123 WAVE_TAB_GUESS_arm)\n\
00124 - An order table, PRO.CATG = ORDER_TABLE_GUESS_arm\n\
00125 (if at least degree+1 points are found in each order).\n \
00126 - A line identification residual table, PRO.CATG = FMTCHK_RESID_TAB_LINES_arm\n\
00127 - The bias subtracted formatcheck frame, PRO.CATG = FMTCHK_ON_arm\n\
00128 - [physical model mode]An optimized model configuration table, PRO.CATG = XSH_MOD_CFG_OPT_FMT_ARM\n\
00129 Prepare the frames.\n\
00130 For UVB,VIS :\n\
00131 Subtract Master Bias.\n\
00132 Subtract Master Dark\n\
00133 For NIR:\n\
00134 Subtract ON OFF\n\
00135 Compute guess order table and wavelength solution\n";
00136
00137
00138
00139
00140
00149
00150
00151 int cpl_plugin_get_info(cpl_pluginlist *list) {
00152 cpl_recipe *recipe = NULL;
00153 cpl_plugin *plugin = NULL;
00154
00155 recipe = cpl_calloc(1, sizeof(*recipe));
00156 if ( recipe == NULL ){
00157 return -1;
00158 }
00159
00160 plugin = &recipe->interface ;
00161
00162 cpl_plugin_init(plugin,
00163 CPL_PLUGIN_API,
00164 XSH_BINARY_VERSION,
00165 CPL_PLUGIN_TYPE_RECIPE,
00166 RECIPE_ID,
00167 xsh_predict_description_short,
00168 xsh_predict_description,
00169 RECIPE_AUTHOR,
00170 RECIPE_CONTACT,
00171 xsh_get_license(),
00172 xsh_predict_create,
00173 xsh_predict_exec,
00174 xsh_predict_destroy);
00175
00176 cpl_pluginlist_append(list, plugin);
00177
00178 return (cpl_error_get_code() != CPL_ERROR_NONE);
00179 }
00180
00181
00191
00192
00193 static int xsh_predict_create(cpl_plugin *plugin){
00194 cpl_recipe *recipe = NULL;
00195 xsh_clipping_param detarc_clip_param = { 2.0, 10, 0.7, 0, 0.3};
00196 xsh_detect_arclines_param detarc_param = {-1.0, 2, 0, 5, 5, 0, 2, -1.0,
00197 XSH_GAUSSIAN_METHOD, FALSE};
00198 char paramname[256];
00199 cpl_parameter* p=NULL;
00200
00201
00202 xsh_init();
00203
00204
00205 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00206
00207
00208 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00209 CPL_ERROR_TYPE_MISMATCH,
00210 "Plugin is not a recipe");
00211
00212 recipe = (cpl_recipe *)plugin;
00213
00214
00215 recipe->parameters = cpl_parameterlist_new();
00216 assure( recipe->parameters != NULL,
00217 CPL_ERROR_ILLEGAL_OUTPUT,
00218 "Memory allocation failed!");
00219
00220
00221 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
00222 check( xsh_parameters_pre_overscan( RECIPE_ID, recipe->parameters ) ) ;
00223
00224
00225
00226 check(xsh_parameters_detect_arclines_create(RECIPE_ID,recipe->parameters,
00227 detarc_param));
00228 check(xsh_parameters_clipping_detect_arclines_create(RECIPE_ID,
00229 recipe->parameters, detarc_clip_param));
00230
00231
00232
00233
00234 check( xsh_parameters_new_int( recipe->parameters, RECIPE_ID,
00235 "model-maxit",1000,
00236 "Number/10 of annealing iterations "
00237 "if in physical model mode."));
00238
00239 check( xsh_parameters_new_double( recipe->parameters, RECIPE_ID,
00240 "model-anneal-factor",1.0,
00241 "Multiplier applied to the automatic "
00242 "parameter ranges (i.e. when scenario!=0). "
00243 "For routine operations should be 1.0. "
00244 "(physical model mode)."));
00245
00246
00247 sprintf(paramname,"xsh.%s.%s",RECIPE_ID,"model-scenario");
00248
00249
00250 check(p=cpl_parameter_new_enum(paramname,CPL_TYPE_INT,
00251 "selects preset flag and range combinations "
00252 "appropriate to common scenarios: \n"
00253
00254
00255 " 0 - No scenario, input cfg flags and limits "
00256 "used.\n"
00257 " 1 - scenario appropriate for the startup "
00258 "recipe (large ranges for parameters "
00259 "affecting single ph exposures, dist "
00260 "coeff fixed).\n"
00261 " 2 - Like 1, but includes parameters "
00262 "affecting all ph positions.\n"
00263 " 3 - Scenario for use in fine tuning cfg "
00264 "to match routine single pinhole exposures. "
00265 "All parameters affecting 1ph exposures "
00266 "except dist coeffs are included and "
00267 "parameter ranges are small. (For use by "
00268 "predict in 1ph case).\n"
00269 " 4 - Like 3 but includes parameters "
00270 "affecting all ph positions (Standard for "
00271 "use by predict in 9ph case and 2dmap). \n"
00272
00273
00274 ,RECIPE_ID,3,9,-1,0,1,2,3,4,5,6,8));
00275
00276
00277 check(cpl_parameter_set_alias(p,CPL_PARAMETER_MODE_CLI,
00278 "model-scenario"));
00279 check(cpl_parameterlist_append(recipe->parameters,p));
00280
00281
00282 cleanup:
00283 if ( cpl_error_get_code() != CPL_ERROR_NONE ){
00284 xsh_error_dump(CPL_MSG_ERROR);
00285 return 1;
00286 }
00287 else {
00288 return 0;
00289 }
00290 }
00291
00292
00298
00299
00300 static int xsh_predict_exec(cpl_plugin *plugin) {
00301 cpl_recipe *recipe = NULL;
00302
00303
00304 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00305
00306
00307 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00308 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00309
00310 recipe = (cpl_recipe *)plugin;
00311
00312
00313 xsh_predict(recipe->parameters, recipe->frames);
00314
00315 cleanup:
00316 if ( cpl_error_get_code() != CPL_ERROR_NONE ) {
00317 xsh_error_dump(CPL_MSG_ERROR);
00318 cpl_error_reset();
00319 return 1;
00320 }
00321 else {
00322 return 0;
00323 }
00324 }
00325
00326
00332
00333 static int xsh_predict_destroy(cpl_plugin *plugin)
00334 {
00335 cpl_recipe *recipe = NULL;
00336
00337
00338 assure( plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin" );
00339
00340
00341 assure( cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00342 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00343
00344 recipe = (cpl_recipe *)plugin;
00345
00346 xsh_free_parameterlist(&recipe->parameters);
00347
00348 cleanup:
00349 if (cpl_error_get_code() != CPL_ERROR_NONE)
00350 {
00351 return 1;
00352 }
00353 else
00354 {
00355 return 0;
00356 }
00357 }
00358
00359 static cpl_error_code
00360 xsh_params_set_defaults(cpl_parameterlist* pars,
00361 xsh_instrument* inst,
00362 xsh_detect_arclines_param* detect_arclines_p)
00363 {
00364 cpl_parameter* p=NULL;
00365
00366 check(p=xsh_parameters_find(pars,RECIPE_ID,"detectarclines-min-sn"));
00367 if(cpl_parameter_get_double(p) <= 0) {
00368 if (xsh_instrument_get_arm(inst) == XSH_ARM_NIR){
00369 detect_arclines_p->min_sn=4;
00370 } else {
00371 detect_arclines_p->min_sn=5.0;
00372 }
00373 }
00374 check(p=xsh_parameters_find(pars,RECIPE_ID,"detectarclines-fit-window-half-size"));
00375 if(cpl_parameter_get_int(p) <= 0) {
00376 if (xsh_instrument_get_arm(inst) == XSH_ARM_UVB){
00377 detect_arclines_p->fit_window_hsize=5;
00378 } else {
00379 detect_arclines_p->fit_window_hsize=4;
00380 }
00381 }
00382 cleanup:
00383
00384 return cpl_error_get_code();
00385
00386 }
00387
00388
00396
00397 static void xsh_predict(cpl_parameterlist* parameters, cpl_frameset* frameset)
00398 {
00399 const char* recipe_tags[1] = {XSH_FMTCHK};
00400 int recipe_tags_size = 1;
00401 char tag[80];
00402
00403 xsh_clipping_param* detect_arclines_clipping = NULL;
00404 xsh_detect_arclines_param* detect_arclines_p = NULL;
00405
00406
00407 cpl_frameset* raws = NULL;
00408 cpl_frameset* calib = NULL;
00409 cpl_frameset* on = NULL;
00410 cpl_frameset* off = NULL;
00411 cpl_frameset* on_off = NULL;
00412 cpl_frame* predict_rmbias = NULL;
00413 cpl_frame* predict_rmdark = NULL;
00414 xsh_instrument* instrument = NULL;
00415 int solution_type=XSH_DETECT_ARCLINES_TYPE_MODEL;
00416
00417 cpl_frame* model_config_frame = NULL;
00418 cpl_frame* spectralformat_frame = NULL;
00419 cpl_frame* bpmap = NULL;
00420 cpl_frame* master_bias = NULL;
00421 cpl_frame* master_dark = NULL;
00422 cpl_frame* theo_tab_sing = NULL;
00423 cpl_frame* resid_map = NULL;
00424 cpl_frame* resid_dan = NULL;
00425 cpl_frame* resid_tab_orders_frame = NULL;
00426 cpl_frame *wave_tab_guess_frame = NULL;
00427 cpl_frame *order_tab_recov_frame = NULL;
00428 cpl_frame* arclines = NULL;
00429 cpl_frame* clean_arclines = NULL;
00430 cpl_frame* guess_order_table = NULL;
00431 cpl_frame* guess_wavesol = NULL;
00432 const char* filename=NULL;
00433 cpl_frame* MODEL_CONF_OPT_frame=NULL;
00434
00435 XSH_INSTRCONFIG * config = NULL;
00436 int maxit=200;
00437 double ann_fac=1.0;
00438 int scenario=3;
00439
00440 char paramname[256];
00441 cpl_parameter * p =NULL;
00442 int pre_overscan_corr=0;
00443 cpl_frame * line_intmon = NULL ;
00444 double exptime=0;
00445 cpl_propertylist* plist=NULL;
00446 cpl_boolean mode_phys;
00447 int resid_name_sw=0;
00448
00449
00450
00451 check( xsh_begin( frameset, parameters, &instrument, &raws, &calib,
00452 recipe_tags, recipe_tags_size,
00453 RECIPE_ID, XSH_BINARY_VERSION,
00454 xsh_predict_description_short ) ) ;
00455 check( xsh_instrument_set_mode( instrument, XSH_MODE_SLIT));
00456
00457 xsh_recipe_params_check(parameters,instrument,RECIPE_ID);
00458
00459
00460
00461 mode_phys=xsh_mode_is_physmod(calib,instrument);
00462 check(bpmap=xsh_check_load_master_bpmap(calib,instrument,RECIPE_ID));
00463 check( arclines = xsh_find_arc_line_list( calib, instrument));
00464 check( spectralformat_frame = xsh_find_frame_with_tag( calib,
00465 XSH_SPECTRAL_FORMAT, instrument));
00466
00467
00468 if (!mode_phys) {
00469 theo_tab_sing = xsh_find_frame_with_tag( calib, XSH_THEO_TAB_SING,
00470 instrument);
00471 wave_tab_guess_frame = xsh_find_frame_with_tag( calib, XSH_WAVE_TAB_GUESS,
00472 instrument);
00473 order_tab_recov_frame = xsh_find_frame_with_tag( calib, XSH_ORDER_TAB_RECOV,
00474 instrument);
00475 solution_type = XSH_DETECT_ARCLINES_TYPE_POLY;
00476 } else {
00477 if( NULL == (model_config_frame = xsh_find_frame_with_tag( calib,
00478 XSH_MOD_CFG_TAB,
00479 instrument))){
00480
00481
00482 model_config_frame=xsh_find_frame_with_tag( calib, XSH_MOD_CFG_OPT_REC,
00483 instrument);
00484 }
00485 solution_type = XSH_DETECT_ARCLINES_TYPE_MODEL;
00486 }
00487
00488
00489 if ( xsh_instrument_get_arm(instrument) != XSH_ARM_NIR){
00490
00491 XSH_ASSURE_NOT_ILLEGAL_MSG(cpl_frameset_get_size(raws) == 1,
00492 "Provide one formatcheck frame for UVB,VIS arm");
00493 if((master_bias = xsh_find_frame_with_tag(calib,XSH_MASTER_BIAS,
00494 instrument)) == NULL) {
00495
00496 xsh_msg_warning("Frame %s not provided",XSH_MASTER_BIAS);
00497 xsh_error_reset();
00498 }
00499
00500 if((master_dark = xsh_find_frame_with_tag(calib,XSH_MASTER_DARK,
00501 instrument)) == NULL){
00502 xsh_msg_warning("Frame %s not provided",XSH_MASTER_DARK);
00503 xsh_error_reset();
00504 }
00505 }
00506
00507 else {
00508
00509 check(xsh_dfs_split_nir(raws,&on,&off));
00510 XSH_ASSURE_NOT_ILLEGAL_MSG(cpl_frameset_get_size(on) == 1,
00511 "Provide one formatcheck on frame for NIR arm");
00512 XSH_ASSURE_NOT_ILLEGAL_MSG(cpl_frameset_get_size(off) == 1,
00513 "Provide one formatcheck off frame for NIR arm");
00514 }
00515 check( xsh_instrument_update_from_spectralformat( instrument,
00516 spectralformat_frame));
00517 check( config = xsh_instrument_get_config( instrument));
00518
00519
00520 if((line_intmon = xsh_find_frame_with_tag( calib, XSH_ARC_LINE_LIST_INTMON,
00521 instrument)) == NULL) {
00522 xsh_error_reset();
00523 }
00524
00525
00526
00527 check(detect_arclines_clipping =
00528 xsh_parameters_clipping_detect_arclines_get(RECIPE_ID, parameters));
00529 check(detect_arclines_p = xsh_parameters_detect_arclines_get(RECIPE_ID,
00530 parameters));
00531 check( pre_overscan_corr = xsh_parameters_get_int( parameters, RECIPE_ID,
00532 "pre-overscan-corr"));
00533
00534 check(xsh_params_set_defaults(parameters,instrument,detect_arclines_p));
00535
00536
00537
00538
00539
00540
00541 if ( xsh_instrument_get_arm(instrument) != XSH_ARM_NIR){
00542 cpl_frame* fmtchk = NULL;
00543
00544
00545 check(xsh_prepare( raws, bpmap, master_bias, XSH_FMTCHK, instrument,
00546 pre_overscan_corr));
00547 check(fmtchk = cpl_frameset_get_first(raws));
00548
00549 if(master_bias != NULL) {
00550
00551 check(predict_rmbias = xsh_subtract_bias(fmtchk,master_bias,
00552 instrument,"FMTCHK_",
00553 pre_overscan_corr,0));
00554 } else {
00555 predict_rmbias =cpl_frame_duplicate(fmtchk);
00556 }
00557
00558 if(master_dark != NULL) {
00559
00560 filename = xsh_stringcat_any( "FMTCHK_DARK_",
00561 xsh_instrument_arm_tostring( instrument ),
00562 ".fits", NULL ) ;
00563
00564
00565 check(predict_rmdark = xsh_subtract_dark(predict_rmbias, master_dark,
00566 filename, instrument));
00567 } else {
00568 predict_rmdark =cpl_frame_duplicate(predict_rmbias);
00569 }
00570
00571 }
00572
00573 else{
00574
00575 check(xsh_prepare(on,bpmap, NULL, "ON", instrument,pre_overscan_corr));
00576
00577 check(xsh_prepare(off,bpmap, NULL, "OFF", instrument,pre_overscan_corr));
00578
00579
00580 check(on_off = xsh_subtract_nir_on_off(on, off, instrument));
00581 check(predict_rmdark = cpl_frame_duplicate(
00582 cpl_frameset_get_first(on_off)));
00583 }
00584
00585 if ( xsh_instrument_get_arm(instrument) != XSH_ARM_NIR){
00586 check(xsh_check_input_is_unbinned(predict_rmdark));
00587 }
00588 plist=cpl_propertylist_load(cpl_frame_get_filename(predict_rmdark),0);
00589 exptime=xsh_pfits_get_exptime(plist);
00590 xsh_free_propertylist(&plist);
00591
00592 xsh_msg("Calling the xsh_detect_arclines");
00593
00594
00595
00596 if(model_config_frame!=NULL) {
00597 resid_name_sw=1;
00598 check( xsh_detect_arclines_dan( predict_rmdark, theo_tab_sing,
00599 arclines, wave_tab_guess_frame,
00600 order_tab_recov_frame,
00601 model_config_frame,
00602 spectralformat_frame,
00603 &resid_tab_orders_frame,
00604 &clean_arclines, &guess_wavesol,
00605 &resid_dan, XSH_SOLUTION_RELATIVE,
00606 detect_arclines_p,
00607 detect_arclines_clipping,
00608 instrument,RECIPE_ID,0,resid_name_sw));
00609
00610 xsh_free_frame(&clean_arclines);
00611 xsh_free_frame(&guess_wavesol);
00612 xsh_free_frame(&resid_tab_orders_frame);
00613 }
00614
00615
00616 check( xsh_detect_arclines( predict_rmdark, theo_tab_sing,
00617 arclines, wave_tab_guess_frame,
00618 order_tab_recov_frame,
00619 model_config_frame,
00620 spectralformat_frame,
00621 &resid_tab_orders_frame,
00622 &clean_arclines, &guess_wavesol,
00623 &resid_map, XSH_SOLUTION_RELATIVE,
00624 detect_arclines_p,
00625 detect_arclines_clipping,
00626 instrument,RECIPE_ID,0,resid_name_sw));
00627
00628 if ( model_config_frame != NULL){
00629 xsh_msg("Produce new config file");
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646 sprintf(paramname,"xsh.%s.%s",RECIPE_ID, "model-maxit");
00647 check(p = cpl_parameterlist_find(parameters,paramname));
00648 check(maxit=cpl_parameter_get_int(p));
00649
00650 sprintf(paramname,"xsh.%s.%s",RECIPE_ID, "model-anneal-factor");
00651 check(p = cpl_parameterlist_find(parameters,paramname));
00652 check(ann_fac=cpl_parameter_get_double(p));
00653
00654 sprintf(paramname,"xsh.%s.%s",RECIPE_ID, "model-scenario");
00655 check(p = cpl_parameterlist_find(parameters,paramname));
00656 check(scenario=cpl_parameter_get_int(p));
00657 xsh_msg("maxit=%d ann_fac=%g scenario=%d",maxit,ann_fac,scenario);
00658
00659 check(MODEL_CONF_OPT_frame=xsh_model_pipe_anneal( model_config_frame, resid_map,
00660 maxit,ann_fac,scenario,1));
00661
00662 }
00663
00664
00665 check( guess_order_table=xsh_create_order_table(predict_rmdark,
00666 spectralformat_frame,
00667 resid_tab_orders_frame,
00668 clean_arclines,
00669 detect_arclines_p,
00670 detect_arclines_clipping,
00671 instrument));
00672
00673
00674 if(line_intmon) {
00675 check(xsh_wavecal_qclog_intmon(resid_map,line_intmon,exptime,instrument));
00676 }
00677 check(xsh_table_merge_clean_and_resid_tabs(resid_map,clean_arclines));
00678
00679
00680
00681 xsh_msg("Saving products");
00682
00683 check(xsh_add_product_table( clean_arclines, frameset,
00684 parameters, RECIPE_ID, instrument,NULL));
00685
00686 if ( guess_wavesol != NULL){
00687 check(xsh_add_product_table( guess_wavesol, frameset,
00688 parameters, RECIPE_ID, instrument,NULL));
00689 }
00690 if ( guess_order_table != NULL){
00691 check(xsh_add_product_table( guess_order_table, frameset,
00692 parameters, RECIPE_ID, instrument,NULL));
00693 }
00694 if(model_config_frame == NULL) {
00695 check(xsh_wavetab_qc(resid_map,true));
00696 } else {
00697 check(xsh_wavetab_qc(resid_map,false));
00698 }
00699
00700
00701 if(model_config_frame!=NULL) {
00702
00703 check(xsh_frame_table_resid_merge(resid_dan,resid_map,solution_type));
00704 check(xsh_add_product_table( resid_dan, frameset,parameters, RECIPE_ID,
00705 instrument,NULL));
00706
00707
00708
00709
00710 } else {
00711 check(xsh_add_product_table( resid_map, frameset,parameters, RECIPE_ID,
00712 instrument,NULL));
00713
00714 }
00715 if ( xsh_instrument_get_arm(instrument) != XSH_ARM_NIR){
00716 check(xsh_add_product_image(predict_rmbias,frameset,parameters,
00717 RECIPE_ID,instrument,NULL));
00718
00719 } else {
00720 sprintf(tag,"%s_ON",XSH_FMTCHK);
00721 check(xsh_add_product_image(predict_rmdark,frameset,parameters,
00722 RECIPE_ID,instrument,tag));
00723 }
00724 if ( model_config_frame != NULL){
00725 check(xsh_add_product_table(MODEL_CONF_OPT_frame,frameset,parameters,
00726 RECIPE_ID, instrument,NULL));
00727 }
00728
00729 xsh_msg("xsh_predict success !!");
00730
00731 cleanup:
00732 xsh_end( RECIPE_ID, frameset, parameters );
00733 XSH_FREE(detect_arclines_clipping);
00734 XSH_FREE(detect_arclines_p);
00735 xsh_free_frameset(&raws);
00736 xsh_free_frameset(&calib);
00737 xsh_free_frameset(&on);
00738 xsh_free_frameset(&off);
00739 xsh_free_frameset(&on_off);
00740 xsh_free_frame(&guess_order_table);
00741 xsh_free_frame(&clean_arclines);
00742 xsh_free_frame(&resid_tab_orders_frame);
00743 xsh_free_frame(&resid_map);
00744 xsh_free_frame(&resid_dan);
00745 xsh_free_frame(&guess_wavesol);
00746 xsh_free_frame(&predict_rmbias);
00747 xsh_free_frame(&predict_rmdark);
00748 xsh_free_frame(&MODEL_CONF_OPT_frame);
00749 xsh_free_frame(&bpmap);
00750 xsh_free_propertylist(&plist);
00751
00752 xsh_instrument_free(&instrument);
00753 return;
00754 }
00755