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
00030
00031
00032
00033
00034
00035 #ifdef HAVE_CONFIG_H
00036 # include <config.h>
00037 #endif
00038
00039
00040
00041 #include <math.h>
00042
00043
00044 #include <irplib_stdstar.h>
00045 #include "irplib_utils.h"
00046 #include "sinfo_dfs.h"
00047 #include "sinfo_tpl_utils.h"
00048
00049 #include "sinfo_new_stdstar.h"
00050 #include "sinfo_standstar_ini_by_cpl.h"
00051 #include "sinfo_pro_save.h"
00052 #include "sinfo_pfits.h"
00053 #include "sinfo_utilities_scired.h"
00054 #include "sinfo_spectrum_ops.h"
00055 #include "sinfo_hidden.h"
00056 #include "sinfo_functions.h"
00057 #include "sinfo_utl_efficiency.h"
00058 #include "sinfo_error.h"
00059 #include "sinfo_utils_wrappers.h"
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 int
00097 sinfo_new_stdstar(const char* plugin_id,
00098 cpl_parameterlist* config,
00099 cpl_frameset* sof,cpl_frameset* ref_set)
00100 {
00101
00102 cpl_errorstate clean_state = cpl_errorstate_get();
00103 standstar_config * cfg=NULL ;
00104 cpl_imagelist * cube=NULL ;
00105
00106 cpl_imagelist * list_object=NULL ;
00107 cpl_image ** spectrum=NULL ;
00108 cpl_image * img_spct=NULL ;
00109
00110
00111
00112 cpl_frameset* raw=NULL;
00113 cpl_frame* frame=NULL;
00114 cpl_image* std_med_ima=NULL;
00115 cpl_image* std_med_dup=NULL;
00116
00117 cpl_table* qclog_tbl=NULL;
00118 cpl_table* tbl_spectrum=NULL;
00119 cpl_propertylist* plist=NULL;
00120
00121
00122 char * name=NULL ;
00123 int fra=0;
00124 float exptime=0 ;
00125 double convfactor=0;
00126 double cleanfactor=0;
00127 float* factor=NULL;
00128
00129 char std_med_filename[MAX_NAME_SIZE];
00130 char std_cub_filename[MAX_NAME_SIZE];
00131
00132 double max_ima_cx=0;
00133 double max_ima_cy=0;
00134 int max_ima_x=0;
00135 int max_ima_y=0;
00136 double norm=0;
00137 double xcen=0;
00138 double ycen=0;
00139 double sig_x=0;
00140 double sig_y=0;
00141 double fwhm_x=0;
00142 double fwhm_y=0;
00143 double disp=0;
00144 double dispersion=0;
00145 int i=0;
00146 int wllx=0;
00147 int wlly=0;
00148 int wurx=0;
00149 int wury=0;
00150 int psf_sz=40;
00151 int qc_info=0;
00152 int ima_szx=0;
00153 int ima_szy=0;
00154 int check1=0;
00155 int check2=0;
00156 int check3=0;
00157 int check4=0;
00158 double xshift=0;
00159 double yshift=0;
00160
00161 float cenpix = 0;
00162 float cenLambda = 0;
00163
00164 int no=0;
00165 double lo_cut=0.;
00166 double hi_cut=0.;
00167
00168 const char* stdstars=NULL;
00169 const char* sed=NULL;
00170 cpl_frame* frm_sci=NULL;
00171 cpl_frame* frm_atmext=NULL;
00172 cpl_frame* frm_std_cat=NULL;
00173 cpl_table* tot_eff=NULL;
00174 double fpar[7];
00175 double dpar[7];
00176 int mpar[7];
00177 int do_compute_eff=0;
00178 cpl_parameter* p=NULL;
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 check_nomsg(raw=cpl_frameset_new());
00193
00194 cknull(cfg=sinfo_parse_cpl_input_standstar(config,sof,&raw),
00195 "could not parse cpl input!") ;
00196
00197
00198 cknull_nomsg(p = cpl_parameterlist_find(config,
00199 "sinfoni.std_star.compute_eff"));
00200
00201 check_nomsg(do_compute_eff = cpl_parameter_get_bool(p));
00202 cknull(list_object = cpl_imagelist_new (),
00203 "could not allocate memory");
00204
00205
00206 sed = sinfo_extract_filename(sof, SINFO_CALIB_SED) ;
00207 stdstars = sinfo_extract_filename(sof, SINFO_CALIB_STDSTARS) ;
00208
00209
00210 if (cfg->convInd == 1) {
00211 factor = sinfo_new_floatarray(cfg->nframes);
00212 }
00213
00214 if(NULL != cpl_frameset_find(sof,PRO_COADD_STD)) {
00215 frame = cpl_frameset_find(sof,PRO_COADD_STD);
00216 strcpy(std_cub_filename,cpl_frame_get_filename(frame));
00217 } else if(NULL != cpl_frameset_find(sof,PRO_COADD_PSF)) {
00218 frame = cpl_frameset_find(sof,PRO_COADD_PSF);
00219 strcpy(std_cub_filename,cpl_frame_get_filename(frame));
00220 } else if(NULL != cpl_frameset_find(sof,PRO_COADD_OBJ)) {
00221 frame = cpl_frameset_find(sof,PRO_COADD_OBJ);
00222 strcpy(std_cub_filename,cpl_frame_get_filename(frame));
00223 } else if(NULL != cpl_frameset_find(sof,PRO_COADD_PUPIL)) {
00224 frame = cpl_frameset_find(sof,PRO_COADD_PUPIL);
00225 strcpy(std_cub_filename,cpl_frame_get_filename(frame));
00226 } else {
00227 sinfo_msg_error("Frame %s, %s, %s or %s not found! Exit!",
00228 PRO_COADD_STD,PRO_COADD_PSF,
00229 PRO_COADD_OBJ,PRO_COADD_PUPIL );
00230 goto cleanup;
00231 }
00232
00233
00234 cknull(plist = cpl_propertylist_load(std_cub_filename, 0),
00235 "getting header from reference ima frame %s",std_cub_filename);
00236
00237 cenpix = sinfo_pfits_get_crpix3(plist);
00238 cenLambda = sinfo_pfits_get_crval3(plist);
00239 dispersion = sinfo_pfits_get_cdelt3(plist);
00240
00241
00242 if (sinfo_propertylist_has(plist, KEY_NAME_CDELT3)) {
00243 disp=cpl_propertylist_get_double(plist, KEY_NAME_CDELT3);
00244 } else {
00245 sinfo_msg_warning("Keyword %s not found.",KEY_NAME_CDELT3);
00246 }
00247
00248
00249 sinfo_free_propertylist(&plist) ;
00250
00251
00252
00253
00254 if(NULL != cpl_frameset_find(sof,PRO_MED_COADD_STD)) {
00255 frame = cpl_frameset_find(sof,PRO_MED_COADD_STD);
00256 strcpy(std_med_filename,cpl_frame_get_filename(frame));
00257 check_nomsg(std_med_ima=cpl_image_load(std_med_filename,
00258 CPL_TYPE_FLOAT,0,0));
00259 } else if(NULL != cpl_frameset_find(sof,PRO_OBS_STD)) {
00260 check_nomsg(frame = cpl_frameset_find(sof,PRO_OBS_STD));
00261 strcpy(std_cub_filename,cpl_frame_get_filename(frame));
00262 check_nomsg(cube = cpl_imagelist_load(std_cub_filename,
00263 CPL_TYPE_FLOAT,0));
00264 strcpy(std_med_filename,STDSTAR_OUT_MED_CUBE);
00265 check_nomsg(std_med_ima=cpl_imagelist_collapse_median_create(cube));
00266 sinfo_free_imagelist(&cube);
00267
00268 ck0(sinfo_pro_save_ima(std_med_ima,ref_set,sof,STDSTAR_OUT_MED_CUBE,
00269 PRO_MED_OBS_PSF,NULL,plugin_id,config),
00270 "Error saving image %s tag %s",STDSTAR_OUT_MED_CUBE,PRO_MED_OBS_PSF);
00271
00272 } else if(NULL != cpl_frameset_find(sof,PRO_MED_COADD_PSF)) {
00273 check_nomsg(frame = cpl_frameset_find(sof,PRO_MED_COADD_PSF));
00274 strcpy(std_med_filename,cpl_frame_get_filename(frame));
00275 check_nomsg(std_med_ima=cpl_image_load(std_med_filename,
00276 CPL_TYPE_FLOAT,0,0));
00277 } else if(NULL != cpl_frameset_find(sof,PRO_OBS_PSF)) {
00278 check_nomsg(frame = cpl_frameset_find(sof,PRO_OBS_PSF));
00279 strcpy(std_cub_filename,cpl_frame_get_filename(frame));
00280 check_nomsg(cube=cpl_imagelist_load(std_cub_filename,CPL_TYPE_FLOAT,0));
00281 strcpy(std_med_filename,STDSTAR_OUT_MED_CUBE);
00282 check_nomsg(std_med_ima=cpl_imagelist_collapse_median_create(cube));
00283 sinfo_free_imagelist(&cube);
00284
00285 ck0(sinfo_pro_save_ima(std_med_ima,ref_set,sof,STDSTAR_OUT_MED_CUBE,
00286 PRO_MED_OBS_PSF,NULL,plugin_id,config),
00287 "Error saving image %s tag %s",STDSTAR_OUT_MED_CUBE,PRO_MED_OBS_PSF);
00288
00289 } else if(NULL != cpl_frameset_find(sof,PRO_MED_COADD_OBJ)) {
00290 check_nomsg(frame = cpl_frameset_find(sof,PRO_MED_COADD_OBJ));
00291 strcpy(std_med_filename,cpl_frame_get_filename(frame));
00292 check_nomsg(std_med_ima=cpl_image_load(std_med_filename,
00293 CPL_TYPE_FLOAT,0,0));
00294 } else if(NULL != cpl_frameset_find(sof,PRO_OBS_OBJ)) {
00295 check_nomsg(frame = cpl_frameset_find(sof,PRO_OBS_OBJ));
00296 strcpy(std_cub_filename,cpl_frame_get_filename(frame));
00297 check_nomsg(cube = cpl_imagelist_load(std_cub_filename,
00298 CPL_TYPE_FLOAT,0));
00299 strcpy(std_med_filename,STDSTAR_OUT_MED_CUBE);
00300 check_nomsg(std_med_ima=cpl_imagelist_collapse_median_create(cube));
00301 sinfo_free_imagelist(&cube);
00302
00303 ck0(sinfo_pro_save_ima(std_med_ima,ref_set,sof,STDSTAR_OUT_MED_CUBE,
00304 PRO_MED_OBS_OBJ,NULL,plugin_id,config),
00305 "Error saving image %s tag %s",STDSTAR_OUT_MED_CUBE,PRO_MED_OBS_OBJ);
00306 } else {
00307 sinfo_msg_error("Frame %s %s %s %s %s %s not found! Exit!",
00308 PRO_MED_COADD_STD, PRO_OBS_STD,
00309 PRO_MED_COADD_PSF, PRO_OBS_PSF,
00310 PRO_MED_COADD_OBJ, PRO_OBS_OBJ);
00311 goto cleanup;
00312 }
00313
00314
00315 check_nomsg(std_med_dup=cpl_image_duplicate(std_med_ima));
00316 sinfo_clean_nan(&std_med_dup);
00317 check_nomsg(cpl_image_get_maxpos(std_med_dup,&max_ima_x,&max_ima_y));
00318 sinfo_free_image(&std_med_dup);
00319
00320
00321 ima_szx=cpl_image_get_size_x(std_med_ima);
00322 ima_szy=cpl_image_get_size_y(std_med_ima);
00323 wllx= ((max_ima_x-psf_sz)>0) ? (max_ima_x-psf_sz) : 1;
00324 wlly= ((max_ima_y-psf_sz)>0) ? (max_ima_y-psf_sz) : 1;
00325 wurx= ((max_ima_x+psf_sz)<ima_szx) ? (max_ima_x+psf_sz) : ima_szx ;
00326 wury= ((max_ima_y+psf_sz)<ima_szy) ? (max_ima_y+psf_sz) : ima_szy ;
00327
00328
00329
00330
00331
00332 check_nomsg(qclog_tbl = sinfo_qclog_init());
00333 check_nomsg(max_ima_cx=cpl_image_get_centroid_x_window(std_med_ima,wllx,
00334 wlly,wurx,wury));
00335 check_nomsg(max_ima_cy=cpl_image_get_centroid_y_window(std_med_ima,wllx,
00336 wlly,wurx,wury));
00337
00338
00339 xshift=max_ima_cx-ima_szx/2;
00340 yshift=max_ima_cy-ima_szy/2;
00341
00342 ck0_nomsg(sinfo_qclog_add_double(qclog_tbl,"QC SHIFTX",xshift,
00343 "X shift centroid - center image","%f"));
00344
00345 ck0_nomsg(sinfo_qclog_add_double(qclog_tbl,"QC SHIFTY",yshift,
00346 "Y shift centroid - center image","%f"));
00347
00348 if(
00349 ((max_ima_x-psf_sz) < 1) ||
00350 ((max_ima_y-psf_sz) < 1) ||
00351 ((max_ima_x+psf_sz) > ima_szx) ||
00352 ((max_ima_x+psf_sz) > ima_szy)
00353 )
00354 {
00355 psf_sz = (psf_sz < (max_ima_x-1)) ? psf_sz : (max_ima_x-1);
00356 psf_sz = (psf_sz < (max_ima_y-1)) ? psf_sz : (max_ima_y-1);
00357 psf_sz = (psf_sz < ima_szx-max_ima_x) ? psf_sz : (ima_szx-max_ima_x);
00358 psf_sz = (psf_sz < ima_szy-max_ima_y) ? psf_sz : (ima_szy-max_ima_y);
00359
00360 psf_sz = (psf_sz > 4) ? psf_sz : 4;
00361 }
00362
00363
00364 ck0_nomsg(sinfo_qclog_add_int(qclog_tbl,"QC FWHM LLX",cfg->llx,
00365 "STD star FWHM LLX","%d"));
00366 ck0_nomsg(sinfo_qclog_add_int(qclog_tbl,"QC FWHM LLY",cfg->lly,
00367 "STD star FWHM LLY","%d"));
00368 ck0_nomsg(sinfo_qclog_add_int(qclog_tbl,"QC FWHM HBX",cfg->halfbox_x,
00369 "STD star FWHM HBX","%d"));
00370 ck0_nomsg(sinfo_qclog_add_int(qclog_tbl,"QC FWHM HBX",cfg->halfbox_y,
00371 "STD star FWHM HBY","%d"));
00372
00373
00374
00375 for ( i = 0 ; i < 7 ; i++ )
00376 {
00377 mpar[i] = 1 ;
00378 }
00379
00380
00381 if(-1 == sinfo_new_fit_2d_gaussian(std_med_ima,
00382 fpar,
00383 dpar,
00384 mpar,
00385 cfg->llx,
00386 cfg->lly,
00387 cfg->halfbox_x,
00388 cfg->halfbox_y,
00389 &check4 ) ) {
00390 irplib_error_recover(clean_state,"2d Gaussian fit failed");
00391
00392
00393 } else {
00394
00395 ck0_nomsg(sinfo_qclog_add_double(qclog_tbl,"QC FWHM MAJ",fpar[4],
00396 "STD star FWHM on major axis","%f"));
00397 ck0_nomsg(sinfo_qclog_add_double(qclog_tbl,"QC FWHM MIN",fpar[5],
00398 "STD star FWHM on minor axis","%f"));
00399 ck0_nomsg(sinfo_qclog_add_double(qclog_tbl,"QC THETA",fpar[6],
00400 "STD star ellipsis angle theta","%f"));
00401
00402
00403 }
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413 if(CPL_ERROR_NONE == cpl_image_fit_gaussian(std_med_ima,
00414 max_ima_x,
00415 max_ima_y,
00416 psf_sz,
00417 &norm,
00418 &xcen,
00419 &ycen,
00420 &sig_x,
00421 &sig_y,
00422 &fwhm_x,
00423 &fwhm_y)) {
00424
00425
00426 ck0_nomsg(sinfo_qclog_add_double(qclog_tbl,"QC FWHMX",fwhm_x,
00427 "STD star FWHM on X","%f"));
00428 ck0_nomsg(sinfo_qclog_add_double(qclog_tbl,"QC FWHMY",fwhm_y,
00429 "STD star FWHM on Y","%f"));
00430
00431 cfg -> halfbox_x = (floor)(0.5*(fwhm_x+fwhm_y)*cfg->fwhm_factor+0.5);
00432
00433 cfg -> halfbox_y = (floor)(0.5*(fwhm_x+fwhm_y)*cfg->fwhm_factor+0.5);
00434
00435 } else {
00436
00437 irplib_error_recover(clean_state,"Problem fitting Gaussian");
00438 cpl_error_reset();
00439
00440 }
00441 sinfo_free_image(&std_med_ima);
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451 cfg -> llx = (int)(xcen-cfg->halfbox_x);
00452 cfg -> llx = (cfg -> llx > 0 ) ? cfg -> llx : 1;
00453
00454 if((cfg->llx+2*cfg->halfbox_x) >= ima_szx) {
00455 cfg -> halfbox_x=(int) ((ima_szx-cfg->llx-1)/2);
00456 check1++;
00457 }
00458
00459 cfg -> lly = (int)(ycen-cfg->halfbox_y);
00460 cfg -> lly = (cfg -> lly > 0 ) ? cfg -> lly : 1;
00461 if((cfg->lly+2*cfg->halfbox_y) >= ima_szy) {
00462 cfg -> halfbox_y=(int) ((ima_szy-cfg->lly-1)/2);
00463 check1++;
00464 }
00465 ck0_nomsg(sinfo_qclog_add_int(qclog_tbl,"QC CHECK1",check1,
00466 "Check on evaluation box","%d"));
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480 sinfo_msg("Extraction");
00481 cknull(spectrum = (cpl_image**) cpl_calloc (cfg -> nframes,
00482 sizeof(cpl_image*)),
00483 "Could not allocate memory for spectrum image");
00484
00485 for (fra=0; fra < cfg->nframes; fra++) {
00486 name = cfg->inFrameList[fra];
00487 if(sinfo_is_fits_file(name) != 1) {
00488 sinfo_msg_error("Input file %s is not FITS",name);
00489 goto cleanup;
00490 }
00491 cknull(cube = cpl_imagelist_load(name,CPL_TYPE_FLOAT,0),
00492 "could not load data cube" );
00493
00494 if (exptime == FLAG) {
00495 sinfo_msg_error("could not find exposure time in the fits header");
00496 return -1;
00497 }
00498 exptime = sinfo_pfits_get_ditndit(name);
00499
00500 sinfo_msg("cfg->gain %f",cfg->gain);
00501 check_nomsg(tbl_spectrum=cpl_table_new(cpl_imagelist_get_size(cube)));
00502 if(NULL==(spectrum[fra]=sinfo_new_optimal_extraction_from_cube( cube,
00503 cfg->llx,
00504 cfg->lly,
00505 cfg->halfbox_x,
00506 cfg->halfbox_y,
00507 cfg->fwhm_factor,
00508 BKG_VARIANCE,
00509 SKY_FLUX,
00510 cfg->gain,
00511 exptime,
00512 name,
00513 &tbl_spectrum,
00514 qc_info,
00515 &check2))){
00516
00517 irplib_error_recover(clean_state,
00518 "could not do sinfo_optimalExtractionFromCube");
00519 } else {
00520 check_nomsg(cpl_imagelist_set(list_object,
00521 cpl_image_duplicate(spectrum[fra]), fra));
00522
00523 }
00524
00525
00526
00527 ck0_nomsg(sinfo_qclog_add_int(qclog_tbl,"QC CHECK2",
00528 check2,"Check on evaluation box","%d"));
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561 ck0(sinfo_pro_save_tbl(tbl_spectrum,ref_set,sof,
00562 (char*)STDSTAR_OUT_TABLE,
00563 PRO_STD_STAR_SPECTRA,qclog_tbl,
00564 plugin_id,config),
00565 "cannot dump ima %s", "out_std_star_spectrum.fits");
00566
00567
00568 sinfo_free_table(&qclog_tbl);
00569
00570 if (do_compute_eff) {
00571 sinfo_msg("compute efficiency");
00572 frm_sci = cpl_frameset_find(sof,PRO_STD_STAR_SPECTRA);
00573 frm_std_cat = cpl_frameset_find(sof,FLUX_STD_CATALOG);
00574 frm_atmext = cpl_frameset_find(sof,EXTCOEFF_TABLE);
00575
00576
00577
00578 check_nomsg(tot_eff=sinfo_efficiency_compute(frm_sci,frm_std_cat,
00579 frm_atmext));
00580 ck0(sinfo_pro_save_tbl(tot_eff,ref_set,sof,(char*)EFFICIENCY_FILENAME,
00581 PRO_EFFICIENCY,qclog_tbl,plugin_id,config),
00582 "cannot dump ima %s", "out_.fits");
00583 }
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594 if (cfg->convInd == 1) {
00595 sinfo_msg("Determines convertion factor");
00596
00597 convfactor = sinfo_new_determine_conversion_factor( cube,
00598 cfg->mag,
00599 exptime,
00600 cfg->llx,
00601 cfg->lly,
00602 cfg->halfbox_x,
00603 cfg->halfbox_y,
00604 &check3 );
00605
00606
00607 if (convfactor < -100000.) {
00608 sinfo_msg_warning("could not do sinfo_determineConversionFactor!" );
00609
00610 } else {
00611 sinfo_new_array_set_value(factor, convfactor, fra);
00612 }
00613 }
00614 sinfo_free_imagelist(&cube);
00615 }
00616
00617 sinfo_free_table(&tbl_spectrum);
00618 sinfo_free_image_array(&spectrum,cfg->nframes);
00619 if (cfg->convInd == 1) {
00620 sinfo_msg("Determines clean factor");
00621 cleanfactor = sinfo_new_clean_mean(factor,
00622 cfg->nframes,
00623 cfg->lo_reject*100.,
00624 cfg->hi_reject*100.);
00625 }
00626 if (cleanfactor > 100000. || cleanfactor == FLAG) {
00627 sinfo_msg_error("could not do sinfo_clean_mean!" );
00628 goto cleanup;
00629 }
00630
00631
00632
00633 sinfo_msg("Average with rejection");
00634
00635 no=cpl_imagelist_get_size(list_object);
00636 lo_cut=(floor)(cfg->lo_reject*no+0.5);
00637 hi_cut=(floor)(cfg->hi_reject*no+0.5);
00638 if(no > 0) {
00639 cknull(img_spct=cpl_imagelist_collapse_minmax_create(list_object,
00640 lo_cut,hi_cut),
00641 "sinfo_average_with_rejection failed" );
00642 }
00643
00644 sinfo_free_imagelist(&list_object);
00645 if(no > 0) {
00646 check_nomsg(qclog_tbl = sinfo_qclog_init());
00647
00648 ck0_nomsg(sinfo_qclog_add_double(qclog_tbl,"QC CONVFCT",cleanfactor,
00649 "Conversion factor","%g"));
00650
00651 ck0_nomsg(sinfo_qclog_add_int(qclog_tbl,"QC CHECK3",check3,
00652 "Check evaluation box","%d"));
00653
00654
00655 ck0(sinfo_pro_save_ima(img_spct,ref_set,sof,cfg->outName,
00656 PRO_STD_STAR_SPECTRUM,qclog_tbl,
00657 plugin_id,config),
00658 "cannot dump ima %s", cfg->outName);
00659
00660 sinfo_new_set_wcs_spectrum(img_spct,cfg->outName,cenLambda,disp,cenpix);
00661 sinfo_free_table(&qclog_tbl);
00662 }
00663
00664 if(factor != NULL) sinfo_new_destroy_array(&factor);
00665 sinfo_free_image(&img_spct);
00666 sinfo_stdstar_free(&cfg);
00667 sinfo_free_frameset(&raw);
00668
00669 return 0;
00670
00671 cleanup:
00672 sinfo_free_table(&tbl_spectrum);
00673 sinfo_free_table(&qclog_tbl);
00674 sinfo_free_imagelist(&list_object);
00675 if(spectrum != NULL) sinfo_free_image_array(&spectrum,cfg->nframes);
00676 sinfo_free_image(&std_med_ima);
00677 sinfo_free_image(&std_med_dup);
00678 sinfo_free_imagelist(&cube);
00679 sinfo_free_propertylist(&plist) ;
00680 if(factor != NULL) sinfo_new_destroy_array(&factor);
00681 sinfo_free_image(&img_spct);
00682 sinfo_stdstar_free (&cfg);
00683 sinfo_free_frameset(&raw);
00684 return -1;
00685
00686 }
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822