-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also fixed plotting codes to show the plots by default.
- Loading branch information
Showing
10 changed files
with
215 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,4 @@ nosetests.xml | |
docs/_build/ | ||
Makefile | ||
docs/warnings.txt | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from SimPEG import Mesh, Maps, np | ||
|
||
def run(plotIt=True): | ||
""" | ||
Maps: ComboMaps | ||
=============== | ||
We will use an example where we want a 1D layered earth as | ||
our model, but we want to map this to a 2D discretization to do our forward | ||
modeling. We will also assume that we are working in log conductivity still, | ||
so after the transformation we want to map to conductivity space. | ||
To do this we will introduce the vertical 1D map (:class:`SimPEG.Maps.SurjectVertical1D`), | ||
which does the first part of what we just described. The second part will be | ||
done by the :class:`SimPEG.Maps.ExpMap` described above. | ||
.. code-block:: python | ||
:linenos: | ||
M = Mesh.TensorMesh([7,5]) | ||
v1dMap = Maps.SurjectVertical1D(M) | ||
expMap = Maps.ExpMap(M) | ||
myMap = expMap * v1dMap | ||
m = np.r_[0.2,1,0.1,2,2.9] # only 5 model parameters! | ||
sig = myMap * m | ||
If you noticed, it was pretty easy to combine maps. What is even cooler is | ||
that the derivatives also are made for you (if everything goes right). | ||
Just to be sure that the derivative is correct, you should always run the test | ||
on the mapping that you create. | ||
""" | ||
|
||
|
||
M = Mesh.TensorMesh([7,5]) | ||
v1dMap = Maps.SurjectVertical1D(M) | ||
expMap = Maps.ExpMap(M) | ||
myMap = expMap * v1dMap | ||
m = np.r_[0.2,1,0.1,2,2.9] # only 5 model parameters! | ||
sig = myMap * m | ||
|
||
if not plotIt: return | ||
|
||
import matplotlib.pyplot as plt | ||
figs, axs = plt.subplots(1,2) | ||
axs[0].plot(m, M.vectorCCy, 'b-o') | ||
axs[0].set_title('Model') | ||
axs[0].set_ylabel('Depth, y') | ||
axs[0].set_xlabel('Value, $m_i$') | ||
axs[0].set_xlim(0,3) | ||
axs[0].set_ylim(0,1) | ||
clbar = plt.colorbar(M.plotImage(sig,ax=axs[1],grid=True,gridOpts=dict(color='grey'))[0]) | ||
axs[1].set_title('Physical Property') | ||
axs[1].set_ylabel('Depth, y') | ||
clbar.set_label('$\sigma = \exp(\mathbf{P}m)$') | ||
plt.tight_layout() | ||
plt.show() | ||
|
||
|
||
if __name__ == '__main__': | ||
run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from SimPEG import Mesh, Maps, Utils | ||
|
||
def run(plotIt=True): | ||
""" | ||
Maps: Mesh2Mesh | ||
=============== | ||
This mapping allows you to go from one mesh to another. | ||
""" | ||
|
||
M = Mesh.TensorMesh([100,100]) | ||
h1 = Utils.meshTensor([(6,7,-1.5),(6,10),(6,7,1.5)]) | ||
h1 = h1/h1.sum() | ||
M2 = Mesh.TensorMesh([h1,h1]) | ||
V = Utils.ModelBuilder.randomModel(M.vnC, seed=79, its=50) | ||
v = Utils.mkvc(V) | ||
modh = Maps.Mesh2Mesh([M,M2]) | ||
modH = Maps.Mesh2Mesh([M2,M]) | ||
H = modH * v | ||
h = modh * H | ||
|
||
if not plotIt: return | ||
|
||
import matplotlib.pyplot as plt | ||
ax = plt.subplot(131) | ||
M.plotImage(v, ax=ax) | ||
ax.set_title('Fine Mesh (Original)') | ||
ax = plt.subplot(132) | ||
M2.plotImage(H,clim=[0,1],ax=ax) | ||
ax.set_title('Course Mesh') | ||
ax = plt.subplot(133) | ||
M.plotImage(h,clim=[0,1],ax=ax) | ||
ax.set_title('Fine Mesh (Interpolated)') | ||
plt.show() | ||
|
||
|
||
if __name__ == '__main__': | ||
run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. _examples_Inversion_IRLS: | ||
|
||
.. --------------------------------- .. | ||
.. .. | ||
.. THIS FILE IS AUTO GENEREATED .. | ||
.. .. | ||
.. SimPEG/Examples/__init__.py .. | ||
.. .. | ||
.. --------------------------------- .. | ||
Inversion: Linear Problem | ||
========================= | ||
|
||
Here we go over the basics of creating a linear problem and inversion. | ||
|
||
|
||
|
||
.. plot:: | ||
|
||
from SimPEG import Examples | ||
Examples.Inversion_IRLS.run() | ||
|
||
.. literalinclude:: ../../../SimPEG/Examples/Inversion_IRLS.py | ||
:language: python | ||
:linenos: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.. _examples_Maps_ComboMaps: | ||
|
||
.. --------------------------------- .. | ||
.. .. | ||
.. THIS FILE IS AUTO GENEREATED .. | ||
.. .. | ||
.. SimPEG/Examples/__init__.py .. | ||
.. .. | ||
.. --------------------------------- .. | ||
Maps: ComboMaps | ||
=============== | ||
|
||
We will use an example where we want a 1D layered earth as | ||
our model, but we want to map this to a 2D discretization to do our forward | ||
modeling. We will also assume that we are working in log conductivity still, | ||
so after the transformation we want to map to conductivity space. | ||
To do this we will introduce the vertical 1D map (:class:`SimPEG.Maps.SurjectVertical1D`), | ||
which does the first part of what we just described. The second part will be | ||
done by the :class:`SimPEG.Maps.ExpMap` described above. | ||
|
||
.. code-block:: python | ||
:linenos: | ||
M = Mesh.TensorMesh([7,5]) | ||
v1dMap = Maps.SurjectVertical1D(M) | ||
expMap = Maps.ExpMap(M) | ||
myMap = expMap * v1dMap | ||
m = np.r_[0.2,1,0.1,2,2.9] # only 5 model parameters! | ||
sig = myMap * m | ||
If you noticed, it was pretty easy to combine maps. What is even cooler is | ||
that the derivatives also are made for you (if everything goes right). | ||
Just to be sure that the derivative is correct, you should always run the test | ||
on the mapping that you create. | ||
|
||
|
||
|
||
.. plot:: | ||
|
||
from SimPEG import Examples | ||
Examples.Maps_ComboMaps.run() | ||
|
||
.. literalinclude:: ../../../SimPEG/Examples/Maps_ComboMaps.py | ||
:language: python | ||
:linenos: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.. _examples_Maps_Mesh2Mesh: | ||
|
||
.. --------------------------------- .. | ||
.. .. | ||
.. THIS FILE IS AUTO GENEREATED .. | ||
.. .. | ||
.. SimPEG/Examples/__init__.py .. | ||
.. .. | ||
.. --------------------------------- .. | ||
Maps: Mesh2Mesh | ||
=============== | ||
|
||
This mapping allows you to go from one mesh to another. | ||
|
||
|
||
|
||
.. plot:: | ||
|
||
from SimPEG import Examples | ||
Examples.Maps_Mesh2Mesh.run() | ||
|
||
.. literalinclude:: ../../../SimPEG/Examples/Maps_Mesh2Mesh.py | ||
:language: python | ||
:linenos: |