/************************************************************************ * xyzs2cm reads a file in xyzs format and convert to the NAVO * * NGA, NOAA, SIO common format * ************************************************************************/ /************************************************************************ * Creator: * * Date : * ************************************************************************/ /************************************************************************ * Modification History: * * Date : * * * ************************************************************************/ #include #include #include #include "../../include/gmt.h" main(int argc, char **argv) { double lat,lon,depth,sigd,pd; int time,idepth,pred,isigd; int id,nrec,sigh; if(argc < 4){ fprintf(stderr,"usage: %s sig_h source_id topo.grd < file.xyz > file.cm\n\n",argv[0]); fprintf(stderr," sig_h - horizontal uncertainty (m) (0 no estimate)\n"); fprintf(stderr," source_id unique ID number for each file\n"); fprintf(stderr," topo.grd grd-file of predicted depth\n\n"); exit(-1); } /* parse the command line */ sigh=atoi(argv[1]); id=atoi(argv[2]); /* read all the data */ nrec=0; while (fscanf(stdin,"%lf %lf %lf %lf",&lon,&lat,&depth,&sigd) != EOF) { nrec++; /* prepare the data for output */ if(lon > 180.) lon = lon-360.; if(lon < -180.) lon = lon+360.; idepth=floor(depth+0.5); /* get the interpolated depth */ interp_topo(argv[3],&lon,&lat,&pd); pred = floor(pd+.5); isigd= floor(sigd+.5); printf("%d %.5f %.5f %d %d %d %d %d \n",nrec,lon,lat,idepth,sigh,isigd,id,pred); /* needed for lakes above sea level */ /*if(idepth < 0) printf("%d %.5f %.5f %d %d %d %d %d \n",nrec,lon,lat,idepth,sigh,sigd,id,pred); */ } }