def imshow_sw(dat,seis_coord = None,well_files = None,horfiles = None,rockprop = None)  :
    minval = 0
    maxval = np.max(dat)
    fig, ax = plt.subplots()
    divider = make_axes_locatable(ax)
    cax = divider.append_axes('right', size='5%', pad=0.05)    
    if (seis_coord is None):
        pos =ax.imshow(dat,interpolation='bicubic',cmap = 'nipy_spectral', aspect='auto',vmin = 0,vmax =maxval)
        fig.colorbar(pos, cax=cax, orientation='vertical')
    else:        
                #dist = calc_dist(seis_coord)[0]   
        tmin = seis_coord['tseis'][0]
        tmax = seis_coord['tseis'][-1]
        xmin = 0
        xmax = dat.shape[1]*seis_coord['bins'][0]        
        pos = ax.imshow(dat,interpolation='bicubic',cmap = 'nipy_spectral', aspect='auto',vmin =0,vmax =maxval,\
           extent = [xmin,xmax,tmax,tmin])
        
        nwells = well_files.size
        numm = 40
        wellcoord = seis_coord['wellcoord']
        for i in range(nwells):
            wlog = mfun.load_obj(well_files[i])
            rho = wlog.Rhob
            if (rho is None):
                raise Exception ('Density log does not exist')
            wtmin = np.int(wlog.time[0])
            wtmax = np.int(wlog.time[-1])
            if(wtmin < tmin):
                wtmin = tmin
            elif( wtmax > tmax):
                wtmax = tmax
            zone = np.array([wtmin,wtmax], dtype = int)
            rho = mfun.segment_logs(zone,wlog.time,rho)[0]
            wxmin = xmin + wellcoord['indx'][i]*seis_coord['bins'][0]
            wxmax = wxmin + numm 
            ai_mat = np.tile(rho,[numm,1]).T
            ax.imshow(ai_mat,interpolation='bicubic',cmap = 'nipy_spectral', aspect='auto',vmin = 0,vmax =maxval,\
                          extent = [wxmin,wxmax,wtmax,wtmin])
                          
        if(horfiles is not None):
            nhor = horfiles.size
            indx = seis_coord['coord_indx']        
            hor_x = np.arange(xmin,xmax,seis_coord['bins'][0]) # temp
            for xd in range(nhor):
                hor = mfun.load_obj(horfiles[xd])
                hor_y = hor.Z[indx]
                ax.plot(hor_x,hor_y,'k')
    
    fig.colorbar(pos, cax=cax, orientation='vertical')
    ax.autoscale() 
    ax.set_xlabel('Distance(m)')
    ax.set_ylabel('Time(ms)')
    if (rockprop is None):
        rockprop = 'Porosity'
    ax.set_title(rockprop)     
    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 #3
0
    def save_interp_mod(self):
        print ('inside save_interp_mod->backgrundmodeling class')
        print('To do : check if model directory exist and if not create it')
        
        BKModelcoord ={}
        
        if (self.coordName is None):
            coord_bin,coord_XY = self.generate_coordinate()
            BKModelcoord['Lines'] = coord_bin[:,0]
            BKModelcoord['Traces'] = coord_bin[:,1]
        else:
            tmp = mfun.load_obj(self.coordName)
            BKModelcoord['Lines'] = tmp['Lines']
            BKModelcoord['Traces'] = tmp['Traces']         
            
            

        BKModelcoord['HorIndx'] = self.HorIndx
        BKModelcoord['hor'] = self.hor
        BKModelcoord['corr_indx'] = self.corr_indx
        BKModelcoord['nLines'] = self.nLines 
        BKModelcoord['nTraces'] = self.nTraces
        BKModelcoord['GEOM'] = self.GEOM
        BKModelcoord['Grid'] = self.Grid 
        BKModelcoord['bin'] = self.bin 
        BKModelcoord['dt'] = self.dt
        BKModelcoord['tmin'] = self.tmin
        BKModelcoord['tmax'] = self.tmax
        BKModelcoord['wellfiles'] = self.wellfiles
        BKModelcoord['wellcoord'] = self.wellcoord
        BKModelcoord['wellxy'] = self.wellxy
        BKModelcoord['dlines'] = self.dlines
        BKModelcoord['dtraces'] = self.dtraces        
        mfun.save_obj('models\BKModelcoord',BKModelcoord)
        
                
        if (self.wlog == 'Vp'):
            mfun.numpy_save(self.model,'models\VPinterp')  
            mfun.save_obj('models\\vpLOGS',self.LOGS)   # original logs... no time axis
            mfun.save_obj('models\\vplogss',self.logs)   # resampled log on the seisimic grid 
            if (self.Algorithm):
               mfun.save_obj('models\\VPmodcov',self.modvar) 
        elif (self.wlog == 'Vs'):
            mfun.numpy_save(self.model,'models\VSinterp') 
            mfun.save_obj('models\\vsLOGS',self.LOGS) 
            mfun.save_obj('models\\vslogss',self.logs)  
            if (self.Algorithm):
               mfun.save_obj('models\\VSmodcov',self.modvar)             
        elif (self.wlog == 'Rhob'):
            mfun.numpy_save(self.model,'models\RHOinterp') 
            mfun.save_obj('models\\rhoLOGS',self.LOGS) 
            mfun.save_obj('models\\rhologss',self.logs)   
            if (self.Algorithm):
               mfun.save_obj('models\\RHOmodcov',self.modvar) 
Exemple #4
0
 def creatinglogsInGrid(self):         
     tmp = mfun.load_obj(self.coordName)
     """
     BKModelcoord ={}
     BKModelcoord['Lines'] = tmp['Lines']
     BKModelcoord['Traces'] = tmp['Traces']  
     BKModelcoord['X'] = tmp['X']
     BKModelcoord['Y'] = tmp['Y'] 
     """
     XY = np.vstack((tmp['X'],tmp['Y']))
     self.layered = np.zeros((self.nzones,self.nwells))
     for i in range(self.nwells):                       
         self.layered[:,i] = self.newlogs[i,1]
     return XY.T
Exemple #5
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 #6
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 #7
0
    def read(self):
        if (self.well_flag is None):
            self.init()

        self.Inline = np.zeros(self.nwells)
        self.Crossline = np.zeros(self.nwells)
        self.Xloc = np.zeros(self.nwells)
        self.Yloc = np.zeros(self.nwells)

        for i in range(self.nwells):
            self.wells[i] = mfun.load_obj(
                self.wellnames[i])  # m is welldata class
            self.wells[i].wellname = self.wellnames[i]
            if (self.wells[i].Inline is not None):
                self.Inline[i] = self.wells[i].Inline

            if (self.wells[i].Crossline is not None):
                self.Crossline[i] = self.wells[i].Crossline

            if (self.wells[i].Xloc is not None):
                self.Xloc[i] = self.wells[i].Xloc

            if (self.wells[i].Yloc is not None):
                self.Yloc[i] = self.wells[i].Yloc
Exemple #8
0
 def save_geodata(self,path):
     geodata = {}
     print('Run after VP, VS and Rho Models are saved on disk')
     fp_vplogs = path + 'vplogss'
     fp_vslogs = path + 'vslogss'
     fp_rhologs = path + 'rhologss' 
     
     fp_vpLOGS = path + 'vpLOGS' 
     fp_vsLOGS = path + 'vsLOGS'
     fp_rhoLOGS = path + 'rhoLOGS' 
     
     # This is the resampled log on the seisimic grid 
     # loaded into cells
     geodata['Vplogs'] =   mfun.load_obj(fp_vplogs) 
     geodata['Vslogs'] =   mfun.load_obj(fp_vslogs) 
     geodata['rhologs'] =   mfun.load_obj(fp_rhologs)    
     
     # This is the original  log loaded into cells
     geodata['VpLOGS'] =   mfun.load_obj(fp_vpLOGS) 
     geodata['VsLOGS'] =   mfun.load_obj(fp_vsLOGS) 
     geodata['rhoLOGS'] =   mfun.load_obj(fp_rhoLOGS)  
     
     mfun.save_obj('models\geodata',geodata)        
Exemple #9
0
    w19_19A.TD_MD = mat[:,0]
    w19_19A.TD_X = mat[:,8]
    w19_19A.TD_Y = mat[:,9]

    # Deviation file
    mat = w19_19A.read('well_files//volve//TD//HRS//15_9_19A_well_tie.txt',16)
    w19_19A.MD_dev = mat[:,0]
    w19_19A.Xdev = mat[:,8]
    w19_19A.Ydev = mat[:,9]

    fig, (ax1, ax2) = plt.subplots(2,1)
    ax1.plot(w19_19A.MD,w19_19A.Vp)
    
    w19_19A.apply_TD()
    w19_19A_time = well()
    w19_19A_time = mfun.load_obj('well_files//volve//time//w19A')

    # debug
    zone = np.zeros(2)
    if (w19_19A.time [0] >= w19_19A_time.time[0] ):
        zone[0] = w19_19A.time[0]
    else:
        zone[0] = w19_19A_time.time[0]
        
    if (w19_19A.time [-1]<=w19_19A_time.time[-1] ):
        zone[1] = w19_19A_time.time[-1]
    else:
        zone[1] = w19_19A.time[-1]
    zone[0] = 2350
    zone[1] = 2515
    
        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


#----------------------------------------------------
if __name__ == "__main__":
    import matplotlib.pyplot as plt
    tseis = np.arange(0, 3601, 1)

    data = mfun.load_obj('Poseidon_2')

    plt.plot(data.Vs, data.time, 'k')

    params = ctrendlogs(data.Vs, data.time, 'Vs')
    #pred = fcompactntrend_vs(data.time,params)
    pred = predict(params, 'Vp', data.Vs, tseis)
    plt.plot(pred, data.time, 'ro')
    plt.show()