Exemple #1
0
def datnormhrs(Rdepth, seis, tseis, Vp, Vs, Rho, tlog, wav, AVO):
    num = 10
    if (seis.shape[1] != wav.size):
        raise Exception("seismic and obj.wavletelet has unequal angles")
    dat = mfun.segdat(Rdepth, tseis, seis)  # to do
    vp, vs, rho = mfun.seglog(Rdepth, tlog, Vp, Vs, Rho)  # to do
    ndat, nang = mfun.size(wav)
    sc = mfun.cell(nang)
    datnorm = mfun.cell(ndat, nang)
    Re = Dobsn(vp, vs, rho, AVO, ang)  # to do

    sc = np.zeros(nang)
    for i in range(nang):
        synth = convm(Re[i], wav[i])
        Logsc = np.sort(ft.xcorr(wav[i], synth))  # BUG
        Trcsc = np.sort(ft.xcorr(wav[i], dat[i]))  # BUG

        wscl, lag = ft.xcorr(wav[i])
        wsc = wscl[np.nonzero(lag == 0)]
        Logsc = Logsc / wsc
        nsL = len(Logsc)
        nsT = len(Trcsc)
        dLg = mfun.rms(np.concatenate(Logsc[0:num], Logsc[num:-1]))
        dTr = mfun.rms(np.concatenate(Trcsc[0:num], Trcsc[num:-1]))

        sc[i] = dTr / dLg
        datnorm = seis[i] / sc[i]

    return sc, datnorm
Exemple #2
0
    def kern_fatti(self):
        if (self.init_flag == False):
            self.init()
        t = (self.ang * np.pi) / 180
        C1 = mf.cell(self.nang, 1)
        C2 = mf.cell(self.nang, 1)
        C3 = mf.cell(self.nang, 1)
        c1 = np.zeros(self.nsamp)
        c2 = np.zeros(self.nsamp)
        c3 = np.zeros(self.nsamp)

        for i in range(self.nang):
            c1 = np.eye(self.nsamp) * 1 / (2 * np.cos(t[i]**2))
            c2 = np.eye(self.nsamp) * -4 * self.vsvp**2 * (np.sin(t[i]**2))
            c3 = np.eye(self.nsamp) * (0.5 - c2 + (2 * self.vsvp**2 *
                                                   (np.sin(t[i]**2))))

            C1[i, 0] = c1
            C2[i, 0] = c2
            C3[i, 0] = c3
        c1_tmp = self.cell2mat(C1)
        c2_tmp = self.cell2mat(C2)
        c3_tmp = self.cell2mat(C3)

        C = np.concatenate((c1_tmp, c2_tmp, c3_tmp), axis=1)
        return C
Exemple #3
0
  def lodwells(self):
      self.LOGS = mfun.cell(self.nwells,self.nlogs)
      
      for i in range(self.nwells):
          dat_in = self.wellmanger.wells[i].extract_logs(self.wlog)
          z_in  = self.wellmanger.wells[i].time
          self.LOGS[i,1],self.LOGS[i,0] = ft.resample(dat_in,z_in,self.old_dt,self.dt)
 
      self.clean_logs()            
Exemple #4
0
 def hor_grid(self):
     nr,nc = self.hor.size
     self.horz = mfun.cell(nr,nc)
     ntrc = 2
     print("ntrc is not parametezed , please check")
     ind = np.arange(ntrc)
     for i in range(nc):
         tmp = self.hor[i]
         self.horz[i] = tmp[ind]
Exemple #5
0
 def cleanLOGS(self):
     print('inside cleanLOGS-> background modeling')
     print('---A better version is to use HRS idea of replacing nan values with averages----')        
     print('additionally removing nan value by interpolation: please find time to debug ')
     print('-------------------------------------------------------------------------------')
     LOGS = mfun.cell(self.nwells,self.nlogs)
     for i in range(self.nwells):
         LOGS[i,0],LOGS[i,1] = self.remove_nan(self.LOGS[i,0],self.LOGS[i,1])
         LOGS[i,1] = mfun.remove_nan_interp(LOGS[i,1])
     self.LOGS = LOGS
Exemple #6
0
    def load_hor(self,options = None):
        print('-----loading horizons-----------')
        if (options is None):
            options = 'pristine'
# MAKING SURE THAT TOTAL THICKNESS IS MORE THAN FILTER LENGTH
        period = round(1000/self.bkmodfreq)
        FL = round(period/self.dt)
        
        nhor =self.horfiles.size
        horz = mfun.cell(nhor)
        horm = mfun.cell(nhor)
        
        for i in range(nhor):
            m = mfun.load_obj(self.horfiles[i])
            tmp = np.stack((m.Inline,m.Crossline,m.Z), axis = 1)
            horz[i] = tmp
        ns = horz[0][:,0].size
        
        horm = horz
        
        for ii in range(ns):
            for i in range(nhor-1):
                temp = horm[i+1][ii,2] - horm[i][ii,2]
                if temp < (FL*self.dt):
                    horm[i+1][ii,2] = horm[i+1][ii,2] + (FL*self.dt) + 1
         
        if (options == 'pristine'):
            hor = horz
        elif(options == 'modify'):
            hor = horm
            
 #   recoordinating with seismic time sampling
            
        for i in range(nhor):
            temp = hor[i][:,2]
            tmp = self.recoordzone(temp)
            hor[i][:,2] = tmp
                
        self.hor = hor
Exemple #7
0
 def loadhor(self,options = None):
     if (options is None):
         options  = 'pristine'
     
     Period = round(1000/self.bkmodfreq)
     FL = round(Period/self.dt)
     
     nhor = self.horfiles.size
     horz = mfun.cell(nhor)
     horm = mfun.cell(nhor)
     
     for i in range(nhor):
         m = mfun.load_obj(self.horfiles[i])
         temp  = np.concatenate(m.Inlne,m.Crossline,m.Z)
         horz[i] = temp
     
     nrm,ncm = horz.size_data
     ns = nrm[0]
     
     horm = horz
     
     for ii in range(ns):
         for i in range(nhor-1):
             temp = horm[i+1][ii,2] - horm[i][ii,2]
             if temp < (FL*self.dt):
                 horm[ii][ii,2] = horm[ii+1][ii,3] + (FL*self.dt) + 1
                 
     if (options == 'pristine'):
          hor =horz
     elif (options,'modify'):
          hor  = horm 
      
     for i in range(nhor):
         temp = hor[i][:,2]
         temp = self.recoordzone(temp)
         hor[i][:,2] = temp
         
     self.hor = hor
Exemple #8
0
 def init(self):
     if (os.path.isdir('Model Building2') is None):  # BUG
         os.mkdir('Model Building2')
         print('creating ...Model Building2.... in the current directory')
     
     if (self.Type == "Elastic"):
         self.nlogs  = 4 
     elif(self.Type == "Acoustic"):
         self.nlogs =3 
     self.nlogs = 2 
     self.wellmanger.wellnames = self.wellfiles
     self.wellmanger.read()
     
     self.nhor = self.horfiles.size
     self.nwells = self.wellfiles.size        
     self.wellcoord = np.stack((self.wellmanger.Inline,self.wellmanger.Crossline),axis = 1)
     self.wellxy = np.stack((self.wellmanger.Xloc,self.wellmanger.Yloc),axis = 1)
     
     self.logs = mfun.cell(self.nwells,self.nlogs)
     self.newlogs = mfun.cell(self.nwells,self.nlogs)
     
     self.load_hor()
     self.loadwells() 
     
     self.nCDP = self.hor[0][:,1].size
     self.ntrc = self.nLines * self.nTraces
     self.tseis = np.arange(self.tmin,self.tmax+self.dt,self.dt)
     
     if(self.nCDP !=self.ntrc):
         print("No of traces in the seismic grid is unequal to horizon")
     
     self.model_preallocate()  # stopped here
     
     if(self.tmin == 0):
         self.corr_indx = 0
     else:
         self.corr_indx = np.fix(1/self.dt*self.tmin)
Exemple #9
0
    def create_wavdata(self):
        if (self.init_flag == False):
            self.init()
        wavz = np.zeros((self.nsamp, self.nsamp))
        wavdata = mf.cell(self.nang * self.nsurv, self.nang * self.nsurv)

        for ii in range(self.nang):
            for i in range(self.nang):
                if (i == ii):
                    wavdata[i, ii] = fm.convmat2(self.wavelet[0, ii],
                                                 self.nsamp)
                else:
                    wavdata[i, ii] = wavz
        wavdata = self.cell2mat(wavdata)
        return wavdata.T
    def read(self):
        if (self.init_flag is None):
            self.init()

        tmp = mfun.load_obj(self.wavefiles[0])
        self.data = mfun.cell(self.nwav, tmp.nang)
        for ii in range(self.nwav):
            self.wav[ii] = mfun.load_obj(self.wavefiles[ii])
            self.nang = self.wav[ii].nang
            self.wavename[ii] = self.wav[ii].wavename

            for i in range(self.nang):
                if (self.nang == 1):
                    self.data[ii, i] = self.wav[ii].data
                else:
                    self.data[ii, i] = self.wav[ii].data[:, i]
Exemple #11
0
def dobsn(vp, vs, rho, ang, AVO):
    nr, nc = mfun.shape(vp)
    nang = len(ang)

    R = np.zeros(nr, 1)
    Re = mfun.cell(nang)

    for ii in range(nang):
        for i in range(nr - 1):
            Rpp = avopp(vp[i],vs[i],rho[i], \
                        vp[1+i],vs[1+i],rho[1+i], \
                        ang[ii],AVO)
            R[i] = np.real(Rpp)

            R[nr - 1] = R[nr - 2]
        Re[ii] = R

    return Re
Exemple #12
0
 def normalize_logs(self):
     
     nw,nl = self.newlogs.size()
     logs = mfun.cell(nw,nl)
     sz = self.newlogs.size_data()
     ndat = np.max(sz[:,1])
     tindex = [0, ndat] 
     ns_out = tindex[1] - tindex[0]
     
     if (self.nzones is None):
         self.nzones = np.int(ns_out)
         msg = 'number of zones is forced to be' + str(ns_out)
         print(msg) 
     else:
         ns_out = self.nzones
         
     for i in range(nw):
         nsamp = self.newlogs[i,1].size
         logs[i,1],logs[i,0] = \
         ft.resample(self.newlogs[i,1],self.newlogs[i,0],self.dt,(nsamp/ns_out))          
         
     return logs
Exemple #13
0
 def loadwells(self):
     print('-----loading wells-----------')
     self.LOGS = mfun.cell(self.nwells,self.nlogs)
     for i in range(self.nwells):
         tmp_in = getattr(self.wellmanger.wells[i],self.wlog)
         time_in = self.wellmanger.wells[i].time
         
         if (time_in is None):
             msg = ' z-axis does not exist in' + self.wellmanger.wells[i]
             raise Exception (msg)            
         if (tmp_in is None):
             msg = self.wlog + 'does not exist in' + self.wellmanger.wells[i]
             raise Exception (msg)                
             
         if (self.old_dt == self.dt):
             tmp_out = tmp_in
             tcord = time_in
         else:
             tmp_out,tcord = ft.resample(tmp_in,time_in,self.old_dt,self.dt)
             
         self.LOGS[i,0] = tcord
         self.LOGS[i,1] = tmp_out
         
     self.cleanLOGS()
Exemple #14
0
 def extract_logs(self, wlog):
     LOGS = mfun.cell(self.nwells, 2)  # pseudo cell_arrays
     for i in range(self.nwells):
         LOGS[i][0] = self.wells[i].time
         LOGS[i][1] = getattr(self.wells[i], wlog)
     return LOGS
Exemple #15
0
                             "waveletmanager")  # extracting well class
    """
    G = AVOModel()
    G.nsamp = 10
    G.ang = np.array([10,20,30])
    wav_manager = waveletmanager()
    wav_manager.wavefiles = np.array(['wavelet\\wav_poseidon'])
    wav_manager.read()
    wavelet = wav_manager.get_data() 
    
    G = AVOModel()
    G.nsamp = 10
    G.ang = np.array([10,20,30])
    G.wavelet = wavelet
    G.process()
    """
    G = AVOModel()
    wav_manager = waveletmanager()
    wav_manager.wavefiles = np.array(['wavelet\\wav_shell_area1_Full'])
    wav_manager.read()
    #wavelet = wav_manager.get_data()
    dat = np.array([1, 2, 3])
    wavelet = mf.cell(1, 1)
    wavelet[0, 0] = dat

    G = AVOModel()
    G.nsamp = 5
    G.ang = np.array([0])
    G.wavelet = wavelet
    GG = G.process()
def predict_ver2(params, wlog, LOGS, tseis):
    dt = tseis[1] - tseis[0]
    nwells, nlogs = LOGS.size
    logs = mfun.cell(nwells, nlogs)
    for i in range(nwells):
        t1 = np.min(tseis)
        t2 = np.min(LOGS[i, 0]) - dt
        upper = np.arange(t1, t2 + dt, dt)
        z = upper
        if (upper.size == 0):
            upperzone_data = z  # there is data above the horizon
        else:
            if (wlog == 'AI'):
                scal = 1
                upperzone_data = scal * fcompactntrend_AI(z, params)
            elif (wlog == 'Vp'):
                scal = 1
                upperzone_data = scal * fcompactntrend_vp(z, params)
            elif (wlog == 'Vs'):
                scal = 1
                upperzone_data = scal * fcompactntrend_vs(z, params)
            elif (wlog == 'Rhob'):
                upperzone_data = fcompactntrend_rho(z, params)
            elif (wlog == 'GR'):
                upperzone_data = fcompactntrend_gr(z, params)
            else:
                raise Exception('not yet coded for this lognames')

        t2 = np.max(tseis)
        t1 = np.max(LOGS[i, 0]) + dt
        lower = np.arange(t1, t2 + dt, dt)
        z = lower
        if (lower.size == 0):
            lowerzone_data = lower  # there is data beneath tseis
        else:
            if (wlog == 'AI'):
                scal = 1
                lowerzone_data = scal * fcompactntrend_AI(z, params)
            elif (wlog == 'Vp'):
                scal = 1
                lowerzone_data = scal * fcompactntrend_vp(z, params)
            elif (wlog == 'Vs'):
                scal = 1
                lowerzone_data = scal * fcompactntrend_vs(z, params)
            elif (wlog == 'Rhob'):
                scal = 1
                lowerzone_data = fcompactntrend_rho(z, params)
            elif (wlog == 'GR'):
                lowerzone_data = fcompactntrend_gr(z, params)
            else:
                raise Exception('not yet coded for this lognames')

        if (upper.size == 0 and lower.size != 0):
            zone = np.array([np.min(tseis), LOGS[i, 0][-1]], dtype=int)
            data, t = mfun.segment_logs(zone, LOGS[i, 0], LOGS[i, 3])
            dat_out = np.concatenate((data, lowerzone_data), axis=None)
        elif (upper.size != 0 and lower.size == 0):
            zone = np.array([LOGS[i, 0][0], tseis[-1]], dtype=int)
            data, t = mfun.segment_logs(zone, LOGS[i, 0], LOGS[i, 3])
            dat_out = np.concatenate((upperzone_data, data), axis=None)
        elif (upper.size == 0 and lower.size == 0):
            zone = np.array([np.min(tseis), np.max(tseis)], dtype=int)
            data, t = mfun.segment_logs(zone, LOGS[i, 0], LOGS[i, 3])
            dat_out = data
        else:  #upper and lower zone zero
            dat_out = np.concatenate(
                (upperzone_data, LOGS[i, 3], lowerzone_data), axis=None)

        logs[i, 0] = tseis
        logs[i, 1] = LOGS[i, 1]
        logs[i, 2] = LOGS[i, 2]
        logs[i, 3] = dat_out

    return logs