MOONS Pipeline Reference Manual 0.13.2
moo_ext_single.c
1/*
2 * This file is part of the MOONS Pipeline
3 * Copyright (C) 2002-2016 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24/*-----------------------------------------------------------------------------
25 Includes
26 -----------------------------------------------------------------------------*/
27#include <math.h>
28#include <cpl.h>
29#include "moo_pfits.h"
30#include "moo_ext_single.h"
31#include "moo_fits.h"
32#include "moo_qc.h"
33#include "moo_badpix.h"
34#include "moo_spectral_format.h"
35#include "moo_fibres_table.h"
36#include "moo_utils.h"
37/*----------------------------------------------------------------------------*/
53/*----------------------------------------------------------------------------*/
54
57/*-----------------------------------------------------------------------------
58 Function codes
59 -----------------------------------------------------------------------------*/
60
61/*----------------------------------------------------------------------------*/
69/*----------------------------------------------------------------------------*/
70moo_ext_single *
72{
73 moo_ext_single *res = cpl_calloc(1, sizeof(moo_ext_single));
74 res->badpix_mask = MOO_BADPIX_GOOD;
75 res->type = type;
76 res->ntas = ntas;
77 const char *extname = moo_detector_get_extname(type, ntas);
78 res->extname = extname;
79 res->header = cpl_propertylist_new();
80 return res;
81}
82
83/*----------------------------------------------------------------------------*/
95/*----------------------------------------------------------------------------*/
96moo_ext_single *
97moo_ext_single_create(const char *filename, moo_detector_type type, int ntas)
98{
99 cpl_ensure(filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
100
101 moo_ext_single *single = NULL;
102 cpl_propertylist *header = NULL;
103
104 const char *extname = moo_detector_get_extname(type, ntas);
105
106 header = moo_fits_load_extension_header(filename, NULL, extname);
107 if (header != NULL) {
108 int naxis = moo_pfits_get_naxis(header);
109 if (naxis > 0) {
110 single = moo_ext_single_new(type, ntas);
111 single->filename = filename;
112 cpl_propertylist_append(single->header, header);
113 }
114 cpl_propertylist_delete(header);
115 }
116 return single;
117}
118
119/*----------------------------------------------------------------------------*/
130/*----------------------------------------------------------------------------*/
131cpl_error_code
132moo_ext_single_load(moo_ext_single *self, unsigned int level)
133{
134 if (self != NULL) {
135 if ((self->filename != NULL) && (self->extname != NULL)) {
136 if (self->header == NULL) {
137 cpl_size extnum =
138 cpl_fits_find_extension(self->filename, self->extname);
139 if (extnum > 0) {
140 self->header =
141 cpl_propertylist_load(self->filename, extnum);
142 }
143 }
144 if (self->qual == NULL) {
145 self->qual =
146 moo_fits_load_extension_image(self->filename,
147 MOO_EXT_SINGLE_QUAL,
148 self->extname, CPL_TYPE_INT);
149 }
150 if (self->image == NULL) {
151 cpl_image *data = NULL;
152 cpl_image *err = NULL;
153
154 data = moo_fits_load_extension_image(self->filename, NULL,
155 self->extname,
156 CPL_TYPE_DOUBLE);
157 err = moo_fits_load_extension_image(self->filename,
158 MOO_EXT_SINGLE_ERR,
159 self->extname,
160 CPL_TYPE_DOUBLE);
161
162 if (data != NULL && err != NULL) {
163 self->image = hdrl_image_create(data, err);
164 cpl_image_delete(data);
165 cpl_image_delete(err);
166 }
167 }
168 }
169
170 cpl_mask *mask = hdrl_image_get_mask(self->image);
171 moo_badpix_to_mask(self->qual, mask, level);
172 }
173 return CPL_ERROR_NONE;
174}
175
176
177/*----------------------------------------------------------------------------*/
186/*----------------------------------------------------------------------------*/
187
188void
189moo_ext_single_delete(moo_ext_single *self)
190{
191 if (self != NULL) {
192 if (self->header != NULL) {
193 cpl_propertylist_delete(self->header);
194 }
195 if (self->image != NULL) {
196 hdrl_image_delete(self->image);
197 }
198 if (self->qual != NULL) {
199 cpl_image_delete(self->qual);
200 }
201 cpl_free(self);
202 }
203}
204/*----------------------------------------------------------------------------*/
217/*----------------------------------------------------------------------------*/
218void
219moo_ext_single_save(const moo_ext_single *self,
220 const char *filename,
222 int ntas)
223{
224 const char *extname = moo_detector_get_extname(type, ntas);
225 if (self != NULL) {
226 if (self->image != NULL) {
227 moo_fits_write_extension_image(hdrl_image_get_image(self->image),
228 filename, NULL, extname,
229 CPL_TYPE_FLOAT, self->header);
230
231 cpl_propertylist *err_header = cpl_propertylist_new();
232 moo_pfits_append_hduclass_error(err_header, type, ntas,
233 self->header);
234
235 moo_fits_write_extension_image(hdrl_image_get_error(self->image),
236 filename, MOO_EXT_SINGLE_ERR,
237 extname, MOO_EXT_SINGLE_ERR_TYPE,
238 err_header);
239
240 cpl_propertylist_delete(err_header);
241 cpl_propertylist *qual_header = cpl_propertylist_new();
242 moo_pfits_append_hduclass_quality(qual_header, type, ntas,
243 self->header, self->badpix_mask);
244 moo_fits_write_extension_image(self->qual, filename,
245 MOO_EXT_SINGLE_QUAL, extname,
246 MOO_EXT_SINGLE_QUAL_TYPE,
247 qual_header);
248 cpl_propertylist_delete(qual_header);
249 }
250 }
251 else {
252 cpl_propertylist *h = cpl_propertylist_new();
253 cpl_propertylist_append_string(h, MOO_PFITS_EXTNAME, extname);
254 cpl_propertylist_save(h, filename, CPL_IO_EXTEND);
255 cpl_propertylist_delete(h);
256
257 moo_fits_write_extension_image(NULL, filename, MOO_EXT_SINGLE_ERR,
258 extname, MOO_EXT_SINGLE_ERR_TYPE, NULL);
259 moo_fits_write_extension_image(NULL, filename, MOO_EXT_SINGLE_QUAL,
260 extname, MOO_EXT_SINGLE_QUAL_TYPE, NULL);
261 }
262}
263
264/*----------------------------------------------------------------------------*/
276/*----------------------------------------------------------------------------*/
277cpl_error_code
278moo_ext_single_dump(const moo_ext_single *self, FILE *stream)
279{
280 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
281 cpl_ensure_code(stream != NULL, CPL_ERROR_NULL_INPUT);
282
283 fprintf(stream, "---MOO_EXT_SINGLE\n");
284 fprintf(stream, "filename %s extname %s\n", self->filename, self->extname);
285
286 return CPL_ERROR_NONE;
287}
288
289/*----------------------------------------------------------------------------*/
299/*----------------------------------------------------------------------------*/
300hdrl_image *
301moo_ext_single_get_image(moo_ext_single *self)
302{
303 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
304
305 return self->image;
306}
307/*----------------------------------------------------------------------------*/
317/*----------------------------------------------------------------------------*/
318cpl_image *
319moo_ext_single_get_data(moo_ext_single *self)
320{
321 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
322
323 cpl_image *res = NULL;
324
325 if (self->image != NULL) {
326 res = hdrl_image_get_image(self->image);
327 }
328 return res;
329}
330
331/*----------------------------------------------------------------------------*/
342/*----------------------------------------------------------------------------*/
343cpl_image *
344moo_ext_single_get_errs(moo_ext_single *self)
345{
346 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
347
348 cpl_image *res = NULL;
349
350 if (self->image != NULL) {
351 res = hdrl_image_get_error(self->image);
352 }
353 return res;
354}
355
356/*----------------------------------------------------------------------------*/
366/*----------------------------------------------------------------------------*/
367cpl_image *
368moo_ext_single_get_qual(moo_ext_single *self)
369{
370 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
371 cpl_ensure(self->filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
372 cpl_ensure(self->extname != NULL, CPL_ERROR_NULL_INPUT, NULL);
373
374 if (self->qual == NULL) {
375 self->qual =
376 moo_fits_load_extension_image(self->filename, MOO_EXT_SINGLE_QUAL,
377 self->extname,
378 MOO_EXT_SINGLE_QUAL_TYPE);
379 }
380 return self->qual;
381}
382
383/*----------------------------------------------------------------------------*/
394/*----------------------------------------------------------------------------*/
395cpl_propertylist *
396moo_ext_single_get_header(moo_ext_single *self)
397{
398 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
399 cpl_ensure(self->filename != NULL, CPL_ERROR_NULL_INPUT, NULL);
400 cpl_ensure(self->extname != NULL, CPL_ERROR_NULL_INPUT, NULL);
401
402 if (self->header == NULL) {
403 self->header =
404 moo_fits_load_extension_header(self->filename, NULL, self->extname);
405 if (self->header == NULL) {
406 self->header = cpl_propertylist_new();
407 }
408 }
409 return self->header;
410}
411
412cpl_error_code
413moo_ext_single_compute_qc(moo_ext_single *self,
414 const char *colname,
415 const char *dersnr_colname,
416 cpl_table *fibres_table)
417{
418 cpl_array *index = NULL;
419 cpl_image *snr = NULL;
420 cpl_error_code status = CPL_ERROR_NONE;
421
422 cpl_errorstate prestate = cpl_errorstate_get();
423
424 if (self != NULL) {
425 hdrl_image *image = moo_ext_single_get_image(self);
426 cpl_mask *mask = hdrl_image_get_mask(image);
427
428 cpl_ensure_code(image != NULL, CPL_ERROR_NULL_INPUT);
429
430 unsigned int badpix_level = MOO_BADPIX_COSMETIC |
433 moo_try_check(moo_badpix_to_mask(self->qual, mask, badpix_level), " ");
434 cpl_image *data = hdrl_image_get_image(image);
435 cpl_image *err = hdrl_image_get_error(image);
436
437 int nx = cpl_image_get_size_x(data);
438 double min = cpl_image_get_min(data);
439 double max = cpl_image_get_max(data);
440 double rms = cpl_image_get_stdev(data);
441 double median = cpl_image_get_median(data);
442 double mean = cpl_image_get_mean(data);
443 cpl_propertylist *header = moo_ext_single_get_header(self);
444
445 moo_qc_set_mflat_min(header, min);
446 moo_qc_set_mflat_max(header, max);
447
448 moo_qc_set_mflat_avg(header, mean);
449 moo_qc_set_mflat_med(header, median);
450 moo_qc_set_mflat_rms(header, rms);
451 cpl_image_reject_value(err, CPL_VALUE_ZERO);
452 int nbrej = cpl_image_count_rejected(err);
453 int allpix = cpl_image_get_size_x(err) * cpl_image_get_size_y(err);
454 if (nbrej < allpix) {
455 moo_try_check(snr = cpl_image_divide_create(data, err), " ");
456 double max_snr = cpl_image_get_max(snr);
457 double min_snr = cpl_image_get_min(snr);
458 double median_snr = cpl_image_get_median(snr);
459
460 moo_qc_set_mflat_sn_min(header, min_snr);
461 moo_qc_set_mflat_sn_max(header, max_snr);
462 moo_qc_set_mflat_sn_med(header, median_snr);
463
464 moo_try_check(index = cpl_table_where_selected(fibres_table), " ");
465 int size = cpl_array_get_size(index);
466
467 for (int i = 0; i < size; i++) {
468 int idx = cpl_array_get_cplsize(index, i, NULL);
469 int h = cpl_table_get(fibres_table, MOO_FIBRES_TABLE_HEALTH,
470 idx, NULL);
471 if (h == 1) {
472 double val = NAN;
473 double dersnr = NAN;
474 cpl_errorstate fstate = cpl_errorstate_get();
475 val = cpl_image_get_median_window(snr, 1, i + 1, nx, i + 1);
476 if (cpl_errorstate_is_equal(fstate)) {
477 cpl_table_set(fibres_table, colname, idx, val);
478 }
479 else {
480 cpl_table_set(fibres_table, colname, idx, NAN);
481 cpl_errorstate_set(fstate);
482 }
483 cpl_vector *row =
484 cpl_vector_new_from_image_row(data, i + 1);
485 cpl_vector *row_filter = moo_vector_filter_nan(row);
486 dersnr = moo_vector_get_dersnr(row_filter);
487 cpl_table_set(fibres_table, dersnr_colname, idx, dersnr);
488 cpl_vector_delete(row_filter);
489 cpl_vector_delete(row);
490 }
491 }
492 }
493 }
494
495moo_try_cleanup:
496 cpl_array_delete(index);
497 cpl_image_delete(snr);
498
499 if (!cpl_errorstate_is_equal(prestate)) {
500 status = cpl_error_get_code();
501 cpl_msg_error("moo_ext_single", "Can't compute QC for file %s",
502 self->filename);
503 }
504 return status;
505}
506/*----------------------------------------------------------------------------*/
522/*----------------------------------------------------------------------------*/
523cpl_error_code
524moo_ext_single_set_wcs1(moo_ext_single *self,
525 double crpix1,
526 double crval1,
527 double cd1_1,
528 const char *ctype1,
529 const char *cunit1)
530{
531 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
532 cpl_ensure_code(self->header != NULL, CPL_ERROR_ILLEGAL_INPUT);
533
534 cpl_error_code code = CPL_ERROR_NONE;
535 code =
536 cpl_propertylist_append_double(self->header, MOO_PFITS_CRPIX1, crpix1);
537 cpl_ensure_code(code == CPL_ERROR_NONE, code);
538 code =
539 cpl_propertylist_append_double(self->header, MOO_PFITS_CRVAL1, crval1);
540 cpl_ensure_code(code == CPL_ERROR_NONE, code);
541 code = cpl_propertylist_append_double(self->header, MOO_PFITS_CD1_1, cd1_1);
542 cpl_ensure_code(code == CPL_ERROR_NONE, code);
543 code =
544 cpl_propertylist_append_string(self->header, MOO_PFITS_CTYPE1, ctype1);
545 cpl_ensure_code(code == CPL_ERROR_NONE, code);
546 code =
547 cpl_propertylist_append_string(self->header, MOO_PFITS_CUNIT1, cunit1);
548 cpl_ensure_code(code == CPL_ERROR_NONE, code);
549 return code;
550}
551
552/*----------------------------------------------------------------------------*/
562/*----------------------------------------------------------------------------*/
563cpl_error_code
564moo_ext_single_free(moo_ext_single *self)
565{
566 cpl_ensure_code(self != NULL, CPL_ERROR_NULL_INPUT);
567
568 if (self->filename != NULL && self->extname != NULL) {
569 if (self->header != NULL) {
570 cpl_propertylist_delete(self->header);
571 self->header = NULL;
572 }
573 if (self->image != NULL) {
574 hdrl_image_delete(self->image);
575 self->image = NULL;
576 }
577 if (self->qual != NULL) {
578 cpl_image_delete(self->qual);
579 self->qual = NULL;
580 }
581 }
582 return CPL_ERROR_NONE;
583}
584/*----------------------------------------------------------------------------*/
595/*----------------------------------------------------------------------------*/
596cpl_error_code
597moo_ext_single_sum(moo_ext_single *a, moo_ext_single *b)
598{
599 cpl_ensure_code(a != NULL, CPL_ERROR_NULL_INPUT);
600 cpl_ensure_code(b != NULL, CPL_ERROR_NULL_INPUT);
601
602 hdrl_image *a_img = moo_ext_single_get_image(a);
603 hdrl_image *b_img = moo_ext_single_get_image(b);
604
605 hdrl_image_add_image(a_img, b_img);
606
607 cpl_image *qual1 = moo_ext_single_get_qual(a);
608 cpl_image *qual2 = moo_ext_single_get_qual(b);
609
610 cpl_image_or(a->qual, qual1, qual2);
611
612 return CPL_ERROR_NONE;
613}
614
615/*----------------------------------------------------------------------------*/
627/*----------------------------------------------------------------------------*/
628double
629moo_ext_single_compute_snr(moo_ext_single *self,
630 int ext_idx,
631 cpl_image *wmap,
632 moo_spectral_format_info *sinfo,
633 moo_sky_lines_list *skylines,
634 double *dersnr)
635{
636 double snr = 0.0;
637 cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, 0.0);
638 cpl_ensure(wmap != NULL, CPL_ERROR_NULL_INPUT, 0.0);
639 cpl_ensure(sinfo != NULL, CPL_ERROR_NULL_INPUT, 0.0);
640
641 hdrl_image *himg = moo_ext_single_get_image(self);
642 int nx = cpl_image_get_size_x(wmap);
643 int rej;
644 int start = 1;
645 int direction = sinfo->direction;
646
647 double wmin = cpl_image_get(wmap, start, ext_idx, &rej);
648
649 while (isnan(wmin)) {
650 start++;
651 wmin = cpl_image_get(wmap, start, ext_idx, &rej);
652 }
653
654 int stop = nx;
655
656 double wmax = cpl_image_get(wmap, stop, ext_idx, &rej);
657 while (isnan(wmax)) {
658 stop--;
659 wmax = cpl_image_get(wmap, stop, ext_idx, &rej);
660 }
661
662 if (direction < 0) {
663 double temp = wmin;
664 int itemp = start;
665 wmin = wmax;
666 start = stop;
667 wmax = temp;
668 stop = itemp;
669 }
670 double *zwmin = NULL;
671 double *zwmax = NULL;
672 cpl_array *sel = NULL;
673
674 moo_sky_lines_list_get_free_zones(skylines, wmin, wmax, &zwmin, &zwmax,
675 &sel);
676 int size = cpl_array_get_size(sel);
677 cpl_vector *data = NULL;
678 cpl_vector *data_dersnr = NULL;
679 for (int i = 0; i < size; i++) {
680 int idx = cpl_array_get_cplsize(sel, i, NULL);
681 double cmin = zwmin[idx];
682 double cmax = zwmax[idx];
683
684 int zstart = start;
685 double zmin = cpl_image_get(wmap, zstart, ext_idx, &rej);
686 while (zmin < cmin) {
687 zstart += direction;
688 zmin = cpl_image_get(wmap, zstart, ext_idx, &rej);
689 }
690
691 int zstop = zstart;
692 double zmax = cpl_image_get(wmap, zstop, ext_idx, &rej);
693
694 while (zmax < cmax && zstop < stop) {
695 zstop += direction;
696 zmax = cpl_image_get(wmap, zstop, ext_idx, &rej);
697 }
698 if (direction < 0) {
699 int temp = zstart;
700 zstart = zstop;
701 zstop = temp;
702 }
703 hdrl_image *fimg =
704 hdrl_image_extract(himg, zstart, ext_idx, zstop, ext_idx);
705 hdrl_image_reject_value(fimg, CPL_VALUE_NAN);
706 cpl_image *img = hdrl_image_get_image(fimg);
707 cpl_image *error = hdrl_image_get_error(fimg);
708 cpl_image_reject_value(error, CPL_VALUE_NAN | CPL_VALUE_ZERO);
709 int enx = cpl_image_get_size_x(error);
710 int enbrej = cpl_image_count_rejected(error);
711 if (enx > enbrej) {
712 cpl_vector *imrow = cpl_vector_new_from_image_row(img, 1);
713
714 if (data_dersnr == NULL) {
715 data_dersnr = cpl_vector_duplicate(imrow);
716 }
717 else {
718 int vsize = cpl_vector_get_size(data_dersnr);
719 int row_size = cpl_vector_get_size(imrow);
720 cpl_vector_set_size(data_dersnr, vsize + row_size);
721 for (int j = 0; j < row_size; j++) {
722 double v = cpl_vector_get(imrow, j);
723 cpl_vector_set(data_dersnr, j + vsize, v);
724 }
725 }
726 cpl_image_divide(img, error);
727
728 cpl_vector *row = cpl_vector_new_from_image_row(img, 1);
729 if (data == NULL) {
730 data = cpl_vector_duplicate(row);
731 }
732 else {
733 int vsize = cpl_vector_get_size(data);
734 int row_size = cpl_vector_get_size(row);
735 cpl_vector_set_size(data, vsize + row_size);
736 for (int j = 0; j < row_size; j++) {
737 double v = cpl_vector_get(row, j);
738 cpl_vector_set(data, j + vsize, v);
739 }
740 }
741 cpl_vector_delete(row);
742 cpl_vector_delete(imrow);
743 }
744 hdrl_image_delete(fimg);
745 }
746 if (data_dersnr != NULL) {
747 *dersnr = moo_vector_get_dersnr(data_dersnr);
748 snr = cpl_vector_get_median(data);
749 }
750 else {
751 *dersnr = NAN;
752 snr = NAN;
753 }
754
755 cpl_vector_delete(data);
756 cpl_vector_delete(data_dersnr);
757 cpl_array_delete(sel);
758 return snr;
759}
760/*----------------------------------------------------------------------------*/
#define MOO_BADPIX_OUTSIDE_DATA_RANGE
Definition: moo_badpix.h:62
#define MOO_BADPIX_CALIB_DEFECT
Definition: moo_badpix.h:48
#define MOO_BADPIX_HOT
Definition: moo_badpix.h:51
cpl_error_code moo_badpix_to_mask(cpl_image *badpix, cpl_mask *mask, unsigned int level)
Apply the badpix map on the given mask.
Definition: moo_badpix.c:58
#define MOO_BADPIX_GOOD
Definition: moo_badpix.h:36
#define MOO_BADPIX_COSMETIC
Definition: moo_badpix.h:57
const char * moo_detector_get_extname(moo_detector_type type, int ntas)
Get the extension name of a detector.
Definition: moo_detector.c:137
enum _moo_detector_type_ moo_detector_type
The type code type.
Definition: moo_detector.h:64
double moo_ext_single_compute_snr(moo_ext_single *self, int ext_idx, cpl_image *wmap, moo_spectral_format_info *sinfo, moo_sky_lines_list *skylines, double *dersnr)
Compute SNR for a given target.
moo_ext_single * moo_ext_single_new(moo_detector_type type, int ntas)
Create a new moo_ext_single.
hdrl_image * moo_ext_single_get_image(moo_ext_single *self)
Get image of EXT_SINGLE.
cpl_error_code moo_ext_single_load(moo_ext_single *self, unsigned int level)
load a moo_ext_single using the level for badpixel
cpl_error_code moo_ext_single_free(moo_ext_single *self)
Free memory associate to this single EXT.
void moo_ext_single_delete(moo_ext_single *self)
Delete a moo_ext_single.
cpl_image * moo_ext_single_get_qual(moo_ext_single *self)
Get image of qual.
moo_ext_single * moo_ext_single_create(const char *filename, moo_detector_type type, int ntas)
Create a new moo_ext_single from the given EXT filename.
void moo_ext_single_save(const moo_ext_single *self, const char *filename, moo_detector_type type, int ntas)
Save a moo_ext_single to a FITS file.
cpl_error_code moo_ext_single_set_wcs1(moo_ext_single *self, double crpix1, double crval1, double cd1_1, const char *ctype1, const char *cunit1)
Set the WCS1 of the extension.
cpl_image * moo_ext_single_get_errs(moo_ext_single *self)
Get image of errs.
cpl_error_code moo_ext_single_dump(const moo_ext_single *self, FILE *stream)
Dump structural information of EXT_SINGLE.
cpl_error_code moo_ext_single_sum(moo_ext_single *a, moo_ext_single *b)
Add two single EXT.
cpl_propertylist * moo_ext_single_get_header(moo_ext_single *self)
Get header of ext single.
cpl_image * moo_ext_single_get_data(moo_ext_single *self)
Get image of data.
cpl_error_code moo_fits_write_extension_image(cpl_image *image, const char *filename, const char *name, const char *detectorname, cpl_type type, cpl_propertylist *header)
Write an image as extension in FITS file.
Definition: moo_fits.c:123
cpl_image * moo_fits_load_extension_image(const char *filename, const char *name, const char *detectorname, cpl_type type)
Load an image from FITS file.
Definition: moo_fits.c:311
cpl_error_code moo_sky_lines_list_get_free_zones(moo_sky_lines_list *self, double wmin, double wmax, double **zwmin, double **zwmax, cpl_array **sel)
Get free zones for a specific wave range.
cpl_error_code moo_pfits_append_hduclass_quality(cpl_propertylist *plist, moo_detector_type type, int ntas, const cpl_propertylist *sci_header, int mask)
Set the HDUCLASS QUALITY Keyword.
Definition: moo_pfits.c:1591
cpl_error_code moo_pfits_append_hduclass_error(cpl_propertylist *plist, moo_detector_type type, int ntas, const cpl_propertylist *sci_header)
Set the HDUCLASS ERROR Keyword.
Definition: moo_pfits.c:1537
int moo_pfits_get_naxis(const cpl_propertylist *plist)
find out the NAXIS value
Definition: moo_pfits.c:980
cpl_error_code moo_qc_set_mflat_max(cpl_propertylist *plist, double val)
Set the QC.MFLAT.MAX value.
Definition: moo_qc.c:1532
cpl_error_code moo_qc_set_mflat_min(cpl_propertylist *plist, double val)
Set the QC.MFLAT.MIN value.
Definition: moo_qc.c:1503
cpl_error_code moo_qc_set_mflat_sn_max(cpl_propertylist *plist, double val)
Set the QC.MFLAT.SN.MAX value.
Definition: moo_qc.c:1358
cpl_error_code moo_qc_set_mflat_sn_min(cpl_propertylist *plist, double val)
Set the QC.MFLAT.SN.MIN value.
Definition: moo_qc.c:1329
cpl_error_code moo_qc_set_mflat_rms(cpl_propertylist *plist, double val)
Set the QC.MFLAT.RMS value.
Definition: moo_qc.c:1619
cpl_error_code moo_qc_set_mflat_sn_med(cpl_propertylist *plist, double val)
Set the QC.MFLAT.SN.MED value.
Definition: moo_qc.c:1387
cpl_error_code moo_qc_set_mflat_med(cpl_propertylist *plist, double val)
Set the QC.MFLAT.MED value.
Definition: moo_qc.c:1590
cpl_error_code moo_qc_set_mflat_avg(cpl_propertylist *plist, double val)
Set the QC.MFLAT.AVG value.
Definition: moo_qc.c:1561
cpl_vector * moo_vector_filter_nan(cpl_vector *v)
Create new vector with nan values filter.
Definition: moo_utils.c:1309
double moo_vector_get_dersnr(const cpl_vector *ve)
This function computes the signal to noise ratio DER_SNR following the definition set forth by the Sp...
Definition: moo_utils.c:2189