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
00033
00034
00035
00036 #include "visir_recipe.h"
00037 #include "visir_spectro.h"
00038 #include "visir_spc_distortion.h"
00039 #include "visir_spc_photom.h"
00040
00041
00042
00043
00044
00045
00046 #define RECIPE_STRING "visir_old_spc_obs"
00047
00048 #define RECIPE_SAVE_STRING "visir_spc_obs"
00049
00050
00051 #define RECIPE_KEYS_REGEXP_ALL \
00052 VISIR_PFITS_REGEXP_IMG_RECOMBINE \
00053 "|" VISIR_PFITS_REGEXP_SPC_GET_RES_WL
00054
00055
00056 #define RECIPE_KEYS_REGEXP \
00057 RECIPE_KEYS_REGEXP_ALL \
00058 "|" VISIR_PFITS_REGEXP_CAPA \
00059 "|" VISIR_PFITS_REGEXP_SPC_WCAL_PAF
00060
00061
00062 #define RECIPE_KEYS_REGEXP_WCS \
00063 RECIPE_KEYS_REGEXP \
00064 "|" IRPLIB_PFITS_WCS_REGEXP
00065
00066 #define IS_PREPROCESSED 1
00067 #define IS_PHOT 2
00068 #define IS_ECH 4
00069 #define RAW_INPUT 0
00070 #define PREPROCESSED_INPUT IS_PREPROCESSED
00071 #define RAW_PHOT_INPUT IS_PHOT
00072 #define PREPROCESSED_PHOT_INPUT (IS_PHOT | IS_PREPROCESSED)
00073
00074
00075
00076
00077 static cpl_error_code visir_spc_obs_save(cpl_frameset *,
00078 const cpl_parameterlist *,
00079 cpl_propertylist *,
00080 const cpl_propertylist *,
00081 const cpl_image *,
00082 const cpl_image *,
00083 const cpl_table *,
00084 const char *);
00085
00086 #ifdef VISIR_CHAIN
00087 #define cpl_plugin_get_info visir_old_spc_obs_get_info
00088 #endif
00089 VISIR_RECIPE_DEFINE(visir_old_spc_obs,
00090 VISIR_PARAM_ORDEROFF |
00091 VISIR_PARAM_EMIS_TOL |
00092 VISIR_PARAM_REFINE | VISIR_PARAM_XCORR |
00093 VISIR_PARAM_OFFSETS | VISIR_PARAM_OBJECTS |
00094 VISIR_PARAM_NODPOS | VISIR_PARAM_AUTOBPM |
00095 VISIR_PARAM_GLITCH | VISIR_PARAM_PURGE |
00096 VISIR_PARAM_UNION | VISIR_PARAM_REJECT |
00097 VISIR_PARAM_STRIPITE | VISIR_PARAM_STRIPMOR |
00098 VISIR_PARAM_PLOT | VISIR_PARAM_SLITSKEW |
00099 VISIR_PARAM_SPECSKEW | VISIR_PARAM_VERTARC |
00100 VISIR_PARAM_REJLEFT | VISIR_PARAM_REJRIGHT |
00101 VISIR_PARAM_HORIARC | VISIR_PARAM_FIXCOMBI |
00102 VISIR_PARAM_BKG_CORRECT,
00103 "Old DRS detector: Spectroscopic Observation recipe",
00104 "This recipe estimates the dispersion relation using the "
00105 "atmospheric spectrum\n"
00106 "in a long-slit spectroscopy half-cycle frame.\n"
00107 "It also extracts the spectrum of an observed object using "
00108 "a combined frame.\n"
00109 "The files listed in the Set Of Frames (sof-file) "
00110 "must be tagged:\n"
00111 "VISIR-Long-Slit-Spectroscopy-file.fits "
00112 VISIR_SPC_OBS_RAW "\n"
00113 "VISIR-Quantum-Efficiency-Calibration-file.fits "
00114 VISIR_CALIB_QEFF_SPC "\n"
00115 "VISIR-Atmospheric-Emission-Lines-Calibration-file.fits "
00116 VISIR_CALIB_LINES_SPC
00117 "\n"
00118 MAN_VISIR_CALIB_BPM_SPC);
00119
00120
00121
00122
00123
00124
00128
00129
00130
00131
00132
00133
00134
00141
00142 static int visir_old_spc_obs(cpl_frameset * framelist,
00143 const cpl_parameterlist * parlist)
00144 {
00145 irplib_framelist * allframes = NULL;
00146 irplib_framelist * rawframes = NULL;
00147 irplib_framelist * skyframes = NULL;
00148 cpl_propertylist * qclist = cpl_propertylist_new();
00149 cpl_propertylist * paflist = cpl_propertylist_new();
00150 const char * badpix;
00151 const char * star_cat;
00152 const char * spc_cal_qeff;
00153 const char * spc_cal_lines;
00154 const char * flat;
00155 cpl_image * combined = NULL;
00156 cpl_image * flipped = NULL;
00157 cpl_image * comnarrow = NULL;
00158 cpl_imagelist * hcycle = NULL;
00159 cpl_table * spc_table = NULL;
00160 cpl_image * weight2d = NULL;
00161 cpl_image * imhcycle = NULL;
00162 cpl_image * imhcyclenarrow = NULL;
00163 cpl_image ** combinedpair;
00164 double wlen, slitw, temp, fwhm;
00165 visir_spc_resol resol;
00166 cpl_boolean drop_wcs;
00167 int input_mode;
00168 cpl_boolean bkgcorrect;
00169 visir_spc_config spc_config;
00170 const char * dit_key = VISIR_PFITS_DOUBLE_DIT;
00171 const char * rawtag;
00172
00173 spc_config.recipename = RECIPE_STRING;
00174 spc_config.parlist = parlist;
00175 spc_config.orderoffset = 0;
00176 spc_config.phot_emis_tol = 1.0;
00177
00178
00179 spc_config.plot =
00180 visir_parameterlist_get_int(parlist, RECIPE_STRING, VISIR_PARAM_PLOT);
00181
00182 spc_config.phi =
00183 visir_parameterlist_get_double(parlist,RECIPE_STRING,VISIR_PARAM_SLITSKEW);
00184 spc_config.ksi =
00185 visir_parameterlist_get_double(parlist,RECIPE_STRING,VISIR_PARAM_SPECSKEW);
00186 spc_config.eps =
00187 visir_parameterlist_get_double(parlist, RECIPE_STRING,VISIR_PARAM_VERTARC);
00188 spc_config.delta =
00189 visir_parameterlist_get_double(parlist, RECIPE_STRING,VISIR_PARAM_HORIARC);
00190
00191 spc_config.orderoffset =
00192 visir_parameterlist_get_int(parlist, RECIPE_STRING, VISIR_PARAM_ORDEROFF);
00193
00194 spc_config.do_fixcombi = visir_parameterlist_get_bool(parlist, RECIPE_STRING,
00195 VISIR_PARAM_FIXCOMBI);
00196 spc_config.phot_emis_tol =
00197 visir_parameterlist_get_double(parlist, RECIPE_STRING, VISIR_PARAM_EMIS_TOL);
00198
00199 bkgcorrect = visir_parameterlist_get_bool(parlist, RECIPE_STRING,
00200 VISIR_PARAM_BKG_CORRECT);
00201 skip_if (0);
00202
00203
00204 skip_if (visir_dfs_set_groups(framelist));
00205
00206
00207 allframes = irplib_framelist_cast(framelist);
00208 skip_if(allframes == NULL);
00209
00210 if (irplib_frameset_find_file(framelist, VISIR_SPC_OBS_PP)) {
00211
00212 rawframes = irplib_framelist_extract(allframes, VISIR_SPC_OBS_PP);
00213 rawtag = VISIR_SPC_OBS_PP;
00214 cpl_msg_info(cpl_func, "Input: preprocessed observation frame ("
00215 VISIR_SPC_OBS_PP ")");
00216 input_mode = PREPROCESSED_INPUT;
00217
00218 } else if (irplib_frameset_find_file(framelist, VISIR_SPC_PHOT_PP)) {
00219
00220 rawframes = irplib_framelist_extract(allframes, VISIR_SPC_PHOT_PP);
00221 rawtag = VISIR_SPC_PHOT_PP;
00222 cpl_msg_info(cpl_func, "Input: preprocessed photometric frame ("
00223 VISIR_SPC_PHOT_PP ")");
00224 input_mode = PREPROCESSED_PHOT_INPUT;
00225
00226 } else if (irplib_frameset_find_file(framelist, VISIR_SPC_OBS_ECH_PP)) {
00227
00228 rawframes = irplib_framelist_extract(allframes, VISIR_SPC_OBS_ECH_PP);
00229 rawtag = VISIR_SPC_OBS_ECH_PP;
00230 cpl_msg_info(cpl_func, "Input: preprocessed observation echelle frame ("
00231 VISIR_SPC_OBS_ECH_PP ")");
00232 input_mode = PREPROCESSED_INPUT | IS_ECH;
00233
00234 } else if (irplib_frameset_find_file(framelist, VISIR_SPC_PHOT_ECH_PP)) {
00235
00236 rawframes = irplib_framelist_extract(allframes, VISIR_SPC_PHOT_ECH_PP);
00237 rawtag = VISIR_SPC_PHOT_ECH_PP;
00238 cpl_msg_info(cpl_func, "Input: preprocessed photometric echelle frame ("
00239 VISIR_SPC_PHOT_ECH_PP ")");
00240 input_mode = PREPROCESSED_PHOT_INPUT | IS_ECH;
00241
00242 } else if (irplib_frameset_find_file(framelist, VISIR_SPC_OBS_RAW)) {
00243
00244 rawframes = irplib_framelist_extract(allframes, VISIR_SPC_OBS_RAW);
00245 rawtag = VISIR_SPC_OBS_RAW;
00246 cpl_msg_info(cpl_func, "Input: raw observation frame ("
00247 VISIR_SPC_OBS_RAW")");
00248 input_mode = RAW_INPUT;
00249
00250 } else if (irplib_frameset_find_file(framelist, VISIR_SPC_PHOT_RAW)) {
00251
00252 rawframes = irplib_framelist_extract(allframes, VISIR_SPC_PHOT_RAW);
00253 rawtag = VISIR_SPC_PHOT_RAW;
00254 cpl_msg_info(cpl_func, "Input: raw photometric frame ("
00255 VISIR_SPC_PHOT_RAW")");
00256 input_mode = RAW_PHOT_INPUT;
00257
00258 } else if (irplib_frameset_find_file(framelist, VISIR_SPC_OBS_ECH_RAW)) {
00259
00260 rawframes = irplib_framelist_extract(allframes, VISIR_SPC_OBS_ECH_RAW);
00261 rawtag = VISIR_SPC_OBS_ECH_RAW;
00262 cpl_msg_info(cpl_func, "Input: raw observation echelle frame ("
00263 VISIR_SPC_OBS_ECH_RAW")");
00264 input_mode = RAW_INPUT | IS_ECH;
00265
00266 } else if (irplib_frameset_find_file(framelist, VISIR_SPC_PHOT_ECH_RAW)) {
00267
00268 rawframes = irplib_framelist_extract(allframes, VISIR_SPC_PHOT_ECH_RAW);
00269 rawtag = VISIR_SPC_PHOT_ECH_RAW;
00270 cpl_msg_info(cpl_func, "Input: raw photometric echelle frame ("
00271 VISIR_SPC_PHOT_ECH_RAW")");
00272 input_mode = RAW_PHOT_INPUT | IS_ECH;
00273
00274 } else {
00275 error_if(1, CPL_ERROR_ILLEGAL_INPUT, "Input frame set must contain "
00276 "frame(s) tagged as one of: " VISIR_SPC_OBS_RAW ", "
00277 VISIR_SPC_PHOT_RAW ", " VISIR_SPC_OBS_PP ","
00278 VISIR_SPC_PHOT_PP "," VISIR_SPC_OBS_ECH_RAW ","
00279 VISIR_SPC_OBS_ECH_PP "," VISIR_SPC_PHOT_ECH_RAW ","
00280 VISIR_SPC_PHOT_ECH_PP);
00281 }
00282
00283 bug_if (rawframes == NULL);
00284
00285 if (input_mode & IS_PREPROCESSED) {
00286 skyframes = irplib_framelist_extract(allframes, VISIR_SPC_OBS_SKYFRAME);
00287 error_if(skyframes == NULL, CPL_ERROR_ILLEGAL_INPUT,
00288 "Frame set with a preprocessed frame (%s) must include a sky "
00289 "frame (" VISIR_SPC_OBS_SKYFRAME ")", rawtag);
00290 }
00291
00292 irplib_framelist_empty(allframes);
00293
00294 skip_if(irplib_framelist_load_propertylist_all(rawframes, 0, "^("
00295 VISIR_PFITS_REGEXP_SPC_SENSIT
00296 "|" RECIPE_KEYS_REGEXP_ALL
00297 "|" RECIPE_KEYS_REGEXP_WCS
00298 "|" VISIR_PFITS_REGEXP_DIT
00299 "|" VISIR_PFITS_DOUBLE_WLEN
00300 "|" VISIR_PFITS_DOUBLE_PWLEN
00301 "|" "ESO DRS .*"
00302 "|" "ESO QC EXPTIME"
00303 "|" "ESO QC EXECTIME"
00304 "|" "ESO QC BACKGD MEAN"
00305 ")$", CPL_FALSE));
00306
00307 skip_if(visir_dfs_check_framelist_tag(rawframes));
00308
00309 if (cpl_propertylist_has(irplib_framelist_get_propertylist(rawframes, 0),
00310 VISIR_PFITS_DOUBLE_SEQ1_DIT))
00311 dit_key = VISIR_PFITS_DOUBLE_SEQ1_DIT;
00312 skip_if(0);
00313
00314
00315 star_cat = irplib_frameset_find_file(framelist, VISIR_CALIB_STDSTAR_SPC);
00316 error_if ((input_mode & IS_PHOT) && star_cat == NULL,
00317 CPL_ERROR_DATA_NOT_FOUND, "Frame set with a photometric frame "
00318 "(%s) must include a standard star catalogue ("
00319 VISIR_CALIB_STDSTAR_SPC ")", rawtag);
00320
00321 visir_data_type data_type;
00322 const cpl_frame * frm = irplib_framelist_get_const(rawframes, 0);
00323 skip_if(visir_get_data_type(frm,
00324 irplib_framelist_get_propertylist(rawframes, 0), &data_type, NULL));
00325
00326 if (visir_data_is_drs(data_type)) {
00327
00328 const cpl_parameter * par =
00329 cpl_parameterlist_find_const(parlist, PACKAGE "." RECIPE_STRING ".ksi");
00330 if (spc_config.ksi == cpl_parameter_get_default_double(par) * CPL_MATH_RAD_DEG) {
00331 spc_config.ksi = VISIR_DRS_DIST_KSI;
00332 }
00333 par = cpl_parameterlist_find_const(parlist, PACKAGE "." RECIPE_STRING ".eps");
00334 if (spc_config.eps == cpl_parameter_get_default_double(par)) {
00335 spc_config.eps = VISIR_DRS_DIST_EPS;
00336 }
00337 par = cpl_parameterlist_find_const(parlist, PACKAGE "." RECIPE_STRING ".delta");
00338 if (spc_config.delta == cpl_parameter_get_default_double(par)) {
00339 spc_config.delta = VISIR_DRS_DIST_DELTA;
00340 }
00341 par = cpl_parameterlist_find_const(parlist, PACKAGE "." RECIPE_STRING ".phi");
00342 if (spc_config.phi == cpl_parameter_get_default_double(par) * CPL_MATH_RAD_DEG) {
00343 spc_config.phi = VISIR_DRS_DIST_PHI;
00344 }
00345 }
00346
00347
00348 spc_cal_qeff = irplib_frameset_find_file(framelist, VISIR_CALIB_QEFF_SPC);
00349
00350
00351 spc_cal_lines = irplib_frameset_find_file(framelist, VISIR_CALIB_LINES_SPC);
00352
00353
00354 badpix = irplib_frameset_find_file(framelist, VISIR_CALIB_BPM);
00355
00356
00357 flat = irplib_frameset_find_file(framelist, VISIR_CALIB_FLAT);
00358
00359
00360 resol = visir_spc_get_res_wl(rawframes, &wlen, &slitw, &temp, &fwhm,
00361 visir_data_is_aqu(data_type));
00362
00363 skip_if (0);
00364
00365 if (resol == VISIR_SPC_R_GHR) {
00366 error_if(!(input_mode & IS_ECH) && !(input_mode & IS_PREPROCESSED),
00367 CPL_ERROR_TYPE_MISMATCH, "Will not "
00368 "reduce echelle data tagged as long slit data");
00369 } else {
00370 if (spc_config.orderoffset == 0) {
00371 cpl_msg_warning(cpl_func,"Reducing non-HR Grism data as main order");
00372 } else {
00373 cpl_msg_error(cpl_func, "This recipe cannot reduce non-HR Grism "
00374 "data with an order-offset of %d",
00375 spc_config.orderoffset);
00376 visir_error_set(CPL_ERROR_TYPE_MISMATCH);
00377 skip_if(1);
00378 }
00379 }
00380
00381 if (input_mode & IS_PREPROCESSED) {
00382 cpl_imagelist * imagelist = cpl_imagelist_new();
00383 cpl_size nframes = irplib_framelist_get_size(rawframes);
00384 const cpl_propertylist ** plists =
00385 cpl_malloc(nframes * sizeof(cpl_propertylist *));
00386 double bg_sum = 0;
00387
00388 for (cpl_size i = 0; i < nframes; i++) {
00389 cpl_frame * frame = irplib_framelist_get(rawframes, i);
00390 const char * fname = cpl_frame_get_filename(frame);
00391 const cpl_size next = cpl_fits_count_extensions(fname);
00392 cpl_imagelist * tmplist = cpl_imagelist_new();
00393 cpl_errorstate prestate = cpl_errorstate_get();
00394 cpl_image * tmp;
00395
00396 plists[i] = irplib_framelist_get_propertylist_const(rawframes, i);
00397 if (cpl_propertylist_has(plists[i], "ESO QC BACKGD MEAN"))
00398 bg_sum += cpl_propertylist_get_double(plists[i],
00399 "ESO QC BACKGD MEAN");
00400 skip_if(0);
00401
00402 for (cpl_size j = 0; j < 1 + next; j++) {
00403 cpl_image * img =
00404 cpl_image_load(fname, CPL_TYPE_UNSPECIFIED, 0, j);
00405 if (img == NULL) {
00406 cpl_errorstate_set(prestate);
00407 cpl_msg_info(cpl_func, "No image in extension %d", (int)j);
00408 continue;
00409 }
00410 cpl_image_reject_value(img, CPL_VALUE_NAN);
00411 cpl_imagelist_set(tmplist, img, cpl_imagelist_get_size(tmplist));
00412 skip_if(0);
00413 }
00414 tmp = cpl_imagelist_collapse_create(tmplist);
00415
00416 cpl_imagelist_set(imagelist, tmp,
00417 cpl_imagelist_get_size(imagelist));
00418 cpl_imagelist_delete(tmplist);
00419 }
00420 combinedpair =
00421 visir_img_recombine_list(RECIPE_STRING, parlist, imagelist,
00422 plists, CPL_GEOM_FIRST, &drop_wcs);
00423
00424
00425 cpl_propertylist_append_double(qclist, "ESO QC BACKGD MEAN",
00426 bg_sum / nframes);
00427 cpl_imagelist_delete(imagelist);
00428 cpl_free(plists);
00429 bug_if(0);
00430
00431
00432 {
00433 cpl_frame * frame = irplib_framelist_get(skyframes, 0);
00434 const char * fname = cpl_frame_get_filename(frame);
00435 imhcycle = cpl_image_load(fname, CPL_TYPE_UNSPECIFIED, 0, 0);
00436 cpl_image_reject_value(imhcycle, CPL_VALUE_NAN);
00437 skip_if(imhcycle == NULL);
00438 }
00439
00440
00441 } else {
00442 bug_if (input_mode & IS_PREPROCESSED);
00443
00444 combinedpair = visir_img_recombine(RECIPE_STRING, parlist, rawframes,
00445 badpix, flat, CPL_GEOM_FIRST,
00446 &drop_wcs, !spc_config.do_fixcombi,
00447 wlen, resol);
00448
00449
00450 hcycle = visir_load_hcycle(rawframes, 0);
00451 skip_if (0);
00452
00453 imhcycle = cpl_imagelist_unset(hcycle, 0);
00454
00455 skip_if (visir_spc_det_fix(&imhcycle, 1, CPL_FALSE,
00456 wlen, resol,
00457 spc_config.phi,
00458 spc_config.ksi,
00459 spc_config.eps,
00460 spc_config.delta,
00461 spc_config.plot));
00462
00463 skip_if(visir_qc_append_background(qclist, rawframes, 0, 0));
00464 }
00465
00466 error_if (combinedpair == NULL, cpl_error_get_code(),
00467 "Could not combine the input frames (%s)", rawtag);
00468
00469 cpl_image_delete(combinedpair[1]);
00470 combined = cpl_image_cast(combinedpair[0], CPL_TYPE_DOUBLE);
00471 cpl_image_delete(combinedpair[0]);
00472 cpl_free(combinedpair);
00473
00474 bug_if (0);
00475
00476 if (!(input_mode & IS_PREPROCESSED)) {
00477
00478
00479 flipped = visir_spc_flip(combined, wlen, resol, VISIR_DATA_CUBE2);
00480 skip_if (0);
00481 cpl_image_delete(combined);
00482 combined = flipped;
00483 flipped = NULL;
00484
00485
00486 flipped = visir_spc_flip(imhcycle, wlen, resol, VISIR_DATA_CUBE2);
00487 skip_if (0);
00488 cpl_image_delete(imhcycle);
00489 imhcycle = flipped;
00490 flipped = NULL;
00491 }
00492
00493 skip_if (spc_config.do_fixcombi && !(input_mode & IS_PREPROCESSED) &&
00494 visir_spc_det_fix(&combined, 1, CPL_TRUE, wlen, resol,
00495 spc_config.phi, spc_config.ksi,
00496 spc_config.eps, spc_config.delta,
00497 spc_config.plot));
00498
00499 cpl_msg_info(cpl_func, "input_mode %d", input_mode);
00500 skip_if(visir_spc_extract_order(&imhcyclenarrow, &comnarrow,
00501 combined, imhcycle, wlen, &spc_config,
00502 (input_mode & IS_ECH) == IS_ECH,
00503 visir_data_is_aqu(data_type)));
00504
00505 skip_if (visir_spc_extract_wcal(comnarrow, imhcyclenarrow,
00506 wlen, slitw, temp, fwhm,
00507 resol, spc_config.orderoffset,
00508 spc_cal_lines, spc_cal_qeff,
00509 &spc_table, &weight2d, qclist,
00510 spc_config.plot, bkgcorrect,
00511 visir_data_is_aqu(data_type)));
00512
00513
00514 bug_if (visir_spectro_qc(qclist, paflist, drop_wcs, rawframes, NULL,
00515 "^(" VISIR_PFITS_REGEXP_SPC_WCAL_PAF ")$"));
00516
00517 if (star_cat) {
00518 cpl_errorstate prestate = cpl_errorstate_get();
00519 const cpl_propertylist * plist =
00520 irplib_framelist_get_propertylist_const(rawframes, 0);
00521 skip_if(0);
00522
00523 if (!(input_mode & IS_PHOT))
00524 cpl_msg_info(cpl_func, "The frame set contains observation frame"
00525 "(s) (%s) together with a standard star catalogue ("
00526 VISIR_CALIB_STDSTAR_SPC "), attempting to perform a "
00527 "photometric calibration", rawtag);
00528
00529 if (visir_spc_phot_sensit(rawframes, &spc_config, plist, star_cat,
00530 &weight2d, qclist, spc_table, resol,
00531 dit_key)) {
00532 if (!(input_mode & IS_PHOT)) {
00533 irplib_error_recover(prestate, "The frame set contains "
00534 "observation frame(s) (%s) together with "
00535 "a standard star catalogue ("
00536 VISIR_CALIB_STDSTAR_SPC ") but the "
00537 "photometric calibration failed", rawtag);
00538 }
00539 skip_if(0);
00540 }
00541 else
00542 input_mode |= IS_PHOT;
00543 } else {
00544 bug_if(input_mode & IS_PHOT);
00545
00546 bug_if (cpl_table_erase_column(spc_table, "SPC_EMISSIVITY"));
00547 }
00548
00549 irplib_framelist_empty(rawframes);
00550
00551
00552 cpl_msg_info(cpl_func, "Saving the produced spectrum");
00553
00554
00555 bug_if (cpl_propertylist_append_string(paflist, CPL_DFS_PRO_CATG,
00556 VISIR_SPC_OBS_COMBINED_PROCATG));
00557
00558 if (input_mode & IS_PHOT) {
00559 if (input_mode & IS_ECH)
00560 skip_if (visir_spc_obs_save(framelist, parlist, qclist, paflist,
00561 combined, weight2d, spc_table,
00562 VISIR_SPC_PHOT_ECH_TAB_PROCATG));
00563 else
00564 skip_if (visir_spc_obs_save(framelist, parlist, qclist, paflist,
00565 combined, weight2d, spc_table,
00566 VISIR_SPC_PHOT_TAB_PROCATG));
00567 }
00568 else {
00569 if (input_mode & IS_ECH)
00570 skip_if (visir_spc_obs_save(framelist, parlist, qclist, paflist,
00571 combined, weight2d, spc_table,
00572 VISIR_SPC_OBS_ECH_TAB_PROCATG));
00573 else
00574 skip_if (visir_spc_obs_save(framelist, parlist, qclist, paflist,
00575 combined, weight2d, spc_table,
00576 VISIR_SPC_OBS_TAB_PROCATG));
00577 }
00578
00579 end_skip;
00580
00581 cpl_propertylist_delete(qclist);
00582 cpl_propertylist_delete(paflist);
00583 irplib_framelist_delete(allframes);
00584 irplib_framelist_delete(rawframes);
00585 irplib_framelist_delete(skyframes);
00586 cpl_image_delete(flipped);
00587 cpl_image_delete(combined);
00588 cpl_image_delete(comnarrow);
00589 cpl_image_delete(imhcycle);
00590 cpl_image_delete(imhcyclenarrow);
00591 cpl_table_delete(spc_table);
00592 cpl_image_delete(weight2d);
00593 cpl_imagelist_delete(hcycle);
00594
00595 return cpl_error_get_code();
00596 }
00597
00598
00599
00614
00615 static cpl_error_code visir_spc_obs_save(cpl_frameset * set,
00616 const cpl_parameterlist * parlist,
00617 cpl_propertylist * qclist,
00618 const cpl_propertylist * paflist,
00619 const cpl_image * combined,
00620 const cpl_image * weight2d,
00621 const cpl_table * table,
00622 const char * tab_procatg)
00623 {
00624 bug_if (0);
00625
00626
00627 cpl_propertylist * plist = cpl_propertylist_new();
00628 cpl_propertylist_update_string(plist, "EXTNAME", "TAB_SPECTRUM");
00629 skip_if (irplib_dfs_save_table(set, parlist, set, table, plist,
00630 RECIPE_SAVE_STRING, tab_procatg,
00631 qclist, NULL, visir_pipe_id,
00632 RECIPE_SAVE_STRING "_tab" CPL_DFS_FITS));
00633
00634 cpl_propertylist_update_string(plist, "EXTNAME", "IMG_COMBINED");
00635 skip_if(cpl_image_save(combined, RECIPE_SAVE_STRING "_tab" CPL_DFS_FITS,
00636 CPL_TYPE_FLOAT, plist, CPL_IO_EXTEND));
00637 cpl_propertylist_update_string(plist, "EXTNAME", "IMG_WEIGHT");
00638 skip_if(cpl_image_save(weight2d, RECIPE_SAVE_STRING "_tab" CPL_DFS_FITS,
00639 CPL_TYPE_FLOAT, plist, CPL_IO_EXTEND));
00640 cpl_propertylist_delete(plist);
00641
00642 #ifdef VISIR_SAVE_PAF
00643
00644
00645 skip_if (cpl_dfs_save_paf("VISIR", RECIPE_SAVE_STRING, paflist,
00646 RECIPE_SAVE_STRING CPL_DFS_PAF));
00647 #else
00648 bug_if(paflist == NULL);
00649 #endif
00650
00651 end_skip;
00652
00653 return cpl_error_get_code();
00654
00655 }