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 "irplib_stdstar.h"
00037 #include "irplib_utils.h"
00038 #include "irplib_wcs.h"
00039 #include <cpl.h>
00040
00041 #include <string.h>
00042 #include <math.h>
00043 #include <float.h>
00044
00045
00046
00047
00048
00049 #if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(6, 3, 0)
00050 #define IRPLIB_FRAMESET_GET_CONST cpl_frameset_get_position_const
00051 #else
00052
00053 #define IRPLIB_FRAMESET_GET_CONST cpl_frameset_get_frame_const
00054 #endif
00055
00056
00057
00061
00064
00065
00066
00067
00068
00087
00088 cpl_error_code
00089 irplib_stdstar_write_catalogs(cpl_frameset * set_in,
00090 const cpl_frameset * set_raw,
00091 const char * recipe_name,
00092 const char * pro_cat,
00093 const char * pro_type,
00094 const char * package_name,
00095 const char * ins_name,
00096 cpl_table * (*convert_ascii_table)(const char *))
00097 {
00098
00099 const cpl_size nb_catalogs = cpl_frameset_get_size(set_raw);
00100 cpl_propertylist * plist_ext;
00101 char * out_name;
00102 cpl_error_code error = CPL_ERROR_NONE;
00103 cpl_size i;
00104
00105
00106 if (set_in == NULL) return cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00107 if (set_raw == NULL) return cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00108 if (recipe_name == NULL) return cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00109 if (pro_cat == NULL) return cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00110 if (ins_name == NULL) return cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00111 if (convert_ascii_table == NULL) return
00112 cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00113
00114
00115 out_name = cpl_sprintf("%s" CPL_DFS_FITS, recipe_name);
00116
00117 plist_ext = cpl_propertylist_new();
00118
00119
00120 for (i = 0; i < nb_catalogs; i++) {
00121
00122 const cpl_frame * cur_frame = IRPLIB_FRAMESET_GET_CONST(set_raw, i);
00123 const char * cat_name = cpl_frame_get_filename(cur_frame);
00124
00125 cpl_table * out = convert_ascii_table(cat_name);
00126
00127
00128 if (out == NULL) {
00129 error = cpl_error_get_code() ? cpl_error_set_where(cpl_func)
00130 : cpl_error_set(cpl_func, CPL_ERROR_UNSPECIFIED);
00131 break;
00132 }
00133
00134 if (cpl_table_get_nrow(out) == 0) {
00135 cpl_table_delete(out);
00136 error = cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
00137 "Empty catalogue %d in '%s'",
00138 (int)i+1, cat_name);
00139 break;
00140 }
00141
00142 cpl_propertylist_update_string(plist_ext, "EXTNAME", cat_name);
00143
00144
00145 if (i == 0) {
00146 cpl_parameterlist * parlist = cpl_parameterlist_new();
00147 cpl_propertylist * plist = cpl_propertylist_new();
00148
00149
00150 cpl_propertylist_append_string(plist, "INSTRUME", ins_name);
00151 cpl_propertylist_append_string(plist, CPL_DFS_PRO_CATG, pro_cat);
00152 if (pro_type != NULL) {
00153 cpl_propertylist_append_string(plist, CPL_DFS_PRO_TYPE,
00154 pro_type);
00155 }
00156
00157 error = cpl_dfs_save_table(set_in, NULL, parlist, set_raw, NULL,
00158 out, plist_ext, recipe_name, plist,
00159 NULL, package_name, out_name);
00160 cpl_parameterlist_delete(parlist);
00161 cpl_propertylist_delete(plist);
00162 } else {
00163 error = cpl_table_save(out, NULL, plist_ext, out_name,
00164 CPL_IO_EXTEND);
00165 }
00166
00167 cpl_table_delete(out);
00168
00169 if (error) {
00170 (void)cpl_error_set_where(cpl_func);
00171 break;
00172 }
00173 }
00174
00175 cpl_propertylist_delete(plist_ext);
00176 cpl_free(out_name);
00177
00178 return error;
00179 }
00180
00181
00194
00195 cpl_table * irplib_stdstar_load_catalog(
00196 const char * filename,
00197 const char * ext_name)
00198 {
00199 int next;
00200 cpl_table * out;
00201 cpl_table * out_cur;
00202 cpl_frame * cur_frame;
00203 int i;
00204
00205
00206 if (filename == NULL) return NULL;
00207 if (ext_name == NULL) return NULL;
00208
00209
00210 out = NULL;
00211
00212
00213 cur_frame = cpl_frame_new();
00214 cpl_frame_set_filename(cur_frame, filename);
00215 next = cpl_frame_get_nextensions(cur_frame);
00216 cpl_frame_delete(cur_frame);
00217
00218
00219 for (i=0; i<next; i++) {
00220 cpl_propertylist * plist;
00221 const char * cur_name;
00222
00223
00224 if ((plist = cpl_propertylist_load_regexp(filename, i+1, "EXTNAME",
00225 0)) == NULL) {
00226 cpl_msg_error(cpl_func, "Cannot load header of %d th extension",
00227 i+1);
00228 return NULL;
00229 }
00230 cur_name = cpl_propertylist_get_string(plist, "EXTNAME");
00231
00232
00233 if (!strcmp(cur_name, ext_name)) {
00234
00235 if (out == NULL) {
00236 out = cpl_table_load(filename, i+1, 1);
00237 cpl_table_new_column(out, IRPLIB_STDSTAR_CAT_COL, CPL_TYPE_STRING);
00238 cpl_table_fill_column_window_string(out, IRPLIB_STDSTAR_CAT_COL,
00239 0, cpl_table_get_nrow(out),
00240 cur_name);
00241 if (out == NULL) {
00242 cpl_msg_error(cpl_func, "Cannot load extension %d", i+1);
00243 cpl_propertylist_delete(plist);
00244 return NULL;
00245 }
00246 }
00247 } else if (!strcmp(ext_name, "all")) {
00248
00249 if (i==0) {
00250
00251 out = cpl_table_load(filename, i+1, 1);
00252 cpl_table_new_column(out, IRPLIB_STDSTAR_CAT_COL, CPL_TYPE_STRING);
00253 cpl_table_fill_column_window_string(out, IRPLIB_STDSTAR_CAT_COL,
00254 0, cpl_table_get_nrow(out),
00255 cur_name);
00256 if (out == NULL) {
00257 cpl_msg_error(cpl_func, "Cannot load extension %d", i+1);
00258 cpl_propertylist_delete(plist);
00259 return NULL;
00260 }
00261 } else {
00262
00263 out_cur = cpl_table_load(filename, i+1, 1);
00264 if (out_cur == NULL) {
00265 cpl_msg_error(cpl_func, "Cannot load extension %d", i+1);
00266 cpl_table_delete(out);
00267 cpl_propertylist_delete(plist);
00268 return NULL;
00269 }
00270 cpl_table_new_column(out_cur, IRPLIB_STDSTAR_CAT_COL, CPL_TYPE_STRING);
00271 cpl_table_fill_column_window_string(out_cur, IRPLIB_STDSTAR_CAT_COL,
00272 0, cpl_table_get_nrow(out_cur),
00273 cur_name);
00274
00275 if (cpl_table_insert(out, out_cur,
00276 cpl_table_get_nrow(out)) != CPL_ERROR_NONE) {
00277 cpl_msg_error(cpl_func, "Cannot merge table %d", i+1);
00278 cpl_table_delete(out);
00279 cpl_table_delete(out_cur);
00280 cpl_propertylist_delete(plist);
00281 return NULL;
00282 }
00283 cpl_table_delete(out_cur);
00284 }
00285 }
00286 cpl_propertylist_delete(plist);
00287 }
00288 return out;
00289 }
00290
00291
00300
00301 cpl_error_code irplib_stdstar_check_columns_exist(
00302 const cpl_table * catal)
00303 {
00304
00305 if (!cpl_table_has_column(catal, IRPLIB_STDSTAR_STAR_COL)) {
00306 return cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
00307 "Missing column: %s",
00308 IRPLIB_STDSTAR_STAR_COL);
00309 }
00310 if (!cpl_table_has_column(catal, IRPLIB_STDSTAR_TYPE_COL)) {
00311 return cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
00312 "Missing column: %s",
00313 IRPLIB_STDSTAR_TYPE_COL);
00314 }
00315 if (!cpl_table_has_column(catal, IRPLIB_STDSTAR_CAT_COL)) {
00316 return cpl_error_set_message(cpl_func,
00317 CPL_ERROR_ILLEGAL_INPUT,
00318 "Missing column: %s",
00319 IRPLIB_STDSTAR_CAT_COL);
00320 }
00321 if (!cpl_table_has_column(catal, IRPLIB_STDSTAR_RA_COL)) {
00322 return cpl_error_set_message(cpl_func,
00323 CPL_ERROR_ILLEGAL_INPUT,
00324 "Missing column: %s",
00325 IRPLIB_STDSTAR_RA_COL);
00326 }
00327 if (!cpl_table_has_column(catal, IRPLIB_STDSTAR_DEC_COL)) {
00328 return cpl_error_set_message(cpl_func,
00329 CPL_ERROR_ILLEGAL_INPUT,
00330 "Missing column: %s",
00331 IRPLIB_STDSTAR_DEC_COL);
00332 }
00333 return CPL_ERROR_NONE;
00334 }
00335
00336
00348
00349 int irplib_stdstar_select_stars_dist(
00350 cpl_table * cat,
00351 double ra,
00352 double dec,
00353 double dist)
00354 {
00355 double distance;
00356 int nrows;
00357 int i;
00358
00359
00360 if (cat == NULL) return -1;
00361
00362
00363 nrows = cpl_table_get_nrow(cat);
00364
00365
00366 if (!cpl_table_has_column(cat, IRPLIB_STDSTAR_RA_COL)) {
00367 cpl_msg_error(cpl_func, "Missing %s column", IRPLIB_STDSTAR_RA_COL);
00368 return -1;
00369 }
00370 if (!cpl_table_has_column(cat, IRPLIB_STDSTAR_DEC_COL)) {
00371 cpl_msg_error(cpl_func, "Missing %s column", IRPLIB_STDSTAR_DEC_COL);
00372 return -1;
00373 }
00374
00375
00376 for (i=0; i<nrows; i++) {
00377 if (cpl_table_is_selected(cat, i)) {
00378
00379 distance = irplib_wcs_great_circle_dist(ra, dec,
00380 cpl_table_get_double(cat, IRPLIB_STDSTAR_RA_COL, i, NULL),
00381 cpl_table_get_double(cat, IRPLIB_STDSTAR_DEC_COL, i, NULL));
00382 if (distance > dist) cpl_table_unselect_row(cat, i);
00383 }
00384 }
00385 return 0;
00386 }
00387
00388
00397
00398 int irplib_stdstar_select_stars_mag(
00399 cpl_table * cat,
00400 const char * mag_colname)
00401 {
00402
00403 if (cat == NULL) return -1;
00404 if (mag_colname == NULL) return -1;
00405
00406
00407 if (!cpl_table_has_column(cat, mag_colname)) {
00408 cpl_msg_error(cpl_func, "Column %s does not exist in the catalog",
00409 mag_colname);
00410 return -1;
00411 }
00412
00413
00414 if (cpl_table_and_selected_double(cat, mag_colname, CPL_NOT_GREATER_THAN,
00415 98.0) <= 0) {
00416 cpl_msg_error(cpl_func, "Column %s does not exist in the catalog",
00417 mag_colname);
00418 return -1;
00419 }
00420 return 0;
00421 }
00422
00423
00433
00434 int irplib_stdstar_find_closest(
00435 const cpl_table * cat,
00436 double ra,
00437 double dec)
00438 {
00439 double min_dist, distance;
00440 int nrows;
00441 int ind;
00442 int i;
00443
00444
00445 if (cat == NULL) return -1;
00446
00447
00448 min_dist = 1000.0;
00449 ind = -1;
00450
00451
00452 nrows = cpl_table_get_nrow(cat);
00453
00454
00455 if (!cpl_table_has_column(cat, IRPLIB_STDSTAR_RA_COL)) {
00456 cpl_msg_error(cpl_func, "Missing %s column", IRPLIB_STDSTAR_RA_COL);
00457 return -1;
00458 }
00459 if (!cpl_table_has_column(cat, IRPLIB_STDSTAR_DEC_COL)) {
00460 cpl_msg_error(cpl_func, "Missing %s column", IRPLIB_STDSTAR_DEC_COL);
00461 return -1;
00462 }
00463
00464
00465 for (i=0; i<nrows; i++) {
00466 if (cpl_table_is_selected(cat, i)) {
00467
00468 distance = irplib_wcs_great_circle_dist(ra, dec,
00469 cpl_table_get_double(cat, IRPLIB_STDSTAR_RA_COL, i, NULL),
00470 cpl_table_get_double(cat, IRPLIB_STDSTAR_DEC_COL, i, NULL));
00471 if (distance <= min_dist) {
00472 min_dist = distance;
00473 ind = i;
00474 }
00475 }
00476 }
00477 return ind;
00478 }
00479
00480
00501
00502 cpl_error_code irplib_stdstar_find_star(
00503 const char * catfile,
00504 double ra,
00505 double dec,
00506 const char * band,
00507 const char * catname,
00508 double * mag,
00509 char ** name,
00510 char ** type,
00511 char ** usedcatname,
00512 double * star_ra,
00513 double * star_dec,
00514 double dist_am)
00515 {
00516 cpl_errorstate prestate = cpl_errorstate_get();
00517 cpl_table * catal;
00518 const double dist = dist_am / 60.0;
00519 int ind;
00520
00521
00522 if (catfile == NULL) return cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00523 if (band == NULL) return cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00524 if (catname == NULL) return cpl_error_set(cpl_func, CPL_ERROR_NULL_INPUT);
00525
00526
00527 if ((catal = irplib_stdstar_load_catalog(catfile, catname)) == NULL) {
00528 return cpl_error_set_message(cpl_func, CPL_ERROR_FILE_NOT_FOUND,
00529 "Cannot load the catalog %s from %s",
00530 catname, catfile);
00531 }
00532
00533
00534 if (irplib_stdstar_check_columns_exist(catal) != CPL_ERROR_NONE) {
00535 cpl_table_delete(catal);
00536 return cpl_error_set_where(cpl_func);
00537 }
00538
00539
00540 if (irplib_stdstar_select_stars_mag(catal, band) == -1) {
00541 cpl_table_delete(catal);
00542 return cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
00543 "Cannot select stars in that band");
00544 }
00545
00546
00547 if (irplib_stdstar_select_stars_dist(catal, ra, dec, dist) == -1) {
00548 cpl_table_delete(catal);
00549 return cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
00550 "Cannot select close stars");
00551 }
00552
00553
00554 if ((ind=irplib_stdstar_find_closest(catal, ra, dec)) < 0) {
00555 cpl_table_delete(catal);
00556 return cpl_error_set_message(cpl_func, CPL_ERROR_ILLEGAL_INPUT,
00557 "Cannot get the closest star with "
00558 "known %s magnitude",band);
00559 }
00560
00561 if(mag != NULL)
00562 *mag = cpl_table_get_double(catal, band, ind, NULL);
00563
00564 if(name != NULL)
00565 {
00566 *name = cpl_strdup(cpl_table_get_string(catal,
00567 IRPLIB_STDSTAR_STAR_COL, ind));
00568
00569 }
00570 if(type != NULL)
00571 {
00572 *type = cpl_strdup(cpl_table_get_string(catal, IRPLIB_STDSTAR_TYPE_COL,
00573 ind));
00574 }
00575 if(usedcatname != NULL)
00576 {
00577 if(strcmp(catname, "all"))
00578 *usedcatname = cpl_strdup(catname);
00579 else
00580 {
00581 *usedcatname = cpl_strdup(cpl_table_get_string
00582 (catal, IRPLIB_STDSTAR_CAT_COL, ind));
00583 }
00584 }
00585 if(star_ra != NULL)
00586 *star_ra = cpl_table_get_double(catal, IRPLIB_STDSTAR_RA_COL, ind, NULL);
00587 if(star_dec != NULL)
00588 *star_dec = cpl_table_get_double(catal, IRPLIB_STDSTAR_DEC_COL, ind, NULL);
00589
00590
00591 cpl_table_delete(catal);
00592 return cpl_errorstate_is_equal(prestate) ? CPL_ERROR_NONE
00593 : cpl_error_set_where(cpl_func);
00594 }
00595
00596
00609
00610 cpl_vector * irplib_stdstar_get_conversion(
00611 const cpl_bivector * spec,
00612 double dit,
00613 double surface,
00614 double gain,
00615 double mag)
00616 {
00617 double h = 6.62e-27;
00618 double c = 3e18;
00619 const cpl_vector * wave;
00620 const cpl_vector * extr;
00621 cpl_vector * out;
00622 double factor;
00623
00624
00625 if (spec == NULL) return NULL;
00626 if (dit <= 0.0) return NULL;
00627
00628
00629 wave = cpl_bivector_get_x_const(spec);
00630 extr = cpl_bivector_get_y_const(spec);
00631
00632
00633 out = cpl_vector_duplicate(extr);
00634
00635
00636 cpl_vector_divide_scalar(out, dit);
00637
00638
00639 cpl_vector_divide_scalar(out, surface);
00640
00641
00642 cpl_vector_multiply_scalar(out, gain);
00643
00644
00645 factor = pow(10, mag/2.5);
00646 cpl_vector_multiply_scalar(out, factor);
00647
00648
00649 factor = (cpl_vector_get(wave, cpl_vector_get_size(wave)-1) -
00650 cpl_vector_get(wave, 0)) / cpl_vector_get_size(wave);
00651 cpl_vector_divide_scalar(out, factor);
00652
00653
00654 cpl_vector_multiply_scalar(out, h*c);
00655 cpl_vector_divide(out, wave);
00656
00657 return out;
00658 }
00659
00660
00668
00669 cpl_vector * irplib_stdstar_get_mag_zero(
00670 const cpl_bivector * sed,
00671 const cpl_vector * waves,
00672 double cent_wl)
00673 {
00674 double wmin, wmax, wstep;
00675 int nb_sed;
00676 const double * sed_x;
00677 const double * sed_y;
00678 cpl_bivector * sed_loc;
00679 double * sed_loc_x;
00680 double * sed_loc_y;
00681 cpl_vector * out;
00682 cpl_bivector * out_biv;
00683 double f0_jan, f0_erg, cent_val;
00684 int i;
00685
00686
00687 if (sed == NULL) return NULL;
00688 if (waves == NULL) return NULL;
00689
00690
00691 nb_sed = cpl_bivector_get_size(sed);
00692 sed_x = cpl_bivector_get_x_data_const(sed);
00693 sed_y = cpl_bivector_get_y_data_const(sed);
00694 wstep = sed_x[1] - sed_x[0];
00695 wmin = cpl_vector_get(waves, 0);
00696 wmax = cpl_vector_get(waves, cpl_vector_get_size(waves)-1);
00697
00698
00699 sed_loc = cpl_bivector_new(nb_sed + 4);
00700 sed_loc_x = cpl_bivector_get_x_data(sed_loc);
00701 sed_loc_y = cpl_bivector_get_y_data(sed_loc);
00702 for (i=0; i<nb_sed; i++) {
00703 sed_loc_x[i+2] = sed_x[i];
00704 sed_loc_y[i+2] = sed_y[i];
00705 }
00706
00707
00708 sed_loc_x[1] = sed_loc_x[2] - wstep;
00709 if (sed_loc_x[2] < wmin) {
00710 sed_loc_x[0] = sed_loc_x[1] - wstep;
00711 } else {
00712 sed_loc_x[0] = wmin - wstep;
00713 }
00714 sed_loc_y[0] = 1e-20;
00715 sed_loc_y[1] = 1e-20;
00716
00717
00718 sed_loc_x[nb_sed+2] = sed_loc_x[nb_sed+1] + wstep;
00719 if (sed_loc_x[nb_sed+1] > wmax) {
00720 sed_loc_x[nb_sed+3] = sed_loc_x[nb_sed+2] + wstep;
00721 } else {
00722 sed_loc_x[nb_sed+3] = wmax + wstep;
00723 }
00724 sed_loc_y[nb_sed+2] = 1e-20;
00725 sed_loc_y[nb_sed+3] = 1e-20;
00726
00727
00728 out = cpl_vector_duplicate(waves);
00729 IRPLIB_DIAG_PRAGMA_PUSH_IGN(-Wcast-qual);
00730
00731 out_biv = cpl_bivector_wrap_vectors((cpl_vector*)waves, out);
00732 IRPLIB_DIAG_PRAGMA_POP;
00733
00734 if (cpl_bivector_interpolate_linear(out_biv, sed_loc) != CPL_ERROR_NONE) {
00735 cpl_msg_error(cpl_func, "Cannot interpolate the wavelength");
00736 cpl_bivector_unwrap_vectors(out_biv);
00737 cpl_vector_delete(out);
00738 cpl_bivector_delete(sed_loc);
00739 return NULL;
00740 }
00741 cpl_bivector_unwrap_vectors(out_biv);
00742 cpl_bivector_delete(sed_loc);
00743
00744
00745 f0_jan = 5513.15 / ( pow(cent_wl,3) * (exp(1.2848/cent_wl)-1) );
00746
00747
00748 f0_erg = f0_jan * 1e-26 * 1e7 * 3e18 / (1e4 * cent_wl*cent_wl*1e4*1e4);
00749
00750
00751 cent_val = cpl_vector_get(out, cpl_vector_get_size(out)/2);
00752 if (cent_val <= 0.0) {
00753 cpl_msg_error(cpl_func, "Negative or 0 central value");
00754 cpl_vector_delete(out);
00755 return NULL;
00756 }
00757 cpl_vector_multiply_scalar(out, f0_erg/cent_val);
00758
00759
00760 return out;
00761 }
00762
00763
00773
00774 cpl_bivector * irplib_stdstar_get_sed(
00775 const char * seds_file,
00776 const char * sptype)
00777 {
00778 cpl_table * seds;
00779 cpl_bivector * out;
00780 cpl_vector * wave;
00781 cpl_vector * sed;
00782 cpl_bivector * tmp;
00783 int nlines;
00784
00785
00786 if (seds_file == NULL) return NULL;
00787 if (sptype == NULL) return NULL;
00788
00789
00790 if ((seds = cpl_table_load(seds_file, 1, 0)) == NULL) {
00791 cpl_msg_error(cpl_func, "Cannot load the table");
00792 return NULL;
00793 }
00794
00795
00796 if (!cpl_table_has_column(seds, sptype)) {
00797 cpl_msg_error(cpl_func, "SED of the requested star not available");
00798 cpl_table_delete(seds);
00799 return NULL;
00800 }
00801
00802
00803 nlines = cpl_table_get_nrow(seds);
00804
00805
00806 if ((wave = cpl_vector_wrap(nlines,
00807 cpl_table_get_data_double(seds, "Wavelength"))) == NULL) {
00808 cpl_msg_error(cpl_func, "Cannot get the Wavelength column");
00809 cpl_table_delete(seds);
00810 return NULL;
00811 }
00812
00813
00814 if ((sed = cpl_vector_wrap(nlines,
00815 cpl_table_get_data_double(seds, sptype))) == NULL) {
00816 cpl_msg_error(cpl_func, "Cannot get the SED column");
00817 cpl_table_delete(seds);
00818 cpl_vector_unwrap(wave);
00819 return NULL;
00820 }
00821 tmp = cpl_bivector_wrap_vectors(wave, sed);
00822
00823
00824 out = cpl_bivector_duplicate(tmp);
00825
00826
00827 cpl_bivector_unwrap_vectors(tmp);
00828 cpl_vector_unwrap(wave);
00829 cpl_vector_unwrap(sed);
00830 cpl_table_delete(seds);
00831
00832
00833 return out;
00834 }