MUSE Pipeline Reference Manual  2.1.1
muse_pfits.c
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set sw=2 sts=2 et cin: */
3 /*
4  * This file is part of the MUSE Instrument Pipeline
5  * Copyright (C) 2005-2017 European Southern Observatory
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 
26 /*----------------------------------------------------------------------------*
27  * Includes *
28  *----------------------------------------------------------------------------*/
29 #include <cpl.h>
30 #include <math.h>
31 #include <string.h>
32 
33 #include "muse_pfits.h"
34 #include "muse_instrument.h"
35 
36 /*----------------------------------------------------------------------------*/
40 /*----------------------------------------------------------------------------*/
41 
44 /*----------------------------------------------------------------------------*/
52 /*----------------------------------------------------------------------------*/
53 const char *
54 muse_pfits_get_arcfile(const cpl_propertylist *aHeaders)
55 {
56  const char *value = cpl_propertylist_get_string(aHeaders, "ARCFILE");
57  cpl_ensure(value, cpl_error_get_code(), NULL);
58  return value;
59 }
60 
61 /*----------------------------------------------------------------------------*/
69 /*----------------------------------------------------------------------------*/
70 const char *
71 muse_pfits_get_origfile(const cpl_propertylist *aHeaders)
72 {
73  const char *value = cpl_propertylist_get_string(aHeaders, "ORIGFILE");
74  cpl_ensure(value, cpl_error_get_code(), NULL);
75  return value;
76 }
77 
78 /*----------------------------------------------------------------------------*/
86 /*----------------------------------------------------------------------------*/
87 const char *
88 muse_pfits_get_pipefile(const cpl_propertylist *aHeaders)
89 {
90  const char *value = cpl_propertylist_get_string(aHeaders, "PIPEFILE");
91  cpl_ensure(value, cpl_error_get_code(), NULL);
92  return value;
93 }
94 
95 /*----------------------------------------------------------------------------*/
103 /*----------------------------------------------------------------------------*/
104 const char *
105 muse_pfits_get_dpr_type(const cpl_propertylist *aHeaders)
106 {
107  cpl_errorstate prestate = cpl_errorstate_get();
108  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DPR TYPE");
109  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
110  return value;
111 } /* muse_pfits_get_dpr_type() */
112 
113 /*----------------------------------------------------------------------------*/
121 /*----------------------------------------------------------------------------*/
122 const char *
123 muse_pfits_get_dpr_catg(const cpl_propertylist *aHeaders)
124 {
125  cpl_errorstate prestate = cpl_errorstate_get();
126  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DPR CATG");
127  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
128  return value;
129 } /* muse_pfits_get_dpr_catg() */
130 
131 /*----------------------------------------------------------------------------*/
139 /*----------------------------------------------------------------------------*/
140 const char *
141 muse_pfits_get_pro_type(const cpl_propertylist *aHeaders)
142 {
143  cpl_errorstate prestate = cpl_errorstate_get();
144  const char *value = cpl_propertylist_get_string(aHeaders, "ESO PRO TYPE");
145  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
146  return value;
147 } /* muse_pfits_get_pro_type() */
148 
149 /*----------------------------------------------------------------------------*/
157 /*----------------------------------------------------------------------------*/
158 const char *
159 muse_pfits_get_pro_catg(const cpl_propertylist *aHeaders)
160 {
161  cpl_errorstate prestate = cpl_errorstate_get();
162  const char *value = cpl_propertylist_get_string(aHeaders, "ESO PRO CATG");
163  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
164  return value;
165 } /* muse_pfits_get_pro_catg() */
166 
167 /*----------------------------------------------------------------------------*/
179 /*----------------------------------------------------------------------------*/
180 cpl_boolean
181 muse_pfits_has_ifu(const cpl_propertylist *aHeaders, unsigned char aIFU)
182 {
183  cpl_errorstate prestate = cpl_errorstate_get();
184  const char *extname = muse_pfits_get_extname(aHeaders);
185  if (!cpl_errorstate_is_equal(prestate) || /* no EXTNAME */
186  strncmp(extname, "CHAN", 4) || /* doesn't start with CHAN */
187  strlen(extname) < 6) { /* too short */
188  cpl_errorstate_set(prestate); /* ignore the error */
189  return CPL_FALSE;
190  }
191  unsigned char chan = atoi(extname + 4);
192  return chan == aIFU;
193 } /* muse_pfits_has_ifu() */
194 
195 /*----------------------------------------------------------------------------*/
203 /*----------------------------------------------------------------------------*/
204 const char *
205 muse_pfits_get_extname(const cpl_propertylist *aHeaders)
206 {
207  cpl_errorstate prestate = cpl_errorstate_get();
208  const char *value = cpl_propertylist_get_string(aHeaders, "EXTNAME");
209  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
210  return value;
211 } /* muse_pfits_get_extname() */
212 
213 /*----------------------------------------------------------------------------*/
221 /*----------------------------------------------------------------------------*/
222 const char *
223 muse_pfits_get_bunit(const cpl_propertylist *aHeaders)
224 {
225  cpl_errorstate prestate = cpl_errorstate_get();
226  const char *value = cpl_propertylist_get_string(aHeaders, "BUNIT");
227  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
228  return value;
229 } /* muse_pfits_get_bunit() */
230 
231 /*----------------------------------------------------------------------------*/
240 /*----------------------------------------------------------------------------*/
241 cpl_size
242 muse_pfits_get_naxis(const cpl_propertylist *aHeaders, unsigned int aAxis)
243 {
244  cpl_errorstate prestate = cpl_errorstate_get();
245  if (aAxis == 0) {
246  cpl_size value = cpl_propertylist_get_long_long(aHeaders, "NAXIS");
247  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
248  return value;
249  }
250  char keyword[KEYWORD_LENGTH];
251  snprintf(keyword, KEYWORD_LENGTH, "NAXIS%u", aAxis);
252  cpl_size value = cpl_propertylist_get_long_long(aHeaders, keyword);
253  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
254  return value;
255 }
256 
257 /*----------------------------------------------------------------------------*/
265 /*----------------------------------------------------------------------------*/
266 double
267 muse_pfits_get_ra(const cpl_propertylist *aHeaders)
268 {
269  cpl_errorstate prestate = cpl_errorstate_get();
270  const double value = cpl_propertylist_get_double(aHeaders, "RA");
271  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
272  return value;
273 }
274 
275 /*----------------------------------------------------------------------------*/
283 /*----------------------------------------------------------------------------*/
284 double
285 muse_pfits_get_dec(const cpl_propertylist *aHeaders)
286 {
287  cpl_errorstate prestate = cpl_errorstate_get();
288  const double value = cpl_propertylist_get_double(aHeaders, "DEC");
289  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
290  return value;
291 }
292 
293 /*----------------------------------------------------------------------------*/
304 /*----------------------------------------------------------------------------*/
305 double
306 muse_pfits_get_equinox(const cpl_propertylist *aHeaders)
307 {
308  cpl_errorstate prestate = cpl_errorstate_get();
309  double value = cpl_propertylist_get_double(aHeaders, "EQUINOX");
310  if (!cpl_errorstate_is_equal(prestate)) {
311  cpl_errorstate_set(prestate);
312  value = cpl_propertylist_get_long_long(aHeaders, "EQUINOX");
313  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
314  } /* if error when reading as double */
315  return value;
316 }
317 
318 /*----------------------------------------------------------------------------*/
326 /*----------------------------------------------------------------------------*/
327 double
328 muse_pfits_get_lst(const cpl_propertylist *aHeaders)
329 {
330  cpl_errorstate prestate = cpl_errorstate_get();
331  const double value = cpl_propertylist_get_double(aHeaders, "LST");
332  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
333  return value;
334 }
335 
336 /*----------------------------------------------------------------------------*/
344 /*----------------------------------------------------------------------------*/
345 double
346 muse_pfits_get_mjdobs(const cpl_propertylist *aHeaders)
347 {
348  cpl_errorstate prestate = cpl_errorstate_get();
349  const double value = cpl_propertylist_get_double(aHeaders, "MJD-OBS");
350  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
351  return value;
352 }
353 
354 /*----------------------------------------------------------------------------*/
362 /*----------------------------------------------------------------------------*/
363 const char *
364 muse_pfits_get_dateobs(const cpl_propertylist *aHeaders)
365 {
366  cpl_errorstate prestate = cpl_errorstate_get();
367  const char *value = cpl_propertylist_get_string(aHeaders, "DATE-OBS");
368  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
369  return value;
370 }
371 
372 /*----------------------------------------------------------------------------*/
380 /*----------------------------------------------------------------------------*/
381 double
382 muse_pfits_get_exptime(const cpl_propertylist *aHeaders)
383 {
384  cpl_errorstate prestate = cpl_errorstate_get();
385  const double value = cpl_propertylist_get_double(aHeaders, "EXPTIME");
386  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
387  return value;
388 }
389 
390 /*----------------------------------------------------------------------------*/
399 /*----------------------------------------------------------------------------*/
400 double
401 muse_pfits_get_crpix(const cpl_propertylist *aHeaders, unsigned int aAxis)
402 {
403  cpl_errorstate prestate = cpl_errorstate_get();
404  char keyword[KEYWORD_LENGTH];
405  snprintf(keyword, KEYWORD_LENGTH, "CRPIX%u", aAxis);
406  const double value = cpl_propertylist_get_double(aHeaders, keyword);
407  /* default to 0.0 as per FITS Standard v3.0 */
408  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
409  return value;
410 }
411 
412 /*----------------------------------------------------------------------------*/
421 /*----------------------------------------------------------------------------*/
422 double
423 muse_pfits_get_crval(const cpl_propertylist *aHeaders, unsigned int aAxis)
424 {
425  cpl_errorstate prestate = cpl_errorstate_get();
426  char keyword[KEYWORD_LENGTH];
427  snprintf(keyword, KEYWORD_LENGTH, "CRVAL%u", aAxis);
428  const double value = cpl_propertylist_get_double(aHeaders, keyword);
429  /* default to 0.0 as per FITS Standard v3.0 */
430  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
431  return value;
432 }
433 
434 /*----------------------------------------------------------------------------*/
444 /*----------------------------------------------------------------------------*/
445 double
446 muse_pfits_get_cd(const cpl_propertylist *aHeaders, unsigned int aAxisI,
447  unsigned int aAxisJ)
448 {
449  cpl_errorstate prestate = cpl_errorstate_get();
450  char keyword[KEYWORD_LENGTH];
451  snprintf(keyword, KEYWORD_LENGTH, "CD%u_%u", aAxisI, aAxisJ);
452  const double value = cpl_propertylist_get_double(aHeaders, keyword);
453  /* default to 0.0 as per FITS Standard v3.0 */
454  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
455  return value;
456 }
457 
458 /*----------------------------------------------------------------------------*/
467 /*----------------------------------------------------------------------------*/
468 const char *
469 muse_pfits_get_ctype(const cpl_propertylist *aHeaders, unsigned int aAxis)
470 {
471  cpl_errorstate prestate = cpl_errorstate_get();
472  char keyword[KEYWORD_LENGTH];
473  snprintf(keyword, KEYWORD_LENGTH, "CTYPE%u", aAxis);
474  const char *value = cpl_propertylist_get_string(aHeaders, keyword);
475  /* default to single space as per FITS Standard v3.0 */
476  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), " ");
477  return value;
478 }
479 
480 /*----------------------------------------------------------------------------*/
489 /*----------------------------------------------------------------------------*/
490 const char *
491 muse_pfits_get_cunit(const cpl_propertylist *aHeaders, unsigned int aAxis)
492 {
493  cpl_errorstate prestate = cpl_errorstate_get();
494  char keyword[KEYWORD_LENGTH];
495  snprintf(keyword, KEYWORD_LENGTH, "CUNIT%u", aAxis);
496  const char *value = cpl_propertylist_get_string(aHeaders, keyword);
497  /* default to single space as per FITS Standard v3.0 */
498  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), " ");
499  return value;
500 }
501 
502 /*----------------------------------------------------------------------------*/
510 /*----------------------------------------------------------------------------*/
511 int
512 muse_pfits_get_read_id(const cpl_propertylist *aHeaders)
513 {
514  cpl_errorstate prestate = cpl_errorstate_get();
515  const int value = cpl_propertylist_get_int(aHeaders, "ESO DET READ CURID");
516  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
517  return value;
518 }
519 
520 /*----------------------------------------------------------------------------*/
528 /*----------------------------------------------------------------------------*/
529 const char *
530 muse_pfits_get_read_name(const cpl_propertylist *aHeaders)
531 {
532  cpl_errorstate prestate = cpl_errorstate_get();
533  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DET READ CURNAME");
534  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
535  return value;
536 }
537 
538 /*----------------------------------------------------------------------------*/
546 /*----------------------------------------------------------------------------*/
547 int
548 muse_pfits_get_binx(const cpl_propertylist *aHeaders)
549 {
550  cpl_errorstate prestate = cpl_errorstate_get();
551  const int value = cpl_propertylist_get_int(aHeaders, "ESO DET BINX");
552  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 1);
553  return value;
554 }
555 
556 /*----------------------------------------------------------------------------*/
564 /*----------------------------------------------------------------------------*/
565 int
566 muse_pfits_get_biny(const cpl_propertylist *aHeaders)
567 {
568  cpl_errorstate prestate = cpl_errorstate_get();
569  const int value = cpl_propertylist_get_int(aHeaders, "ESO DET BINY");
570  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 1);
571  return value;
572 }
573 
574 /*----------------------------------------------------------------------------*/
582 /*----------------------------------------------------------------------------*/
583 const char *
584 muse_pfits_get_chip_name(const cpl_propertylist *aHeaders)
585 {
586  cpl_errorstate prestate = cpl_errorstate_get();
587  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DET CHIP NAME");
588  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
589  return value;
590 }
591 
592 /*----------------------------------------------------------------------------*/
600 /*----------------------------------------------------------------------------*/
601 const char *
602 muse_pfits_get_chip_id(const cpl_propertylist *aHeaders)
603 {
604  cpl_errorstate prestate = cpl_errorstate_get();
605  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DET CHIP ID");
606  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
607  return value;
608 }
609 
610 /*----------------------------------------------------------------------------*/
618 /*----------------------------------------------------------------------------*/
619 const char *
620 muse_pfits_get_chip_date(const cpl_propertylist *aHeaders)
621 {
622  cpl_errorstate prestate = cpl_errorstate_get();
623  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DET CHIP DATE");
624  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
625  return value;
626 }
627 
628 /*----------------------------------------------------------------------------*/
637 /*----------------------------------------------------------------------------*/
638 cpl_boolean
639 muse_pfits_get_chip_live(const cpl_propertylist *aHeaders)
640 {
641  cpl_errorstate prestate = cpl_errorstate_get();
642  const cpl_boolean value = cpl_propertylist_get_bool(aHeaders,
643  "ESO DET CHIP LIVE") == 0
644  ? CPL_FALSE : CPL_TRUE;
645  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), CPL_FALSE);
646  return value;
647 }
648 
649 /*----------------------------------------------------------------------------*/
658 /*----------------------------------------------------------------------------*/
659 double
660 muse_pfits_get_ron(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
661 {
662  char keyword[KEYWORD_LENGTH];
663  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d RON", aQuadrant);
664  if (!cpl_propertylist_has(aHeaders, keyword)) {
665  cpl_msg_warning(__func__, "Could not get %s, using RON=1.0",
666  keyword);
667  return 1.0;
668  }
669  return cpl_propertylist_get_double(aHeaders, keyword);
670 }
671 
672 /*----------------------------------------------------------------------------*/
684 /*----------------------------------------------------------------------------*/
685 double
686 muse_pfits_get_gain(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
687 {
688  char keyword[KEYWORD_LENGTH];
689  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d GAIN", aQuadrant);
690  return cpl_propertylist_get_double(aHeaders, keyword);
691 } /* muse_pfits_get_gain() */
692 
693 /*----------------------------------------------------------------------------*/
702 /*----------------------------------------------------------------------------*/
703 int
704 muse_pfits_get_out_output_x(const cpl_propertylist *aHeaders,
705  unsigned char aQuadrant)
706 {
707  cpl_errorstate prestate = cpl_errorstate_get();
708  char keyword[KEYWORD_LENGTH];
709  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d X", aQuadrant);
710  const int value = cpl_propertylist_get_int(aHeaders, keyword);
711  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
712  return value;
713 }
714 
715 /*----------------------------------------------------------------------------*/
724 /*----------------------------------------------------------------------------*/
725 int
726 muse_pfits_get_out_output_y(const cpl_propertylist *aHeaders,
727  unsigned char aQuadrant)
728 {
729  cpl_errorstate prestate = cpl_errorstate_get();
730  char keyword[KEYWORD_LENGTH];
731  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d Y", aQuadrant);
732  const int value = cpl_propertylist_get_int(aHeaders, keyword);
733  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
734  return value;
735 }
736 
737 /*----------------------------------------------------------------------------*/
746 /*----------------------------------------------------------------------------*/
747 int
748 muse_pfits_get_out_nx(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
749 {
750  cpl_errorstate prestate = cpl_errorstate_get();
751  char keyword[KEYWORD_LENGTH];
752  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d NX", aQuadrant);
753  const int value = cpl_propertylist_get_int(aHeaders, keyword);
754  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
755  return value;
756 }
757 
758 /*----------------------------------------------------------------------------*/
767 /*----------------------------------------------------------------------------*/
768 int
769 muse_pfits_get_out_ny(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
770 {
771  cpl_errorstate prestate = cpl_errorstate_get();
772  char keyword[KEYWORD_LENGTH];
773  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d NY", aQuadrant);
774  const int value = cpl_propertylist_get_int(aHeaders, keyword);
775  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
776  return value;
777 }
778 
779 /*----------------------------------------------------------------------------*/
788 /*----------------------------------------------------------------------------*/
789 int
790 muse_pfits_get_out_prescan_x(const cpl_propertylist *aHeaders,
791  unsigned char aQuadrant)
792 {
793  cpl_errorstate prestate = cpl_errorstate_get();
794  char keyword[KEYWORD_LENGTH];
795  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d PRSCX", aQuadrant);
796  const int value = cpl_propertylist_get_int(aHeaders, keyword);
797  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
798  return value;
799 }
800 
801 /*----------------------------------------------------------------------------*/
810 /*----------------------------------------------------------------------------*/
811 int
812 muse_pfits_get_out_prescan_y(const cpl_propertylist *aHeaders,
813  unsigned char aQuadrant)
814 {
815  cpl_errorstate prestate = cpl_errorstate_get();
816  char keyword[KEYWORD_LENGTH];
817  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d PRSCY", aQuadrant);
818  const int value = cpl_propertylist_get_int(aHeaders, keyword);
819  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
820  return value;
821 }
822 
823 /*----------------------------------------------------------------------------*/
832 /*----------------------------------------------------------------------------*/
833 int
834 muse_pfits_get_out_overscan_x(const cpl_propertylist *aHeaders,
835  unsigned char aQuadrant)
836 {
837  cpl_errorstate prestate = cpl_errorstate_get();
838  char keyword[KEYWORD_LENGTH];
839  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d OVSCX", aQuadrant);
840  const int value = cpl_propertylist_get_int(aHeaders, keyword);
841  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
842  return value;
843 }
844 
845 /*----------------------------------------------------------------------------*/
854 /*----------------------------------------------------------------------------*/
855 int
856 muse_pfits_get_out_overscan_y(const cpl_propertylist *aHeaders,
857  unsigned char aQuadrant)
858 {
859  cpl_errorstate prestate = cpl_errorstate_get();
860  char keyword[KEYWORD_LENGTH];
861  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d OVSCY", aQuadrant);
862  const int value = cpl_propertylist_get_int(aHeaders, keyword);
863  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
864  return value;
865 }
866 
867 /*----------------------------------------------------------------------------*/
880 /*----------------------------------------------------------------------------*/
881 double
882 muse_pfits_get_geolat(const cpl_propertylist *aHeaders)
883 {
884  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL GEOLAT");
885  if (fabs(value) < DBL_EPSILON) {
886  return -24.625278;
887  }
888  return value;
889 }
890 
891 /*----------------------------------------------------------------------------*/
904 /*----------------------------------------------------------------------------*/
905 double
906 muse_pfits_get_geolon(const cpl_propertylist *aHeaders)
907 {
908  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL GEOLON");
909  if (fabs(value) < DBL_EPSILON) {
910  return 70.402222;
911  }
912  return value;
913 }
914 
915 /*----------------------------------------------------------------------------*/
926 /*----------------------------------------------------------------------------*/
927 double
928 muse_pfits_get_geoelev(const cpl_propertylist *aHeaders)
929 {
930  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL GEOELEV");
931  if (fabs(value) < DBL_EPSILON) {
932  return 2648.;
933  }
934  return value;
935 }
936 
937 /*----------------------------------------------------------------------------*/
949 /*----------------------------------------------------------------------------*/
950 double
951 muse_pfits_get_focu_scale(const cpl_propertylist *aHeaders)
952 {
953  double value = 1.705;
954  if (aHeaders && cpl_propertylist_has(aHeaders, "ESO TEL FOCU SCALE")) {
955  value = cpl_propertylist_get_double(aHeaders, "ESO TEL FOCU SCALE");
956  }
957  return value;
958 }
959 
960 /*----------------------------------------------------------------------------*/
968 /*----------------------------------------------------------------------------*/
969 double
970 muse_pfits_get_airmass_start(const cpl_propertylist *aHeaders)
971 {
972  cpl_errorstate prestate = cpl_errorstate_get();
973  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AIRM START");
974  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
975  return value;
976 }
977 
978 /*----------------------------------------------------------------------------*/
986 /*----------------------------------------------------------------------------*/
987 double
988 muse_pfits_get_airmass_end(const cpl_propertylist *aHeaders)
989 {
990  cpl_errorstate prestate = cpl_errorstate_get();
991  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AIRM END");
992  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
993  return value;
994 }
995 
996 /*----------------------------------------------------------------------------*/
1004 /*----------------------------------------------------------------------------*/
1005 double
1006 muse_pfits_get_temp(const cpl_propertylist *aHeaders)
1007 {
1008  cpl_errorstate prestate = cpl_errorstate_get();
1009  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI TEMP");
1010  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1011  return value;
1012 }
1013 
1014 /*----------------------------------------------------------------------------*/
1022 /*----------------------------------------------------------------------------*/
1023 double
1024 muse_pfits_get_rhum(const cpl_propertylist *aHeaders)
1025 {
1026  cpl_errorstate prestate = cpl_errorstate_get();
1027  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI RHUM");
1028  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1029  return value;
1030 }
1031 
1032 /*----------------------------------------------------------------------------*/
1040 /*----------------------------------------------------------------------------*/
1041 double
1042 muse_pfits_get_pres_start(const cpl_propertylist *aHeaders)
1043 {
1044  cpl_errorstate prestate = cpl_errorstate_get();
1045  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI PRES START");
1046  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1047  return value;
1048 }
1049 
1050 /*----------------------------------------------------------------------------*/
1058 /*----------------------------------------------------------------------------*/
1059 double
1060 muse_pfits_get_pres_end(const cpl_propertylist *aHeaders)
1061 {
1062  cpl_errorstate prestate = cpl_errorstate_get();
1063  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI PRES END");
1064  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1065  return value;
1066 }
1067 
1068 /*----------------------------------------------------------------------------*/
1076 /*----------------------------------------------------------------------------*/
1077 double
1078 muse_pfits_get_fwhm_start(const cpl_propertylist *aHeaders)
1079 {
1080  cpl_errorstate prestate = cpl_errorstate_get();
1081  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI FWHM START");
1082  cpl_ensure(cpl_errorstate_is_equal(prestate) && value > 0.,
1083  cpl_error_get_code(), 0.0);
1084  return value;
1085 }
1086 
1087 /*----------------------------------------------------------------------------*/
1095 /*----------------------------------------------------------------------------*/
1096 double
1097 muse_pfits_get_fwhm_end(const cpl_propertylist *aHeaders)
1098 {
1099  cpl_errorstate prestate = cpl_errorstate_get();
1100  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI FWHM END");
1101  cpl_ensure(cpl_errorstate_is_equal(prestate) && value > 0.,
1102  cpl_error_get_code(), 0.0);
1103  return value;
1104 }
1105 
1106 /*----------------------------------------------------------------------------*/
1114 /*----------------------------------------------------------------------------*/
1115 double
1116 muse_pfits_get_altang(const cpl_propertylist *aHeaders)
1117 {
1118  cpl_errorstate prestate = cpl_errorstate_get();
1119  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL ALT");
1120  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1121  return value;
1122 }
1123 
1124 /*----------------------------------------------------------------------------*/
1132 /*----------------------------------------------------------------------------*/
1133 double
1134 muse_pfits_get_parang_start(const cpl_propertylist *aHeaders)
1135 {
1136  cpl_errorstate prestate = cpl_errorstate_get();
1137  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL PARANG START");
1138  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1139  return value;
1140 }
1141 
1142 /*----------------------------------------------------------------------------*/
1150 /*----------------------------------------------------------------------------*/
1151 double
1152 muse_pfits_get_parang_end(const cpl_propertylist *aHeaders)
1153 {
1154  cpl_errorstate prestate = cpl_errorstate_get();
1155  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL PARANG END");
1156  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1157  return value;
1158 }
1159 
1160 /*----------------------------------------------------------------------------*/
1168 /*----------------------------------------------------------------------------*/
1169 double
1170 muse_pfits_get_agx_avg(const cpl_propertylist *aHeaders)
1171 {
1172  cpl_errorstate prestate = cpl_errorstate_get();
1173  const double value = cpl_propertylist_get_double(aHeaders, "ESO OCS SGS AG FWHMX AVG");
1174  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1175  return value;
1176 }
1177 
1178 /*----------------------------------------------------------------------------*/
1186 /*----------------------------------------------------------------------------*/
1187 double
1188 muse_pfits_get_agx_rms(const cpl_propertylist *aHeaders)
1189 {
1190  cpl_errorstate prestate = cpl_errorstate_get();
1191  const double value = cpl_propertylist_get_double(aHeaders, "ESO OCS SGS AG FWHMX RMS");
1192  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1193  return value;
1194 }
1195 
1196 /*----------------------------------------------------------------------------*/
1204 /*----------------------------------------------------------------------------*/
1205 double
1206 muse_pfits_get_agy_avg(const cpl_propertylist *aHeaders)
1207 {
1208  cpl_errorstate prestate = cpl_errorstate_get();
1209  const double value = cpl_propertylist_get_double(aHeaders, "ESO OCS SGS AG FWHMY AVG");
1210  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1211  return value;
1212 }
1213 
1214 /*----------------------------------------------------------------------------*/
1222 /*----------------------------------------------------------------------------*/
1223 double
1224 muse_pfits_get_agy_rms(const cpl_propertylist *aHeaders)
1225 {
1226  cpl_errorstate prestate = cpl_errorstate_get();
1227  const double value = cpl_propertylist_get_double(aHeaders, "ESO OCS SGS AG FWHMY RMS");
1228  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1229  return value;
1230 }
1231 
1232 /*----------------------------------------------------------------------------*/
1240 /*----------------------------------------------------------------------------*/
1241 double
1242 muse_pfits_get_ia_fwhm(const cpl_propertylist *aHeaders)
1243 {
1244  cpl_errorstate prestate = cpl_errorstate_get();
1245  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL IA FWHM");
1246  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1247  return value;
1248 }
1249 
1250 /*----------------------------------------------------------------------------*/
1258 /*----------------------------------------------------------------------------*/
1259 double
1260 muse_pfits_get_ia_fwhmlin(const cpl_propertylist *aHeaders)
1261 {
1262  cpl_errorstate prestate = cpl_errorstate_get();
1263  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL IA FWHMLIN");
1264  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1265  return value;
1266 }
1267 
1268 /*----------------------------------------------------------------------------*/
1276 /*----------------------------------------------------------------------------*/
1277 const char *
1278 muse_pfits_get_drot_mode(const cpl_propertylist *aHeaders)
1279 {
1280  cpl_errorstate prestate = cpl_errorstate_get();
1281  const char *value = cpl_propertylist_get_string(aHeaders, "ESO INS DROT MODE");
1282  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1283  return value;
1284 }
1285 
1286 /*----------------------------------------------------------------------------*/
1294 /*----------------------------------------------------------------------------*/
1295 double
1296 muse_pfits_get_drot_posang(const cpl_propertylist *aHeaders)
1297 {
1298  cpl_errorstate prestate = cpl_errorstate_get();
1299  const double value = cpl_propertylist_get_double(aHeaders, "ESO INS DROT POSANG");
1300  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1301  return value;
1302 }
1303 
1304 /*----------------------------------------------------------------------------*/
1312 /*----------------------------------------------------------------------------*/
1313 double
1314 muse_pfits_get_drot_start(const cpl_propertylist *aHeaders)
1315 {
1316  cpl_errorstate prestate = cpl_errorstate_get();
1317  const double value = cpl_propertylist_get_double(aHeaders, "ESO INS DROT START");
1318  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1319  return value;
1320 }
1321 
1322 /*----------------------------------------------------------------------------*/
1330 /*----------------------------------------------------------------------------*/
1331 double
1332 muse_pfits_get_drot_end(const cpl_propertylist *aHeaders)
1333 {
1334  cpl_errorstate prestate = cpl_errorstate_get();
1335  const double value = cpl_propertylist_get_double(aHeaders, "ESO INS DROT END");
1336  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1337  return value;
1338 }
1339 
1340 /*----------------------------------------------------------------------------*/
1350 /*----------------------------------------------------------------------------*/
1351 muse_ins_mode
1352 muse_pfits_get_mode(const cpl_propertylist *aHeaders)
1353 {
1354  const char *value = muse_pfits_get_insmode(aHeaders);
1355  cpl_ensure(value, cpl_error_get_code(), MUSE_MODE_WFM_NONAO_N);
1356  if (!strncmp(value, "NFM", 3)) {
1357  return MUSE_MODE_NFM_AO_N;
1358  }
1359  if (!strncmp(value, "WFM-AO-N", 8)) {
1360  return MUSE_MODE_WFM_AO_N;
1361  }
1362  if (!strncmp(value, "WFM-AO-E", 8)) {
1363  return MUSE_MODE_WFM_AO_E;
1364  }
1365  if (!strncmp(value, "WFM-NOAO-N", 10) || !strncmp(value, "WFM-NONAO-N", 11)) {
1366  return MUSE_MODE_WFM_NONAO_N;
1367  }
1368  return MUSE_MODE_WFM_NONAO_E;
1369 }
1370 
1371 /*----------------------------------------------------------------------------*/
1381 /*----------------------------------------------------------------------------*/
1382 const char *
1383 muse_pfits_get_insmode(const cpl_propertylist *aHeaders)
1384 {
1385  cpl_errorstate prestate = cpl_errorstate_get();
1386  const char *value = cpl_propertylist_get_string(aHeaders, "ESO INS MODE");
1387  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1388  return value;
1389 }
1390 
1391 /*----------------------------------------------------------------------------*/
1407 /*----------------------------------------------------------------------------*/
1408 double
1409 muse_pfits_get_pam_intensity(const cpl_propertylist *aHeaders, int aDiode)
1410 {
1411  cpl_errorstate prestate = cpl_errorstate_get();
1412  char keyword[KEYWORD_LENGTH];
1413  snprintf(keyword, KEYWORD_LENGTH, "ESO INS AMPL%d CURR", aDiode);
1414  double value = cpl_propertylist_get_double(aHeaders, keyword);
1415  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1416  const char *comment = cpl_propertylist_get_comment(aHeaders, keyword);
1417  cpl_boolean ismilliampere = comment && strstr(comment, "[mA]")
1418  ? CPL_TRUE : CPL_FALSE;
1419  if (!ismilliampere) {
1420  cpl_error_set_message(__func__, CPL_ERROR_INCOMPATIBLE_INPUT,
1421  "Could not ensure that %s is in mA!", keyword);
1422  } else {
1423  value /= 1000.; /* convert from mA to A */
1424  }
1425  return value;
1426 }
1427 
1428 /*----------------------------------------------------------------------------*/
1437 /*----------------------------------------------------------------------------*/
1438 double
1439 muse_pfits_get_pam_stdev(const cpl_propertylist *aHeaders, int aDiode)
1440 {
1441  cpl_errorstate prestate = cpl_errorstate_get();
1442  char keyword[KEYWORD_LENGTH];
1443  snprintf(keyword, KEYWORD_LENGTH, "ESO INS AMPL%d STDEV", aDiode);
1444  const double value = cpl_propertylist_get_double(aHeaders, keyword);
1445  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1446  return value;
1447 }
1448 
1449 /*----------------------------------------------------------------------------*/
1457 /*----------------------------------------------------------------------------*/
1458 const char *
1459 muse_pfits_get_pam2_filter(const cpl_propertylist *aHeaders)
1460 {
1461  cpl_errorstate prestate = cpl_errorstate_get();
1462  const char *value = cpl_propertylist_get_string(aHeaders,
1463  "ESO INS AMPL2 FILTER");
1464  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1465  return value;
1466 }
1467 
1468 /*----------------------------------------------------------------------------*/
1481 /*----------------------------------------------------------------------------*/
1482 int
1483 muse_pfits_get_lampnum(const cpl_propertylist *aHeaders)
1484 {
1485  cpl_errorstate prestate = cpl_errorstate_get();
1486  const int value = cpl_propertylist_get_int(aHeaders, "ESO INS LAMPNUM");
1487  if (!cpl_errorstate_is_equal(prestate)) {
1488  /* header keyword not present (old data of some sort?!) */
1489  cpl_errorstate_set(prestate); /* be backward-compatible */
1490  return 6; /* return the default */
1491  }
1492  return value;
1493 }
1494 
1495 /*----------------------------------------------------------------------------*/
1504 /*----------------------------------------------------------------------------*/
1505 const char *
1506 muse_pfits_get_lamp_name(const cpl_propertylist *aHeaders, int aLamp)
1507 {
1508  cpl_errorstate prestate = cpl_errorstate_get();
1509  char keyword[KEYWORD_LENGTH];
1510  snprintf(keyword, KEYWORD_LENGTH, "ESO INS LAMP%d NAME", aLamp);
1511  const char *value = cpl_propertylist_get_string(aHeaders, keyword);
1512  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1513  return value;
1514 }
1515 
1516 /*----------------------------------------------------------------------------*/
1525 /*----------------------------------------------------------------------------*/
1526 int
1527 muse_pfits_get_lamp_status(const cpl_propertylist *aHeaders, int aLamp)
1528 {
1529  cpl_errorstate prestate = cpl_errorstate_get();
1530  char keyword[KEYWORD_LENGTH];
1531  snprintf(keyword, KEYWORD_LENGTH, "ESO INS LAMP%d ST", aLamp);
1532  const int value = cpl_propertylist_get_bool(aHeaders, keyword);
1533  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
1534  return value;
1535 }
1536 
1537 /*----------------------------------------------------------------------------*/
1546 /*----------------------------------------------------------------------------*/
1547 const char *
1548 muse_pfits_get_shut_name(const cpl_propertylist *aHeaders, int aShutter)
1549 {
1550  cpl_errorstate prestate = cpl_errorstate_get();
1551  char keyword[KEYWORD_LENGTH];
1552  snprintf(keyword, KEYWORD_LENGTH, "ESO INS SHUT%d NAME", aShutter);
1553  const char *value = cpl_propertylist_get_string(aHeaders, keyword);
1554  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1555  return value;
1556 }
1557 
1558 /*----------------------------------------------------------------------------*/
1567 /*----------------------------------------------------------------------------*/
1568 int
1569 muse_pfits_get_shut_status(const cpl_propertylist *aHeaders, int aShutter)
1570 {
1571  cpl_errorstate prestate = cpl_errorstate_get();
1572  char keyword[KEYWORD_LENGTH];
1573  snprintf(keyword, KEYWORD_LENGTH, "ESO INS SHUT%d ST", aShutter);
1574  const int value = cpl_propertylist_get_bool(aHeaders, keyword);
1575  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
1576  return value;
1577 }
1578 
1579 /*----------------------------------------------------------------------------*/
1590 /*----------------------------------------------------------------------------*/
1591 int
1592 muse_pfits_get_posenc(const cpl_propertylist *aHeaders, unsigned short aEncoder)
1593 {
1594  cpl_errorstate prestate = cpl_errorstate_get();
1595  char keyword[KEYWORD_LENGTH];
1596  snprintf(keyword, KEYWORD_LENGTH, "ESO INS POS%d ENC", aEncoder);
1597  const int value = cpl_propertylist_get_int(aHeaders, keyword);
1598  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
1599  return value;
1600 }
1601 
1602 /*----------------------------------------------------------------------------*/
1619 /*----------------------------------------------------------------------------*/
1620 double
1621 muse_pfits_get_pospos(const cpl_propertylist *aHeaders, unsigned short aEncoder)
1622 {
1623  cpl_errorstate prestate = cpl_errorstate_get();
1624  char keyword[KEYWORD_LENGTH];
1625  snprintf(keyword, KEYWORD_LENGTH, "ESO INS POS%d POS", aEncoder);
1626  const double value = cpl_propertylist_get_double(aHeaders, keyword);
1627  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1628  return value;
1629 }
1630 
1631 /*----------------------------------------------------------------------------*/
1639 /*----------------------------------------------------------------------------*/
1640 long
1641 muse_pfits_get_obsid(const cpl_propertylist *aHeaders)
1642 {
1643  cpl_errorstate prestate = cpl_errorstate_get();
1644  const long value = cpl_propertylist_get_long(aHeaders, "ESO OBS ID");
1645  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
1646  return value;
1647 }
1648 
1649 /*----------------------------------------------------------------------------*/
1657 /*----------------------------------------------------------------------------*/
1658 const char *
1659 muse_pfits_get_progid(const cpl_propertylist *aHeaders)
1660 {
1661  cpl_errorstate prestate = cpl_errorstate_get();
1662  const char *value = cpl_propertylist_get_string(aHeaders, "ESO OBS PROG ID");
1663  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1664  return value;
1665 }
1666 
1667 /*----------------------------------------------------------------------------*/
1675 /*----------------------------------------------------------------------------*/
1676 const char *
1677 muse_pfits_get_targname(const cpl_propertylist *aHeaders)
1678 {
1679  cpl_errorstate prestate = cpl_errorstate_get();
1680  const char *value = cpl_propertylist_get_string(aHeaders, "ESO OBS TARG NAME");
1681  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1682  return value;
1683 }
1684 
1685 /*----------------------------------------------------------------------------*/
1694 /*----------------------------------------------------------------------------*/
1695 const char *
1696 muse_pfits_get_pipe_id(const cpl_propertylist *aHeaders, unsigned int idx)
1697 {
1698  cpl_ensure(aHeaders, CPL_ERROR_NULL_INPUT, NULL);
1699  char *key = cpl_sprintf("ESO PRO REC%-u PIPE ID", idx);
1700  cpl_errorstate prestate = cpl_errorstate_get();
1701  const char *value = cpl_propertylist_get_string(aHeaders, key);
1702  cpl_errorstate_set(prestate);
1703  cpl_free(key);
1704  return value;
1705 }
1706 
1707 /*----------------------------------------------------------------------------*/
1716 /*----------------------------------------------------------------------------*/
1717 const char *
1718 muse_pfits_get_raw_filename(const cpl_propertylist *aHeaders, unsigned int idx)
1719 {
1720  cpl_ensure(aHeaders, CPL_ERROR_NULL_INPUT, NULL);
1721  char *key = cpl_sprintf("ESO PRO REC1 RAW%-u NAME", idx);
1722  cpl_errorstate prestate = cpl_errorstate_get();
1723  const char *value = cpl_propertylist_get_string(aHeaders, key);
1724  cpl_errorstate_set(prestate);
1725  cpl_free(key);
1726  return value;
1727 }
1728 
1729 /*----------------------------------------------------------------------------*/
1737 /*----------------------------------------------------------------------------*/
1738 const char *
1739 muse_pfits_get_ancestor(const cpl_propertylist *aHeaders)
1740 {
1741  cpl_ensure(aHeaders, CPL_ERROR_NULL_INPUT, NULL);
1742  cpl_errorstate prestate = cpl_errorstate_get();
1743  const char *value = cpl_propertylist_get_string(aHeaders, "ESO PRO ANCESTOR");
1744  cpl_errorstate_set(prestate);
1745  return value;
1746 }
1747 
const char * muse_pfits_get_dpr_type(const cpl_propertylist *aHeaders)
find out the DPR type
Definition: muse_pfits.c:105
cpl_boolean muse_pfits_has_ifu(const cpl_propertylist *aHeaders, unsigned char aIFU)
Find out the whether this header related to a certain IFU.
Definition: muse_pfits.c:181
int muse_pfits_get_out_overscan_y(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the vertical size of the overscan region of one quadrant
Definition: muse_pfits.c:856
int muse_pfits_get_out_output_y(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the vertical location of the output port of one quadrant
Definition: muse_pfits.c:726
double muse_pfits_get_cd(const cpl_propertylist *aHeaders, unsigned int aAxisI, unsigned int aAxisJ)
find out the WCS coordinate at the reference point
Definition: muse_pfits.c:446
cpl_boolean muse_pfits_get_chip_live(const cpl_propertylist *aHeaders)
find out if the CCD was active (live)
Definition: muse_pfits.c:639
const char * muse_pfits_get_extname(const cpl_propertylist *aHeaders)
find out the extension name
Definition: muse_pfits.c:205
const char * muse_pfits_get_insmode(const cpl_propertylist *aHeaders)
find out the observation mode
Definition: muse_pfits.c:1383
int muse_pfits_get_read_id(const cpl_propertylist *aHeaders)
find out the readout mode id
Definition: muse_pfits.c:512
const char * muse_pfits_get_dpr_catg(const cpl_propertylist *aHeaders)
find out the DPR category
Definition: muse_pfits.c:123
double muse_pfits_get_rhum(const cpl_propertylist *aHeaders)
find out the relavtive humidity (in %)
Definition: muse_pfits.c:1024
double muse_pfits_get_crval(const cpl_propertylist *aHeaders, unsigned int aAxis)
find out the WCS coordinate at the reference point
Definition: muse_pfits.c:423
double muse_pfits_get_ra(const cpl_propertylist *aHeaders)
find out the right ascension
Definition: muse_pfits.c:267
cpl_size muse_pfits_get_naxis(const cpl_propertylist *aHeaders, unsigned int aAxis)
find out the size of a given axis
Definition: muse_pfits.c:242
double muse_pfits_get_gain(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find the detector gain (in units of count/adu)
Definition: muse_pfits.c:686
int muse_pfits_get_shut_status(const cpl_propertylist *aHeaders, int aShutter)
query the status of one shutter
Definition: muse_pfits.c:1569
double muse_pfits_get_ia_fwhm(const cpl_propertylist *aHeaders)
find out the image analysis FWHM corrected by airmass (in arcsec)
Definition: muse_pfits.c:1242
int muse_pfits_get_out_overscan_x(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the horizontal size of the overscan region of one quadrant
Definition: muse_pfits.c:834
const char * muse_pfits_get_ancestor(const cpl_propertylist *aHeaders)
find out the ancestor of a file.
Definition: muse_pfits.c:1739
double muse_pfits_get_agy_avg(const cpl_propertylist *aHeaders)
find out the y-FWHM average value from the auto-guider (in arcsec)
Definition: muse_pfits.c:1206
const char * muse_pfits_get_raw_filename(const cpl_propertylist *aHeaders, unsigned int idx)
find out the i-th raw file name.
Definition: muse_pfits.c:1718
double muse_pfits_get_altang(const cpl_propertylist *aHeaders)
find out the altitude angle at start of the exposure (in degrees)
Definition: muse_pfits.c:1116
int muse_pfits_get_out_output_x(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the horizontal location of the output port of one quadrant
Definition: muse_pfits.c:704
double muse_pfits_get_pres_start(const cpl_propertylist *aHeaders)
find out the ambient pressure at start of exposure (in mbar)
Definition: muse_pfits.c:1042
double muse_pfits_get_airmass_start(const cpl_propertylist *aHeaders)
find out the airmass at start of exposure
Definition: muse_pfits.c:970
const char * muse_pfits_get_dateobs(const cpl_propertylist *aHeaders)
find out the date of observations
Definition: muse_pfits.c:364
const char * muse_pfits_get_bunit(const cpl_propertylist *aHeaders)
find out the unit string
Definition: muse_pfits.c:223
double muse_pfits_get_focu_scale(const cpl_propertylist *aHeaders)
find out the scale in the VLT focal plane
Definition: muse_pfits.c:951
const char * muse_pfits_get_shut_name(const cpl_propertylist *aHeaders, int aShutter)
query the name of one shutter
Definition: muse_pfits.c:1548
int muse_pfits_get_lampnum(const cpl_propertylist *aHeaders)
query the number of lamps installed
Definition: muse_pfits.c:1483
const char * muse_pfits_get_cunit(const cpl_propertylist *aHeaders, unsigned int aAxis)
find out the WCS axis unit string
Definition: muse_pfits.c:491
double muse_pfits_get_drot_posang(const cpl_propertylist *aHeaders)
find out the MUSE derotator position angle (in degrees)
Definition: muse_pfits.c:1296
const char * muse_pfits_get_chip_date(const cpl_propertylist *aHeaders)
find out the chip installation date
Definition: muse_pfits.c:620
double muse_pfits_get_equinox(const cpl_propertylist *aHeaders)
find out the equinox
Definition: muse_pfits.c:306
const char * muse_pfits_get_targname(const cpl_propertylist *aHeaders)
find out the ESO observation target name
Definition: muse_pfits.c:1677
double muse_pfits_get_crpix(const cpl_propertylist *aHeaders, unsigned int aAxis)
find out the WCS reference point
Definition: muse_pfits.c:401
const char * muse_pfits_get_pam2_filter(const cpl_propertylist *aHeaders)
query the filter set up in front of photo diode (pico amplifier) 2
Definition: muse_pfits.c:1459
double muse_pfits_get_fwhm_end(const cpl_propertylist *aHeaders)
find out the ambient seeing at end of exposure (in arcsec)
Definition: muse_pfits.c:1097
int muse_pfits_get_biny(const cpl_propertylist *aHeaders)
find out the binning factor in y direction
Definition: muse_pfits.c:566
double muse_pfits_get_geolat(const cpl_propertylist *aHeaders)
find out the telescope&#39;s latitude
Definition: muse_pfits.c:882
const char * muse_pfits_get_lamp_name(const cpl_propertylist *aHeaders, int aLamp)
query the name of one lamp
Definition: muse_pfits.c:1506
double muse_pfits_get_pam_intensity(const cpl_propertylist *aHeaders, int aDiode)
query the intensity measured by one photo diode (pico amplifier)
Definition: muse_pfits.c:1409
const char * muse_pfits_get_pipefile(const cpl_propertylist *aHeaders)
find out the pipefile
Definition: muse_pfits.c:88
const char * muse_pfits_get_drot_mode(const cpl_propertylist *aHeaders)
find out the MUSE derotator mode
Definition: muse_pfits.c:1278
int muse_pfits_get_out_prescan_y(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the vertical size of the prescan region of one quadrant
Definition: muse_pfits.c:812
int muse_pfits_get_out_nx(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the horizontal size of the data section of one quadrant
Definition: muse_pfits.c:748
const char * muse_pfits_get_arcfile(const cpl_propertylist *aHeaders)
find out the arcfile
Definition: muse_pfits.c:54
double muse_pfits_get_ron(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find the detector read-out noise
Definition: muse_pfits.c:660
const char * muse_pfits_get_read_name(const cpl_propertylist *aHeaders)
find out the readout mode name
Definition: muse_pfits.c:530
double muse_pfits_get_pam_stdev(const cpl_propertylist *aHeaders, int aDiode)
query the intensity std. dev. of one photo diode (pico amplifier)
Definition: muse_pfits.c:1439
double muse_pfits_get_drot_end(const cpl_propertylist *aHeaders)
find out the MUSE derotator rotation at exposure end (in degrees)
Definition: muse_pfits.c:1332
double muse_pfits_get_fwhm_start(const cpl_propertylist *aHeaders)
find out the ambient seeing at start of exposure (in arcsec)
Definition: muse_pfits.c:1078
double muse_pfits_get_drot_start(const cpl_propertylist *aHeaders)
find out the MUSE derotator rotation at exposure start (in degrees)
Definition: muse_pfits.c:1314
double muse_pfits_get_dec(const cpl_propertylist *aHeaders)
find out the declination
Definition: muse_pfits.c:285
const char * muse_pfits_get_progid(const cpl_propertylist *aHeaders)
find out the ESO program identification
Definition: muse_pfits.c:1659
int muse_pfits_get_posenc(const cpl_propertylist *aHeaders, unsigned short aEncoder)
query the absolute encoder position of one encoder
Definition: muse_pfits.c:1592
double muse_pfits_get_agy_rms(const cpl_propertylist *aHeaders)
find out the y-FWHM root mean square from the auto-guider (in arcsec)
Definition: muse_pfits.c:1224
const char * muse_pfits_get_chip_id(const cpl_propertylist *aHeaders)
find out the chip id
Definition: muse_pfits.c:602
const char * muse_pfits_get_ctype(const cpl_propertylist *aHeaders, unsigned int aAxis)
find out the WCS axis type string
Definition: muse_pfits.c:469
long muse_pfits_get_obsid(const cpl_propertylist *aHeaders)
find out the observation block id
Definition: muse_pfits.c:1641
double muse_pfits_get_agx_rms(const cpl_propertylist *aHeaders)
find out the x-FWHM root mean square from the auto-guider (in arcsec)
Definition: muse_pfits.c:1188
int muse_pfits_get_binx(const cpl_propertylist *aHeaders)
find out the binning factor in x direction
Definition: muse_pfits.c:548
double muse_pfits_get_parang_start(const cpl_propertylist *aHeaders)
find out the parallactic angle at start of exposure (in degrees)
Definition: muse_pfits.c:1134
double muse_pfits_get_pres_end(const cpl_propertylist *aHeaders)
find out the ambient pressure at end of exposure (in mbar)
Definition: muse_pfits.c:1060
double muse_pfits_get_airmass_end(const cpl_propertylist *aHeaders)
find out the airmass at end of exposure
Definition: muse_pfits.c:988
int muse_pfits_get_lamp_status(const cpl_propertylist *aHeaders, int aLamp)
query the status of one lamp
Definition: muse_pfits.c:1527
double muse_pfits_get_mjdobs(const cpl_propertylist *aHeaders)
find out the Julian Date of the observation
Definition: muse_pfits.c:346
double muse_pfits_get_pospos(const cpl_propertylist *aHeaders, unsigned short aEncoder)
query the position in user units of one encoder
Definition: muse_pfits.c:1621
const char * muse_pfits_get_pro_type(const cpl_propertylist *aHeaders)
find out the PRO type
Definition: muse_pfits.c:141
double muse_pfits_get_exptime(const cpl_propertylist *aHeaders)
find out the exposure time
Definition: muse_pfits.c:382
const char * muse_pfits_get_pro_catg(const cpl_propertylist *aHeaders)
find out the PRO category
Definition: muse_pfits.c:159
double muse_pfits_get_temp(const cpl_propertylist *aHeaders)
find out the ambient temperature (in degrees Celsius)
Definition: muse_pfits.c:1006
double muse_pfits_get_geoelev(const cpl_propertylist *aHeaders)
find out the telescope&#39;s elevation
Definition: muse_pfits.c:928
int muse_pfits_get_out_prescan_x(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the horizontal size of the prescan region of one quadrant
Definition: muse_pfits.c:790
double muse_pfits_get_lst(const cpl_propertylist *aHeaders)
find out the local siderial time
Definition: muse_pfits.c:328
double muse_pfits_get_agx_avg(const cpl_propertylist *aHeaders)
find out the x-FWHM average value from the auto-guider (in arcsec)
Definition: muse_pfits.c:1170
const char * muse_pfits_get_pipe_id(const cpl_propertylist *aHeaders, unsigned int idx)
find out the value of the flux calibration flag
Definition: muse_pfits.c:1696
double muse_pfits_get_ia_fwhmlin(const cpl_propertylist *aHeaders)
find out the image analysis FWHM from a linear fit (in arcsec)
Definition: muse_pfits.c:1260
const char * muse_pfits_get_origfile(const cpl_propertylist *aHeaders)
find out the origfile
Definition: muse_pfits.c:71
int muse_pfits_get_out_ny(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the vertical size of the data section of one quadrant
Definition: muse_pfits.c:769
const char * muse_pfits_get_chip_name(const cpl_propertylist *aHeaders)
find out the chip name
Definition: muse_pfits.c:584
double muse_pfits_get_geolon(const cpl_propertylist *aHeaders)
find out the telescope&#39;s longitude
Definition: muse_pfits.c:906
muse_ins_mode muse_pfits_get_mode(const cpl_propertylist *aHeaders)
find out the observation mode
Definition: muse_pfits.c:1352
double muse_pfits_get_parang_end(const cpl_propertylist *aHeaders)
find out the parallactic angle at end of exposure (in degrees)
Definition: muse_pfits.c:1152