/* @(#)ostcrea.c 17.1.1.1 (ESO-DMD) 01/25/02 17:50:05 */ /*=========================================================================== Copyright (C) 1995 European Southern Observatory (ESO) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. Correspondence concerning ESO-MIDAS should be addressed as follows: Internet e-mail: midas@eso.org Postal address: European Southern Observatory Data Management Division Karl-Schwarzschild-Strasse 2 D 85748 Garching bei Muenchen GERMANY ===========================================================================*/ /*--------------------------------------------------------------------- .TYPE Module .NAME ostcrea.c .LANGUAGE C .AUTHOR IPG-ESO Garching .CATEGORY Data Organizer utilities .COMMENTS This module implements the following Midas commands: \begin{TeX} \begin{enumerate} \item \end{enumerate} \end{TeX} .VERSION 1.0 15-Mar-1993 Definition M. Peron 010116 last modif -------------------------------------------------------------------*/ #ifndef vms /* dirent.h does not exist on vms */ #include #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #define NM 61 #define NT 6 #define SLEN 256 #define NLAB 17 #define MXLIST 64 char *getnext() ; static int lno = -1; /* no. to current list range */ static struct { /* structure with list of no's */ int first; /* first no. in range */ int last; /* last no. of in range */ } list[MXLIST]; /* #ifndef vms struct dirent *oslread(); #endif */ char *getnext(); unsigned long ccitt32_updcrc(); double otimetomjd(); int listtype,no,tidtemp,colfile,nenttemp,lname; int kuni; char cext[4]; char finame[128],diname[128]; /* */ int ostcrea(flist,pfix,intable,outable,flag) char flist[128],intable[60],outable[60],flag[4],pfix[5]; { int htype,ktype,mfd,nll,err,nchar,knewtype,nent,newnoelem; int dummy,dummy1,i,j,k,l,n, nocat,notrue,fd,newtab,nsel,sel ; int status,tid,nrow,kcol,fcol,otid,ormf,nb,imno ; int pcol,kncol,tcol,incr; int noelem[SLEN], noelembis,ocol[SLEN],colf; int *ipos,ontype,poss,*keyival[256], unit; int null, nl, fin,dfmt,flen; int one,zero,loc,size,upda; int naxis,npix[3],ocolmjd,ocolmean,ocolsigma,ocolmprime,ocolsigprime; int ocolaz,ocolal,ocoldate,close; int fid; /* file descr. returned by dopen. CG 3/6/98 */ int MxMdb; /* now the no. of used entries in mdbuf (KB) */ unsigned long crc; float ms[2],*keyrval[256],fac,zeroi,*image, min, max; float sparam[8]; double start[3],step[3],dval,mjd,date,time,ra,dec,lst,*keydval[256]; double azimuth,altitude,mydate; char fmt,hist,*valc,*buffer; char filename[80],dinewname[128]; char *line,incata[60],cpos[4]; char *cdummy, type,*nfn,devt; char form[1+TBL_FORLEN],*temp, *otype,*oform; char *keyname,*label,*area,defaul[5]; char *keyword = "key_iname"; char *mylabel; char *keycval[256],fflist[128]; BFDEF *bfdef,*hdr_init(); KWORD kw; MDBUF *mdbuf,*mdb_init(); ADEF *ad; status = TCTOPN(intable,F_I_MODE,&tid) ; status = TCIGET(tid,&dummy,&nrow,&dummy,&dummy,&dummy); status = TCSCNT(tid,&nsel); for (i=0; i<256; i++) { keycval[i] = (char *)0; keyival[i] = (int *) 0; keydval[i] = (double *) 0; keyrval[i] = (float *) 0; } ormf = 0; l =0; no = 1; listtype = 0; close = 0; strcpy(fflist,flist); for (i=0; i= 0) { if (nchar == 0 ) continue; if (0naxis); } if (stucomp("NPIX",keyname + i * NM) == 0) { if (ocol[i] == -1) { ontype = D_I4_FORMAT; noelem[i] = 1; strcpy(form,"I8"); strcpy(mylabel,label+i*NLAB); if (*(ipos+i) != 1){ sprintf(cpos,"_%d",*(ipos+i)); strcat(mylabel,cpos); } TCCINI(otid,ontype,noelem[i],form," ", mylabel,&ocol[i]); } TCEWRI(otid,notrue,ocol[i],&bfdef->data[ipos[i]-1].naxis); } if (stucomp("START",keyname + i * NM) == 0) { if (ocol[i] == -1) { ontype = D_R8_FORMAT; noelem[i] = 1; strcpy(form,"E24.17"); strcpy(mylabel,label+i*NLAB); if (*(ipos+i) != 1){ sprintf(cpos,"_%d",*(ipos+i)); strcat(mylabel,cpos); } TCCINI(otid,ontype,noelem[i],form," ", mylabel,&ocol[i]); } ad = &bfdef->data[ipos[i]]; dval = ad->crval - (ad->crpix-1.0) * ad->cdelt; TCEWRD(otid,notrue,ocol[i],&dval); } if (stucomp("IDENT",keyname + i * NM) == 0){ if (ocol[i] == -1) { ontype = D_C_FORMAT; noelem[i] = 72; sprintf(form,"A%d",noelem[i]); TCCINI(otid,ontype,noelem[i],form," ", label+i*NLAB,&ocol[i]); } TCEWRC(otid,notrue,ocol[i],bfdef->ident); } } mjd = ra = dec = time = 0; MxMdb = mdb_size(); /* get no. of used entries in mdbuf */ for (i=0; idata[0].naxis * bfdef->data[1].naxis * bfdef->bitpix / 8; size = ABSOLUTE(size); image = (float *) osmmget(bfdef->data[0].naxis * bfdef->data[1].naxis * 4); i=0; min = MAXFLOAT; max = -1E+38; n=0; incr = 0; while (0data[0].naxis * bfdef->data[1].naxis ; npix[0] = bfdef->data[0].naxis; npix[1] = bfdef->data[1].naxis; dfmt = bfdef->bitpix; fac = bfdef->bscale; zero = bfdef->bzero; /*for (i=0; i max) max = *(image+i); } printf("min:%f, max:%f\n",min,max); crc = ccitt32_updcrc(crc, image, size); printf("crc:%d\n", crc); */ cstat(image,npix,sparam); if (flag[2] == 'S' || flag[2] == 's') { TCEWRR(otid,notrue,ocolmean,&sparam[0]); TCEWRR(otid,notrue,ocolsigma,&sparam[1]); } else { TCEWRR(otid,notrue,ocolmean,&sparam[0]); TCEWRR(otid,notrue,ocolsigma,&sparam[1]); TCEWRR(otid,notrue,ocolmprime,&sparam[4]); TCEWRR(otid,notrue,ocolsigprime,&sparam[5]); } osmmfree((char *)image); } if (flag[0] == 'F' || flag[0] == 'f') dclose(fid); else osaclose(fd); } } else { while ((nfn = getnext(pfix)) != NULL) { SCFOPN(nfn,D_R4_FORMAT,F_I_MODE,F_IMA_TYPE,&imno); notrue++; TCEWRC(otid,notrue,colf,nfn); for (i=0; i nenttemp) return(NULL); else { TCERDC(tidtemp,nel,colfile,fname,&null); nel++; return(fname); } } else { #ifndef vms itisdir = 0; while (!itisdir) { if ((dirp = oslread()) == NULL) return(NULL); else { if (diname[0] =='.' && diname[1] == '/') strcpy(oname,dirp->d_name); else { strcpy(oname,diname); strcat(oname,dirp->d_name); } osfinfo(oname,&mystatus); if (S_ISDIR(mystatus.protection)) continue; else return(oname); } } #else return(NULL); #endif } } int openlist(plist) char *plist; /* pointer to list specification */ { char c; int l,ldig,n,nelem; nelem = 0; lno = -1; for (n=0; n