1
/*===========================================================================
2
Copyright (C) 1995-2011 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 a) copy images
34
b) rearrange planes of a cube
35
c) convert descr sequences to a table (e.g. VIMOS data)
37
.VERSION 1.00 950921: Creation
40
---------------------------------------------------------------------*/
48
#include <midas_def.h>
54
void convert(infile,outfile)
55
char *infile, *outfile;
58
char cbuf[124], instring[124], *ptra;
59
char dscroot[48], fulldscroot[124], *dscsub[MAXSUBS], *helpsub[MAXSUBS];
63
int dtype[MAXSUBS], colno[MAXSUBS], csize[MAXSUBS], hlen[MAXSUBS];
64
int mn, mm, maxsubs, nval, null, unit;
65
int n, convdir, bytelm, status;
66
int ec, el, ed, ln1, ln0, delflag;
67
int nrow, nrowmax, dlim[2], single;
78
CONVERT/DESCR_MATRIX image table direction
79
dscroot[,first[,last]] dscsub1,dscsub2,... del_flag
84
single = 0; /* set, if 1-dim array instead of matrix */
85
(void) strcpy(sfmt,"%s%d.");
87
(void) SCKGETC("P3",1,4,&nval,cbuf); /* which way to go? */
89
mm = strcmp(cbuf,"t-ds");
90
if (mm != 0) /* descriptors -> table */
93
(void) SCKRDI("INPUTI",1,1,&nval,&delflag,&unit,&null); /* delete flag */
95
else /* table -> descriptors */
99
(void) TCTOPN(outfile,F_I_MODE,&tid);
100
(void) TCIGET(tid,&maxsubs,&nrowmax,&mn,&mn,&mn);
101
(void) SCDRDI(tid,"DESCR_MATRIX",1,1,&nval,&single,&unit,&null);
106
/* look for root part of descr and optional index limits */
108
if (single == 1) /* that implies convdir = 2 ! */
110
(void) strcpy(sfmt,"%s%d");
111
(void) SCDGETC(tid,"DESCR_ROOT",1,120,&nval,fulldscroot);
115
(void) SCKGETC("P4",1,120,&nval,fulldscroot);
116
if ((fulldscroot[0] == '+') || (fulldscroot[0] == '?'))
117
{ /* nothing entered */
119
SCETER(67,"missing root of descr...");
120
/* get info from table descr. */
121
(void) SCDGETC(tid,"DESCR_ROOT",1,120,&nval,fulldscroot);
126
/* and process root[,first[,last]] */
128
(void) strcpy(instring,fulldscroot);
129
mm = CGN_INDEXC(instring,',');
133
(void) strcpy(dscroot,instring); /* copy first string */
134
(void) strcpy(instring,&instring[mm+1]);
135
mm = CGN_INDEXC(instring,',');
143
n = CGN_CNVT(instring,1,mm,dlim,&rval,&dval);
144
if (n != mm) SCETER(64,"invalid start, end indices...");
146
if (dlim[0] < 1) dlim[0] = 1;
147
if ((mm == 2) && (dlim[1] < dlim[0]))
148
SCETER(65,"invalid start, end indices...");
152
(void) strcpy(dscroot,instring);
153
dlim[0] = 1; /* index of first descr. */
154
dlim[1] = -1; /* index of last descr. */
158
/* allocate virtual space for subDSCs and their help
159
max 46 chars per subDSC and 72 chars per help string */
161
mm = 48 + 74; /* use multiples of 4 for nicer handling */
163
dscsub[0] = (char *) malloc((size_t) (MAXSUBS * mm));
164
if (dscsub[0] == (char *) 0)
165
SCETER(66,"could not allocate virtual memory...");
166
helpsub[0] = dscsub[0] + (MAXSUBS * 48); /* skip to help string part */
168
for (n=1; n<MAXSUBS; n++)
170
dscsub[n] = dscsub[n-1] + 48;
171
helpsub[n] = helpsub[n-1] + 74;
175
/* open the image for access to FITS/descr. header */
177
(void) SCFOPN(infile,D_OLD_FORMAT,0,F_IMA_TYPE,&imnoa);
178
(void) SCECNT("GET",&ec,&el,&ed);
182
/* ........................................
186
......................................... */
191
maxsubs = 1; /* parse individual descr fields (subDCS) */
192
(void) SCKGETC("P5",1,120,&nval,instring);
193
if ((instring[0] == '?') || (instring[0] == '+'))
196
(void) strcpy(dscsub[0],""); /* points to Nirwana... */
197
(void) strcpy(sfmt,"%s%d");
203
for (n=0; n<MAXSUBS; n++)
205
mm = CGN_INDEXC(ptra,',');
209
(void) strcpy(dscsub[n],ptra);
215
(void) strcpy(dscsub[n],ptra);
222
/* move descriptors to binary table */
226
printf("use as descr_root: %s###\nand as descr_fields: ",dscroot);
229
printf("use as descr_root: %s### and no descr_fields ",dscroot);
231
(void) sprintf(instring,sfmt,dscroot,dlim[0]); /* for first descr. */
232
mm = (int) strlen(instring);
234
for (n=0; n<maxsubs; n++)
236
(void) strcpy(&instring[mm],dscsub[n]);
237
(void) SCDFND(imnoa,instring,cbuf,&nval,&bytelm);
239
SCETER(62,"could not get descr_field type...");
244
else if (cbuf[0] == 'R')
246
else if (cbuf[0] == 'D')
248
else /* only C (character) left */
251
csize[n] = nval * bytelm; /* size of char. column */
254
(void) printf("%s, ",dscsub[n]);
256
(void) SCDRDH(imnoa,instring,1,72,&nval,cbuf,&mn);
262
(void) strcpy(helpsub[n],cbuf);
267
(void) printf("\n=> table will be created with %d columns\n",maxsubs);
270
(void) printf("\n=> table will be created with %d column\n",maxsubs);
271
(void) strcpy(dscsub[0],dscroot);
275
/* create the table with `maxsubs' cols * 200 rows */
277
(void) TCTINI(outfile,F_TRANS,F_O_MODE,maxsubs,200,&tid);
279
for (n=0; n<maxsubs; n++)
282
status = TCCINI(tid,D_I4_FORMAT,1,"I8"," ",dscsub[n],&colno[n]);
283
else if (dtype[n] == 2)
284
status = TCCINI(tid,D_R4_FORMAT,1,"G12.6"," ",dscsub[n],&colno[n]);
285
else if (dtype[n] == 4)
286
status = TCCINI(tid,D_R8_FORMAT,1,"G12.6"," ",dscsub[n],&colno[n]);
289
mn = (int) strlen(dscsub[n]);
290
nval = ((mn - 1)%8 + 1) * 8; /* => chunks of 8 chars */
291
(void) sprintf(cbuf,"a%d",nval);
292
status = TCCINI(tid,D_C_FORMAT,csize[n],cbuf," ",dscsub[n],&colno[n]);
295
if (status != ERR_NORMAL)
296
SCETER(63,"could not create table columns...");
299
(void) SCDWRC(tid,"DESCR_ROOT",1,fulldscroot,1,120,&unit);
300
(void) SCDWRI(tid,"DESCR_MATRIX",&single,1,1,&unit);
301
for (n=0; n<maxsubs; n++)
303
(void) sprintf(instring,"DESCR_%4.4d",n);
304
(void) SCDWRC(tid,instring,1,dscsub[n],1,(int)strlen(dscsub[n]),&unit);
305
if (*helpsub[n] != '\0')
307
hlen[n] = (int) strlen(helpsub[n]);
308
(void) SCDWRH(tid,instring,helpsub[n],1,hlen[n]);
312
if (single == 1) (void) strcpy(dscsub[0],"");
315
/* loop through header of file */
317
(void) SCECNT("PUT",&ln1,&ln0,&ln0); /* now, ignore errors */
319
if (dlim[1] == -1) dlim[1] = 200000;
322
for (mn=dlim[0]; mn<dlim[1]+1 ; mn++)
324
(void) sprintf(instring,sfmt,dscroot,mn); /* build DSC name */
325
mm = (int) strlen(instring);
327
for (n=0; n<maxsubs; n++)
329
(void) strcpy(&instring[mm],dscsub[n]);
332
status = SCDRDI(imnoa,instring,1,1,&nval,&ival,&unit,&null);
333
if (status == ERR_NORMAL)
335
(void) TCEWRI(tid,nrow,colno[n],&ival);
336
if (delflag == 1) (void) SCDDEL(imnoa,instring);
339
else if (dtype[n] == 2)
341
status = SCDRDR(imnoa,instring,1,1,&nval,&rval,&unit,&null);
342
if (status == ERR_NORMAL)
344
(void) TCEWRR(tid,nrow,colno[n],&rval);
345
if (delflag == 1) (void) SCDDEL(imnoa,instring);
348
else if (dtype[n] == 4)
350
status = SCDRDD(imnoa,instring,1,1,&nval,&dval,&unit,&null);
351
if (status == ERR_NORMAL)
353
(void) TCEWRD(tid,nrow,colno[n],&dval);
354
if (delflag == 1) (void) SCDDEL(imnoa,instring);
357
else /* only char string left */
359
status = SCDRDC(imnoa,instring,1,1,80,&nval,cbuf,&unit,&null);
360
if (status == ERR_NORMAL)
363
(void) TCEWRC(tid,nrow,colno[n],cbuf);
364
if (delflag == 1) (void) SCDDEL(imnoa,instring);
370
if (status == ERR_DSCNPR)
372
nrow --; /* adjust no. of rows written */
373
(void) sprintf(instring,"%d rows created",nrow);
383
/* ........................................
387
......................................... */
391
for (n=0; n<maxsubs; n++) /* find all columns to process */
393
(void) sprintf(cbuf,"#%d",n+1);
394
(void) TCCSER(tid,cbuf,&colno[n]);
396
SCETER(68,"input column bad...");
398
(void) TCFGET(tid,colno[n],cbuf,&mn,&nval);
400
if (nval == D_C_FORMAT)
405
else if (nval == D_R8_FORMAT)
407
else if (nval == D_R4_FORMAT)
410
dtype[n] = 1; /* all other => integer */
412
(void) sprintf(instring,"DESCR_%4.4d",n);
413
(void) SCDHRC(tid,instring,1,1,46,&nval,dscsub[n],cbuf,72,&unit,&null);
414
*(dscsub[n] + nval) = '\0'; /* strings from descr. have no '\0' */
415
(void) strcpy(helpsub[n],cbuf);
416
hlen[n] = (int) strlen(cbuf);
419
printf("dscsub[%d] = >%s<, type = %d, size = %d\n",
420
n,dscsub[n],dtype[n],csize[n]);
421
printf("helpsub[%d] = >%s<, hlen = %d\n\n",
422
n,helpsub[n],hlen[n]);
426
if (single == 1) (void) strcpy(dscsub[0],"");
429
/* move binary table to descriptors */
431
(void) SCECNT("PUT",&ln1,&ln0,&ln0); /* now, ignore errors */
434
if (dlim[1] == -1) dlim[1] = nrowmax;
438
(void) sprintf(instring,sfmt,dscroot,mn); /* build DSC name */
439
mm = (int) strlen(instring);
441
for (n=0; n<maxsubs; n++)
443
(void) strcpy(&instring[mm],dscsub[n]);
447
status = TCERDI(tid,nrow,colno[n],&ival,&null);
448
if (status == ERR_NORMAL)
449
(void) xSCDWRI(imnoa,instring,&ival,1,1,&unit);
451
else if (dtype[n] == 2)
453
status = TCERDR(tid,nrow,colno[n],&rval,&null);
454
if (status == ERR_NORMAL)
455
(void) xSCDWRR(imnoa,instring,&rval,1,1,&unit);
457
else if (dtype[n] == 4)
459
status = TCERDD(tid,nrow,colno[n],&dval,&null);
460
if (status == ERR_NORMAL)
461
(void) xSCDWRD(imnoa,instring,&dval,1,1,&unit);
463
else /* only character left */
465
status = TCERDC(tid,nrow,colno[n],cbuf,&null);
466
if (status == ERR_NORMAL)
467
(void) xSCDWRC(imnoa,instring,1,cbuf,1,csize[n],&unit);
470
if (*helpsub[n] != '\0')
471
(void) xSCDWRH(imnoa,instring,helpsub[n],1,hlen[n]);
475
if ((mn > dlim[1]) || (nrow > nrowmax))
477
nrow --; /* adjust no. of rows written */
478
(void) sprintf(instring,"%d rows processed",nrow);
486
(void) SCECNT("PUT",&ec,&el,&ed); /* reset error flags */
488
(void) SCKWRI("OUTPUTI",&nrow,9,1,&unit); /* save in OUTPUTI(9) */
491
(void) SCFCLO(imnoa);
498
void mappi(in,map,out,nval,aux,msize,flag,oo)
499
float *in; /* IN: input buffer */
500
float *map; /* IN: the map buffer */
501
float *out; /* OUT: result buffer */
502
int nval; /* IN: no. of pixels */
503
float *aux; /* IN: aux[0] = fact, aux[1] = xlo, aux[2] = xhi */
504
int msize; /* IN: highest index of map */
505
int flag; /* IN: = 0, do scaling - = 1, take value directly as index */
506
float *oo; /* OUT: min, max value */
509
register int nr, indx, mindx;
511
float fact, xlo, xhi, mapmax;
512
register float rin, rout, turbo;
517
fact = aux[0]; xlo = aux[1]; xhi = aux[2];
518
turbo = 0.5 - fact*xlo;
519
mapmax = *(map+mindx);
524
/* indx = 1 + NINT((r - xlo)*fact); but first pixel of map has indx = 0
525
=> indx = NINT(r*fact - xlo*fact) or (int) (r*fact - xlo*fact + 0.5) */
527
for (nr=0; nr<nval; nr++)
536
indx = (int) (rin*fact + turbo);
541
else if (rout > oo[1])
551
for (nr=0; nr<nval; nr++)
553
indx = (int) (turbo + (*in++));
556
else if (indx >= mindx)
562
else if (rout > oo[1])
588
return (D_I1_FORMAT);
589
else if (*cbuf == '2')
590
return (D_I2_FORMAT);
591
else if (*cbuf == '4')
592
return (D_I4_FORMAT);
600
if ((*cbuf == 'I') || (*cbuf == 'i'))
602
if (*(++cbuf) == '2')
603
return (D_UI2_FORMAT);
611
return (D_R8_FORMAT);
613
return (D_R4_FORMAT);
619
return (D_R8_FORMAT);
626
return (-1); /* wrong format */
632
void mapima(infile,mapfile,outfile)
633
char *infile, *mapfile, *outfile;
636
char *pntra, *pntrb, *pntrc, cbuf[4];
638
int naxis, npix[6], imnoa, imnob, imnoc, imnow1, imnow2;
639
int felm, mapsize, sizze, msize, clony;
640
int n, null, nval, unit, scflag;
642
float cuts[4], fact, oldoo[2], oo[2], faux[3];
646
(void) SCKRDI("MONITPAR",20,1,&nval,&n,&unit,&null); /* get storage size */
649
(void) SCKGETC("P5",1,2,&nval,cbuf);
650
if ((cbuf[0] == 's') || (cbuf[0] == 'S'))
653
scflag = 1; /* use pixel value directly as index for map */
656
(void) SCFOPN(infile,D_R4_FORMAT,0,F_IMA_TYPE,&imnoa);
657
(void) SCDRDI(imnoa,"NAXIS",1,1,&nval,&naxis,&unit,&null);
658
if (naxis > 6) SCETER(3,"More than 6 dimensions...");
660
(void) SCDRDI(imnoa,"NPIX",1,naxis,&nval,npix,&unit,&null);
662
sizze = 1; /* get total size of frame */
663
for (n=0; n< naxis; n++) sizze *= npix[n];
665
(void) SCKRDR("INPUTR",1,2,&nval,cuts,&unit,&null); /* get mapping interval */
666
if (cuts[1] <= cuts[0])
668
(void) SCDRDR(imnoa,"LHCUTS",3,2,&nval,cuts,&unit,&null);
669
if (cuts[1] <= cuts[0])
670
SCETER(23,"Invalid Map-limits (bad descr. LHCUTS)...");
674
/* create new image and try to clone all descriptors */
676
(void) CGN_IBUILD(imnoa,outfile,D_R4_FORMAT,sizze,&imnoc,&clony);
679
/* get the complete image "map" */
682
(void) SCFOPN(mapfile,D_R4_FORMAT,0,F_IMA_TYPE,&imnob);
683
(void) SCDRDI(imnob,"NAXIS",1,1,&nval,&naxis,&unit,&null);
684
if (naxis > 6) SCETER(3,"More than 6 dimensions...");
686
(void) SCDRDI(imnob,"NPIX",1,naxis,&nval,npix,&unit,&null);
688
msize = 1; /* get total size of map */
689
for (n=0; n< naxis; n++) msize *= npix[n];
691
(void) SCFMAP(imnob,F_I_MODE,1,msize,&nval,&pntrb);
694
/* compute aux-variables:
696
(pix - pxlo)/(pxhi - pxlo) = (x - cuts[0])/(cuts[1] - cuts[0])
697
pix = pxlo + (x - cuts[0])*fact
698
with fact = (pxhi - pxlo)/(cuts[1] - cuts[0]) */
701
/* allocate virtual memory for in/out frame buffers with right data types */
703
if (sizze <= mapsize) mapsize = sizze;
704
(void) SCFCRE("work1",D_R4_FORMAT,F_X_MODE,F_IMA_TYPE,mapsize,&imnow1);
705
(void) SCFMAP(imnow1,F_X_MODE,1,mapsize,&nval,&pntra);
706
(void) SCFCRE("work2",D_R4_FORMAT,F_X_MODE,F_IMA_TYPE,mapsize,&imnow2);
707
(void) SCFMAP(imnow2,F_X_MODE,1,mapsize,&nval,&pntrc);
710
fact = (msize-1) / (cuts[1] - cuts[0]);
711
faux[0] = fact; faux[1] = cuts[0]; faux[2] = cuts[1];
713
printf("index-range = [1,%d], map-range = [%f,%f], \n",
714
msize,cuts[0],cuts[1]);
716
(void) SCDRDR(imnob,"LHCUTS",3,2,&nval,oldoo,&unit,&null);
717
if (oldoo[1] <= oldoo[0]) SCETER(24,"Invalid LHCUTS of mapfile...");
719
oo[0] = oldoo[1]; oo[1] = oldoo[0]; /* should be pixels in that interval */
720
oldoo[0] = oo[0]; oldoo[1] = oo[1];
723
/* now we do the mapping */
729
(void) SCFGET(imnoa,n,mapsize,&nval,pntra);
730
mappi(pntra,pntrb,pntrc,nval,faux,msize,scflag,oo);
731
(void) SCFPUT(imnoc,n,nval,pntrc);
733
if (oo[0] < oldoo[0]) oldoo[0] = oo[0];
734
if (oo[1] > oldoo[1]) oldoo[1] = oo[1];
738
(void) SCDCOP(imnoa,imnoc,1," "); /* copy all descriptors */
740
cuts[0] = cuts[1] = 0.0;
741
cuts[2] = oldoo[0]; cuts[3] = oldoo[1];
742
(void) SCDWRR(imnoc,"LHCUTS",cuts,1,4,&unit);
749
void copyii(infile,outfile)
750
char *infile, *outfile;
753
char cbuf[12], dely[8];
756
int naxis, npix[6], imnoa, imnob, imnow1, imnow2;
757
int felm, mapsize, sizze, clony;
758
int info[5], null, nval, unit;
759
int n, fmtin, fmtout, uflow, oflow;
764
(void) SCKGETC("P3",1,10,&nval,cbuf); /* get output format */
765
(void) SCKGETC("P4",1,7,&nval,dely); /* get delete flag */
767
(void) SCKRDI("MONITPAR",20,1,&nval,&n,&unit,&null); /* get mapping size */
770
(void) SCFINF(infile,2,info); /* get source format */
772
fmtout = check_fmt(cbuf);
773
if (fmtout < 0) SCETER(2,"invalid data format...");
776
(void) SCFOPN(infile,info[1],0,F_IMA_TYPE,&imnoa);
777
(void) SCDRDI(imnoa,"NAXIS",1,1,&nval,&naxis,&unit,&null);
778
if (naxis > 6) SCETER(3,"More than 6 dimensions...");
780
(void) SCDRDI(imnoa,"NPIX",1,naxis,&nval,npix,&unit,&null);
781
(void) SCDRDR(imnoa,"LHCUTS",1,4,&nval,cuts,&unit,&null);
783
uflow = 0; oflow = 0;
784
sizze = 1; /* get total size of frame */
785
for (n=0; n< naxis; n++)
788
/* (void) SCFCRE(outfile,fmtout,F_O_MODE,F_IMA_TYPE,size,&imnob); */
789
(void) CGN_IBUILD(imnoa,outfile,fmtout,sizze,&imnob,&clony);
792
/* allocate virtual memory for in/out frame buffers with right data types */
794
if (sizze <= mapsize) mapsize = sizze;
795
(void) SCFCRE("work1",fmtin,F_X_MODE,F_IMA_TYPE,mapsize,&imnow1);
796
(void) SCFMAP(imnow1,F_X_MODE,1,mapsize,&nval,&pntra);
800
(void) SCFCRE("work2",fmtout,F_X_MODE,F_IMA_TYPE,mapsize,&imnow2);
801
(void) SCFMAP(imnow2,F_X_MODE,1,mapsize,&nval,&pntrb);
807
/* now we do the conversion */
813
(void) SCFGET(imnoa,n,mapsize,&nval,pntra);
815
conv_pix(pntrb,pntra,fmtout,fmtin,nval);
816
(void) SCFPUT(imnob,n,nval,pntrb);
821
/* handle over, underflow */
823
if (fmtout == D_I1_FORMAT)
825
if (cuts[2] < 0) uflow = 1;
826
if (cuts[3] > 255) oflow = 1;
828
else if (fmtout == D_I2_FORMAT)
830
if (cuts[2] < -32768) uflow = 1;
831
if (cuts[3] > 32767) oflow = 1;
833
else if (fmtout == D_UI2_FORMAT)
835
if (cuts[2] < 0) uflow = 1;
836
if (cuts[3] > 65534) oflow = 1;
839
SCTPUT("Warning: Format conversion results in underflow...");
841
SCTPUT("Warning: Format conversion results in overflow...");
845
(void) SCDCOP(imnoa,imnob,1,cbuf); /* copy all descriptors */
847
n = CGN_INDEXC(dely,','); /* test history_update_flag */
853
if ((dely[1] == 'U') || (dely[1] == 'u'))
854
(void) CGN_DSCUPD(imnob,imnob," "); /* update history */
858
/* if delete flag set, delete the input frame */
860
if ((dely[0] == 'D') || (dely[0] == 'd')) (void) SCFDEL(infile);
867
void transcube(infile,outfile)
868
char *infile, *outfile;
871
char cbuf[12], temp[128];
874
static char workfile[] = "middummxyz.bdf";
876
int nobytes, mapsize, unit, null, fmtin;
877
int naxis, npix[3], newpix[3], imnoa, imnob, imnow, size;
878
int info[5], planedir, nval, mm[3];
881
double start[3], step[3], nstart[3], nstep[3];
884
(void) SCFINF(infile,2,info); /* get source format */
885
nobytes = info[0]; /* bytes per pixel */
889
(void) SCFOPN(infile,fmtin,0,F_IMA_TYPE,&imnoa);
890
(void) SCDRDI(imnoa,"NAXIS",1,1,&nval,&naxis,&unit,&null);
892
SCETER(3,"Input image has not 3 dimensions...");
893
(void) SCDRDI(imnoa,"NPIX",1,naxis,&nval,npix,&unit,&null);
894
(void) SCDRDD(imnoa,"START",1,naxis,&nval,start,&unit,&null);
895
(void) SCDRDD(imnoa,"STEP",1,naxis,&nval,step,&unit,&null);
898
/* create working frame (may be renamed to output frame) */
900
size = npix[0] * npix[1] * npix[2]; /* get total size of frame */
901
(void) SCFCRE(workfile,fmtin,F_O_MODE,F_IMA_TYPE,size,&imnob);
904
(void) SCKGETC("P3",1,4,&nval,cbuf); /* get plane specs */
907
if ( (strncmp(cbuf,"ZY",2) == 0) || (strncmp(cbuf,"YZ",2) == 0) )
912
planedir = Z_Y_PLANE;
916
"Warning: YZ-plane is handled as ZY-plane, i.e. rows are in z-direction...");
919
else if ( (strncmp(cbuf,"ZX",2) == 0) || (strncmp(cbuf,"XZ",2) == 0) )
924
planedir = X_Z_PLANE;
928
"Warning: ZX-plane is handled as XZ-plane, i.e. rows are in x-direction...");
932
SCETER(3,"Invalid plane specification...");
934
for (nr=0; nr<3; nr++)
936
newpix[nr] = npix[mm[nr]];
937
nstart[nr] = start[mm[nr]];
938
nstep[nr] = step[mm[nr]];
941
(void) SCDCOP(imnoa,imnob,1,cbuf); /* copy all descriptors */
942
(void) SCDWRI(imnob,"NPIX",newpix,1,naxis,&unit); /* update NPIX */
943
(void) SCDWRD(imnob,"START",nstart,1,naxis,&unit); /* update START */
944
(void) SCDWRD(imnob,"STEP",nstep,1,naxis,&unit); /* update STEP */
947
/* allocate virtual memory for buffer with right data types */
949
mapsize = newpix[0] * newpix[1];
950
(void) SCFCRE("work1",fmtin,F_X_MODE,F_IMA_TYPE,mapsize,&imnow);
951
(void) SCFMAP(imnow,F_X_MODE,1,mapsize,&nval,&pntra);
954
/* loop through YZ- or XZ_planes and store them as XY_plane into
957
for (nr=0; nr<newpix[2]; nr++)
960
(void) SCPGET(imnoa,planedir,mr,pntra);
961
(void) SCPPUT(imnob,X_Y_PLANE,mr,pntra);
964
CGN_DSCUPD(imnoa,imnob," "); /* update history */
967
/* now test if result should replace input frame or go to a new frame */
969
if (outfile[0] == '+')
970
CGN_CLEANF(infile,0,temp,120,&nval,&null);
972
CGN_CLEANF(outfile,0,temp,120,&nval,&null);
973
(void) SCFRNM(workfile,temp);
984
char infile[124], outfile[124], mapfile[124], cbuf[12];
989
(void) SCSPRO("genxy1");
991
(void) SCKGETC("IN_A",1,120,&nval,infile); /* get input frame */
992
(void) SCKGETC("OUT_A",1,120,&nval,outfile); /* get output frame */
994
(void) SCKGETC("ACTION",1,3,&nval,cbuf); /* get action flag */
996
if (strcmp(cbuf,"TRA") == 0)
997
transcube(infile,outfile);
999
else if (strcmp(cbuf,"COP") == 0)
1000
copyii(infile,outfile);
1002
else if (strcmp(cbuf,"CON") == 0)
1003
convert(infile,outfile);
1005
else if (strcmp(cbuf,"MAP") == 0)
1007
(void) SCKGETC("IN_B",1,120,&nval,mapfile);
1008
mapima(infile,mapfile,outfile);