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 <string.h>
00037 #include <math.h>
00038 #include <assert.h>
00039
00040 #include "irplib_framelist.h"
00041
00042 #include "visir_spc_photom.h"
00043
00044 #include "visir_parameter.h"
00045 #include "visir_utils.h"
00046 #include "visir_pfits.h"
00047 #include "visir_spc_distortion.h"
00048
00049
00050
00051
00052
00053 static cpl_bivector * visir_spc_phot_model_from_cat(const char *, double,
00054 double);
00055 static int visir_spc_phot_model_rebin(const cpl_bivector *, cpl_table *);
00056
00057 static cpl_error_code visir_spc_sens_stat(const visir_spc_config *,
00058 const visir_spc_resol,
00059 double *, double *, double *,
00060 const cpl_table *);
00061
00062 static cpl_error_code visir_spc_phot_qc(cpl_propertylist *,
00063 const char *, double, double, double,
00064 double, double);
00065
00066
00070
00071
00072
00073
00074
00075
00076
00077 #ifndef VISIR_WAVELEN_QC_MIN
00078 #define VISIR_WAVELEN_QC_MIN 8e-6
00079 #endif
00080
00081 #ifndef VISIR_WAVELEN_QC_MAX
00082 #define VISIR_WAVELEN_QC_MAX 13e-6
00083 #endif
00084
00085
00086 #ifndef VISIR_WAVELEN_QC_IGNORE
00087 #define VISIR_WAVELEN_QC_IGNORE 3
00088 #endif
00089
00093
00108
00109 cpl_error_code
00110 visir_spc_phot_sensit(const irplib_framelist * rawframes,
00111 const visir_spc_config * pconfig,
00112 const cpl_propertylist * plist,
00113 const char * star_cat,
00114 cpl_image ** pweight2d,
00115 cpl_propertylist * qclist,
00116 cpl_table * spc_table,
00117 const visir_spc_resol resol,
00118 const char * dit_key)
00119
00120 {
00121 cpl_errorstate cleanstate = cpl_errorstate_get();
00122 cpl_bivector * flux_model = NULL;
00123 double * ext_array;
00124 double * spc_array;
00125 double * err_array;
00126 double sens_median = -1.0;
00127 double sens_mean = -1.0;
00128 double sens_stdev = -1.0;
00129 double exptime, factor, exectime = -1.;
00130
00131 const double ra = visir_pfits_get_ra(plist);
00132 const double dec = visir_pfits_get_dec(plist);
00133 const char * star_name;
00134
00135 skip_if (0);
00136
00137
00138 skip_if(irplib_framelist_contains(rawframes, dit_key,
00139 CPL_TYPE_DOUBLE, CPL_FALSE, 0.0));
00140 if(irplib_framelist_contains(rawframes, dit_key,
00141 CPL_TYPE_DOUBLE, CPL_TRUE, 1e-5)) {
00142
00143
00144 visir_error_reset("DIT differs by more than %g", 1e-5);
00145 }
00146
00147
00148 skip_if(irplib_framelist_contains(rawframes, VISIR_PFITS_DOUBLE_RA,
00149 CPL_TYPE_DOUBLE, CPL_FALSE, 0.0));
00150
00151
00152 skip_if(irplib_framelist_contains(rawframes, VISIR_PFITS_DOUBLE_DEC,
00153 CPL_TYPE_DOUBLE, CPL_TRUE, 1.0));
00154
00155 skip_if(irplib_framelist_contains(rawframes, VISIR_PFITS_INT_CHOP_NCYCLES,
00156 CPL_TYPE_INT, CPL_TRUE, 0.0));
00157
00158 skip_if(irplib_framelist_contains(rawframes, VISIR_PFITS_INT_NDIT,
00159 CPL_TYPE_INT, CPL_TRUE, 0.0));
00160
00161 if (irplib_framelist_contains(rawframes, VISIR_PFITS_STRING_STARNAME,
00162 CPL_TYPE_STRING, CPL_TRUE, 0.0)) {
00163 visir_error_reset("Rawframe(s) missing standard star name");
00164 }
00165
00166 if (cpl_propertylist_has(plist, "ESO QC EXPTIME"))
00167 exptime = cpl_propertylist_get_double(plist, "ESO QC EXPTIME");
00168 else {
00169 const int nnod = irplib_framelist_get_size(rawframes);
00170 exptime = visir_utils_get_exptime(nnod, plist);
00171 }
00172 cpl_msg_info(cpl_func, "Exposure time: %.3f", exptime);
00173 if (cpl_propertylist_has(plist, "ESO QC EXECTIME"))
00174 exectime = cpl_propertylist_get_double(plist, "ESO QC EXECTIME");
00175
00176 skip_if (exptime <= 0.0);
00177
00178 factor = sqrt(exptime)/6.0;
00179
00180
00181 star_name = visir_pfits_get_starname(plist);
00182 if (star_name == NULL) visir_error_reset("Could not get standard star name");
00183
00184
00185 if ((flux_model=visir_spc_phot_model_from_cat(star_cat, ra, dec)) == NULL) {
00186 cpl_msg_error(cpl_func, "Cannot retrieve the flux model from the cat.");
00187 skip_if(1);
00188 }
00189
00190
00191 if (visir_spc_phot_model_rebin(flux_model, spc_table) == -1) {
00192 cpl_msg_error(cpl_func, "Cannot rebin the flux model");
00193 skip_if(1);
00194 }
00195 cpl_bivector_delete(flux_model);
00196 flux_model = NULL;
00197
00198
00199
00200
00201 cpl_table_duplicate_column(spc_table, "SENSITIVITY", spc_table,
00202 "STD_STAR_MODEL");
00203 cpl_table_set_column_unit(spc_table, "SENSITIVITY", "mJy");
00204
00205 ext_array = cpl_table_get_data_double(spc_table, "SENSITIVITY");
00206 spc_array = cpl_table_get_data_double(spc_table, "SPC_EXTRACTED");
00207 err_array = cpl_table_get_data_double(spc_table, "SPC_ERROR");
00208
00209 for (cpl_size i = 0; i < cpl_table_get_nrow(spc_table); i++) {
00210 ext_array[i] *= factor * err_array[i];
00211 if (ext_array[i] < 0 || spc_array[i] <= 0) {
00212 cpl_msg_warning(cpl_func, "Setting non-physical sensitivity in row %d "
00213 "to 0: %g/%g", (int)i+1, ext_array[i], spc_array[i]);
00214 ext_array[i] = 0;
00215 } else {
00216 ext_array[i] /= spc_array[i];
00217 }
00218 }
00219
00220 skip_if(visir_spc_sens_stat(pconfig, resol, &sens_median, &sens_mean,
00221 &sens_stdev, spc_table));
00222
00223
00224 skip_if (cpl_table_erase_column(spc_table, "SPC_EMISSIVITY"));
00225
00226 skip_if (visir_spc_phot_qc(qclist, star_name, exptime, exectime,
00227 sens_median, sens_mean, sens_stdev));
00228
00229
00230 if (pconfig->plot) {
00231 visir_table_plot("", "t 'Extracted spectrum' w lines", "", spc_table,
00232 "WLEN", "SPC_EXTRACTED");
00233 visir_table_plot("", "t 'Extracted spectrum error' w lines", "",
00234 spc_table, "WLEN", "SPC_ERROR");
00235 visir_table_plot("", "t 'Standard star model' w lines", "", spc_table,
00236 "WLEN", "STD_STAR_MODEL");
00237 visir_table_plot("set grid;", "t 'Sensitivity (mJy)' w lines", "",
00238 spc_table, "WLEN", "SENSITIVITY");
00239 visir_image_plot("", "t 'The weight map'", "", *pweight2d);
00240 }
00241
00242 end_skip;
00243 cpl_bivector_delete(flux_model);
00244
00245 return cpl_error_get_code();
00246 }
00247
00248
00269
00270 cpl_table *
00271 visir_spc_phot_sensit_from_image(cpl_image ** combined,
00272 const irplib_framelist * rawframes,
00273 const visir_spc_config * pconfig,
00274 const char * star_cat,
00275 const char * spc_cal_lines,
00276 const char * spc_cal_qeff,
00277 cpl_image ** pweight2d,
00278 cpl_propertylist * qclist,
00279 cpl_boolean do_ech,
00280 double wlen,
00281 double slitw,
00282 double temp,
00283 double fwhm,
00284 const visir_spc_resol resol,
00285 const char * dit_key)
00286 {
00287 const cpl_propertylist * plist;
00288 const cpl_frame * frm = NULL;
00289 cpl_imagelist * hcycle = NULL;
00290 cpl_image * imhcycle = NULL;
00291 cpl_image * flipped = NULL;
00292 cpl_image * comorder = NULL;
00293 cpl_image * order = NULL;
00294 cpl_table * spc_table = NULL;
00295 visir_data_type dtype;
00296
00297 *pweight2d = NULL;
00298
00299 skip_if (rawframes == NULL);
00300
00301
00302 plist = irplib_framelist_get_propertylist_const(rawframes, 0);
00303 frm = irplib_framelist_get_const(rawframes, 0);
00304
00305 skip_if (visir_get_data_type(frm, plist, &dtype, NULL));
00306
00307
00308 hcycle = visir_load_imagelist(rawframes, 0, CPL_FALSE);
00309 skip_if (0);
00310
00311 skip_if (pconfig->do_fixcombi &&
00312 visir_spc_det_fix(combined, 1, CPL_TRUE,
00313 wlen, resol,
00314 pconfig->phi,
00315 pconfig->ksi,
00316 pconfig->eps,
00317 pconfig->delta,
00318 pconfig->plot));
00319
00320
00321 imhcycle = cpl_imagelist_unset(hcycle, 0);
00322 skip_if (0);
00323
00324 skip_if (visir_spc_det_fix(&imhcycle, 1, CPL_FALSE,
00325 wlen, resol,
00326 pconfig->phi,
00327 pconfig->ksi,
00328 pconfig->eps,
00329 pconfig->delta,
00330 pconfig->plot));
00331
00332
00333 flipped = visir_spc_flip(*combined, wlen, resol, dtype);
00334 skip_if (0);
00335 cpl_image_delete(*combined);
00336 *combined = flipped;
00337 flipped = NULL;
00338
00339
00340 flipped = visir_spc_flip(imhcycle, wlen, resol, dtype);
00341 skip_if (0);
00342 cpl_image_delete(imhcycle);
00343 imhcycle = flipped;
00344 flipped = NULL;
00345
00346 skip_if(visir_spc_extract_order(&order, &comorder,
00347 *combined, imhcycle,
00348 wlen, pconfig, do_ech,
00349 visir_data_is_aqu(dtype)));
00350
00351 if (do_ech) {
00352 int icol1, icol2;
00353 skip_if (visir_spc_echelle_limit(&icol1, &icol2, wlen,
00354 pconfig->orderoffset,
00355 1, cpl_image_get_size_y(*combined),
00356 visir_data_is_aqu(dtype)));
00357 skip_if(visir_qc_append_background(qclist, rawframes, icol1, icol2));
00358 }
00359 else
00360 skip_if(visir_qc_append_background(qclist, rawframes, 0, 0));
00361
00362
00363 skip_if (visir_spc_extract_wcal(comorder,
00364 order, wlen, slitw, temp, fwhm,
00365 resol, pconfig->orderoffset,
00366 spc_cal_lines, spc_cal_qeff,
00367 &spc_table, pweight2d,
00368 qclist,
00369 pconfig->plot, CPL_FALSE,
00370 visir_data_is_aqu(dtype)));
00371
00372 visir_spc_phot_sensit(rawframes, pconfig, plist, star_cat, pweight2d,
00373 qclist, spc_table, resol, dit_key);
00374
00375 cpl_imagelist_delete(hcycle);
00376 hcycle = NULL;
00377
00378
00379 end_skip;
00380
00381 cpl_imagelist_delete(hcycle);
00382
00383 cpl_image_delete(flipped);
00384 cpl_image_delete(imhcycle);
00385 cpl_image_delete(order);
00386 cpl_image_delete(comorder);
00387
00388 if (cpl_error_get_code()) {
00389 cpl_table_delete(spc_table);
00390 spc_table = NULL;
00391 cpl_image_delete(*pweight2d);
00392 *pweight2d = NULL;
00393 }
00394
00395 return spc_table;
00396 }
00397
00400
00412
00413 static cpl_bivector * visir_spc_phot_model_from_cat(const char * star_cat,
00414 double ra,
00415 double dec)
00416 {
00417 const double max_radius = VISIR_STAR_MAX_RADIUS;
00418 const cpl_table * catalog = NULL;
00419 int nb_stars;
00420 const double * dd;
00421 const cpl_array * da;
00422 cpl_vector * v_ra = NULL;
00423 cpl_vector * v_dec = NULL;
00424 int min_dist_ind;
00425 cpl_bivector * model = NULL;
00426 cpl_vector * model_x = NULL;
00427 cpl_vector * model_y = NULL;
00428 const double conv_mJy = 3.33E8;
00429 double star_dist;
00430 int nb_vals;
00431
00432
00433 bug_if (0);
00434
00435
00436 catalog = cpl_table_load(star_cat, 1, 0);
00437 if (catalog == NULL) {
00438 cpl_msg_error(cpl_func, "Could not open the star catalog: %s",
00439 star_cat ? star_cat : "<NULL>");
00440 skip_if(1);
00441 }
00442
00443 nb_stars = cpl_table_get_nrow(catalog);
00444
00445 skip_if(nb_stars < 1);
00446
00447
00448 dd = cpl_table_get_data_double_const(catalog, "RA");
00449 skip_if (dd == NULL);
00450 IRPLIB_DIAG_PRAGMA_PUSH_IGN(-Wcast-qual);
00451 v_ra = cpl_vector_wrap(nb_stars, (double*)dd);
00452 IRPLIB_DIAG_PRAGMA_POP;
00453 bug_if( v_ra == NULL);
00454
00455 dd = cpl_table_get_data_double_const(catalog, "DEC");
00456 skip_if (dd == NULL);
00457 IRPLIB_DIAG_PRAGMA_PUSH_IGN(-Wcast-qual);
00458 v_dec = cpl_vector_wrap(nb_stars, (double*)dd);
00459 IRPLIB_DIAG_PRAGMA_POP;
00460 bug_if( v_dec == NULL);
00461
00462
00463 min_dist_ind = visir_star_find(v_ra, v_dec, ra, dec, max_radius, &star_dist);
00464
00465 skip_if (min_dist_ind < 0);
00466
00467 cpl_msg_info(cpl_func, "The standard star closest to (RA,DEC)=(%g,%g) is "
00468 "no. %d, '%s' at (RA,DEC)=(%g,%g) with the distance [degree]: "
00469 "%g", ra, dec, 1+min_dist_ind,
00470 cpl_table_get_string(catalog, "STARS", min_dist_ind),
00471 cpl_table_get_double(catalog, "RA", min_dist_ind, NULL),
00472 cpl_table_get_double(catalog, "DEC", min_dist_ind, NULL),
00473 star_dist);
00474
00475
00476 da = cpl_table_get_array(catalog, "WAVELENGTHS", min_dist_ind);
00477 skip_if (da == NULL);
00478 dd = cpl_array_get_data_double_const(da);
00479 skip_if (dd == NULL);
00480
00481 nb_vals = cpl_array_get_size(da);
00482
00483 model_x = cpl_vector_new(nb_vals);
00484 memcpy(cpl_vector_get_data(model_x), dd, nb_vals * sizeof(double));
00485
00486
00487 da = cpl_table_get_array(catalog, "MODEL_FLUX", min_dist_ind);
00488 skip_if (da == NULL);
00489 dd = cpl_array_get_data_double_const(da);
00490 skip_if (dd == NULL);
00491
00492 skip_if (nb_vals != cpl_array_get_size(da));
00493
00494 model_y = cpl_vector_new(nb_vals);
00495 memcpy(cpl_vector_get_data(model_y), dd, nb_vals * sizeof(double));
00496
00497
00498 bug_if (cpl_vector_multiply_scalar(model_y, conv_mJy));
00499 bug_if (cpl_vector_multiply(model_y, model_x));
00500 bug_if (cpl_vector_multiply(model_y, model_x));
00501
00502
00503 bug_if (cpl_vector_multiply_scalar(model_x, 1e-6));
00504
00505 model = cpl_bivector_wrap_vectors(model_x, model_y);
00506
00507 bug_if (model == NULL);
00508
00509 end_skip;
00510
00511 (void)cpl_vector_unwrap(v_ra);
00512 (void)cpl_vector_unwrap(v_dec);
00513 IRPLIB_DIAG_PRAGMA_PUSH_IGN(-Wcast-qual);
00514 cpl_table_delete((cpl_table*)catalog);
00515 IRPLIB_DIAG_PRAGMA_POP;
00516
00517 if (cpl_error_get_code()) {
00518
00519 cpl_vector_delete(model_x);
00520 cpl_vector_delete(model_y);
00521 }
00522
00523 return model;
00524 }
00525
00526
00532
00533 static int visir_spc_phot_model_rebin(
00534 const cpl_bivector * model,
00535 cpl_table * spec_tab)
00536 {
00537 cpl_vector * bounds = NULL;
00538 cpl_vector * spec = NULL;
00539 double bin_pos;
00540 const int nrow = cpl_table_get_nrow(spec_tab);
00541 int i;
00542
00543
00544 skip_if (0);
00545
00546
00547 bounds = cpl_vector_new(nrow + 1);
00548 for (i=1 ; i<cpl_vector_get_size(bounds) - 1 ; i++) {
00549 bin_pos = (cpl_table_get(spec_tab, "WLEN", i-1, NULL) +
00550 cpl_table_get(spec_tab, "WLEN", i, NULL)) / 2.0;
00551 cpl_vector_set(bounds, i, bin_pos);
00552 }
00553 bin_pos = cpl_table_get(spec_tab, "WLEN", 0, NULL) -
00554 ((cpl_table_get(spec_tab, "WLEN", 1, NULL) -
00555 cpl_table_get(spec_tab, "WLEN", 0, NULL)) / 2.0);
00556 cpl_vector_set(bounds, 0, bin_pos);
00557 bin_pos =
00558 cpl_table_get(spec_tab, "WLEN", nrow-1, NULL) +
00559 ((cpl_table_get(spec_tab,"WLEN", 1, NULL) -
00560 cpl_table_get(spec_tab, "WLEN", 0, NULL)) / 2.0);
00561 cpl_vector_set(bounds, cpl_vector_get_size(bounds)-1, bin_pos);
00562
00563
00564 spec = cpl_vector_new(nrow);
00565
00566
00567 if (visir_vector_resample(spec, bounds, model)) {
00568 cpl_msg_error(cpl_func, "Cannot rebin the spectrum");
00569 skip_if(1);
00570 }
00571
00572
00573 cpl_table_new_column(spec_tab, "STD_STAR_MODEL", CPL_TYPE_DOUBLE);
00574 cpl_table_set_column_unit(spec_tab, "STD_STAR_MODEL", "mJy");
00575 for (i=0 ; i<nrow ; i++) {
00576 cpl_table_set_double(spec_tab, "STD_STAR_MODEL", i,
00577 cpl_vector_get(spec, i));
00578 }
00579
00580 end_skip;
00581
00582 cpl_vector_delete(spec);
00583 cpl_vector_delete(bounds);
00584
00585 return cpl_error_get_code();
00586 }
00587
00588
00598
00599 static cpl_error_code visir_spc_wl_start_end(const cpl_table * self,
00600 cpl_size * pstart, cpl_size * pend)
00601 {
00602 const cpl_size npix = cpl_table_get_nrow(self);
00603 cpl_vector * vwave = NULL;
00604
00605
00606
00607 IRPLIB_DIAG_PRAGMA_PUSH_IGN(-Wcast-qual);
00608 vwave = cpl_vector_wrap(npix, (double*)
00609 cpl_table_get_data_double_const(self, "WLEN"));
00610 IRPLIB_DIAG_PRAGMA_POP;
00611
00612 assert(VISIR_WAVELEN_QC_MIN < VISIR_WAVELEN_QC_MAX);
00613
00614 cpl_size l = visir_lower_bound(vwave, VISIR_WAVELEN_QC_MIN);
00615 cpl_size u = visir_upper_bound(vwave, VISIR_WAVELEN_QC_MAX);
00616
00617 l = CPL_MAX(l, VISIR_WAVELEN_QC_IGNORE);
00618 u = CPL_MIN(u, npix - VISIR_WAVELEN_QC_IGNORE);
00619
00620 if (u - l <= 0) {
00621 (void)cpl_error_set_message(cpl_func, CPL_ERROR_DATA_NOT_FOUND,
00622 "For QC the calibrated wavelength range "
00623 "(%g, %g) does not intersect with the "
00624 "required (%g, %g) [m]",
00625 cpl_vector_get(vwave, l),
00626 cpl_vector_get(vwave, u),
00627 VISIR_WAVELEN_QC_MIN, VISIR_WAVELEN_QC_MAX);
00628 } else {
00629 *pstart = l;
00630 *pend = u;
00631 }
00632
00633 cpl_vector_unwrap(vwave);
00634
00635 return cpl_error_get_code();
00636 }
00637
00638
00639
00650
00651 static cpl_error_code visir_spc_sens_stat(const visir_spc_config * pconfig,
00652 const visir_spc_resol resol,
00653 double * psens_median,
00654 double * psens_mean,
00655 double * psens_stdev,
00656 const cpl_table * spc_table)
00657 {
00658
00659 cpl_vector * sens_ignore = NULL;
00660 cpl_vector * sens_mini = NULL;
00661 double emis_min, emis_max;
00662 cpl_size npix_start = 0;
00663 cpl_size npix_end = 0;
00664 cpl_size nuse;
00665 int iok;
00666
00667 skip_if(0);
00668
00669 skip_if(pconfig == NULL);
00670
00671 if (resol == VISIR_SPC_R_LRP || resol == VISIR_SPC_R_LR) {
00672 skip_if(visir_spc_wl_start_end(spc_table, &npix_start, &npix_end));
00673 } else {
00674 npix_start = VISIR_WAVELEN_QC_IGNORE;
00675 npix_end = cpl_table_get_nrow(spc_table) - VISIR_WAVELEN_QC_IGNORE;
00676 }
00677
00678 nuse = npix_end - npix_start;
00679
00680 cpl_msg_info(cpl_func, "QC computed from %lld spectral values in the range "
00681 "(%g, %g) [m]", (long long)nuse, VISIR_WAVELEN_QC_MIN,
00682 VISIR_WAVELEN_QC_MAX);
00683
00684
00685
00686
00687
00688 IRPLIB_DIAG_PRAGMA_PUSH_IGN(-Wcast-qual);
00689 sens_ignore = cpl_vector_wrap( nuse, (double*)
00690 cpl_table_get_data_double_const(spc_table,
00691 "SENSITIVITY") + npix_start);
00692 IRPLIB_DIAG_PRAGMA_POP;
00693 skip_if(0);
00694
00695 if (pconfig->plot)
00696 visir_vector_plot("set grid;","t 'Truncated Sensitivity (mJy)' w lines",
00697 "", sens_ignore);
00698
00699 sens_mini = cpl_vector_duplicate(sens_ignore);
00700 skip_if(0);
00701
00702 emis_min = cpl_table_get_column_min(spc_table, "SPC_EMISSIVITY");
00703 emis_max = cpl_table_get_column_max(spc_table, "SPC_EMISSIVITY");
00704 skip_if(0);
00705
00706 emis_max = emis_min + pconfig->phot_emis_tol * (emis_max - emis_min);
00707
00708 iok = 0;
00709 for (cpl_size i=0; i < nuse; i++) {
00710 const double emis = cpl_table_get(spc_table, "SPC_EMISSIVITY",
00711 i + npix_start, NULL);
00712
00713 skip_if(0);
00714
00715 if (emis > emis_max) continue;
00716
00717 if (i > iok)
00718 skip_if(cpl_vector_set(sens_mini, iok, cpl_vector_get(sens_mini, i)));
00719
00720 iok++;
00721
00722 }
00723
00724 assert( iok > 0);
00725
00726 skip_if(cpl_vector_set_size(sens_mini, iok));
00727
00728 *psens_mean = cpl_vector_get_mean(sens_mini);
00729
00730 if (iok == 1) {
00731 cpl_msg_warning(cpl_func, "Sensitivity computed on only 1 wavelength "
00732 "with emissivity %f", emis_max);
00733 *psens_stdev = 0;
00734 } else {
00735 cpl_msg_info(cpl_func, "Sensitivity computed on %d wavelengths with "
00736 "emissivity at most %f", iok, emis_max);
00737
00738 *psens_stdev = cpl_vector_get_stdev(sens_mini);
00739
00740 }
00741
00742 *psens_median = cpl_vector_get_median(sens_mini);
00743
00744 end_skip;
00745
00746 cpl_vector_unwrap(sens_ignore);
00747 cpl_vector_delete(sens_mini);
00748
00749 return cpl_error_get_code();
00750
00751 }
00752
00753
00754
00767
00768 static cpl_error_code visir_spc_phot_qc(cpl_propertylist * self,
00769 const char * star_name,
00770 double exptime,
00771 double exectime,
00772 double sens_median,
00773 double sens_mean,
00774 double sens_stdev)
00775 {
00776
00777 bug_if (cpl_propertylist_append_double(self, "ESO QC EXPTIME", exptime));
00778 if (exectime > 0) {
00779 bug_if (cpl_propertylist_append_double(self, "ESO QC EXECTIME",
00780 exectime));
00781 }
00782 bug_if (cpl_propertylist_append_double(self, "ESO QC SENS MEDIAN",
00783 sens_median));
00784 bug_if (cpl_propertylist_append_double(self, "ESO QC SENS MEAN", sens_mean));
00785 bug_if (cpl_propertylist_append_double(self, "ESO QC SENS STDEV",
00786 sens_stdev));
00787
00788 bug_if (cpl_propertylist_append_string(self, "ESO QC STARNAME",
00789 star_name ? star_name : ""));
00790
00791 end_skip;
00792
00793 return cpl_error_get_code();
00794
00795 }