SINFONI Pipeline Reference Manual  2.5.2
sinfo_pfits.c
1 /* $Id: sinfo_pfits.c,v 1.14 2012-05-04 08:11:07 amodigli Exp $
2  *
3  * This file is part of the SINFONI Pipeline
4  * Copyright (C) 2002,2003 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: amodigli $
23  * $Date: 2012-05-04 08:11:07 $
24  * $Revision: 1.14 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 # include <config.h>
30 #endif
31 /*----------------------------------------------------------------------------
32  Includes
33  ----------------------------------------------------------------------------*/
34 #include <ctype.h>
35 #include <cpl.h>
36 #include "sinfo_pfits.h"
37 #include "sinfo_key_names.h"
38 #include "sinfo_utils_wrappers.h"
39 #include "sinfo_msg.h"
40 #include <string.h>
41 
42 /*---------------------------------------------------------------------------*/
43 #define ASCIILINESZ 1024
44 #define PAF_MAGIC_SZ 13
45 #define PAF_MAGIC "PAF.HDR.START"
46 
47 /*-----------------------------------------------------------------------------
48  Function codes
49  ----------------------------------------------------------------------------*/
50 char * sinfo_paf_query(
51  char * filename,
52  char * key) ;
53 
54 static int sinfo_is_paf_file(char * filename) ;
55 
56 static char * sinfo_strcrop(char * s);
57 
58 
67 /*---------------------------------------------------------------------------*/
80 /*---------------------------------------------------------------------------*/
81 static char * sinfo_strcrop(char * s)
82 {
83  static char l[ASCIILINESZ+1];
84  char * last ;
85 
86  if (s==NULL) return NULL ;
87  memset(l, 0, ASCIILINESZ+1);
88  strcpy(l, s);
89  last = l + strlen(l);
90  while (last > l) {
91  if (!isspace((int)*(last-1)))
92  break ;
93  last -- ;
94  }
95  *last = (char)0;
96  return l ;
97 }
98 
99 
100 /*---------------------------------------------------------------------------*/
113 /*---------------------------------------------------------------------------*/
114 char * sinfo_paf_query(
115  char * filename,
116  char * key)
117 {
118  static char value[ASCIILINESZ];
119  FILE * paf ;
120  char line[ASCIILINESZ+1];
121  char val[ASCIILINESZ+1];
122  char head[ASCIILINESZ+1];
123  int found ;
124  int len ;
125 
126  /* Check inputs */
127  if (filename==NULL || key==NULL) return NULL ;
128 
129  /* Check PAF validity */
130  if (sinfo_is_paf_file(filename)!=1) {
131  sinfo_msg_error("not a PAF file: [%s]", filename);
132  return NULL ;
133  }
134 
135  /* Open file and read it */
136  paf = fopen(filename, "r");
137  if (paf==NULL) {
138  sinfo_msg_error("opening [%s]", filename);
139  return NULL ;
140  }
141 
142  found = 0 ;
143  while (fgets(line, ASCIILINESZ, paf)!=NULL) {
144  sscanf(line, "%[^ ]", head);
145  if (!strcmp(head, key)) {
146  /* Get value */
147  sscanf(line, "%*[^ ] %[^;]", value);
148  found ++ ;
149  break ;
150  }
151  }
152  if (!found) {
153  fclose(paf);
154  return NULL ;
155  }
156 
157  /* Remove trailing blanks */
158  strcpy(val, sinfo_strcrop(value));
159  /* Get rid of possible quotes */
160  len = strlen(val);
161  if (val[0]=='\"' && val[len-1]=='\"') {
162  strncpy(value, val+1, len-2);
163  value[len-2]=(char)0;
164  } else {
165  strcpy(value, val);
166  }
167  if(paf!=NULL){
168  fclose(paf);
169  }
170  return value ;
171 }
172 
173 /*---------------------------------------------------------------------------*/
182 /*---------------------------------------------------------------------------*/
183 static int sinfo_is_paf_file(char * filename)
184 {
185  FILE * fp ;
186  int is_paf ;
187  char line[ASCIILINESZ] ;
188 
189  if (filename==NULL) return -1 ;
190 
191  /* Initialize is_paf */
192  is_paf = 0 ;
193 
194  /* Open file */
195  if ((fp = fopen(filename, "r"))==NULL) {
196  sinfo_msg_error("cannot open file [%s]", filename) ;
197  return -1 ;
198  }
199 
200  /* Parse file */
201  while (fgets(line, ASCIILINESZ, fp) != NULL) {
202  if (line[0] != '#') {
203  if (!strncmp(line, PAF_MAGIC, PAF_MAGIC_SZ)) is_paf = 1 ;
204  (void)fclose(fp) ;
205  return is_paf ;
206  }
207  }
208 
209  (void)fclose(fp) ;
210  return is_paf ;
211 }
212 
213 /*---------------------------------------------------------------------------*/
219 /*---------------------------------------------------------------------------*/
220 char * sinfo_pfits_get_mode(const cpl_propertylist * plist)
221 {
222 
223  return (char*) cpl_propertylist_get_string(plist,"ESO DET MODE NAME");
224 
225 }
226 
227 /*---------------------------------------------------------------------------*/
233 /*---------------------------------------------------------------------------*/
234 double sinfo_pfits_get_exp_time(const cpl_propertylist* plist)
235 {
236 
237  return cpl_propertylist_get_double(plist,"EXPTIME");
238 
239 }
240 
241 
242 
243 
244 
245 /*----------------------------------------------------------------------------
246  Function : sinfo_pfits_get_ditndit()
247  In : fits file name
248  Out : total integration time in sec
249  Job : reads the product dit*ndit from the FITS-header
250  ---------------------------------------------------------------------------*/
251 double sinfo_pfits_get_ditndit(const char* name)
252 {
253  double dit;
254  int ndit=0;
255  cpl_propertylist* plist=NULL;
256  plist=cpl_propertylist_load(name,0);
257 
258  dit = cpl_propertylist_get_double(plist,"ESO DET DIT");
259  ndit = cpl_propertylist_get_int(plist,"ESO DET NDIT");
260  sinfo_free_propertylist(&plist);
261  return dit*ndit ;
262 
263 }
264 
265 
266 /*---------------------------------------------------------------------------*/
272 /*---------------------------------------------------------------------------*/
273 double sinfo_pfits_get_exptime(const char * filename)
274 {
275  double exptime ;
276  cpl_propertylist* plist=NULL;
277  plist=cpl_propertylist_load(filename,0);
278  exptime = cpl_propertylist_get_double(plist,"EXPTIME");
279  sinfo_free_propertylist(&plist);
280 
281  return exptime;
282 }
283 
284 
285 
286 
287 /*---------------------------------------------------------------------------*/
293 /*---------------------------------------------------------------------------*/
294 int sinfo_pfits_get_rom(const cpl_propertylist * plist)
295 {
296 
297  return cpl_propertylist_get_int(plist,"ESO DET NCORRS");
298 
299 }
300 
301 /*---------------------------------------------------------------------------*/
307 /*---------------------------------------------------------------------------*/
308 int sinfo_pfits_get_expno(const cpl_propertylist * plist)
309 {
310 
311  return cpl_propertylist_get_int(plist,"ESO TPL EXPNO");
312 
313 }
314 
315 
316 /*---------------------------------------------------------------------------*/
322 /*---------------------------------------------------------------------------*/
323 double sinfo_pfits_get_airmass_start(const cpl_propertylist * plist)
324 {
325 
326  return cpl_propertylist_get_double(plist,"ESO TEL AIRM START");
327 
328 }
329 
330 /*---------------------------------------------------------------------------*/
336 /*---------------------------------------------------------------------------*/
337 double sinfo_pfits_get_airmass_end(const cpl_propertylist * plist)
338 {
339  return cpl_propertylist_get_double(plist,"ESO TEL AIRM END");
340 
341 }
342 
343 /*---------------------------------------------------------------------------*/
349 /*---------------------------------------------------------------------------*/
350 double sinfo_pfits_get_alpha(const cpl_propertylist * plist)
351 {
352  return cpl_propertylist_get_double(plist,"ESO TEL TARG OFFSETALPHA");
353 }
354 
355 /*---------------------------------------------------------------------------*/
361 /*---------------------------------------------------------------------------*/
362 double sinfo_pfits_get_targ_alpha(const cpl_propertylist * plist)
363 {
364  return cpl_propertylist_get_double(plist,"ESO INS TARG ALPHA");
365 }
366 
367 
368 /*---------------------------------------------------------------------------*/
374 /*---------------------------------------------------------------------------*/
375 double sinfo_pfits_get_targ_delta(const cpl_propertylist * plist)
376 {
377  return cpl_propertylist_get_double(plist,"ESO INS TARG DELTA");
378 }
379 
380 /*---------------------------------------------------------------------------*/
386 /*---------------------------------------------------------------------------*/
387 const char * sinfo_pfits_get_arcfile(const cpl_propertylist * plist)
388 {
389  return (const char*) cpl_propertylist_get_string(plist,KEY_NAME_ARCFILE);
390 }
391 
392 /*---------------------------------------------------------------------------*/
398 /*---------------------------------------------------------------------------*/
399 const char * sinfo_pfits_get_rec1raw1name(const cpl_propertylist * plist)
400 {
401  return (const char*) cpl_propertylist_get_string(plist,
402  KEY_NAME_PRO_REC1_RAW1_NAME);
403 }
404 
405 /*---------------------------------------------------------------------------*/
411 /*---------------------------------------------------------------------------*/
412 const char * sinfo_pfits_get_ins_setup(const cpl_propertylist * plist)
413 {
414  if(cpl_propertylist_get_string(plist,"ESO INS SETUP ID")) {
415  return (const char*) cpl_propertylist_get_string(plist,"ESO INS SETUP ID");
416  } else {
417  cpl_error_reset();
418  return "Dark";
419  }
420 
421 }
422 
423 
424 
425 /*---------------------------------------------------------------------------*/
431 /*---------------------------------------------------------------------------*/
432 double sinfo_pfits_get_wlen(const cpl_propertylist * plist)
433 {
434 
435  return cpl_propertylist_get_double(plist,"ESO INS GRAT1 WLEN");
436 }
437 
438 /*---------------------------------------------------------------------------*/
444 /*---------------------------------------------------------------------------*/
445 int sinfo_pfits_get_chop_ncycles(const cpl_propertylist * plist)
446 {
447 
448  return cpl_propertylist_get_int(plist,"ESO DET CHOP NCYCLES");
449 
450 }
451 
452 /*---------------------------------------------------------------------------*/
458 /*---------------------------------------------------------------------------*/
459 double sinfo_pfits_get_pixscale(const cpl_propertylist * plist)
460 {
461  const char* val=NULL;
462  val=cpl_propertylist_get_string(plist,"ESO INS OPTI1 NAME");
463  return atof(val);
464 }
465 
466 /*---------------------------------------------------------------------------*/
472 /*---------------------------------------------------------------------------*/
473 double sinfo_pfits_get_posangle(const cpl_propertylist * plist)
474 {
475  return cpl_propertylist_get_double(plist,"ESO ADA POSANG");
476 }
477 
478 /*---------------------------------------------------------------------------*/
484 /*---------------------------------------------------------------------------*/
485 double sinfo_pfits_get_DEC(const cpl_propertylist * plist)
486 {
487  return cpl_propertylist_get_double(plist,"DEC");
488 }
489 
490 
491 /*---------------------------------------------------------------------------*/
497 /*---------------------------------------------------------------------------*/
498 double sinfo_pfits_get_cumoffsetx(const cpl_propertylist * plist)
499 {
500  return cpl_propertylist_get_double(plist,"ESO SEQ CUMOFFSETX");
501 }
502 
503 /*---------------------------------------------------------------------------*/
509 /*---------------------------------------------------------------------------*/
510 double sinfo_pfits_get_cumoffsety(const cpl_propertylist * plist)
511 {
512  return cpl_propertylist_get_double(plist,"ESO SEQ CUMOFFSETY");
513 }
514 
515 /*---------------------------------------------------------------------------*/
521 /*---------------------------------------------------------------------------*/
522 const char * sinfo_pfits_get_date_obs(const cpl_propertylist * plist)
523 {
524 
525  return (const char*) cpl_propertylist_get_string(plist,"DATE-OBS");
526 
527 }
528 
529 /*---------------------------------------------------------------------------*/
535 /*---------------------------------------------------------------------------*/
536 double sinfo_pfits_get_delta(const cpl_propertylist * plist)
537 {
538 
539  return cpl_propertylist_get_double(plist,"ESO TEL TARG OFFSETDELTA");
540 
541 }
542 
543 /*---------------------------------------------------------------------------*/
549 /*---------------------------------------------------------------------------*/
550 double sinfo_pfits_get_dec(const cpl_propertylist * plist)
551 {
552  return cpl_propertylist_get_double(plist,"DEC");
553 }
554 
555 /*---------------------------------------------------------------------------*/
562 /*---------------------------------------------------------------------------*/
563 double sinfo_pfits_get_dit(const cpl_propertylist * plist)
564 {
565  return cpl_propertylist_get_double(plist,"ESO DET DIT");
566 }
567 /*---------------------------------------------------------------------------*/
573 /*---------------------------------------------------------------------------*/
574 float sinfo_pfits_get_pixelscale(const char * name)
575 {
576  cpl_propertylist* plist=NULL;
577  float pixscale=0;
578  const char* scale=NULL;
579  plist=cpl_propertylist_load(name,0);
580  scale= cpl_propertylist_get_string(plist,"ESO INS OPTI1 NAME");
581  pixscale=atof(scale);
582  sinfo_free_propertylist(&plist);
583  return pixscale;
584 }
585 
586 
587 /*---------------------------------------------------------------------------*/
594 /*---------------------------------------------------------------------------*/
595 const char * sinfo_pfits_get_ncorrs_name(const cpl_propertylist * plist)
596 {
597  return cpl_propertylist_get_string(plist,"ESO DET NCORRS NAME");
598 }
599 
600 
601 /*---------------------------------------------------------------------------*/
608 /*---------------------------------------------------------------------------*/
609 const char * sinfo_pfits_get_band(const cpl_propertylist * plist)
610 {
611  return cpl_propertylist_get_string(plist,"ESO INS FILT1 NAME");
612 }
613 
614 /*---------------------------------------------------------------------------*/
620 /*---------------------------------------------------------------------------*/
621 const char * sinfo_pfits_get_dpr_catg(const cpl_propertylist * plist)
622 {
623  return cpl_propertylist_get_string(plist,"ESO DPR CATG");
624 }
625 
626 /*---------------------------------------------------------------------------*/
632 /*---------------------------------------------------------------------------*/
633 const char * sinfo_pfits_get_dpr_tech(const cpl_propertylist * plist)
634 {
635  return cpl_propertylist_get_string(plist,"ESO DPR TECH");
636 }
637 
638 /*---------------------------------------------------------------------------*/
644 /*---------------------------------------------------------------------------*/
645 const char * sinfo_pfits_get_dpr_type(const cpl_propertylist * plist)
646 {
647  return cpl_propertylist_get_string(plist,"ESO DPR TYPE");
648 }
649 
650 
651 /*---------------------------------------------------------------------------*/
657 /*---------------------------------------------------------------------------*/
658 const char * sinfo_pfits_get_filter_im(const cpl_propertylist * plist)
659 {
660  return cpl_propertylist_get_string(plist,"ESO INS FILT1 NAME");
661 }
662 
663 /*---------------------------------------------------------------------------*/
669 /*---------------------------------------------------------------------------*/
670 const char * sinfo_pfits_get_filter_spec(const cpl_propertylist * plist)
671 {
672  return cpl_propertylist_get_string(plist,"ESO INS FILT2 NAME");
673 }
674 
675 /*---------------------------------------------------------------------------*/
681 /*---------------------------------------------------------------------------*/
682 double sinfo_pfits_get_focus(const cpl_propertylist * plist)
683 {
684  return cpl_propertylist_get_double(plist,"ESO TEL FOCU LEN");
685 }
686 
687 
688 /*---------------------------------------------------------------------------*/
694 /*---------------------------------------------------------------------------*/
695 const char * sinfo_pfits_get_frame_type(const cpl_propertylist * plist)
696 {
697  return cpl_propertylist_get_string(plist,"ESO DET FRAM TYPE");
698 }
699 
700 /*---------------------------------------------------------------------------*/
706 /*---------------------------------------------------------------------------*/
707 const char * sinfo_pfits_get_instrument(const cpl_propertylist * plist)
708 {
709  return cpl_propertylist_get_string(plist,"INSTRUME");
710 }
711 
712 /*---------------------------------------------------------------------------*/
718 /*---------------------------------------------------------------------------*/
719 double sinfo_pfits_get_mjdobs(const cpl_propertylist * plist)
720 {
721  return cpl_propertylist_get_double(plist,"MJD-OBS");
722 }
723 
724 
725 /*---------------------------------------------------------------------------*/
731 /*---------------------------------------------------------------------------*/
732 double sinfo_pfits_get_monoc_pos(const cpl_propertylist * plist)
733 {
734  return cpl_propertylist_get_double(plist,"INS MONOC1 POS");
735 }
736 
737 /*---------------------------------------------------------------------------*/
743 /*---------------------------------------------------------------------------*/
744 int sinfo_pfits_get_ndit(const cpl_propertylist * plist)
745 {
746  return cpl_propertylist_get_int(plist,"ESO DET NDIT");
747 }
748 
749 /*---------------------------------------------------------------------------*/
755 /*---------------------------------------------------------------------------*/
756 int sinfo_pfits_get_naxis1(const cpl_propertylist * plist)
757 {
758  return cpl_propertylist_get_int(plist,"NAXIS1");
759 }
760 
761 
762 /*---------------------------------------------------------------------------*/
768 /*---------------------------------------------------------------------------*/
769 int sinfo_pfits_get_naxis2(const cpl_propertylist * plist)
770 {
771  return cpl_propertylist_get_int(plist,"NAXIS2");
772 }
773 
774 
775 /*---------------------------------------------------------------------------*/
781 /*---------------------------------------------------------------------------*/
782 int sinfo_pfits_get_naxis3(const cpl_propertylist * plist)
783 {
784  return cpl_propertylist_get_int(plist,"NAXIS3");
785 }
786 
787 
788 
789 
790 /*---------------------------------------------------------------------------*/
796 /*---------------------------------------------------------------------------*/
797 double sinfo_pfits_get_crpix1(const cpl_propertylist * plist)
798 {
799  return cpl_propertylist_get_double(plist,"CRPIX1");
800 }
801 
802 
803 
804 /*---------------------------------------------------------------------------*/
810 /*---------------------------------------------------------------------------*/
811 double sinfo_pfits_get_crpix2(const cpl_propertylist * plist)
812 {
813  return cpl_propertylist_get_double(plist,"CRPIX2");
814 }
815 
816 
817 
818 /*---------------------------------------------------------------------------*/
824 /*---------------------------------------------------------------------------*/
825 double sinfo_pfits_get_crpix3(const cpl_propertylist * plist)
826 {
827  return cpl_propertylist_get_double(plist,"CRPIX3");
828 }
829 
830 
831 /*---------------------------------------------------------------------------*/
837 /*---------------------------------------------------------------------------*/
838 double sinfo_pfits_get_cdelt1(const cpl_propertylist * plist)
839 {
840  return cpl_propertylist_get_double(plist,"CDELT1");
841 }
842 
843 
844 
845 /*---------------------------------------------------------------------------*/
851 /*---------------------------------------------------------------------------*/
852 double sinfo_pfits_get_cdelt2(const cpl_propertylist * plist)
853 {
854  return cpl_propertylist_get_double(plist,"CDELT2");
855 }
856 
857 
858 
859 /*---------------------------------------------------------------------------*/
865 /*---------------------------------------------------------------------------*/
866 double sinfo_pfits_get_cdelt3(const cpl_propertylist * plist)
867 {
868  return cpl_propertylist_get_double(plist,"CDELT3");
869 }
870 
871 
872 
873 /*---------------------------------------------------------------------------*/
879 /*---------------------------------------------------------------------------*/
880 double sinfo_pfits_get_crval1(const cpl_propertylist * plist)
881 {
882  return cpl_propertylist_get_double(plist,"CRVAL1");
883 }
884 
885 /*---------------------------------------------------------------------------*/
891 /*---------------------------------------------------------------------------*/
892 double sinfo_pfits_get_crval2(const cpl_propertylist * plist)
893 {
894  return cpl_propertylist_get_double(plist,"CRVAL2");
895 }
896 
897 /*---------------------------------------------------------------------------*/
903 /*---------------------------------------------------------------------------*/
904 double sinfo_pfits_get_crval3(const cpl_propertylist * plist)
905 {
906  return cpl_propertylist_get_double(plist,"CRVAL3");
907 }
908 
909 /*---------------------------------------------------------------------------*/
915 /*---------------------------------------------------------------------------*/
916 int sinfo_pfits_get_numbexp(const cpl_propertylist * plist)
917 {
918  return cpl_propertylist_get_int(plist,"ESO TPL NEXP");
919 }
920 
921 /*---------------------------------------------------------------------------*/
927 /*---------------------------------------------------------------------------*/
928 const char * sinfo_pfits_get_obs_id(const cpl_propertylist * plist)
929 {
930  return cpl_propertylist_get_string(plist,"ESO OBS ID");
931 }
932 
933 /*---------------------------------------------------------------------------*/
939 /*---------------------------------------------------------------------------*/
940 int sinfo_pfits_get_nodpos(const cpl_propertylist * plist)
941 {
942  return cpl_propertylist_get_int(plist,"ESO SEQ NODPOS");
943 }
944 
945 
946 
947 /*---------------------------------------------------------------------------*/
953 /*---------------------------------------------------------------------------*/
954 double sinfo_pfits_get_ra(const cpl_propertylist * plist)
955 {
956  return cpl_propertylist_get_double(plist,"RA");
957 }
958 
959 /*---------------------------------------------------------------------------*/
965 /*---------------------------------------------------------------------------*/
966 const char * sinfo_pfits_get_starname(const cpl_propertylist * plist)
967 {
968  return cpl_propertylist_get_string(plist,"ESO OBS TARG NAME");
969 }
970 
971 /*---------------------------------------------------------------------------*/
977 /*---------------------------------------------------------------------------*/
978 double sinfo_pfits_get_resol(const cpl_propertylist * plist)
979 {
980  return cpl_propertylist_get_double(plist,"ESO INS RESOL");
981 }
982 
983 /*---------------------------------------------------------------------------*/
989 /*---------------------------------------------------------------------------*/
990 const char * sinfo_pfits_get_templateid(const cpl_propertylist * plist)
991 {
992  return (const char*) cpl_propertylist_get_string(plist,"ESO TPL ID");
993 }
1002 static cpl_error_code
1003 sinfo_plist_set_extra_common_keys(cpl_propertylist* plist)
1004 {
1005 
1006  cpl_propertylist_append_string(plist,"HDUCLASS", "ESO") ;
1007  cpl_propertylist_set_comment(plist,"HDUCLASS","hdu classification") ;
1008 
1009  cpl_propertylist_append_string(plist,"HDUDOC", "DICD") ;
1010  cpl_propertylist_set_comment(plist,"HDUDOC","hdu reference document") ;
1011 
1012  cpl_propertylist_append_string(plist,"HDUVERS", "DICD V6.0") ;
1013  cpl_propertylist_set_comment(plist,"HDUVERS","hdu reference document version") ;
1014 
1015  return cpl_error_get_code();
1016 }
1017 
1030 cpl_error_code
1031 sinfo_plist_set_extra_keys(cpl_propertylist* plist,
1032  const char* hduclas1,
1033  const char* hduclas2,
1034  const char* hduclas3,
1035  const char* scidata,
1036  const char* errdata,
1037  const char* qualdata,
1038  const int type)
1039 {
1040 
1041  cpl_ensure_code(type<3,CPL_ERROR_ILLEGAL_INPUT);
1042  cpl_ensure_code(type>=0,CPL_ERROR_ILLEGAL_INPUT);
1043 
1044  sinfo_plist_set_extra_common_keys(plist);
1045 
1046  cpl_propertylist_append_string(plist,"HDUCLAS1",hduclas1) ;
1047  cpl_propertylist_set_comment(plist,"HDUCLAS1","hdu format classification") ;
1048 
1049  cpl_propertylist_append_string(plist,"HDUCLAS2",hduclas2) ;
1050  cpl_propertylist_set_comment(plist,"HDUCLAS2","hdu type classification") ;
1051 
1052  if(type!=0) {
1053  cpl_propertylist_append_string(plist,"HDUCLAS3",hduclas3) ;
1054  cpl_propertylist_set_comment(plist,"HDUCLAS3","hdu info classification") ;
1055  cpl_propertylist_append_string(plist,"SCIDATA",scidata) ;
1056  cpl_propertylist_set_comment(plist,"SCIDATA","name of data extension") ;
1057  }
1058 
1059  if(type!=1) {
1060  /* CASA prefers to have these not set if the extension actually does not
1061  * exist
1062  cpl_propertylist_append_string(plist,"ERRDATA",errdata) ;
1063  cpl_propertylist_set_comment(plist,"ERRDATA","name of errs extension") ;
1064  */
1065  }
1066 
1067  if(type!=2) {
1068  /* CASA prefers to have these not set if the extension actually does not
1069  * exist
1070  cpl_propertylist_append_string(plist,"QUALDATA",qualdata) ;
1071  cpl_propertylist_set_comment(plist,"QUALDATA","name of qual extension") ;
1072  */
1073  }
1074 
1075  return cpl_error_get_code();
1076 }
1077