/************************************************************************ * xyz2cm reads a file in xyz 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,pd; int time,idepth,pred; int id,nrec,sigh,sigd; if(argc < 5){ fprintf(stderr,"usage: %s sig_h sig_d 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," sig_d - depth uncertainty (m) (-1 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]); sigd=atoi(argv[2]); id=atoi(argv[3]); /* read all the data */ nrec=0; while (fscanf(stdin,"%lf %lf %lf",&lon,&lat,&depth) != 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[4],&lon,&lat,&pd); pred = floor(pd+.5); printf("%d %.5f %.5f %d %d %d %d %d \n",nrec,lon,lat,idepth,sigh,sigd,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); */ } }