/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .COPYRIGHT (c) 1996 European Southern Observatory .IDENT tbl2bdf.c .LANGUAGE C .AUTHOR P. Grosbol ESO/IPG .KEYWORDS 3D-table, convert, image .ENVIRON MIDAS .PURPOSE Convert a 3D-table column to a image file .VERSION 1.0 1996-Apr-12 : Creation, PJG ------------------------------------------------------------------------*/ #include /* Mathematical macros */ #include /* String handling macros */ #include #include "midas_def.h" /* MIDAS definitions */ #define MXDIM 16 /* Max. image dimension */ #define MXPAR 64 /* Max. char. in parameter string */ #define MXNAME 129 /* Max. length of file name */ main() { char *pc, *buf, *cstart, *cstep, *cunit; char col[MXPAR], row[MXPAR], tname[MXPAR], pfix[MXPAR]; char dim[MXPAR], coor[MXPAR], iname[MXNAME], text[MXNAME]; char ident[MXPAR]; int fid, tid, nident, ndim, ncol, nstr, nstp, nrlo, nrhi; int n, err, nr, nb, ns, iva, inull, sf, dt_double; int mcol, mrow, msort, macol, marow; int dt, dtdim, items, msize, maxis, dtcol; int mident, mstr, mstp, dtstr, dtstp; int npix[MXDIM], kunit[4]; float *fbuf, f, cut[4]; double *dbuf, d, cl, ch, step[MXDIM], start[MXDIM]; SCSPRO("TBL2BDF"); /* initiate MIDAS environment */ /* get table name and open it */ err = SCKGETC("IN_A", 1, MXPAR-1, &iva, tname); err = TCTOPN(tname, F_I_MODE, &tid); err = TCIGET(tid, &mcol, &mrow, &msort, &macol, &marow); /* get name of column which should be converted to an image */ err = SCKGETC("INPUTC", 1, MXPAR-1, &iva, col); err = TCCSER(tid, col, &ncol); err = TCBGET(tid, ncol, &dtcol, &items, &nb); dt_double = (dtcol == D_R8_FORMAT); /* get range of rows to convert */ err = SCKGETC("ROW", 1, MXPAR-1, &iva, row); nrlo = 1; nrhi = mrow; if (row[0] != '*') { nr = atol(strtok(row, ",")); nr = (nr<1) ? 1 : ((mrow%s<",cstart); else sprintf(text,"Error: Inconsistent size of column >%s<",cstep); SCETER(4, text); } } else if (coor[0] != '*') { n = 0; start[n++] = atof(strtok(coor, ",")); while ((pc=strtok(NULL, ",")) && n%s,%s,@%d<",tname,col,nr); /* create new image file */ sprintf(iname,"%s%04d",pfix,nr); dt = (dt_double) ? D_R8_FORMAT : D_R4_FORMAT; err = SCFCRE(iname, dt, F_O_MODE, F_IMA_TYPE, msize, &fid); iva = 1; ns = msize; while (0%s< created, npix:%5d,%5d",iname,npix[0],npix[1]); else sprintf(text," Frame >%s< created, npix:%5d",iname,npix[0]); SCTPUT(text); } /* close files and exit */ free(buf); TCTCLO(tid); SCSEPI(); }