int main(int argc, char **argv) { float **data; char **hdrdata; float ***workm; int ival2; /* int value of key2 */ int ival3; /* int value of key3 */ Value val2; /* ... its value */ Value val3; /* ... its value */ int index2; int index3; int n1,n2,n3; int i1,i2,i3; char *key2=NULL; /* header key word from segy.h */ char *type2=NULL; /* ... its type */ char *key3=NULL; /* header key word from segy.h */ char *type3=NULL; /* ... its type */ int lins; int line; int nl; int dir=2; int il; int su; float cdp; float t; float dt; /* Initialize */ initargs(argc, argv); requestdoc(1); MUSTGETPARINT("n2", &n2); MUSTGETPARINT("n3", &n3); /* get key2*/ if (!getparstring("key2", &key2)) key2 = "fldr"; type2 = hdtype(key2); index2 = getindex(key2); /* get key3*/ if (!getparstring("key3", &key3)) key3 = "tracf"; type3 = hdtype(key3); index3 = getindex(key3); if (!getparint("lins", &lins)) lins = 1; if(lins<1) err(" lins must be larger than 0"); if (!getparint("line", &line)) line = n2; if (!getparint("su", &su)) su = 1; /* Get info from first trace */ if (!gettr(&tr)) err ("can't get first trace"); n1 = tr.ns; if (!getparfloat("dt", &dt)) dt = ((float) tr.dt)/1000000.0; if (!dt) { dt = .01; warn("dt not set, assumed to be .01"); } data = bmalloc(n1*sizeof(float),n2,n3); hdrdata = bmalloc(HDRBYTES,n2,n3); do { gethval(&tr, index2, &val2); ival2 = vtoi(type2,val2); gethval(&tr, index3, &val3); ival3 = vtoi(type3,val3); if(ival2>n2 || ival2<0 ) err(" Array in dimension 2 out of bound\n"); if(ival3>n3 || ival3<0 ) err(" Array in dimension 3 out of bound\n"); bmwrite(data,1,ival2-1,ival3-1,1,tr.data); bmwrite(hdrdata,1,ival2-1,ival3-1,1,&tr); } while (gettr(&tr)); nl=line-lins+1; if(dir==2) { /* n2 direction */ workm = alloc3float(n1,n3,nl); for(il=lins-1;il<nl;il++) { for(i3=0;i3<n3;i3++) bmread(data,1,lins+il-1,i3,1,workm[il][i3]); } if(su==1) { fprintf(stdout,"cdp="); for(il=lins-1;il<nl;il++) { for(i3=0;i3<n3;i3++) fprintf(stdout,"%d,",(lins+il)*1000+i3+1); } for(il=lins-1;il<nl;il++) { for(i3=0;i3<n3;i3++){ fprintf(stdout,"\ntnmo="); for(i1=0;i1<n1;i1++) fprintf(stdout,"%.3f,",dt*i1); fprintf(stdout,"\nvnmo="); for(i1=0;i1<n1;i1++) fprintf(stdout,"%.3f,",workm[il][i3][i1]); } } } else { for(il=lins-1;il<nl;il++) { for(i3=0;i3<n3;i3++) { cdp=(lins+il)*1000+i3+1; fwrite(&cdp,sizeof(float),1,stdout); } } for(il=lins-1;il<nl;il++) { for(i3=0;i3<n3;i3++){ for(i1=0;i1<n1;i1++) { t=tr.d1*i1; fwrite(&t,sizeof(float),1,stdout); } for(i1=0;i1<n1;i1++) fwrite(&workm[il][i3][i1],sizeof(float),1,stdout); } } } free3float(workm); } bmfree(data); bmfree(hdrdata); return EXIT_SUCCESS; }
int main(int argc, char **argv) { int gelev_vmin, gelev_vmax, selev_vmin, selev_vmax; int gelev_min, gelev_max, selev_min, selev_max; int gelev_globalmin, gelev_globalmax, selev_globalmin, selev_globalmax; int gelev_num, selev_num; int imin, iminv, ifirst, nz1, nz, ns, ntr, ntrv, nsv; double dfirst, delrt, delrtv, twt, dt, dtv, factor, z, amp_out; double *depth, *tr_amp; float ***velocity; short verbose; register int i, j, k, l; cwp_String vfile; FILE *fv; initargs(argc, argv); requestdoc (0); if (!getparshort("verbose", &verbose)) verbose = 1; if (!getparstring("vfile",&vfile)) vfile = "output.su"; ntr = gettra (&tr, 0); fv = efopen (vfile, "r"); ntrv = fgettra (fv, &vtr, 0); delrt = tr.delrt; delrtv = vtr.delrt; if (!getparint("ns", &ns)) ns = tr.ns; if (!getparint("nsv", &nsv)) nsv = vtr.ns; if (!getparint("nz", &nz)) nz=2000; dt = tr.dt * 0.001; dtv = vtr.dt * 0.001; imin = nint ( delrt / dt ); iminv = nint ( delrtv / dtv ); depth = ealloc1double ( ns ); tr_amp = ealloc1double ( ns ); factor = 0.0005; if ( verbose ) { fprintf ( stderr, "\n" ); fprintf ( stderr, "Number of input traces = %d\n", ntr ); fprintf ( stderr, "Number of input samples per trace = %d\n", ns ); fprintf ( stderr, "Number of output samples per trace = %d\n", nz ); fprintf ( stderr, "Sample rate = %f ms.\n", dt ); fprintf ( stderr, "Average velocity SU file name = %s\n", vfile ); fprintf ( stderr, "Number of VAVG input traces = %d\n", ntrv ); fprintf ( stderr, "Number of VAVG input samples per trace = %d\n", nsv ); fprintf ( stderr, "VAVG Sample rate = %f ms.\n", dtv ); fprintf ( stderr, "Input Delay = %f ms., First sample = %d\n", delrt, imin ); fprintf ( stderr, "Velocity Delay = %f ms., First sample = %d\n", delrtv, iminv ); fprintf ( stderr, "\n" ); } rewind ( fv ); gelev_vmin = selev_vmin = INT_MAX; gelev_vmax = selev_vmax = INT_MIN; for ( i = 0; i < ntrv; ++i ) { fgettr (fv, &vtr); gelev_vmin = min ( gelev_vmin, vtr.gelev ); gelev_vmax = max ( gelev_vmax, vtr.gelev ); selev_vmin = min ( selev_vmin, vtr.selev ); selev_vmax = max ( selev_vmax, vtr.selev ); } if ( verbose ) fprintf ( stderr, "VELOCITY DATA - gelev_vmin = %d, gelev_vmax = %d, selev_vmin = %d, selev_vmax = %d\n", gelev_vmin, gelev_vmax, selev_vmin, selev_vmax ); rewind (stdin); gelev_min = selev_min = INT_MAX; gelev_max = selev_max = INT_MIN; for ( i = 0; i < ntr; ++i ) { gettr (&tr); gelev_min = min ( gelev_min, tr.gelev ); gelev_max = max ( gelev_max, tr.gelev ); selev_min = min ( selev_min, tr.selev ); selev_max = max ( selev_max, tr.selev ); } if ( verbose ) fprintf ( stderr, "INPUT DATA - gelev_min = %d, gelev_max = %d, selev_min = %d, selev_max = %d\n", gelev_min, gelev_max, selev_min, selev_max ); gelev_globalmin = max ( gelev_min, gelev_vmin ); selev_globalmin = max ( selev_min, selev_vmin ); gelev_globalmax = min ( gelev_max, gelev_vmax ); selev_globalmax = min ( selev_max, selev_vmax ); gelev_num = gelev_globalmax - gelev_globalmin + 1; selev_num = selev_globalmax - selev_globalmin + 1; if ( verbose ) { fprintf ( stderr, "\n" ); fprintf ( stderr, "gelev_globalmin = %d, gelev_globalmax = %d, selev_globalmin = %d, selev_globalmax = %d\n", gelev_globalmin, gelev_globalmax, selev_globalmin, selev_globalmax ); fprintf ( stderr, "gelev_num = %d, selev_num = %d\n", gelev_num, selev_num ); } velocity = ealloc3float ( nsv, selev_num, gelev_num ); rewind ( fv ); ifirst = 0; dfirst = 9999999999999999.9; for ( k = 0; k < ntrv; ++k ) { fgettr (fv, &vtr); if ( vtr.gelev >= gelev_globalmin && vtr.gelev <= gelev_globalmax && vtr.selev >= selev_globalmin && vtr.selev <= selev_globalmax ) { i = vtr.gelev - gelev_globalmin; j = vtr.selev - selev_globalmin; memcpy( (void *) &velocity[i][j][0], (const void *) &vtr.data, nsv * FSIZE ); dfirst = min ( dfirst, velocity[i][j][0] * delrtv * factor ); } } efclose (fv); ifirst = nint ( dfirst / dt ); nz1 = nz - ifirst; if ( verbose ) fprintf ( stderr, "ifirst = %d, dfirst = %f, nz1 = %d\n", ifirst, dfirst, nz1 ); float zero; double depth_max; zero = 0.0; rewind (stdin); for ( l = 0; l < ntr; ++l ) { gettr (&tr); if ( tr.gelev >= gelev_globalmin && tr.gelev <= gelev_globalmax && tr.selev >= selev_globalmin && tr.selev <= selev_globalmax ) { i = tr.gelev - gelev_globalmin; j = tr.selev - selev_globalmin; for ( k = 0; k < nsv; ++k ) { twt = ( k * dtv ) + delrtv; tr_amp[k] = tr.data[k+iminv]; depth[k] = velocity[i][j][k] * twt * factor; } depth_max = depth[nsv-1]; fprintf ( stderr, "trace number = %5d, depth_max = %f\n", l, depth_max ); for ( k=ifirst; k < nz1; ++k ) { z = k * dt; if ( z <= depth_max ) { dintlin ( nsv, depth, tr_amp, tr_amp[0], tr_amp[nsv-1], 1, &z, &_out ); tr.data[k-ifirst] = (float) amp_out; } else { tr.data[k-ifirst] = zero; } } tr.trid = 1; tr.ns = nsv; tr.delrt = nint ( dfirst ); tr.dt = nint(dt*1000); puttr (&tr); } } free1double (tr_amp); free1double (depth); free3float (velocity); return EXIT_SUCCESS; }
int main(int argc, char **argv) { int n1; /*number of samples in the fastest direction.*/ int n2; /*number of samples in the 2nd direction*/ int n3; /*number of samples in slownest direction*/ int n1s; /*stride in the fastest direction.*/ int n2s; /*stride in the 2nd direction*/ int n3s; /*stride in slownest direction*/ int i1,i2,i3; int i1min,i1max; /*indice for min max in n1*/ int i2min,i2max; /*indice for min max in n2*/ int i3min,i3max; /*indice for min max in n3*/ int newn1,newn2,newn3; int i1new,i2new,i3new; float v0; float emission[4]; float ***data; /*data for plotting*/ float ***emis; /*emission for plotting*/ int verbose; /*if =1 print some useful information*/ float ***cube; /*the 3D data set*/ float vmin; float vmax; float xmin,xmax; float ymin,ymax; float zmin,zmax; float eyez; float q0[4]; int cx,cy,cz; /*center of the 1st, 2nd and 3rd view plane*/ /* hook up getpar */ initargs(argc,argv); requestdoc(1); /* get parameters */ if (!getparint("n1",&n1)) err("Must specify n1"); if (!getparint("n2",&n2)) err("Must specify n2\n"); if (!getparint("n3",&n3)) err("Must specify n3\n"); if (!getparint("n1s",&n1s)) n1s=1; if (!getparint("n2s",&n2s)) n2s=1; if (!getparint("n3s",&n3s)) n3s=1; if (!getparint("hue",&glb_hue)) glb_hue=1; /*1 for glb_hue*/ if (!getparfloat("tbs",&tbs)) tbs=0.8; if (glb_hue!=0) glb_hue=1; if (n1<1) err("n1=%d < 1",n1); if (n2<1) err("n2=%d < 1",n2); if (n3<1) err("n3=%d < 1",n3); n1s=MAX(1,n1s); n1s=MIN(n1,n1s); n2s=MAX(1,n2s); n2s=MIN(n2,n2s); n3s=MAX(1,n3s); n3s=MIN(n3,n3s); newn1=MAX(2,n1/n1s); newn2=MAX(2,n2/n2s); newn3=MAX(2,n3/n3s); if (!getparint("verbose",&verbose)) verbose=0; if (!getparint("cx",&cx)) cx=n2/2; if (!getparint("cy",&cy)) cy=n3/2; if (!getparint("cz",&cz)) cz=n1/2; cx=MAX(0,MIN(newn2-1,cx/n2s)); cy=MAX(0,MIN(newn3-1,cy/n3s)); cz=MAX(0,MIN(newn1-1,cz/n1s)); if (verbose) { warn("newn1=%d\nnewn2=%d\nnewn3=%d\ncx=%d\ncy=%d\ncz=%d", newn1,newn2,newn3,cx,cy,cz); warn("hue=%d",glb_hue); } cube=ealloc3float(newn1,newn2,newn3); for (i3=0;i3<n3;i3++) { for (i2=0;i2<n2;i2++) { for (i1=0;i1<n1;i1++) { if (fread(&v0,sizeof(float),1,stdin)!=1) err("Can not read in cube"); if ( i3%n3s==0 && i2%n2s==0 && i1%n1s==0) { i3new=MIN(newn3-1,i3/n3s); i2new=MIN(newn2-1,i2/n2s); i1new=MIN(newn1-1,i1/n1s); cube[i3new][i2new][i1new]=v0; if (n1/n1s<2) cube[i3new][i2new][1]=cube[i3new][i2new][0]; if (n2/n2s<2) cube[i3new][1][i1new]=cube[i3new][0][i1new]; if (n3/n3s<2) cube[1][i2new][i1new]=cube[0][i2new][i1new]; } } } } n1=newn1; n2=newn2; n3=newn3; zmin=0; zmax=MAX(n1-1,1); ymin=0; ymax=MAX(n3-1,1); xmin=0; xmax=MAX(n2-1,1); glb_plane_flag=(enum On_or_Off *)ealloc1int(3); glb_plane_flag[2]=OFF; glb_plane_flag[1]=ON; glb_plane_flag[0]=OFF; glb_plot_axis=DO_NOT_PLOT_AXIS; vmin=cube[0][0][0]; vmax=vmin; i1min=i2min=i3min=0; i1max=i2max=i3max=0; for (i1=0;i1<n1;i1++) { for (i2=0;i2<n2;i2++) { for (i3=0;i3<n3;i3++) { if (vmin<cube[i3][i2][i1]) { i3min=i3; i2min=i2; i1min=i1; vmin=cube[i3][i2][i1]; } if (vmax>cube[i3][i2][i1]) { i3max=i3; i2max=i2; i1max=i1; vmax=cube[i3][i2][i1]; } } } } fprintf(stderr, "max value=%e, at i3=%d i2=%d i1=%d\n",vmin,i3min,i2min,i1min); fprintf(stderr, "min value=%e, at i3=%d i2=%d i1=%d\n",vmax,i3max,i2max,i1max); glutInit(&argc, argv); glutInitWindowSize(512, 512); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("trip"); glutDisplayFunc(redraw); glutIdleFunc(NULL); if (!getparfloat("q",q0)){ q0[0]=-0.6; q0[1]=0.05; q0[2]=-0.06; q0[3]=0.8; } normalize_quat(q0); curquat[0]=q0[0]; curquat[1]=q0[1]; curquat[2]=q0[2]; curquat[3]=q0[3]; glutReshapeFunc(myReshape); glutVisibilityFunc(vis); glutMouseFunc(mouse); glutMotionFunc(motion); glutCreateMenu(controlPanel); glutAddMenuEntry("Full screen",1); glutAddMenuEntry("Quit", 2); glutAddMenuEntry("First vertical plane",3); glutAddMenuEntry("Second vertical plane",4); glutAddMenuEntry("Horizontal plane",5); glutAddMenuEntry("Plot Axes",6); glutAttachMenu(GLUT_RIGHT_BUTTON); glShadeModel(GL_SMOOTH); /* colors will be continuous */ glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glLineWidth(1.0); glMatrixMode(GL_PROJECTION); eyez=25; gluPerspective( 40.0, /*fovy: view angle in y direction*/ 1.0, /*aspect: ratio of width (x) to y (height)*/ eyez-DIAMETER, /*near clipping plane*/ eyez+DIAMETER); /*far clipping plane*/ glMatrixMode(GL_MODELVIEW); gluLookAt( 0.0, 0.0, eyez, /*(eyex,eyey,eyez): the eye position*/ 0.0, 0.0, 0.0, /*(centerx,centery,centerz): the center*/ 0.0, 1.0, 0.0); /*(upx,upy,upz): the up direction*/ glPushMatrix(); /**************************************************** Let's plot the first vertical plane (facing x-axis): ****************************************************/ data=ealloc3float(3,n1,n3); emis=ealloc3float(4,n1,n3); for (i1=0;i1<n1;i1++) { for (i3=0;i3<n3;i3++) { data[i3][i1][0]=((cx-xmin)/(xmax-xmin)-0.5)*DIAMETER; data[i3][i1][1]=((i3-ymin)/(ymax-ymin)-0.5)*DIAMETER; data[i3][i1][2]=((i1-zmin)/(zmax-zmin)-0.5)*DIAMETER; v0=cube[i3][cx][i1]; zmEmission(v0,vmin,vmax,emis[i3][i1]); } } showPlane( 3, /*list of plot*/ data, /*2-D plane data*/ emis, /*emission*/ n3, /*slow dimension in the 2D data*/ n1); /*fast dimension in the 2D data*/ free3float(data); free3float(emis); /**************************************************** Let's plot the second vertical plane (facing y-axis): ****************************************************/ data=ealloc3float(3,n1,n2); emis=ealloc3float(4,n1,n2); for (i1=0;i1<n1;i1++) { for (i2=0;i2<n2;i2++) { data[i2][i1][0]=((i2-xmin)/(xmax-xmin)-0.5)*DIAMETER; data[i2][i1][1]=((cy-ymin)/(ymax-ymin)-0.5)*DIAMETER; data[i2][i1][2]=((i1-zmin)/(zmax-zmin)-0.5)*DIAMETER; v0=cube[cy][i2][i1]; zmEmission(v0,vmin,vmax,emis[i2][i1]); } } showPlane( 4, /*list of plot*/ data, /*2-D plane data*/ emis, /*emission*/ n2, /*slow dimension in the 2D data*/ n1); /*fast dimension in the 2D data*/ free3float(data); free3float(emis); /**************************************************** Let's plot the horizontal plane: ****************************************************/ data=ealloc3float(3,n3,n2); emis=ealloc3float(4,n3,n2); for (i3=0;i3<n3;i3++) { for (i2=0;i2<n2;i2++) { data[i2][i3][0]=((i2-xmin)/(xmax-xmin)-0.5)*DIAMETER; data[i2][i3][1]=((i3-ymin)/(ymax-ymin)-0.5)*DIAMETER; data[i2][i3][2]=((cz-zmin)/(zmax-zmin)-0.5)*DIAMETER; v0=cube[i3][i2][cz]; zmEmission(v0,vmin,vmax,emis[i2][i3]); } } showPlane( 5, /*list of plot*/ data, /*2-D plane data*/ emis, /*emission*/ n2, /*slow dimension in the 2D data*/ n3); /*fast dimension in the 2D data*/ free3float(data); free3float(emis); /*show axes*/ glNewList(6,GL_COMPILE); glLineWidth(1.5); emission[0]=1.0; emission[1]=1.0; emission[2]=1.0; emission[3]=1.0; glMaterialfv(GL_FRONT,GL_EMISSION,emission); glBegin(GL_LINES); glVertex3f(0.0,0.0,0.0); glVertex3f(RADIUS,0.0,0.0); glEnd(); glBegin(GL_LINES); glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,RADIUS,0.0); glEnd(); glBegin(GL_LINES); glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,0.0,-RADIUS); glEnd(); glEndList(); glutMainLoop(); return 0; }
int main(int argc, char **argv) { int ix; /*index for nx*/ int iy; /*index for ny*/ int nx; /*number of sampels in horizon*/ int ny; /*number of sampels in horizon*/ float xmin,xmax; float ymin,ymax; float zmin,zmax; float ***databot; /*data for plotting*/ float ***datatop; float ***emisbot; /*color on top horizon*/ float ***emistop; /*color right above base horizon*/ float v0; int verbose; /*if =1 print some useful information*/ float eyez; int ihz; /*index for interfaces*/ int *ntris; /*number of triangles*/ int nt; /*number of samples in each ray*/ int iray; /*index for nrays*/ int it; /*index for nt*/ int iw,iwf,nwf; int is,ns; /*number of sources*/ float q0[4]; char *rayfile=""; /*ray file*/ char *wffile=""; char *sttfile=""; FILE *rayfp=NULL; FILE *wffp=NULL; FILE *sttfp=NULL; Layer *horz; Layer *ray; Layer *wf; float vmin=99999.0; float vmax=0.0; float tt; /*debugging information in the ray file*/ int itri; char names[10]; int iflag; /*flag: =1 means ray effective*/ float emission[4]; float tmax=0.0,tmin=FLT_MAX; float ***stt=NULL; float **ttt=NULL; int ntr; /* hook up getpar */ initargs(argc,argv); requestdoc(1); /* get parameters */ if (!getparint("verbose",&verbose)) verbose=0; /****************************************** Read model parameters from hzfile ******************************************/ fread(&nhz,sizeof(int),1,stdin); fread(&nx,sizeof(int),1,stdin); fread(&ny,sizeof(int),1,stdin); fread(&xmin,sizeof(float),1,stdin); fread(&xmax,sizeof(float),1,stdin); fread(&ymin,sizeof(float),1,stdin); fread(&ymax,sizeof(float),1,stdin); fread(&zmin,sizeof(float),1,stdin); fread(&zmax,sizeof(float),1,stdin); if (verbose) fprintf(stderr,"xmin=%f\nxmax=%f\nymin=%f\nymax=%f\nzmin=%f\nzmax=%f\n", xmin,xmax,ymin,ymax,zmin,zmax); if (getparstring("rayfile",&rayfile)) if ((rayfp=fopen(rayfile,"r"))==NULL) err("Can not open rayfile %s",rayfile); if (getparstring("wffile",&wffile)) if ((wffp=fopen(wffile,"r"))==NULL) err("Can not open wffile %s",wffile); if (getparstring("sttfile",&sttfile)) if ((sttfp=fopen(sttfile,"r"))==NULL) err("Can not open sttfile %s",sttfile); if (!getparfloat("tbs",&tbs)) tbs=0.8; if (!getparint("hue",&glb_hue)) glb_hue=1; /*1 for glb_hue*/ if (verbose) warn("nhz=%d, nx=%d, ny=%d\n",nhz,nx,ny); glb_on_or_off=(enum On_or_Off *)ealloc1int(3*nhz+6); for (ihz=0;ihz<nhz;ihz++) glb_on_or_off[ihz]=ON; horz=(Layer *)alloc1float(sizeof(Layer)*(nhz+1)); /********************************************************* Do not use GLUT_INDEX, which gives no image; GLUT_SINGLE will cause redrawing every time you retate it; *********************************************************/ glutInit(&argc, argv); glutInitWindowSize(768,768); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("viewer3"); glutDisplayFunc(redraw); glutIdleFunc(NULL); if (!getparfloat("q",q0)){ q0[0]=-0.6; q0[1]=0.05; q0[2]=-0.06; q0[3]=0.8; } checkpars(); normalize_quat(q0); curquat[0]=q0[0]; curquat[1]=q0[1]; curquat[2]=q0[2]; curquat[3]=q0[3]; glutReshapeFunc(myReshape); glutVisibilityFunc(vis); glutMouseFunc(mouse); glutMotionFunc(motion); glutCreateMenu(controlLights); glutAddMenuEntry("Quit",-1); glutAddMenuEntry("Full Screen",0); glutAddMenuEntry("White/Color Rays",1); glutAddMenuEntry("Plot Rays",2); glutAddMenuEntry("Surface Traveltimes",3); glutAddMenuEntry("Wired or Solid WFs",4); glutAddMenuEntry("Plot Wavefronts",5); glutAddMenuEntry("TRI or TETRA or LAYER or HORZ",6); for (ihz=0;ihz<nhz;ihz++) { sprintf(names,"Layer %d",ihz+1); glutAddMenuEntry(names,ihz+7); } glutAttachMenu(GLUT_RIGHT_BUTTON); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); eyez=25; glMatrixMode(GL_PROJECTION); gluPerspective( 40.0, /*fovy: view angle in y direction*/ 1.0, /*aspect: ratio of width (x) to y (height)*/ eyez-DIAMETER, /*near clipping plane*/ eyez+DIAMETER); /*far clipping plane*/ glMatrixMode(GL_MODELVIEW); gluLookAt( 0.0, 0.0, eyez, /*(eyex,eyey,eyez): the eye position*/ 0.0, 0.0, 0.0, /*(centerx,centery,centerz): the center*/ 0.0, 1.0, 0.0); /*(upx,upy,upz): the up direction*/ glPushMatrix(); /*the order that tetramod uses is like this*/ for (ihz=0;ihz<nhz;ihz++) { fprintf(stderr,"reading horizon information %d\n",ihz); /********************************************************** input the horizon information from file hzfile: **********************************************************/ horz[ihz].x=ealloc2float(nx,ny); horz[ihz].y=ealloc2float(nx,ny); horz[ihz].z=ealloc2float(nx,ny); horz[ihz].v0=ealloc2float(nx,ny); horz[ihz].v1=ealloc2float(nx,ny); fprintf(stderr,"read horz[%d].x...\n",ihz); if (fread(horz[ihz].x[0],sizeof(float),nx*ny, stdin)!=nx*ny) err("Can not read x to stdin"); fprintf(stderr,"read horz[%d].y...\n",ihz); if (fread(horz[ihz].y[0],sizeof(float),nx*ny, stdin)!=nx*ny) err("Can not read y to stdin"); fprintf(stderr,"read horz[%d].z...\n",ihz); if (fread(horz[ihz].z[0],sizeof(float),nx*ny, stdin)!=nx*ny) err("Can not read z to stdin"); fprintf(stderr,"read horz[%d].v0...\n",ihz); if (fread(horz[ihz].v0[0],sizeof(float),nx*ny,stdin)!= nx*ny) err("Can not read v0 to stdin"); fprintf(stderr,"read horz[%d].v1...\n",ihz); if (fread(horz[ihz].v1[0],sizeof(float),nx*ny,stdin)!= nx*ny) err("Can not read v1 to stdin"); for (iy=0;iy<ny;iy++) { for (ix=0;ix<nx;ix++) { vmin=MIN(vmin,horz[ihz].v0[iy][ix]); vmax=MAX(vmax,horz[ihz].v0[iy][ix]); vmin=MIN(vmin,horz[ihz].v1[iy][ix]); vmax=MAX(vmax,horz[ihz].v1[iy][ix]); } } } if (verbose) fprintf(stderr,"vmin=%f, vmax=%f\n",vmin,vmax); horz[nhz].x=ealloc2float(nx,ny); horz[nhz].y=ealloc2float(nx,ny); horz[nhz].z=ealloc2float(nx,ny); fprintf(stderr,"assign horz[%d].x,y,z\n",nhz); for (ix=0;ix<nx;ix++) { for (iy=0;iy<ny;iy++) { horz[nhz].x[iy][ix]=horz[nhz-1].x[iy][ix]; horz[nhz].y[iy][ix]=horz[nhz-1].y[iy][ix]; horz[nhz].z[iy][ix]=zmax; } } databot=ealloc3float(3,nx,ny); emisbot=ealloc3float(4,nx,ny); datatop=ealloc3float(3,nx,ny); emistop=ealloc3float(4,nx,ny); for (ihz=0;ihz<nhz;ihz++) { fprintf(stderr,"assigning datatop for ihz=%d\n",ihz); for (ix=0;ix<nx;ix++) { for (iy=0;iy<ny;iy++) { datatop[iy][ix][0]=( (horz[ihz].x[iy][ix]-xmin)/ (xmax-xmin)-0.5)*DIAMETER; datatop[iy][ix][1]=-( (horz[ihz].y[iy][ix]-ymin)/ (ymax-ymin)-0.5)*DIAMETER; datatop[iy][ix][2]=( (horz[ihz].z[iy][ix]-zmin)/ (zmax-zmin)-0.5)*DIAMETER; v0=horz[ihz].v0[iy][ix]; vEmission(v0,vmin,vmax,emistop[iy][ix]); } } fprintf(stderr,"assigning databot for ihz=%d\n",ihz); for (ix=0;ix<nx;ix++) { for (iy=0;iy<ny;iy++) { databot[iy][ix][0]=( (horz[ihz+1].x[iy][ix]-xmin) /(xmax-xmin)-0.5)*DIAMETER; databot[iy][ix][1]=-( (horz[ihz+1].y[iy][ix]-ymin) /(ymax-ymin)-0.5)*DIAMETER; databot[iy][ix][2]=( (horz[ihz+1].z[iy][ix]-zmin) /(zmax-zmin)-0.5)*DIAMETER; v0=horz[ihz].v1[iy][ix]; vEmission(v0,vmin,vmax,emisbot[iy][ix]); } } showLayer(ihz,databot,datatop,nx,ny,emisbot,emistop); showHorz(ihz,datatop,nx,ny,emistop); showTetra(ihz,databot,datatop,nx,ny,emisbot,emistop); showTri(ihz,datatop,nx,ny,emistop); } free3float(databot); free3float(datatop); free3float(emisbot); free3float(emistop); /******************************************************************* The ray positions are generated by sutetraray, named by rayfile. This part will be ignored if rayfile not specified. ********************************************************************/ if (rayfp!=NULL) { fscanf(rayfp, "%d =Number of shots\n",&ns); fprintf(stderr,"ns=%d\n",ns); if (ns<=0 || ns>100) { ns=0; rayfp=NULL; } ray=(Layer *)alloc1float(sizeof(Layer)*ns); tmax=0.0; for (is=0;is<ns;is++) { fscanf(rayfp, "%d =Maximum number of segments\n",&nt); fprintf(stderr,"%d =Maximum number of segments\n",nt); fscanf(rayfp, "%d =Number of rays\n",&ray[is].nrays); fprintf(stderr,"%d =Number of rays\n",ray[is].nrays); ray[is].x=ealloc2float(ray[is].nrays,nt); ray[is].y=ealloc2float(ray[is].nrays,nt); ray[is].z=ealloc2float(ray[is].nrays,nt); ray[is].v0=ealloc2float(ray[is].nrays,nt); ray[is].nseg=ealloc1int(ray[is].nrays); for (iray=0;iray<ray[is].nrays;iray++) { fscanf(rayfp,"%d=nseg %f=ttotal\n",&ray[is].nseg[iray],&tt); if (nt<ray[is].nseg[iray]) err("nt should >=ray[is].nseg[iray]"); for (it=0;it<ray[is].nseg[iray];it++) { fscanf(rayfp,"%f %f %f %f %f\n", &ray[is].x[it][iray], &ray[is].y[it][iray], &ray[is].z[it][iray], &ray[is].v0[it][iray],&tt); tmax=MAX(tmax,ray[is].v0[it][iray]); } ray[is].z[ray[is].nseg[iray]-1][iray]= MAX(0.001,ray[is].z[ray[is].nseg[iray]-1][iray]); for (it=0;it<ray[is].nseg[iray];it++) { ray[is].x[it][iray]=((ray[is].x[it][iray]-xmin)/ (xmax-xmin)-0.5)*DIAMETER; ray[is].y[it][iray]=-((ray[is].y[it][iray]-ymin)/ (ymax-ymin)-0.5)*DIAMETER; ray[is].z[it][iray]=((ray[is].z[it][iray]-zmin)/ (zmax-zmin)-0.5)*DIAMETER; } } } fclose(rayfp); /*white rays*/ glNewList(nhz*4+3,GL_COMPILE); emission[0]=emission[1]=emission[2]=emission[3]=1.0; glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,emission); for (is=0;is<ns;is++) { for (iray=0;iray<ray[is].nrays;iray++) { iflag=0; glBegin(GL_LINE_STRIP); for (it=0;it<ray[is].nseg[iray];it++) { if (fabs(ray[is].x[it][iray])<RADIUS && fabs(ray[is].y[it][iray])<RADIUS && fabs(ray[is].z[it][iray])<RADIUS) { glVertex3f(ray[is].x[it][iray],ray[is].y[it][iray], ray[is].z[it][iray]); iflag=1; } else if (iflag) break; /*once good, now bad*/ } glEnd(); } } glEndList(); /*colored rays*/ glNewList(nhz*4+4,GL_COMPILE); for (is=0;is<ns;is++) { for (iray=0;iray<ray[is].nrays;iray++) { iflag=0; glBegin(GL_LINE_STRIP); for (it=0;it<ray[is].nseg[iray];it++) { if (fabs(ray[is].x[it][iray])<RADIUS && fabs(ray[is].y[it][iray])<RADIUS && fabs(ray[is].z[it][iray])<RADIUS) { tEmission( ray[is].v0[it][iray], 0.0, /*tmin*/ tmax, emission); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,emission); glVertex3f( ray[is].x[it][iray], ray[is].y[it][iray], ray[is].z[it][iray]); iflag=1; } else if (iflag) break; /*once good, now bad*/ } glEnd(); } } glEndList(); } /************************************************************* Plot the wavefront if it is given. If the wffile does not contain effective data, ntris may be wild. In this case, do thing about the wavefront. *************************************************************/ if (wffp!=NULL) { fscanf(wffp,"%d = nwf2dump\n",&nwf); fprintf(stderr,"nwf2dump=%d\n",nwf); if (nwf>200) wffp=NULL; } if (wffp!=NULL) { emission[0]=1.0; emission[1]=1.0; emission[2]=0.0; emission[3]=1.0; wf=(Layer *)alloc1float(sizeof(Layer)*nwf); ntris=ealloc1int(sizeof(int)*nwf); for (iwf=0;iwf<nwf;iwf++) { if (1!=fscanf(wffp,"%d = ntris\n",&ntris[iwf])) { nwf=iwf; break; } if (ntris[iwf]==0) { nwf=iwf; break; } if (verbose) warn("ntris=%d of nwf=%d\n",ntris[iwf],nwf); wf[iwf].x=ealloc2float(3,ntris[iwf]); wf[iwf].y=ealloc2float(3,ntris[iwf]); wf[iwf].z=ealloc2float(3,ntris[iwf]); for (it=0;it<ntris[iwf];it++) { fscanf(wffp,"%f %f %f %f %f %f %f %f %f\n", wf[iwf].x[it], wf[iwf].y[it], wf[iwf].z[it], wf[iwf].x[it]+1,wf[iwf].y[it]+1,wf[iwf].z[it]+1, wf[iwf].x[it]+2,wf[iwf].y[it]+2,wf[iwf].z[it]+2); } fprintf(stderr,"Totally read in %d wavefront triangles\n",ntris[iwf]); for (it=0;it<ntris[iwf];it++) { for (iw=0;iw<3;iw++) { wf[iwf].x[it][iw]=((wf[iwf].x[it][iw]-xmin)/ (xmax-xmin)-0.5)*DIAMETER; wf[iwf].y[it][iw]=-((wf[iwf].y[it][iw]-ymin)/ (ymax-ymin)-0.5)*DIAMETER; wf[iwf].z[it][iw]=((wf[iwf].z[it][iw]-zmin)/ (zmax-zmin)-0.5)*DIAMETER; } } } fclose(wffp); fprintf(stderr,"Click right MB to get menu\n"); fprintf(stderr,"Click left MB and drag to rotate\n"); fprintf(stderr,"Press shift and push left MB to scale\n"); glNewList(nhz*4+6,GL_COMPILE); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,emission); for (iwf=0;iwf<nwf;iwf++) { for (itri=0;itri<ntris[iwf];itri++) { glBegin(GL_LINE_LOOP); if (fabs(wf[iwf].x[itri][0])<RADIUS && fabs(wf[iwf].y[itri][0])<RADIUS && fabs(wf[iwf].z[itri][0])<RADIUS && fabs(wf[iwf].x[itri][1])<RADIUS && fabs(wf[iwf].y[itri][1])<RADIUS && fabs(wf[iwf].z[itri][1])<RADIUS && fabs(wf[iwf].x[itri][2])<RADIUS && fabs(wf[iwf].y[itri][2])<RADIUS && fabs(wf[iwf].z[itri][2])<RADIUS) { glVertex3f(wf[iwf].x[itri][0], wf[iwf].y[itri][0], wf[iwf].z[itri][0]); glVertex3f(wf[iwf].x[itri][1], wf[iwf].y[itri][1], wf[iwf].z[itri][1]); glVertex3f(wf[iwf].x[itri][2], wf[iwf].y[itri][2], wf[iwf].z[itri][2]); } else { fprintf(stderr,"warning: some triangles ignored\n"); glEnd(); break; } glEnd(); } } glEndList(); /*solid wavefronts*/ glNewList(nhz*4+7,GL_COMPILE); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,emission); for (iwf=0;iwf<nwf;iwf++) { for (itri=0;itri<ntris[iwf];itri++) { glBegin(GL_TRIANGLE_STRIP); if (fabs(wf[iwf].x[itri][0])<RADIUS && fabs(wf[iwf].y[itri][0])<RADIUS && fabs(wf[iwf].z[itri][0])<RADIUS && fabs(wf[iwf].x[itri][1])<RADIUS && fabs(wf[iwf].y[itri][1])<RADIUS && fabs(wf[iwf].z[itri][1])<RADIUS && fabs(wf[iwf].x[itri][2])<RADIUS && fabs(wf[iwf].y[itri][2])<RADIUS && fabs(wf[iwf].z[itri][2])<RADIUS) { glVertex3f(wf[iwf].x[itri][0], wf[iwf].y[itri][0], wf[iwf].z[itri][0]); glVertex3f(wf[iwf].x[itri][1], wf[iwf].y[itri][1], wf[iwf].z[itri][1]); glVertex3f(wf[iwf].x[itri][2], wf[iwf].y[itri][2], wf[iwf].z[itri][2]); } else { fprintf(stderr,"warning: some triangles ignored\n"); glEnd(); break; } glEnd(); } } glEndList(); } /*surface traveltimes*/ if (sttfp!=NULL) { fscanf(sttfp,"%d = ntris\n",&ntr); fprintf(stderr,"ntr=%d\n",ntr); if (ntr>2000) sttfp=NULL; } if (sttfp!=NULL && ntr>0) { stt=ealloc3float(3,3,ntr); ttt=ealloc2float(3,ntr); tmax=0.0; tmin=1.0e+10; for (itri=0;itri<ntr;itri++) { fscanf(sttfp,"%f %f %f %f %f %f %f %f %f %f %f %f\n", &stt[itri][0][0], &stt[itri][0][1], &stt[itri][0][2], &ttt[itri][0], &stt[itri][1][0], &stt[itri][1][1], &stt[itri][1][2], &ttt[itri][1], &stt[itri][2][0], &stt[itri][2][1], &stt[itri][2][2], &ttt[itri][2]); tmax=MAX(tmax,ttt[itri][0]); tmax=MAX(tmax,ttt[itri][1]); tmax=MAX(tmax,ttt[itri][2]); tmin=MIN(tmin,ttt[itri][0]); tmin=MIN(tmin,ttt[itri][1]); tmin=MIN(tmin,ttt[itri][2]); stt[itri][0][0]=((stt[itri][0][0]-xmin)/ (xmax-xmin)-0.5)*DIAMETER; stt[itri][0][1]=-((stt[itri][0][1]-ymin)/ (ymax-ymin)-0.5)*DIAMETER; stt[itri][0][2]=((stt[itri][0][2]-zmin)/ (zmax-zmin)-0.5)*DIAMETER; stt[itri][1][0]=((stt[itri][1][0]-xmin)/ (xmax-xmin)-0.5)*DIAMETER; stt[itri][1][1]=-((stt[itri][1][1]-ymin)/ (ymax-ymin)-0.5)*DIAMETER; stt[itri][1][2]=((stt[itri][1][2]-zmin)/ (zmax-zmin)-0.5)*DIAMETER; stt[itri][2][0]=((stt[itri][2][0]-xmin)/ (xmax-xmin)-0.5)*DIAMETER; stt[itri][2][1]=-((stt[itri][2][1]-ymin)/ (ymax-ymin)-0.5)*DIAMETER; stt[itri][2][2]=((stt[itri][2][2]-zmin)/ (zmax-zmin)-0.5)*DIAMETER; } } tmax=MAX(tmax,tmin+0.01); glNewList(nhz*4+5,GL_COMPILE); for (itri=0;itri<ntr;itri++) { glBegin(GL_TRIANGLE_STRIP); tEmission(ttt[itri][0],tmin,tmax,emission); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,emission); glVertex3fv(stt[itri][0]); tEmission(ttt[itri][1],tmin,tmax,emission); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,emission); glVertex3fv(stt[itri][1]); tEmission(ttt[itri][2],tmin,tmax,emission); glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,emission); glVertex3fv(stt[itri][2]); glEnd(); } glEndList(); glutMainLoop(); return 0; }
int main (int argc, char **argv) { int nt,nzt,nxt,nz,nxo,nxs,ns,nx,nr,is,ixo,ixs; int ls,jtr,mtr,tracl,mzmax; off_t nseek; float ft,fzt,fxt,fz,fx,fxo,fs,fxs,dt,dzt,dxt,dz,dx,dxo,ds,dxs, ext,ezt,es,ex,ez,xo,s,xs,xg,fpeak; float v0,dvz; float fmax,angmax,offmax,rmax,aperx; float **mig,**migi,***ttab,**tb,**pb,**cosb,**sigb,**tsum,**tt; char *infile="stdin",*outfile="stdout",*ttfile,*jpfile; FILE *infp,*outfp,*ttfp,*jpfp; Wavelet *w; /* hook up getpar to handle the parameters */ initargs(argc, argv); requestdoc(1); /* open input and output files */ if( !getparstring("infile",&infile)) { infp = stdin; } else if ((infp=fopen(infile,"r"))==NULL) err("cannot open infile=%s\n",infile); if( !getparstring("outfile",&outfile)) { outfp = stdout; } else { outfp = fopen(outfile,"w"); } efseeko(infp,(off_t) 0,SEEK_CUR); warn("Got A"); efseeko(outfp,(off_t) 0,SEEK_CUR); if( !getparstring("ttfile",&ttfile)) err("must specify ttfile!\n"); if ((ttfp=fopen(ttfile,"r"))==NULL) err("cannot open ttfile=%s\n",ttfile); if( !getparstring("jpfile",&jpfile)) { jpfp = stderr; } else jpfp = fopen(jpfile,"w"); /* get information for seismogram traces */ if (!getparint("nt",&nt)) nt = 501; if (!getparfloat("dt",&dt)) dt = 0.004; if (!getparfloat("ft",&ft)) ft = 0.0; if (!getparfloat("fmax",&fmax)) fmax = 1.0/(4*dt); fpeak = 0.2/dt; if (!getparint("nxs",&nxs)) nxs = 101; if (!getparfloat("dxs",&dxs)) dxs = 15; if (!getparfloat("fxs",&fxs)) fxs = 0.0; if (!getparint("nxo",&nxo)) nxo = 1; if (!getparfloat("dxo",&dxo)) dxo = 50; if (!getparfloat("fxo",&fxo)) fxo = 0.0; /* get traveltime table parameters */ if (!getparint("nxt",&nxt)) err("must specify nxt!\n"); if (!getparfloat("fxt",&fxt)) err("must specify fxt!\n"); if (!getparfloat("dxt",&dxt)) err("must specify dxt!\n"); if (!getparint("nzt",&nzt)) err("must specify nzt!\n"); if (!getparfloat("fzt",&fzt)) err("must specify fzt!\n"); if (!getparfloat("dzt",&dzt)) err("must specify dzt!\n"); if (!getparint("ns",&ns)) err("must specify ns!\n"); if (!getparfloat("fs",&fs)) err("must specify fs!\n"); if (!getparfloat("ds",&ds)) err("must specify ds!\n"); ext = fxt+(nxt-1)*dxt; ezt = fzt+(nzt-1)*dzt; es = fs+(ns-1)*ds; /* check source and receiver coordinates */ for (ixs=0; ixs<nxs; ++ixs) { xs = fxs+ixs*dxs; for (ixo=0; ixo<nxo; ++ixo) { xg = xs+fxo+ixo*dxo; if (fs>xs || es<xs || fs>xg || es<xg) err("shot or receiver lie outside of specified (x,z) grid\n"); } } /* get migration section parameters */ if (!getparint("nx",&nx)) err("must specify nx!\n"); if (!getparfloat("fx",&fx)) err("must specify fx!\n"); if (!getparfloat("dx",&dx)) err("must specify dx!\n"); if (!getparint("nz",&nz)) err("must specify nz!\n"); if (!getparfloat("fz",&fz)) err("must specify fz!\n"); if (!getparfloat("dz",&dz)) err("must specify dz!\n"); ex = fx+(nx-1)*dx; ez = fz+(nz-1)*dz; if(fxt>fx || ext<ex || fzt>fz || ezt<ez) err(" migration section is out of traveltime table!\n"); if (!getparfloat("v0",&v0)) v0 = 1500; if (!getparfloat("dvz",&dvz)) dvz = 0; if (!getparfloat("angmax",&angmax)) angmax = 60.; if (angmax<0.00001) err("angmax must be positive!\n"); mzmax = dx*sin(angmax*PI/180.)/dz; if(mzmax<1) mzmax = 1; if (!getparfloat("aperx",&aperx)) aperx = 0.5*nxt*dxt; if (!getparint("ls",&ls)) ls = 1; if (!getparint("mtr",&mtr)) mtr = 100; fprintf(jpfp,"\n"); fprintf(jpfp," Modeling parameters\n"); fprintf(jpfp," ================\n"); fprintf(jpfp," infile=%s \n",infile); fprintf(jpfp," outfile=%s \n",outfile); fprintf(jpfp," ttfile=%s \n",ttfile); fprintf(jpfp," \n"); fprintf(jpfp," nzt=%d fzt=%g dzt=%g\n",nzt,fzt,dzt); fprintf(jpfp," nxt=%d fxt=%g dxt=%g\n",nxt,fxt,dxt); fprintf(jpfp," ns=%d fs=%g ds=%g\n",ns,fs,ds); fprintf(jpfp," \n"); fprintf(jpfp," nz=%d fz=%g dz=%g\n",nz,fz,dz); fprintf(jpfp," nx=%d fx=%g dx=%g\n",nx,fx,dx); fprintf(jpfp," \n"); fprintf(jpfp," nxs=%d fxs=%g dxs=%g\n",nxs,fxs,dxs); fprintf(jpfp," nxo=%d fxo=%g dxo=%g\n",nxo,fxo,dxo); fprintf(jpfp," \n"); /* compute reference traveltime and slowness */ offmax = MAX(ABS(fxo),ABS(fxo+(nxo-1)*dxo)); rmax = MAX(es-fxt,ext-fs); rmax = MIN(rmax,0.5*offmax+aperx); nr = 2+(int)(rmax/dx); tb = ealloc2float(nzt,nr); pb = ealloc2float(nzt,nr); sigb = ealloc2float(nzt,nr); cosb = ealloc2float(nzt,nr); timeb(nr,nzt,dx,dzt,fzt,dvz,v0,tb,pb,sigb,cosb); fprintf(jpfp," nt=%d ft=%g dt=%g fpeak=%g \n",nt,ft,dt,fpeak); fprintf(jpfp," v0=%g dvz=%g \n",v0,dvz); fprintf(jpfp," aperx=%g angmax=%g offmax=%g\n",aperx,angmax,offmax); fprintf(jpfp," mtr=%d ls=%d\n",mtr,ls); fprintf(jpfp," ================\n"); fflush(jpfp); /* allocate space */ mig = ealloc2float(nz,nx); migi = ealloc2float(nz+2*mzmax,nx); ttab = ealloc3float(nzt,nxt,ns); tt = ealloc2float(nzt,nxt); tsum = ealloc2float(nzt,nxt); /* make wavelet */ makericker(fpeak,dt,&w); /* set constant segy trace header parameters */ memset((void *) &tr, 0, sizeof(segy)); tr.trid = 1; tr.counit = 1; tr.ns = nt; tr.dt = 1.0e6*dt; tr.delrt = 1.0e3*ft; fprintf(jpfp," read traveltime tables \n"); fflush(jpfp); /* compute traveltime residual */ for(is=0; is<ns; ++is){ nseek = (off_t) nxt*nzt*is; efseeko(ttfp,nseek*((off_t) sizeof(float)),SEEK_SET); fread(ttab[is][0],sizeof(float),nxt*nzt,ttfp); s = fs+is*ds; resit(nxt,fxt,dxt,nzt,nr,dx,tb,ttab[is],s); } fprintf(jpfp," read migration section \n"); fflush(jpfp); /* read migration section */ fread(mig[0],sizeof(float),nx*nz,infp); /* integrate migration section for constructing anti-aliasing filter */ integ(mig,nz,dz,nx,mzmax,migi); fprintf(jpfp," start synthesis ... \n"); fprintf(jpfp," \n"); fflush(jpfp); jtr = 0; /* loop over shots */ for (ixs=0,xs=fxs,tracl=0; ixs<nxs; ++ixs,xs+=dxs) { /* loop over offsets */ for (ixo=0,xo=fxo; ixo<nxo; ++ixo,xo+=dxo) { float as,res; int is; xg = xs+xo; /* set segy trace header parameters */ tr.tracl = tr.tracr = ++tracl; tr.fldr = 1+ixs; tr.tracf = 1+ixo; tr.offset = NINT(xo); tr.sx = NINT(xs); tr.gx = NINT(xg); as = (xs-fs)/ds; is = (int)as; if(is==ns-1) is=ns-2; res = as-is; if(res<=0.01) res = 0.0; if(res>=0.99) res = 1.0; sum2(nxt,nzt,1-res,res,ttab[is],ttab[is+1],tsum); as = (xg-fs)/ds; is = (int)as; if(is==ns-1) is=ns-2; res = as-is; if(res<=0.01) res = 0.0; if(res>=0.99) res = 1.0; sum2(nxt,nzt,1-res,res,ttab[is],ttab[is+1],tt); sum2(nxt,nzt,1,1,tt,tsum,tsum); fflush(jpfp); /* make one trace */ maketrace(tr.data,nt,ft,dt,xs,xg,mig,migi,aperx, nx,fx,dx,nz,fz,dz,mzmax,ls,angmax,v0,fmax,w, tb,pb,sigb,cosb,nr,tsum,nxt,fxt,dxt,nzt,fzt,dzt); /* write trace */ fputtr(outfp,&tr); jtr++; if((jtr-1)%mtr ==0 ){ fprintf(jpfp," generated trace %d\n",jtr); fflush(jpfp); } } } fprintf(jpfp," generated %d traces in total\n",jtr); fprintf(jpfp," \n"); fprintf(jpfp," output done\n"); fflush(jpfp); efclose(jpfp); efclose(outfp); free2float(tsum); free2float(tt); free2float(pb); free2float(tb); free2float(cosb); free2float(sigb); free3float(ttab); free2float(mig); free2float(migi); return(CWP_Exit()); }