def readUBC_DC2DLoc(fileName): from SimPEG import np """ Read UBC GIF 2D observation file and generate arrays for tx-rx location Input: :param fileName, path to the UBC GIF 2D model file Output: :param rx, tx :return Created on Thu Nov 12 13:14:10 2015 @author: dominiquef """ # Open fileand skip header... assume that we know the mesh already #============================================================================== # fopen = open(fileName,'r') # lines = fopen.readlines() # fopen.close() #============================================================================== # Load file obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='!') # Check first line and figure out if 2D or 3D file format line = np.array(obsfile[0].split(),dtype=float) tx_A = [] tx_B = [] rx_M = [] rx_N = [] d = [] wd = [] for ii in range(obsfile.shape[0]): # If len==3, then simple format where tx-rx is listed on each line if len(line) == 4: temp = np.fromstring(obsfile[ii], dtype=float,sep=' ') tx_A = np.hstack((tx_A,temp[0])) tx_B = np.hstack((tx_B,temp[1])) rx_M = np.hstack((rx_M,temp[2])) rx_N = np.hstack((rx_N,temp[3])) rx = np.transpose(np.array((rx_M,rx_N))) tx = np.transpose(np.array((tx_A,tx_B))) return tx, rx, d, wd
def readUBC_DC2Dobs(fileName): """ ------- NEEDS TO BE UPDATED ------ Read UBC GIF 2D observation file and generate arrays for tx-rx location Input: :param fileName, path to the UBC GIF 2D model file Output: :param rx, tx :return Created on Thu Nov 12 13:14:10 2015 @author: dominiquef """ from SimPEG import np # Load file obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='!') # Check first line and figure out if 2D or 3D file format line = np.array(obsfile[0].split(),dtype=float) tx_A = [] tx_B = [] rx_M = [] rx_N = [] d = [] wd = [] for ii in range(obsfile.shape[0]): # If len==3, then simple format where tx-rx is listed on each line if len(line) == 4: temp = np.fromstring(obsfile[ii], dtype=float,sep=' ') tx_A = np.hstack((tx_A,temp[0])) tx_B = np.hstack((tx_B,temp[1])) rx_M = np.hstack((rx_M,temp[2])) rx_N = np.hstack((rx_N,temp[3])) rx = np.transpose(np.array((rx_M,rx_N))) tx = np.transpose(np.array((tx_A,tx_B))) return tx, rx, d, wd
def readUBC_DC3Dobs(fileName): from SimPEG import np """ Read UBC GIF DCIP 3D observation file and generate arrays for tx-rx location Input: :param fileName, path to the UBC GIF 3D obs file Output: :param rx, tx, d, wd :return Created on Mon December 7th, 2015 @author: dominiquef """ # Load file obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='!') # Pre-allocate Tx = [] Rx = [] d = [] wd = [] # Countdown for number of obs/tx count = 0 for ii in range(obsfile.shape[0]): if not obsfile[ii]: continue # First line is transmitter with number of receivers if count==0: temp = (np.fromstring(obsfile[ii], dtype=float,sep=' ').T) count = int(temp[-1]) temp = np.reshape(temp[0:-1],[2,3]).T Tx.append(temp) rx = [] continue temp = np.fromstring(obsfile[ii], dtype=float,sep=' ') rx.append(temp) count = count -1 # Reach the end of if count == 0: temp = np.asarray(rx) Rx.append(temp[:,0:6]) # Check for data + uncertainties if temp.shape[1]==8: d.append(temp[:,6]) wd.append(temp[:,7]) # Check for data only elif temp.shape[1]==7: d.append(temp[:,6]) return Tx, Rx, d, wd
def readUBC_DC3Dobs(fileName): """ Read UBC GIF DCIP 3D observation file and generate arrays for tx-rx location Input: :param fileName, path to the UBC GIF 3D obs file Output: :param rx, tx, d, wd :return Created on Mon December 7th, 2015 @author: dominiquef """ # Load file obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='!') # Pre-allocate srcLists = [] Rx = [] d = [] wd = [] zflag = True # Flag for z value provided # Countdown for number of obs/tx count = 0 for ii in range(obsfile.shape[0]): if not obsfile[ii]: continue # First line is transmitter with number of receivers if count==0: temp = (np.fromstring(obsfile[ii], dtype=float,sep=' ').T) count = int(temp[-1]) # Check if z value is provided, if False -> nan if len(temp)==5: tx = np.r_[temp[0:2],np.nan,temp[0:2],np.nan] zflag = False else: tx = temp[:-1] rx = [] continue temp = np.fromstring(obsfile[ii], dtype=float,sep=' ') if zflag: rx.append(temp[:-2]) # Check if there is data with the location if len(temp)==8: d.append(temp[-2]) wd.append(temp[-1]) else: rx.append(np.r_[temp[0:2],np.nan,temp[0:2],np.nan] ) # Check if there is data with the location if len(temp)==6: d.append(temp[-2]) wd.append(temp[-1]) count = count -1 # Reach the end of transmitter block if count == 0: rx = np.asarray(rx) Rx = DC.RxDipole(rx[:,:3],rx[:,3:]) srcLists.append( DC.SrcDipole( [Rx], tx[:3],tx[3:]) ) # Create survey class survey = DC.SurveyDC(srcLists) survey.dobs = np.asarray(d) survey.std = np.asarray(wd) return {'DCsurvey':survey}
def readUBC_DC2Dpre(fileName): """ Read UBC GIF DCIP 2D observation file and generate arrays for tx-rx location Input: :param fileName, path to the UBC GIF 3D obs file Output: DCsurvey :return Created on Mon March 9th, 2016 << Doug's 70th Birthday !! >> @author: dominiquef """ # Load file obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='!') # Pre-allocate srcLists = [] Rx = [] d = [] zflag = True # Flag for z value provided for ii in range(obsfile.shape[0]): if not obsfile[ii]: continue # First line is transmitter with number of receivers temp = (np.fromstring(obsfile[ii], dtype=float,sep=' ').T) # Check if z value is provided, if False -> nan if len(temp)==5: tx = np.r_[temp[0],np.nan,np.nan,temp[1],np.nan,np.nan] zflag = False else: tx = np.r_[temp[0],np.nan,temp[1],temp[2],np.nan,temp[3]] if zflag: rx = np.c_[temp[4],np.nan,temp[5],temp[6],np.nan,temp[7]] else: rx = np.c_[temp[2],np.nan,np.nan,temp[3],np.nan,np.nan] # Check if there is data with the location d.append(temp[-1]) Rx = DC.RxDipole(rx[:,:3],rx[:,3:]) srcLists.append( DC.SrcDipole( [Rx], tx[:3],tx[3:]) ) # Create survey class survey = DC.SurveyDC(srcLists) survey.dobs = np.asarray(d) return {'DCsurvey':survey}
def readUBC_DC3Dobs(fileName, rtype = 'DC'): """ Read UBC GIF IP 3D observation file and generate survey :param string fileName:, path to the UBC GIF 3D obs file :rtype: Survey :return: DCIPsurvey """ zflag = True # Flag for z value provided # Load file if rtype == 'IP': obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='IPTYPE') elif rtype == 'DC': obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='!') else: print "rtype must be 'DC'(default) | 'IP'" # Pre-allocate srcLists = [] Rx = [] d = [] wd = [] # Countdown for number of obs/tx count = 0 for ii in range(obsfile.shape[0]): # Skip if blank line if not obsfile[ii]: continue # First line or end of a transmitter block, read transmitter info if count==0: # Read the line temp = (np.fromstring(obsfile[ii], dtype=float, sep=' ').T) count = int(temp[-1]) # Check if z value is provided, if False -> nan if len(temp)==5: tx = np.r_[temp[0:2],np.nan,temp[2:4],np.nan] zflag = False # Pass on the flag to the receiver loc else: tx = temp[:-1] rx = [] continue temp = np.fromstring(obsfile[ii], dtype=float,sep=' ') # Get the string # Filter out negative IP # if temp[-2] < 0: # count = count -1 # print "Negative!" # # else: # If the Z-location is provided, otherwise put nan if zflag: rx.append(temp[:-2]) # Check if there is data with the location if len(temp)==8: d.append(temp[-2]) wd.append(temp[-1]) else: rx.append(np.r_[temp[0:2],np.nan,temp[2:4],np.nan] ) # Check if there is data with the location if len(temp)==6: d.append(temp[-2]) wd.append(temp[-1]) count = count -1 # Reach the end of transmitter block, append the src, rx and continue if count == 0: rx = np.asarray(rx) Rx = DC.RxDipole(rx[:,:3],rx[:,3:]) srcLists.append( DC.SrcDipole( [Rx], tx[:3],tx[3:]) ) # Create survey class survey = DC.SurveyDC(srcLists) survey.dobs = np.asarray(d) survey.std = np.asarray(wd) return {'DCsurvey':survey}