1
/*===========================================================================
2
Copyright (C) 1995-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
/*+++++++++++++++++++++++++ SC interface module SCP +++++++++++++++++++++++
30
.IDENTIFICATION Module SCP
31
.AUTHOR K. Banse ESO - Garching
32
.KEYWORDS standard interfaces, data frames
33
.ENVIRONMENT VMS and UNIX
34
.COMMENTS holds SCPGET, SCPPUT
35
.VERSION [1.00] 950622: creation
38
-----------------------------------------------------------------------------*/
40
#include <fileexts.h> /* includes <midas_def.h> */
46
int SCPGET(imno,plandir,planno,bufadr)
48
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
50
get a plane along a major axis of a cube
53
return status ( ERR_NORMAL (=0) means o.k. )
55
--------------------------------------------------------------------------*/
57
int imno; /* IN: file no. of data cube */
58
int plandir; /* IN: direction of plane (x, y or z) */
59
int planno; /* IN: no. of plane, starting with 1 */
60
char *bufadr; /* IN: address of data buffer */
64
int unit, nullo, status;
65
int iav, xyplansiz, linsiz, felem, mm, first;
70
struct FCT_STRUCT *fctpntr;
72
static int old_imno = -1;
73
static int naxis, npi[3];
76
/* get descriptors NAXIS + NPIX */
80
naxis = npi[0] = npi[1] = npi[2] = 0;
82
(void) SCDRDI(imno,"NAXIS",1,1,&iav,&naxis,&unit,&nullo);
83
if (naxis == 0) MID_E2(12,imno,"NAXIS",ERR_INPINV,1);
87
if ((naxis == 2) && (plandir == X_Y_PLANE) && (planno == 1))
90
MID_E2(12,imno,"NAXIS",ERR_INPINV,1);
93
(void) SCDRDI(imno,"NPIX",1,naxis,&iav,npi,&unit,&nullo);
94
if (npi[0] == 0) MID_E2(12,imno,"NPIX",ERR_INPINV,1);
100
if (plandir == X_Y_PLANE)
102
else if (plandir == X_Z_PLANE)
104
else if (plandir == Z_Y_PLANE)
108
MID_E2(12,imno,"plandir ",ERR_INPINV,1);
112
if ( (planno > npi[mm]) || (planno < 1) )
113
MID_E2(12,imno,"planno ",ERR_INPINV,1);
116
xyplansiz = npi[0] * npi[1];
117
fctpntr = FCT.ENTRIES + imno;
121
case X_Y_PLANE: /* get x-y plane of data cube */
122
first = (planno-1)*xyplansiz + 1;
124
status = SCFGET(imno,first,xyplansiz,&iav,bufadr);
127
case X_Z_PLANE: /* get x-z plane of data cube */
129
first = (planno-1)*npi[0] + 1;
132
for (nr=0; nr<npi[2]; nr++)
134
status = SCFGET(imno,first,linsiz,&iav,inpntr);
135
inpntr += linsiz*fctpntr->NOBYTE;
140
case Z_Y_PLANE: /* get z-y plane of data cube */
144
if (fctpntr->FILTYP > 0)
146
for (nr=0; nr<npi[1]; nr++)
149
for (nrr=0; nrr<npi[2]; nrr++)
151
status = SCFGET(imno,first,1,&iav,inpntr);
152
inpntr += fctpntr->NOBYTE;
161
if (fctpntr->DATTYP != fctpntr->FORMAT)
164
char dummy[24], *oldpntr;
167
nobytes = get_byte(fctpntr->DATTYP);
169
for (nr=0; nr<npi[1]; nr++)
172
for (nrr=0; nrr<npi[2]; nrr++)
174
status = rddisk(imno,first,1,&iav,oldpntr);
175
conv_pix(inpntr,oldpntr,fctpntr->DATTYP,fctpntr->FORMAT,1);
184
for (nr=0; nr<npi[1]; nr++)
187
for (nrr=0; nrr<npi[2]; nrr++)
189
status = rddisk(imno,first,1,&iav,inpntr);
190
inpntr += fctpntr->NOBYTE;
205
int SCPPUT(imno,plandir,planno,bufadr)
207
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
209
write a plane along a major axis of a cube
212
return status ( ERR_NORMAL (=0) means o.k. )
214
--------------------------------------------------------------------------*/
216
int imno; /* IN: file no. of data cube */
217
int plandir; /* IN: direction of plane (x, y or z) */
218
int planno; /* IN: no. of plane, starting with 1 */
219
char *bufadr; /* IN: address of data buffer */
222
int unit, nullo, status;
223
int iav, xyplansiz, linsiz, felem, mm, first;
224
register int nr, nrr;
228
struct FCT_STRUCT *fctpntr;
230
static int old_imno = -1;
231
static int naxis, npi[3];
235
/* get descriptors NAXIS + NPIX */
238
if (imno != old_imno)
240
naxis = npi[0] = npi[1] = npi[2] = 0;
242
(void) SCDRDI(imno,"NAXIS",1,1,&iav,&naxis,&unit,&nullo);
243
if (naxis == 0) MID_E2(13,imno,"NAXIS",ERR_INPINV,1);
247
if ((naxis == 2) && (plandir == X_Y_PLANE) && (planno == 1))
250
MID_E2(12,imno,"NAXIS",ERR_INPINV,1);
253
(void) SCDRDI(imno,"NPIX",1,naxis,&iav,npi,&unit,&nullo);
254
if (npi[0] == 0) MID_E2(13,imno,"NPIX",ERR_INPINV,1);
259
if (plandir == X_Y_PLANE)
261
else if (plandir == X_Z_PLANE)
263
else if (plandir == Z_Y_PLANE)
267
MID_E2(13,imno,"plandir ",ERR_INPINV,1);
271
if ( (planno > npi[mm]) || (planno < 1) )
272
MID_E2(13,imno,"planno ",ERR_INPINV,1);
275
xyplansiz = npi[0] * npi[1];
276
fctpntr = FCT.ENTRIES + imno;
280
case X_Y_PLANE: /* put x-y plane of data cube */
281
first = (planno-1)*xyplansiz + 1;
282
status = SCFPUT(imno,first,xyplansiz,bufadr);
285
case X_Z_PLANE: /* put x-z plane of data cube */
287
first = (planno-1)*npi[0] + 1;
290
for (nr=0; nr<npi[2]; nr++)
292
status = SCFPUT(imno,first,linsiz,inpntr);
293
inpntr += linsiz*fctpntr->NOBYTE;
298
case Z_Y_PLANE: /* put z-y plane of data cube */
302
if (fctpntr->FILTYP > 0)
304
for (nr=0; nr<npi[1]; nr++)
307
for (nrr=0; nrr<npi[2]; nrr++)
309
status = SCFPUT(imno,first,1,inpntr);
310
inpntr += fctpntr->NOBYTE;
319
if (fctpntr->DATTYP != fctpntr->FORMAT)
322
char dummy[24], *newpntr;
325
nobytes = get_byte(fctpntr->DATTYP);
327
for (nr=0; nr<npi[1]; nr++)
330
for (nrr=0; nrr<npi[2]; nrr++)
332
conv_pix(newpntr,inpntr,fctpntr->FORMAT,fctpntr->DATTYP,1);
333
status = wrdisk(imno,first,1,newpntr);
342
for (nr=0; nr<npi[1]; nr++)
345
for (nrr=0; nrr<npi[2]; nrr++)
347
status = wrdisk(imno,first,1,inpntr);
348
inpntr += fctpntr->NOBYTE;