human
2. Main class definition
What we are now going to do is create a class named Hyperbola
Each object of this class is capable of computing traveltimes to a certain subsurface point (diffractor) and plotting this point response (hyperbola) on a grid
How? to more clearly define a class? probably change to a function?
 ... Here we are now going to do is create a class named Hyperbola?
assistant
#Here we are now going to do is create a class named Hyperbola
.
class Hyperbola:
    def __init__(self, xarray, tarray, x0, t0, v=2):
        ###input parameters define a difractor's position (x0,t0), P-wave velocity of homogeneous subsurface, and x- and t-arrays to compute traveltimes on.
        ###
        
        self.x=xarray
        self.x0=x0
        self.t0=t0
        self.v=v
        
        #compute traveltimes
        self.t=sqrt(t0**2 + (2*(xarray-x0)/v)**2)
        
        #obtain some grid parameters
        xstep=xarray[1]-xarray[0]
        tbegin=tarray[0]
        tend=tarray[-1]
        tstep=tarray[1]-tarray[0]
        
        #delete t's and x's for samples where t exceeds maxt
        self.x=self.x[ (self.t>=tbegin) & (self.t <= tend) ]        
        self.t=self.t[ (self.t>=tbegin) & (self.t <= tend) ]
        self.imgind=((self.x-xarray[0])/xstep).astype(int)       
        
        #compute amplitudes' fading according to geometrical spreading

        self.amp = 1/(self.t/self.t0)

        
        self.grid_resample(xarray, tarray)
        
    
    def grid_resample(self, xarray, tarray):
    # that's a function that computes at which 'cells' of image should we place the hyperbola
    
        tend=tarray[-1]
        tstep=tarray[1]-tarray[0]
        
        self.xind=((self.x-xarray[0])/xstep).astype(int)  #X cells numbers
        
        self.tind=np.round((self.t-tarray[0])/tstep).astype(int) #T cells numbers
        self.tind=self.tind[self.tind*tstep<=tarray[-1]] #delete T's exceeding max.T
        
        self.tgrid=tarray[self.tind] # get 'gridded' T-values
        
        self.coord=np.vstack((self.xind,tarray[self.tind]))    
        
            
    def add_to_img(self, img, wavelet):
    # puts the hyperbola into the right cells of image with a given wavelet
        maxind=np.size(img,1)        
        wavlen=np.floor(len(wavelet)/2).astype(int)      
        
        self.imgind=self.imgind[self.tind < maxind-wavlen-1]        
        self.amp = self.amp[self.tind < maxind-wavlen-1]
        self.tind=self.tind[self.tind <...