1
/*===========================================================================
2
Copyright (C) 2003-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29
.COPYRIGHT (c) 2003 European Southern Observatory
32
.AUTHOR K. Banse ESO - Garching
34
.PURPOSE Copy FITS header from 1st FITS extension to other
35
extensions of same file, but do not overwrite existing data
36
.VERSION 1.0 031028 KB
38
090710 last modification
39
---------------------------------------------------------------------*/
42
#define _XOPEN_SOURCE 1
46
#include <midas_def.h>
54
char root[64], extlist[104], exttypes[96], source[80];
57
int uni, nulo, nval, n, mm, mask;
58
int extno[80], imnoa, imnob;
69
(void) SCSPRO("FHEADCOPY"); /* get into MIDAS env. */
70
(void) SCKGETC("INPUTC",1,20,&nval,root); /* read root for file names */
73
/* thanks to INDISK/MFITS, the total no. of extensions (files created)
74
is stored in keyword MID$INFO(4), and the types in OUTPUTC(1:) */
77
(void) SCKRDI("MID$INFO",4,1,&n,&totext,&uni,&nulo);
79
(void) SCKGETC("OUTPUTC",1,n,&nval,exttypes);
82
/* check, which extensions should be processed */
84
(void) SCKGETC("P6",1,100,&nval,extlist);
85
mm = CGN_INDEXC(extlist,',') + 1;
87
SCETER(3,"Invalid copy_FITS_header_flag - we quit ...");
89
if (extlist[mm] != '*') /* copy,e1,e2,... */
91
(void) strcpy(extlist,&extlist[mm]); /* move to begin of string */
92
extcount = CGN_CNVT(extlist,1,80,extno,&rdum,&ddum);
94
SCETER(4,"invalid syntax for extension no.s ...");
98
extcount = totext - 1; /* subtract 1. header (extension) */
99
for (n=0; n<extcount; n++) extno[n] = n + 1;
103
/* open source_frame (1. extension of FITS file) - it's always type IMAGE! */
105
(void) sprintf(source,"%s0000",root);
106
(void) SCFOPN(source,D_OLD_FORMAT,0,F_IMA_TYPE,&imnoa);
108
/* copy all but extended, standard descr.s, except the ones specified in
109
dsclist param. - no overwrite */
111
mask = 210; /* flag = 10, no_overwrite = 200 */
113
for (n=0; n<extcount; n++)
115
mm = extno[n]; /* no. of dest_frame */
116
(void) sprintf(name,"%s%4.4d",root,mm);
117
if ((exttypes[mm] == 'I') || (exttypes[mm] == 'E'))
119
(void) strcat(name,".bdf"); /* type IMAG */
120
(void) SCFOPN(name,D_OLD_FORMAT,0,F_IMA_TYPE,&imnob);
121
(void) SCDCOP(imnoa,imnob,mask,"O_POS"); /* don't copy O_POS */
122
(void) SCFCLO(imnob);
126
(void) strcat(name,".tbl"); /* type TABL */
127
(void) TCTOPN(name, F_IO_MODE, &imnob);
128
(void) SCDCOP(imnoa,imnob,mask,"O_POS"); /* don't copy O_POS */
129
(void) TCTCLO(imnob);