Skip to content

Developer1

Rodolfo Dirack edited this page May 30, 2021 · 8 revisions

Mnhcrssurf.c (the utilitarian to build non-hyperbolic CRS surfaces)

The program sfnhcrssurf, generated with Mnhcrssurf.c source, builds a non-hyperbolic CRS traveltime surface for RN, RNIP and BETA parameters given.

RSF input/output files

The program reads a template of the traveltime surface from stdin file "in". Its dimensions will be the same of the output file "out", but it's values are not read. This file is only a template to offer dimensions to the program without using command line parameters.

/* RSF files I/O */
sf_file in; // Traveltime surface with the output dimensions
sf_file out; // Non-hyperbolic traveltime surface output
sf_file par; // RN, RNIP and BETA parameters

Reading parameters file

The output file "out" is the traveltime surface for RN, RNIP and BETA that are read from "par" file. The first 3 values in "par" file should be RN, RNIP and BETA respectively. They are read and stored in a temporary c vector as follows:

c = sf_floatalloc(nc);
sf_floatread(c,nc,par);

RN = c[0];
RNIP = c[1];
BETA  = c[2];

Non-hyperbolic CRS surface calculation

The logic of the program is straightforward. It loops through h and m coordinates of the traveltime surface and it calculates the traveltime function for each t(m,h) using the non-hyperbolic CRS formula.

        for (im=0; im < nm; im++){

                for(ih=0;ih<nh;ih++){

                        m = om + (im * dm);
                        m = m - m0;
                        h = oh + (ih * dh);

                        a1=(2*sin(BETA))/(v0);
                        a2=(2*cos(BETA)*cos(BETA)*t0)/(v0*RN);
                        b2=(2*cos(BETA)*cos(BETA)*t0)/(v0*RNIP);
                        c1=2*b2+a1*a1-a2;


                        Fd=(t0+a1*m)*(t0+a1*m)+a2*m*m;
                        Fd2=(t0+a1*(m-h))*(t0+a1*(m-h))+a2*(m-h)*(m-h);
                        Fd1=(t0+a1*(m+h))*(t0+a1*(m+h))+a2*(m+h)*(m+h);                    
                        t[im][ih]=sqrt((Fd+c1*h*h+sqrt(Fd2*Fd1))*0.5);

                } /* Loop over half-offset */
        } /* Loop over CMP*/

Output

After the main loop it prepares the axis of the output file "out" (ax, ay and az) and it writes them in the "out" file.

/* axis = sf_maxa(n,o,d)*/
ax = sf_maxa(nh, oh, dh);
ay = sf_maxa(nm, om, dm);
az = sf_maxa(1, 0, 1);

/* sf_oaxa(file, axis, axis index) */
sf_oaxa(out,ax,1);
sf_oaxa(out,ay,2);
sf_oaxa(out,az,3);
sf_floatwrite(t[0],nh*nm,out);

Clone this wiki locally