Fix merge conflicts and add read GOCAD triangulated surface file

This commit is contained in:
D Fournier
2016-01-15 12:38:08 -08:00
parent dc7b8607eb
commit 44b7dd184f
4 changed files with 1609 additions and 39 deletions
+35 -1
View File
@@ -360,4 +360,38 @@ def read_MAGinv_inp(input_file):
else:
lpnorms = l_input[0].rstrip()
return mshfile, obsfile, topofile, mstart, mref, magfile, wgtfile, chi, alphas, bounds, lpnorms
return mshfile, obsfile, topofile, mstart, mref, magfile, wgtfile, chi, alphas, bounds, lpnorms
def read_GOCAD_ts(tsfile):
"""Read GOCAD triangulated surface (*.ts) file
INPUT:
tsfile: Triangulated surface
OUTPUT:
vrts : Array of vertices in XYZ coordinates [n x 3]
trgl : Array of index for triangles [m x 3]. The order of the vertices
is important and describes the normal
n = cross( (P2 - P1 ) , (P3 - P1) )
Created on Jan 13th, 2016
Author: @fourndo
"""
fid = open(tsfile,'r')
line = fid.readline()
# Skip all the lines until the vertices
while re.match('TFACE',line)==None:
line = fid.readline()
line = fid.readline()
vrtx = []
# Run down all the vertices and save in array
while re.match('VRTX',line):
l_input = line.split('\s')
vrtx = np.vstack([vrtx,l_input[1]])
return vrtx
+3
View File
@@ -46,6 +46,9 @@ rxLoc = dobs[:,0:3]
#rxLoc[:,2] += 5 # Temporary change for test
ndata = rxLoc.shape[0]
# Load GOCAD surf
tsfile = 'SphereA.ts'
vrtx = PF.BaseMag.read_GOCAD_ts(tsfile)
#%% Run forward modeling
# Compute forward model using integral equation
d = PF.Magnetics.Intgrl_Fwr_Data(mesh,B,M,rxLoc,model,actv,'tmi')
+2
View File
@@ -874,6 +874,8 @@ def get_dist_wgt(mesh,rxLoc,R,R0):
wr = mkvc(wr)
wr = np.sqrt(wr/(np.max(wr)))
print "Done 100% ...distance weighting completed!!\n"
return wr
def writeUBCobs(filename,B,M,rxLoc,d,wd):
File diff suppressed because one or more lines are too long