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 <cxlist.h>
00038
00039 #include <string.h>
00040
00041
00042
00043
00044
00045
00046 #define RECIPE_STRING "visir_util_apply_calib"
00047
00048
00049
00050
00051
00052
00053 cpl_recipe_define(visir_util_apply_calib, VISIR_BINARY_VERSION,
00054 "Julian Taylor", PACKAGE_BUGREPORT, "2012",
00055 "Attempt to remove stripes in spectral data",
00056 "The files listed in the Set Of Frames (sof-file) "
00057 "must be tagged:\n"
00058 "VISIR-chopnod-corrected-file.fits "
00059 "\nThe product(s) will have a FITS card\n"
00060 "'HIERARCH ESO PRO CATG' with a value of:\n");
00061
00062
00066
00067
00068
00069
00070
00071
00072 static inline cpl_boolean
00073 plist_strcmp(const cpl_propertylist * plist,
00074 const char * key, const char * val)
00075 {
00076 if (!cpl_propertylist_has(plist, key))
00077 return CPL_FALSE;
00078 return strcmp(cpl_propertylist_get_string(plist, key), val) == 0;
00079 }
00080
00081
00082
00090
00091 static cpl_error_code
00092 visir_util_apply_calib_fill_parameterlist(cpl_parameterlist * self)
00093 {
00094 if (self) {}
00095 return CPL_ERROR_NONE;
00096 }
00097
00098
00099 static cpl_frameset *
00100 get_img_conv(double * conv, double * error,
00101 irplib_framelist * phot_frames)
00102 {
00103 cpl_vector * v = NULL;
00104 double derror = 0.;
00105 cpl_errorstate cleanstate = cpl_errorstate_get();
00106 irplib_framelist * one_frames = NULL;
00107 irplib_framelist * cmb_frames = NULL;
00108 cpl_frameset * usedframes = cpl_frameset_new();
00109 cpl_propertylist * cmb_plist;
00110
00111 cpl_ensure(conv, CPL_ERROR_NULL_INPUT, NULL);
00112
00113 skip_if(irplib_framelist_load_propertylist_all(phot_frames, 0,
00114 "ESO QC", 0));
00115
00116 cmb_frames = irplib_framelist_extract(phot_frames,
00117 VISIR_IMG_PHOT_COMBINED_PROCATG);
00118
00119 skip_if(irplib_framelist_contains(cmb_frames, "ESO QC CONVER",
00120 CPL_TYPE_DOUBLE, CPL_FALSE, 0.));
00121 cmb_plist = irplib_framelist_get_propertylist(cmb_frames, 0);
00122 cpl_frameset_insert(usedframes,
00123 cpl_frame_duplicate(irplib_framelist_get(cmb_frames, 0)));
00124
00125 one_frames = irplib_framelist_extract(phot_frames,
00126 VISIR_IMG_PHOT_ONEBEAM_PROCATG);
00127 if (one_frames == NULL)
00128 cpl_errorstate_set(cleanstate);
00129 else {
00130
00131 skip_if(irplib_framelist_contains(one_frames, "ESO QC CONVER",
00132 CPL_TYPE_DOUBLE, CPL_FALSE, 0.));
00133
00134 v = cpl_vector_new(irplib_framelist_get_size(one_frames));
00135
00136 for (int i = 0; i < irplib_framelist_get_size(one_frames); i++) {
00137 const cpl_propertylist * plist =
00138 irplib_framelist_get_propertylist_const(one_frames, i);
00139 double conver = cpl_propertylist_get_double(plist, "ESO QC CONVER");
00140 skip_if(0);
00141
00142 cpl_vector_set(v, i, conver);
00143 }
00144 }
00145
00146 *conv = cpl_propertylist_get_double(cmb_plist, "ESO QC CONVER");
00147
00148 if (derror >= 0)
00149 cpl_msg_info(cpl_func, "Conversion factor: %g +- %g", *conv, derror);
00150 else
00151 cpl_msg_info(cpl_func, "Conversion factor: %g", *conv);
00152
00153 if (error)
00154 *error = derror;
00155
00156 end_skip;
00157
00158 cpl_vector_delete(v);
00159 irplib_framelist_delete(cmb_frames);
00160 irplib_framelist_delete(one_frames);
00161 if (cpl_error_get_code()) {
00162 cpl_frameset_delete(usedframes);
00163 }
00164
00165 return usedframes;
00166 }
00167
00168 static cpl_error_code
00169 update_error(cpl_image * eimg_, const cpl_image * img_,
00170 const double conv, const double cerror)
00171 {
00172 cpl_image * img = cpl_image_cast(img_, CPL_TYPE_DOUBLE);
00173 cpl_image * eimg = cpl_image_cast(eimg_, CPL_TYPE_DOUBLE);
00174 size_t nx = cpl_image_get_size_x(img);
00175 size_t npix = nx * cpl_image_get_size_y(img);
00176 double * eimgd = cpl_image_get_data_double(eimg);
00177 const double * imgd = cpl_image_get_data_double_const(img);
00178
00179 cpl_ensure_code(conv != 0. && cerror >= 0., CPL_ERROR_ILLEGAL_INPUT);
00180 skip_if(imgd == NULL || eimgd == NULL);
00181
00182 for (size_t i = 0; i < npix; i++) {
00183
00184 double da = eimgd[i] / conv;
00185 double db = cerror * imgd[i] / (conv * conv);
00186 cpl_image_set(eimg_, i % nx + 1, i / nx + 1, hypot(da, db));
00187 }
00188
00189 end_skip;
00190 cpl_image_delete(img);
00191 cpl_image_delete(eimg);
00192
00193 return cpl_error_get_code();
00194 }
00195
00196 typedef struct {
00197 cpl_image * img;
00198 cpl_table * tbl;
00199 cpl_propertylist * plist;
00200 } visir_plane;
00201
00202 static visir_plane *
00203 visir_plane_new(cpl_image * img, cpl_table * tbl, cpl_propertylist * plist)
00204 {
00205 visir_plane * pl = cpl_calloc(1, sizeof(visir_plane));
00206 pl->img = img;
00207 pl->tbl = tbl;
00208 pl->plist = plist;
00209 return pl;
00210 }
00211
00212 static void visir_plane_delete(visir_plane * pl)
00213 {
00214 if (pl) {
00215 cpl_image_delete(pl->img);
00216 cpl_table_delete(pl->tbl);
00217 cpl_propertylist_delete(pl->plist);
00218 cpl_free(pl);
00219 }
00220 }
00221
00222
00223 static cx_list *
00224 planelist_from_frame(const cpl_frame * frame)
00225 {
00226 cpl_size next = cpl_frame_get_nextensions(frame);
00227 const char * fn = cpl_frame_get_filename(frame);
00228 cpl_errorstate cleanstate = cpl_errorstate_get();
00229 cx_list * planelist = NULL;
00230 cpl_propertylist * plist = NULL;
00231 cpl_image * img = NULL;
00232 cpl_table * tbl = NULL;
00233
00234 plist = cpl_propertylist_load(fn, 0);
00235 skip_if(plist == NULL);
00236 planelist = cx_list_new();
00237
00238 img = cpl_image_load(fn, CPL_TYPE_UNSPECIFIED, 0, 0);
00239 if (img == NULL)
00240 cpl_errorstate_set(cleanstate);
00241
00242 cx_list_push_back(planelist, visir_plane_new(img, NULL, plist));
00243 img = NULL;
00244 tbl = NULL;
00245 plist = NULL;
00246
00247 for (cpl_size e = 1; e < next + 1; e++) {
00248 img = cpl_image_load(fn, CPL_TYPE_UNSPECIFIED, 0, e);
00249 if (img == 0) {
00250 cpl_errorstate_set(cleanstate);
00251 tbl = cpl_table_load(fn, e, 0);
00252 }
00253 skip_if(0);
00254 plist = cpl_propertylist_load(fn, e);
00255 skip_if(plist == NULL);
00256 cx_list_push_back(planelist, visir_plane_new(img, tbl, plist));
00257 img = NULL;
00258 tbl = NULL;
00259 plist = NULL;
00260 }
00261
00262 end_skip;
00263 cpl_image_delete(img);
00264 cpl_propertylist_delete(plist);
00265
00266 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00267 cx_list_destroy(planelist, (visir_free)visir_plane_delete);
00268 return NULL;
00269 }
00270 else
00271 return planelist;
00272 }
00273
00274
00275 static cpl_error_code
00276 apply_img_calib(cpl_frameset *framelist, const cpl_parameterlist * parlist,
00277 irplib_framelist * objects,
00278 const double conv, const double error,
00279 cpl_frameset * calibframes)
00280 {
00281 cpl_frameset * usedframes = cpl_frameset_new();
00282 cx_list * planes = NULL;
00283
00284 for (int i = 0; i < irplib_framelist_get_size(objects); i++) {
00285 cpl_frame * frm = irplib_framelist_get(objects, i);
00286 cpl_image * eimg = NULL;
00287 char buffer[300];
00288 visir_plane * skip[] = {NULL, NULL};
00289
00290 planes = planelist_from_frame(frm);
00291 skip_if(planes == NULL);
00292
00293 cpl_frame_set_group(frm, CPL_FRAME_GROUP_RAW);
00294
00295 cpl_frameset_insert(usedframes, cpl_frame_duplicate(frm));
00296 FOR_EACH_FRAMESET(cfrm, calibframes) {
00297 cpl_frame_set_group(cfrm, CPL_FRAME_GROUP_RAW);
00298 cpl_frameset_insert(usedframes, cpl_frame_duplicate(cfrm));
00299 }
00300 skip_if(0);
00301
00302 visir_plane * first = cx_list_front(planes);
00303 cpl_image * simg =
00304 cpl_image_multiply_scalar_create(first->img, 1. / conv);
00305 skip_if(simg == NULL);
00306 cpl_propertylist_update_string(first->plist, "BUNIT", "Jy");
00307
00308 sprintf(buffer, "visir_calibrated_%03d.fits", i + 1);
00309 irplib_dfs_save_image(framelist, parlist, usedframes, simg,
00310 CPL_TYPE_FLOAT, RECIPE_STRING,
00311 VISIR_IMG_OBJ_CALIBRATED_PROCATG, first->plist,
00312 NULL, visir_pipe_id, buffer);
00313 cpl_image_delete(simg);
00314 skip_if(0);
00315
00316
00317 FOR_EACH_T(visir_plane * pl, planes) {
00318 if (plist_strcmp(pl->plist, "EXTNAME", VISIR_EXTN_ERROR)) {
00319 eimg = pl->img;
00320
00321 update_error(eimg, first->img, conv, error);
00322 cpl_propertylist_update_string(pl->plist, "BUNIT", "Jy");
00323
00324 cpl_image_save(eimg, buffer, CPL_TYPE_FLOAT,
00325 pl->plist, CPL_IO_EXTEND);
00326 skip[0] = pl;
00327 }
00328 skip_if(0);
00329 }
00330
00331 FOR_EACH_T(visir_plane * pl, planes) {
00332 if (plist_strcmp(pl->plist, "EXTNAME", VISIR_EXTN_WEIGHT)) {
00333 cpl_image * wgt = cpl_image_power_create(eimg, -2);
00334 cpl_image_fill_rejected(wgt, 0);
00335
00336 cpl_image_save(wgt, buffer, CPL_TYPE_FLOAT,
00337 pl->plist, CPL_IO_EXTEND);
00338 cpl_image_delete(wgt);
00339 skip[1] = pl;
00340 }
00341 skip_if(0);
00342 }
00343
00344 FOR_EACH_T(visir_plane * pl, planes) {
00345 if (pl == first || pl == skip[0] || pl == skip[1])
00346 continue;
00347
00348 if (pl->img)
00349 cpl_image_save(pl->img, buffer, CPL_TYPE_UNSPECIFIED,
00350 pl->plist, CPL_IO_EXTEND);
00351 else if (pl->tbl)
00352 cpl_table_save(pl->tbl, NULL, pl->plist, buffer,
00353 CPL_IO_EXTEND);
00354 else
00355 cpl_propertylist_save(pl->plist, buffer, CPL_IO_EXTEND);
00356 skip_if(0);
00357 }
00358 cx_list_destroy(planes, (visir_free)visir_plane_delete);
00359 planes = NULL;
00360 }
00361
00362 end_skip;
00363 cx_list_destroy(planes, (visir_free)visir_plane_delete);
00364
00365 cpl_frameset_delete(usedframes);
00366
00367 return cpl_error_get_code();
00368 }
00369
00370 static cpl_error_code
00371 propagate_all(cpl_frameset * framelist, const cpl_parameterlist * parlist,
00372 irplib_framelist * allframes)
00373 {
00374 cpl_frameset * usedframes = cpl_frameset_new();
00375 cx_list * planes = NULL;
00376
00377 for (int i = 0; i < irplib_framelist_get_size(allframes); i++) {
00378 cpl_frame * frm = irplib_framelist_get(allframes, i);
00379 char buffer[300];
00380 sprintf(buffer, "visir_result_%03d.fits", i + 1);
00381
00382 cpl_frame_set_group(frm, CPL_FRAME_GROUP_RAW);
00383 cpl_frameset_insert(usedframes, cpl_frame_duplicate(frm));
00384
00385 planes = planelist_from_frame(frm);
00386 skip_if(planes == NULL);
00387 visir_plane * first = cx_list_front(planes);
00388
00389 if (first->img)
00390 irplib_dfs_save_image(framelist, parlist, usedframes, first->img,
00391 CPL_TYPE_UNSPECIFIED, RECIPE_STRING,
00392 cpl_frame_get_tag(frm), first->plist,
00393 NULL, visir_pipe_id, buffer);
00394 else
00395 irplib_dfs_save_propertylist(framelist, parlist, usedframes,
00396 RECIPE_STRING,
00397 cpl_frame_get_tag(frm),
00398 first->plist, NULL,
00399 visir_pipe_id, buffer);
00400 skip_if(0);
00401
00402 FOR_EACH_T(visir_plane * pl, planes) {
00403 if (pl == first)
00404 continue;
00405 if (pl->img)
00406 cpl_image_save(pl->img, buffer, CPL_TYPE_UNSPECIFIED,
00407 pl->plist, CPL_IO_EXTEND);
00408 else if (pl->tbl)
00409 cpl_table_save(pl->tbl, NULL, pl->plist, buffer,
00410 CPL_IO_EXTEND);
00411 else
00412 cpl_propertylist_save(pl->plist, buffer, CPL_IO_EXTEND);
00413 skip_if(0);
00414 }
00415
00416 cx_list_destroy(planes, (visir_free)visir_plane_delete);
00417 planes = NULL;
00418 }
00419
00420 end_skip;
00421 cpl_frameset_delete(usedframes);
00422 cx_list_destroy(planes, (visir_free)visir_plane_delete);
00423
00424 return cpl_error_get_code();
00425 }
00426
00427
00428 static cpl_table *
00429 calibrate_frame(const cpl_frame * frm, const cpl_bivector * std,
00430 const cpl_bivector * stde)
00431 {
00432 const char * dfn = cpl_frame_get_filename(frm);
00433 const cpl_vector * swlen = cpl_bivector_get_x_const(std);
00434 cpl_bivector * intstd = NULL;
00435 cpl_bivector * intstde = NULL;
00436 cpl_table * obj = cpl_table_load(dfn, 1, 0);
00437 skip_if(obj == NULL);
00438 const size_t n = cpl_table_get_nrow(obj);
00439
00440
00441 cpl_vector * objv =
00442 cpl_vector_wrap(n, cpl_table_get_data_double(obj, "WLEN"));
00443
00444 const double smin = cpl_vector_get(swlen, 0);
00445 const double smax = cpl_vector_get(swlen, cpl_vector_get_size(swlen) - 1);
00446 const size_t l = visir_lower_bound(objv, smin);
00447 const size_t u = visir_upper_bound(objv, smax);
00448
00449 if (u - l == 0) {
00450 cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
00451 "Calibration data has no wavelength overlap "
00452 "with object");
00453 cpl_vector_unwrap(objv);
00454 skip_if(1);
00455 }
00456 cpl_msg_info(cpl_func, "Overlapping wavelength: %.4g [mu] (%zu) to "
00457 "%.4g [mu] (%zu)", cpl_vector_get(objv, l) * 1e6, l,
00458 cpl_vector_get(objv, u - 1) * 1e6, u);
00459 cpl_vector_unwrap(objv);
00460
00461 {
00462
00463 intstd = cpl_bivector_new(u - l);
00464 intstde = cpl_bivector_new(u - l);
00465 skip_if(intstd == NULL);
00466 skip_if(intstde == NULL);
00467
00468 memcpy(cpl_bivector_get_x_data(intstd),
00469 cpl_table_get_data_double_const(obj, "WLEN") + l,
00470 sizeof(double) * (u - l));
00471 memcpy(cpl_bivector_get_x_data(intstde),
00472 cpl_table_get_data_double_const(obj, "WLEN") + l,
00473 sizeof(double) * (u - l));
00474
00475
00476 skip_if(cpl_bivector_interpolate_linear(intstd, std));
00477 skip_if(cpl_bivector_interpolate_linear(intstde, stde));
00478 }
00479
00480 skip_if(0);
00481
00482
00483 cpl_table_duplicate_column(obj, "SPC_CALIBRATED",
00484 obj, "SPC_EXTRACTED");
00485 skip_if(0);
00486 {
00487 double * d = cpl_table_get_data_double(obj, "SPC_CALIBRATED");
00488 double * v = cpl_vector_get_data(cpl_bivector_get_y(intstd));
00489 for (size_t i = 0; i < n; i++) {
00490 if (i < l || i >= u)
00491 cpl_table_set_invalid(obj, "SPC_CALIBRATED", i);
00492 else
00493 d[i] /= v[i - l];
00494 }
00495 }
00496
00497 cpl_table_new_column(obj, "SPC_CALIBRATED_ERROR", CPL_TYPE_DOUBLE);
00498 skip_if(0);
00499
00500 {
00501 double * ed = cpl_table_get_data_double(obj, "SPC_ERROR");
00502 double * vd = cpl_table_get_data_double(obj, "SPC_EXTRACTED");
00503 double * svd = cpl_bivector_get_y_data(intstd);
00504 double * sed = cpl_bivector_get_y_data(intstde);
00505 for (size_t j = 0; j < n; j++) {
00506 if (j < l || j >= u)
00507 cpl_table_set_invalid(obj, "SPC_CALIBRATED_ERROR", j);
00508 else {
00509 double da = ed[j] / svd[j - l];
00510 double db = sed[j - l] * vd[j] / (svd[j - l] * svd[j - l]);
00511 cpl_table_set_double(obj, "SPC_CALIBRATED_ERROR",
00512 j, hypot(da, db));
00513 }
00514 }
00515 }
00516
00517 skip_if(0);
00518
00519 end_skip;
00520
00521 cpl_bivector_delete(intstd);
00522 cpl_bivector_delete(intstde);
00523
00524 return obj;
00525 }
00526
00527 static cpl_error_code
00528 get_spec_std(cpl_frameset * framelist,
00529 const irplib_framelist * stdtab,
00530 const irplib_framelist * objtab,
00531 const cpl_parameterlist * parlist,
00532 const char * procatg)
00533 {
00534 const cpl_frame * frm;
00535 cpl_bivector * std = NULL;
00536 cpl_bivector * stde = NULL;
00537 skip_if(stdtab == NULL);
00538 skip_if(objtab == NULL);
00539 cpl_ensure_code(irplib_framelist_get_size(stdtab) == 1,
00540 CPL_ERROR_UNSUPPORTED_MODE);
00541 cpl_ensure_code(irplib_framelist_get_size(objtab) > 0,
00542 CPL_ERROR_UNSUPPORTED_MODE);
00543
00544 frm = irplib_framelist_get_const(stdtab, 0);
00545 skip_if(frm == NULL);
00546 {
00547 const char * fn = cpl_frame_get_filename(frm);
00548 cpl_bivector * model = visir_bivector_load_fits(fn, "WLEN",
00549 "STD_STAR_MODEL", 1);
00550 std = visir_bivector_load_fits(fn, "WLEN", "SPC_EXTRACTED", 1);
00551 stde = visir_bivector_load_fits(fn, "WLEN", "SPC_ERROR", 1);
00552
00553
00554 cpl_vector_divide(cpl_bivector_get_y(std), cpl_bivector_get_y(model));
00555 cpl_vector_divide(cpl_bivector_get_y(stde), cpl_bivector_get_y(model));
00556 cpl_bivector_delete(model);
00557 }
00558 skip_if(0);
00559
00560 for (int i = 0; i < irplib_framelist_get_size(objtab); i++) {
00561 char buffer[300];
00562 cpl_frame * ofrm =
00563 cpl_frame_duplicate(irplib_framelist_get_const(objtab, i));
00564 cpl_frame * sfrm = cpl_frame_duplicate(frm);
00565 cpl_frameset * usedframes = cpl_frameset_new();
00566 cpl_frame_set_group(sfrm, CPL_FRAME_GROUP_CALIB);
00567 cpl_frame_set_group(ofrm, CPL_FRAME_GROUP_RAW);
00568 cpl_frameset_insert(usedframes, sfrm);
00569 cpl_frameset_insert(usedframes, ofrm);
00570
00571 cpl_table * obj = calibrate_frame(ofrm, std, stde);
00572 sprintf(buffer, "visir_calibrated_%03d.fits", i + 1);
00573 irplib_dfs_save_table(framelist, parlist, usedframes, obj,
00574 NULL, RECIPE_STRING, procatg, NULL,
00575 NULL, visir_pipe_id, buffer);
00576
00577
00578 if (cpl_frame_get_nextensions(ofrm) == 3) {
00579 cpl_propertylist * plist =
00580 cpl_propertylist_load(cpl_frame_get_filename(ofrm), 2);
00581 cpl_image * img = cpl_image_load(cpl_frame_get_filename(ofrm),
00582 CPL_TYPE_UNSPECIFIED, 0, 2);
00583 cpl_image_save(img, buffer, CPL_TYPE_UNSPECIFIED, plist, CPL_IO_EXTEND);
00584 cpl_image_delete(img);
00585 cpl_propertylist_delete(plist);
00586 plist = cpl_propertylist_load(cpl_frame_get_filename(ofrm), 2);
00587 img = cpl_image_load(cpl_frame_get_filename(ofrm),
00588 CPL_TYPE_UNSPECIFIED, 0, 2);
00589 cpl_image_save(img, buffer, CPL_TYPE_UNSPECIFIED, plist, CPL_IO_EXTEND);
00590 cpl_image_delete(img);
00591 cpl_propertylist_delete(plist);
00592 }
00593
00594 cpl_frameset_delete(usedframes);
00595 cpl_table_delete(obj);
00596 skip_if(0);
00597 }
00598
00599 end_skip;
00600
00601 cpl_bivector_delete(std);
00602 cpl_bivector_delete(stde);
00603
00604 return cpl_error_get_code();
00605 }
00606
00607
00608
00615
00616 static int visir_util_apply_calib(cpl_frameset * framelist,
00617 const cpl_parameterlist * parlist)
00618 {
00619 irplib_framelist * allframes = irplib_framelist_cast(framelist);
00620 cpl_errorstate cleanstate = cpl_errorstate_get();
00621
00622 irplib_framelist * others = NULL;
00623 irplib_framelist * objects =
00624 irplib_framelist_extract_regexp(allframes, ".*OBJ.*", CPL_FALSE);
00625 irplib_framelist * specobs =
00626 irplib_framelist_extract_regexp(allframes, ".*SPC_OBS.*", CPL_FALSE);
00627
00628 if (irplib_framelist_get_size(allframes) > 0)
00629 cpl_errorstate_set(cleanstate);
00630
00631
00632 if (objects && irplib_framelist_get_size(objects) <
00633 irplib_framelist_get_size(allframes)) {
00634 double conv = 1., error = 0.;
00635 cpl_msg_info(cpl_func, "Applying conversion factor");
00636 cpl_frameset * calibframes = get_img_conv(&conv, &error, allframes);
00637 skip_if(calibframes == NULL);
00638 skip_if(apply_img_calib(framelist, parlist, objects, conv, error, calibframes));
00639 others = irplib_framelist_extract_regexp(allframes, ".*OBJ.*", CPL_TRUE);
00640 skip_if(propagate_all(framelist, parlist, others));
00641 }
00642 else if (specobs && irplib_framelist_get_size(specobs) <
00643 irplib_framelist_get_size(allframes)) {
00644 irplib_framelist * stdtab =
00645 irplib_framelist_extract_regexp(allframes, ".*PHOT.*TAB", CPL_FALSE);
00646 irplib_framelist * objtab =
00647 irplib_framelist_extract_regexp(allframes, ".*OBS.*TAB", CPL_FALSE);
00648 cpl_msg_info(cpl_func, "Removing telluric lines");
00649 skip_if(get_spec_std(framelist, stdtab, objtab,
00650 parlist, "SPC_OBS_LMR_TAB"));
00651 others = irplib_framelist_extract_regexp(allframes, ".*OBS.*TAB", CPL_TRUE);
00652 propagate_all(framelist, parlist, others);
00653 irplib_framelist_delete(objtab);
00654 irplib_framelist_delete(stdtab);
00655 skip_if(0);
00656 }
00657 else {
00658 cpl_msg_info(cpl_func, "No calibration data to apply, doing nothing");
00659 skip_if(propagate_all(framelist, parlist, allframes));
00660 }
00661
00662 end_skip;
00663 irplib_framelist_delete(allframes);
00664 irplib_framelist_delete(objects);
00665 irplib_framelist_delete(specobs);
00666 irplib_framelist_delete(others);
00667
00668 return cpl_error_get_code();
00669 }