MUSE Pipeline Reference Manual  0.18.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-2014 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_pipefile(const cpl_propertylist *aHeaders)
72 {
73  const char *value = cpl_propertylist_get_string(aHeaders, "PIPEFILE");
74  cpl_ensure(value, cpl_error_get_code(), NULL);
75  return value;
76 }
77 
78 /*----------------------------------------------------------------------------*/
86 /*----------------------------------------------------------------------------*/
87 const char *
88 muse_pfits_get_dpr_type(const cpl_propertylist *aHeaders)
89 {
90  cpl_errorstate prestate = cpl_errorstate_get();
91  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DPR TYPE");
92  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
93  return value;
94 } /* muse_pfits_get_dpr_type() */
95 
96 /*----------------------------------------------------------------------------*/
104 /*----------------------------------------------------------------------------*/
105 const char *
106 muse_pfits_get_dpr_catg(const cpl_propertylist *aHeaders)
107 {
108  cpl_errorstate prestate = cpl_errorstate_get();
109  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DPR CATG");
110  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
111  return value;
112 } /* muse_pfits_get_dpr_catg() */
113 
114 /*----------------------------------------------------------------------------*/
122 /*----------------------------------------------------------------------------*/
123 const char *
124 muse_pfits_get_pro_type(const cpl_propertylist *aHeaders)
125 {
126  cpl_errorstate prestate = cpl_errorstate_get();
127  const char *value = cpl_propertylist_get_string(aHeaders, "ESO PRO TYPE");
128  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
129  return value;
130 } /* muse_pfits_get_pro_type() */
131 
132 /*----------------------------------------------------------------------------*/
140 /*----------------------------------------------------------------------------*/
141 const char *
142 muse_pfits_get_pro_catg(const cpl_propertylist *aHeaders)
143 {
144  cpl_errorstate prestate = cpl_errorstate_get();
145  const char *value = cpl_propertylist_get_string(aHeaders, "ESO PRO CATG");
146  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
147  return value;
148 } /* muse_pfits_get_pro_catg() */
149 
150 /*----------------------------------------------------------------------------*/
162 /*----------------------------------------------------------------------------*/
163 cpl_boolean
164 muse_pfits_has_ifu(const cpl_propertylist *aHeaders, unsigned char aIFU)
165 {
166  cpl_errorstate prestate = cpl_errorstate_get();
167  const char *extname = muse_pfits_get_extname(aHeaders);
168  if (!cpl_errorstate_is_equal(prestate) || /* no EXTNAME */
169  strncmp(extname, "CHAN", 4) || /* doesn't start with CHAN */
170  strlen(extname) < 6) { /* too short */
171  cpl_errorstate_set(prestate); /* ignore the error */
172  return CPL_FALSE;
173  }
174  unsigned char chan = atoi(extname + 4);
175  return chan == aIFU;
176 } /* muse_pfits_has_ifu() */
177 
178 /*----------------------------------------------------------------------------*/
186 /*----------------------------------------------------------------------------*/
187 const char *
188 muse_pfits_get_extname(const cpl_propertylist *aHeaders)
189 {
190  cpl_errorstate prestate = cpl_errorstate_get();
191  const char *value = cpl_propertylist_get_string(aHeaders, "EXTNAME");
192  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
193  return value;
194 } /* muse_pfits_get_extname() */
195 
196 /*----------------------------------------------------------------------------*/
204 /*----------------------------------------------------------------------------*/
205 double
206 muse_pfits_get_ra(const cpl_propertylist *aHeaders)
207 {
208  cpl_errorstate prestate = cpl_errorstate_get();
209  const double value = cpl_propertylist_get_double(aHeaders, "RA");
210  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
211  return value;
212 }
213 
214 /*----------------------------------------------------------------------------*/
222 /*----------------------------------------------------------------------------*/
223 double
224 muse_pfits_get_dec(const cpl_propertylist *aHeaders)
225 {
226  cpl_errorstate prestate = cpl_errorstate_get();
227  const double value = cpl_propertylist_get_double(aHeaders, "DEC");
228  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
229  return value;
230 }
231 
232 /*----------------------------------------------------------------------------*/
240 /*----------------------------------------------------------------------------*/
241 double
242 muse_pfits_get_lst(const cpl_propertylist *aHeaders)
243 {
244  cpl_errorstate prestate = cpl_errorstate_get();
245  const double value = cpl_propertylist_get_double(aHeaders, "LST");
246  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
247  return value;
248 }
249 
250 /*----------------------------------------------------------------------------*/
258 /*----------------------------------------------------------------------------*/
259 const char *
260 muse_pfits_get_dateobs(const cpl_propertylist *aHeaders)
261 {
262  cpl_errorstate prestate = cpl_errorstate_get();
263  const char *value = cpl_propertylist_get_string(aHeaders, "DATE-OBS");
264  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
265  return value;
266 }
267 
268 /*----------------------------------------------------------------------------*/
276 /*----------------------------------------------------------------------------*/
277 double
278 muse_pfits_get_exptime(const cpl_propertylist *aHeaders)
279 {
280  cpl_errorstate prestate = cpl_errorstate_get();
281  const double value = cpl_propertylist_get_double(aHeaders, "EXPTIME");
282  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
283  return value;
284 }
285 
286 /*----------------------------------------------------------------------------*/
294 /*----------------------------------------------------------------------------*/
295 int
296 muse_pfits_get_read_id(const cpl_propertylist *aHeaders)
297 {
298  cpl_errorstate prestate = cpl_errorstate_get();
299  const int value = cpl_propertylist_get_int(aHeaders, "ESO DET READ CURID");
300  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
301  return value;
302 }
303 
304 /*----------------------------------------------------------------------------*/
312 /*----------------------------------------------------------------------------*/
313 const char *
314 muse_pfits_get_read_name(const cpl_propertylist *aHeaders)
315 {
316  cpl_errorstate prestate = cpl_errorstate_get();
317  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DET READ CURNAME");
318  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
319  return value;
320 }
321 
322 /*----------------------------------------------------------------------------*/
330 /*----------------------------------------------------------------------------*/
331 int
332 muse_pfits_get_binx(const cpl_propertylist *aHeaders)
333 {
334  cpl_errorstate prestate = cpl_errorstate_get();
335  const int value = cpl_propertylist_get_int(aHeaders, "ESO DET BINX");
336  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 1);
337  return value;
338 }
339 
340 /*----------------------------------------------------------------------------*/
348 /*----------------------------------------------------------------------------*/
349 int
350 muse_pfits_get_biny(const cpl_propertylist *aHeaders)
351 {
352  cpl_errorstate prestate = cpl_errorstate_get();
353  const int value = cpl_propertylist_get_int(aHeaders, "ESO DET BINY");
354  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 1);
355  return value;
356 }
357 
358 /*----------------------------------------------------------------------------*/
366 /*----------------------------------------------------------------------------*/
367 const char *
368 muse_pfits_get_chip_name(const cpl_propertylist *aHeaders)
369 {
370  cpl_errorstate prestate = cpl_errorstate_get();
371  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DET CHIP NAME");
372  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
373  return value;
374 }
375 
376 /*----------------------------------------------------------------------------*/
384 /*----------------------------------------------------------------------------*/
385 const char *
386 muse_pfits_get_chip_id(const cpl_propertylist *aHeaders)
387 {
388  cpl_errorstate prestate = cpl_errorstate_get();
389  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DET CHIP ID");
390  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
391  return value;
392 }
393 
394 /*----------------------------------------------------------------------------*/
402 /*----------------------------------------------------------------------------*/
403 const char *
404 muse_pfits_get_chip_date(const cpl_propertylist *aHeaders)
405 {
406  cpl_errorstate prestate = cpl_errorstate_get();
407  const char *value = cpl_propertylist_get_string(aHeaders, "ESO DET CHIP DATE");
408  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
409  return value;
410 }
411 
412 /*----------------------------------------------------------------------------*/
421 /*----------------------------------------------------------------------------*/
422 cpl_boolean
423 muse_pfits_get_chip_live(const cpl_propertylist *aHeaders)
424 {
425  cpl_errorstate prestate = cpl_errorstate_get();
426  const cpl_boolean value = cpl_propertylist_get_bool(aHeaders,
427  "ESO DET CHIP LIVE") == 0
428  ? CPL_FALSE : CPL_TRUE;
429  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), CPL_FALSE);
430  return value;
431 }
432 
433 /*----------------------------------------------------------------------------*/
442 /*----------------------------------------------------------------------------*/
443 double
444 muse_pfits_get_ron(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
445 {
446  char keyword[KEYWORD_LENGTH];
447  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d RON", aQuadrant);
448  if (!cpl_propertylist_has(aHeaders, keyword)) {
449  cpl_msg_warning(__func__, "Could not get %s, using RON=1.0",
450  keyword);
451  return 1.0;
452  }
453  return cpl_propertylist_get_double(aHeaders, keyword);
454 }
455 
456 /*----------------------------------------------------------------------------*/
468 /*----------------------------------------------------------------------------*/
469 double
470 muse_pfits_get_gain(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
471 {
472  char keyword[KEYWORD_LENGTH];
473  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d GAIN", aQuadrant);
474  return cpl_propertylist_get_double(aHeaders, keyword);
475 } /* muse_pfits_get_gain() */
476 
477 /*----------------------------------------------------------------------------*/
486 /*----------------------------------------------------------------------------*/
487 int
488 muse_pfits_get_out_output_x(const cpl_propertylist *aHeaders,
489  unsigned char aQuadrant)
490 {
491  cpl_errorstate prestate = cpl_errorstate_get();
492  char keyword[KEYWORD_LENGTH];
493  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d X", aQuadrant);
494  const int value = cpl_propertylist_get_int(aHeaders, keyword);
495  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
496  return value;
497 }
498 
499 /*----------------------------------------------------------------------------*/
508 /*----------------------------------------------------------------------------*/
509 int
510 muse_pfits_get_out_output_y(const cpl_propertylist *aHeaders,
511  unsigned char aQuadrant)
512 {
513  cpl_errorstate prestate = cpl_errorstate_get();
514  char keyword[KEYWORD_LENGTH];
515  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d Y", aQuadrant);
516  const int value = cpl_propertylist_get_int(aHeaders, keyword);
517  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
518  return value;
519 }
520 
521 /*----------------------------------------------------------------------------*/
530 /*----------------------------------------------------------------------------*/
531 int
532 muse_pfits_get_out_nx(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
533 {
534  cpl_errorstate prestate = cpl_errorstate_get();
535  char keyword[KEYWORD_LENGTH];
536  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d NX", aQuadrant);
537  const int value = cpl_propertylist_get_int(aHeaders, keyword);
538  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
539  return value;
540 }
541 
542 /*----------------------------------------------------------------------------*/
551 /*----------------------------------------------------------------------------*/
552 int
553 muse_pfits_get_out_ny(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
554 {
555  cpl_errorstate prestate = cpl_errorstate_get();
556  char keyword[KEYWORD_LENGTH];
557  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d NY", aQuadrant);
558  const int value = cpl_propertylist_get_int(aHeaders, keyword);
559  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
560  return value;
561 }
562 
563 /*----------------------------------------------------------------------------*/
572 /*----------------------------------------------------------------------------*/
573 int
574 muse_pfits_get_out_prescan_x(const cpl_propertylist *aHeaders,
575  unsigned char aQuadrant)
576 {
577  cpl_errorstate prestate = cpl_errorstate_get();
578  char keyword[KEYWORD_LENGTH];
579  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d PRSCX", aQuadrant);
580  const int value = cpl_propertylist_get_int(aHeaders, keyword);
581  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
582  return value;
583 }
584 
585 /*----------------------------------------------------------------------------*/
594 /*----------------------------------------------------------------------------*/
595 int
596 muse_pfits_get_out_prescan_y(const cpl_propertylist *aHeaders,
597  unsigned char aQuadrant)
598 {
599  cpl_errorstate prestate = cpl_errorstate_get();
600  char keyword[KEYWORD_LENGTH];
601  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d PRSCY", aQuadrant);
602  const int value = cpl_propertylist_get_int(aHeaders, keyword);
603  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
604  return value;
605 }
606 
607 /*----------------------------------------------------------------------------*/
616 /*----------------------------------------------------------------------------*/
617 int
618 muse_pfits_get_out_overscan_x(const cpl_propertylist *aHeaders,
619  unsigned char aQuadrant)
620 {
621  cpl_errorstate prestate = cpl_errorstate_get();
622  char keyword[KEYWORD_LENGTH];
623  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d OVSCX", aQuadrant);
624  const int value = cpl_propertylist_get_int(aHeaders, keyword);
625  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
626  return value;
627 }
628 
629 /*----------------------------------------------------------------------------*/
638 /*----------------------------------------------------------------------------*/
639 int
640 muse_pfits_get_out_overscan_y(const cpl_propertylist *aHeaders,
641  unsigned char aQuadrant)
642 {
643  cpl_errorstate prestate = cpl_errorstate_get();
644  char keyword[KEYWORD_LENGTH];
645  snprintf(keyword, KEYWORD_LENGTH, "ESO DET OUT%d OVSCY", aQuadrant);
646  const int value = cpl_propertylist_get_int(aHeaders, keyword);
647  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), -1);
648  return value;
649 }
650 
651 /*----------------------------------------------------------------------------*/
664 /*----------------------------------------------------------------------------*/
665 double
666 muse_pfits_get_geolat(const cpl_propertylist *aHeaders)
667 {
668  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL GEOLAT");
669  if (fabs(value) < DBL_EPSILON) {
670  return -24.625278;
671  }
672  return value;
673 }
674 
675 /*----------------------------------------------------------------------------*/
688 /*----------------------------------------------------------------------------*/
689 double
690 muse_pfits_get_geolon(const cpl_propertylist *aHeaders)
691 {
692  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL GEOLON");
693  if (fabs(value) < DBL_EPSILON) {
694  return 70.402222;
695  }
696  return value;
697 }
698 
699 /*----------------------------------------------------------------------------*/
711 /*----------------------------------------------------------------------------*/
712 double
713 muse_pfits_get_focu_scale(const cpl_propertylist *aHeaders)
714 {
715  double value = 1.705;
716  if (aHeaders && cpl_propertylist_has(aHeaders, "ESO TEL FOCU SCALE")) {
717  value = cpl_propertylist_get_double(aHeaders, "ESO TEL FOCU SCALE");
718  }
719  return value;
720 }
721 
722 /*----------------------------------------------------------------------------*/
730 /*----------------------------------------------------------------------------*/
731 double
732 muse_pfits_get_airmass_start(const cpl_propertylist *aHeaders)
733 {
734  cpl_errorstate prestate = cpl_errorstate_get();
735  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AIRM START");
736  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
737  return value;
738 }
739 
740 /*----------------------------------------------------------------------------*/
748 /*----------------------------------------------------------------------------*/
749 double
750 muse_pfits_get_airmass_end(const cpl_propertylist *aHeaders)
751 {
752  cpl_errorstate prestate = cpl_errorstate_get();
753  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AIRM END");
754  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
755  return value;
756 }
757 
758 /*----------------------------------------------------------------------------*/
766 /*----------------------------------------------------------------------------*/
767 double
768 muse_pfits_get_temp(const cpl_propertylist *aHeaders)
769 {
770  cpl_errorstate prestate = cpl_errorstate_get();
771  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI TEMP");
772  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
773  return value;
774 }
775 
776 /*----------------------------------------------------------------------------*/
784 /*----------------------------------------------------------------------------*/
785 double
786 muse_pfits_get_rhum(const cpl_propertylist *aHeaders)
787 {
788  cpl_errorstate prestate = cpl_errorstate_get();
789  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI RHUM");
790  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
791  return value;
792 }
793 
794 /*----------------------------------------------------------------------------*/
802 /*----------------------------------------------------------------------------*/
803 double
804 muse_pfits_get_pres_start(const cpl_propertylist *aHeaders)
805 {
806  cpl_errorstate prestate = cpl_errorstate_get();
807  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI PRES START");
808  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
809  return value;
810 }
811 
812 /*----------------------------------------------------------------------------*/
820 /*----------------------------------------------------------------------------*/
821 double
822 muse_pfits_get_pres_end(const cpl_propertylist *aHeaders)
823 {
824  cpl_errorstate prestate = cpl_errorstate_get();
825  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI PRES END");
826  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
827  return value;
828 }
829 
830 /*----------------------------------------------------------------------------*/
838 /*----------------------------------------------------------------------------*/
839 double
840 muse_pfits_get_fwhm_start(const cpl_propertylist *aHeaders)
841 {
842  cpl_errorstate prestate = cpl_errorstate_get();
843  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI FWHM START");
844  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
845  return value;
846 }
847 
848 /*----------------------------------------------------------------------------*/
856 /*----------------------------------------------------------------------------*/
857 double
858 muse_pfits_get_fwhm_end(const cpl_propertylist *aHeaders)
859 {
860  cpl_errorstate prestate = cpl_errorstate_get();
861  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL AMBI FWHM END");
862  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
863  return value;
864 }
865 
866 /*----------------------------------------------------------------------------*/
874 /*----------------------------------------------------------------------------*/
875 double
876 muse_pfits_get_altang(const cpl_propertylist *aHeaders)
877 {
878  cpl_errorstate prestate = cpl_errorstate_get();
879  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL ALT");
880  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
881  return value;
882 }
883 
884 /*----------------------------------------------------------------------------*/
892 /*----------------------------------------------------------------------------*/
893 double
894 muse_pfits_get_parang_start(const cpl_propertylist *aHeaders)
895 {
896  cpl_errorstate prestate = cpl_errorstate_get();
897  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL PARANG START");
898  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
899  return value;
900 }
901 
902 /*----------------------------------------------------------------------------*/
910 /*----------------------------------------------------------------------------*/
911 double
912 muse_pfits_get_parang_end(const cpl_propertylist *aHeaders)
913 {
914  cpl_errorstate prestate = cpl_errorstate_get();
915  const double value = cpl_propertylist_get_double(aHeaders, "ESO TEL PARANG END");
916  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
917  return value;
918 }
919 
920 /*----------------------------------------------------------------------------*/
928 /*----------------------------------------------------------------------------*/
929 const char *
930 muse_pfits_get_drot_mode(const cpl_propertylist *aHeaders)
931 {
932  cpl_errorstate prestate = cpl_errorstate_get();
933  const char *value = cpl_propertylist_get_string(aHeaders, "ESO INS DROT MODE");
934  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
935  return value;
936 }
937 
938 /*----------------------------------------------------------------------------*/
946 /*----------------------------------------------------------------------------*/
947 double
948 muse_pfits_get_drot_posang(const cpl_propertylist *aHeaders)
949 {
950  cpl_errorstate prestate = cpl_errorstate_get();
951  const double value = cpl_propertylist_get_double(aHeaders, "ESO INS DROT POSANG");
952  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
953  return value;
954 }
955 
956 /*----------------------------------------------------------------------------*/
964 /*----------------------------------------------------------------------------*/
965 double
966 muse_pfits_get_drot_start(const cpl_propertylist *aHeaders)
967 {
968  cpl_errorstate prestate = cpl_errorstate_get();
969  const double value = cpl_propertylist_get_double(aHeaders, "ESO INS DROT START");
970  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
971  return value;
972 }
973 
974 /*----------------------------------------------------------------------------*/
982 /*----------------------------------------------------------------------------*/
983 double
984 muse_pfits_get_drot_end(const cpl_propertylist *aHeaders)
985 {
986  cpl_errorstate prestate = cpl_errorstate_get();
987  const double value = cpl_propertylist_get_double(aHeaders, "ESO INS DROT END");
988  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
989  return value;
990 }
991 
992 /*----------------------------------------------------------------------------*/
1001 /*----------------------------------------------------------------------------*/
1002 muse_ins_mode
1003 muse_pfits_get_mode(const cpl_propertylist *aHeaders)
1004 {
1005  cpl_errorstate prestate = cpl_errorstate_get();
1006  const char *value = cpl_propertylist_get_string(aHeaders, "ESO INS MODE");
1007  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(),
1008  MUSE_MODE_WFM_NONAO_N);
1009  if (!strncmp(value, "NFM", 3)) {
1010  return MUSE_MODE_NFM_AO_N;
1011  }
1012  if (!strncmp(value, "WFM-AO", 6)) {
1013  return MUSE_MODE_WFM_AO_N;
1014  }
1015  if (!strncmp(value, "WFM-NOAO-N", 10) || !strncmp(value, "WFM-NONAO-N", 11)) {
1016  return MUSE_MODE_WFM_NONAO_N;
1017  }
1018  return MUSE_MODE_WFM_NONAO_X;
1019 }
1020 
1021 /*----------------------------------------------------------------------------*/
1037 /*----------------------------------------------------------------------------*/
1038 double
1039 muse_pfits_get_pam_intensity(const cpl_propertylist *aHeaders, int aDiode)
1040 {
1041  cpl_errorstate prestate = cpl_errorstate_get();
1042  char keyword[KEYWORD_LENGTH];
1043  snprintf(keyword, KEYWORD_LENGTH, "ESO INS AMPL%d CURR", aDiode);
1044  double value = cpl_propertylist_get_double(aHeaders, keyword);
1045  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1046  const char *comment = cpl_propertylist_get_comment(aHeaders, keyword);
1047  cpl_boolean ismilliampere = comment && strstr(comment, "[mA]")
1048  ? CPL_TRUE : CPL_FALSE;
1049  if (!ismilliampere) {
1050  cpl_error_set_message(__func__, CPL_ERROR_INCOMPATIBLE_INPUT,
1051  "Could not ensure that %s is in mA!", keyword);
1052  } else {
1053  value /= 1000.; /* convert from mA to A */
1054  }
1055  return value;
1056 }
1057 
1058 /*----------------------------------------------------------------------------*/
1067 /*----------------------------------------------------------------------------*/
1068 double
1069 muse_pfits_get_pam_stdev(const cpl_propertylist *aHeaders, int aDiode)
1070 {
1071  cpl_errorstate prestate = cpl_errorstate_get();
1072  char keyword[KEYWORD_LENGTH];
1073  snprintf(keyword, KEYWORD_LENGTH, "ESO INS AMPL%d STDEV", aDiode);
1074  const double value = cpl_propertylist_get_double(aHeaders, keyword);
1075  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1076  return value;
1077 }
1078 
1079 /*----------------------------------------------------------------------------*/
1087 /*----------------------------------------------------------------------------*/
1088 const char *
1089 muse_pfits_get_pam2_filter(const cpl_propertylist *aHeaders)
1090 {
1091  cpl_errorstate prestate = cpl_errorstate_get();
1092  const char *value = cpl_propertylist_get_string(aHeaders,
1093  "ESO INS AMPL2 FILTER");
1094  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1095  return value;
1096 }
1097 
1098 /*----------------------------------------------------------------------------*/
1111 /*----------------------------------------------------------------------------*/
1112 int
1113 muse_pfits_get_lampnum(const cpl_propertylist *aHeaders)
1114 {
1115  cpl_errorstate prestate = cpl_errorstate_get();
1116  const int value = cpl_propertylist_get_int(aHeaders, "ESO INS LAMPNUM");
1117  if (!cpl_errorstate_is_equal(prestate)) {
1118  /* header keyword not present (old data of some sort?!) */
1119  cpl_errorstate_set(prestate); /* be backward-compatible */
1120  return 6; /* return the default */
1121  }
1122  return value;
1123 }
1124 
1125 /*----------------------------------------------------------------------------*/
1134 /*----------------------------------------------------------------------------*/
1135 const char *
1136 muse_pfits_get_lamp_name(const cpl_propertylist *aHeaders, int aLamp)
1137 {
1138  cpl_errorstate prestate = cpl_errorstate_get();
1139  char keyword[KEYWORD_LENGTH];
1140  snprintf(keyword, KEYWORD_LENGTH, "ESO INS LAMP%d NAME", aLamp);
1141  const char *value = cpl_propertylist_get_string(aHeaders, keyword);
1142  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1143  return value;
1144 }
1145 
1146 /*----------------------------------------------------------------------------*/
1155 /*----------------------------------------------------------------------------*/
1156 int
1157 muse_pfits_get_lamp_status(const cpl_propertylist *aHeaders, int aLamp)
1158 {
1159  cpl_errorstate prestate = cpl_errorstate_get();
1160  char keyword[KEYWORD_LENGTH];
1161  snprintf(keyword, KEYWORD_LENGTH, "ESO INS LAMP%d ST", aLamp);
1162  const int value = cpl_propertylist_get_bool(aHeaders, keyword);
1163  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
1164  return value;
1165 }
1166 
1167 /*----------------------------------------------------------------------------*/
1176 /*----------------------------------------------------------------------------*/
1177 const char *
1178 muse_pfits_get_shut_name(const cpl_propertylist *aHeaders, int aShutter)
1179 {
1180  cpl_errorstate prestate = cpl_errorstate_get();
1181  char keyword[KEYWORD_LENGTH];
1182  snprintf(keyword, KEYWORD_LENGTH, "ESO INS SHUT%d NAME", aShutter);
1183  const char *value = cpl_propertylist_get_string(aHeaders, keyword);
1184  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), NULL);
1185  return value;
1186 }
1187 
1188 /*----------------------------------------------------------------------------*/
1197 /*----------------------------------------------------------------------------*/
1198 int
1199 muse_pfits_get_shut_status(const cpl_propertylist *aHeaders, int aShutter)
1200 {
1201  cpl_errorstate prestate = cpl_errorstate_get();
1202  char keyword[KEYWORD_LENGTH];
1203  snprintf(keyword, KEYWORD_LENGTH, "ESO INS SHUT%d ST", aShutter);
1204  const int value = cpl_propertylist_get_bool(aHeaders, keyword);
1205  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
1206  return value;
1207 }
1208 
1209 /*----------------------------------------------------------------------------*/
1220 /*----------------------------------------------------------------------------*/
1221 int
1222 muse_pfits_get_posenc(const cpl_propertylist *aHeaders, unsigned short aEncoder)
1223 {
1224  cpl_errorstate prestate = cpl_errorstate_get();
1225  char keyword[KEYWORD_LENGTH];
1226  snprintf(keyword, KEYWORD_LENGTH, "ESO INS POS%d ENC", aEncoder);
1227  const int value = cpl_propertylist_get_int(aHeaders, keyword);
1228  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0);
1229  return value;
1230 }
1231 
1232 /*----------------------------------------------------------------------------*/
1249 /*----------------------------------------------------------------------------*/
1250 double
1251 muse_pfits_get_pospos(const cpl_propertylist *aHeaders, unsigned short aEncoder)
1252 {
1253  cpl_errorstate prestate = cpl_errorstate_get();
1254  char keyword[KEYWORD_LENGTH];
1255  snprintf(keyword, KEYWORD_LENGTH, "ESO INS POS%d POS", aEncoder);
1256  const double value = cpl_propertylist_get_double(aHeaders, keyword);
1257  cpl_ensure(cpl_errorstate_is_equal(prestate), cpl_error_get_code(), 0.0);
1258  return value;
1259 }
1260 
const char * muse_pfits_get_dpr_type(const cpl_propertylist *aHeaders)
find out the DPR type
Definition: muse_pfits.c:88
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:164
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:640
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:510
cpl_boolean muse_pfits_get_chip_live(const cpl_propertylist *aHeaders)
find out if the CCD was active (live)
Definition: muse_pfits.c:423
const char * muse_pfits_get_extname(const cpl_propertylist *aHeaders)
find out the extension name
Definition: muse_pfits.c:188
int muse_pfits_get_read_id(const cpl_propertylist *aHeaders)
find out the readout mode id
Definition: muse_pfits.c:296
const char * muse_pfits_get_dpr_catg(const cpl_propertylist *aHeaders)
find out the DPR category
Definition: muse_pfits.c:106
double muse_pfits_get_rhum(const cpl_propertylist *aHeaders)
find out the relavtive humidity (in %)
Definition: muse_pfits.c:786
double muse_pfits_get_ra(const cpl_propertylist *aHeaders)
find out the right ascension
Definition: muse_pfits.c:206
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:470
int muse_pfits_get_shut_status(const cpl_propertylist *aHeaders, int aShutter)
query the status of one shutter
Definition: muse_pfits.c:1199
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:618
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:876
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:488
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:804
double muse_pfits_get_airmass_start(const cpl_propertylist *aHeaders)
find out the airmass at start of exposure
Definition: muse_pfits.c:732
const char * muse_pfits_get_dateobs(const cpl_propertylist *aHeaders)
find out the exposure time
Definition: muse_pfits.c:260
double muse_pfits_get_focu_scale(const cpl_propertylist *aHeaders)
find out the scale in the VLT focal plane
Definition: muse_pfits.c:713
const char * muse_pfits_get_shut_name(const cpl_propertylist *aHeaders, int aShutter)
query the name of one shutter
Definition: muse_pfits.c:1178
int muse_pfits_get_lampnum(const cpl_propertylist *aHeaders)
query the number of lamps installed
Definition: muse_pfits.c:1113
double muse_pfits_get_drot_posang(const cpl_propertylist *aHeaders)
find out the MUSE derotator position angle (in degrees)
Definition: muse_pfits.c:948
const char * muse_pfits_get_chip_date(const cpl_propertylist *aHeaders)
find out the chip installation date
Definition: muse_pfits.c:404
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:1089
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:858
int muse_pfits_get_biny(const cpl_propertylist *aHeaders)
find out the binning factor in y direction
Definition: muse_pfits.c:350
double muse_pfits_get_geolat(const cpl_propertylist *aHeaders)
find out the telescope's latitude
Definition: muse_pfits.c:666
const char * muse_pfits_get_lamp_name(const cpl_propertylist *aHeaders, int aLamp)
query the name of one lamp
Definition: muse_pfits.c:1136
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:1039
const char * muse_pfits_get_pipefile(const cpl_propertylist *aHeaders)
find out the pipefile
Definition: muse_pfits.c:71
const char * muse_pfits_get_drot_mode(const cpl_propertylist *aHeaders)
find out the MUSE derotator mode
Definition: muse_pfits.c:930
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:596
int muse_pfits_get_out_nx(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the horizontal size of the data region of one quadrant
Definition: muse_pfits.c:532
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:444
const char * muse_pfits_get_read_name(const cpl_propertylist *aHeaders)
find out the readout mode name
Definition: muse_pfits.c:314
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:1069
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:984
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:840
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:966
double muse_pfits_get_dec(const cpl_propertylist *aHeaders)
find out the declination
Definition: muse_pfits.c:224
int muse_pfits_get_posenc(const cpl_propertylist *aHeaders, unsigned short aEncoder)
query the absolute encoder position of one encoder
Definition: muse_pfits.c:1222
const char * muse_pfits_get_chip_id(const cpl_propertylist *aHeaders)
find out the chip id
Definition: muse_pfits.c:386
int muse_pfits_get_binx(const cpl_propertylist *aHeaders)
find out the binning factor in x direction
Definition: muse_pfits.c:332
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:894
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:822
double muse_pfits_get_airmass_end(const cpl_propertylist *aHeaders)
find out the airmass at end of exposure
Definition: muse_pfits.c:750
int muse_pfits_get_lamp_status(const cpl_propertylist *aHeaders, int aLamp)
query the status of one lamp
Definition: muse_pfits.c:1157
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:1251
const char * muse_pfits_get_pro_type(const cpl_propertylist *aHeaders)
find out the PRO type
Definition: muse_pfits.c:124
double muse_pfits_get_exptime(const cpl_propertylist *aHeaders)
find out the exposure time
Definition: muse_pfits.c:278
const char * muse_pfits_get_pro_catg(const cpl_propertylist *aHeaders)
find out the PRO category
Definition: muse_pfits.c:142
double muse_pfits_get_temp(const cpl_propertylist *aHeaders)
find out the ambient temperature (in degrees Celsius)
Definition: muse_pfits.c:768
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:574
double muse_pfits_get_lst(const cpl_propertylist *aHeaders)
find out the local siderial time
Definition: muse_pfits.c:242
int muse_pfits_get_out_ny(const cpl_propertylist *aHeaders, unsigned char aQuadrant)
find out the vertical size of the data region of one quadrant
Definition: muse_pfits.c:553
const char * muse_pfits_get_chip_name(const cpl_propertylist *aHeaders)
find out the chip name
Definition: muse_pfits.c:368
double muse_pfits_get_geolon(const cpl_propertylist *aHeaders)
find out the telescope's longitude
Definition: muse_pfits.c:690
muse_ins_mode muse_pfits_get_mode(const cpl_propertylist *aHeaders)
find out the observation mode
Definition: muse_pfits.c:1003
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:912