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 <string.h>
00038
00039
00040
00041
00042
00043 #define RECIPE_STRING "visir_util_join"
00044
00045
00046
00047
00048
00049 static
00050 cpl_error_code visir_util_join_one(cpl_frameset *,
00051 const irplib_framelist *,
00052 const irplib_framelist *,
00053 const irplib_framelist *,
00054 const irplib_framelist *,
00055 const irplib_framelist *,
00056 const irplib_framelist *,
00057 int, cpl_boolean, cpl_boolean,
00058 cpl_boolean, cpl_boolean,
00059 cpl_boolean,
00060 const cpl_parameterlist *);
00061
00062 #ifdef VISIR_CHAIN
00063 #define cpl_plugin_get_info visir_util_join_get_info
00064 #endif
00065 VISIR_RECIPE_DEFINE(visir_util_join, 0,
00066 "Extend the final product with extensions containing its "
00067 "error map, bad pixel map and weight or contribution map",
00068 "The files listed in the Set Of Frames (SOF-file) "
00069 "must be tagged:\n"
00070 "VISIR-data.fits " VISIR_UTIL_DATA "\n"
00071 "\nOptionally, the SOF may also contain one or more of "
00072 "the following:\n"
00073 "VISIR-bad-pixel-map.fits " VISIR_CALIB_BPM "\n"
00074 "VISIR-error.fits " VISIR_UTIL_WEIGHT2ERROR_PROCATG
00075 "\n"
00076 "VISIR-contribution-map.fits " VISIR_IMG_CLIPPED_MAP_PROCATG
00077 "\n"
00078 "VISIR-weight-map.fits " VISIR_UTIL_WEIGHT2ERROR
00079 "\n"
00080 "\nThe product(s) will have a FITS card\n"
00081 "'HIERARCH " CPL_DFS_PRO_CATG "' with a value of:\n"
00082 VISIR_UTIL_JOIN_PROCATG);
00083
00084
00088
00089
00090
00091
00092
00093
00094
00101
00102 static int visir_util_join(cpl_frameset * framelist,
00103 const cpl_parameterlist * parlist)
00104 {
00105 irplib_framelist * allframes = NULL;
00106 irplib_framelist * rawframes = NULL;
00107 irplib_framelist * bpmframes = NULL;
00108 irplib_framelist * errframes = NULL;
00109 irplib_framelist * conframes = NULL;
00110 irplib_framelist * wgtframes = NULL;
00111 irplib_framelist * qcframes = NULL;
00112 int n;
00113 int nbad = 0, nerr = 0, ncon = 0, nwgt = 0, nqc = 0;
00114
00115
00116
00117 skip_if (visir_dfs_set_groups(framelist));
00118 FOR_EACH_FRAMESET(frm, framelist)
00119 cpl_frame_set_group(frm, CPL_FRAME_GROUP_RAW);
00120
00121
00122 allframes = irplib_framelist_cast(framelist);
00123 skip_if(allframes == NULL);
00124
00125 rawframes =
00126 irplib_framelist_extract_regexp(allframes, "^("
00127 VISIR_UTIL_DATA
00128 "|" VISIR_IMG_PHOT_ONEBEAM_PROCATG
00129 "|" VISIR_IMG_PHOT_COMBINED_PROCATG
00130 "|COADDED_IMAGE"
00131 "|" VISIR_IMG_COADDED_IMG
00132 ")$",
00133 CPL_FALSE);
00134
00135 skip_if(rawframes == NULL);
00136
00137 n = irplib_framelist_get_size(rawframes);
00138
00139 if (cpl_frameset_find_const(framelist, VISIR_CALIB_BPM)) {
00140 bpmframes = irplib_framelist_extract(allframes, VISIR_CALIB_BPM);
00141 skip_if (bpmframes == NULL);
00142
00143 nbad = irplib_framelist_get_size(bpmframes);
00144 error_if(nbad != n && nbad != 1, CPL_ERROR_INCOMPATIBLE_INPUT,
00145 "%d raw-frames <=> %d bpm frames", n, nbad);
00146 }
00147
00148 if (cpl_frameset_find_const(framelist, VISIR_UTIL_ERROR_MAP_PROCATG)) {
00149 errframes = irplib_framelist_extract(allframes,
00150 VISIR_UTIL_ERROR_MAP_PROCATG);
00151 skip_if (errframes == NULL);
00152
00153 nerr = irplib_framelist_get_size(errframes);
00154 error_if(nerr != n && nerr != 1, CPL_ERROR_INCOMPATIBLE_INPUT,
00155 "%d raw-frames <=> %d error frames", n, nerr);
00156
00157 }
00158
00159 if (cpl_frameset_find_const(framelist, VISIR_IMG_CLIPPED_MAP_PROCATG)) {
00160 conframes = irplib_framelist_extract(allframes,
00161 VISIR_IMG_CLIPPED_MAP_PROCATG);
00162 skip_if (conframes == NULL);
00163
00164 ncon = irplib_framelist_get_size(conframes);
00165 error_if(ncon % n != 0 && ncon != 1, CPL_ERROR_INCOMPATIBLE_INPUT,
00166 "%d raw-frames <=> %d contribution frames", n, ncon);
00167 }
00168
00169 if (cpl_frameset_find_const(framelist, VISIR_UTIL_WEIGHT_MAP_PROCATG)) {
00170 wgtframes = irplib_framelist_extract(allframes,
00171 VISIR_UTIL_WEIGHT_MAP_PROCATG);
00172 skip_if (wgtframes == NULL);
00173
00174 nwgt = irplib_framelist_get_size(wgtframes);
00175 error_if(nwgt != n && nwgt != 1, CPL_ERROR_INCOMPATIBLE_INPUT,
00176 "%d raw-frames <=> %d weight frames", n, nwgt);
00177 }
00178
00179 if (cpl_frameset_find_const(framelist, VISIR_UTIL_QC_PROCATG)) {
00180 qcframes = irplib_framelist_extract(allframes, VISIR_UTIL_QC_PROCATG);
00181 skip_if (qcframes == NULL);
00182
00183 nqc = irplib_framelist_get_size(qcframes);
00184 error_if(nqc != n && nqc != 1, CPL_ERROR_INCOMPATIBLE_INPUT,
00185 "%d raw-frames <=> %d qc frames", n, nqc);
00186 }
00187
00188 for (int i = 0; i < n; i++) {
00189 cpl_msg_info(cpl_func, "Joining frame %d/%d", 1+i, n);
00190
00191 skip_if (visir_util_join_one(framelist, rawframes, bpmframes, errframes,
00192 conframes, wgtframes, qcframes, i, nbad == 1,
00193 nerr == 1, ncon == 1, nwgt == 1, nqc == 1,
00194 parlist));
00195 }
00196
00197 end_skip;
00198
00199 irplib_framelist_delete(allframes);
00200 irplib_framelist_delete(rawframes);
00201 irplib_framelist_delete(bpmframes);
00202 irplib_framelist_delete(errframes);
00203 irplib_framelist_delete(conframes);
00204 irplib_framelist_delete(wgtframes);
00205 irplib_framelist_delete(qcframes);
00206
00207 return cpl_error_get_code();
00208 }
00209
00210
00211
00230
00231 static
00232 cpl_error_code visir_util_join_one(cpl_frameset * framelist,
00233 const irplib_framelist * rawframes,
00234 const irplib_framelist * bpmframes,
00235 const irplib_framelist * errframes,
00236 const irplib_framelist * conframes,
00237 const irplib_framelist * wgtframes,
00238 const irplib_framelist * qcframes,
00239 int i,
00240 cpl_boolean bshared, cpl_boolean eshared,
00241 cpl_boolean cshared, cpl_boolean wshared,
00242 cpl_boolean qcshared,
00243 const cpl_parameterlist * parlist)
00244 {
00245
00246 const int n = irplib_framelist_get_size(rawframes);
00247 const cpl_frame * frame;
00248 cpl_frameset * products = cpl_frameset_new();
00249 cpl_frameset * usedframes = cpl_frameset_new();
00250 const char * filename;
00251 cpl_propertylist * img_plist = NULL;
00252 char * proname = NULL;
00253 cpl_image * img = NULL;
00254 cpl_image * csum = NULL;
00255 const char * bunit = NULL;
00256 char * inpcatg = NULL;
00257
00258 cpl_image * bpm = NULL;
00259 cpl_image * err = NULL;
00260 cpl_image * wgt = NULL;
00261 cpl_image * con = NULL;
00262
00263 cpl_propertylist * bpm_plist = NULL;
00264 cpl_propertylist * err_plist = NULL;
00265 cpl_propertylist * wgt_plist = NULL;
00266 cpl_propertylist * con_plist = NULL;
00267 cpl_propertylist * qc_plist = NULL;
00268
00269 const char * procatg = VISIR_UTIL_JOIN_PROCATG;
00270
00271 bug_if(cpl_frameset_insert(usedframes, cpl_frame_duplicate
00272 (irplib_framelist_get_const(rawframes, i))));
00273
00274
00275 frame = irplib_framelist_get_const(rawframes, i);
00276 filename = cpl_frame_get_filename(frame);
00277
00278 img_plist = cpl_propertylist_load(filename, 0);
00279 skip_if(img_plist == NULL);
00280
00281 img = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED, 0, 0);
00282 skip_if(img == NULL);
00283
00284 if (qcframes) {
00285 const cpl_frame * qcframe =
00286 irplib_framelist_get_const(qcframes, qcshared ? 0 : i);
00287 filename = cpl_frame_get_filename(qcframe);
00288 qc_plist = cpl_propertylist_load_regexp(filename, 0,
00289 "ESO QC |BUNIT|ESO DRS CATG", CPL_FALSE);
00290 skip_if (qc_plist == NULL);
00291 if (cpl_propertylist_has(qc_plist, "BUNIT")) {
00292 bunit = cpl_propertylist_get_string(qc_plist, "BUNIT");
00293 }
00294 if (cpl_propertylist_has(qc_plist, "ESO DRS CATG")) {
00295 inpcatg =
00296 cpl_strdup(cpl_propertylist_get_string(qc_plist, "ESO DRS CATG"));
00297 cpl_propertylist_erase(qc_plist, "ESO DRS CATG");
00298 }
00299 }
00300
00301 if (bunit == NULL && cpl_propertylist_has(img_plist, "BUNIT")) {
00302 bunit = cpl_propertylist_get_string(img_plist, "BUNIT");
00303 }
00304 if (inpcatg == NULL && cpl_propertylist_has(img_plist, "ESO DRS CATG")) {
00305 inpcatg =
00306 cpl_strdup(cpl_propertylist_get_string(img_plist, "ESO DRS CATG"));
00307 cpl_propertylist_erase(img_plist, "ESO DRS CATG");
00308 }
00309 cpl_propertylist_append(img_plist, qc_plist);
00310
00311 if (!strcmp(cpl_frame_get_tag(frame), VISIR_IMG_PHOT_ONEBEAM_PROCATG))
00312 procatg = VISIR_IMG_PHOT_ONEBEAM_PROCATG;
00313 else if (!strcmp(cpl_frame_get_tag(frame), VISIR_IMG_PHOT_COMBINED_PROCATG))
00314 procatg = VISIR_IMG_PHOT_COMBINED_PROCATG;
00315 else if (!strcmp(cpl_frame_get_tag(frame), VISIR_IMG_COADDED_IMG))
00316 procatg = VISIR_IMG_OBJ_COMBINED_PROCATG;
00317 else if (!strcmp(cpl_frame_get_tag(frame), "COADDED_IMAGE"))
00318 procatg = VISIR_IMG_OBJ_ONEBEAM_PROCATG;
00319
00320 procatg = visir_dfs_output_catg(inpcatg, procatg);
00321
00322 if (cpl_propertylist_has(img_plist, "ESO QC BEAMID")) {
00323 const char * b = cpl_propertylist_get_string(img_plist,
00324 "ESO QC BEAMID");
00325 proname = cpl_sprintf(RECIPE_STRING "_b%s_%03d"
00326 CPL_DFS_FITS, b, 1+i);
00327 }
00328 else
00329 proname = cpl_sprintf(RECIPE_STRING "_%03d"
00330 CPL_DFS_FITS, 1+i);
00331
00332 if (bpmframes != NULL) {
00333
00334 frame = irplib_framelist_get_const(bpmframes, bshared ? 0 : i);
00335
00336 filename = cpl_frame_get_filename(frame);
00337
00338 bpm = cpl_image_load(filename, CPL_TYPE_INT, 0, 0);
00339 skip_if(bpm == NULL);
00340
00341 bpm_plist = cpl_propertylist_load_regexp(filename, 0, " ESO QC | ESO PRO ",
00342 0);
00343 skip_if(bpm_plist == NULL);
00344 cpl_propertylist_append_string(bpm_plist, "EXTNAME", VISIR_EXTN_BPM);
00345 }
00346
00347 if (errframes != NULL) {
00348
00349
00350 frame = irplib_framelist_get_const(errframes, eshared ? 0 : i);
00351
00352 filename = cpl_frame_get_filename(frame);
00353
00354 err = cpl_image_load(filename, CPL_TYPE_UNSPECIFIED, 0, 0);
00355 skip_if(err == NULL);
00356
00357 err_plist = cpl_propertylist_load_regexp(filename, 0, " ESO QC | ESO PRO ",
00358 0);
00359 skip_if(err_plist == NULL);
00360 cpl_propertylist_append_string(err_plist, "EXTNAME", VISIR_EXTN_ERROR);
00361 if (bunit) {
00362 cpl_propertylist_append_string(err_plist, "BUNIT", bunit);
00363 }
00364
00365 if (wgtframes == NULL) {
00366 wgt = cpl_image_new(cpl_image_get_size_x(err),
00367 cpl_image_get_size_y(err),
00368 CPL_TYPE_FLOAT);
00369 cpl_image_add_scalar(wgt, 1.0);
00370 cpl_image_divide(wgt, err);
00371 cpl_image_power(wgt, 2);
00372 wgt_plist = cpl_propertylist_new();
00373 cpl_propertylist_append_string(wgt_plist, "EXTNAME", VISIR_EXTN_WEIGHT);
00374 skip_if(0);
00375 }
00376
00377 }
00378
00379 if (conframes != NULL) {
00380
00381
00382 if (cshared || irplib_framelist_get_size(conframes) == n) {
00383
00384 frame = irplib_framelist_get_const(conframes, cshared ? 0 : i);
00385
00386 filename = cpl_frame_get_filename(frame);
00387
00388 con = cpl_image_load(filename, CPL_TYPE_INT, 0, 0);
00389 skip_if(con == NULL);
00390
00391 con_plist = cpl_propertylist_load_regexp(filename, 0, " ESO QC | ESO PRO ",
00392 0);
00393 skip_if(con_plist == NULL);
00394
00395 } else {
00396
00397 const int ncon = irplib_framelist_get_size(conframes);
00398 const int nz = ncon / n;
00399 int j;
00400
00401 for (j = i * nz; j < i * nz + nz; j ++) {
00402 frame = irplib_framelist_get_const(conframes, j);
00403 bug_if(cpl_frameset_insert(usedframes,
00404 cpl_frame_duplicate(frame)));
00405
00406 filename = cpl_frame_get_filename(frame);
00407
00408 if (j == i * nz) {
00409
00410 con = cpl_image_load(filename, CPL_TYPE_INT, 0, 0);
00411 skip_if(con == NULL);
00412
00413 } else {
00414 csum = cpl_image_load(filename, CPL_TYPE_INT, 0, 0);
00415 skip_if(csum == NULL);
00416 skip_if(cpl_image_add(con, csum));
00417 }
00418 }
00419
00420 }
00421
00422 if (bpm == NULL) {
00423 bpm = cpl_image_duplicate(con);
00424
00425
00426 bug_if(cpl_image_threshold(bpm, -0.5, 1.0, 0.5, 1.0));
00427 bug_if(cpl_image_multiply_scalar(bpm, -1.0));
00428 bug_if(cpl_image_add_scalar(bpm, 1.0));
00429
00430 bpm_plist = cpl_propertylist_new();
00431 cpl_propertylist_append_string(bpm_plist, "EXTNAME", VISIR_EXTN_BPM);
00432 }
00433 }
00434
00435
00436 if (wgtframes != NULL) {
00437
00438
00439 frame = irplib_framelist_get_const(wgtframes, wshared ? 0 : i);
00440
00441 filename = cpl_frame_get_filename(frame);
00442
00443 wgt_plist = cpl_propertylist_load_regexp(filename, 0, " ESO QC | ESO PRO ",
00444 0);
00445 skip_if(wgt_plist == NULL);
00446
00447 bug_if(cpl_propertylist_append_string(wgt_plist, "EXTNAME", VISIR_EXTN_WEIGHT));
00448
00449 wgt = cpl_image_load(filename, CPL_TYPE_FLOAT, 0, 0);
00450 skip_if(wgt == NULL);
00451
00452 if (err == NULL) {
00453 err = cpl_image_new(cpl_image_get_size_x(wgt),
00454 cpl_image_get_size_y(wgt), CPL_TYPE_FLOAT);
00455 cpl_image_add_scalar(err, 1.0);
00456 cpl_image_divide(err, wgt);
00457 cpl_image_power(err, 0.5);
00458 cpl_image_fill_rejected(err, INFINITY);
00459 err_plist = cpl_propertylist_new();
00460 cpl_propertylist_append_string(err_plist, "EXTNAME", VISIR_EXTN_ERROR);
00461 if (bunit) {
00462 cpl_propertylist_append_string(err_plist, "BUNIT", bunit);
00463 }
00464 skip_if(0);
00465 }
00466
00467 }
00468
00469 if (err != NULL && con == NULL && bpm == NULL) {
00470
00471
00472 cpl_mask * mbpm = cpl_mask_threshold_image_create(err, -DBL_EPSILON, 1e8);
00473 cpl_mask_not(mbpm);
00474 bpm = cpl_image_new_from_mask(mbpm);
00475 cpl_mask_delete(mbpm);
00476
00477 bpm_plist = cpl_propertylist_new();
00478 cpl_propertylist_append_string(bpm_plist, "EXTNAME", VISIR_EXTN_BPM);
00479 }
00480 skip_if(0);
00481
00482
00483 if (!cpl_propertylist_has(img_plist, "ESO QC GAUSSFIT FWHM_MAX")) {
00484 cpl_errorstate cleanstate = cpl_errorstate_get();
00485 double fwhm_x = -1., fwhm_y = -1.,
00486 peak = -1., peak_err = 0.,
00487 major = -1., major_err = 0.,
00488 minor = -1., minor_err = 0.,
00489 angle = -1., angle_err = 0.;
00490 cpl_size x_pos = cpl_propertylist_get_double(img_plist, "CRPIX1");
00491 cpl_size y_pos = cpl_propertylist_get_double(img_plist, "CRPIX2");
00492 cpl_image * lwgt = wgt;
00493
00494
00495 cpl_image_get_fwhm(img, (int)x_pos, (int)y_pos, &fwhm_x, &fwhm_y);
00496
00497 if (lwgt == NULL) {
00498 lwgt = cpl_image_new(cpl_image_get_size_x(img), cpl_image_get_size_y(img), CPL_TYPE_DOUBLE);
00499 cpl_image_add_scalar(lwgt, 1);
00500 }
00501 if (fit_2d_gauss(img, lwgt, (cpl_size)x_pos, (cpl_size)y_pos,
00502 fwhm_x, fwhm_y, &peak, &peak_err,
00503 &major, &major_err, &minor, &minor_err,
00504 &angle, &angle_err) == CPL_ERROR_NONE) {
00505 cpl_msg_info(cpl_func, "Peak: %g +- %g, FWHM : %g +- %g major ; %g +- %g minor, "
00506 "angle %g +- %g", peak, peak_err,
00507 major, major_err, minor, minor_err,
00508 angle * CPL_MATH_DEG_RAD,
00509 angle_err * CPL_MATH_DEG_RAD);
00510 cpl_propertylist_append_double(img_plist, "ESO QC GAUSSFIT FWHM_MAX",
00511 major);
00512 cpl_propertylist_set_comment(img_plist, "ESO QC GAUSSFIT FWHM_MAX",
00513 "major axis [pix]");
00514 cpl_propertylist_append_double(img_plist, "ESO QC GAUSSFIT FWHM_MAX_ERR",
00515 major_err);
00516 cpl_propertylist_append_double(img_plist, "ESO QC GAUSSFIT FWHM_MIN",
00517 minor);
00518 cpl_propertylist_set_comment(img_plist, "ESO QC GAUSSFIT FWHM_MIN",
00519 "minor axis [pix]");
00520 cpl_propertylist_append_double(img_plist, "ESO QC GAUSSFIT FWHM_MIN_ERR",
00521 minor_err);
00522 cpl_propertylist_append_double(img_plist, "ESO QC GAUSSFIT ANGLE",
00523 angle * CPL_MATH_DEG_RAD);
00524 cpl_propertylist_set_comment(img_plist, "ESO QC GAUSSFIT ANGLE",
00525 "[deg]");
00526 cpl_propertylist_append_double(img_plist, "ESO QC GAUSSFIT ANGLE_ERR",
00527 angle_err * CPL_MATH_DEG_RAD);
00528 cpl_propertylist_append_double(img_plist, "ESO QC GAUSSFIT PEAK",
00529 peak);
00530 cpl_propertylist_append_double(img_plist, "ESO QC GAUSSFIT PEAK_ERR",
00531 peak_err);
00532 }
00533 else {
00534 cpl_msg_warning(cpl_func, "2D gauss fit failed, approximate FWHM : %g"
00535 "in x ; %g in y ", fwhm_x, fwhm_y);
00536 }
00537
00538 if (lwgt != wgt) {
00539 cpl_image_delete(lwgt);
00540 }
00541
00542 cpl_errorstate_set(cleanstate);
00543 }
00544
00545 skip_if(irplib_dfs_save_image(products, parlist, usedframes,
00546 img, CPL_TYPE_UNSPECIFIED,
00547 RECIPE_STRING,
00548 procatg, img_plist,
00549 NULL, visir_pipe_id, proname));
00550
00551 if (bpm) {
00552 if (bpmframes) {
00553 frame = irplib_framelist_get_const(bpmframes, bshared ? 0 : i);
00554 bug_if(cpl_frameset_insert(usedframes, cpl_frame_duplicate(frame)));
00555 }
00556 skip_if(cpl_image_save(bpm, proname, CPL_BPP_8_UNSIGNED,
00557 bpm_plist, CPL_IO_EXTEND));
00558 }
00559 if (err) {
00560 if (errframes) {
00561 frame = irplib_framelist_get_const(errframes, eshared ? 0 : i);
00562 bug_if(cpl_frameset_insert(usedframes, cpl_frame_duplicate(frame)));
00563 }
00564 skip_if(cpl_image_save(err, proname, CPL_TYPE_UNSPECIFIED,
00565 err_plist, CPL_IO_EXTEND));
00566 }
00567 if (con) {
00568 if (conframes) {
00569 frame = irplib_framelist_get_const(conframes, cshared ? 0 : i);
00570 bug_if(cpl_frameset_insert(usedframes, cpl_frame_duplicate(frame)));
00571 }
00572 skip_if(cpl_image_save(con, proname, CPL_TYPE_UNSPECIFIED,
00573 con_plist, CPL_IO_EXTEND));
00574 }
00575 if (wgt) {
00576 if (wgtframes) {
00577 frame = irplib_framelist_get_const(wgtframes, wshared ? 0 : i);
00578 bug_if(cpl_frameset_insert(usedframes, cpl_frame_duplicate(frame)));
00579 }
00580 skip_if(cpl_image_save(wgt, proname, CPL_TYPE_UNSPECIFIED,
00581 wgt_plist, CPL_IO_EXTEND));
00582 }
00583
00584 FOR_EACH_FRAMESET_C(frm, products) {
00585 cpl_frame * copy = cpl_frame_duplicate(frm);
00586 cpl_error_code error = cpl_frameset_insert(framelist, copy);
00587
00588 if (error) break;
00589 }
00590
00591 end_skip;
00592
00593 cpl_image_delete(img);
00594 cpl_image_delete(err);
00595 cpl_image_delete(wgt);
00596 cpl_image_delete(con);
00597 cpl_image_delete(bpm);
00598 cpl_image_delete(csum);
00599 cpl_free(proname);
00600 cpl_free(inpcatg);
00601 cpl_propertylist_delete(img_plist);
00602 cpl_propertylist_delete(err_plist);
00603 cpl_propertylist_delete(wgt_plist);
00604 cpl_propertylist_delete(con_plist);
00605 cpl_propertylist_delete(bpm_plist);
00606 cpl_propertylist_delete(qc_plist);
00607 cpl_frameset_delete(usedframes);
00608 cpl_frameset_delete(products);
00609
00610 return cpl_error_get_code();
00611 }