~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to prim/dio/src/fheadcopy.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*===========================================================================
 
2
  Copyright (C) 2003-2009 European Southern Observatory (ESO)
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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, 
 
17
  MA 02139, USA.
 
18
 
 
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 
 
25
                        GERMANY
 
26
===========================================================================*/
 
27
 
 
28
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
29
.COPYRIGHT    (c)  2003  European Southern Observatory
 
30
.IDENT        fheadcopy.c
 
31
.LANGUAGE     C
 
32
.AUTHOR       K. Banse          ESO - Garching
 
33
.KEYWORDS     FITS header
 
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
 
37
 
 
38
 090710         last modification
 
39
---------------------------------------------------------------------*/
 
40
 
 
41
#ifndef _XOPEN_SOURCE
 
42
#define _XOPEN_SOURCE 1
 
43
#endif
 
44
 
 
45
#include   <stdio.h>
 
46
#include   <midas_def.h>
 
47
 
 
48
/*
 
49
 
 
50
*/
 
51
 
 
52
int main()
 
53
{
 
54
char  root[64], extlist[104], exttypes[96], source[80];
 
55
char  name[120];
 
56
 
 
57
int   uni, nulo, nval, n, mm, mask;
 
58
int   extno[80], imnoa, imnob;
 
59
int   extcount, totext;
 
60
 
 
61
float  rdum;
 
62
 
 
63
double ddum;
 
64
 
 
65
 
 
66
 
 
67
 
 
68
 
 
69
(void) SCSPRO("FHEADCOPY");                     /* get into MIDAS env. */
 
70
(void) SCKGETC("INPUTC",1,20,&nval,root);       /* read root for file names */
 
71
 
 
72
 
 
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:)     */
 
75
 
 
76
nulo = -1;
 
77
(void) SCKRDI("MID$INFO",4,1,&n,&totext,&uni,&nulo);
 
78
n = totext + 1;
 
79
(void) SCKGETC("OUTPUTC",1,n,&nval,exttypes);
 
80
 
 
81
 
 
82
/* check, which extensions should be processed */
 
83
 
 
84
(void) SCKGETC("P6",1,100,&nval,extlist);
 
85
mm = CGN_INDEXC(extlist,',') + 1;
 
86
if (mm < 2) 
 
87
   SCETER(3,"Invalid copy_FITS_header_flag - we quit ...");
 
88
 
 
89
if (extlist[mm] != '*')                         /* copy,e1,e2,... */
 
90
   {
 
91
   (void) strcpy(extlist,&extlist[mm]);         /* move to begin of string */
 
92
   extcount = CGN_CNVT(extlist,1,80,extno,&rdum,&ddum);
 
93
   if (extcount < 1) 
 
94
      SCETER(4,"invalid syntax for extension no.s ...");
 
95
   }
 
96
else                                            /* copy,*   */
 
97
   {
 
98
   extcount = totext - 1;               /* subtract 1. header (extension) */
 
99
   for (n=0; n<extcount; n++) extno[n] = n + 1;
 
100
   }
 
101
 
 
102
 
 
103
/* open source_frame (1. extension of FITS file) - it's always type IMAGE! */
 
104
 
 
105
(void) sprintf(source,"%s0000",root);
 
106
(void) SCFOPN(source,D_OLD_FORMAT,0,F_IMA_TYPE,&imnoa);
 
107
 
 
108
/* copy all but extended, standard descr.s, except the ones specified in
 
109
   dsclist param. - no overwrite */
 
110
 
 
111
mask = 210;                     /* flag = 10, no_overwrite = 200 */
 
112
 
 
113
for (n=0; n<extcount; n++)
 
114
   {
 
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'))
 
118
      {
 
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);
 
123
      }
 
124
   else
 
125
      {
 
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);
 
130
      }
 
131
   }
 
132
 
 
133
 
 
134
return SCSEPI();
 
135
}
 
136