mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-18 12:40:30 +08:00
Create import functions for UBCDC2D model and mesh.
Start driver function for forward model data from example.
This commit is contained in:
+80
-69
File diff suppressed because one or more lines are too long
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
|
||||
home_dir = 'C:\Users\dominiquef.MIRAGEOSCIENCE\Documents\GIT\SimPEG\simpegdc\simpegDCIP\Dev'
|
||||
|
||||
inpfile = 'MAG3Cfwr.inp'
|
||||
|
||||
os.chdir(home_dir)
|
||||
|
||||
#%%
|
||||
from SimPEG import np, Utils, Mesh
|
||||
import simpegDCIP as DC
|
||||
import pylab as plt
|
||||
|
||||
from readUBC_DC2DMesh import readUBC_DC2DMesh
|
||||
from readUBC_DC2DModel import readUBC_DC2DModel
|
||||
|
||||
# Load UBC mesh 2D
|
||||
mesh = readUBC_DC2DMesh('mesh2d.txt')
|
||||
|
||||
# Load model
|
||||
model = readUBC_DC2DModel('model2d.con')
|
||||
|
||||
# load obs file
|
||||
|
||||
#%% Plot model
|
||||
fig, axs = plt.subplots(1,1, figsize=(10,7))
|
||||
h1 = mesh.plotImage(model, ax = axs)
|
||||
plt.ylim([-1000,0])
|
||||
plt.xlim([0,2000])
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
29
|
||||
-4349.9 -2908.3 1
|
||||
-1947.17 1
|
||||
-1306.45 1
|
||||
-879.30 1
|
||||
-594.53 1
|
||||
-404.69 1
|
||||
-278.13 1
|
||||
-193.75 1
|
||||
-137.50 1
|
||||
-100.00 1
|
||||
-75.00 1
|
||||
-50.00 1
|
||||
-25.00 1
|
||||
0.00 1
|
||||
2000.00 80
|
||||
2025.00 1
|
||||
2050.00 1
|
||||
2075.00 1
|
||||
2100.00 1
|
||||
2137.50 1
|
||||
2193.75 1
|
||||
2278.13 1
|
||||
2404.69 1
|
||||
2594.53 1
|
||||
2879.30 1
|
||||
3306.45 1
|
||||
3947.17 1
|
||||
4908.25 1
|
||||
6349.88 1
|
||||
|
||||
11
|
||||
0.00 975.00 39
|
||||
1462.50 13
|
||||
1518.75 1
|
||||
1603.13 1
|
||||
1729.69 1
|
||||
1919.53 1
|
||||
2204.30 1
|
||||
2631.45 1
|
||||
3272.17 1
|
||||
4233.25 1
|
||||
5674.88 1
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,325 @@
|
||||
0 0 75 150
|
||||
0 0 150 225
|
||||
0 0 225 300
|
||||
0 0 300 375
|
||||
0 0 375 450
|
||||
0 0 450 525
|
||||
0 0 525 600
|
||||
0 0 600 675
|
||||
0 0 675 750
|
||||
0 0 750 825
|
||||
0 0 825 900
|
||||
0 0 900 975
|
||||
0 0 975 1050
|
||||
0 0 1050 1125
|
||||
0 0 1125 1200
|
||||
0 0 1200 1275
|
||||
0 0 1275 1350
|
||||
0 0 1350 1425
|
||||
0 0 1425 1500
|
||||
0 0 1500 1575
|
||||
0 0 1575 1650
|
||||
0 0 1650 1725
|
||||
0 0 1725 1800
|
||||
0 0 1800 1875
|
||||
0 0 1875 1950
|
||||
75 75 150 225
|
||||
75 75 225 300
|
||||
75 75 300 375
|
||||
75 75 375 450
|
||||
75 75 450 525
|
||||
75 75 525 600
|
||||
75 75 600 675
|
||||
75 75 675 750
|
||||
75 75 750 825
|
||||
75 75 825 900
|
||||
75 75 900 975
|
||||
75 75 975 1050
|
||||
75 75 1050 1125
|
||||
75 75 1125 1200
|
||||
75 75 1200 1275
|
||||
75 75 1275 1350
|
||||
75 75 1350 1425
|
||||
75 75 1425 1500
|
||||
75 75 1500 1575
|
||||
75 75 1575 1650
|
||||
75 75 1650 1725
|
||||
75 75 1725 1800
|
||||
75 75 1800 1875
|
||||
75 75 1875 1950
|
||||
150 150 225 300
|
||||
150 150 300 375
|
||||
150 150 375 450
|
||||
150 150 450 525
|
||||
150 150 525 600
|
||||
150 150 600 675
|
||||
150 150 675 750
|
||||
150 150 750 825
|
||||
150 150 825 900
|
||||
150 150 900 975
|
||||
150 150 975 1050
|
||||
150 150 1050 1125
|
||||
150 150 1125 1200
|
||||
150 150 1200 1275
|
||||
150 150 1275 1350
|
||||
150 150 1350 1425
|
||||
150 150 1425 1500
|
||||
150 150 1500 1575
|
||||
150 150 1575 1650
|
||||
150 150 1650 1725
|
||||
150 150 1725 1800
|
||||
150 150 1800 1875
|
||||
150 150 1875 1950
|
||||
225 225 300 375
|
||||
225 225 375 450
|
||||
225 225 450 525
|
||||
225 225 525 600
|
||||
225 225 600 675
|
||||
225 225 675 750
|
||||
225 225 750 825
|
||||
225 225 825 900
|
||||
225 225 900 975
|
||||
225 225 975 1050
|
||||
225 225 1050 1125
|
||||
225 225 1125 1200
|
||||
225 225 1200 1275
|
||||
225 225 1275 1350
|
||||
225 225 1350 1425
|
||||
225 225 1425 1500
|
||||
225 225 1500 1575
|
||||
225 225 1575 1650
|
||||
225 225 1650 1725
|
||||
225 225 1725 1800
|
||||
225 225 1800 1875
|
||||
225 225 1875 1950
|
||||
300 300 375 450
|
||||
300 300 450 525
|
||||
300 300 525 600
|
||||
300 300 600 675
|
||||
300 300 675 750
|
||||
300 300 750 825
|
||||
300 300 825 900
|
||||
300 300 900 975
|
||||
300 300 975 1050
|
||||
300 300 1050 1125
|
||||
300 300 1125 1200
|
||||
300 300 1200 1275
|
||||
300 300 1275 1350
|
||||
300 300 1350 1425
|
||||
300 300 1425 1500
|
||||
300 300 1500 1575
|
||||
300 300 1575 1650
|
||||
300 300 1650 1725
|
||||
300 300 1725 1800
|
||||
300 300 1800 1875
|
||||
300 300 1875 1950
|
||||
375 375 450 525
|
||||
375 375 525 600
|
||||
375 375 600 675
|
||||
375 375 675 750
|
||||
375 375 750 825
|
||||
375 375 825 900
|
||||
375 375 900 975
|
||||
375 375 975 1050
|
||||
375 375 1050 1125
|
||||
375 375 1125 1200
|
||||
375 375 1200 1275
|
||||
375 375 1275 1350
|
||||
375 375 1350 1425
|
||||
375 375 1425 1500
|
||||
375 375 1500 1575
|
||||
375 375 1575 1650
|
||||
375 375 1650 1725
|
||||
375 375 1725 1800
|
||||
375 375 1800 1875
|
||||
375 375 1875 1950
|
||||
450 450 525 600
|
||||
450 450 600 675
|
||||
450 450 675 750
|
||||
450 450 750 825
|
||||
450 450 825 900
|
||||
450 450 900 975
|
||||
450 450 975 1050
|
||||
450 450 1050 1125
|
||||
450 450 1125 1200
|
||||
450 450 1200 1275
|
||||
450 450 1275 1350
|
||||
450 450 1350 1425
|
||||
450 450 1425 1500
|
||||
450 450 1500 1575
|
||||
450 450 1575 1650
|
||||
450 450 1650 1725
|
||||
450 450 1725 1800
|
||||
450 450 1800 1875
|
||||
450 450 1875 1950
|
||||
525 525 600 675
|
||||
525 525 675 750
|
||||
525 525 750 825
|
||||
525 525 825 900
|
||||
525 525 900 975
|
||||
525 525 975 1050
|
||||
525 525 1050 1125
|
||||
525 525 1125 1200
|
||||
525 525 1200 1275
|
||||
525 525 1275 1350
|
||||
525 525 1350 1425
|
||||
525 525 1425 1500
|
||||
525 525 1500 1575
|
||||
525 525 1575 1650
|
||||
525 525 1650 1725
|
||||
525 525 1725 1800
|
||||
525 525 1800 1875
|
||||
525 525 1875 1950
|
||||
600 600 675 750
|
||||
600 600 750 825
|
||||
600 600 825 900
|
||||
600 600 900 975
|
||||
600 600 975 1050
|
||||
600 600 1050 1125
|
||||
600 600 1125 1200
|
||||
600 600 1200 1275
|
||||
600 600 1275 1350
|
||||
600 600 1350 1425
|
||||
600 600 1425 1500
|
||||
600 600 1500 1575
|
||||
600 600 1575 1650
|
||||
600 600 1650 1725
|
||||
600 600 1725 1800
|
||||
600 600 1800 1875
|
||||
600 600 1875 1950
|
||||
675 675 750 825
|
||||
675 675 825 900
|
||||
675 675 900 975
|
||||
675 675 975 1050
|
||||
675 675 1050 1125
|
||||
675 675 1125 1200
|
||||
675 675 1200 1275
|
||||
675 675 1275 1350
|
||||
675 675 1350 1425
|
||||
675 675 1425 1500
|
||||
675 675 1500 1575
|
||||
675 675 1575 1650
|
||||
675 675 1650 1725
|
||||
675 675 1725 1800
|
||||
675 675 1800 1875
|
||||
675 675 1875 1950
|
||||
750 750 825 900
|
||||
750 750 900 975
|
||||
750 750 975 1050
|
||||
750 750 1050 1125
|
||||
750 750 1125 1200
|
||||
750 750 1200 1275
|
||||
750 750 1275 1350
|
||||
750 750 1350 1425
|
||||
750 750 1425 1500
|
||||
750 750 1500 1575
|
||||
750 750 1575 1650
|
||||
750 750 1650 1725
|
||||
750 750 1725 1800
|
||||
750 750 1800 1875
|
||||
750 750 1875 1950
|
||||
825 825 900 975
|
||||
825 825 975 1050
|
||||
825 825 1050 1125
|
||||
825 825 1125 1200
|
||||
825 825 1200 1275
|
||||
825 825 1275 1350
|
||||
825 825 1350 1425
|
||||
825 825 1425 1500
|
||||
825 825 1500 1575
|
||||
825 825 1575 1650
|
||||
825 825 1650 1725
|
||||
825 825 1725 1800
|
||||
825 825 1800 1875
|
||||
825 825 1875 1950
|
||||
900 900 975 1050
|
||||
900 900 1050 1125
|
||||
900 900 1125 1200
|
||||
900 900 1200 1275
|
||||
900 900 1275 1350
|
||||
900 900 1350 1425
|
||||
900 900 1425 1500
|
||||
900 900 1500 1575
|
||||
900 900 1575 1650
|
||||
900 900 1650 1725
|
||||
900 900 1725 1800
|
||||
900 900 1800 1875
|
||||
900 900 1875 1950
|
||||
975 975 1050 1125
|
||||
975 975 1125 1200
|
||||
975 975 1200 1275
|
||||
975 975 1275 1350
|
||||
975 975 1350 1425
|
||||
975 975 1425 1500
|
||||
975 975 1500 1575
|
||||
975 975 1575 1650
|
||||
975 975 1650 1725
|
||||
975 975 1725 1800
|
||||
975 975 1800 1875
|
||||
975 975 1875 1950
|
||||
1050 1050 1125 1200
|
||||
1050 1050 1200 1275
|
||||
1050 1050 1275 1350
|
||||
1050 1050 1350 1425
|
||||
1050 1050 1425 1500
|
||||
1050 1050 1500 1575
|
||||
1050 1050 1575 1650
|
||||
1050 1050 1650 1725
|
||||
1050 1050 1725 1800
|
||||
1050 1050 1800 1875
|
||||
1050 1050 1875 1950
|
||||
1125 1125 1200 1275
|
||||
1125 1125 1275 1350
|
||||
1125 1125 1350 1425
|
||||
1125 1125 1425 1500
|
||||
1125 1125 1500 1575
|
||||
1125 1125 1575 1650
|
||||
1125 1125 1650 1725
|
||||
1125 1125 1725 1800
|
||||
1125 1125 1800 1875
|
||||
1125 1125 1875 1950
|
||||
1200 1200 1275 1350
|
||||
1200 1200 1350 1425
|
||||
1200 1200 1425 1500
|
||||
1200 1200 1500 1575
|
||||
1200 1200 1575 1650
|
||||
1200 1200 1650 1725
|
||||
1200 1200 1725 1800
|
||||
1200 1200 1800 1875
|
||||
1200 1200 1875 1950
|
||||
1275 1275 1350 1425
|
||||
1275 1275 1425 1500
|
||||
1275 1275 1500 1575
|
||||
1275 1275 1575 1650
|
||||
1275 1275 1650 1725
|
||||
1275 1275 1725 1800
|
||||
1275 1275 1800 1875
|
||||
1275 1275 1875 1950
|
||||
1350 1350 1425 1500
|
||||
1350 1350 1500 1575
|
||||
1350 1350 1575 1650
|
||||
1350 1350 1650 1725
|
||||
1350 1350 1725 1800
|
||||
1350 1350 1800 1875
|
||||
1350 1350 1875 1950
|
||||
1425 1425 1500 1575
|
||||
1425 1425 1575 1650
|
||||
1425 1425 1650 1725
|
||||
1425 1425 1725 1800
|
||||
1425 1425 1800 1875
|
||||
1425 1425 1875 1950
|
||||
1500 1500 1575 1650
|
||||
1500 1500 1650 1725
|
||||
1500 1500 1725 1800
|
||||
1500 1500 1800 1875
|
||||
1500 1500 1875 1950
|
||||
1575 1575 1650 1725
|
||||
1575 1575 1725 1800
|
||||
1575 1575 1800 1875
|
||||
1575 1575 1875 1950
|
||||
1650 1650 1725 1800
|
||||
1650 1650 1800 1875
|
||||
1650 1650 1875 1950
|
||||
1725 1725 1800 1875
|
||||
1725 1725 1875 1950
|
||||
1800 1800 1875 1950
|
||||
@@ -0,0 +1,70 @@
|
||||
def readUBC_DC2DMesh(fileName):
|
||||
|
||||
from SimPEG import np
|
||||
"""
|
||||
Read UBC GIF 2DTensor mesh and generate 2D Tensor mesh in simpeg
|
||||
|
||||
Input:
|
||||
:param fileName, path to the UBC GIF mesh file
|
||||
|
||||
Output:
|
||||
:param SimPEG TensorMesh 2D object
|
||||
:return
|
||||
|
||||
Created on Thu Nov 12 13:14:10 2015
|
||||
|
||||
@author: dominiquef
|
||||
|
||||
"""
|
||||
|
||||
# Open file
|
||||
fopen = open(fileName,'r')
|
||||
|
||||
# Read down the file and unpack dx vector
|
||||
def unpackdx(fid,nrows):
|
||||
for ii in range(nrows):
|
||||
|
||||
line = fid.readline()
|
||||
var = np.array(line.split(),dtype=float)
|
||||
|
||||
if ii==0:
|
||||
x0= var[0]
|
||||
xvec = np.ones(int(var[2])) * (var[1] - var[0]) / int(var[2])
|
||||
xend = var[1]
|
||||
|
||||
else:
|
||||
xvec = np.hstack((xvec,np.ones(int(var[1])) * (var[0] - xend) / int(var[1])))
|
||||
xend = var[0]
|
||||
|
||||
return x0, xvec
|
||||
|
||||
#%% Start with dx block
|
||||
# First line specifies the number of rows for x-cells
|
||||
line = fopen.readline()
|
||||
nl = np.array(line.split(),dtype=float)
|
||||
|
||||
[x0, dx] = unpackdx(fopen,nl)
|
||||
|
||||
|
||||
#%% Move down the file until reaching the z-block
|
||||
line = fopen.readline()
|
||||
if not line:
|
||||
line = fopen.readline()
|
||||
|
||||
#%% End with dz block
|
||||
# First line specifies the number of rows for z-cells
|
||||
line = fopen.readline()
|
||||
nl = np.array(line.split(),dtype=float)
|
||||
|
||||
[z0, dz] = unpackdx(fopen,nl)
|
||||
|
||||
# Flip z0 to be the bottom of the mesh for SimPEG
|
||||
z0 = z0 - sum(dz)
|
||||
dz = dz[::-1]
|
||||
#%% Make the mesh using SimPEG
|
||||
|
||||
from SimPEG import Mesh
|
||||
tensMsh = Mesh.TensorMesh([dx,dz],(x0, z0))
|
||||
return tensMsh
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
def readUBC_DC2DModel(fileName):
|
||||
|
||||
from SimPEG import np, mkvc
|
||||
"""
|
||||
Read UBC GIF 2DTensor model and generate 2D Tensor model in simpeg
|
||||
|
||||
Input:
|
||||
:param fileName, path to the UBC GIF 2D model file
|
||||
|
||||
Output:
|
||||
:param SimPEG TensorMesh 2D object
|
||||
: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()
|
||||
|
||||
dim = np.array(lines[0].split(),dtype=float)
|
||||
|
||||
model = np.array(lines[1:],dtype=float)
|
||||
|
||||
# Permute the second dimension to flip the order
|
||||
model = model.reshape(dim[1],dim[0])
|
||||
|
||||
model = model[::-1,:]
|
||||
model = np.transpose(model, (1, 0))
|
||||
model = mkvc(model)
|
||||
|
||||
|
||||
return model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user