1
/*===========================================================================
2
Copyright (C) 1988-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
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
.AUTHOR K. Banse ESO/IPG
32
.KEYWORDS Bulk data frames, Images
33
.PURPOSE Read File Control Block of given image and display that
34
info in a user friendly format
39
---------------------------------------------------------------------*/
58
char cbuf[32], infile[128], filetype[24], outbuf[80];
60
int imnoa, datformat, nobytes, nval;
61
int n, stat, unit, naxis;
62
int Mflag, isfits, siprint, minfo[5];
63
int e_c, e_log, e_disp, ln, ln1, ln2;
70
struct FCT_STRUCT *fctpntr;
72
struct FCB_STRUCT *fcbp;
78
if (argc > 1) /* we're with command line args. */
80
(void) strcpy(infile,argv[1]);
85
(void) strncpy(cbuf,argv[2],4); /* we only need first 4 chars. */
94
stat = SCKGETC("IN_A",1,120,&nval,infile); /* get input frame */
95
stat = SCKGETC("P2",1,4,&nval,cbuf); /* get action */
96
Mflag = 1; /* we're inside Midas */
99
for (n=0; n<5; n++) minfo[n] = 0;
103
if ((cbuf[0] == 'T') || (cbuf[0] == 't'))
106
double dd[200]; /* test section for SCFMOD */
110
unit = 0; /* create an image frame using SCFMOD */
112
stat = SCFCRE(infile,D_I1_FORMAT,F_H_MODE,F_IMA_TYPE,size,&imnoa);
115
SCDWRI(imnoa,"NAXIS",minfo,1,1,&unit);
116
minfo[0] = minfo[1] = 512;
117
SCDWRI(imnoa,"NPIX",minfo,1,2,&unit);
119
SCDWRD(imnoa,"START",dd,1,2,&unit);
121
SCDWRD(imnoa,"STEP",dd,1,2,&unit);
122
strcpy(outbuf,"test header file stuff");
123
SCDWRC(imnoa,"IDENT",1,outbuf,1,strlen(outbuf),&unit);
124
strcpy(outbuf,"intensity x-pix y-pix");
125
SCDWRC(imnoa,"CUNIT",1,outbuf,1,strlen(outbuf),&unit);
126
cuts[0] = cuts[1] = 0.0;
127
cuts[2] = 22.2; cuts[3] = 19999.9;
128
SCDWRR(imnoa,"LHCUTS",cuts,1,4,&unit);
129
strcpy(outbuf,"this descr. holds the cut values");
130
SCDWRH(imnoa,"LHCUTS",outbuf,1,strlen(outbuf));
132
for (n=0; n<200; n++) dd[n] = (double) n;
135
sprintf(outbuf,"double_descriptor%d",n);
136
SCDWRD(imnoa,outbuf,dd,1,200,&unit);
139
SCFMOD(imnoa,D_R4_FORMAT,size);
141
for (n=20; n<40; n++)
143
sprintf(outbuf,"double_descriptor%d",n);
144
SCDWRD(imnoa,outbuf,dd,1,200,&unit);
151
if ((cbuf[0] == 'D') || (cbuf[0] == 'd'))
152
{ /* debug section for FCB, FCT */
153
MID_SHOWFCT(infile); /* show FCT + FCB entry */
154
stat = MID_SHOWFCB(infile);
156
SCTPUT("unsupported descriptor format!");
157
else if (stat != ERR_NORMAL)
166
if ((cbuf[0] == 'I') || (cbuf[0] == 'i'))
167
{ /* test section for CGN_FILINFO */
168
long int filsize, ltime;
170
CGN_FILINFO(infile,&filsize,<ime,&nval);
171
(void) printf("frame: %s\n",infile);
172
(void) printf("filesize = %ld bytes, creation time = %ld, protection = %d\n",
180
if ((cbuf[0] == 'E') || (cbuf[0] == 'e'))
181
{ /* show all extensions of FITS file */
182
n = MID_fitsin(-1,infile,0,filetype,filetype,&nval,minfo);
185
/* if not in Midas just print */
190
(void) printf("%s - not a valid FITS file...\n",infile);
192
(void) printf("total no. of extensions = %d\n",minfo[0]);
196
if (n != 0) SCETER(11,"not a valid FITS file...");
198
(void) SCKWRI("OUTPUTI",minfo,19,1,&unit);
199
(void) sprintf(outbuf,"total no. of extensions = %d\n",minfo[0]);
201
(void) SCKWRI("INPUTI",&isfits,19,1,&unit);
211
/* here the `normal' INFO/FRAME section */
213
SCECNT("GET",&ln,&ln1,&ln2);
214
e_c = 1; e_log = 0; e_disp = 0;
215
SCECNT("PUT",&e_c,&e_log,&e_disp);
217
stat = SCFOPN(infile,D_OLD_FORMAT,0,F_OLD_TYPE,&imnoa);
218
fctpntr = FCT.ENTRIES + imnoa;
221
SCECNT("PUT",&ln,&ln1,&ln2);
223
if (stat != ERR_NORMAL)
231
n = (int) strlen(fcbp->BDTYPE);
233
if (fcbp->BDTYPE[n] == 'F')
236
if (argc < 2) siprint = 0; /* in Midas + FITS file, don't print */
237
(void) strcpy(filetype,"FITS ");
242
(void) strcpy(filetype,fcbp->BDTYPE);
246
(void) sprintf(outbuf,"Name: %s - frame type: %s",fctpntr->NAME,filetype);
249
(void) sprintf(outbuf,"Version: %s",fcbp->VERSION);
250
if (siprint == 1) SCTPUT(outbuf);
252
(void) CGN_CNVT(&fcbp->VERSION[5],1,1,&nval,&rr,&dd);
255
if (nval < 6) SCTPUT("this version is not supported anymore!");
257
nobytes = fcbp->NOBYT;
258
datformat = fcbp->DFORMAT;
259
minfo[0] = datformat;
260
minfo[1] = fcbp->NDVAL;
262
if (filetype[0] == 'T')
264
else if (filetype[0] == 'F')
267
minfo[3] = 1; /* default to image */
269
if (datformat == D_R4_FORMAT)
270
(void) sprintf(outbuf,
271
"data type of pixels = real, %d bytes per pixel",nobytes);
272
else if (datformat == D_I4_FORMAT)
273
(void) sprintf(outbuf,
274
"data type of pixels = integer, %d bytes per pixel",nobytes);
275
else if (datformat == D_I2_FORMAT)
276
(void) sprintf(outbuf,
277
"data type of pixels = short int, %d bytes per pixel",nobytes);
278
else if (datformat == D_I1_FORMAT)
279
(void) sprintf(outbuf,
280
"data type of pixels = byte, %d bytes per pixel",nobytes);
281
else if (datformat == D_R8_FORMAT)
282
(void) sprintf(outbuf,
283
"data type of pixels = double prec., %d bytes per pixel",nobytes);
284
else if (datformat == D_UI2_FORMAT)
285
(void) sprintf(outbuf,
286
"data type of pixels = unsigned short int, %d bytes per pixel",
288
if (siprint == 1) SCTPUT(outbuf);
290
(void) sprintf(outbuf,"Total no. of pixels = %d",fcbp->NDVAL);
291
if (siprint == 1) SCTPUT(outbuf);
293
n = (fcbp->D1BLOCK - 1) * DISK_REC;
294
(void) sprintf(outbuf,
295
"first pixel begins at byte no. %d (counting starts at 0)",n);
296
if (siprint == 1) SCTPUT(outbuf);
298
if (minfo[4] < 10) /* OJO: we have VERS_006 or VERS_007 binary file */
302
xptr = (char *) &fcbp->NDVAL + 4; /* point to previous CREATIM */
303
for (n=0; n<16; n++) cbuf[n] = *xptr++;
305
(void) sprintf(outbuf,
306
"created on: %s - OJO: outdated format, convert to FITS!",cbuf);
310
int longt[2]; /* offset of CRETIM is 220 bytes -
311
NOT a multiple of 8 ... */
312
longt[0] = fcbp->CRETIM[0];
313
longt[1] = fcbp->CRETIM[1];
314
longtime = (long int *) longt;
315
(void) sprintf(outbuf,"created on: %s - %ld seconds",
316
fcbp->CREATE,*longtime);
318
if (siprint == 1) SCTPUT(outbuf);
320
naxis = fcbp->DATAINFO[0];
322
(void) sprintf(outbuf,"Naxis = %d Npix = %d", naxis,fcbp->DATAINFO[1]);
324
(void) sprintf(outbuf,"Naxis = %d Npix = %d,%d", naxis,
325
fcbp->DATAINFO[1],fcbp->DATAINFO[2]);
327
(void) sprintf(outbuf,"Naxis = %d Npix = %d,%d,%d", naxis,
328
fcbp->DATAINFO[1],fcbp->DATAINFO[2],fcbp->DATAINFO[3]);
330
(void) sprintf(outbuf,"Naxis = %d ", naxis);
331
if (siprint == 1) SCTPUT(outbuf);
336
(void) SCKWRI("MID$INFO",minfo,1,5,&unit);
339
(void) SCKWRI("INPUTI",&isfits,19,1,&unit);
343
return (0); /* just to calm the compiler... */