From ade37fb4931b635056318aacc2138a5b157038cb Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 09:51:57 -0800 Subject: [PATCH 01/77] add travis to docs. nit-picky testing on html, latex, link check --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 258c4b7b..4ac1849f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,6 +45,11 @@ install: # Run test script: - nosetests $TEST_DIR --with-cov --cov SimPEG --cov-config .coveragerc -v -s + # test docs + - cd docs + - sphinx-build -nW -b html -d _build/doctrees . _build/html + - sphinx-build docs -nW -b latex -d _build/doctrees . _build/latex + - sphinx-build docs -nW -b linkcheck -d _build/doctrees . _build/linkcheck # Calculate coverage after_success: From ac2e38e89d7894957a17614d3367a213554f3b8a Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 10:47:00 -0800 Subject: [PATCH 02/77] test docs first --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4ac1849f..d437ce0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,12 +44,15 @@ install: # Run test script: - - nosetests $TEST_DIR --with-cov --cov SimPEG --cov-config .coveragerc -v -s # test docs - cd docs - sphinx-build -nW -b html -d _build/doctrees . _build/html - sphinx-build docs -nW -b latex -d _build/doctrees . _build/latex - sphinx-build docs -nW -b linkcheck -d _build/doctrees . _build/linkcheck + - cd ../ + + - nosetests $TEST_DIR --with-cov --cov SimPEG --cov-config .coveragerc -v -s + # Calculate coverage after_success: From e005ed8f5f6c9a25346de25a698c8603023599ab Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 10:51:55 -0800 Subject: [PATCH 03/77] use cd to get into docs directories for testing --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d437ce0d..39b18a33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,8 +47,8 @@ script: # test docs - cd docs - sphinx-build -nW -b html -d _build/doctrees . _build/html - - sphinx-build docs -nW -b latex -d _build/doctrees . _build/latex - - sphinx-build docs -nW -b linkcheck -d _build/doctrees . _build/linkcheck + - sphinx-build -nW -b latex -d _build/doctrees . _build/latex + - sphinx-build -nW -b linkcheck -d _build/doctrees . _build/linkcheck - cd ../ - nosetests $TEST_DIR --with-cov --cov SimPEG --cov-config .coveragerc -v -s From e314bdb740910ec46ef7175459f77d2783bb8cb6 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 11:06:47 -0800 Subject: [PATCH 04/77] add sphinx to travis conda install --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39b18a33..00e19168 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ before_install: # Install packages install: - - conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython ipython nose + - conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython ipython nose sphinx - pip install nose-cov python-coveralls - git clone https://github.com/rowanc1/pymatsolver.git From f4ef767764948d5030624380006cb26392c79bbb Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 12:08:29 -0800 Subject: [PATCH 05/77] seperate out docs test so it runs independently (not on every test) --- .travis.yml | 7 +------ tests/docs/test_docs.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 tests/docs/test_docs.py diff --git a/.travis.yml b/.travis.yml index 00e19168..1ee3e434 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ env: - TEST_DIR=tests/examples - TEST_DIR=tests/em/fdem/inverse/adjoint - TEST_DIR=tests/em/fdem/forward + - TEST_DIR=tests/docs # Setup anaconda before_install: @@ -45,12 +46,6 @@ install: # Run test script: # test docs - - cd docs - - sphinx-build -nW -b html -d _build/doctrees . _build/html - - sphinx-build -nW -b latex -d _build/doctrees . _build/latex - - sphinx-build -nW -b linkcheck -d _build/doctrees . _build/linkcheck - - cd ../ - - nosetests $TEST_DIR --with-cov --cov SimPEG --cov-config .coveragerc -v -s diff --git a/tests/docs/test_docs.py b/tests/docs/test_docs.py new file mode 100644 index 00000000..cb060743 --- /dev/null +++ b/tests/docs/test_docs.py @@ -0,0 +1,21 @@ +import subprocess +import unittest +import os + + +class Doc_Test(unittest.TestCase): + + def test_html(self,rmdir=True): + check = subprocess.call(["sphinx-build", "-nW", "-b", "html", "-d", "../../docs/_build/doctrees", "../../docs", "../../docs/_build/html"]) + assert check == 0 + + def test_latex(self,rmdir=True): + check = subprocess.call(["sphinx-build", "-nW", "-b", "latex", "-d", "../../docs/_build/doctrees", "../../docs", "../../docs/_build/latex"]) + assert check == 0 + + def test_linkcheck(self,rmdir=True): + check = subprocess.call(["sphinx-build", "-nW", "-b", "linkcheck", "-d", "../../docs/_build/doctrees", "../../docs", "../../docs/_build"]) + assert check == 0 + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From d9d6f70958d58ce2967fb9c60de697983d1daa85 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 12:45:51 -0800 Subject: [PATCH 06/77] better description of paths in test_docs --- tests/docs/test_docs.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/tests/docs/test_docs.py b/tests/docs/test_docs.py index cb060743..cee68206 100644 --- a/tests/docs/test_docs.py +++ b/tests/docs/test_docs.py @@ -2,19 +2,41 @@ import subprocess import unittest import os - class Doc_Test(unittest.TestCase): - def test_html(self,rmdir=True): - check = subprocess.call(["sphinx-build", "-nW", "-b", "html", "-d", "../../docs/_build/doctrees", "../../docs", "../../docs/_build/html"]) + @property + def path_to_docs(self): + dirname, filename = os.path.split(os.path.abspath(__file__)) + return os.path.sep.join(dirname.split(os.path.sep)[:-2] + ['docs']) + + def test_html(self): + doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) + html_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['html']) + + check = subprocess.call(["sphinx-build", "-nW", "-b", "html", "-d", + "%s"%(doctrees_path) , + "%s"%(self.path_to_docs), + "%s"%(html_path)]) assert check == 0 - def test_latex(self,rmdir=True): - check = subprocess.call(["sphinx-build", "-nW", "-b", "latex", "-d", "../../docs/_build/doctrees", "../../docs", "../../docs/_build/latex"]) + def test_latex(self): + doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) + latex_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['latex']) + + check = subprocess.call(["sphinx-build", "-nW", "-b", "latex", "-d", + "%s"%(doctrees_path), + "%s"%(self.path_to_docs), + "%s"%(latex_path)]) assert check == 0 - def test_linkcheck(self,rmdir=True): - check = subprocess.call(["sphinx-build", "-nW", "-b", "linkcheck", "-d", "../../docs/_build/doctrees", "../../docs", "../../docs/_build"]) + def test_linkcheck(self): + doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) + link_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']) + + check = subprocess.call(["sphinx-build", "-nW", "-b", "linkcheck", "-d", + "%s"%(doctrees_path), + "%s"%(self.path_to_docs), + "%s"%(link_path)]) assert check == 0 if __name__ == '__main__': From adca273565f565fa46696277eaccfa3bc62fff28 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 12:46:24 -0800 Subject: [PATCH 07/77] ignore nonlocal images in sphinx build --- docs/conf.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index fee262de..10a25e7b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -251,3 +251,15 @@ texinfo_documents = [ #texinfo_show_urls = 'footnote' autodoc_member_order = 'bysource' + + +# -- User Defined ------------------------------------------------ +import sphinx.environment +from docutils.utils import get_source_line + +# supress nonlocal image warn +def _supress_nonlocal_image_warn(self, msg, node): + if not msg.startswith('nonlocal image URI found:'): + self._warnfunc(msg, '%s:%s' % get_source_line(node)) + +sphinx.environment.BuildEnvironment.warn_node = _supress_nonlocal_image_warn From 2874e204ee3c4a3c42da17e18de5d25e49dccf49 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 12:52:42 -0800 Subject: [PATCH 08/77] exclude _static from warnings --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 10a25e7b..39589e82 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,7 +67,7 @@ release = '0.1.9' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ['_build','_static'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None From 841ba6100680cee00945eea232806574b3571b31 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 13:22:36 -0800 Subject: [PATCH 09/77] clean up the html build --- SimPEG/Mesh/TensorMesh.py | 6 ++++-- SimPEG/Utils/meshutils.py | 16 +++++++++------- docs/api_Solver.rst | 2 ++ docs/api_Utils.rst | 11 ++++++++--- docs/conf.py | 4 ++-- docs/flow/index.rst | 5 +++-- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/SimPEG/Mesh/TensorMesh.py b/SimPEG/Mesh/TensorMesh.py index c76306fe..d2353c55 100644 --- a/SimPEG/Mesh/TensorMesh.py +++ b/SimPEG/Mesh/TensorMesh.py @@ -197,9 +197,10 @@ class BaseTensorMesh(BaseMesh): Determines if a set of points are inside a mesh. :param numpy.ndarray pts: Location of points to test - :rtype numpy.ndarray - :return inside, numpy array of booleans + :rtype numpy.ndarray: + :return inside, numpy array of booleans: """ + pts = Utils.asArray_N_x_Dim(pts, self.dim) tensors = self.getTensor(locType) @@ -234,6 +235,7 @@ class BaseTensorMesh(BaseMesh): 'N' -> scalar field defined on nodes 'CC' -> scalar field defined on cell centers """ + if self._meshType == 'CYL' and self.isSymmetric and locType in ['Ex','Ez','Fy']: raise Exception('Symmetric CylMesh does not support %s interpolation, as this variable does not exist.' % locType) diff --git a/SimPEG/Utils/meshutils.py b/SimPEG/Utils/meshutils.py index 585fcc9a..80ca0118 100644 --- a/SimPEG/Utils/meshutils.py +++ b/SimPEG/Utils/meshutils.py @@ -321,13 +321,15 @@ def writeVTRFile(fileName,mesh,model=None): def ExtractCoreMesh(xyzlim, mesh, meshType='tensor'): """ - Extracts Core Mesh from Global mesh - xyzlim: 2D array [ndim x 2] - mesh: SimPEG mesh - This function ouputs: - - actind: corresponding boolean index from global to core - - meshcore: core SimPEG mesh - Warning: 1D and 2D has not been tested + Extracts Core Mesh from Global mesh + xyzlim: 2D array [ndim x 2] + mesh: SimPEG mesh + + This function ouputs: + - actind: corresponding boolean index from global to core + - meshcore: core SimPEG mesh + + Warning: 1D and 2D has not been tested """ from SimPEG import Mesh if mesh.dim ==1: diff --git a/docs/api_Solver.rst b/docs/api_Solver.rst index d96bd9b2..2d237c46 100644 --- a/docs/api_Solver.rst +++ b/docs/api_Solver.rst @@ -46,6 +46,8 @@ The API ======= .. autofunction:: SimPEG.Utils.SolverUtils.SolverWrapD + :noindex: .. autofunction:: SimPEG.Utils.SolverUtils.SolverWrapI + :noindex: diff --git a/docs/api_Utils.rst b/docs/api_Utils.rst index 1bf86516..c3145a41 100644 --- a/docs/api_Utils.rst +++ b/docs/api_Utils.rst @@ -21,7 +21,7 @@ Solver Utilities :undoc-members: Curv Utilities -============= +============== .. automodule:: SimPEG.Utils.curvutils :members: @@ -51,7 +51,9 @@ Interpolation Utilities Counter Utilities ================= -:: +.. code-block:: python + :linenos: + class MyClass(object): def __init__(self, url): self.counter = Counter() @@ -68,8 +70,9 @@ Counter Utilities for i in range(100): c.MyMethod() for i in range(300): c.MySecondMethod() c.counter.summary() + -:: +.. code-block:: none Counters: MyClass.MyMethod : 100 @@ -77,6 +80,8 @@ Counter Utilities Times: mean sum MyClass.MySecondMethod : 1.70e-06, 5.10e-04, 300x + + The API ------- diff --git a/docs/conf.py b/docs/conf.py index 39589e82..c117b152 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,7 +67,7 @@ release = '0.1.9' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build','_static'] +exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None @@ -129,7 +129,7 @@ except Exception, e: # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. diff --git a/docs/flow/index.rst b/docs/flow/index.rst index 3c8083fc..c7960382 100644 --- a/docs/flow/index.rst +++ b/docs/flow/index.rst @@ -35,13 +35,14 @@ Here we reproduce the results from Celia et al. (1990): .. plot:: - from SimPEG.FLOW.Examples import Celia1990 + from SimPEG.Examples import FLOW_Richards_1D_Celia1990 as Celia1990 Celia1990.run() + Richards ======== -.. automodule:: simpegFLOW.Richards.Empirical +.. automodule:: SimPEG.FLOW.Richards.Empirical :show-inheritance: :members: :undoc-members: From 012d2cadf109f34c947b95c2203d7e9be72ca8f6 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 13:54:24 -0800 Subject: [PATCH 10/77] use intersphinx mapping to get numpy, scipy, matplotlib, python inventories --- docs/conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index c117b152..f8dd224c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,7 @@ sys.path.append('../') # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc', 'matplotlib.sphinxext.plot_directive'] +extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'matplotlib.sphinxext.plot_directive'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -229,6 +229,12 @@ man_pages = [ # If true, show URL addresses after external links. #man_show_urls = False +# Intersphinx +intersphinx_mapping = {'python': ('http://docs.python.org/2', None), + 'numpy': ('http://docs.scipy.org/doc/numpy/', None), + 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None), + 'matplotlib': ('http://matplotlib.sourceforge.net/', None)} + # -- Options for Texinfo output ------------------------------------------------ From 2254eedbac73f08e25e49cc9a2311839888eb383 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 13:54:39 -0800 Subject: [PATCH 11/77] indentations clean up in FDEM.py --- SimPEG/EM/FDEM/FDEM.py | 65 ++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/SimPEG/EM/FDEM/FDEM.py b/SimPEG/EM/FDEM/FDEM.py index f2167fd8..66c682c3 100644 --- a/SimPEG/EM/FDEM/FDEM.py +++ b/SimPEG/EM/FDEM/FDEM.py @@ -29,6 +29,7 @@ class BaseFDEMProblem(BaseEMProblem): if using the H-J formulation (:code:`Problem_j` or :code:`Problem_h`). The problem performs the elimination so that we are solving the system for \\\(\\\mathbf{e},\\\mathbf{b},\\\mathbf{j} \\\) or \\\(\\\mathbf{h}\\\) + """ surveyPair = SurveyFDEM @@ -149,6 +150,7 @@ class BaseFDEMProblem(BaseEMProblem): :param float freq: Frequency :rtype: numpy.ndarray (nE or nF, nSrc) :return: S_m, S_e + """ Srcs = self.survey.getSrcByFreq(freq) if self._eqLocs is 'FE': @@ -186,6 +188,7 @@ class Problem_e(BaseFDEMProblem): \\left(\mathbf{C}^T \mathbf{M_{\mu^{-1}}^f} \mathbf{C}+ i \omega \mathbf{M^e_{\sigma}} \\right)\mathbf{e} = \mathbf{C}^T \mathbf{M_{\mu^{-1}}^f}\mathbf{s_m} -i\omega\mathbf{M^e}\mathbf{s_e} which we solve for \\\(\\\mathbf{e}\\\). + """ _fieldType = 'e' @@ -222,12 +225,13 @@ class Problem_e(BaseFDEMProblem): def getRHS(self, freq): """ - .. math :: - \mathbf{RHS} = \mathbf{C}^T \mathbf{M_{\mu^{-1}}^f}\mathbf{s_m} -i\omega\mathbf{M_e}\mathbf{s_e} + .. math :: + \mathbf{RHS} = \mathbf{C}^T \mathbf{M_{\mu^{-1}}^f}\mathbf{s_m} -i\omega\mathbf{M_e}\mathbf{s_e} + + :param float freq: Frequency + :rtype: numpy.ndarray (nE, nSrc) + :return: RHS - :param float freq: Frequency - :rtype: numpy.ndarray (nE, nSrc) - :return: RHS """ S_m, S_e = self.getSourceTerm(freq) @@ -370,20 +374,20 @@ class Problem_b(BaseFDEMProblem): class Problem_j(BaseFDEMProblem): """ - We eliminate \\\(\\\mathbf{h}\\\) using + We eliminate \\\(\\\mathbf{h}\\\) using - .. math :: + .. math :: - \mathbf{h} = \\frac{1}{i \omega} \mathbf{M_{\mu}^e}^{-1} \\left(-\mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{j} + \mathbf{M^e} \mathbf{s_m} \\right) + \mathbf{h} = \\frac{1}{i \omega} \mathbf{M_{\mu}^e}^{-1} \\left(-\mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{j} + \mathbf{M^e} \mathbf{s_m} \\right) - and solve for \\\(\\\mathbf{j}\\\) using + and solve for \\\(\\\mathbf{j}\\\) using - .. math :: + .. math :: - \\left(\mathbf{C} \mathbf{M_{\mu}^e}^{-1} \mathbf{C}^T \mathbf{M_{\\rho}^f} + i \omega\\right)\mathbf{j} = \mathbf{C} \mathbf{M_{\mu}^e}^{-1} \mathbf{M^e} \mathbf{s_m} -i\omega\mathbf{s_e} + \\left(\mathbf{C} \mathbf{M_{\mu}^e}^{-1} \mathbf{C}^T \mathbf{M_{\\rho}^f} + i \omega\\right)\mathbf{j} = \mathbf{C} \mathbf{M_{\mu}^e}^{-1} \mathbf{M^e} \mathbf{s_m} -i\omega\mathbf{s_e} - .. note:: - This implementation does not yet work with full anisotropy!! + .. note:: + This implementation does not yet work with full anisotropy!! """ @@ -402,6 +406,7 @@ class Problem_j(BaseFDEMProblem): :param float freq: Frequency :rtype: scipy.sparse.csr_matrix :return: A + """ MeMuI = self.MeMuI @@ -418,12 +423,13 @@ class Problem_j(BaseFDEMProblem): def getADeriv_m(self, freq, u, v, adjoint=False): """ - In this case, we assume that electrical conductivity, \\\(\\\sigma\\\) is the physical property of interest (i.e. \\\(\\\sigma\\\) = model.transform). Then we want + In this case, we assume that electrical conductivity, \\\(\\\sigma\\\) is the physical property of interest (i.e. \\\(\\\sigma\\\) = model.transform). Then we want - .. math :: + .. math :: + + \\frac{\mathbf{A(\sigma)} \mathbf{v}}{d \\mathbf{m}} &= \\mathbf{C} \\mathbf{M^e_{mu^{-1}}} \\mathbf{C^T} \\frac{d \\mathbf{M^f_{\\sigma^{-1}}}}{d \\mathbf{m}} + &= \\mathbf{C} \\mathbf{M^e_{mu}^{-1}} \\mathbf{C^T} \\frac{d \\mathbf{M^f_{\\sigma^{-1}}}}{d \\mathbf{\\sigma^{-1}}} \\frac{d \\mathbf{\\sigma^{-1}}}{d \\mathbf{\\sigma}} \\frac{d \\mathbf{\\sigma}}{d \\mathbf{m}} - \\frac{\mathbf{A(\sigma)} \mathbf{v}}{d \\mathbf{m}} &= \\mathbf{C} \\mathbf{M^e_{mu^{-1}}} \\mathbf{C^T} \\frac{d \\mathbf{M^f_{\\sigma^{-1}}}}{d \\mathbf{m}} - &= \\mathbf{C} \\mathbf{M^e_{mu}^{-1}} \\mathbf{C^T} \\frac{d \\mathbf{M^f_{\\sigma^{-1}}}}{d \\mathbf{\\sigma^{-1}}} \\frac{d \\mathbf{\\sigma^{-1}}}{d \\mathbf{\\sigma}} \\frac{d \\mathbf{\\sigma}}{d \\mathbf{m}} """ MeMuI = self.MeMuI @@ -443,12 +449,13 @@ class Problem_j(BaseFDEMProblem): def getRHS(self, freq): """ - .. math :: + .. math :: + \mathbf{RHS} = \mathbf{C} \mathbf{M_{\mu}^e}^{-1}\mathbf{s_m} -i\omega \mathbf{s_e} + + :param float freq: Frequency + :rtype: numpy.ndarray (nE, nSrc) + :return: RHS - \mathbf{RHS} = \mathbf{C} \mathbf{M_{\mu}^e}^{-1}\mathbf{s_m} -i\omega \mathbf{s_e} - :param float freq: Frequency - :rtype: numpy.ndarray (nE, nSrc) - :return: RHS """ S_m, S_e = self.getSourceTerm(freq) @@ -486,17 +493,17 @@ class Problem_j(BaseFDEMProblem): class Problem_h(BaseFDEMProblem): """ - We eliminate \\\(\\\mathbf{j}\\\) using + We eliminate \\\(\\\mathbf{j}\\\) using - .. math :: + .. math :: - \mathbf{j} = \mathbf{C} \mathbf{h} - \mathbf{s_e} + \mathbf{j} = \mathbf{C} \mathbf{h} - \mathbf{s_e} - and solve for \\\(\\\mathbf{h}\\\) using + and solve for \\\(\\\mathbf{h}\\\) using - .. math :: + .. math :: - \\left(\mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{C} + i \omega \mathbf{M_{\mu}^e}\\right) \mathbf{h} = \mathbf{M^e} \mathbf{s_m} + \mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{s_e} + \\left(\mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{C} + i \omega \mathbf{M_{\mu}^e}\\right) \mathbf{h} = \mathbf{M^e} \mathbf{s_m} + \mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{s_e} """ @@ -516,6 +523,7 @@ class Problem_h(BaseFDEMProblem): :param float freq: Frequency :rtype: scipy.sparse.csr_matrix :return: A + """ MeMu = self.MeMu @@ -543,6 +551,7 @@ class Problem_h(BaseFDEMProblem): :param float freq: Frequency :rtype: numpy.ndarray (nE, nSrc) :return: RHS + """ S_m, S_e = self.getSourceTerm(freq) From 6b359f49b5f92daca39e9123da0ccf2a87671fcb Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 31 Jan 2016 15:21:46 -0800 Subject: [PATCH 12/77] docs clean-up (using autoclass is more stable than automodule) --- SimPEG/Maps.py | 12 ++++++------ SimPEG/Mesh/BaseMesh.py | 34 ++++++++++++++++++---------------- SimPEG/Mesh/InnerProducts.py | 14 +++++++------- docs/api_ForwardProblem.rst | 4 ++-- docs/api_InnerProducts.rst | 2 +- docs/api_Inversion.rst | 6 +++--- docs/api_Mesh.rst | 2 +- docs/api_MeshCode.rst | 17 +++++++---------- tests/docs/test_docs.py | 32 ++++++++++++++++---------------- 9 files changed, 61 insertions(+), 62 deletions(-) diff --git a/SimPEG/Maps.py b/SimPEG/Maps.py index 5b4782ac..6323d3d5 100644 --- a/SimPEG/Maps.py +++ b/SimPEG/Maps.py @@ -34,8 +34,8 @@ class IdentityMap(object): """ The default shape is (mesh.nC, nP). - :rtype: (int,int) - :return: shape of the operator as a tuple + :rtype: tuple + :return: shape of the operator as a tuple (int,int) """ if self.mesh is None: return ('*', self.nP) @@ -77,7 +77,7 @@ class IdentityMap(object): The derivative of the transformation. :param numpy.array m: model - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: derivative of transformed model """ @@ -206,7 +206,7 @@ class ExpMap(IdentityMap): def deriv(self, m): """ :param numpy.array m: model - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: derivative of transformed model The *transform* changes the model into the physical property. @@ -350,7 +350,7 @@ class Vertical1DMap(IdentityMap): def deriv(self, m): """ :param numpy.array m: model - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: derivative of transformed model """ repNum = self.mesh.vnC[:self.mesh.dim-1].prod() @@ -405,7 +405,7 @@ class Map2Dto3D(IdentityMap): def deriv(self, m): """ :param numpy.array m: model - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: derivative of transformed model """ inds = self * np.arange(self.nP) diff --git a/SimPEG/Mesh/BaseMesh.py b/SimPEG/Mesh/BaseMesh.py index 14b3aecf..ba2ce920 100644 --- a/SimPEG/Mesh/BaseMesh.py +++ b/SimPEG/Mesh/BaseMesh.py @@ -7,8 +7,8 @@ class BaseMesh(object): BaseMesh does all the counting you don't want to do. BaseMesh should be inherited by meshes with a regular structure. - :param numpy.array,list n: number of cells in each direction (dim, ) - :param numpy.array,list x0: Origin of the mesh (dim, ) + :param numpy.array n: (or list) number of cells in each direction (dim, ) + :param numpy.array x0: (or list) Origin of the mesh (dim, ) """ @@ -34,8 +34,8 @@ class BaseMesh(object): """ Origin of the mesh - :rtype: numpy.array (dim, ) - :return: x0 + :rtype: numpy.array + :return: x0, (dim, ) """ return self._x0 @@ -116,8 +116,8 @@ class BaseMesh(object): """ Total number of edges in each direction - :rtype: numpy.array (dim, ) - :return: [nEx, nEy, nEz] + :rtype: numpy.array + :return: [nEx, nEy, nEz], (dim, ) .. plot:: :include-source: @@ -173,8 +173,8 @@ class BaseMesh(object): """ Total number of faces in each direction - :rtype: numpy.array (dim, ) - :return: [nFx, nFy, nFz] + :rtype: numpy.array + :return: [nFx, nFy, nFz], (dim, ) .. plot:: :include-source: @@ -200,8 +200,8 @@ class BaseMesh(object): """ Face Normals - :rtype: numpy.array (sum(nF), dim) - :return: normals + :rtype: numpy.array + :return: normals, (sum(nF), dim) """ if self.dim == 2: nX = np.c_[np.ones(self.nFx), np.zeros(self.nFx)] @@ -218,8 +218,8 @@ class BaseMesh(object): """ Edge Tangents - :rtype: numpy.array (sum(nE), dim) - :return: normals + :rtype: numpy.array + :return: normals, (sum(nE), dim) """ if self.dim == 2: tX = np.c_[np.ones(self.nEx), np.zeros(self.nEx)] @@ -236,8 +236,9 @@ class BaseMesh(object): Given a vector, fV, in cartesian coordinates, this will project it onto the mesh using the normals :param numpy.array fV: face vector with shape (nF, dim) - :rtype: numpy.array with shape (nF, ) - :return: projected face vector + :rtype: numpy.array + :return: projected face vector, (nF, ) + """ assert isinstance(fV, np.ndarray), 'fV must be an ndarray' assert len(fV.shape) == 2 and fV.shape[0] == self.nF and fV.shape[1] == self.dim, 'fV must be an ndarray of shape (nF x dim)' @@ -248,8 +249,9 @@ class BaseMesh(object): Given a vector, eV, in cartesian coordinates, this will project it onto the mesh using the tangents :param numpy.array eV: edge vector with shape (nE, dim) - :rtype: numpy.array with shape (nE, ) - :return: projected edge vector + :rtype: numpy.array + :return: projected edge vector, (nE, ) + """ assert isinstance(eV, np.ndarray), 'eV must be an ndarray' assert len(eV.shape) == 2 and eV.shape[0] == self.nE and eV.shape[1] == self.dim, 'eV must be an ndarray of shape (nE x dim)' diff --git a/SimPEG/Mesh/InnerProducts.py b/SimPEG/Mesh/InnerProducts.py index 42a08702..8415b7ad 100644 --- a/SimPEG/Mesh/InnerProducts.py +++ b/SimPEG/Mesh/InnerProducts.py @@ -16,7 +16,7 @@ class InnerProducts(object): :param bool invProp: inverts the material property :param bool invMat: inverts the matrix :param bool doFast: do a faster implementation if available. - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: M, the inner product matrix (nF, nF) """ return self._getInnerProduct('F', prop=prop, invProp=invProp, invMat=invMat, doFast=doFast) @@ -27,7 +27,7 @@ class InnerProducts(object): :param bool invProp: inverts the material property :param bool invMat: inverts the matrix :param bool doFast: do a faster implementation if available. - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: M, the inner product matrix (nE, nE) """ return self._getInnerProduct('E', prop=prop, invProp=invProp, invMat=invMat, doFast=doFast) @@ -39,7 +39,7 @@ class InnerProducts(object): :param bool invProp: inverts the material property :param bool invMat: inverts the matrix :param bool doFast: do a faster implementation if available. - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: M, the inner product matrix (nE, nE) """ assert projType in ['F', 'E'], "projType must be 'F' for faces or 'E' for edges" @@ -121,7 +121,7 @@ class InnerProducts(object): Given u, dMdmu returns (nF, nC*nA) :param np.ndarray u: vector that multiplies dMdmu - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: dMdmu, the derivative of the inner product matrix for a certain u """ return self._getInnerProductDeriv(prop, 'F', doFast=doFast, invProp=invProp, invMat=invMat) @@ -133,7 +133,7 @@ class InnerProducts(object): :param bool doFast: do a faster implementation if available. :param bool invProp: inverts the material property :param bool invMat: inverts the matrix - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: dMdm, the derivative of the inner product matrix (nE, nC*nA) """ return self._getInnerProductDeriv(prop, 'E', doFast=doFast, invProp=invProp, invMat=invMat) @@ -145,7 +145,7 @@ class InnerProducts(object): :param bool doFast: do a faster implementation if available. :param bool invProp: inverts the material property :param bool invMat: inverts the matrix - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: dMdm, the derivative of the inner product matrix (nE, nC*nA) """ fast = None @@ -169,7 +169,7 @@ class InnerProducts(object): :param numpy.array v: vector to multiply (required in the general implementation) :param list P: list of projection matrices :param str projType: 'F' for faces 'E' for edges - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: dMdm, the derivative of the inner product matrix (n, nC*nA) """ assert projType in ['F', 'E'], "projType must be 'F' for faces or 'E' for edges" diff --git a/docs/api_ForwardProblem.rst b/docs/api_ForwardProblem.rst index 0bf9596f..efefedc9 100644 --- a/docs/api_ForwardProblem.rst +++ b/docs/api_ForwardProblem.rst @@ -67,13 +67,13 @@ The API Problem ------- -.. automodule:: SimPEG.Problem +.. autoclass:: SimPEG.Problem :members: :undoc-members: Survey ------ -.. automodule:: SimPEG.Survey +.. autoclass:: SimPEG.Survey :members: :undoc-members: diff --git a/docs/api_InnerProducts.rst b/docs/api_InnerProducts.rst index bc9426c6..a57a4c91 100644 --- a/docs/api_InnerProducts.rst +++ b/docs/api_InnerProducts.rst @@ -266,6 +266,6 @@ These are computed for each of the 8 projections, horizontally concatenated, and The API ------- -.. automodule:: SimPEG.Mesh.InnerProducts +.. autoclass:: SimPEG.Mesh.InnerProducts :members: :undoc-members: diff --git a/docs/api_Inversion.rst b/docs/api_Inversion.rst index 5cac5f0c..ec98ba0d 100644 --- a/docs/api_Inversion.rst +++ b/docs/api_Inversion.rst @@ -3,7 +3,7 @@ InvProblem ********** -.. automodule:: SimPEG.InvProblem +.. autoclass:: SimPEG.InvProblem :show-inheritance: :members: :undoc-members: @@ -12,7 +12,7 @@ InvProblem Inversion ********* -.. automodule:: SimPEG.Inversion +.. autoclass:: SimPEG.Inversion :show-inheritance: :members: :undoc-members: @@ -20,7 +20,7 @@ Inversion Directives ********** -.. automodule:: SimPEG.Directives +.. autoclass:: SimPEG.Directives :show-inheritance: :members: :undoc-members: diff --git a/docs/api_Mesh.rst b/docs/api_Mesh.rst index ed216b13..1043703b 100644 --- a/docs/api_Mesh.rst +++ b/docs/api_Mesh.rst @@ -188,6 +188,6 @@ other types of meshes in this SimPEG framework. The API ======= -.. automodule:: SimPEG.Mesh.BaseMesh +.. autoclass:: SimPEG.Mesh.BaseMesh :members: :undoc-members: diff --git a/docs/api_MeshCode.rst b/docs/api_MeshCode.rst index 2d7cab9f..aab8a849 100644 --- a/docs/api_MeshCode.rst +++ b/docs/api_MeshCode.rst @@ -3,34 +3,31 @@ Tensor Mesh =========== -.. automodule:: SimPEG.Mesh.TensorMesh - :show-inheritance: +.. autoclass:: SimPEG.Mesh.TensorMesh :members: :undoc-members: - + :show-inheritance: Cylindrical Mesh ================ -.. automodule:: SimPEG.Mesh.CylMesh - :show-inheritance: +.. autoclass:: SimPEG.Mesh.CylMesh :members: :undoc-members: - + :show-inheritance: Tree Mesh ========= .. autoclass:: SimPEG.Mesh.TreeMesh.TreeMesh - :show-inheritance: :members: :undoc-members: - + :show-inheritance: Curvilinear Mesh ================ -.. automodule:: SimPEG.Mesh.CurvilinearMesh - :show-inheritance: +.. autoclass:: SimPEG.Mesh.CurvilinearMesh :members: :undoc-members: + :show-inheritance: \ No newline at end of file diff --git a/tests/docs/test_docs.py b/tests/docs/test_docs.py index cee68206..4bd10d6c 100644 --- a/tests/docs/test_docs.py +++ b/tests/docs/test_docs.py @@ -19,25 +19,25 @@ class Doc_Test(unittest.TestCase): "%s"%(html_path)]) assert check == 0 - def test_latex(self): - doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) - latex_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['latex']) + # def test_latex(self): + # doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) + # latex_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['latex']) - check = subprocess.call(["sphinx-build", "-nW", "-b", "latex", "-d", - "%s"%(doctrees_path), - "%s"%(self.path_to_docs), - "%s"%(latex_path)]) - assert check == 0 + # check = subprocess.call(["sphinx-build", "-nW", "-b", "latex", "-d", + # "%s"%(doctrees_path), + # "%s"%(self.path_to_docs), + # "%s"%(latex_path)]) + # assert check == 0 - def test_linkcheck(self): - doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) - link_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']) + # def test_linkcheck(self): + # doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) + # link_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']) - check = subprocess.call(["sphinx-build", "-nW", "-b", "linkcheck", "-d", - "%s"%(doctrees_path), - "%s"%(self.path_to_docs), - "%s"%(link_path)]) - assert check == 0 + # check = subprocess.call(["sphinx-build", "-nW", "-b", "linkcheck", "-d", + # "%s"%(doctrees_path), + # "%s"%(self.path_to_docs), + # "%s"%(link_path)]) + # assert check == 0 if __name__ == '__main__': unittest.main() \ No newline at end of file From cbe87584652e855fe410403e281238d91cb9b364 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Mon, 1 Feb 2016 08:22:00 -0800 Subject: [PATCH 13/77] corrected scipy.sparse.csr_matrix, move size descriptions to :return: instead of :type: --- SimPEG/Mesh/CylMesh.py | 12 ++++++------ SimPEG/Mesh/TreeMesh.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SimPEG/Mesh/CylMesh.py b/SimPEG/Mesh/CylMesh.py index ecdf36ac..2f2946ba 100644 --- a/SimPEG/Mesh/CylMesh.py +++ b/SimPEG/Mesh/CylMesh.py @@ -68,8 +68,8 @@ class CylMesh(BaseTensorMesh, BaseRectangularMesh, InnerProducts, CylView): """ Number of x-faces in each direction - :rtype: numpy.array (dim, ) - :return: vnFx + :rtype: numpy.array + :return: vnFx, (dim, ) """ return self.vnC @@ -78,8 +78,8 @@ class CylMesh(BaseTensorMesh, BaseRectangularMesh, InnerProducts, CylView): """ Number of y-edges in each direction - :rtype: numpy.array (dim, ) - :return: vnEy or None if dim < 2 + :rtype: numpy.array + :return: vnEy or None if dim < 2, (dim, ) """ nNx = self.nNx if self.isSymmetric else self.nNx - 1 return np.r_[nNx, self.nCy, self.nNz] @@ -89,8 +89,8 @@ class CylMesh(BaseTensorMesh, BaseRectangularMesh, InnerProducts, CylView): """ Number of z-edges in each direction - :rtype: numpy.array (dim, ) - :return: vnEz or None if nCy > 1 + :rtype: numpy.array + :return: vnEz or None if nCy > 1, (dim, ) """ if self.isSymmetric: return np.r_[self.nNx, self.nNy, self.nCz] diff --git a/SimPEG/Mesh/TreeMesh.py b/SimPEG/Mesh/TreeMesh.py index 1d5c8c8c..67afce38 100644 --- a/SimPEG/Mesh/TreeMesh.py +++ b/SimPEG/Mesh/TreeMesh.py @@ -1869,7 +1869,7 @@ class TreeMesh(BaseTensorMesh, InnerProducts): :param numpy.ndarray locs: Location of points to interpolate to :param str locType: What to interpolate (see below) - :rtype: scipy.sparse.csr.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: M, the interpolation matrix locType can be:: From 312b5d79c5ce46faefea823e05ac587cb91ca8ee Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 9 Feb 2016 08:53:01 -0800 Subject: [PATCH 14/77] resolved merge conflicts in TensorMesh --- SimPEG/Mesh/TensorMesh.py | 573 +------------------------------------- 1 file changed, 5 insertions(+), 568 deletions(-) diff --git a/SimPEG/Mesh/TensorMesh.py b/SimPEG/Mesh/TensorMesh.py index 39db8321..8baab7df 100644 --- a/SimPEG/Mesh/TensorMesh.py +++ b/SimPEG/Mesh/TensorMesh.py @@ -1,9 +1,9 @@ -<<<<<<< HEAD from SimPEG import Utils, np, sp from BaseMesh import BaseMesh, BaseRectangularMesh from View import TensorView from DiffOperators import DiffOperators from InnerProducts import InnerProducts +from MeshIO import TensorMeshIO class BaseTensorMesh(BaseMesh): @@ -198,10 +198,9 @@ class BaseTensorMesh(BaseMesh): Determines if a set of points are inside a mesh. :param numpy.ndarray pts: Location of points to test - :rtype numpy.ndarray: - :return inside, numpy array of booleans: + :rtype numpy.ndarray + :return inside, numpy array of booleans """ - pts = Utils.asArray_N_x_Dim(pts, self.dim) tensors = self.getTensor(locType) @@ -217,7 +216,7 @@ class BaseTensorMesh(BaseMesh): inside = inside & (pts[:,i] >= tensor.min()-TOL) & (pts[:,i] <= tensor.max()+TOL) return inside - def getInterpolationMat(self, loc, locType, zerosOutside=False): + def getInterpolationMat(self, loc, locType='CC', zerosOutside=False): """ Produces interpolation matrix :param numpy.ndarray loc: Location of points to interpolate to @@ -236,7 +235,6 @@ class BaseTensorMesh(BaseMesh): 'N' -> scalar field defined on nodes 'CC' -> scalar field defined on cell centers """ - if self._meshType == 'CYL' and self.isSymmetric and locType in ['Ex','Ez','Fy']: raise Exception('Symmetric CylMesh does not support %s interpolation, as this variable does not exist.' % locType) @@ -362,7 +360,7 @@ class BaseTensorMesh(BaseMesh): -class TensorMesh(BaseTensorMesh, BaseRectangularMesh, TensorView, DiffOperators, InnerProducts): +class TensorMesh(BaseTensorMesh, BaseRectangularMesh, TensorView, DiffOperators, InnerProducts, TensorMeshIO): """ TensorMesh is a mesh class that deals with tensor product meshes. @@ -559,564 +557,3 @@ class TensorMesh(BaseTensorMesh, BaseRectangularMesh, TensorView, DiffOperators, indzd = (self.gridCC[:,2]==min(self.gridCC[:,2])) indzu = (self.gridCC[:,2]==max(self.gridCC[:,2])) return indxd, indxu, indyd, indyu, indzd, indzu -======= -from SimPEG import Utils, np, sp -from BaseMesh import BaseMesh, BaseRectangularMesh -from View import TensorView -from DiffOperators import DiffOperators -from InnerProducts import InnerProducts -from MeshIO import TensorMeshIO - -class BaseTensorMesh(BaseMesh): - - __metaclass__ = Utils.SimPEGMetaClass - - _meshType = 'BASETENSOR' - - _unitDimensions = [1, 1, 1] - - def __init__(self, h_in, x0_in=None): - assert type(h_in) in [list, tuple], 'h_in must be a list' - assert len(h_in) in [1,2,3], 'h_in must be of dimension 1, 2, or 3' - h = range(len(h_in)) - for i, h_i in enumerate(h_in): - if Utils.isScalar(h_i) and type(h_i) is not np.ndarray: - # This gives you something over the unit cube. - h_i = self._unitDimensions[i] * np.ones(int(h_i))/int(h_i) - elif type(h_i) is list: - h_i = Utils.meshTensor(h_i) - assert isinstance(h_i, np.ndarray), ("h[%i] is not a numpy array." % i) - assert len(h_i.shape) == 1, ("h[%i] must be a 1D numpy array." % i) - h[i] = h_i[:] # make a copy. - - x0 = np.zeros(len(h)) - if x0_in is not None: - assert len(h) == len(x0_in), "Dimension mismatch. x0 != len(h)" - for i in range(len(h)): - x_i, h_i = x0_in[i], h[i] - if Utils.isScalar(x_i): - x0[i] = x_i - elif x_i == '0': - x0[i] = 0.0 - elif x_i == 'C': - x0[i] = -h_i.sum()*0.5 - elif x_i == 'N': - x0[i] = -h_i.sum() - else: - raise Exception("x0[%i] must be a scalar or '0' to be zero, 'C' to center, or 'N' to be negative." % i) - - if isinstance(self, BaseRectangularMesh): - BaseRectangularMesh.__init__(self, np.array([x.size for x in h]), x0) - else: - BaseMesh.__init__(self, np.array([x.size for x in h]), x0) - - # Ensure h contains 1D vectors - self._h = [Utils.mkvc(x.astype(float)) for x in h] - - @property - def h(self): - """h is a list containing the cell widths of the tensor mesh in each dimension.""" - return self._h - - @property - def hx(self): - "Width of cells in the x direction" - return self._h[0] - - @property - def hy(self): - "Width of cells in the y direction" - return None if self.dim < 2 else self._h[1] - - @property - def hz(self): - "Width of cells in the z direction" - return None if self.dim < 3 else self._h[2] - - @property - def vectorNx(self): - """Nodal grid vector (1D) in the x direction.""" - return np.r_[0., self.hx.cumsum()] + self.x0[0] - - @property - def vectorNy(self): - """Nodal grid vector (1D) in the y direction.""" - return None if self.dim < 2 else np.r_[0., self.hy.cumsum()] + self.x0[1] - - @property - def vectorNz(self): - """Nodal grid vector (1D) in the z direction.""" - return None if self.dim < 3 else np.r_[0., self.hz.cumsum()] + self.x0[2] - - @property - def vectorCCx(self): - """Cell-centered grid vector (1D) in the x direction.""" - return np.r_[0, self.hx[:-1].cumsum()] + self.hx*0.5 + self.x0[0] - - @property - def vectorCCy(self): - """Cell-centered grid vector (1D) in the y direction.""" - return None if self.dim < 2 else np.r_[0, self.hy[:-1].cumsum()] + self.hy*0.5 + self.x0[1] - - @property - def vectorCCz(self): - """Cell-centered grid vector (1D) in the z direction.""" - return None if self.dim < 3 else np.r_[0, self.hz[:-1].cumsum()] + self.hz*0.5 + self.x0[2] - - @property - def gridCC(self): - """Cell-centered grid.""" - return self._getTensorGrid('CC') - - @property - def gridN(self): - """Nodal grid.""" - return self._getTensorGrid('N') - - @property - def gridFx(self): - """Face staggered grid in the x direction.""" - if self.nFx == 0: return - return self._getTensorGrid('Fx') - - @property - def gridFy(self): - """Face staggered grid in the y direction.""" - if self.nFy == 0 or self.dim < 2: return - return self._getTensorGrid('Fy') - - @property - def gridFz(self): - """Face staggered grid in the z direction.""" - if self.nFz == 0 or self.dim < 3: return - return self._getTensorGrid('Fz') - - @property - def gridEx(self): - """Edge staggered grid in the x direction.""" - if self.nEx == 0: return - return self._getTensorGrid('Ex') - - @property - def gridEy(self): - """Edge staggered grid in the y direction.""" - if self.nEy == 0 or self.dim < 2: return - return self._getTensorGrid('Ey') - - @property - def gridEz(self): - """Edge staggered grid in the z direction.""" - if self.nEz == 0 or self.dim < 3: return - return self._getTensorGrid('Ez') - - def _getTensorGrid(self, key): - if getattr(self, '_grid' + key, None) is None: - setattr(self, '_grid' + key, Utils.ndgrid(self.getTensor(key))) - return getattr(self, '_grid' + key) - - def getTensor(self, key): - """ Returns a tensor list. - - :param str key: What tensor (see below) - :rtype: list - :return: list of the tensors that make up the mesh. - - key can be:: - - 'CC' -> scalar field defined on cell centers - 'N' -> scalar field defined on nodes - 'Fx' -> x-component of field defined on faces - 'Fy' -> y-component of field defined on faces - 'Fz' -> z-component of field defined on faces - 'Ex' -> x-component of field defined on edges - 'Ey' -> y-component of field defined on edges - 'Ez' -> z-component of field defined on edges - - """ - - if key == 'Fx': - ten = [self.vectorNx , self.vectorCCy, self.vectorCCz] - elif key == 'Fy': - ten = [self.vectorCCx, self.vectorNy , self.vectorCCz] - elif key == 'Fz': - ten = [self.vectorCCx, self.vectorCCy, self.vectorNz ] - elif key == 'Ex': - ten = [self.vectorCCx, self.vectorNy , self.vectorNz ] - elif key == 'Ey': - ten = [self.vectorNx , self.vectorCCy, self.vectorNz ] - elif key == 'Ez': - ten = [self.vectorNx , self.vectorNy , self.vectorCCz] - elif key == 'CC': - ten = [self.vectorCCx, self.vectorCCy, self.vectorCCz] - elif key == 'N': - ten = [self.vectorNx , self.vectorNy , self.vectorNz ] - - return [t for t in ten if t is not None] - - # --------------- Methods --------------------- - - def isInside(self, pts, locType='N'): - """ - Determines if a set of points are inside a mesh. - - :param numpy.ndarray pts: Location of points to test - :rtype numpy.ndarray - :return inside, numpy array of booleans - """ - pts = Utils.asArray_N_x_Dim(pts, self.dim) - - tensors = self.getTensor(locType) - - if locType == 'N' and self._meshType == 'CYL': - #NOTE: for a CYL mesh we add a node to check if we are inside in the radial direction! - tensors[0] = np.r_[0.,tensors[0]] - tensors[1] = np.r_[tensors[1], 2.0*np.pi] - - inside = np.ones(pts.shape[0],dtype=bool) - for i, tensor in enumerate(tensors): - TOL = np.diff(tensor).min() * 1.0e-10 - inside = inside & (pts[:,i] >= tensor.min()-TOL) & (pts[:,i] <= tensor.max()+TOL) - return inside - - def getInterpolationMat(self, loc, locType='CC', zerosOutside=False): - """ Produces interpolation matrix - - :param numpy.ndarray loc: Location of points to interpolate to - :param str locType: What to interpolate (see below) - :rtype: scipy.sparse.csr.csr_matrix - :return: M, the interpolation matrix - - locType can be:: - - 'Ex' -> x-component of field defined on edges - 'Ey' -> y-component of field defined on edges - 'Ez' -> z-component of field defined on edges - 'Fx' -> x-component of field defined on faces - 'Fy' -> y-component of field defined on faces - 'Fz' -> z-component of field defined on faces - 'N' -> scalar field defined on nodes - 'CC' -> scalar field defined on cell centers - """ - if self._meshType == 'CYL' and self.isSymmetric and locType in ['Ex','Ez','Fy']: - raise Exception('Symmetric CylMesh does not support %s interpolation, as this variable does not exist.' % locType) - - loc = Utils.asArray_N_x_Dim(loc, self.dim) - - if zerosOutside is False: - assert np.all(self.isInside(loc)), "Points outside of mesh" - else: - indZeros = np.logical_not(self.isInside(loc)) - loc[indZeros, :] = np.array([v.mean() for v in self.getTensor('CC')]) - - if locType in ['Fx','Fy','Fz','Ex','Ey','Ez']: - ind = {'x':0, 'y':1, 'z':2}[locType[1]] - assert self.dim >= ind, 'mesh is not high enough dimension.' - nF_nE = self.vnF if 'F' in locType else self.vnE - components = [Utils.spzeros(loc.shape[0], n) for n in nF_nE] - components[ind] = Utils.interpmat(loc, *self.getTensor(locType)) - # remove any zero blocks (hstack complains) - components = [comp for comp in components if comp.shape[1] > 0] - Q = sp.hstack(components) - elif locType in ['CC', 'N']: - Q = Utils.interpmat(loc, *self.getTensor(locType)) - else: - raise NotImplementedError('getInterpolationMat: locType=='+locType+' and mesh.dim=='+str(self.dim)) - - if zerosOutside: - Q[indZeros, :] = 0 - - return Q.tocsr() - - - def _fastInnerProduct(self, projType, prop=None, invProp=False, invMat=False): - """ - Fast version of getFaceInnerProduct. - This does not handle the case of a full tensor prop. - - :param numpy.array prop: material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6)) - :param str projType: 'E' or 'F' - :param bool returnP: returns the projection matrices - :param bool invProp: inverts the material property - :param bool invMat: inverts the matrix - :rtype: scipy.csr_matrix - :return: M, the inner product matrix (nF, nF) - """ - assert projType in ['F', 'E'], "projType must be 'F' for faces or 'E' for edges" - - if prop is None: - prop = np.ones(self.nC) - - if invProp: - prop = 1./prop - - if Utils.isScalar(prop): - prop = prop*np.ones(self.nC) - - if prop.size == self.nC: - Av = getattr(self, 'ave'+projType+'2CC') - Vprop = self.vol * Utils.mkvc(prop) - M = self.dim * Utils.sdiag(Av.T * Vprop) - elif prop.size == self.nC*self.dim: - Av = getattr(self, 'ave'+projType+'2CCV') - V = sp.kron(sp.identity(self.dim), Utils.sdiag(self.vol)) - M = Utils.sdiag(Av.T * V * Utils.mkvc(prop)) - else: - return None - - if invMat: - return Utils.sdInv(M) - else: - return M - - def _fastInnerProductDeriv(self, projType, prop, invProp=False, invMat=False): - """ - :param str projType: 'E' or 'F' - :param TensorType tensorType: type of the tensor - :param bool invProp: inverts the material property - :param bool invMat: inverts the matrix - :rtype: function - :return: dMdmu, the derivative of the inner product matrix - """ - assert projType in ['F', 'E'], "projType must be 'F' for faces or 'E' for edges" - tensorType = Utils.TensorType(self, prop) - - dMdprop = None - - if invMat: - MI = self._fastInnerProduct(projType, prop, invProp=invProp, invMat=invMat) - - if tensorType == 0: - Av = getattr(self, 'ave'+projType+'2CC') - V = Utils.sdiag(self.vol) - ones = sp.csr_matrix((np.ones(self.nC), (range(self.nC), np.zeros(self.nC))), shape=(self.nC,1)) - if not invMat and not invProp: - dMdprop = self.dim * Av.T * V * ones - elif invMat and invProp: - dMdprop = self.dim * Utils.sdiag(MI.diagonal()**2) * Av.T * V * ones * Utils.sdiag(1./prop**2) - - if tensorType == 1: - Av = getattr(self, 'ave'+projType+'2CC') - V = Utils.sdiag(self.vol) - if not invMat and not invProp: - dMdprop = self.dim * Av.T * V - elif invMat and invProp: - dMdprop = self.dim * Utils.sdiag(MI.diagonal()**2) * Av.T * V * Utils.sdiag(1./prop**2) - - if tensorType == 2: # anisotropic - Av = getattr(self, 'ave'+projType+'2CCV') - V = sp.kron(sp.identity(self.dim), Utils.sdiag(self.vol)) - if not invMat and not invProp: - dMdprop = Av.T * V - elif invMat and invProp: - dMdprop = Utils.sdiag(MI.diagonal()**2) * Av.T * V * Utils.sdiag(1./prop**2) - - if dMdprop is not None: - def innerProductDeriv(v=None): - if v is None: - print 'Depreciation Warning: TensorMesh.innerProductDeriv. You should be supplying a vector. Use: sdiag(u)*dMdprop' - return dMdprop - return Utils.sdiag(v) * dMdprop - return innerProductDeriv - else: - return None - - - -class TensorMesh(BaseTensorMesh, BaseRectangularMesh, TensorView, DiffOperators, InnerProducts, TensorMeshIO): - """ - TensorMesh is a mesh class that deals with tensor product meshes. - - Any Mesh that has a constant width along the entire axis - such that it can defined by a single width vector, called 'h'. - - :: - - hx = np.array([1,1,1]) - hy = np.array([1,2]) - hz = np.array([1,1,1,1]) - - mesh = Mesh.TensorMesh([hx, hy, hz]) - - Example of a padded tensor mesh using :func:`SimPEG.Utils.meshutils.meshTensor`: - - .. plot:: - :include-source: - - from SimPEG import Mesh, Utils - M = Mesh.TensorMesh([[(10,10,-1.3),(10,40),(10,10,1.3)], [(10,10,-1.3),(10,20)]]) - M.plotGrid() - - For a quick tensor mesh on a (10x12x15) unit cube:: - - mesh = Mesh.TensorMesh([10, 12, 15]) - - """ - - __metaclass__ = Utils.SimPEGMetaClass - - _meshType = 'TENSOR' - - def __init__(self, h_in, x0=None): - BaseTensorMesh.__init__(self, h_in, x0) - - def __str__(self): - outStr = ' ---- {0:d}-D TensorMesh ---- '.format(self.dim) - def printH(hx, outStr=''): - i = -1 - while True: - i = i + 1 - if i > hx.size: - break - elif i == hx.size: - break - h = hx[i] - n = 1 - for j in range(i+1, hx.size): - if hx[j] == h: - n = n + 1 - i = i + 1 - else: - break - - if n == 1: - outStr += ' {0:.2f},'.format(h) - else: - outStr += ' {0:d}*{1:.2f},'.format(n,h) - - return outStr[:-1] - - if self.dim == 1: - outStr += '\n x0: {0:.2f}'.format(self.x0[0]) - outStr += '\n nCx: {0:d}'.format(self.nCx) - outStr += printH(self.hx, outStr='\n hx:') - pass - elif self.dim == 2: - outStr += '\n x0: {0:.2f}'.format(self.x0[0]) - outStr += '\n y0: {0:.2f}'.format(self.x0[1]) - outStr += '\n nCx: {0:d}'.format(self.nCx) - outStr += '\n nCy: {0:d}'.format(self.nCy) - outStr += printH(self.hx, outStr='\n hx:') - outStr += printH(self.hy, outStr='\n hy:') - elif self.dim == 3: - outStr += '\n x0: {0:.2f}'.format(self.x0[0]) - outStr += '\n y0: {0:.2f}'.format(self.x0[1]) - outStr += '\n z0: {0:.2f}'.format(self.x0[2]) - outStr += '\n nCx: {0:d}'.format(self.nCx) - outStr += '\n nCy: {0:d}'.format(self.nCy) - outStr += '\n nCz: {0:d}'.format(self.nCz) - outStr += printH(self.hx, outStr='\n hx:') - outStr += printH(self.hy, outStr='\n hy:') - outStr += printH(self.hz, outStr='\n hz:') - - return outStr - - - # --------------- Geometries --------------------- - @property - def vol(self): - """Construct cell volumes of the 3D model as 1d array.""" - if getattr(self, '_vol', None) is None: - vh = self.h - # Compute cell volumes - if self.dim == 1: - self._vol = Utils.mkvc(vh[0]) - elif self.dim == 2: - # Cell sizes in each direction - self._vol = Utils.mkvc(np.outer(vh[0], vh[1])) - elif self.dim == 3: - # Cell sizes in each direction - self._vol = Utils.mkvc(np.outer(Utils.mkvc(np.outer(vh[0], vh[1])), vh[2])) - return self._vol - - @property - def area(self): - """Construct face areas of the 3D model as 1d array.""" - if getattr(self, '_area', None) is None: - # Ensure that we are working with column vectors - vh = self.h - # The number of cell centers in each direction - n = self.vnC - # Compute areas of cell faces - if(self.dim == 1): - self._area = np.ones(n[0]+1) - elif(self.dim == 2): - area1 = np.outer(np.ones(n[0]+1), vh[1]) - area2 = np.outer(vh[0], np.ones(n[1]+1)) - self._area = np.r_[Utils.mkvc(area1), Utils.mkvc(area2)] - elif(self.dim == 3): - area1 = np.outer(np.ones(n[0]+1), Utils.mkvc(np.outer(vh[1], vh[2]))) - area2 = np.outer(vh[0], Utils.mkvc(np.outer(np.ones(n[1]+1), vh[2]))) - area3 = np.outer(vh[0], Utils.mkvc(np.outer(vh[1], np.ones(n[2]+1)))) - self._area = np.r_[Utils.mkvc(area1), Utils.mkvc(area2), Utils.mkvc(area3)] - return self._area - - @property - def edge(self): - """Construct edge legnths of the 3D model as 1d array.""" - if getattr(self, '_edge', None) is None: - # Ensure that we are working with column vectors - vh = self.h - # The number of cell centers in each direction - n = self.vnC - # Compute edge lengths - if(self.dim == 1): - self._edge = Utils.mkvc(vh[0]) - elif(self.dim == 2): - l1 = np.outer(vh[0], np.ones(n[1]+1)) - l2 = np.outer(np.ones(n[0]+1), vh[1]) - self._edge = np.r_[Utils.mkvc(l1), Utils.mkvc(l2)] - elif(self.dim == 3): - l1 = np.outer(vh[0], Utils.mkvc(np.outer(np.ones(n[1]+1), np.ones(n[2]+1)))) - l2 = np.outer(np.ones(n[0]+1), Utils.mkvc(np.outer(vh[1], np.ones(n[2]+1)))) - l3 = np.outer(np.ones(n[0]+1), Utils.mkvc(np.outer(np.ones(n[1]+1), vh[2]))) - self._edge = np.r_[Utils.mkvc(l1), Utils.mkvc(l2), Utils.mkvc(l3)] - return self._edge - - @property - def faceBoundaryInd(self): - """ - Find indices of boundary faces in each direction - """ - if self.dim==1: - indxd = (self.gridFx==min(self.gridFx)) - indxu = (self.gridFx==max(self.gridFx)) - return indxd, indxu - elif self.dim==2: - indxd = (self.gridFx[:,0]==min(self.gridFx[:,0])) - indxu = (self.gridFx[:,0]==max(self.gridFx[:,0])) - indyd = (self.gridFy[:,1]==min(self.gridFy[:,1])) - indyu = (self.gridFy[:,1]==max(self.gridFy[:,1])) - return indxd, indxu, indyd, indyu - elif self.dim==3: - indxd = (self.gridFx[:,0]==min(self.gridFx[:,0])) - indxu = (self.gridFx[:,0]==max(self.gridFx[:,0])) - indyd = (self.gridFy[:,1]==min(self.gridFy[:,1])) - indyu = (self.gridFy[:,1]==max(self.gridFy[:,1])) - indzd = (self.gridFz[:,2]==min(self.gridFz[:,2])) - indzu = (self.gridFz[:,2]==max(self.gridFz[:,2])) - return indxd, indxu, indyd, indyu, indzd, indzu - - @property - def cellBoundaryInd(self): - """ - Find indices of boundary faces in each direction - """ - if self.dim==1: - indxd = (self.gridCC==min(self.gridCC)) - indxu = (self.gridCC==max(self.gridCC)) - return indxd, indxu - elif self.dim==2: - indxd = (self.gridCC[:,0]==min(self.gridCC[:,0])) - indxu = (self.gridCC[:,0]==max(self.gridCC[:,0])) - indyd = (self.gridCC[:,1]==min(self.gridCC[:,1])) - indyu = (self.gridCC[:,1]==max(self.gridCC[:,1])) - return indxd, indxu, indyd, indyu - elif self.dim==3: - indxd = (self.gridCC[:,0]==min(self.gridCC[:,0])) - indxu = (self.gridCC[:,0]==max(self.gridCC[:,0])) - indyd = (self.gridCC[:,1]==min(self.gridCC[:,1])) - indyu = (self.gridCC[:,1]==max(self.gridCC[:,1])) - indzd = (self.gridCC[:,2]==min(self.gridCC[:,2])) - indzu = (self.gridCC[:,2]==max(self.gridCC[:,2])) - return indxd, indxu, indyd, indyu, indzd, indzu ->>>>>>> dev From 6acaa81fafc3a89f35f6488c1b5ea2871ce53304 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 9 Feb 2016 09:03:20 -0800 Subject: [PATCH 15/77] fixed merge conflicts in FDEM docs that I missed --- SimPEG/EM/FDEM/FDEM.py | 77 ++---------------------------------------- 1 file changed, 3 insertions(+), 74 deletions(-) diff --git a/SimPEG/EM/FDEM/FDEM.py b/SimPEG/EM/FDEM/FDEM.py index 5d6abbd7..feede1e4 100644 --- a/SimPEG/EM/FDEM/FDEM.py +++ b/SimPEG/EM/FDEM/FDEM.py @@ -170,16 +170,9 @@ class BaseFDEMProblem(BaseEMProblem): """ Evaluates the sources for a given frequency and puts them in matrix form -<<<<<<< HEAD - :param float freq: Frequency - :rtype: numpy.ndarray (nE or nF, nSrc) - :return: S_m, S_e - -======= :param float freq: Frequency :rtype: (numpy.ndarray, numpy.ndarray) :return: S_m, S_e (nE or nF, nSrc) ->>>>>>> dev """ Srcs = self.survey.getSrcByFreq(freq) if self._eqLocs is 'FE': @@ -218,12 +211,7 @@ class Problem_e(BaseFDEMProblem): which we solve for :math:`\mathbf{e}`. -<<<<<<< HEAD - which we solve for \\\(\\\mathbf{e}\\\). - -======= :param SimPEG.Mesh mesh: mesh ->>>>>>> dev """ _fieldType = 'e' @@ -277,15 +265,6 @@ class Problem_e(BaseFDEMProblem): def getRHS(self, freq): """ -<<<<<<< HEAD - .. math :: - \mathbf{RHS} = \mathbf{C}^T \mathbf{M_{\mu^{-1}}^f}\mathbf{s_m} -i\omega\mathbf{M_e}\mathbf{s_e} - - :param float freq: Frequency - :rtype: numpy.ndarray (nE, nSrc) - :return: RHS - -======= Right hand side for the system .. math :: @@ -294,7 +273,6 @@ class Problem_e(BaseFDEMProblem): :param float freq: Frequency :rtype: numpy.ndarray :return: RHS (nE, nSrc) ->>>>>>> dev """ S_m, S_e = self.getSourceTerm(freq) @@ -481,21 +459,14 @@ class Problem_j(BaseFDEMProblem): .. math :: -<<<<<<< HEAD - \mathbf{h} = \\frac{1}{i \omega} \mathbf{M_{\mu}^e}^{-1} \\left(-\mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{j} + \mathbf{M^e} \mathbf{s_m} \\right) -======= \mathbf{h} = \\frac{1}{i \omega} \mathbf{M_{\mu}^e}^{-1} \\left(-\mathbf{C}^{\\top} \mathbf{M_{\\rho}^f} \mathbf{j} + \mathbf{M^e} \mathbf{s_m} \\right) ->>>>>>> dev + and solve for \\\(\\\mathbf{j}\\\) using .. math :: -<<<<<<< HEAD - \\left(\mathbf{C} \mathbf{M_{\mu}^e}^{-1} \mathbf{C}^T \mathbf{M_{\\rho}^f} + i \omega\\right)\mathbf{j} = \mathbf{C} \mathbf{M_{\mu}^e}^{-1} \mathbf{M^e} \mathbf{s_m} -i\omega\mathbf{s_e} -======= \\left(\mathbf{C} \mathbf{M_{\mu}^e}^{-1} \mathbf{C}^{\\top} \mathbf{M_{\\rho}^f} + i \omega\\right)\mathbf{j} = \mathbf{C} \mathbf{M_{\mu}^e}^{-1} \mathbf{M^e} \mathbf{s_m} -i\omega\mathbf{s_e} ->>>>>>> dev .. note:: This implementation does not yet work with full anisotropy!! @@ -517,16 +488,9 @@ class Problem_j(BaseFDEMProblem): .. math :: \\mathbf{A} = \\mathbf{C} \\mathbf{M^e_{\\mu^{-1}}} \\mathbf{C}^{\\top} \\mathbf{M^f_{\\sigma^{-1}}} + i\\omega -<<<<<<< HEAD - :param float freq: Frequency - :rtype: scipy.sparse.csr_matrix - :return: A - -======= :param float freq: Frequency :rtype: scipy.sparse.csr_matrix :return: A ->>>>>>> dev """ MeMuI = self.MeMuI @@ -543,15 +507,6 @@ class Problem_j(BaseFDEMProblem): def getADeriv_m(self, freq, u, v, adjoint=False): """ -<<<<<<< HEAD - In this case, we assume that electrical conductivity, \\\(\\\sigma\\\) is the physical property of interest (i.e. \\\(\\\sigma\\\) = model.transform). Then we want - - .. math :: - - \\frac{\mathbf{A(\sigma)} \mathbf{v}}{d \\mathbf{m}} &= \\mathbf{C} \\mathbf{M^e_{mu^{-1}}} \\mathbf{C^T} \\frac{d \\mathbf{M^f_{\\sigma^{-1}}}}{d \\mathbf{m}} - &= \\mathbf{C} \\mathbf{M^e_{mu}^{-1}} \\mathbf{C^T} \\frac{d \\mathbf{M^f_{\\sigma^{-1}}}}{d \\mathbf{\\sigma^{-1}}} \\frac{d \\mathbf{\\sigma^{-1}}}{d \\mathbf{\\sigma}} \\frac{d \\mathbf{\\sigma}}{d \\mathbf{m}} - -======= Product of the derivative of our system matrix with respect to the model and a vector In this case, we assume that electrical conductivity, :math:`\sigma` is the physical property of interest (i.e. :math:`\sigma` = model.transform). Then we want @@ -566,7 +521,6 @@ class Problem_j(BaseFDEMProblem): :param bool adjoint: adjoint? :rtype: numpy.ndarray :return: derivative of the system matrix times a vector (nP,) or adjoint (nD,) ->>>>>>> dev """ MeMuI = self.MeMuI @@ -586,15 +540,6 @@ class Problem_j(BaseFDEMProblem): def getRHS(self, freq): """ -<<<<<<< HEAD - .. math :: - \mathbf{RHS} = \mathbf{C} \mathbf{M_{\mu}^e}^{-1}\mathbf{s_m} -i\omega \mathbf{s_e} - - :param float freq: Frequency - :rtype: numpy.ndarray (nE, nSrc) - :return: RHS - -======= Right hand side for the system .. math :: @@ -604,7 +549,6 @@ class Problem_j(BaseFDEMProblem): :param float freq: Frequency :rtype: numpy.ndarray (nE, nSrc) :return: RHS ->>>>>>> dev """ S_m, S_e = self.getSourceTerm(freq) @@ -663,11 +607,7 @@ class Problem_h(BaseFDEMProblem): .. math :: -<<<<<<< HEAD - \\left(\mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{C} + i \omega \mathbf{M_{\mu}^e}\\right) \mathbf{h} = \mathbf{M^e} \mathbf{s_m} + \mathbf{C}^T \mathbf{M_{\\rho}^f} \mathbf{s_e} -======= \\left(\mathbf{C}^{\\top} \mathbf{M_{\\rho}^f} \mathbf{C} + i \omega \mathbf{M_{\mu}^e}\\right) \mathbf{h} = \mathbf{M^e} \mathbf{s_m} + \mathbf{C}^{\\top} \mathbf{M_{\\rho}^f} \mathbf{s_e} ->>>>>>> dev :param SimPEG.Mesh mesh: mesh """ @@ -686,16 +626,11 @@ class Problem_h(BaseFDEMProblem): .. math:: \mathbf{A} = \mathbf{C}^{\\top} \mathbf{M_{\\rho}^f} \mathbf{C} + i \omega \mathbf{M_{\mu}^e} -<<<<<<< HEAD - :param float freq: Frequency - :rtype: scipy.sparse.csr_matrix - :return: A -======= :param float freq: Frequency :rtype: scipy.sparse.csr_matrix :return: A ->>>>>>> dev + """ MeMu = self.MeMu @@ -735,16 +670,10 @@ class Problem_h(BaseFDEMProblem): \mathbf{RHS} = \mathbf{M^e} \mathbf{s_m} + \mathbf{C}^{\\top} \mathbf{M_{\\rho}^f} \mathbf{s_e} -<<<<<<< HEAD - :param float freq: Frequency - :rtype: numpy.ndarray (nE, nSrc) - :return: RHS - -======= :param float freq: Frequency :rtype: numpy.ndarray :return: RHS (nE, nSrc) ->>>>>>> dev + """ S_m, S_e = self.getSourceTerm(freq) From fbb8cf2731e10000f71e2056215a363ffc0d4023 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Wed, 4 May 2016 23:17:01 -0700 Subject: [PATCH 16/77] modularizing regularization --- SimPEG/Regularization.py | 404 ++++++++++++++++++++++++++------------- 1 file changed, 269 insertions(+), 135 deletions(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index fc101a61..fd974130 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -403,7 +403,203 @@ class BaseRegularization(object): return mD.T * ( self.W.T * ( self.W * ( mD * v) ) ) -class Tikhonov(BaseRegularization): +class Simple(BaseRegularization): + """ + Simple regularization that does not include length scales in the derivatives. + """ + + mrefInSmooth = False #: SMOOTH and SMOOTH_MOD_DIF options + alpha_s = Utils.dependentProperty('_alpha_s', 1e-6, ['_W', '_Wsmall'], "Smallness weight") + alpha_x = Utils.dependentProperty('_alpha_x', 1.0, ['_W', '_Wx'], "Weight for the first derivative in the x direction") + alpha_y = Utils.dependentProperty('_alpha_y', 1.0, ['_W', '_Wy'], "Weight for the first derivative in the y direction") + alpha_z = Utils.dependentProperty('_alpha_z', 1.0, ['_W', '_Wz'], "Weight for the first derivative in the z direction") + wght = 1. + + def __init__(self, mesh, mapping=None, indActive=None, **kwargs): + BaseRegularization.__init__(self, mesh, mapping=mapping, indActive=indActive, **kwargs) + + if isinstance(self.wght,float): + self.wght = np.ones(self.regmesh.nC) * self.wght + + @property + def Wsmall(self): + """Regularization matrix Wsmall""" + if getattr(self,'_Wsmall', None) is None: + self._Wsmall = Utils.sdiag((self.regmesh.vol*self.alpha_s*self.wght)**0.5) + return self._Wsmall + + @property + def Wx(self): + """Regularization matrix Wx""" + if getattr(self, '_Wx', None) is None: + self._Wx = Utils.sdiag((self.regmesh.aveCC2Fx * self.regmesh.vol*self.alpha_x*(self.regmesh.aveCC2Fx*self.wght))**0.5)*self.regmesh.cellDiffxStencil + return self._Wx + + @property + def Wy(self): + """Regularization matrix Wy""" + if getattr(self, '_Wy', None) is None: + self._Wy = Utils.sdiag((self.regmesh.aveCC2Fy * self.regmesh.vol * self.alpha_y*(self.regmesh.aveCC2Fy*self.wght))**0.5)*self.regmesh.cellDiffyStencil + return self._Wy + + @property + def Wz(self): + """Regularization matrix Wz""" + if getattr(self, '_Wz', None) is None: + self._Wz = Utils.sdiag((self.regmesh.aveCC2Fz * self.regmesh.vol*self.alpha_z*(self.regmesh.aveCC2Fz*self.wght))**0.5)*self.regmesh.cellDiffzStencil + return self._Wz + + @property + def Wsmooth(self): + """Full smoothness regularization matrix W""" + if getattr(self, '_Wsmooth', None) is None: + wlist = (self.Wx,) + if self.regmesh.dim > 1: + wlist += (self.Wy,) + if self.regmesh.dim > 2: + wlist += (self.Wz,) + self._Wsmooth = sp.vstack(wlist) + return self._Wsmooth + + @property + def W(self): + """Full regularization matrix W""" + if getattr(self, '_W', None) is None: + wlist = (self.Wsmall, self.Wsmooth) + self._W = sp.vstack(wlist) + return self._W + + @Utils.timeIt + def _evalSmall(self, m): + r = self.Wsmall * ( self.mapping * (m - self.mref) ) + return 0.5 * r.dot(r) + + @property + def W(self): + """Full regularization matrix W""" + if getattr(self, '_W', None) is None: + wlist = (self.Wsmall, self.Wsmooth) + self._W = sp.vstack(wlist) + return self._W + + @property + def Wsmooth(self): + """Full smoothness regularization matrix W""" + if getattr(self, '_Wsmooth', None) is None: + wlist = (self.Wx,) + if self.regmesh.dim > 1: + wlist += (self.Wy,) + if self.regmesh.dim > 2: + wlist += (self.Wz,) + self._Wsmooth = sp.vstack(wlist) + return self._Wsmooth + + + @Utils.timeIt + def _evalSmall(self, m): + r = self.Wsmall * ( self.mapping * (m - self.mref) ) + return 0.5 * r.dot(r) + + @Utils.timeIt + def _evalSmallDeriv(self,m): + r = self.Wsmall * ( self.mapping * (m - self.mref) ) + return r.T * ( self.Wsmall * self.mapping.deriv(m - self.mref) ) + + @Utils.timeIt + def _evalSmoothx(self, m): + if self.mrefInSmooth == True: + r = self.Wx * ( self.mapping * (m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wx * ( self.mapping * (m) ) + return 0.5 * r.dot(r) + + @Utils.timeIt + def _evalSmoothy(self, m): + if self.mrefInSmooth == True: + r = self.Wy * ( self.mapping * (m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wy * ( self.mapping * (m) ) + return 0.5 * r.dot(r) + + @Utils.timeIt + def _evalSmoothz(self, m): + if self.mrefInSmooth == True: + r = self.Wz * ( self.mapping * (m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wz * ( self.mapping * (m) ) + return 0.5 * r.dot(r) + + @Utils.timeIt + def _evalSmooth(self, m): + phiSmooth = self._evalSmoothx(m) + if self.regmesh.dim > 1: + phiSmooth += self._evalSmoothy(m) + if self.regmesh.dim > 2: + phiSmooth += self._evalSmoothz(m) + return phiSmooth + + @Utils.timeIt + def _evalSmoothxDeriv(self,m): + if self.mrefInSmooth == True: + r = self.Wx * ( self.mapping * ( m - self.mref ) ) + return r.T * ( self.Wx * self.mapping.deriv(m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wx * ( self.mapping * m ) + return r.T * ( self.Wx * self.mapping.deriv(m) ) + + @Utils.timeIt + def _evalSmoothyDeriv(self,m): + if self.mrefInSmooth == True: + r = self.Wy * ( self.mapping * ( m - self.mref ) ) + return r.T * ( self.Wy * self.mapping.deriv(m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wy * ( self.mapping * m ) + return r.T * ( self.Wy * self.mapping.deriv(m) ) + + @Utils.timeIt + def _evalSmoothzDeriv(self,m): + if self.mrefInSmooth == True: + r = self.Wz * ( self.mapping * ( m - self.mref ) ) + return r.T * ( self.Wz * self.mapping.deriv(m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wz * ( self.mapping * m ) + return r.T * ( self.Wz * self.mapping.deriv(m) ) + + @Utils.timeIt + def _evalSmoothDeriv(self,m): + deriv = self._evalSmoothxDeriv(m) + if self.regmesh.dim > 1: + deriv += self._evalSmoothyDeriv(m) + if self.regmesh.dim > 2: + deriv += self._evalSmoothzDeriv(m) + return deriv + + + @Utils.timeIt + def eval(self, m): + return self._evalSmall(m) + self._evalSmooth(m) + + @Utils.timeIt + def evalDeriv(self, m): + """ + The regularization is: + + .. math:: + + R(m) = \\frac{1}{2}\mathbf{(m-m_\\text{ref})^\\top W^\\top W(m-m_\\text{ref})} + + So the derivative is straight forward: + + .. math:: + + R(m) = \mathbf{W^\\top W (m-m_\\text{ref})} + + """ + return self._evalSmallDeriv(m) + self._evalSmoothDeriv(m) + + + +class Tikhonov(Simple): """ L2 Tikhonov regularization with both smallness and smoothness (first order derivative) contributions. @@ -493,56 +689,92 @@ class Tikhonov(BaseRegularization): self._Wzz = Utils.sdiag((self.regmesh.vol*self.alpha_zz)**0.5)*self.regmesh.faceDiffz*self.regmesh.cellDiffz return self._Wzz + @property - def Wsmooth(self): + def Wsmooth2(self): """Full smoothness regularization matrix W""" if getattr(self, '_Wsmooth', None) is None: - wlist = (self.Wx, self.Wxx) + wlist = (self.Wxx) if self.regmesh.dim > 1: - wlist += (self.Wy, self.Wyy) + wlist += (self.Wyy) if self.regmesh.dim > 2: - wlist += (self.Wz, self.Wzz) + wlist += (self.Wzz) self._Wsmooth = sp.vstack(wlist) return self._Wsmooth - @property - def W(self): - """Full regularization matrix W""" - if getattr(self, '_W', None) is None: - wlist = (self.Wsmall, self.Wsmooth) - self._W = sp.vstack(wlist) - return self._W - @Utils.timeIt - def _evalSmall(self, m): - r = self.Wsmall * ( self.mapping * (m - self.mref) ) - return 0.5 * r.dot(r) - - @Utils.timeIt - def _evalSmooth(self, m): + def _evalSmoothxx(self, m): if self.mrefInSmooth == True: - r = self.Wsmooth * ( self.mapping * (m - self.mref) ) + r = self.Wxx * ( self.mapping * (m - self.mref) ) elif self.mrefInSmooth == False: - r = self.Wsmooth * ( self.mapping * (m) ) + r = self.Wxx * ( self.mapping * (m) ) return 0.5 * r.dot(r) + @Utils.timeIt + def _evalSmoothyy(self, m): + if self.mrefInSmooth == True: + r = self.Wyy * ( self.mapping * (m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wyy * ( self.mapping * (m) ) + return 0.5 * r.dot(r) + + @Utils.timeIt + def _evalSmoothzz(self, m): + if self.mrefInSmooth == True: + r = self.Wzz * ( self.mapping * (m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wzz * ( self.mapping * (m) ) + return 0.5 * r.dot(r) + + @Utils.timeIt + def _evalSmooth2(self, m): + phiSmooth2 = self._evalSmoothxx(m) + if self.regmesh.dim > 1: + phiSmooth2 += self._evalSmoothyy(m) + if self.regmesh.dim > 2: + phiSmooth2 += self._evalSmoothzz(m) + return phiSmooth2 + + @Utils.timeIt + def _evalSmoothxxDeriv(self,m): + if self.mrefInSmooth == True: + r = self.Wxx * ( self.mapping * ( m - self.mref ) ) + return r.T * ( self.Wxx * self.mapping.deriv(m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wxx * ( self.mapping * m ) + return r.T * ( self.Wxx * self.mapping.deriv(m) ) + + @Utils.timeIt + def _evalSmoothyyDeriv(self,m): + if self.mrefInSmooth == True: + r = self.Wyy * ( self.mapping * ( m - self.mref ) ) + return r.T * ( self.Wyy * self.mapping.deriv(m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wyy * ( self.mapping * m ) + return r.T * ( self.Wyy * self.mapping.deriv(m) ) + + @Utils.timeIt + def _evalSmoothzzDeriv(self,m): + if self.mrefInSmooth == True: + r = self.Wzz * ( self.mapping * ( m - self.mref ) ) + return r.T * ( self.Wzz * self.mapping.deriv(m - self.mref) ) + elif self.mrefInSmooth == False: + r = self.Wzz * ( self.mapping * m ) + return r.T * ( self.Wzz * self.mapping.deriv(m) ) + + @Utils.timeIt + def _evalSmooth2Deriv(self,m): + deriv = self._evalSmoothxxDeriv(m) + if self.regmesh.dim > 1: + deriv += self._evalSmoothyyDeriv(m) + if self.regmesh.dim > 2: + deriv += self._evalSmoothzzDeriv(m) + return deriv + + @Utils.timeIt def eval(self, m): - return self._evalSmall(m) + self._evalSmooth(m) - - @Utils.timeIt - def _evalSmallDeriv(self,m): - r = self.Wsmall * ( self.mapping * (m - self.mref) ) - return r.T * ( self.Wsmall * self.mapping.deriv(m - self.mref) ) - - @Utils.timeIt - def _evalSmoothDeriv(self,m): - if self.mrefInSmooth == True: - r = self.Wsmooth * ( self.mapping * ( m - self.mref ) ) - return r.T * ( self.Wsmooth * self.mapping.deriv(m - self.mref) ) - elif self.mrefInSmooth == False: - r = self.Wsmooth * ( self.mapping * m ) - return r.T * ( self.Wsmooth * self.mapping.deriv(m) ) + return self._evalSmall(m) + self._evalSmooth(m) + self._evalSmooth2(m) @Utils.timeIt def evalDeriv(self, m): @@ -560,88 +792,9 @@ class Tikhonov(BaseRegularization): R(m) = \mathbf{W^\\top W (m-m_\\text{ref})} """ - return self._evalSmallDeriv(m) + self._evalSmoothDeriv(m) + return self._evalSmallDeriv(m) + self._evalSmoothDeriv(m) + self._evalSmooth2Deriv(m) -class Simple(Tikhonov): - """ - Simple regularization that does not include length scales in the derivatives. - """ - - mrefInSmooth = False #: SMOOTH and SMOOTH_MOD_DIF options - alpha_s = Utils.dependentProperty('_alpha_s', 1.0, ['_W', '_Wsmall'], "Smallness weight") - alpha_x = Utils.dependentProperty('_alpha_x', 1.0, ['_W', '_Wx'], "Weight for the first derivative in the x direction") - alpha_y = Utils.dependentProperty('_alpha_y', 1.0, ['_W', '_Wy'], "Weight for the first derivative in the y direction") - alpha_z = Utils.dependentProperty('_alpha_z', 1.0, ['_W', '_Wz'], "Weight for the first derivative in the z direction") - wght = 1. - - def __init__(self, mesh, mapping=None, indActive=None, **kwargs): - BaseRegularization.__init__(self, mesh, mapping=mapping, indActive=indActive, **kwargs) - - if isinstance(self.wght,float): - self.wght = np.ones(self.regmesh.nC) * self.wght - - @property - def Wsmall(self): - """Regularization matrix Wsmall""" - if getattr(self,'_Wsmall', None) is None: - self._Wsmall = Utils.sdiag((self.regmesh.vol*self.alpha_s*self.wght)**0.5) - return self._Wsmall - - @property - def Wx(self): - """Regularization matrix Wx""" - if getattr(self, '_Wx', None) is None: - self._Wx = Utils.sdiag((self.regmesh.aveCC2Fx * self.regmesh.vol*self.alpha_x*(self.regmesh.aveCC2Fx*self.wght))**0.5)*self.regmesh.cellDiffxStencil - return self._Wx - - @property - def Wy(self): - """Regularization matrix Wy""" - if getattr(self, '_Wy', None) is None: - self._Wy = Utils.sdiag((self.regmesh.aveCC2Fy * self.regmesh.vol * self.alpha_y*(self.regmesh.aveCC2Fy*self.wght))**0.5)*self.regmesh.cellDiffyStencil - return self._Wy - - @property - def Wz(self): - """Regularization matrix Wz""" - if getattr(self, '_Wz', None) is None: - self._Wz = Utils.sdiag((self.regmesh.aveCC2Fz * self.regmesh.vol*self.alpha_z*(self.regmesh.aveCC2Fz*self.wght))**0.5)*self.regmesh.cellDiffzStencil - return self._Wz - - @property - def Wsmooth(self): - """Full smoothness regularization matrix W""" - if getattr(self, '_Wsmooth', None) is None: - wlist = (self.Wx,) - if self.regmesh.dim > 1: - wlist += (self.Wy,) - if self.regmesh.dim > 2: - wlist += (self.Wz,) - self._Wsmooth = sp.vstack(wlist) - return self._Wsmooth - - @property - def W(self): - """Full regularization matrix W""" - if getattr(self, '_W', None) is None: - wlist = (self.Wsmall, self.Wsmooth) - self._W = sp.vstack(wlist) - return self._W - - @Utils.timeIt - def _evalSmall(self, m): - r = self.Wsmall * ( self.mapping * (m - self.mref) ) - return 0.5 * r.dot(r) - - @Utils.timeIt - def _evalSmooth(self, m): - if self.mrefInSmooth == True: - r = self.Wsmooth * ( self.mapping * (m - self.mref) ) - elif self.mrefInSmooth == False: - r = self.Wsmooth * ( self.mapping * m) - return 0.5 * r.dot(r) - class Sparse(Simple): @@ -716,25 +869,6 @@ class Sparse(Simple): return Utils.sdiag(((self.regmesh.aveCC2Fz * self.regmesh.vol)*self.alpha_z*self.gamma*(self.regmesh.aveCC2Fz*self.wght))**0.5)*self.Rz*self.regmesh.cellDiffzStencil - @property - def Wsmooth(self): - """Full smoothness regularization matrix W""" - #if getattr(self, '_Wsmooth', None) is None: - wlist = (self.Wx,) - if self.regmesh.dim > 1: - wlist += (self.Wy,) - if self.regmesh.dim > 2: - wlist += (self.Wz,) - #self._Wsmooth = sp.vstack(wlist) - return sp.vstack(wlist) - - @property - def W(self): - """Full regularization matrix W""" - if getattr(self, '_W', None) is None: - wlist = (self.Wsmall, self.Wsmooth) - self._W = sp.vstack(wlist) - return self._W def R(self, f_m , eps, exponent): From b4ab60c2601b6cb2dd64a65d58863f66f265f458 Mon Sep 17 00:00:00 2001 From: D Fournier Date: Thu, 5 May 2016 11:55:56 -0700 Subject: [PATCH 17/77] Add model mapping to sparse regularization --- SimPEG/Regularization.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index ed1039ec..1b0d180f 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -663,7 +663,7 @@ class Sparse(Simple): self.Rs = Utils.speye(self.regmesh.nC) else: - f_m = self.curModel - self.reg.mref + f_m = self.mapping * (self.curModel - self.reg.mref) self.rs = self.R(f_m , self.eps_p, self.norms[0]) #print "Min rs: " + str(np.max(self.rs)) + "Max rs: " + str(np.min(self.rs)) self.Rs = Utils.sdiag( self.rs ) @@ -679,7 +679,7 @@ class Sparse(Simple): self.Rx = Utils.speye(self.regmesh.cellDiffxStencil.shape[0]) else: - f_m = self.regmesh.cellDiffxStencil * self.curModel + f_m = self.regmesh.cellDiffxStencil * (self.mapping * self.curModel) self.rx = self.R( f_m , self.eps_q, self.norms[1]) self.Rx = Utils.sdiag( self.rx ) @@ -693,7 +693,7 @@ class Sparse(Simple): self.Ry = Utils.speye(self.regmesh.cellDiffyStencil.shape[0]) else: - f_m = self.regmesh.cellDiffyStencil * self.curModel + f_m = self.regmesh.cellDiffyStencil * (self.mapping * self.curModel) self.ry = self.R( f_m , self.eps_q, self.norms[2]) self.Ry = Utils.sdiag( self.ry ) @@ -707,7 +707,7 @@ class Sparse(Simple): self.Rz = Utils.speye(self.regmesh.cellDiffzStencil.shape[0]) else: - f_m = self.regmesh.cellDiffzStencil * self.curModel + f_m = self.regmesh.cellDiffzStencil * (self.mapping * self.curModel) self.rz = self.R( f_m , self.eps_q, self.norms[3]) self.Rz = Utils.sdiag( self.rz ) From fb5434695f13388790df41b6f4b293a5425d053d Mon Sep 17 00:00:00 2001 From: D Fournier Date: Tue, 10 May 2016 14:31:45 -0700 Subject: [PATCH 18/77] Alpha_s default to 1.0 --- SimPEG/Regularization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 7f50ea59..8fdb9fd5 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -409,7 +409,7 @@ class Simple(BaseRegularization): """ mrefInSmooth = False #: SMOOTH and SMOOTH_MOD_DIF options - alpha_s = Utils.dependentProperty('_alpha_s', 1e-6, ['_W', '_Wsmall'], "Smallness weight") + alpha_s = Utils.dependentProperty('_alpha_s', 1.0, ['_W', '_Wsmall'], "Smallness weight") alpha_x = Utils.dependentProperty('_alpha_x', 1.0, ['_W', '_Wx'], "Weight for the first derivative in the x direction") alpha_y = Utils.dependentProperty('_alpha_y', 1.0, ['_W', '_Wy'], "Weight for the first derivative in the y direction") alpha_z = Utils.dependentProperty('_alpha_z', 1.0, ['_W', '_Wz'], "Weight for the first derivative in the z direction") From eaa37f42e47b3e1d01ed10fd50d9b7cd8d29796f Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 10 May 2016 14:51:56 -0700 Subject: [PATCH 19/77] remove duplicate evalSmall --- SimPEG/Regularization.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 8fdb9fd5..1276cbb6 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -469,10 +469,6 @@ class Simple(BaseRegularization): self._W = sp.vstack(wlist) return self._W - @Utils.timeIt - def _evalSmall(self, m): - r = self.Wsmall * ( self.mapping * (m - self.mref) ) - return 0.5 * r.dot(r) @property def W(self): From 3f0c89f10b3783e63b14ccb530b565613d0cbff0 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 10 May 2016 14:53:43 -0700 Subject: [PATCH 20/77] remove extra Ws --- SimPEG/Regularization.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 1276cbb6..361a3206 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -470,27 +470,6 @@ class Simple(BaseRegularization): return self._W - @property - def W(self): - """Full regularization matrix W""" - if getattr(self, '_W', None) is None: - wlist = (self.Wsmall, self.Wsmooth) - self._W = sp.vstack(wlist) - return self._W - - @property - def Wsmooth(self): - """Full smoothness regularization matrix W""" - if getattr(self, '_Wsmooth', None) is None: - wlist = (self.Wx,) - if self.regmesh.dim > 1: - wlist += (self.Wy,) - if self.regmesh.dim > 2: - wlist += (self.Wz,) - self._Wsmooth = sp.vstack(wlist) - return self._Wsmooth - - @Utils.timeIt def _evalSmall(self, m): r = self.Wsmall * ( self.mapping * (m - self.mref) ) From 2a802c1aa3ae90b120cb828194c36dfd2d57ccbf Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 10 May 2016 16:39:47 -0700 Subject: [PATCH 21/77] weights --> cell_weights, removed vol term from simple regularization --- SimPEG/Regularization.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 361a3206..5d40adf8 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -413,40 +413,40 @@ class Simple(BaseRegularization): alpha_x = Utils.dependentProperty('_alpha_x', 1.0, ['_W', '_Wx'], "Weight for the first derivative in the x direction") alpha_y = Utils.dependentProperty('_alpha_y', 1.0, ['_W', '_Wy'], "Weight for the first derivative in the y direction") alpha_z = Utils.dependentProperty('_alpha_z', 1.0, ['_W', '_Wz'], "Weight for the first derivative in the z direction") - wght = 1. + cell_weights = 1. def __init__(self, mesh, mapping=None, indActive=None, **kwargs): BaseRegularization.__init__(self, mesh, mapping=mapping, indActive=indActive, **kwargs) - if isinstance(self.wght,float): - self.wght = np.ones(self.regmesh.nC) * self.wght + if isinstance(self.cell_weights,float): + self.cell_weights = np.ones(self.regmesh.nC) * self.cell_weights @property def Wsmall(self): """Regularization matrix Wsmall""" if getattr(self,'_Wsmall', None) is None: - self._Wsmall = Utils.sdiag((self.regmesh.vol*self.alpha_s*self.wght)**0.5) + self._Wsmall = Utils.sdiag((self.alpha_s*self.cell_weights)**0.5) return self._Wsmall @property def Wx(self): """Regularization matrix Wx""" if getattr(self, '_Wx', None) is None: - self._Wx = Utils.sdiag((self.regmesh.aveCC2Fx * self.regmesh.vol*self.alpha_x*(self.regmesh.aveCC2Fx*self.wght))**0.5)*self.regmesh.cellDiffxStencil + self._Wx = Utils.sdiag((self.alpha_x * (self.regmesh.aveCC2Fx*self.cell_weights))**0.5)*self.regmesh.cellDiffxStencil return self._Wx @property def Wy(self): """Regularization matrix Wy""" if getattr(self, '_Wy', None) is None: - self._Wy = Utils.sdiag((self.regmesh.aveCC2Fy * self.regmesh.vol * self.alpha_y*(self.regmesh.aveCC2Fy*self.wght))**0.5)*self.regmesh.cellDiffyStencil + self._Wy = Utils.sdiag((self.alpha_y * (self.regmesh.aveCC2Fy*self.cell_weights))**0.5)*self.regmesh.cellDiffyStencil return self._Wy @property def Wz(self): """Regularization matrix Wz""" if getattr(self, '_Wz', None) is None: - self._Wz = Utils.sdiag((self.regmesh.aveCC2Fz * self.regmesh.vol*self.alpha_z*(self.regmesh.aveCC2Fz*self.wght))**0.5)*self.regmesh.cellDiffzStencil + self._Wz = Utils.sdiag((self.alpha_z * (self.regmesh.aveCC2Fz*self.cell_weights))**0.5)*self.regmesh.cellDiffzStencil return self._Wz @property @@ -779,13 +779,13 @@ class Sparse(Simple): curModel = None # use a model to compute the weights gamma = 1. norms = [0., 2., 2., 2.] - wght = 1. + cell_weights = 1. def __init__(self, mesh, mapping=None, indActive=None, **kwargs): Simple.__init__(self, mesh, mapping=mapping, indActive=indActive, **kwargs) - if isinstance(self.wght,float): - self.wght = np.ones(self.regmesh.nC) * self.wght + if isinstance(self.cell_weights,float): + self.cell_weights = np.ones(self.regmesh.nC) * self.cell_weights @property def Wsmall(self): @@ -799,7 +799,7 @@ class Sparse(Simple): #print "Min rs: " + str(np.max(self.rs)) + "Max rs: " + str(np.min(self.rs)) self.Rs = Utils.sdiag( self.rs ) - return Utils.sdiag((self.regmesh.vol*self.alpha_s*self.gamma*self.wght)**0.5)*self.Rs + return Utils.sdiag((self.regmesh.vol*self.alpha_s*self.gamma*self.cell_weights)**0.5)*self.Rs @property @@ -814,7 +814,7 @@ class Sparse(Simple): self.rx = self.R( f_m , self.eps_q, self.norms[1]) self.Rx = Utils.sdiag( self.rx ) - return Utils.sdiag(( (self.regmesh.aveCC2Fx * self.regmesh.vol) *self.alpha_x*self.gamma*(self.regmesh.aveCC2Fx*self.wght))**0.5)*self.Rx*self.regmesh.cellDiffxStencil + return Utils.sdiag(( (self.regmesh.aveCC2Fx * self.regmesh.vol) *self.alpha_x*self.gamma*(self.regmesh.aveCC2Fx*self.cell_weights))**0.5)*self.Rx*self.regmesh.cellDiffxStencil @property def Wy(self): @@ -828,7 +828,7 @@ class Sparse(Simple): self.ry = self.R( f_m , self.eps_q, self.norms[2]) self.Ry = Utils.sdiag( self.ry ) - return Utils.sdiag(((self.regmesh.aveCC2Fy * self.regmesh.vol)*self.alpha_y*self.gamma*(self.regmesh.aveCC2Fy*self.wght))**0.5)*self.Ry*self.regmesh.cellDiffyStencil + return Utils.sdiag(((self.regmesh.aveCC2Fy * self.regmesh.vol)*self.alpha_y*self.gamma*(self.regmesh.aveCC2Fy*self.cell_weights))**0.5)*self.Ry*self.regmesh.cellDiffyStencil @property def Wz(self): @@ -842,7 +842,7 @@ class Sparse(Simple): self.rz = self.R( f_m , self.eps_q, self.norms[3]) self.Rz = Utils.sdiag( self.rz ) - return Utils.sdiag(((self.regmesh.aveCC2Fz * self.regmesh.vol)*self.alpha_z*self.gamma*(self.regmesh.aveCC2Fz*self.wght))**0.5)*self.Rz*self.regmesh.cellDiffzStencil + return Utils.sdiag(((self.regmesh.aveCC2Fz * self.regmesh.vol)*self.alpha_z*self.gamma*(self.regmesh.aveCC2Fz*self.cell_weights))**0.5)*self.Rz*self.regmesh.cellDiffzStencil def R(self, f_m , eps, exponent): From 955bd54019b9e6fccf8f766ce83d4fdde9ac61f0 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 10 May 2016 16:46:11 -0700 Subject: [PATCH 22/77] notation cleanup in Regularization --- SimPEG/Regularization.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 5d40adf8..16bb4b9f 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -1,4 +1,6 @@ -import Utils, Maps, Mesh, numpy as np, scipy.sparse as sp +import Utils, Maps, Mesh +import numpy as np +import scipy.sparse as sp class RegularizationMesh(object): """ @@ -476,7 +478,7 @@ class Simple(BaseRegularization): return 0.5 * r.dot(r) @Utils.timeIt - def _evalSmallDeriv(self,m): + def _evalSmallDeriv(self, m): r = self.Wsmall * ( self.mapping * (m - self.mref) ) return r.T * ( self.Wsmall * self.mapping.deriv(m - self.mref) ) @@ -514,7 +516,7 @@ class Simple(BaseRegularization): return phiSmooth @Utils.timeIt - def _evalSmoothxDeriv(self,m): + def _evalSmoothxDeriv(self, m): if self.mrefInSmooth == True: r = self.Wx * ( self.mapping * ( m - self.mref ) ) return r.T * ( self.Wx * self.mapping.deriv(m - self.mref) ) @@ -523,7 +525,7 @@ class Simple(BaseRegularization): return r.T * ( self.Wx * self.mapping.deriv(m) ) @Utils.timeIt - def _evalSmoothyDeriv(self,m): + def _evalSmoothyDeriv(self, m): if self.mrefInSmooth == True: r = self.Wy * ( self.mapping * ( m - self.mref ) ) return r.T * ( self.Wy * self.mapping.deriv(m - self.mref) ) @@ -532,7 +534,7 @@ class Simple(BaseRegularization): return r.T * ( self.Wy * self.mapping.deriv(m) ) @Utils.timeIt - def _evalSmoothzDeriv(self,m): + def _evalSmoothzDeriv(self, m): if self.mrefInSmooth == True: r = self.Wz * ( self.mapping * ( m - self.mref ) ) return r.T * ( self.Wz * self.mapping.deriv(m - self.mref) ) @@ -541,7 +543,7 @@ class Simple(BaseRegularization): return r.T * ( self.Wz * self.mapping.deriv(m) ) @Utils.timeIt - def _evalSmoothDeriv(self,m): + def _evalSmoothDeriv(self, m): deriv = self._evalSmoothxDeriv(m) if self.regmesh.dim > 1: deriv += self._evalSmoothyDeriv(m) @@ -711,7 +713,7 @@ class Tikhonov(Simple): return phiSmooth2 @Utils.timeIt - def _evalSmoothxxDeriv(self,m): + def _evalSmoothxxDeriv(self, m): if self.mrefInSmooth == True: r = self.Wxx * ( self.mapping * ( m - self.mref ) ) return r.T * ( self.Wxx * self.mapping.deriv(m - self.mref) ) @@ -720,7 +722,7 @@ class Tikhonov(Simple): return r.T * ( self.Wxx * self.mapping.deriv(m) ) @Utils.timeIt - def _evalSmoothyyDeriv(self,m): + def _evalSmoothyyDeriv(self, m): if self.mrefInSmooth == True: r = self.Wyy * ( self.mapping * ( m - self.mref ) ) return r.T * ( self.Wyy * self.mapping.deriv(m - self.mref) ) @@ -729,7 +731,7 @@ class Tikhonov(Simple): return r.T * ( self.Wyy * self.mapping.deriv(m) ) @Utils.timeIt - def _evalSmoothzzDeriv(self,m): + def _evalSmoothzzDeriv(self, m): if self.mrefInSmooth == True: r = self.Wzz * ( self.mapping * ( m - self.mref ) ) return r.T * ( self.Wzz * self.mapping.deriv(m - self.mref) ) @@ -738,7 +740,7 @@ class Tikhonov(Simple): return r.T * ( self.Wzz * self.mapping.deriv(m) ) @Utils.timeIt - def _evalSmooth2Deriv(self,m): + def _evalSmooth2Deriv(self, m): deriv = self._evalSmoothxxDeriv(m) if self.regmesh.dim > 1: deriv += self._evalSmoothyyDeriv(m) @@ -774,12 +776,12 @@ class Tikhonov(Simple): class Sparse(Simple): # set default values - eps_p = 1e-1 - eps_q = 1e-1 + eps_p = 1e-1 + eps_q = 1e-1 curModel = None # use a model to compute the weights - gamma = 1. - norms = [0., 2., 2., 2.] - cell_weights = 1. + gamma = 1. + norms = [0., 2., 2., 2.] + cell_weights = 1. def __init__(self, mesh, mapping=None, indActive=None, **kwargs): Simple.__init__(self, mesh, mapping=mapping, indActive=indActive, **kwargs) From 7964ebce50f86b87f11873cfb0e40632f4eb930f Mon Sep 17 00:00:00 2001 From: D Fournier Date: Tue, 10 May 2016 17:20:46 -0700 Subject: [PATCH 23/77] Update directive to None the Wsmooth after iteration. --- SimPEG/Directives.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SimPEG/Directives.py b/SimPEG/Directives.py index 4fc1ffc5..008cc57b 100644 --- a/SimPEG/Directives.py +++ b/SimPEG/Directives.py @@ -303,26 +303,27 @@ class Update_IRLS(InversionDirective): # Set the weighting matrix to None so that it is recomputed next time # it is called in the inversion self.reg._W = None + self.reg._Wsmooth = None class Update_lin_PreCond(InversionDirective): """ Create a Jacobi preconditioner for the linear problem """ onlyOnStart=False - + def initialize(self): - + if getattr(self.opt, 'approxHinv', None) is None: # Update the pre-conditioner diagA = np.sum(self.prob.G**2.,axis=0) + self.invProb.beta*(self.reg.W.T*self.reg.W).diagonal() #* (self.reg.mapping * np.ones(self.reg.curModel.size))**2. PC = Utils.sdiag((self.prob.mapping.deriv(None).T *diagA)**-1.) self.opt.approxHinv = PC - + def endIter(self): # Cool the threshold parameter if self.onlyOnStart==True: return - + if getattr(self.opt, 'approxHinv', None) is not None: # Update the pre-conditioner diagA = np.sum(self.prob.G**2.,axis=0) + self.invProb.beta*(self.reg.W.T*self.reg.W).diagonal() #* (self.reg.mapping * np.ones(self.reg.curModel.size))**2. From 90a3030796234798c3755745810415f52ef5a77e Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 10 May 2016 21:39:15 -0700 Subject: [PATCH 24/77] fixed 2 deriv --- SimPEG/Examples/Inversion_IRLS.py | 4 +- SimPEG/Regularization.py | 123 ++++++++++++++++++++++++++++-- 2 files changed, 119 insertions(+), 8 deletions(-) diff --git a/SimPEG/Examples/Inversion_IRLS.py b/SimPEG/Examples/Inversion_IRLS.py index 06ef4be4..c925cce2 100644 --- a/SimPEG/Examples/Inversion_IRLS.py +++ b/SimPEG/Examples/Inversion_IRLS.py @@ -84,12 +84,12 @@ def run(N=200, plotIt=True): #============================================================================== #reg.recModel = mrec - reg.wght = np.ones(mesh.nC) + # reg.cell_weight = np.ones(mesh.nC) reg.mref = np.zeros(mesh.nC) reg.eps_p = 5e-2 reg.eps_q = 1e-2 reg.norms = [0., 0., 2., 2.] - reg.wght = wr + reg.cell_weight = wr opt = Optimization.ProjectedGNCG(maxIter=10 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 20, tolCG = 1e-3) invProb = InvProblem.BaseInvProblem(dmis, reg, opt, beta = invProb.beta*2.) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 16bb4b9f..5947ed03 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -410,11 +410,11 @@ class Simple(BaseRegularization): Simple regularization that does not include length scales in the derivatives. """ - mrefInSmooth = False #: SMOOTH and SMOOTH_MOD_DIF options + mrefInSmooth = False #: include mref in the smoothness? alpha_s = Utils.dependentProperty('_alpha_s', 1.0, ['_W', '_Wsmall'], "Smallness weight") - alpha_x = Utils.dependentProperty('_alpha_x', 1.0, ['_W', '_Wx'], "Weight for the first derivative in the x direction") - alpha_y = Utils.dependentProperty('_alpha_y', 1.0, ['_W', '_Wy'], "Weight for the first derivative in the y direction") - alpha_z = Utils.dependentProperty('_alpha_z', 1.0, ['_W', '_Wz'], "Weight for the first derivative in the z direction") + alpha_x = Utils.dependentProperty('_alpha_x', 1.0, ['_W', '_Wx'], "Weight for the first derivative in the x direction") + alpha_y = Utils.dependentProperty('_alpha_y', 1.0, ['_W', '_Wy'], "Weight for the first derivative in the y direction") + alpha_z = Utils.dependentProperty('_alpha_z', 1.0, ['_W', '_Wz'], "Weight for the first derivative in the z direction") cell_weights = 1. def __init__(self, mesh, mapping=None, indActive=None, **kwargs): @@ -454,6 +454,8 @@ class Simple(BaseRegularization): @property def Wsmooth(self): """Full smoothness regularization matrix W""" + print 'wtf why are we using Wsmooth' + raise NotImplementedError if getattr(self, '_Wsmooth', None) is None: wlist = (self.Wx,) if self.regmesh.dim > 1: @@ -482,6 +484,13 @@ class Simple(BaseRegularization): r = self.Wsmall * ( self.mapping * (m - self.mref) ) return r.T * ( self.Wsmall * self.mapping.deriv(m - self.mref) ) + @Utils.timeIt + def _evalSmall2Deriv(self, m, v = None): + rDeriv = self.Wsmall * ( self.mapping.deriv(m - self.mref) ) + if v is not None: + return rDeriv.T * (rDeriv * v) + return rDeriv.T * rDeriv + @Utils.timeIt def _evalSmoothx(self, m): if self.mrefInSmooth == True: @@ -524,6 +533,17 @@ class Simple(BaseRegularization): r = self.Wx * ( self.mapping * m ) return r.T * ( self.Wx * self.mapping.deriv(m) ) + @Utils.timeIt + def _evalSmoothx2Deriv(self, m, v=None): + if self.mrefInSmooth == True: + rDeriv = self.Wx * ( self.mapping.deriv( m - self.mref ) ) + elif self.mrefInSmooth == False: + rDeriv = self.Wx * ( self.mapping.deriv(m) ) + + if v is not None: + return rDeriv.T * ( rDeriv * v ) + return rDeriv.T * rDeriv + @Utils.timeIt def _evalSmoothyDeriv(self, m): if self.mrefInSmooth == True: @@ -533,6 +553,17 @@ class Simple(BaseRegularization): r = self.Wy * ( self.mapping * m ) return r.T * ( self.Wy * self.mapping.deriv(m) ) + @Utils.timeIt + def _evalSmoothy2Deriv(self, m, v=None): + if self.mrefInSmooth == True: + rDeriv = self.Wy * ( self.mapping.deriv( m - self.mref ) ) + elif self.mrefInSmooth == False: + rDeriv = self.Wy * ( self.mapping.deriv(m) ) + + if v is not None: + return rDeriv.T * ( rDeriv * v ) + return rDeriv.T * rDeriv + @Utils.timeIt def _evalSmoothzDeriv(self, m): if self.mrefInSmooth == True: @@ -542,6 +573,17 @@ class Simple(BaseRegularization): r = self.Wz * ( self.mapping * m ) return r.T * ( self.Wz * self.mapping.deriv(m) ) + @Utils.timeIt + def _evalSmoothz2Deriv(self, m, v=None): + if self.mrefInSmooth == True: + rDeriv = self.Wz * ( self.mapping.deriv( m - self.mref ) ) + elif self.mrefInSmooth == False: + rDeriv = self.Wz * ( self.mapping.deriv(m) ) + + if v is not None: + return rDeriv.T * ( rDeriv * v ) + return rDeriv.T * rDeriv + @Utils.timeIt def _evalSmoothDeriv(self, m): deriv = self._evalSmoothxDeriv(m) @@ -551,6 +593,15 @@ class Simple(BaseRegularization): deriv += self._evalSmoothzDeriv(m) return deriv + @Utils.timeIt + def _evalSmooth2Deriv(self, m, v=None): + deriv = self._evalSmoothx2Deriv(m, v) + if self.regmesh.dim > 1: + deriv += self._evalSmoothy2Deriv(m, v) + if self.regmesh.dim > 2: + deriv += self._evalSmoothz2Deriv(m, v) + return deriv + @Utils.timeIt def eval(self, m): @@ -574,6 +625,10 @@ class Simple(BaseRegularization): """ return self._evalSmallDeriv(m) + self._evalSmoothDeriv(m) + @Utils.timeIt + def eval2Deriv(self, m, v=None): + return self._evalSmall2Deriv(m, v) + self._evalSmooth2Deriv(m, v) + class Tikhonov(Simple): @@ -740,7 +795,37 @@ class Tikhonov(Simple): return r.T * ( self.Wzz * self.mapping.deriv(m) ) @Utils.timeIt - def _evalSmooth2Deriv(self, m): + def _evalSmoothxx2Deriv(self, m, v=None): + if self.mrefInSmooth == True: + rDeriv = self.Wxx * ( self.mapping.deriv( m - self.mref ) ) + elif self.mrefInSmooth == False: + rDeriv = self.Wxx * self.mapping.deriv(m) + if v is not None: + return rDeriv.T * (rDeriv * v) + return rDeriv.T * rDeriv + + @Utils.timeIt + def _evalSmoothyy2Deriv(self, m, v=None): + if self.mrefInSmooth == True: + rDeriv = self.Wyy * ( self.mapping.deriv( m - self.mref ) ) + elif self.mrefInSmooth == False: + rDeriv = self.Wyy * self.mapping.deriv(m) + if v is not None: + return rDeriv.T * (rDeriv * v) + return rDeriv.T * rDeriv + + @Utils.timeIt + def _evalSmoothzz2Deriv(self, m, v=None): + if self.mrefInSmooth == True: + rDeriv = self.Wzz * ( self.mapping.deriv( m - self.mref ) ) + elif self.mrefInSmooth == False: + rDeriv = self.Wzz * self.mapping.deriv(m) + if v is not None: + return rDeriv.T * (rDeriv * v) + return rDeriv.T * rDeriv + + @Utils.timeIt + def _evalSmoothDeriv2(self, m): deriv = self._evalSmoothxxDeriv(m) if self.regmesh.dim > 1: deriv += self._evalSmoothyyDeriv(m) @@ -748,6 +833,15 @@ class Tikhonov(Simple): deriv += self._evalSmoothzzDeriv(m) return deriv + @Utils.timeIt + def _evalSmooth2Deriv2(self, m, v=None): + deriv = self._evalSmoothxx2Deriv(m, v) + if self.regmesh.dim > 1: + deriv += self._evalSmoothyy2Deriv(m, v) + if self.regmesh.dim > 2: + deriv += self._evalSmoothzz2Deriv(m, v) + return deriv + @Utils.timeIt def eval(self, m): @@ -769,7 +863,24 @@ class Tikhonov(Simple): R(m) = \mathbf{W^\\top W (m-m_\\text{ref})} """ - return self._evalSmallDeriv(m) + self._evalSmoothDeriv(m) + self._evalSmooth2Deriv(m) + return self._evalSmallDeriv(m) + self._evalSmoothDeriv(m) + self._evalSmoothDeriv2(m) + + def eval2Deriv(self, m): + """ + The regularization is: + + .. math:: + + R(m) = \\frac{1}{2}\mathbf{(m-m_\\text{ref})^\\top W^\\top W(m-m_\\text{ref})} + + So the derivative is straight forward: + + .. math:: + + R(m) = \mathbf{W^\\top W (m-m_\\text{ref})} + + """ + return self._evalSmall2Deriv(m) + self._evalSmooth2Deriv(m) + self._evalSmooth2Deriv2(m) From 3dd9ecc9cd7f95b596d9027595013f9ca4647035 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 10 May 2016 22:10:19 -0700 Subject: [PATCH 25/77] fix tikhonov 2Deriv --- SimPEG/Regularization.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 5947ed03..8f1b2d2c 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -865,7 +865,7 @@ class Tikhonov(Simple): """ return self._evalSmallDeriv(m) + self._evalSmoothDeriv(m) + self._evalSmoothDeriv2(m) - def eval2Deriv(self, m): + def eval2Deriv(self, m, v=None): """ The regularization is: @@ -880,7 +880,7 @@ class Tikhonov(Simple): R(m) = \mathbf{W^\\top W (m-m_\\text{ref})} """ - return self._evalSmall2Deriv(m) + self._evalSmooth2Deriv(m) + self._evalSmooth2Deriv2(m) + return self._evalSmall2Deriv(m, v) + self._evalSmooth2Deriv(m, v) + self._evalSmooth2Deriv2(m, v) From e10d6878fb86b129953e68c3749307321a7d8eea Mon Sep 17 00:00:00 2001 From: D Fournier Date: Wed, 11 May 2016 07:58:06 -0700 Subject: [PATCH 26/77] Remove Wsmooth from def W and replace by parts --- SimPEG/Regularization.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 8f1b2d2c..3263ba9a 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -469,7 +469,11 @@ class Simple(BaseRegularization): def W(self): """Full regularization matrix W""" if getattr(self, '_W', None) is None: - wlist = (self.Wsmall, self.Wsmooth) + wlist = (self.Wsmall, self.Wx) + if self.regmesh.dim > 1: + wlist += (self.Wy,) + if self.regmesh.dim > 2: + wlist += (self.Wz,) self._W = sp.vstack(wlist) return self._W From cd2360b8153a9b4f343cfdb81d084e5f36c49132 Mon Sep 17 00:00:00 2001 From: D Fournier Date: Wed, 11 May 2016 23:04:14 -0700 Subject: [PATCH 27/77] Stash the regularization between each beta --- SimPEG/Directives.py | 24 ++++++++++++-- SimPEG/Regularization.py | 67 ++++++++++++++++++++++------------------ 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/SimPEG/Directives.py b/SimPEG/Directives.py index 008cc57b..a9b74276 100644 --- a/SimPEG/Directives.py +++ b/SimPEG/Directives.py @@ -271,6 +271,14 @@ class Update_IRLS(InversionDirective): self.reg.curModel = self.invProb.curModel self.reg.gamma = self.gamma + print "Initial gamma ", np.linalg.norm(self.reg.gamma) + # Reset the regularization matrices so that it is + # recalculated with new gamma + self.reg._Wsmall = None + self.reg._Wx = None + self.reg._Wy = None + self.reg._Wz = None + self.reg._W = None if getattr(self, 'phi_d_last', None) is None: self.phi_d_last = self.invProb.phi_d @@ -294,16 +302,26 @@ class Update_IRLS(InversionDirective): # Temporarely set gamma to 1. to get raw phi_m self.reg.gamma = 1. + # Reset the regularization matrices so that it is + # recalculated for current model + self.reg._Wsmall = None + self.reg._Wx = None + self.reg._Wy = None + self.reg._Wz = None + self.reg._W = None + # Compute new model objective function value phim_new = self.reg.eval(self.invProb.curModel) # Update gamma to scale the regularization between IRLS iterations self.reg.gamma = self.phi_m_last / phim_new - # Set the weighting matrix to None so that it is recomputed next time - # it is called in the inversion + # Reset the regularization matrices again for new gamma + self.reg._Wsmall = None + self.reg._Wx = None + self.reg._Wy = None + self.reg._Wz = None self.reg._W = None - self.reg._Wsmooth = None class Update_lin_PreCond(InversionDirective): """ diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 3263ba9a..5dc5aba0 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -468,6 +468,7 @@ class Simple(BaseRegularization): @property def W(self): """Full regularization matrix W""" + print 'wtf why are we using W' if getattr(self, '_W', None) is None: wlist = (self.Wsmall, self.Wx) if self.regmesh.dim > 1: @@ -907,60 +908,66 @@ class Sparse(Simple): @property def Wsmall(self): """Regularization matrix Wsmall""" - if getattr(self, 'curModel', None) is None: - self.Rs = Utils.speye(self.regmesh.nC) + if getattr(self,'_Wsmall', None) is None: + if getattr(self, 'curModel', None) is None: + self.Rs = Utils.speye(self.regmesh.nC) - else: - f_m = self.mapping * (self.curModel - self.reg.mref) - self.rs = self.R(f_m , self.eps_p, self.norms[0]) - #print "Min rs: " + str(np.max(self.rs)) + "Max rs: " + str(np.min(self.rs)) - self.Rs = Utils.sdiag( self.rs ) + else: + f_m = self.mapping * (self.curModel - self.reg.mref) + self.rs = self.R(f_m , self.eps_p, self.norms[0]) + self.Rs = Utils.sdiag( self.rs ) - return Utils.sdiag((self.regmesh.vol*self.alpha_s*self.gamma*self.cell_weights)**0.5)*self.Rs + self._Wsmall = Utils.sdiag((self.alpha_s*self.gamma*self.cell_weights)**0.5)*self.Rs + return self._Wsmall @property def Wx(self): """Regularization matrix Wx""" + if getattr(self,'_Wx', None) is None: + if getattr(self, 'curModel', None) is None: + self.Rx = Utils.speye(self.regmesh.cellDiffxStencil.shape[0]) - if getattr(self, 'curModel', None) is None: - self.Rx = Utils.speye(self.regmesh.cellDiffxStencil.shape[0]) + else: + f_m = self.regmesh.cellDiffxStencil * (self.mapping * self.curModel) + self.rx = self.R( f_m , self.eps_q, self.norms[1]) + self.Rx = Utils.sdiag( self.rx ) - else: - f_m = self.regmesh.cellDiffxStencil * (self.mapping * self.curModel) - self.rx = self.R( f_m , self.eps_q, self.norms[1]) - self.Rx = Utils.sdiag( self.rx ) + self._Wx = Utils.sdiag(( self.alpha_x*self.gamma*(self.regmesh.aveCC2Fx*self.cell_weights))**0.5)*self.Rx*self.regmesh.cellDiffxStencil - return Utils.sdiag(( (self.regmesh.aveCC2Fx * self.regmesh.vol) *self.alpha_x*self.gamma*(self.regmesh.aveCC2Fx*self.cell_weights))**0.5)*self.Rx*self.regmesh.cellDiffxStencil + return self._Wx @property def Wy(self): """Regularization matrix Wy""" + if getattr(self,'_Wy', None) is None: + if getattr(self, 'curModel', None) is None: + self.Ry = Utils.speye(self.regmesh.cellDiffyStencil.shape[0]) - if getattr(self, 'curModel', None) is None: - self.Ry = Utils.speye(self.regmesh.cellDiffyStencil.shape[0]) + else: + f_m = self.regmesh.cellDiffyStencil * (self.mapping * self.curModel) + self.ry = self.R( f_m , self.eps_q, self.norms[2]) + self.Ry = Utils.sdiag( self.ry ) - else: - f_m = self.regmesh.cellDiffyStencil * (self.mapping * self.curModel) - self.ry = self.R( f_m , self.eps_q, self.norms[2]) - self.Ry = Utils.sdiag( self.ry ) + self._Wy = Utils.sdiag((self.alpha_y*self.gamma*(self.regmesh.aveCC2Fy*self.cell_weights))**0.5)*self.Ry*self.regmesh.cellDiffyStencil - return Utils.sdiag(((self.regmesh.aveCC2Fy * self.regmesh.vol)*self.alpha_y*self.gamma*(self.regmesh.aveCC2Fy*self.cell_weights))**0.5)*self.Ry*self.regmesh.cellDiffyStencil + return self._Wy @property def Wz(self): """Regularization matrix Wz""" + if getattr(self,'_Wz', None) is None: + if getattr(self, 'curModel', None) is None: + self.Rz = Utils.speye(self.regmesh.cellDiffzStencil.shape[0]) - if getattr(self, 'curModel', None) is None: - self.Rz = Utils.speye(self.regmesh.cellDiffzStencil.shape[0]) + else: + f_m = self.regmesh.cellDiffzStencil * (self.mapping * self.curModel) + self.rz = self.R( f_m , self.eps_q, self.norms[3]) + self.Rz = Utils.sdiag( self.rz ) - else: - f_m = self.regmesh.cellDiffzStencil * (self.mapping * self.curModel) - self.rz = self.R( f_m , self.eps_q, self.norms[3]) - self.Rz = Utils.sdiag( self.rz ) - - return Utils.sdiag(((self.regmesh.aveCC2Fz * self.regmesh.vol)*self.alpha_z*self.gamma*(self.regmesh.aveCC2Fz*self.cell_weights))**0.5)*self.Rz*self.regmesh.cellDiffzStencil + self._Wz = Utils.sdiag((self.alpha_z*self.gamma*(self.regmesh.aveCC2Fz*self.cell_weights))**0.5)*self.Rz*self.regmesh.cellDiffzStencil + return self._Wz def R(self, f_m , eps, exponent): From 3cc46131a3138096441fb4c423c5f4f21543d2b4 Mon Sep 17 00:00:00 2001 From: D Fournier Date: Thu, 12 May 2016 08:31:01 -0700 Subject: [PATCH 28/77] Temporary change ... comment out W and Wsmooth --- SimPEG/Directives.py | 6 ++--- SimPEG/Regularization.py | 52 ++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/SimPEG/Directives.py b/SimPEG/Directives.py index a9b74276..6b15be9f 100644 --- a/SimPEG/Directives.py +++ b/SimPEG/Directives.py @@ -278,7 +278,6 @@ class Update_IRLS(InversionDirective): self.reg._Wx = None self.reg._Wy = None self.reg._Wz = None - self.reg._W = None if getattr(self, 'phi_d_last', None) is None: self.phi_d_last = self.invProb.phi_d @@ -308,20 +307,19 @@ class Update_IRLS(InversionDirective): self.reg._Wx = None self.reg._Wy = None self.reg._Wz = None - self.reg._W = None # Compute new model objective function value phim_new = self.reg.eval(self.invProb.curModel) # Update gamma to scale the regularization between IRLS iterations self.reg.gamma = self.phi_m_last / phim_new - + print "New gamma ", np.linalg.norm(self.reg.gamma) + # Reset the regularization matrices again for new gamma self.reg._Wsmall = None self.reg._Wx = None self.reg._Wy = None self.reg._Wz = None - self.reg._W = None class Update_lin_PreCond(InversionDirective): """ diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 5dc5aba0..422c8f9c 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -451,32 +451,32 @@ class Simple(BaseRegularization): self._Wz = Utils.sdiag((self.alpha_z * (self.regmesh.aveCC2Fz*self.cell_weights))**0.5)*self.regmesh.cellDiffzStencil return self._Wz - @property - def Wsmooth(self): - """Full smoothness regularization matrix W""" - print 'wtf why are we using Wsmooth' - raise NotImplementedError - if getattr(self, '_Wsmooth', None) is None: - wlist = (self.Wx,) - if self.regmesh.dim > 1: - wlist += (self.Wy,) - if self.regmesh.dim > 2: - wlist += (self.Wz,) - self._Wsmooth = sp.vstack(wlist) - return self._Wsmooth - - @property - def W(self): - """Full regularization matrix W""" - print 'wtf why are we using W' - if getattr(self, '_W', None) is None: - wlist = (self.Wsmall, self.Wx) - if self.regmesh.dim > 1: - wlist += (self.Wy,) - if self.regmesh.dim > 2: - wlist += (self.Wz,) - self._W = sp.vstack(wlist) - return self._W +# @property +# def Wsmooth(self): +# """Full smoothness regularization matrix W""" +# print 'wtf why are we using Wsmooth' +# raise NotImplementedError +# if getattr(self, '_Wsmooth', None) is None: +# wlist = (self.Wx,) +# if self.regmesh.dim > 1: +# wlist += (self.Wy,) +# if self.regmesh.dim > 2: +# wlist += (self.Wz,) +# self._Wsmooth = sp.vstack(wlist) +# return self._Wsmooth +# +# @property +# def W(self): +# """Full regularization matrix W""" +# print 'wtf why are we using W' +# if getattr(self, '_W', None) is None: +# wlist = (self.Wsmall, self.Wx) +# if self.regmesh.dim > 1: +# wlist += (self.Wy,) +# if self.regmesh.dim > 2: +# wlist += (self.Wz,) +# self._W = sp.vstack(wlist) +# return self._W @Utils.timeIt From fd3bde787f3a9bc570ad8386e36eb16a7d3da1d3 Mon Sep 17 00:00:00 2001 From: D Fournier Date: Thu, 12 May 2016 14:58:16 -0700 Subject: [PATCH 29/77] Propose change to the Projected_GNCG solver. Add inner GN iterations. Nice improvement to the convergence of IRLS --- SimPEG/Directives.py | 49 ++++++++++++++++++---- SimPEG/Examples/Inversion_IRLS.py | 20 ++++----- SimPEG/Optimization.py | 70 +++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 21 deletions(-) diff --git a/SimPEG/Directives.py b/SimPEG/Directives.py index 6b15be9f..f5c25249 100644 --- a/SimPEG/Directives.py +++ b/SimPEG/Directives.py @@ -144,6 +144,35 @@ class BetaSchedule(InversionDirective): if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter self.invProb.beta /= self.coolingFactor +#class BetaSchedule_PGN_CG(InversionDirective): +# """BetaSchedule""" +# +# coolingFactor = 5. +# coolingRate = 1 +# GN_step_last = None +# GN_step_c = None +# +# def endIter(self): +# +# """ Compute the change in GN step, and proceed with cooling if below tol""" +# if self.opt.iter == 1: +# self.GN_step_last = np.linalg.norm(self.opt.xc - self.opt.x_last) +# d_GN_step = 1. +# +# else: +# self.GN_step_c = np.linalg.norm(self.opt.xc - self.opt.x_last) +# d_GN_step = self.GN_step_c / self.GN_step_last +# +# # Re-initiate last GN step +# self.GN_step_last = self.GN_step_c +# +# print "GN_step_last: ", self.GN_step_last +# print "d_GN_step: ", d_GN_step +# +# if self.opt.iter > 0 and self.opt.iter % self.coolingRate == 0: +# if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter +# self.invProb.beta /= self.coolingFactor + class TargetMisfit(InversionDirective): @property @@ -265,13 +294,16 @@ class Update_IRLS(InversionDirective): if getattr(self, 'phi_m_last', None) is not None: self.reg.curModel = self.invProb.curModel + self.reg._Wsmall = None + self.reg._Wx = None + self.reg._Wy = None + self.reg._Wz = None self.reg.gamma = 1. phim_new = self.reg.eval(self.invProb.curModel) self.gamma = self.phi_m_last / phim_new self.reg.curModel = self.invProb.curModel self.reg.gamma = self.gamma - print "Initial gamma ", np.linalg.norm(self.reg.gamma) # Reset the regularization matrices so that it is # recalculated with new gamma self.reg._Wsmall = None @@ -295,12 +327,6 @@ class Update_IRLS(InversionDirective): # Get phi_m at the end of current iteration self.phi_m_last = self.invProb.phi_m_last - # Update the model used for the IRLS weights - self.reg.curModel = self.invProb.curModel - - # Temporarely set gamma to 1. to get raw phi_m - self.reg.gamma = 1. - # Reset the regularization matrices so that it is # recalculated for current model self.reg._Wsmall = None @@ -308,13 +334,18 @@ class Update_IRLS(InversionDirective): self.reg._Wy = None self.reg._Wz = None + # Update the model used for the IRLS weights + self.reg.curModel = self.invProb.curModel + + # Temporarely set gamma to 1. to get raw phi_m + self.reg.gamma = 1. + # Compute new model objective function value phim_new = self.reg.eval(self.invProb.curModel) # Update gamma to scale the regularization between IRLS iterations self.reg.gamma = self.phi_m_last / phim_new - print "New gamma ", np.linalg.norm(self.reg.gamma) - + # Reset the regularization matrices again for new gamma self.reg._Wsmall = None self.reg._Wx = None diff --git a/SimPEG/Examples/Inversion_IRLS.py b/SimPEG/Examples/Inversion_IRLS.py index c925cce2..6551bf21 100644 --- a/SimPEG/Examples/Inversion_IRLS.py +++ b/SimPEG/Examples/Inversion_IRLS.py @@ -18,6 +18,8 @@ def run(N=200, plotIt=True): mesh = Mesh.TensorMesh([N]) m0 = np.ones(mesh.nC) * 1e-4 + mref = np.zeros(mesh.nC) + nk = 10 jk = np.linspace(1.,nk,nk) p = -2. @@ -51,12 +53,13 @@ def run(N=200, plotIt=True): wr = ( wr/np.max(wr) ) reg = Regularization.Simple(mesh) - reg.wght = wr + reg.mref = mref + reg.cell_weights = wr dmis = DataMisfit.l2_DataMisfit(survey) dmis.Wd = 1./wd - opt = Optimization.ProjectedGNCG(maxIter=30,lower=-2.,upper=2., maxIterCG= 20, tolCG = 1e-4) + opt = Optimization.ProjectedGNCG(maxIter=20,lower=-2.,upper=2., maxIterCG= 10, maxIterGN=1, tolCG = 1e-4) invProb = InvProblem.BaseInvProblem(dmis, reg, opt) invProb.curModel = m0 @@ -76,22 +79,15 @@ def run(N=200, plotIt=True): phid = invProb.phi_d reg = Regularization.Sparse(mesh) + reg.mref = mref + reg.cell_weights = wr -#============================================================================== -# fig, axes = plt.subplots(1,2,figsize=(12*1.2,4*1.2)) -# dmdx = reg.mesh.cellDiffxStencil * mrec -# plt.plot(np.sort(dmdx)) -#============================================================================== - - #reg.recModel = mrec - # reg.cell_weight = np.ones(mesh.nC) reg.mref = np.zeros(mesh.nC) reg.eps_p = 5e-2 reg.eps_q = 1e-2 reg.norms = [0., 0., 2., 2.] - reg.cell_weight = wr - opt = Optimization.ProjectedGNCG(maxIter=10 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 20, tolCG = 1e-3) + opt = Optimization.ProjectedGNCG(maxIter=10 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 10, tolCG = 1e-3) invProb = InvProblem.BaseInvProblem(dmis, reg, opt, beta = invProb.beta*2.) beta = Directives.BetaSchedule(coolingFactor=1, coolingRate=1) #betaest = Directives.BetaEstimate_ByEig() diff --git a/SimPEG/Optimization.py b/SimPEG/Optimization.py index 77704733..95f53320 100644 --- a/SimPEG/Optimization.py +++ b/SimPEG/Optimization.py @@ -893,6 +893,10 @@ class ProjectedGNCG(BFGS, Minimize, Remember): lower = -np.inf upper = np.inf + # Variables to control inner GN iterations + rdm_tol = 1e-2 # Tolerance for largest change in step (Default 1%) + maxIterGN = 3 # Maximum number of GN inner iterations + def _startup(self, x0): # ensure bound vectors are the same size as the model if type(self.lower) is not np.ndarray: @@ -938,6 +942,72 @@ class ProjectedGNCG(BFGS, Minimize, Remember): def approxHinv(self, value): self._approxHinv = value + @Utils.timeIt + def minimize(self, evalFunction, x0): + """minimize(evalFunction, x0) + + Minimizes the function (evalFunction) starting at the location x0. + + :param def evalFunction: function handle that evaluates: f, g, H = F(x) + :param numpy.ndarray x0: starting location + :rtype: numpy.ndarray + :return: x, the last iterate of the optimization algorithm + + The GN newton steps are repeated until it the maxIterGN is reached or the + relative step change falls below some tolrerance. + + """ + self.evalFunction = evalFunction + self.startup(x0) + self.printInit() + + + while True: + self.doStartIteration() + self.f, self.g, self.H = evalFunction(self.xc, return_g=True, return_H=True) + self.printIter() + if self.stoppingCriteria(): break + + # Inner GN iterations, stop on maximum number of iterations + # or on tolerance for step length change + GN_count = 0 + dm0 = None # Initial GN step length + dmc = None # Current GN step length + rdm = 1. # Relative change in step length + + while rdm > self.rdm_tol and GN_count < self.maxIterGN: + + GN_count += 1 + self.searchDirection = self.findSearchDirection() + p = self.scaleSearchDirection(self.searchDirection) + xt, passLS = self.modifySearchDirection(p) + if not passLS: + xt, caught = self.modifySearchDirectionBreak(p) + if not caught: return self.xc + + if GN_count == 1: + dm0 = np.linalg.norm(self.xc - xt) + dmc = dm0 + + else: + dmc = np.linalg.norm(self.xc - xt) + + rdm = dmc / dm0 + self.xc = xt # Update current model + + # Form system for next iteration + self.f, self.g, self.H = evalFunction(self.xc, return_g=True, return_H=True) + + print "GN iter: %i,\t dm: %8.5e,\t rdm: %8.5e"% (GN_count, dmc, rdm) + + self.doEndIteration(xt) + if self.stopNextIteration: break + + self.printDone() + self.finish() + + return self.xc + @Utils.timeIt def findSearchDirection(self): From 28d67e311205ed1ba12b24f06a891df8180eb514 Mon Sep 17 00:00:00 2001 From: seogi_macbook Date: Fri, 27 May 2016 11:26:47 -0700 Subject: [PATCH 30/77] Start of ED !! --- SimPEG/EM/Analytics/FDEM_fields.py | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 SimPEG/EM/Analytics/FDEM_fields.py diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEM_fields.py new file mode 100644 index 00000000..adf10e4e --- /dev/null +++ b/SimPEG/EM/Analytics/FDEM_fields.py @@ -0,0 +1,51 @@ +from __future__ import division +import numpy as np +from scipy.constants import mu_0, pi +from scipy.special import erf +from SimPEG import Utils + + +def ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + XYZ = Utils.asArray_N_x_Dim(XYZ, 3) + + dx = XYZ[:,0]-srcLoc[0] + dy = XYZ[:,1]-srcLoc[1] + dz = XYZ[:,2]-srcLoc[2] + + r = np.sqrt( dx**2. + dy**2. + dz**2.) + k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) + kr = k*r + + front = current * length / (4. * np.pi * sig * r**3) * np.exp(-1j*k*r) + mid = -k**2 * r**2 + 3*1j*k*r + 3 + + # Ex = front*((dx**2 / r**2)*mid + (k**2 * r**2 -1j*k*r)) + # Ey = front*(dx*dy / r**2)*mid + # Ez = front*(dx*dz / r**2)*mid + + if orientation.upper() == 'X': + Ex = front*((dx**2 / r**2)*mid + (k**2 * r**2 -1j*k*r-1.)) + Ey = front*(dx*dy / r**2)*mid + Ez = front*(dx*dz / r**2)*mid + return Ex, Ey, Ez + + elif orientation.upper() == 'Y': + # x--> y, y--> z, z-->x + Ey = front*((dy**2 / r**2)*mid + (k**2 * r**2 -1j*k*r-1.)) + Ez = front*(dy*dz / r**2)*mid + Ex = front*(dy*dx / r**2)*mid + return Ex, Ey, Ez + + elif orientation.upper() == 'Z': + # x --> z, y --> x, z --> y + Ez = front*((dz**2 / r**2)*mid + (k**2 * r**2 -1j*k*r-1.)) + Ex = front*(dz*dx / r**2)*mid + Ey = front*(dz*dy / r**2)*mid + return Ex, Ey, Ez + # return Ey, Ez, Ex + +def A_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): +def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): +def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): +def B_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + mu*H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) From 022e1f7660dd0b20e44b00ebb919a0a2cf77b036 Mon Sep 17 00:00:00 2001 From: D Fournier Date: Fri, 27 May 2016 13:11:31 -0700 Subject: [PATCH 31/77] Update IRLS directive to allow multiple GN iterations. Remove modifications to the ProjGN solver. Update IRLS example. --- SimPEG/Directives.py | 156 ++++++++++++++++-------------- SimPEG/Examples/Inversion_IRLS.py | 14 +-- SimPEG/Optimization.py | 72 +------------- SimPEG/Regularization.py | 38 ++++++-- 4 files changed, 121 insertions(+), 159 deletions(-) diff --git a/SimPEG/Directives.py b/SimPEG/Directives.py index f5c25249..b84d78d1 100644 --- a/SimPEG/Directives.py +++ b/SimPEG/Directives.py @@ -144,34 +144,6 @@ class BetaSchedule(InversionDirective): if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter self.invProb.beta /= self.coolingFactor -#class BetaSchedule_PGN_CG(InversionDirective): -# """BetaSchedule""" -# -# coolingFactor = 5. -# coolingRate = 1 -# GN_step_last = None -# GN_step_c = None -# -# def endIter(self): -# -# """ Compute the change in GN step, and proceed with cooling if below tol""" -# if self.opt.iter == 1: -# self.GN_step_last = np.linalg.norm(self.opt.xc - self.opt.x_last) -# d_GN_step = 1. -# -# else: -# self.GN_step_c = np.linalg.norm(self.opt.xc - self.opt.x_last) -# d_GN_step = self.GN_step_c / self.GN_step_last -# -# # Re-initiate last GN step -# self.GN_step_last = self.GN_step_c -# -# print "GN_step_last: ", self.GN_step_last -# print "d_GN_step: ", d_GN_step -# -# if self.opt.iter > 0 and self.opt.iter % self.coolingRate == 0: -# if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter -# self.invProb.beta /= self.coolingFactor class TargetMisfit(InversionDirective): @@ -286,10 +258,16 @@ class Update_IRLS(InversionDirective): gamma = None phi_m_last = None phi_d_last = None - - + f_old = None + f_min_change = 1e-1 + coolingRate = 3 + maxIRLSiter = 10 + + def initialize(self): - + + self.IRLSiter = 0 + # Scale the regularization for changes in norm if getattr(self, 'phi_m_last', None) is not None: @@ -310,48 +288,75 @@ class Update_IRLS(InversionDirective): self.reg._Wx = None self.reg._Wy = None self.reg._Wz = None - + if getattr(self, 'phi_d_last', None) is None: self.phi_d_last = self.invProb.phi_d + if getattr(self, 'f_last', None) is None: + self.f_old = self.invProb.evalFunction(self.reg.curModel, return_g=False, return_H=False) + print self.f_old def endIter(self): - # Cool the threshold parameter if required - if getattr(self, 'factor', None) is not None: - eps = self.reg.eps / self.factor + + + # Only update after GN iterations + if self.opt.iter % self.coolingRate == 0: + + self.IRLSiter += 1 - if getattr(self, 'eps_min', None) is not None: - self.reg.eps = np.max([self.eps_min,eps]) - else: - self.reg.eps = eps - - # Get phi_m at the end of current iteration - self.phi_m_last = self.invProb.phi_m_last - - # Reset the regularization matrices so that it is - # recalculated for current model - self.reg._Wsmall = None - self.reg._Wx = None - self.reg._Wy = None - self.reg._Wz = None - - # Update the model used for the IRLS weights - self.reg.curModel = self.invProb.curModel - - # Temporarely set gamma to 1. to get raw phi_m - self.reg.gamma = 1. - - # Compute new model objective function value - phim_new = self.reg.eval(self.invProb.curModel) - - # Update gamma to scale the regularization between IRLS iterations - self.reg.gamma = self.phi_m_last / phim_new - - # Reset the regularization matrices again for new gamma - self.reg._Wsmall = None - self.reg._Wx = None - self.reg._Wy = None - self.reg._Wz = None + self.f_change = np.abs(self.f_old - self.opt.f_last) / self.f_old + + print "Function decrease" + str(self.f_change) + + # Check for maximum number of IRLS cycles + if self.IRLSiter == self.maxIRLSiter: + self.opt.stopNextIteration = True + return + + # Check if the function has changed enough + if self.f_change < self.f_min_change: + self.opt.stopNextIteration = True + return + else: + self.f_old = self.opt.f_last + + # Cool the threshold parameter if required + if getattr(self, 'factor', None) is not None: + eps = self.reg.eps / self.factor + + if getattr(self, 'eps_min', None) is not None: + self.reg.eps = np.max([self.eps_min,eps]) + else: + self.reg.eps = eps + + # Get phi_m at the end of current iteration + self.phi_m_last = self.invProb.phi_m_last + + # Reset the regularization matrices so that it is + # recalculated for current model + self.reg._Wsmall = None + self.reg._Wx = None + self.reg._Wy = None + self.reg._Wz = None + + # Update the model used for the IRLS weights + self.reg.curModel = self.invProb.curModel + + # Temporarely set gamma to 1. to get raw phi_m + self.reg.gamma = 1. + + # Compute new model objective function value + phim_new = self.reg.eval(self.invProb.curModel) + + # Update gamma to scale the regularization between IRLS iterations + self.reg.gamma = self.phi_m_last / phim_new + + # Reset the regularization matrices again for new gamma + self.reg._Wsmall = None + self.reg._Wx = None + self.reg._Wy = None + self.reg._Wz = None + # Compute the change in class Update_lin_PreCond(InversionDirective): """ Create a Jacobi preconditioner for the linear problem @@ -411,11 +416,14 @@ class Scale_Beta(InversionDirective): update is done only if the misfit is outside some threshold bounds. """ tol = 0.05 - + coolingRate=5 + def endIter(self): - - # Check if misfit is within the tolerance, otherwise adjust beta - val = self.invProb.phi_d / (self.survey.nD*0.5) - - if np.abs(1.-val) > self.tol: - self.invProb.beta = self.invProb.beta * self.survey.nD*0.5 / self.invProb.phi_d + + # Only update after GN iterations + if self.opt.iter % self.coolingRate == 0: + # Check if misfit is within the tolerance, otherwise adjust beta + val = self.invProb.phi_d / (self.survey.nD*0.5) + + if np.abs(1.-val) > self.tol: + self.invProb.beta = self.invProb.beta * self.survey.nD*0.5 / self.invProb.phi_d diff --git a/SimPEG/Examples/Inversion_IRLS.py b/SimPEG/Examples/Inversion_IRLS.py index 6551bf21..d1da048f 100644 --- a/SimPEG/Examples/Inversion_IRLS.py +++ b/SimPEG/Examples/Inversion_IRLS.py @@ -20,7 +20,7 @@ def run(N=200, plotIt=True): m0 = np.ones(mesh.nC) * 1e-4 mref = np.zeros(mesh.nC) - nk = 10 + nk = 15 jk = np.linspace(1.,nk,nk) p = -2. q = 1. @@ -59,7 +59,7 @@ def run(N=200, plotIt=True): dmis = DataMisfit.l2_DataMisfit(survey) dmis.Wd = 1./wd - opt = Optimization.ProjectedGNCG(maxIter=20,lower=-2.,upper=2., maxIterCG= 10, maxIterGN=1, tolCG = 1e-4) + opt = Optimization.ProjectedGNCG(maxIter=20,lower=-2.,upper=2., maxIterCG= 10, tolCG = 1e-4) invProb = InvProblem.BaseInvProblem(dmis, reg, opt) invProb.curModel = m0 @@ -83,18 +83,18 @@ def run(N=200, plotIt=True): reg.cell_weights = wr reg.mref = np.zeros(mesh.nC) - reg.eps_p = 5e-2 + reg.eps_p = 1e-3 reg.eps_q = 1e-2 reg.norms = [0., 0., 2., 2.] - opt = Optimization.ProjectedGNCG(maxIter=10 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 10, tolCG = 1e-3) + opt = Optimization.ProjectedGNCG(maxIter=100 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 10, tolCG = 1e-3) invProb = InvProblem.BaseInvProblem(dmis, reg, opt, beta = invProb.beta*2.) beta = Directives.BetaSchedule(coolingFactor=1, coolingRate=1) - #betaest = Directives.BetaEstimate_ByEig() + update_beta = Directives.Scale_Beta(tol = 0.05, coolingRate=5) target = Directives.TargetMisfit() - IRLS =Directives.Update_IRLS( phi_m_last = phim, phi_d_last = phid ) + IRLS = Directives.Update_IRLS( phi_m_last = phim, phi_d_last = phid, coolingRate=5 ) - inv = Inversion.BaseInversion(invProb, directiveList=[beta,IRLS]) + inv = Inversion.BaseInversion(invProb, directiveList=[beta,IRLS,update_beta]) m0 = mrec diff --git a/SimPEG/Optimization.py b/SimPEG/Optimization.py index 95f53320..05214dd5 100644 --- a/SimPEG/Optimization.py +++ b/SimPEG/Optimization.py @@ -893,10 +893,6 @@ class ProjectedGNCG(BFGS, Minimize, Remember): lower = -np.inf upper = np.inf - # Variables to control inner GN iterations - rdm_tol = 1e-2 # Tolerance for largest change in step (Default 1%) - maxIterGN = 3 # Maximum number of GN inner iterations - def _startup(self, x0): # ensure bound vectors are the same size as the model if type(self.lower) is not np.ndarray: @@ -942,72 +938,6 @@ class ProjectedGNCG(BFGS, Minimize, Remember): def approxHinv(self, value): self._approxHinv = value - @Utils.timeIt - def minimize(self, evalFunction, x0): - """minimize(evalFunction, x0) - - Minimizes the function (evalFunction) starting at the location x0. - - :param def evalFunction: function handle that evaluates: f, g, H = F(x) - :param numpy.ndarray x0: starting location - :rtype: numpy.ndarray - :return: x, the last iterate of the optimization algorithm - - The GN newton steps are repeated until it the maxIterGN is reached or the - relative step change falls below some tolrerance. - - """ - self.evalFunction = evalFunction - self.startup(x0) - self.printInit() - - - while True: - self.doStartIteration() - self.f, self.g, self.H = evalFunction(self.xc, return_g=True, return_H=True) - self.printIter() - if self.stoppingCriteria(): break - - # Inner GN iterations, stop on maximum number of iterations - # or on tolerance for step length change - GN_count = 0 - dm0 = None # Initial GN step length - dmc = None # Current GN step length - rdm = 1. # Relative change in step length - - while rdm > self.rdm_tol and GN_count < self.maxIterGN: - - GN_count += 1 - self.searchDirection = self.findSearchDirection() - p = self.scaleSearchDirection(self.searchDirection) - xt, passLS = self.modifySearchDirection(p) - if not passLS: - xt, caught = self.modifySearchDirectionBreak(p) - if not caught: return self.xc - - if GN_count == 1: - dm0 = np.linalg.norm(self.xc - xt) - dmc = dm0 - - else: - dmc = np.linalg.norm(self.xc - xt) - - rdm = dmc / dm0 - self.xc = xt # Update current model - - # Form system for next iteration - self.f, self.g, self.H = evalFunction(self.xc, return_g=True, return_H=True) - - print "GN iter: %i,\t dm: %8.5e,\t rdm: %8.5e"% (GN_count, dmc, rdm) - - self.doEndIteration(xt) - if self.stopNextIteration: break - - self.printDone() - self.finish() - - return self.xc - @Utils.timeIt def findSearchDirection(self): @@ -1078,4 +1008,4 @@ class ProjectedGNCG(BFGS, Minimize, Remember): indx = ((self.xc<=self.lower) & (delx < 0)) | ((self.xc>=self.upper) & (delx > 0)) delx[indx] = 0. - return delx + return delx \ No newline at end of file diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index 422c8f9c..c3b1c9e5 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -890,14 +890,37 @@ class Tikhonov(Simple): class Sparse(Simple): - + """ + The regularization is: + + .. math:: + + R(m) = \\frac{1}{2}\mathbf{(m-m_\\text{ref})^\\top W^\\top R^\\top R W(m-m_\\text{ref})} + + where the IRLS weight + + .. math:: + + R = \eta TO FINISH LATER!!! + + So the derivative is straight forward: + + .. math:: + + R(m) = \mathbf{W^\\top R^\\top R W (m-m_\\text{ref})} + + The IRLS weights are recomputed after each beta solves. + It is strongly recommended to do a few Gauss-Newton iterations + before updating. + """ + # set default values - eps_p = 1e-1 - eps_q = 1e-1 - curModel = None # use a model to compute the weights - gamma = 1. - norms = [0., 2., 2., 2.] - cell_weights = 1. + eps_p = 1e-1 # Threshold value for the model norm + eps_q = 1e-1 # Threshold value for the model gradient norm + curModel = None # Requires model to compute the weights + gamma = 1. # Model norm scaling to smooth out convergence + norms = [0., 2., 2., 2.] # Values for norm on (m, dmdx, dmdy, dmdz) + cell_weights = 1. # Consider overwriting with sensitivity weights def __init__(self, mesh, mapping=None, indActive=None, **kwargs): Simple.__init__(self, mesh, mapping=mapping, indActive=indActive, **kwargs) @@ -971,6 +994,7 @@ class Sparse(Simple): def R(self, f_m , eps, exponent): + # Eta scaling is important for mix-norms...do not mess with it eta = (eps**(1.-exponent/2.))**0.5 r = eta / (f_m**2.+ eps**2.)**((1.-exponent/2.)/2.) From 1960b52dfd58a9fc81c225b5ad005d98ee9ca74a Mon Sep 17 00:00:00 2001 From: micmitch Date: Fri, 27 May 2016 14:56:48 -0700 Subject: [PATCH 32/77] First stab at analytic functions for the fields from a harmonic electric dipole source. Not sure about the exception that I try to throw if multiple frequencies and multiple evaluation locations are both specified. --- SimPEG/EM/Analytics/FDEM_fields.py | 119 +++++++++++++++++++++++++---- 1 file changed, 106 insertions(+), 13 deletions(-) diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEM_fields.py index adf10e4e..abf956e8 100644 --- a/SimPEG/EM/Analytics/FDEM_fields.py +++ b/SimPEG/EM/Analytics/FDEM_fields.py @@ -5,24 +5,27 @@ from scipy.special import erf from SimPEG import Utils -def ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): +def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + epsilon = 8.854187817*(10.**-12) + omega = 2.*np.pi*f + XYZ = Utils.asArray_N_x_Dim(XYZ, 3) + # Check + if XYZ.shape[0] > 1 & f.length > 1 + except: + print "I/O type error: For multiple field locations only a single frequency can be specified." dx = XYZ[:,0]-srcLoc[0] dy = XYZ[:,1]-srcLoc[1] dz = XYZ[:,2]-srcLoc[2] r = np.sqrt( dx**2. + dy**2. + dz**2.) - k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) - kr = k*r + # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) + k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) - front = current * length / (4. * np.pi * sig * r**3) * np.exp(-1j*k*r) + front = current * length / (4.*np.pi*sig* r**3) * np.exp(-1j*k*r) mid = -k**2 * r**2 + 3*1j*k*r + 3 - # Ex = front*((dx**2 / r**2)*mid + (k**2 * r**2 -1j*k*r)) - # Ey = front*(dx*dy / r**2)*mid - # Ez = front*(dx*dz / r**2)*mid - if orientation.upper() == 'X': Ex = front*((dx**2 / r**2)*mid + (k**2 * r**2 -1j*k*r-1.)) Ey = front*(dx*dy / r**2)*mid @@ -42,10 +45,100 @@ def ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orienta Ex = front*(dz*dx / r**2)*mid Ey = front*(dz*dy / r**2)*mid return Ex, Ey, Ez - # return Ey, Ez, Ex + +def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + Ex, Ey, Ez = E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) + Jx = sig*Ex + Jy = sig*Ey + Jz = sig*Ez + return Jx, Jy, Jz + + +def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + epsilon = 8.854187817*(10.**-12) + omega = 2.*np.pi*f + + XYZ = Utils.asArray_N_x_Dim(XYZ, 3) + # Check + if XYZ.shape[0] > 1 & f.length > 1 + except: + print "I/O type error: For multiple field locations only a single frequency can be specified." + + dx = XYZ[:,0]-srcLoc[0] + dy = XYZ[:,1]-srcLoc[1] + dz = XYZ[:,2]-srcLoc[2] + + r = np.sqrt( dx**2. + dy**2. + dz**2.) + # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) + k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + + front = current * length / (4.*np.pi* r**2) * (-1j*k*r + 1) * np.exp(-1j*k*r) + + if orientation.upper() == 'X': + Hy = front*(-dz / r) + Hz = front*(dy / r) + Hx = np.zeros_like(Hy) + return Hx, Hy, Hz + + elif orientation.upper() == 'Y': + Hx = front*(dz / r) + Hz = front*(-dx / r) + Hy = np.zeros_like(Hx) + return Hx, Hy, Hz + + elif orientation.upper() == 'Z': + Hx = front*(-dy / r) + Hy = front*(dx / r) + Hz = np.zeros_like(Hx) + return Hx, Hy, Hz + + +def B_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + Hx, Hy, Hz = H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) + Bx = mu*Hx + By = mu*Hy + Bz = mu*Hz + return Bx, By, Bz + def A_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): -def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): -def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): -def B_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - mu*H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) + epsilon = 8.854187817*(10.**-12) + omega = 2.*np.pi*f + + XYZ = Utils.asArray_N_x_Dim(XYZ, 3) + # Check + if XYZ.shape[0] > 1 & f.length > 1 + except: + print "I/O type error: For multiple field locations only a single frequency can be specified." + + dx = XYZ[:,0]-srcLoc[0] + dy = XYZ[:,1]-srcLoc[1] + dz = XYZ[:,2]-srcLoc[2] + + r = np.sqrt( dx**2. + dy**2. + dz**2.) + k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + + front = current * length / (4.*np.pi*r) + + if orientation.upper() == 'X': + Ax = front*np.exp(-1j*k*r) + Ay = np.zeros_like(Ax) + Az = np.zeros_like(Ax) + return Ax, Ay, Az + + elif orientation.upper() == 'Y': + Ay = front*np.exp(-1j*k*r) + Ax = np.zeros_like(Ay) + Az = np.zeros_like(Ay) + return Ax, Ay, Az + + elif orientation.upper() == 'Z': + Az = front*np.exp(-1j*k*r) + Ax = np.zeros_like(Ay) + Ay = np.zeros_like(Ay) + return Ax, Ay, Az + + + + + From 3b4bec9c0b40b0ce949cea8422adef1f29b81bb7 Mon Sep 17 00:00:00 2001 From: D Fournier Date: Sat, 28 May 2016 11:27:09 -0700 Subject: [PATCH 33/77] Refactor IRLS iterations, full solves from l2->lp Adapt Example --- SimPEG/Directives.py | 206 ++++++++++++++++++------------ SimPEG/Examples/Inversion_IRLS.py | 66 +++++----- SimPEG/Regularization.py | 1 + 3 files changed, 158 insertions(+), 115 deletions(-) diff --git a/SimPEG/Directives.py b/SimPEG/Directives.py index b84d78d1..8727d925 100644 --- a/SimPEG/Directives.py +++ b/SimPEG/Directives.py @@ -144,7 +144,7 @@ class BetaSchedule(InversionDirective): if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter self.invProb.beta /= self.coolingFactor - + class TargetMisfit(InversionDirective): @property @@ -238,12 +238,6 @@ class SaveOutputDictEveryIteration(_SaveEveryIteration): # Save the file as a npz np.savez('{:03d}-{:s}'.format(self.opt.iter,self.fileName), iter=self.opt.iter, beta=self.invProb.beta, phi_d=self.invProb.phi_d, phi_m=self.invProb.phi_m, phi_ms=phi_ms, phi_mx=phi_mx, phi_my=phi_my, phi_mz=phi_mz,f=self.opt.f, m=self.invProb.curModel,dpred=self.invProb.dpred) - -# class UpdateReferenceModel(Parameter): - -# mref0 = None - -# def nextIter(self): # mref = getattr(self, 'm_prev', None) # if mref is None: # if self.debug: print 'UpdateReferenceModel is using mref0' @@ -254,109 +248,165 @@ class SaveOutputDictEveryIteration(_SaveEveryIteration): class Update_IRLS(InversionDirective): eps_min = None + eps_p = None + eps_q = None + norms = [2.,2.,2.,2.] factor = None gamma = None phi_m_last = None phi_d_last = None f_old = None - f_min_change = 1e-1 - coolingRate = 3 - maxIRLSiter = 10 - + f_min_change = 1e-2 + beta_tol = 5e-2 + # Solving parameter for IRLS (mode:2) + IRLSiter = 0 + minGNiter = 6 + maxIRLSiter = 10 + iterStart = 0 + + # Beta schedule + coolingFactor = 2. + coolingRate = 1 + + mode = 1 + + @property + def target(self): + if getattr(self, '_target', None) is None: + self._target = self.survey.nD + return self._target + @target.setter + def target(self, val): + self._target = val + def initialize(self): - - self.IRLSiter = 0 - - # Scale the regularization for changes in norm - if getattr(self, 'phi_m_last', None) is not None: - self.reg.curModel = self.invProb.curModel - self.reg._Wsmall = None - self.reg._Wx = None - self.reg._Wy = None - self.reg._Wz = None - self.reg.gamma = 1. - phim_new = self.reg.eval(self.invProb.curModel) - self.gamma = self.phi_m_last / phim_new + if self.mode == 1: + self.reg.norms = [2., 2., 2., 2.] +# # Scale the regularization for changes in norm +# if getattr(self, 'phi_m_last', None) is not None: +# +# self.reg.curModel = self.invProb.curModel +# self.reg._Wsmall = None +# self.reg._Wx = None +# self.reg._Wy = None +# self.reg._Wz = None +# self.reg.gamma = 1. +# phim_new = self.reg.eval(self.invProb.curModel) +# self.gamma = self.phi_m_last / phim_new +# +# self.reg.curModel = self.invProb.curModel +# self.reg.gamma = self.gamma +# # Reset the regularization matrices so that it is +# # recalculated with new gamma +# self.reg._Wsmall = None +# self.reg._Wx = None +# self.reg._Wy = None +# self.reg._Wz = None - self.reg.curModel = self.invProb.curModel - self.reg.gamma = self.gamma - # Reset the regularization matrices so that it is - # recalculated with new gamma - self.reg._Wsmall = None - self.reg._Wx = None - self.reg._Wy = None - self.reg._Wz = None - - if getattr(self, 'phi_d_last', None) is None: - self.phi_d_last = self.invProb.phi_d - - if getattr(self, 'f_last', None) is None: - self.f_old = self.invProb.evalFunction(self.reg.curModel, return_g=False, return_H=False) - print self.f_old - def endIter(self): - - - # Only update after GN iterations - if self.opt.iter % self.coolingRate == 0: +# if getattr(self, 'phi_d_last', None) is None: +# self.phi_d_last = self.invProb.phi_d +# +# if getattr(self, 'f_last', None) is None: +# self.f_old = self.invProb.evalFunction(self.reg.curModel, return_g=False, return_H=False) +# print self.f_old + def endIter(self): + + # After reaching target misfit with l2-norm, switch to IRLS (mode:2) + if self.invProb.phi_d < self.target and self.mode == 1: + print "Convergence with smooth l2-norm regularization: Start IRLS steps..." + + self.mode = 2 + print self.eps_p, self.eps_q, self.norms + self.reg.eps_p = self.eps_p + self.reg.eps_q = self.eps_q + self.reg.norms = self.norms + self.coolingFactor = 1. + self.coolingRate = 1 + self.iterStart = self.opt.iter + self.phi_d_last = self.invProb.phi_d + self.phi_m_last = self.invProb.phi_m_last + + self.reg.l2model = self.invProb.curModel + self.reg.curModel = self.invProb.curModel + + if getattr(self, 'f_old', None) is None: + self.f_old = self.reg.eval(self.invProb.curModel)#self.invProb.evalFunction(self.invProb.curModel, return_g=False, return_H=False) + + if self.opt.iter > 0 and self.opt.iter % self.coolingRate == 0: + if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter + self.invProb.beta /= self.coolingFactor + + + # Only update after GN iterations + if (self.opt.iter-self.iterStart) % self.minGNiter == 0 and self.mode==2: + self.IRLSiter += 1 - self.f_change = np.abs(self.f_old - self.opt.f_last) / self.f_old - - print "Function decrease" + str(self.f_change) - + phim_new = self.reg.eval(self.invProb.curModel) + self.f_change = np.abs(self.f_old - phim_new) / self.f_old + + print "Regularization decrease: %6.3e" % (self.f_change) + # Check for maximum number of IRLS cycles if self.IRLSiter == self.maxIRLSiter: + print "Reach maximum number of IRLS cycles: %i" % self.maxIRLSiter self.opt.stopNextIteration = True return - + # Check if the function has changed enough - if self.f_change < self.f_min_change: + if self.f_change < self.f_min_change and self.IRLSiter > 1: + print "Minimum decrease in regularization. End of IRLS" self.opt.stopNextIteration = True - return - else: - self.f_old = self.opt.f_last - + return + else: + self.f_old = phim_new + # Cool the threshold parameter if required if getattr(self, 'factor', None) is not None: eps = self.reg.eps / self.factor - + if getattr(self, 'eps_min', None) is not None: self.reg.eps = np.max([self.eps_min,eps]) else: self.reg.eps = eps - + # Get phi_m at the end of current iteration self.phi_m_last = self.invProb.phi_m_last - + # Reset the regularization matrices so that it is # recalculated for current model self.reg._Wsmall = None self.reg._Wx = None self.reg._Wy = None self.reg._Wz = None - + # Update the model used for the IRLS weights self.reg.curModel = self.invProb.curModel - + # Temporarely set gamma to 1. to get raw phi_m self.reg.gamma = 1. - + # Compute new model objective function value phim_new = self.reg.eval(self.invProb.curModel) - + # Update gamma to scale the regularization between IRLS iterations self.reg.gamma = self.phi_m_last / phim_new - + # Reset the regularization matrices again for new gamma self.reg._Wsmall = None self.reg._Wx = None self.reg._Wy = None self.reg._Wz = None - # Compute the change in + # Check if misfit is within the tolerance, otherwise adjust beta + val = self.invProb.phi_d / (self.survey.nD*0.5) + + if np.abs(1.-val) > self.beta_tol: + self.invProb.beta = self.invProb.beta * self.survey.nD*0.5 / self.invProb.phi_d + class Update_lin_PreCond(InversionDirective): """ Create a Jacobi preconditioner for the linear problem @@ -409,21 +459,15 @@ class Update_Wj(InversionDirective): self.reg.wght = JtJdiag -class Scale_Beta(InversionDirective): - """ - Instead of a linear cooling schedule, beta is allowed to change based - on the ratio between the target misfit and the current data misfit. The - update is done only if the misfit is outside some threshold bounds. - """ - tol = 0.05 - coolingRate=5 - - def endIter(self): - - # Only update after GN iterations - if self.opt.iter % self.coolingRate == 0: - # Check if misfit is within the tolerance, otherwise adjust beta - val = self.invProb.phi_d / (self.survey.nD*0.5) - - if np.abs(1.-val) > self.tol: - self.invProb.beta = self.invProb.beta * self.survey.nD*0.5 / self.invProb.phi_d +#class Scale_Beta(InversionDirective): +# """ +# Instead of a linear cooling schedule, beta is allowed to change based +# on the ratio between the target misfit and the current data misfit. The +# update is done only if the misfit is outside some threshold bounds. +# """ +# tol = 0.05 +# coolingRate=5 +# +# def endIter(self): +# +# diff --git a/SimPEG/Examples/Inversion_IRLS.py b/SimPEG/Examples/Inversion_IRLS.py index d1da048f..5c1a8770 100644 --- a/SimPEG/Examples/Inversion_IRLS.py +++ b/SimPEG/Examples/Inversion_IRLS.py @@ -52,51 +52,49 @@ def run(N=200, plotIt=True): wr = np.sum(prob.G**2.,axis=0)**0.5 wr = ( wr/np.max(wr) ) - reg = Regularization.Simple(mesh) - reg.mref = mref - reg.cell_weights = wr - +# reg = Regularization.Simple(mesh) +# reg.mref = mref +# reg.cell_weights = wr +# dmis = DataMisfit.l2_DataMisfit(survey) dmis.Wd = 1./wd - - opt = Optimization.ProjectedGNCG(maxIter=20,lower=-2.,upper=2., maxIterCG= 10, tolCG = 1e-4) - invProb = InvProblem.BaseInvProblem(dmis, reg, opt) - invProb.curModel = m0 - - beta = Directives.BetaSchedule(coolingFactor=2, coolingRate=1) - target = Directives.TargetMisfit() - +# +# opt = Optimization.ProjectedGNCG(maxIter=20,lower=-2.,upper=2., maxIterCG= 10, tolCG = 1e-4) +# invProb = InvProblem.BaseInvProblem(dmis, reg, opt) +# invProb.curModel = m0 +# +# beta = Directives.BetaSchedule(coolingFactor=2, coolingRate=1) +# target = Directives.TargetMisfit() +# betaest = Directives.BetaEstimate_ByEig() - inv = Inversion.BaseInversion(invProb, directiveList=[beta, betaest, target]) - - - mrec = inv.run(m0) - ml2 = mrec - print "Final misfit:" + str(invProb.dmisfit.eval(mrec)) - - # Switch regularization to sparse - phim = invProb.phi_m_last - phid = invProb.phi_d +# inv = Inversion.BaseInversion(invProb, directiveList=[beta, betaest, target]) +# +# +# mrec = inv.run(m0) +# ml2 = mrec +# print "Final misfit:" + str(invProb.dmisfit.eval(mrec)) +# +# # Switch regularization to sparse +# phim = invProb.phi_m_last +# phid = invProb.phi_d reg = Regularization.Sparse(mesh) reg.mref = mref reg.cell_weights = wr reg.mref = np.zeros(mesh.nC) - reg.eps_p = 1e-3 - reg.eps_q = 1e-2 - reg.norms = [0., 0., 2., 2.] + eps_p = 1e-3 + eps_q = 1e-2 + norms = [0., 0., 2., 2.] opt = Optimization.ProjectedGNCG(maxIter=100 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 10, tolCG = 1e-3) - invProb = InvProblem.BaseInvProblem(dmis, reg, opt, beta = invProb.beta*2.) - beta = Directives.BetaSchedule(coolingFactor=1, coolingRate=1) - update_beta = Directives.Scale_Beta(tol = 0.05, coolingRate=5) - target = Directives.TargetMisfit() - IRLS = Directives.Update_IRLS( phi_m_last = phim, phi_d_last = phid, coolingRate=5 ) + invProb = InvProblem.BaseInvProblem(dmis, reg, opt) + #beta = Directives.BetaSchedule(coolingFactor=1, coolingRate=1) + #update_beta = Directives.Scale_Beta(tol = 0.05, coolingRate=5) +# target = Directives.TargetMisfit() + IRLS = Directives.Update_IRLS( norms=norms, eps_p=eps_p, eps_q=eps_q) - inv = Inversion.BaseInversion(invProb, directiveList=[beta,IRLS,update_beta]) - - m0 = mrec + inv = Inversion.BaseInversion(invProb, directiveList=[IRLS,betaest]) # Run inversion mrec = inv.run(m0) @@ -113,7 +111,7 @@ def run(N=200, plotIt=True): axes[0].set_title('Columns of matrix G') axes[1].plot(mesh.vectorCCx, mtrue, 'b-') - axes[1].plot(mesh.vectorCCx, ml2, 'r-') + axes[1].plot(mesh.vectorCCx, reg.l2model, 'r-') #axes[1].legend(('True Model', 'Recovered Model')) axes[1].set_ylim(-1.0,1.25) diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index c3b1c9e5..3304022a 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -918,6 +918,7 @@ class Sparse(Simple): eps_p = 1e-1 # Threshold value for the model norm eps_q = 1e-1 # Threshold value for the model gradient norm curModel = None # Requires model to compute the weights + l2model = None gamma = 1. # Model norm scaling to smooth out convergence norms = [0., 2., 2., 2.] # Values for norm on (m, dmdx, dmdy, dmdz) cell_weights = 1. # Consider overwriting with sensitivity weights From e476bf0059b3c6f8e75665bffa1e699b586919a1 Mon Sep 17 00:00:00 2001 From: D Fournier Date: Sun, 29 May 2016 14:09:29 -0700 Subject: [PATCH 34/77] Cleanup Sparse Reg and Directives --- SimPEG/Directives.py | 71 +++++++------------------------ SimPEG/Examples/Inversion_IRLS.py | 16 +++---- 2 files changed, 23 insertions(+), 64 deletions(-) diff --git a/SimPEG/Directives.py b/SimPEG/Directives.py index 8727d925..98770666 100644 --- a/SimPEG/Directives.py +++ b/SimPEG/Directives.py @@ -258,66 +258,39 @@ class Update_IRLS(InversionDirective): f_old = None f_min_change = 1e-2 beta_tol = 5e-2 - + # Solving parameter for IRLS (mode:2) IRLSiter = 0 - minGNiter = 6 + minGNiter = 5 maxIRLSiter = 10 iterStart = 0 - + # Beta schedule coolingFactor = 2. coolingRate = 1 - + mode = 1 - + @property def target(self): if getattr(self, '_target', None) is None: - self._target = self.survey.nD + self._target = self.survey.nD*0.5 return self._target @target.setter def target(self, val): self._target = val - + def initialize(self): if self.mode == 1: self.reg.norms = [2., 2., 2., 2.] -# # Scale the regularization for changes in norm -# if getattr(self, 'phi_m_last', None) is not None: -# -# self.reg.curModel = self.invProb.curModel -# self.reg._Wsmall = None -# self.reg._Wx = None -# self.reg._Wy = None -# self.reg._Wz = None -# self.reg.gamma = 1. -# phim_new = self.reg.eval(self.invProb.curModel) -# self.gamma = self.phi_m_last / phim_new -# -# self.reg.curModel = self.invProb.curModel -# self.reg.gamma = self.gamma -# # Reset the regularization matrices so that it is -# # recalculated with new gamma -# self.reg._Wsmall = None -# self.reg._Wx = None -# self.reg._Wy = None -# self.reg._Wz = None -# if getattr(self, 'phi_d_last', None) is None: -# self.phi_d_last = self.invProb.phi_d -# -# if getattr(self, 'f_last', None) is None: -# self.f_old = self.invProb.evalFunction(self.reg.curModel, return_g=False, return_H=False) -# print self.f_old - def endIter(self): # After reaching target misfit with l2-norm, switch to IRLS (mode:2) if self.invProb.phi_d < self.target and self.mode == 1: print "Convergence with smooth l2-norm regularization: Start IRLS steps..." - + self.mode = 2 print self.eps_p, self.eps_q, self.norms self.reg.eps_p = self.eps_p @@ -328,17 +301,18 @@ class Update_IRLS(InversionDirective): self.iterStart = self.opt.iter self.phi_d_last = self.invProb.phi_d self.phi_m_last = self.invProb.phi_m_last - + self.reg.l2model = self.invProb.curModel self.reg.curModel = self.invProb.curModel - + if getattr(self, 'f_old', None) is None: self.f_old = self.reg.eval(self.invProb.curModel)#self.invProb.evalFunction(self.invProb.curModel, return_g=False, return_H=False) - + + # Beta Schedule if self.opt.iter > 0 and self.opt.iter % self.coolingRate == 0: if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter self.invProb.beta /= self.coolingFactor - + # Only update after GN iterations if (self.opt.iter-self.iterStart) % self.minGNiter == 0 and self.mode==2: @@ -401,12 +375,12 @@ class Update_IRLS(InversionDirective): self.reg._Wy = None self.reg._Wz = None - # Check if misfit is within the tolerance, otherwise adjust beta + # Check if misfit is within the tolerance, otherwise scale beta val = self.invProb.phi_d / (self.survey.nD*0.5) - + if np.abs(1.-val) > self.beta_tol: self.invProb.beta = self.invProb.beta * self.survey.nD*0.5 / self.invProb.phi_d - + class Update_lin_PreCond(InversionDirective): """ Create a Jacobi preconditioner for the linear problem @@ -458,16 +432,3 @@ class Update_Wj(InversionDirective): JtJdiag = JtJdiag / max(JtJdiag) self.reg.wght = JtJdiag - -#class Scale_Beta(InversionDirective): -# """ -# Instead of a linear cooling schedule, beta is allowed to change based -# on the ratio between the target misfit and the current data misfit. The -# update is done only if the misfit is outside some threshold bounds. -# """ -# tol = 0.05 -# coolingRate=5 -# -# def endIter(self): -# -# diff --git a/SimPEG/Examples/Inversion_IRLS.py b/SimPEG/Examples/Inversion_IRLS.py index 5c1a8770..afd90525 100644 --- a/SimPEG/Examples/Inversion_IRLS.py +++ b/SimPEG/Examples/Inversion_IRLS.py @@ -1,7 +1,7 @@ from SimPEG import * -def run(N=200, plotIt=True): +def run(N=100, plotIt=True): """ Inversion: Linear Problem ========================= @@ -19,8 +19,8 @@ def run(N=200, plotIt=True): m0 = np.ones(mesh.nC) * 1e-4 mref = np.zeros(mesh.nC) - - nk = 15 + + nk = 10 jk = np.linspace(1.,nk,nk) p = -2. q = 1. @@ -83,18 +83,16 @@ def run(N=200, plotIt=True): reg.cell_weights = wr reg.mref = np.zeros(mesh.nC) - eps_p = 1e-3 - eps_q = 1e-2 + eps_p = 5e-2 + eps_q = 5e-2 norms = [0., 0., 2., 2.] opt = Optimization.ProjectedGNCG(maxIter=100 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 10, tolCG = 1e-3) invProb = InvProblem.BaseInvProblem(dmis, reg, opt) - #beta = Directives.BetaSchedule(coolingFactor=1, coolingRate=1) - #update_beta = Directives.Scale_Beta(tol = 0.05, coolingRate=5) -# target = Directives.TargetMisfit() + update_Jacobi = Directives.Update_lin_PreCond() IRLS = Directives.Update_IRLS( norms=norms, eps_p=eps_p, eps_q=eps_q) - inv = Inversion.BaseInversion(invProb, directiveList=[IRLS,betaest]) + inv = Inversion.BaseInversion(invProb, directiveList=[IRLS,betaest,update_Jacobi]) # Run inversion mrec = inv.run(m0) From 4844b7230aa9a8a819d255bb4c8a3e650227fac7 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 17:05:42 -0700 Subject: [PATCH 35/77] TOC updates for docs index. --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index 0a812ea6..1293c21a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -49,6 +49,7 @@ Examples .. toctree:: :maxdepth: 2 + api_Examples Packages From feba3849114e0e265aa0ca1abdfd3ab8e7f591ef Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 17:08:11 -0700 Subject: [PATCH 36/77] Add solver parameter to the Casing example. --- SimPEG/Examples/EM_Schenkel_Morrison_Casing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimPEG/Examples/EM_Schenkel_Morrison_Casing.py b/SimPEG/Examples/EM_Schenkel_Morrison_Casing.py index 930b452a..c4306eb1 100644 --- a/SimPEG/Examples/EM_Schenkel_Morrison_Casing.py +++ b/SimPEG/Examples/EM_Schenkel_Morrison_Casing.py @@ -215,7 +215,7 @@ def run(plotIt=True): # ------------ Problem and Survey --------------- survey = FDEM.Survey(sg_p + dg_p) mapping = [('sigma', Maps.IdentityMap(mesh))] - problem = FDEM.Problem3D_h(mesh, mapping=mapping) + problem = FDEM.Problem3D_h(mesh, mapping=mapping, Solver=solver) problem.pair(survey) # ------------- Solve --------------------------- From 5e2a8232a3f308d3ded0d06cf4bbe92184822a7b Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 17:21:37 -0700 Subject: [PATCH 37/77] Minor updates to titles in examples. --- SimPEG/Examples/MT_1D_ForwardAndInversion.py | 2 +- SimPEG/Examples/MT_3D_Foward.py | 11 +++++------ SimPEG/Examples/Utils_surface2ind_topo.py | 16 +++++++++------- docs/examples/DC_Forward_PseudoSection.rst | 1 - docs/examples/MT_1D_ForwardAndInversion.rst | 2 +- docs/examples/MT_3D_Foward.rst | 2 +- docs/examples/Utils_surface2ind_topo.rst | 4 ++++ 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/SimPEG/Examples/MT_1D_ForwardAndInversion.py b/SimPEG/Examples/MT_1D_ForwardAndInversion.py index 69cedd98..2c3d9b46 100644 --- a/SimPEG/Examples/MT_1D_ForwardAndInversion.py +++ b/SimPEG/Examples/MT_1D_ForwardAndInversion.py @@ -7,7 +7,7 @@ import matplotlib.pyplot as plt def run(plotIt=True): """ MT: 1D: Inversion - ======================= + ================= Forward model 1D MT data. Setup and run a MT 1D inversion. diff --git a/SimPEG/Examples/MT_3D_Foward.py b/SimPEG/Examples/MT_3D_Foward.py index da16eeee..0a56e250 100644 --- a/SimPEG/Examples/MT_3D_Foward.py +++ b/SimPEG/Examples/MT_3D_Foward.py @@ -5,14 +5,14 @@ import SimPEG as simpeg from SimPEG import MT import numpy as np try: - from pymatsolver import MumpsSolver as Solver + from pymatsolver import MumpsSolver as solver except: - from SimPEG import Solver + from SimPEG import solver def run(plotIt=True, nFreq=1): """ MT: 3D: Forward - ======================= + =============== Forward model 3D MT data. @@ -47,15 +47,14 @@ def run(plotIt=True, nFreq=1): ## Setup the problem object problem = MT.Problem3D.eForm_ps(M, sigmaPrimary=sigBG) - problem.pair(survey) - problem.Solver = Solver + problem.pair(survey, Solver=solver) # Calculate the data fields = problem.fields(sig) dataVec = survey.eval(fields) # Make the data - mtData = MT.Data(survey,dataVec) + mtData = MT.Data(survey, dataVec) # Add plots if plotIt: pass diff --git a/SimPEG/Examples/Utils_surface2ind_topo.py b/SimPEG/Examples/Utils_surface2ind_topo.py index 4ed1cdaf..e4f748cb 100644 --- a/SimPEG/Examples/Utils_surface2ind_topo.py +++ b/SimPEG/Examples/Utils_surface2ind_topo.py @@ -2,8 +2,12 @@ from SimPEG import * from SimPEG.Utils import surface2ind_topo -def run(plotIt=False, nx = 5, ny = 5): +def run(plotIt=False, nx=5, ny=5): """ + + Utils: surface2ind_topo + ======================= + Here we show how to use :code:`Utils.surface2ind_topo` to identify cells below a topographic surface. @@ -13,27 +17,25 @@ def run(plotIt=False, nx = 5, ny = 5): xtopo = np.linspace(mesh.gridN[:,0].min(), mesh.gridN[:,0].max()) topo = 0.4*np.sin(xtopo*5) # define a topographic surface - Topo = np.hstack([Utils.mkvc(xtopo,2),Utils.mkvc(topo,2)]) #make it an array + Topo = np.hstack([Utils.mkvc(xtopo,2), Utils.mkvc(topo,2)]) #make it an array - indcc = surface2ind_topo(mesh, Topo,'CC') + indcc = surface2ind_topo(mesh, Topo, 'CC') if plotIt: from matplotlib.pylab import plt from scipy.interpolate import interp1d - fig, ax = plt.subplots(1,1,figsize=(6,6)) + fig, ax = plt.subplots(1,1, figsize=(6,6)) mesh.plotGrid(ax=ax, nodes=True, centers=True) ax.plot(xtopo,topo,'k',linewidth=1) - # ax.plot(mesh.vectorNx, interp1d(xtopo,topo)(mesh.vectorNx),'--k',linewidth=3) ax.plot(mesh.vectorCCx, interp1d(xtopo,topo)(mesh.vectorCCx),'--k',linewidth=3) - aveN2CC = Utils.sdiag(mesh.aveN2CC.T.sum(1))*mesh.aveN2CC.T a = aveN2CC * indcc a[a > 0] = 1. a[a < 0.25] = np.nan a = a.reshape(mesh.vnN, order='F') masked_array = np.ma.array(a, mask=np.isnan(a)) - ax.pcolor(mesh.vectorNx,mesh.vectorNy,masked_array.T, cmap = plt.cm.gray,alpha=0.2) + ax.pcolor(mesh.vectorNx,mesh.vectorNy,masked_array.T, cmap=plt.cm.gray, alpha=0.2) plt.show() diff --git a/docs/examples/DC_Forward_PseudoSection.rst b/docs/examples/DC_Forward_PseudoSection.rst index 012d1ced..4231e944 100644 --- a/docs/examples/DC_Forward_PseudoSection.rst +++ b/docs/examples/DC_Forward_PseudoSection.rst @@ -22,7 +22,6 @@ radi = Radius of spheres [r1,r2] param = Conductivity of background and two spheres [m0,m1,m2] surveyType = survey type 'pole-dipole' or 'dipole-dipole' unitType = Data type "appResistivity" | "appConductivity" | "volt" - Created by @fourndo diff --git a/docs/examples/MT_1D_ForwardAndInversion.rst b/docs/examples/MT_1D_ForwardAndInversion.rst index 9646a7eb..bc834215 100644 --- a/docs/examples/MT_1D_ForwardAndInversion.rst +++ b/docs/examples/MT_1D_ForwardAndInversion.rst @@ -10,7 +10,7 @@ MT: 1D: Inversion -======================= +================= Forward model 1D MT data. Setup and run a MT 1D inversion. diff --git a/docs/examples/MT_3D_Foward.rst b/docs/examples/MT_3D_Foward.rst index eaeead7a..142a62a4 100644 --- a/docs/examples/MT_3D_Foward.rst +++ b/docs/examples/MT_3D_Foward.rst @@ -10,7 +10,7 @@ MT: 3D: Forward -======================= +=============== Forward model 3D MT data. diff --git a/docs/examples/Utils_surface2ind_topo.rst b/docs/examples/Utils_surface2ind_topo.rst index 04b27d5d..7ff007d1 100644 --- a/docs/examples/Utils_surface2ind_topo.rst +++ b/docs/examples/Utils_surface2ind_topo.rst @@ -9,6 +9,10 @@ .. --------------------------------- .. + +Utils: surface2ind_topo +======================= + Here we show how to use :code:`Utils.surface2ind_topo` to identify cells below a topographic surface. From 0b4215f33e10d25d8ca6134ee4ca026cd16f5c96 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 17:45:49 -0700 Subject: [PATCH 38/77] Add DC and IP docs. --- docs/{api_DC.rst => dc/index.rst} | 25 ++++++++++++++++--------- docs/index.rst | 2 ++ docs/ip/index.rst | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 9 deletions(-) rename docs/{api_DC.rst => dc/index.rst} (89%) create mode 100644 docs/ip/index.rst diff --git a/docs/api_DC.rst b/docs/dc/index.rst similarity index 89% rename from docs/api_DC.rst rename to docs/dc/index.rst index f6c98d09..27ec89bd 100644 --- a/docs/api_DC.rst +++ b/docs/dc/index.rst @@ -1,5 +1,3 @@ -.. _api_DC: - .. math:: \renewcommand{\div}{\nabla\cdot\,} @@ -38,8 +36,16 @@ \renewcommand {\u} { {\vec u} } \newcommand{\I}{\vec{I}} + +Direct Current Resistivity +************************** + +`SimPEG.DCIP` uses SimPEG as the framework for the forward and inverse +direct current (DC) resistivity and induced polarization (IP) geophysical problems. + + DC resistivity survey -********************* +===================== Electrical resistivity of subsurface materials is measured by causing an electrical current to flow in the earth between one pair of electrodes while the voltage across a second pair of electrodes is measured. The result is an "apparent" resistivity which is a value representing the weighted average resistivity over a volume of the earth. Variations in this measurement are caused by variations in the soil, rock, and pore fluid electrical resistivity. Surveys require contact with the ground, so they can be labour intensive. Results are sometimes interpreted directly, but more commonly, 1D, 2D or 3D models are estimated using inversion procedures (`GPG `_). @@ -55,7 +61,7 @@ As direct current (DC) implies, in DC resistivity survey, we assume steady-state \curl \e = 0 -Then by taking \\(\\curl\\) for the first equation, we have +Then by taking \\(\\div\\) of the first equation, we have .. math:: @@ -137,13 +143,14 @@ Comparing to the analytic function: .. plot:: - import simpegDC as DC - DC.Examples.Verification.run(plotIt=True) + from SimPEG import Examples + Examples.DC_Analytic_Dipole.run(plotIt=True) -API -=== -.. automodule:: simpegDC.BaseDC +API for DC codes +================ + +.. automodule:: SimPEG.DCIP.BaseDC :show-inheritance: :members: :undoc-members: diff --git a/docs/index.rst b/docs/index.rst index 1293c21a..8b27ee1b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -59,6 +59,8 @@ Packages :maxdepth: 3 em/index + dc/index + ip/index mt/index flow/index diff --git a/docs/ip/index.rst b/docs/ip/index.rst new file mode 100644 index 00000000..68def737 --- /dev/null +++ b/docs/ip/index.rst @@ -0,0 +1,14 @@ +Induced Polarization +******************** + +Todo: docs for IP! + + +API for IP codes +================ + +.. automodule:: SimPEG.DCIP.BaseIP + :show-inheritance: + :members: + :undoc-members: + :inherited-members: From 12a12c7b5a8686ee898db48ac69b2aa3e63af67a Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 17:51:41 -0700 Subject: [PATCH 39/77] updates to FDEM docs. --- docs/em/api_FDEM.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/em/api_FDEM.rst b/docs/em/api_FDEM.rst index 778e0b3a..60b38d1c 100644 --- a/docs/em/api_FDEM.rst +++ b/docs/em/api_FDEM.rst @@ -150,7 +150,7 @@ API FDEM Problem ------------ -.. automodule:: SimPEG.EM.FDEM.FDEM +.. automodule:: SimPEG.EM.FDEM.ProblemFDEM :show-inheritance: :members: :undoc-members: @@ -169,6 +169,11 @@ FDEM Survey :members: :undoc-members: +.. automodule:: SimPEG.EM.FDEM.RxFDEM + :show-inheritance: + :members: + :undoc-members: + FDEM Fields ----------- From fc079930067523e784dd3231a6135f39e1a1e275 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 18:03:03 -0700 Subject: [PATCH 40/77] Spacings in functions. --- SimPEG/MT/Utils/dataUtils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SimPEG/MT/Utils/dataUtils.py b/SimPEG/MT/Utils/dataUtils.py index b1947cb8..614470d9 100644 --- a/SimPEG/MT/Utils/dataUtils.py +++ b/SimPEG/MT/Utils/dataUtils.py @@ -19,7 +19,7 @@ def getAppRes(MTdata): zList.append(zc) return [appResPhs(zList[i][0],np.sum(zList[i][1:3])) for i in np.arange(len(zList))] -def rotateData(MTdata,rotAngle): +def rotateData(MTdata, rotAngle): ''' Function that rotates clockwist by rotAngle (- negative for a counter-clockwise rotation) ''' @@ -44,19 +44,19 @@ def rotateData(MTdata,rotAngle): return MT.Data.fromRecArray(outRec) -def appResPhs(freq,z): +def appResPhs(freq, z): app_res = ((1./(8e-7*np.pi**2))/freq)*np.abs(z)**2 app_phs = np.arctan2(z.imag,z.real)*(180/np.pi) return app_res, app_phs -def skindepth(rho,freq): +def skindepth(rho, freq): ''' Function to calculate the skindepth of EM waves''' return np.sqrt( (rho*((1/(freq * mu_0 * np.pi ))))) -def rec2ndarr(x,dt=float): +def rec2ndarr(x, dt=float): return x.view((dt, len(x.dtype.names))) -def makeAnalyticSolution(mesh,model,elev,freqs): +def makeAnalyticSolution(mesh, model, elev, freqs): from SimPEG import MT data1D = [] for freq in freqs: @@ -70,7 +70,7 @@ def makeAnalyticSolution(mesh,model,elev,freqs): dataRec = np.array(data1D,dtype=[('freq',float),('x',float),('y',float),('z',float),('zyx',complex)]) return dataRec -def plotMT1DModelData(problem,models,symList=None): +def plotMT1DModelData(problem, models, symList=None): from SimPEG import MT # Setup the figure fontSize = 15 From de693adaa7129011f3890ff0c37e1e0b020615c0 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 18:04:09 -0700 Subject: [PATCH 41/77] Minor updates to get it 'working' There still seems to be a problem with this example: - The line search breaks. - The plots are not informative. - There are a lot of errors in the structured array codes. --- SimPEG/Examples/MT_1D_ForwardAndInversion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimPEG/Examples/MT_1D_ForwardAndInversion.py b/SimPEG/Examples/MT_1D_ForwardAndInversion.py index 2c3d9b46..446613e5 100644 --- a/SimPEG/Examples/MT_1D_ForwardAndInversion.py +++ b/SimPEG/Examples/MT_1D_ForwardAndInversion.py @@ -50,7 +50,7 @@ def run(plotIt=True): m_0 = np.log(sigma_0[active]) # Set the mapping - actMap = simpeg.Maps.ActiveCells(m1d, active, np.log(1e-8), nC=m1d.nCx) + actMap = simpeg.Maps.InjectActiveCells(m1d, active, np.log(1e-8), nC=m1d.nCx) mappingExpAct = simpeg.Maps.ExpMap(m1d) * actMap ## Setup the layout of the survey, set the sources and the connected receivers @@ -76,7 +76,7 @@ def run(plotIt=True): survey.dobs = survey.dtrue + 0.025*abs(survey.dtrue)*np.random.randn(*survey.dtrue.shape) if plotIt: - fig = MT.Utils.dataUtils.plotMT1DModelData(problem) + fig = MT.Utils.dataUtils.plotMT1DModelData(problem, [m_0]) fig.suptitle('Target - smooth true') From e2bb9c8d8e43ae7df689603dac5f54e0fa974b0c Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 18:12:52 -0700 Subject: [PATCH 42/77] rename flow example. --- docs/flow/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/flow/index.rst b/docs/flow/index.rst index d4299b0d..027376ce 100644 --- a/docs/flow/index.rst +++ b/docs/flow/index.rst @@ -35,8 +35,8 @@ Here we reproduce the results from Celia et al. (1990): .. plot:: - from SimPEG.FLOW.Examples import Celia1990 - Celia1990.run() + from SimPEG import Examples + Examples.FLOW_Richards_1D_Celia1990.run() Richards ======== From 6f7a0b12798bef10d20a65c82d5e74434c3c2b16 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 18:14:42 -0700 Subject: [PATCH 43/77] Rename `Vertical1DMap` to `SurjectVertical1D` due to depreciation. --- SimPEG/MT/SrcMT.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimPEG/MT/SrcMT.py b/SimPEG/MT/SrcMT.py index 70698c88..138d161f 100644 --- a/SimPEG/MT/SrcMT.py +++ b/SimPEG/MT/SrcMT.py @@ -86,7 +86,7 @@ class polxy_1Dprimary(BaseMTSrc): Get the electrical field source """ e_p = self.ePrimary(problem) - Map_sigma_p = Maps.Vertical1DMap(problem.mesh) + Map_sigma_p = Maps.SurjectVertical1D(problem.mesh) sigma_p = Map_sigma_p._transform(self.sigma1d) # Make mass matrix # Note: M(sig) - M(sig_p) = M(sig - sig_p) @@ -163,7 +163,7 @@ class polxy_3Dprimary(BaseMTSrc): Get the electrical field source """ e_p = self.ePrimary(problem) - Map_sigma_p = Maps.Vertical1DMap(problem.mesh) + Map_sigma_p = Maps.SurjectVertical1D(problem.mesh) sigma_p = Map_sigma_p._transform(self.sigma1d) # Make mass matrix # Note: M(sig) - M(sig_p) = M(sig - sig_p) From 74f53955732385b96c3b8a3c675fbd5fdead5b41 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 18:25:42 -0700 Subject: [PATCH 44/77] Surject1D updates. --- docs/api_Maps.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api_Maps.rst b/docs/api_Maps.rst index 0ab32024..4b376194 100644 --- a/docs/api_Maps.rst +++ b/docs/api_Maps.rst @@ -46,14 +46,14 @@ 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.Vertical1DMap`), +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. :: M = Mesh.TensorMesh([7,5]) - v1dMap = Maps.Vertical1DMap(M) + 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! @@ -64,7 +64,7 @@ done by the :class:`SimPEG.Maps.ExpMap` described above. from SimPEG import * import matplotlib.pyplot as plt M = Mesh.TensorMesh([7,5]) - v1dMap = Maps.Vertical1DMap(M) + 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! @@ -148,7 +148,7 @@ lives (i.e. it varies logarithmically). Vertical 1D Map --------------- -.. autoclass:: SimPEG.Maps.Vertical1DMap +.. autoclass:: SimPEG.Maps.SurjectVertical1D :members: :undoc-members: From ad4a0240d1a54e0264933243c12fd1befe80755f Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 18:34:17 -0700 Subject: [PATCH 45/77] Remove Vertical1DMap from tests. --- tests/base/test_maps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/base/test_maps.py b/tests/base/test_maps.py index 19cd4e77..6b1c1ad7 100644 --- a/tests/base/test_maps.py +++ b/tests/base/test_maps.py @@ -5,8 +5,8 @@ from scipy.sparse.linalg import dsolve TOL = 1e-14 -MAPS_TO_TEST_2D = ["CircleMap", "ComplexMap", "ExpMap", "IdentityMap", "SurjectVertical1D", "Weighting", "SurjectFull","FullMap","Vertical1DMap"] -MAPS_TO_TEST_3D = [ "ComplexMap", "ExpMap", "IdentityMap", "SurjectVertical1D", "Weighting", "SurjectFull","FullMap","Vertical1DMap"] +MAPS_TO_TEST_2D = ["CircleMap", "ComplexMap", "ExpMap", "IdentityMap", "SurjectVertical1D", "Weighting", "SurjectFull","FullMap"] +MAPS_TO_TEST_3D = [ "ComplexMap", "ExpMap", "IdentityMap", "SurjectVertical1D", "Weighting", "SurjectFull","FullMap"] class MapTests(unittest.TestCase): From a131383daef1dd9102419b6a367c2712cee59428 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 18:35:41 -0700 Subject: [PATCH 46/77] Correct solver location. --- SimPEG/Examples/MT_3D_Foward.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimPEG/Examples/MT_3D_Foward.py b/SimPEG/Examples/MT_3D_Foward.py index 0a56e250..3baf55a1 100644 --- a/SimPEG/Examples/MT_3D_Foward.py +++ b/SimPEG/Examples/MT_3D_Foward.py @@ -46,8 +46,8 @@ def run(plotIt=True, nFreq=1): survey = MT.Survey(srcList) ## Setup the problem object - problem = MT.Problem3D.eForm_ps(M, sigmaPrimary=sigBG) - problem.pair(survey, Solver=solver) + problem = MT.Problem3D.eForm_ps(M, sigmaPrimary=sigBG, Solver=solver) + problem.pair(survey) # Calculate the data fields = problem.fields(sig) From bc073e49b54a46306cde328c7fc0b4283e4828d4 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 18:57:38 -0700 Subject: [PATCH 47/77] Updates to docs errors. --- SimPEG/EM/FDEM/FieldsFDEM.py | 20 ++++++++++---------- SimPEG/Utils/meshutils.py | 23 ++++++++++++++--------- docs/_ext/__init__.py | 1 + docs/_ext/environmentSetup.py | 15 +++++++++++++++ docs/api_Maps.rst | 6 ++++-- docs/api_Utils.rst | 12 +++++++++--- docs/conf.py | 3 +++ 7 files changed, 56 insertions(+), 24 deletions(-) create mode 100644 docs/_ext/__init__.py create mode 100644 docs/_ext/environmentSetup.py diff --git a/SimPEG/EM/FDEM/FieldsFDEM.py b/SimPEG/EM/FDEM/FieldsFDEM.py index 253b9984..c2e4bfa6 100644 --- a/SimPEG/EM/FDEM/FieldsFDEM.py +++ b/SimPEG/EM/FDEM/FieldsFDEM.py @@ -165,7 +165,7 @@ class Fields3D_e(Fields): Fields object for Problem3D_e. :param Mesh mesh: mesh - :param Survey survey: survey + :param SimPEG.EM.FDEM.SurveyFDEM.Survey survey: survey """ knownFields = {'eSolution':'E'} @@ -431,7 +431,7 @@ class Fields3D_b(Fields): Fields object for Problem3D_b. :param Mesh mesh: mesh - :param Survey survey: survey + :param SimPEG.EM.FDEM.SurveyFDEM.Survey survey: survey """ knownFields = {'bSolution':'F'} @@ -446,8 +446,8 @@ class Fields3D_b(Fields): 'h' : ['bSolution','CCV','_h'], } - def __init__(self,mesh,survey,**kwargs): - Fields.__init__(self,mesh,survey,**kwargs) + def __init__(self, mesh, survey, **kwargs): + Fields.__init__(self, mesh, survey, **kwargs) def startup(self): self.prob = self.survey.prob @@ -698,7 +698,7 @@ class Fields3D_j(Fields): Fields object for Problem3D_j. :param Mesh mesh: mesh - :param Survey survey: survey + :param SimPEG.EM.FDEM.SurveyFDEM.Survey survey: survey """ knownFields = {'jSolution':'F'} @@ -713,8 +713,8 @@ class Fields3D_j(Fields): 'b' : ['jSolution','CCV','_b'], } - def __init__(self,mesh,survey,**kwargs): - Fields.__init__(self,mesh,survey,**kwargs) + def __init__(self, mesh, survey, **kwargs): + Fields.__init__(self, mesh, survey, **kwargs) def startup(self): self.prob = self.survey.prob @@ -993,7 +993,7 @@ class Fields3D_h(Fields): Fields object for Problem3D_h. :param Mesh mesh: mesh - :param Survey survey: survey + :param SimPEG.EM.FDEM.SurveyFDEM.Survey survey: survey """ knownFields = {'hSolution':'E'} @@ -1008,8 +1008,8 @@ class Fields3D_h(Fields): 'b' : ['hSolution','CCV','_b'], } - def __init__(self,mesh,survey,**kwargs): - Fields.__init__(self,mesh,survey,**kwargs) + def __init__(self, mesh, survey, **kwargs): + Fields.__init__(self, mesh, survey, **kwargs) def startup(self): self.prob = self.survey.prob diff --git a/SimPEG/Utils/meshutils.py b/SimPEG/Utils/meshutils.py index eb5d13a1..1415e7b8 100644 --- a/SimPEG/Utils/meshutils.py +++ b/SimPEG/Utils/meshutils.py @@ -105,15 +105,20 @@ def closestPoints(mesh, pts, gridLoc='CC'): def ExtractCoreMesh(xyzlim, mesh, meshType='tensor'): """ Extracts Core Mesh from Global mesh - xyzlim: 2D array [ndim x 2] - mesh: SimPEG mesh - This function ouputs: + + :param numpy.ndarray xyzlim: 2D array [ndim x 2] + :param simpeg.Mesh.BaseMesh mesh: The mesh + + This function ouputs:: + - actind: corresponding boolean index from global to core - meshcore: core SimPEG mesh + Warning: 1D and 2D has not been tested + """ from SimPEG import Mesh - if mesh.dim ==1: + if mesh.dim == 1: xyzlim = xyzlim.flatten() xmin, xmax = xyzlim[0], xyzlim[1] @@ -125,11 +130,11 @@ def ExtractCoreMesh(xyzlim, mesh, meshType='tensor'): x0 = [xc[0]-hx[0]*0.5, yc[0]-hy[0]*0.5] - meshCore = Mesh.TensorMesh([hx, hy] ,x0=x0) + meshCore = Mesh.TensorMesh([hx, hy], x0=x0) actind = (mesh.gridCC[:,0]>xmin) & (mesh.gridCC[:,0]xmin) & (mesh.gridCC[:,0]ymin) & (mesh.gridCC[:,1]xmin) & (mesh.gridCC[:,0]ymin) & (mesh.gridCC[:,1] Date: Sun, 29 May 2016 19:22:15 -0700 Subject: [PATCH 48/77] Suppress image warning. --- docs/_ext/__init__.py | 1 - docs/_ext/environmentSetup.py | 15 --------------- docs/conf.py | 11 ++++++++++- 3 files changed, 10 insertions(+), 17 deletions(-) delete mode 100644 docs/_ext/__init__.py delete mode 100644 docs/_ext/environmentSetup.py diff --git a/docs/_ext/__init__.py b/docs/_ext/__init__.py deleted file mode 100644 index 5dacceb5..00000000 --- a/docs/_ext/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from environmentSetup import supress_nonlocal_image_warn diff --git a/docs/_ext/environmentSetup.py b/docs/_ext/environmentSetup.py deleted file mode 100644 index 16296018..00000000 --- a/docs/_ext/environmentSetup.py +++ /dev/null @@ -1,15 +0,0 @@ - -def supress_nonlocal_image_warn(): - import sphinx.environment - sphinx.environment.BuildEnvironment.warn_node = _supress_nonlocal_image_warn - -def _supress_nonlocal_image_warn(self, msg, node): - from docutils.utils import get_source_line - - if not msg.startswith('nonlocal image URI found:'): - self._warnfunc(msg, '%s:%s' % get_source_line(node)) - - - -if __name__ == '__main__': - checkDependencies() diff --git a/docs/conf.py b/docs/conf.py index 334caf27..d9bcfae7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -258,5 +258,14 @@ texinfo_documents = [ autodoc_member_order = 'bysource' -from _ext import supress_nonlocal_image_warn +def supress_nonlocal_image_warn(): + import sphinx.environment + sphinx.environment.BuildEnvironment.warn_node = _supress_nonlocal_image_warn + +def _supress_nonlocal_image_warn(self, msg, node): + from docutils.utils import get_source_line + + if not msg.startswith('nonlocal image URI found:'): + self._warnfunc(msg, '%s:%s' % get_source_line(node)) + supress_nonlocal_image_warn() From 40f0874dfb88821aef0078a4946bc967863a3a6a Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Sun, 29 May 2016 22:18:22 -0700 Subject: [PATCH 49/77] Doc testing, I think that is most of them! --- .gitignore | 1 + SimPEG/DCIP/BaseDC.py | 4 +- SimPEG/DCIP/BaseIP.py | 2 +- SimPEG/Directives.py | 8 +-- SimPEG/EM/Base.py | 7 ++- SimPEG/EM/FDEM/FieldsFDEM.py | 40 +++++-------- SimPEG/EM/FDEM/ProblemFDEM.py | 32 +++++------ SimPEG/EM/FDEM/RxFDEM.py | 10 ++-- SimPEG/EM/FDEM/SrcFDEM.py | 56 +++++++++--------- SimPEG/EM/TDEM/BaseTDEM.py | 6 +- SimPEG/EM/TDEM/TDEM_b.py | 26 ++++----- .../Examples/EM_Schenkel_Morrison_Casing.py | 5 +- SimPEG/FLOW/Richards/Empirical.py | 4 +- SimPEG/Mesh/BaseMesh.py | 24 ++++---- SimPEG/Mesh/InnerProducts.py | 3 +- SimPEG/Mesh/MeshIO.py | 57 +++++++------------ SimPEG/Mesh/TensorMesh.py | 8 +-- SimPEG/Mesh/View.py | 2 +- SimPEG/Optimization.py | 10 ++-- SimPEG/PropMaps.py | 2 +- SimPEG/Regularization.py | 12 ++-- SimPEG/Tests.py | 2 +- SimPEG/Utils/ModelBuilder.py | 26 ++++----- SimPEG/Utils/SolverUtils.py | 14 ++--- SimPEG/Utils/interputils.py | 2 +- SimPEG/Utils/matutils.py | 12 ++-- SimPEG/Utils/meshutils.py | 4 +- docs/Makefile | 2 +- docs/api_ForwardProblem.rst | 36 +++++++++++- docs/api_InnerProducts.rst | 2 +- docs/api_Inversion.rst | 6 +- docs/api_Maps.rst | 7 ++- docs/api_Mesh.rst | 2 +- docs/api_MeshCode.rst | 39 ++++++++++++- docs/api_PropMaps.rst | 29 ++++++++++ docs/api_Utilities.rst | 1 + docs/api_bigPicture.rst | 4 +- docs/conf.py | 21 +++++++ docs/em/api_TDEM.rst | 2 +- docs/em/api_basic.rst | 33 +++++++++++ docs/em/index.rst | 5 +- docs/examples/EM_Schenkel_Morrison_Casing.rst | 5 +- tests/docs/test_docs.py | 22 +++---- 43 files changed, 365 insertions(+), 230 deletions(-) create mode 100644 docs/api_PropMaps.rst create mode 100644 docs/em/api_basic.rst diff --git a/.gitignore b/.gitignore index fc798cea..e1264b7d 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ nosetests.xml *.sublime-workspace docs/_build/ Makefile +docs/warnings.txt diff --git a/SimPEG/DCIP/BaseDC.py b/SimPEG/DCIP/BaseDC.py index 475c621e..4eb4ca69 100644 --- a/SimPEG/DCIP/BaseDC.py +++ b/SimPEG/DCIP/BaseDC.py @@ -162,8 +162,8 @@ class ProblemDC_CC(Problem.BaseProblem): """ Makes the matrix A(m) for the DC resistivity problem. - :param numpy.array m: model - :rtype: scipy.csc_matrix + :param numpy.ndarray m: model + :rtype: scipy.sparse.csc_matrix :return: A(m) .. math:: diff --git a/SimPEG/DCIP/BaseIP.py b/SimPEG/DCIP/BaseIP.py index a18b5a47..bab3af3a 100644 --- a/SimPEG/DCIP/BaseIP.py +++ b/SimPEG/DCIP/BaseIP.py @@ -71,7 +71,7 @@ class ProblemIP(Problem.BaseProblem): Makes the matrix A(m) for the DC resistivity problem. :param numpy.array m: model - :rtype: scipy.csc_matrix + :rtype: scipy.sparse.csc_matrix :return: A(m) .. math:: diff --git a/SimPEG/Directives.py b/SimPEG/Directives.py index 93e51f62..a35f97c0 100644 --- a/SimPEG/Directives.py +++ b/SimPEG/Directives.py @@ -166,7 +166,7 @@ class TargetMisfit(InversionDirective): -class _SaveEveryIteration(InversionDirective): +class SaveEveryIteration(InversionDirective): @property def name(self): if getattr(self, '_name', None) is None: @@ -187,7 +187,7 @@ class _SaveEveryIteration(InversionDirective): self._fileName = value -class SaveModelEveryIteration(_SaveEveryIteration): +class SaveModelEveryIteration(SaveEveryIteration): """SaveModelEveryIteration""" def initialize(self): @@ -197,7 +197,7 @@ class SaveModelEveryIteration(_SaveEveryIteration): np.save('%03d-%s' % (self.opt.iter, self.fileName), self.opt.xc) -class SaveOutputEveryIteration(_SaveEveryIteration): +class SaveOutputEveryIteration(SaveEveryIteration): """SaveModelEveryIteration""" def initialize(self): @@ -211,7 +211,7 @@ class SaveOutputEveryIteration(_SaveEveryIteration): f.write(' %3d %1.4e %1.4e %1.4e %1.4e\n'%(self.opt.iter, self.invProb.beta, self.invProb.phi_d, self.invProb.phi_m, self.opt.f)) f.close() -class SaveOutputDictEveryIteration(_SaveEveryIteration): +class SaveOutputDictEveryIteration(SaveEveryIteration): """SaveOutputDictEveryIteration""" def initialize(self): diff --git a/SimPEG/EM/Base.py b/SimPEG/EM/Base.py index 2a2ce363..15a0ce60 100644 --- a/SimPEG/EM/Base.py +++ b/SimPEG/EM/Base.py @@ -20,10 +20,10 @@ class BaseEMProblem(Problem.BaseProblem): Problem.BaseProblem.__init__(self, mesh, **kwargs) - surveyPair = Survey.BaseSurvey - dataPair = Survey.Data + surveyPair = Survey.BaseSurvey #: The survey to pair with. + dataPair = Survey.Data #: The data to pair with. - PropMap = EMPropMap + PropMap = EMPropMap #: The property mapping Solver = SimpegSolver solverOpts = {} @@ -217,6 +217,7 @@ class BaseEMSurvey(Survey.BaseSurvey): def eval(self, f): """ Project fields to receiver locations + :param Fields u: fields object :rtype: numpy.ndarray :return: data diff --git a/SimPEG/EM/FDEM/FieldsFDEM.py b/SimPEG/EM/FDEM/FieldsFDEM.py index c2e4bfa6..e0f54be2 100644 --- a/SimPEG/EM/FDEM/FieldsFDEM.py +++ b/SimPEG/EM/FDEM/FieldsFDEM.py @@ -6,11 +6,11 @@ from SimPEG.EM.Utils import omega from SimPEG.Utils import Zero, Identity, sdiag -class Fields(SimPEG.Problem.Fields): +class FieldsFDEM(SimPEG.Problem.Fields): """ Fancy Field Storage for a FDEM survey. Only one field type is stored for - each problem, the rest are computed. The fields obejct acts like an array and is indexed by + each problem, the rest are computed. The fields object acts like an array and is indexed by .. code-block:: python @@ -92,7 +92,7 @@ class Fields(SimPEG.Problem.Fields): """ Total derivative of e with respect to the inversion model. Returns :math:`d\mathbf{e}/d\mathbf{m}` for forward and (:math:`d\mathbf{e}/d\mathbf{u}`, :math:`d\mathb{u}/d\mathbf{m}`) for the adjoint - :param Src src: sorce + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: source :param numpy.ndarray du_dm_v: derivative of the solution vector with respect to the model times a vector (is None for adjoint) :param numpy.ndarray v: vector to take sensitivity product with :param bool adjoint: adjoint? @@ -110,7 +110,7 @@ class Fields(SimPEG.Problem.Fields): """ Total derivative of b with respect to the inversion model. Returns :math:`d\mathbf{b}/d\mathbf{m}` for forward and (:math:`d\mathbf{b}/d\mathbf{u}`, :math:`d\mathb{u}/d\mathbf{m}`) for the adjoint - :param Src src: sorce + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: source :param numpy.ndarray du_dm_v: derivative of the solution vector with respect to the model times a vector (is None for adjoint) :param numpy.ndarray v: vector to take sensitivity product with :param bool adjoint: adjoint? @@ -128,7 +128,7 @@ class Fields(SimPEG.Problem.Fields): """ Total derivative of h with respect to the inversion model. Returns :math:`d\mathbf{h}/d\mathbf{m}` for forward and (:math:`d\mathbf{h}/d\mathbf{u}`, :math:`d\mathb{u}/d\mathbf{m}`) for the adjoint - :param Src src: sorce + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: source :param numpy.ndarray du_dm_v: derivative of the solution vector with respect to the model times a vector (is None for adjoint) :param numpy.ndarray v: vector to take sensitivity product with :param bool adjoint: adjoint? @@ -146,7 +146,7 @@ class Fields(SimPEG.Problem.Fields): """ Total derivative of j with respect to the inversion model. Returns :math:`d\mathbf{j}/d\mathbf{m}` for forward and (:math:`d\mathbf{j}/d\mathbf{u}`, :math:`d\mathb{u}/d\mathbf{m}`) for the adjoint - :param Src src: sorce + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: source :param numpy.ndarray du_dm_v: derivative of the solution vector with respect to the model times a vector (is None for adjoint) :param numpy.ndarray v: vector to take sensitivity product with :param bool adjoint: adjoint? @@ -160,11 +160,11 @@ class Fields(SimPEG.Problem.Fields): return self._jDeriv_u(src, v, adjoint), self._jDeriv_m(src, v, adjoint) return np.array(self._jDeriv_u(src, du_dm_v, adjoint) + self._jDeriv_m(src, v, adjoint), dtype = complex) -class Fields3D_e(Fields): +class Fields3D_e(FieldsFDEM): """ Fields object for Problem3D_e. - :param Mesh mesh: mesh + :param BaseMesh mesh: mesh :param SimPEG.EM.FDEM.SurveyFDEM.Survey survey: survey """ @@ -180,9 +180,6 @@ class Fields3D_e(Fields): 'h' : ['eSolution','CCV','_h'], } - def __init__(self, mesh, survey, **kwargs): - Fields.__init__(self, mesh, survey, **kwargs) - def startup(self): self.prob = self.survey.prob self._edgeCurl = self.survey.prob.mesh.edgeCurl @@ -426,11 +423,11 @@ class Fields3D_e(Fields): -class Fields3D_b(Fields): +class Fields3D_b(FieldsFDEM): """ Fields object for Problem3D_b. - :param Mesh mesh: mesh + :param BaseMesh mesh: mesh :param SimPEG.EM.FDEM.SurveyFDEM.Survey survey: survey """ @@ -446,9 +443,6 @@ class Fields3D_b(Fields): 'h' : ['bSolution','CCV','_h'], } - def __init__(self, mesh, survey, **kwargs): - Fields.__init__(self, mesh, survey, **kwargs) - def startup(self): self.prob = self.survey.prob self._edgeCurl = self.survey.prob.mesh.edgeCurl @@ -693,11 +687,11 @@ class Fields3D_b(Fields): return Zero() -class Fields3D_j(Fields): +class Fields3D_j(FieldsFDEM): """ Fields object for Problem3D_j. - :param Mesh mesh: mesh + :param BaseMesh mesh: mesh :param SimPEG.EM.FDEM.SurveyFDEM.Survey survey: survey """ @@ -713,9 +707,6 @@ class Fields3D_j(Fields): 'b' : ['jSolution','CCV','_b'], } - def __init__(self, mesh, survey, **kwargs): - Fields.__init__(self, mesh, survey, **kwargs) - def startup(self): self.prob = self.survey.prob self._edgeCurl = self.survey.prob.mesh.edgeCurl @@ -988,11 +979,11 @@ class Fields3D_j(Fields): return 1./(1j * omega(src.freq)) * VI * (self._aveE2CCV * ( s_mDeriv(v) - self._edgeCurl.T * ( self._MfRhoDeriv(jSolution) * v ) ) ) -class Fields3D_h(Fields): +class Fields3D_h(FieldsFDEM): """ Fields object for Problem3D_h. - :param Mesh mesh: mesh + :param BaseMesh mesh: mesh :param SimPEG.EM.FDEM.SurveyFDEM.Survey survey: survey """ @@ -1008,9 +999,6 @@ class Fields3D_h(Fields): 'b' : ['hSolution','CCV','_b'], } - def __init__(self, mesh, survey, **kwargs): - Fields.__init__(self, mesh, survey, **kwargs) - def startup(self): self.prob = self.survey.prob self._edgeCurl = self.survey.prob.mesh.edgeCurl diff --git a/SimPEG/EM/FDEM/ProblemFDEM.py b/SimPEG/EM/FDEM/ProblemFDEM.py index c4f24e15..cbc01b9e 100644 --- a/SimPEG/EM/FDEM/ProblemFDEM.py +++ b/SimPEG/EM/FDEM/ProblemFDEM.py @@ -1,7 +1,7 @@ from SimPEG import Problem, Utils, np, sp, Solver as SimpegSolver from scipy.constants import mu_0 from SurveyFDEM import Survey as SurveyFDEM -from FieldsFDEM import Fields, Fields3D_e, Fields3D_b, Fields3D_h, Fields3D_j +from FieldsFDEM import FieldsFDEM, Fields3D_e, Fields3D_b, Fields3D_h, Fields3D_j from SimPEG.EM.Base import BaseEMProblem from SimPEG.EM.Utils import omega @@ -35,7 +35,7 @@ class BaseFDEMProblem(BaseEMProblem): """ surveyPair = SurveyFDEM - fieldsPair = Fields + fieldsPair = FieldsFDEM def fields(self, m): """ @@ -65,7 +65,7 @@ class BaseFDEMProblem(BaseEMProblem): :param numpy.array m: inversion model (nP,) :param numpy.array v: vector which we take sensitivity product with (nP,) - :param SimPEG.EM.FDEM.Fields u: fields object + :param SimPEG.EM.FDEM.FieldsFDEM.FieldsFDEM u: fields object :rtype numpy.array: :return: Jv (ndata,) """ @@ -100,7 +100,7 @@ class BaseFDEMProblem(BaseEMProblem): :param numpy.array m: inversion model (nP,) :param numpy.array v: vector which we take adjoint product with (nP,) - :param SimPEG.EM.FDEM.Fields u: fields object + :param SimPEG.EM.FDEM.FieldsFDEM.FieldsFDEM u: fields object :rtype numpy.array: :return: Jv (ndata,) """ @@ -154,8 +154,8 @@ class BaseFDEMProblem(BaseEMProblem): Evaluates the sources for a given frequency and puts them in matrix form :param float freq: Frequency - :rtype: (numpy.ndarray, numpy.ndarray) - :return: s_m, s_e (nE or nF, nSrc) + :rtype: tuple + :return: (s_m, s_e) (nE or nF, nSrc) """ Srcs = self.survey.getSrcByFreq(freq) if self._formulation is 'EB': @@ -195,7 +195,7 @@ class Problem3D_e(BaseFDEMProblem): which we solve for :math:`\mathbf{e}`. - :param SimPEG.Mesh mesh: mesh + :param SimPEG.Mesh.BaseMesh.BaseMesh mesh: mesh """ _solutionType = 'eSolution' @@ -270,7 +270,7 @@ class Problem3D_e(BaseFDEMProblem): Derivative of the right hand side with respect to the model :param float freq: frequency - :param SimPEG.EM.FDEM.Src src: FDEM source + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: FDEM source :param numpy.ndarray v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -306,7 +306,7 @@ class Problem3D_b(BaseFDEMProblem): .. note :: The inverse problem will not work with full anisotropy - :param SimPEG.Mesh mesh: mesh + :param SimPEG.Mesh.BaseMesh.BaseMesh mesh: mesh """ _solutionType = 'bSolution' @@ -401,7 +401,7 @@ class Problem3D_b(BaseFDEMProblem): Derivative of the right hand side with respect to the model :param float freq: frequency - :param SimPEG.EM.FDEM.Src src: FDEM source + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: FDEM source :param numpy.ndarray v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -455,7 +455,7 @@ class Problem3D_j(BaseFDEMProblem): .. note:: This implementation does not yet work with full anisotropy!! - :param SimPEG.Mesh mesh: mesh + :param SimPEG.Mesh.BaseMesh.BaseMesh mesh: mesh """ _solutionType = 'jSolution' @@ -531,8 +531,8 @@ class Problem3D_j(BaseFDEMProblem): \mathbf{RHS} = \mathbf{C} \mathbf{M_{\mu}^e}^{-1}\mathbf{s_m} -i\omega \mathbf{s_e} :param float freq: Frequency - :rtype: numpy.ndarray (nE, nSrc) - :return: RHS + :rtype: numpy.ndarray + :return: RHS (nE, nSrc) """ s_m, s_e = self.getSourceTerm(freq) @@ -551,7 +551,7 @@ class Problem3D_j(BaseFDEMProblem): Derivative of the right hand side with respect to the model :param float freq: frequency - :param SimPEG.EM.FDEM.Src src: FDEM source + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: FDEM source :param numpy.ndarray v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -593,7 +593,7 @@ class Problem3D_h(BaseFDEMProblem): \\left(\mathbf{C}^{\\top} \mathbf{M_{\\rho}^f} \mathbf{C} + i \omega \mathbf{M_{\mu}^e}\\right) \mathbf{h} = \mathbf{M^e} \mathbf{s_m} + \mathbf{C}^{\\top} \mathbf{M_{\\rho}^f} \mathbf{s_e} - :param SimPEG.Mesh mesh: mesh + :param SimPEG.Mesh.BaseMesh.BaseMesh mesh: mesh """ _solutionType = 'hSolution' @@ -671,7 +671,7 @@ class Problem3D_h(BaseFDEMProblem): Derivative of the right hand side with respect to the model :param float freq: frequency - :param SimPEG.EM.FDEM.Src src: FDEM source + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: FDEM source :param numpy.ndarray v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray diff --git a/SimPEG/EM/FDEM/RxFDEM.py b/SimPEG/EM/FDEM/RxFDEM.py index 53d6c722..13e2f291 100644 --- a/SimPEG/EM/FDEM/RxFDEM.py +++ b/SimPEG/EM/FDEM/RxFDEM.py @@ -25,10 +25,10 @@ class BaseRx(SimPEG.Survey.BaseRx): def eval(self, src, mesh, f): """ - Project fields to recievers to get data. + Project fields to receivers to get data. - :param Source src: FDEM source - :param Mesh mesh: mesh used + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: FDEM source + :param BaseMesh mesh: mesh used :param Fields f: fields object :rtype: numpy.ndarray :return: fields projected to recievers @@ -44,8 +44,8 @@ class BaseRx(SimPEG.Survey.BaseRx): """ Derivative of projected fields with respect to the inversion model times a vector. - :param Source src: FDEM source - :param Mesh mesh: mesh used + :param SimPEG.EM.FDEM.SrcFDEM.BaseSrc src: FDEM source + :param BaseMesh mesh: mesh used :param Fields f: fields object :param numpy.ndarray v: vector to multiply :rtype: numpy.ndarray diff --git a/SimPEG/EM/FDEM/SrcFDEM.py b/SimPEG/EM/FDEM/SrcFDEM.py index e6c8f005..7557ada7 100644 --- a/SimPEG/EM/FDEM/SrcFDEM.py +++ b/SimPEG/EM/FDEM/SrcFDEM.py @@ -23,8 +23,8 @@ class BaseSrc(Survey.BaseSrc): - :math:`s_m` : magnetic source term - :math:`s_e` : electric source term - :param Problem prob: FDEM Problem - :rtype: (numpy.ndarray, numpy.ndarray) + :param BaseFDEMProblem prob: FDEM Problem + :rtype: tuple :return: tuple with magnetic source term and electric source term """ s_m = self.s_m(prob) @@ -37,10 +37,10 @@ class BaseSrc(Survey.BaseSrc): - :code:`s_mDeriv` : derivative of the magnetic source term - :code:`s_eDeriv` : derivative of the electric source term - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :param numpy.ndarray v: vector to take product with :param bool adjoint: adjoint? - :rtype: (numpy.ndarray, numpy.ndarray) + :rtype: tuple :return: tuple with magnetic source term and electric source term derivatives times a vector """ if v is not None: @@ -52,7 +52,7 @@ class BaseSrc(Survey.BaseSrc): """ Primary magnetic flux density - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: primary magnetic flux density """ @@ -64,7 +64,7 @@ class BaseSrc(Survey.BaseSrc): """ Primary magnetic field - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -76,7 +76,7 @@ class BaseSrc(Survey.BaseSrc): """ Primary electric field - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: primary electric field """ @@ -88,7 +88,7 @@ class BaseSrc(Survey.BaseSrc): """ Primary current density - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: primary current density """ @@ -100,7 +100,7 @@ class BaseSrc(Survey.BaseSrc): """ Magnetic source term - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: magnetic source term on mesh """ @@ -110,7 +110,7 @@ class BaseSrc(Survey.BaseSrc): """ Electric source term - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: electric source term on mesh """ @@ -120,7 +120,7 @@ class BaseSrc(Survey.BaseSrc): """ Derivative of magnetic source term with respect to the inversion model - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :param numpy.ndarray v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -133,7 +133,7 @@ class BaseSrc(Survey.BaseSrc): """ Derivative of electric source term with respect to the inversion model - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :param numpy.ndarray v: vector to take product with :param bool adjoint: adjoint? :rtype: numpy.ndarray @@ -162,7 +162,7 @@ class RawVec_e(BaseSrc): """ Electric source term - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: electric source term on mesh """ @@ -191,7 +191,7 @@ class RawVec_m(BaseSrc): """ Magnetic source term - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: magnetic source term on mesh """ @@ -220,7 +220,7 @@ class RawVec(BaseSrc): """ Magnetic source term - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: magnetic source term on mesh """ @@ -232,7 +232,7 @@ class RawVec(BaseSrc): """ Electric source term - :param Problem prob: FDEM Problem + :param BaseFDEMProblem prob: FDEM Problem :rtype: numpy.ndarray :return: electric source term on mesh """ @@ -301,7 +301,7 @@ class MagDipole(BaseSrc): """ The primary magnetic flux density from a magnetic vector potential - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -339,7 +339,7 @@ class MagDipole(BaseSrc): """ The primary magnetic field from a magnetic vector potential - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -350,7 +350,7 @@ class MagDipole(BaseSrc): """ The magnetic source term - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -364,7 +364,7 @@ class MagDipole(BaseSrc): """ The electric source term - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -416,7 +416,7 @@ class MagDipole_Bfield(BaseSrc): """ The primary magnetic flux density from the analytic solution for magnetic fields from a dipole - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -455,7 +455,7 @@ class MagDipole_Bfield(BaseSrc): """ The primary magnetic field from a magnetic vector potential - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -466,7 +466,7 @@ class MagDipole_Bfield(BaseSrc): """ The magnetic source term - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -479,7 +479,7 @@ class MagDipole_Bfield(BaseSrc): """ The electric source term - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -530,7 +530,7 @@ class CircularLoop(BaseSrc): """ The primary magnetic flux density from a magnetic vector potential - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -567,7 +567,7 @@ class CircularLoop(BaseSrc): """ The primary magnetic field from a magnetic vector potential - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -578,7 +578,7 @@ class CircularLoop(BaseSrc): """ The magnetic source term - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ @@ -591,7 +591,7 @@ class CircularLoop(BaseSrc): """ The electric source term - :param Problem prob: FDEM problem + :param BaseFDEMProblem prob: FDEM problem :rtype: numpy.ndarray :return: primary magnetic field """ diff --git a/SimPEG/EM/TDEM/BaseTDEM.py b/SimPEG/EM/TDEM/BaseTDEM.py index 15fc19e3..cb93ab40 100644 --- a/SimPEG/EM/TDEM/BaseTDEM.py +++ b/SimPEG/EM/TDEM/BaseTDEM.py @@ -112,7 +112,7 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem): """ :param numpy.array m: Conductivity model :param numpy.ndarray v: vector (model object) - :param simpegEM.TDEM.FieldsTDEM f: Fields resulting from m + :param FieldsTDEM f: Fields resulting from m :rtype: numpy.ndarray :return: w (data object) @@ -136,8 +136,8 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem): def Jtvec(self, m, v, f=None): """ :param numpy.array m: Conductivity model - :param numpy.ndarray,SimPEG.Survey.Data v: vector (data object) - :param simpegEM.TDEM.FieldsTDEM u: Fields resulting from m + :param numpy.ndarray v: vector (or a :class:`SimPEG.Survey.Data` object) + :param FieldsTDEM u: Fields resulting from m :rtype: numpy.ndarray :return: w (model object) diff --git a/SimPEG/EM/TDEM/TDEM_b.py b/SimPEG/EM/TDEM/TDEM_b.py index cd38660c..f88066e0 100644 --- a/SimPEG/EM/TDEM/TDEM_b.py +++ b/SimPEG/EM/TDEM/TDEM_b.py @@ -87,8 +87,8 @@ class ProblemTDEM_b(BaseTDEMProblem): """ :param numpy.array m: Conductivity model :param numpy.array vec: vector (like a model) - :param simpegEM.TDEM.FieldsTDEM u: Fields resulting from m - :rtype: simpegEM.TDEM.FieldsTDEM + :param FieldsTDEM u: Fields resulting from m + :rtype: FieldsTDEM :return: f Multiply G by a vector @@ -125,9 +125,9 @@ class ProblemTDEM_b(BaseTDEMProblem): """ :param numpy.array m: Conductivity model :param numpy.array vec: vector (like a fields) - :param simpegEM.TDEM.FieldsTDEM u: Fields resulting from m - :rtype: np.ndarray (like a model) - :return: p + :param FieldsTDEM u: Fields resulting from m + :rtype: numpy.ndarray + :return: p (like a model) Multiply G.T by a vector """ @@ -153,8 +153,8 @@ class ProblemTDEM_b(BaseTDEMProblem): def solveAh(self, m, p): """ :param numpy.array m: Conductivity model - :param simpegEM.TDEM.FieldsTDEM p: Fields object - :rtype: simpegEM.TDEM.FieldsTDEM + :param FieldsTDEM p: Fields object + :rtype: FieldsTDEM :return: y Solve the block-matrix system \\\(\\\hat{A} \\\hat{y} = \\\hat{p}\\\): @@ -200,8 +200,8 @@ class ProblemTDEM_b(BaseTDEMProblem): def solveAht(self, m, p): """ :param numpy.array m: Conductivity model - :param simpegEM.TDEM.FieldsTDEM p: Fields object - :rtype: simpegEM.TDEM.FieldsTDEM + :param FieldsTDEM p: Fields object + :rtype: FieldsTDEM :return: y Solve the block-matrix system \\\(\\\hat{A}^\\\\top \\\hat{y} = \\\hat{p}\\\): @@ -270,8 +270,8 @@ class ProblemTDEM_b(BaseTDEMProblem): def _AhVec(self, m, vec): """ :param numpy.array m: Conductivity model - :param simpegEM.TDEM.FieldsTDEM vec: Fields object - :rtype: simpegEM.TDEM.FieldsTDEM + :param FieldsTDEM vec: Fields object + :rtype: FieldsTDEM :return: f Multiply the matrix \\\(\\\hat{A}\\\) by a fields vector where @@ -315,8 +315,8 @@ class ProblemTDEM_b(BaseTDEMProblem): def _AhtVec(self, m, vec): """ :param numpy.array m: Conductivity model - :param simpegEM.TDEM.FieldsTDEM vec: Fields object - :rtype: simpegEM.TDEM.FieldsTDEM + :param FieldsTDEM vec: Fields object + :rtype: FieldsTDEM :return: f Multiply the matrix \\\(\\\hat{A}\\\) by a fields vector where diff --git a/SimPEG/Examples/EM_Schenkel_Morrison_Casing.py b/SimPEG/Examples/EM_Schenkel_Morrison_Casing.py index c4306eb1..3e0b308c 100644 --- a/SimPEG/Examples/EM_Schenkel_Morrison_Casing.py +++ b/SimPEG/Examples/EM_Schenkel_Morrison_Casing.py @@ -19,10 +19,13 @@ def run(plotIt=True): Morrison Casing Model, and the results are used in a 2016 SEG abstract by Yang et al. - - Schenkel, C.J., and H.F. Morrison, 1990, Effects of well casing on potential field measurements using downhole current sources: Geophysical prospecting, 38, 663-686. + .. code-block:: text + + Schenkel, C.J., and H.F. Morrison, 1990, Effects of well casing on potential field measurements using downhole current sources: Geophysical prospecting, 38, 663-686. The model consists of: + - Air: Conductivity 1e-8 S/m, above z = 0 - Background: conductivity 1e-2 S/m, below z = 0 - Casing: conductivity 1e6 S/m diff --git a/SimPEG/FLOW/Richards/Empirical.py b/SimPEG/FLOW/Richards/Empirical.py index 1bb163b5..c6624e94 100644 --- a/SimPEG/FLOW/Richards/Empirical.py +++ b/SimPEG/FLOW/Richards/Empirical.py @@ -31,7 +31,7 @@ class NonLinearMap(object): """ :param numpy.array u: fields :param numpy.array m: model - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: derivative of transformed model The *transform* changes the model into the physical property. @@ -44,7 +44,7 @@ class NonLinearMap(object): """ :param numpy.array u: fields :param numpy.array m: model - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: derivative of transformed model The *transform* changes the model into the physical property. diff --git a/SimPEG/Mesh/BaseMesh.py b/SimPEG/Mesh/BaseMesh.py index ba2ce920..97394b68 100644 --- a/SimPEG/Mesh/BaseMesh.py +++ b/SimPEG/Mesh/BaseMesh.py @@ -34,7 +34,7 @@ class BaseMesh(object): """ Origin of the mesh - :rtype: numpy.array + :rtype: numpy.array :return: x0, (dim, ) """ return self._x0 @@ -116,7 +116,7 @@ class BaseMesh(object): """ Total number of edges in each direction - :rtype: numpy.array + :rtype: numpy.array :return: [nEx, nEy, nEz], (dim, ) .. plot:: @@ -200,7 +200,7 @@ class BaseMesh(object): """ Face Normals - :rtype: numpy.array + :rtype: numpy.array :return: normals, (sum(nF), dim) """ if self.dim == 2: @@ -218,7 +218,7 @@ class BaseMesh(object): """ Edge Tangents - :rtype: numpy.array + :rtype: numpy.array :return: normals, (sum(nE), dim) """ if self.dim == 2: @@ -297,7 +297,7 @@ class BaseRectangularMesh(BaseMesh): """ Total number of cells in each direction - :rtype: numpy.array (dim, ) + :rtype: numpy.array :return: [nCx, nCy, nCz] """ return np.array([x for x in [self.nCx, self.nCy, self.nCz] if not x is None]) @@ -337,7 +337,7 @@ class BaseRectangularMesh(BaseMesh): """ Total number of nodes in each direction - :rtype: numpy.array (dim, ) + :rtype: numpy.array :return: [nNx, nNy, nNz] """ return np.array([x for x in [self.nNx, self.nNy, self.nNz] if not x is None]) @@ -347,7 +347,7 @@ class BaseRectangularMesh(BaseMesh): """ Number of x-edges in each direction - :rtype: numpy.array (dim, ) + :rtype: numpy.array :return: vnEx """ return np.array([x for x in [self.nCx, self.nNy, self.nNz] if not x is None]) @@ -357,7 +357,7 @@ class BaseRectangularMesh(BaseMesh): """ Number of y-edges in each direction - :rtype: numpy.array (dim, ) + :rtype: numpy.array :return: vnEy or None if dim < 2 """ return None if self.dim < 2 else np.array([x for x in [self.nNx, self.nCy, self.nNz] if not x is None]) @@ -367,7 +367,7 @@ class BaseRectangularMesh(BaseMesh): """ Number of z-edges in each direction - :rtype: numpy.array (dim, ) + :rtype: numpy.array :return: vnEz or None if dim < 3 """ return None if self.dim < 3 else np.array([x for x in [self.nNx, self.nNy, self.nCz] if not x is None]) @@ -377,7 +377,7 @@ class BaseRectangularMesh(BaseMesh): """ Number of x-faces in each direction - :rtype: numpy.array (dim, ) + :rtype: numpy.array :return: vnFx """ return np.array([x for x in [self.nNx, self.nCy, self.nCz] if not x is None]) @@ -387,7 +387,7 @@ class BaseRectangularMesh(BaseMesh): """ Number of y-faces in each direction - :rtype: numpy.array (dim, ) + :rtype: numpy.array :return: vnFy or None if dim < 2 """ return None if self.dim < 2 else np.array([x for x in [self.nCx, self.nNy, self.nCz] if not x is None]) @@ -397,7 +397,7 @@ class BaseRectangularMesh(BaseMesh): """ Number of z-faces in each direction - :rtype: numpy.array (dim, ) + :rtype: numpy.array :return: vnFz or None if dim < 3 """ return None if self.dim < 3 else np.array([x for x in [self.nCx, self.nCy, self.nNz] if not x is None]) diff --git a/SimPEG/Mesh/InnerProducts.py b/SimPEG/Mesh/InnerProducts.py index 8415b7ad..0c08cdd3 100644 --- a/SimPEG/Mesh/InnerProducts.py +++ b/SimPEG/Mesh/InnerProducts.py @@ -115,12 +115,11 @@ class InnerProducts(object): :param bool doFast: do a faster implementation if available. :param bool invProp: inverts the material property :param bool invMat: inverts the matrix - :rtype: function :return: dMdmu(u), the derivative of the inner product matrix (u) Given u, dMdmu returns (nF, nC*nA) - :param np.ndarray u: vector that multiplies dMdmu + :param numpy.ndarray u: vector that multiplies dMdmu :rtype: scipy.sparse.csr_matrix :return: dMdmu, the derivative of the inner product matrix for a certain u """ diff --git a/SimPEG/Mesh/MeshIO.py b/SimPEG/Mesh/MeshIO.py index 1c042237..0810f973 100644 --- a/SimPEG/Mesh/MeshIO.py +++ b/SimPEG/Mesh/MeshIO.py @@ -6,13 +6,11 @@ class TensorMeshIO(object): @classmethod def readUBC(TensorMesh, fileName): """ - Read UBC GIF 3DTensor mesh and generate 3D Tensor mesh in simpegTD + Read UBC GIF 3D tensor mesh and generate 3D TensorMesh in SimPEG. - Input: - :param fileName, path to the UBC GIF mesh file - - Output: - :param SimPEG TensorMesh object + :param string fileName: path to the UBC GIF mesh file + :rtype: TensorMesh + :return: The tensor mesh for the fileName. """ # Interal function to read cell size lines for the UBC mesh files. @@ -48,11 +46,9 @@ class TensorMeshIO(object): Read VTK Rectilinear (vtr xml file) and return SimPEG Tensor mesh and model Input: - :param vtrFileName, path to the vtr model file to write to - - Output: - :return SimPEG TensorMesh object - :return SimPEG model dictionary + :param string fileName: path to the vtr model file to read + :rtype: tuple + :return: (TensorMesh, modelDictionary) """ # Import @@ -102,9 +98,8 @@ class TensorMeshIO(object): Makes and saves a VTK rectilinear file (vtr) for a simpeg Tensor mesh and model. Input: - :param str, path to the output vtk file - :param mesh, SimPEG TensorMesh object - mesh to be transfer to VTK - :param models, dictionary of numpy.array - Name('s) and array('s). Match number of cells + :param string fileName: path to the output vtk file + :param dict models: dictionary of numpy.array - Name('s) and array('s). Match number of cells """ # Import @@ -162,12 +157,9 @@ class TensorMeshIO(object): """ Read UBC 3DTensor mesh model and generate 3D Tensor mesh model in simpeg - Input: - :param fileName, path to the UBC GIF mesh file to read - :param mesh, TensorMesh object, mesh that coresponds to the model - - Output: - :return numpy array, model with TensorMesh ordered + :param string fileName: path to the UBC GIF mesh file to read + :rtype: numpy.ndarray + :return: model with TensorMesh ordered """ f = open(fileName, 'r') model = np.array(map(float, f.readlines())) @@ -183,8 +175,7 @@ class TensorMeshIO(object): Writes a model associated with a SimPEG TensorMesh to a UBC-GIF format model file. - :param str fileName: File to write to - :param simpeg.Mesh.TensorMesh mesh: The mesh + :param string fileName: File to write to :param numpy.ndarray model: The model """ @@ -201,8 +192,8 @@ class TensorMeshIO(object): """ Writes a SimPEG TensorMesh to a UBC-GIF format mesh file. - :param str fileName: File to write to - :param simpeg.Mesh.TensorMesh mesh: The mesh + :param string fileName: File to write to + :param dict models: A dictionary of the models """ assert mesh.dim == 3 @@ -231,9 +222,8 @@ class TreeMeshIO(object): """ Write UBC ocTree mesh and model files from a simpeg ocTree mesh and model. - :param str fileName: File to write to - :param simpeg.Mesh.TreeMesh mesh: The mesh - :param dictionary models: The models in a dictionary, where the keys is the name of the of the model file + :param string fileName: File to write to + :param dict models: The models in a dictionary, where the keys is the name of the of the model file """ # Calculate information to write in the file. @@ -286,10 +276,9 @@ class TreeMeshIO(object): Input: :param str meshFile: path to the UBC GIF OcTree mesh file to read + :rtype: SimPEG.Mesh.TreeMesh + :return: The octree mesh - Output: - :return SimPEG.Mesh.TreeMesh mesh: The octree mesh - :return list of ndarray's: models as a list of numpy array's """ ## Read the file lines @@ -335,11 +324,9 @@ class TreeMeshIO(object): """ Read UBC OcTree model and get vector - Input: - :param fileName, path to the UBC GIF model file to read - - Output: - :return numpy array, OcTree model + :param string fileName: path to the UBC GIF model file to read + :rtype: numpy.ndarray + :return: OcTree model """ if type(fileName) is list: diff --git a/SimPEG/Mesh/TensorMesh.py b/SimPEG/Mesh/TensorMesh.py index 1650b5cb..65b6d7e9 100644 --- a/SimPEG/Mesh/TensorMesh.py +++ b/SimPEG/Mesh/TensorMesh.py @@ -198,8 +198,8 @@ class BaseTensorMesh(BaseMesh): Determines if a set of points are inside a mesh. :param numpy.ndarray pts: Location of points to test - :rtype numpy.ndarray - :return inside, numpy array of booleans + :rtype numpy.ndarray: + :return: inside, numpy array of booleans """ pts = Utils.asArray_N_x_Dim(pts, self.dim) @@ -221,7 +221,7 @@ class BaseTensorMesh(BaseMesh): :param numpy.ndarray loc: Location of points to interpolate to :param str locType: What to interpolate (see below) - :rtype: scipy.sparse.csr.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: M, the interpolation matrix locType can be:: @@ -289,7 +289,7 @@ class BaseTensorMesh(BaseMesh): :param bool returnP: returns the projection matrices :param bool invProp: inverts the material property :param bool invMat: inverts the matrix - :rtype: scipy.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: M, the inner product matrix (nF, nF) """ assert projType in ['F', 'E'], "projType must be 'F' for faces or 'E' for edges" diff --git a/SimPEG/Mesh/View.py b/SimPEG/Mesh/View.py index 569e0392..fe062b1b 100644 --- a/SimPEG/Mesh/View.py +++ b/SimPEG/Mesh/View.py @@ -560,7 +560,7 @@ class CurvView(object): :include-source: from SimPEG import Mesh, Utils - X, Y = Utils.exampleCurvGird([3,3],'rotate') + X, Y = Utils.meshutils.exampleLrmGrid([3,3],'rotate') M = Mesh.CurvilinearMesh([X, Y]) M.plotGrid(showIt=True) diff --git a/SimPEG/Optimization.py b/SimPEG/Optimization.py index 77704733..706124c8 100644 --- a/SimPEG/Optimization.py +++ b/SimPEG/Optimization.py @@ -131,7 +131,7 @@ class Minimize(object): Minimizes the function (evalFunction) starting at the location x0. - :param def evalFunction: function handle that evaluates: f, g, H = F(x) + :param callable evalFunction: function handle that evaluates: f, g, H = F(x) :param numpy.ndarray x0: starting location :rtype: numpy.ndarray :return: x, the last iterate of the optimization algorithm @@ -372,8 +372,8 @@ class Minimize(object): Else, a modifySearchDirectionBreak call is preformed. :param numpy.ndarray p: searchDirection - :rtype: numpy.ndarray,bool - :return: (xt, passLS) + :rtype: tuple + :return: (xt, passLS) numpy.ndarray, bool """ # Projected Armijo linesearch self._LS_t = 1 @@ -408,8 +408,8 @@ class Minimize(object): evalFunction returns a False indicating the break was not caught. :param numpy.ndarray p: searchDirection - :rtype: numpy.ndarray,bool - :return: (xt, breakCaught) + :rtype: tuple + :return: (xt, breakCaught) numpy.ndarray, bool """ self.printDone(inLS=True) print 'The linesearch got broken. Boo.' diff --git a/SimPEG/PropMaps.py b/SimPEG/PropMaps.py index e4f65973..34cad863 100644 --- a/SimPEG/PropMaps.py +++ b/SimPEG/PropMaps.py @@ -187,7 +187,7 @@ class _PropMapMetaClass(type): attrs[attr + 'Model'] = prop._getModelProperty() attrs[attr + 'Deriv'] = prop._getModelDerivProperty() - return type(name.replace('PropMap', 'PropModel'), (PropModel, ), attrs) + return type('PropModel', (PropModel, ), attrs) class PropMap(object): diff --git a/SimPEG/Regularization.py b/SimPEG/Regularization.py index fc101a61..96beabcb 100644 --- a/SimPEG/Regularization.py +++ b/SimPEG/Regularization.py @@ -8,7 +8,7 @@ class RegularizationMesh(object): are not necessarily true differential operators, but are constructed from a SimPEG Mesh. - :param Mesh mesh: problem mesh + :param BaseMesh mesh: problem mesh :param numpy.array indActive: bool array, size nC, that is True where we have active cells. Used to reduce the operators so we regularize only on active cells """ @@ -381,8 +381,8 @@ class BaseRegularization(object): :param numpy.array m: geophysical model :param numpy.array v: vector to multiply - :rtype: scipy.sparse.csr_matrix or numpy.ndarray - :return: WtW or WtW*v + :rtype: scipy.sparse.csr_matrix + :return: WtW, or if v is supplied WtW*v (numpy.ndarray) The regularization is: @@ -417,8 +417,8 @@ class Tikhonov(BaseRegularization): Note if the key word argument `mrefInSmooth` is False, then mref is not included in the smoothness contribution. - :param Mesh mesh: SimPEG mesh - :param Maps mapping: regularization mapping, takes the model from model space to the thing you want to regularize + :param BaseMesh mesh: SimPEG mesh + :param IdentityMap mapping: regularization mapping, takes the model from model space to the thing you want to regularize :param numpy.ndarray indActive: active cell indices for reducing the size of differential operators in the definition of a regularization mesh :param bool mrefInSmooth: (default = False) put mref in the smoothness component? :param float alpha_s: (default 1e-6) smallness weight @@ -438,7 +438,7 @@ class Tikhonov(BaseRegularization): alpha_yy = Utils.dependentProperty('_alpha_yy', 0.0, ['_W', '_Wyy'], "Weight for the second derivative in the y direction") alpha_zz = Utils.dependentProperty('_alpha_zz', 0.0, ['_W', '_Wzz'], "Weight for the second derivative in the z direction") - def __init__(self, mesh, mapping=None, indActive = None, **kwargs): + def __init__(self, mesh, mapping=None, indActive=None, **kwargs): BaseRegularization.__init__(self, mesh, mapping=mapping, indActive=indActive, **kwargs) @property diff --git a/SimPEG/Tests.py b/SimPEG/Tests.py index 804ca6b8..ea7a74e1 100644 --- a/SimPEG/Tests.py +++ b/SimPEG/Tests.py @@ -237,7 +237,7 @@ def checkDerivative(fctn, x0, num=7, plotIt=True, dx=None, expectedOrder=2, tole Compares error decay of 0th and 1st order Taylor approximation at point x0 for a randomized search direction. - :param lambda fctn: function handle + :param callable fctn: function handle :param numpy.array x0: point at which to check derivative :param int num: number of times to reduce step length, h :param bool plotIt: if you would like to plot diff --git a/SimPEG/Utils/ModelBuilder.py b/SimPEG/Utils/ModelBuilder.py index 1b868fe5..1f4aa47f 100644 --- a/SimPEG/Utils/ModelBuilder.py +++ b/SimPEG/Utils/ModelBuilder.py @@ -7,11 +7,11 @@ def addBlock(gridCC, modelCC, p0, p1, blockProp): """ Add a block to an exsisting cell centered model, modelCC - :param numpy.array, gridCC: mesh.gridCC is the cell centered grid - :param numpy.array, modelCC: cell centered model - :param numpy.array, p0: bottom, southwest corner of block - :param numpy.array, p1: top, northeast corner of block - :blockProp float, blockProp: property to assign to the model + :param numpy.array gridCC: mesh.gridCC is the cell centered grid + :param numpy.array modelCC: cell centered model + :param numpy.array p0: bottom, southwest corner of block + :param numpy.array p1: top, northeast corner of block + :blockProp float blockProp: property to assign to the model :return numpy.array, modelBlock: model with block """ @@ -147,7 +147,7 @@ def getIndicesSphere(center,radius,ccMesh): if dimMesh == 1: # Define the reference points - + ind = np.abs(center[0] - ccMesh[:,0]) < radius elif dimMesh == 2: @@ -222,14 +222,14 @@ def layeredModel(ccMesh, layerTops, layerValues): :param numpy.array ccMesh: cell-centered mesh :param numpy.array layerTops: z-locations of the tops of each layer - :param numpy.array layerValue: values of the property to assign for each layer (starting at the top) + :param numpy.array layerValue: values of the property to assign for each layer (starting at the top) :rtype: numpy.array - :return: M, layered model on the mesh + :return: M, layered model on the mesh """ descending = np.linalg.norm(sorted(layerTops, reverse=True) - layerTops) < 1e-20 - # TODO: put an error check to make sure that there is an ordering... needs to work with inf elts + # TODO: put an error check to make sure that there is an ordering... needs to work with inf elts # assert ascending or descending, "Layers must be listed in either ascending or descending order" # start from bottom up @@ -253,10 +253,10 @@ def layeredModel(ccMesh, layerTops, layerValues): model = np.zeros(ccMesh.shape[0]) for i, top in enumerate(layerTops): - zind = z <= top + zind = z <= top model[zind] = layerValues[i] - return model + return model @@ -265,9 +265,9 @@ def randomModel(shape, seed=None, anisotropy=None, its=100, bounds=None): Create a random model by convolving a kernel with a uniformly distributed model. - :param int,tuple shape: shape of the model. + :param tuple shape: shape of the model. :param int seed: pick which model to produce, prints the seed if you don't choose. - :param numpy.ndarray,list anisotropy: this is the (3 x n) blurring kernel that is used. + :param numpy.ndarray anisotropy: this is the (3 x n) blurring kernel that is used. :param int its: number of smoothing iterations :param list bounds: bounds on the model, len(list) == 2 :rtype: numpy.ndarray diff --git a/SimPEG/Utils/SolverUtils.py b/SimPEG/Utils/SolverUtils.py index 47c899d3..28a1159d 100644 --- a/SimPEG/Utils/SolverUtils.py +++ b/SimPEG/Utils/SolverUtils.py @@ -13,7 +13,7 @@ def _checkAccuracy(A, b, X, accuracyTol): warnings.warn(msg, RuntimeWarning) -def SolverWrapD(fun, factorize=True, checkAccuracy=True, accuracyTol=1e-6): +def SolverWrapD(fun, factorize=True, checkAccuracy=True, accuracyTol=1e-6, name=None): """ Wraps a direct Solver. @@ -72,11 +72,11 @@ def SolverWrapD(fun, factorize=True, checkAccuracy=True, accuracyTol=1e-6): if factorize and hasattr(self.solver, 'clean'): return self.solver.clean() - return type(fun.__name__+'_Wrapped', (object,), {"__init__": __init__, "clean": clean, "__mul__": __mul__}) + return type(name if name is not None else fun.__name__, (object,), {"__init__": __init__, "clean": clean, "__mul__": __mul__}) -def SolverWrapI(fun, checkAccuracy=True, accuracyTol=1e-5): +def SolverWrapI(fun, checkAccuracy=True, accuracyTol=1e-5, name=None): """ Wraps an iterative Solver. @@ -128,13 +128,13 @@ def SolverWrapI(fun, checkAccuracy=True, accuracyTol=1e-5): def clean(self): pass - return type(fun.__name__+'_Wrapped', (object,), {"__init__": __init__, "clean": clean, "__mul__": __mul__}) + return type(name if name is not None else fun.__name__, (object,), {"__init__": __init__, "clean": clean, "__mul__": __mul__}) from scipy.sparse import linalg -Solver = SolverWrapD(linalg.spsolve, factorize=False) -SolverLU = SolverWrapD(linalg.splu, factorize=True) -SolverCG = SolverWrapI(linalg.cg) +Solver = SolverWrapD(linalg.spsolve, factorize=False, name="Solver") +SolverLU = SolverWrapD(linalg.splu, factorize=True, name="SolverLU") +SolverCG = SolverWrapI(linalg.cg, name="SolverCG") class SolverDiag(object): diff --git a/SimPEG/Utils/interputils.py b/SimPEG/Utils/interputils.py index 17b9b469..16c7bf5e 100644 --- a/SimPEG/Utils/interputils.py +++ b/SimPEG/Utils/interputils.py @@ -25,7 +25,7 @@ def interpmat(locs, x, y=None, z=None): :param numpy.ndarray x: Tensor vector of 1st dimension of grid. :param numpy.ndarray y: Tensor vector of 2nd dimension of grid. None by default. :param numpy.ndarray z: Tensor vector of 3rd dimension of grid. None by default. - :rtype: scipy.sparse.csr.csr_matrix + :rtype: scipy.sparse.csr_matrix :return: Interpolation matrix .. plot:: diff --git a/SimPEG/Utils/matutils.py b/SimPEG/Utils/matutils.py index 3a6030fa..73f414b3 100644 --- a/SimPEG/Utils/matutils.py +++ b/SimPEG/Utils/matutils.py @@ -27,7 +27,7 @@ def mkvc(x, numDims=1): if isinstance(x, Zero): return x - + assert isinstance(x, np.ndarray), "Vector must be a numpy array" if numDims == 1: @@ -355,9 +355,9 @@ def diagEst(matFun, n, k=None, approach='Probing'): 2. Ones : random +/- 1 entries 3. Random : random vectors - :param lambda (numpy.array) matFun: matrix to estimate the diagonal of - :param int64 n: size of the vector that should be used to compute matFun(v) - :param int64 k: number of vectors to be used to estimate the diagonal + :param callable matFun: takes a (numpy.array) and multiplies it by a matrix to estimate the diagonal + :param int n: size of the vector that should be used to compute matFun(v) + :param int k: number of vectors to be used to estimate the diagonal :param str approach: approach to be used for getting vectors :rtype: numpy.array :return: est_diag(A) @@ -422,9 +422,9 @@ class Zero(object): def __ge__(self, v):return 0 >= v def __gt__(self, v):return 0 > v - @property + @property def transpose(self): return Zero() - + @property def T(self): return Zero() diff --git a/SimPEG/Utils/meshutils.py b/SimPEG/Utils/meshutils.py index 53cda719..c7ec1efd 100644 --- a/SimPEG/Utils/meshutils.py +++ b/SimPEG/Utils/meshutils.py @@ -83,7 +83,7 @@ def closestPoints(mesh, pts, gridLoc='CC'): """ Move a list of points to the closest points on a grid. - :param simpeg.Mesh.BaseMesh mesh: The mesh + :param BaseMesh mesh: The mesh :param numpy.ndarray pts: Points to move :param string gridLoc: ['CC', 'N', 'Fx', 'Fy', 'Fz', 'Ex', 'Ex', 'Ey', 'Ez'] :rtype: numpy.ndarray @@ -107,7 +107,7 @@ def ExtractCoreMesh(xyzlim, mesh, meshType='tensor'): Extracts Core Mesh from Global mesh :param numpy.ndarray xyzlim: 2D array [ndim x 2] - :param simpeg.Mesh.BaseMesh mesh: The mesh + :param BaseMesh mesh: The mesh This function ouputs:: diff --git a/docs/Makefile b/docs/Makefile index bee80244..6d8d03df 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,7 +2,7 @@ # # You can set these variables from the command line. -SPHINXOPTS = +SPHINXOPTS = -n -w warnings.txt SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build diff --git a/docs/api_ForwardProblem.rst b/docs/api_ForwardProblem.rst index efefedc9..250a3618 100644 --- a/docs/api_ForwardProblem.rst +++ b/docs/api_ForwardProblem.rst @@ -67,13 +67,45 @@ The API Problem ------- -.. autoclass:: SimPEG.Problem + +.. autoclass:: SimPEG.Problem.BaseProblem + :members: + :undoc-members: + +.. autoclass:: SimPEG.Problem.BaseTimeProblem + :members: + :undoc-members: + +Fields +------ + +.. autoclass:: SimPEG.Fields.Fields + :members: + :undoc-members: + +.. autoclass:: SimPEG.Fields.TimeFields :members: :undoc-members: Survey ------ -.. autoclass:: SimPEG.Survey + +.. autoclass:: SimPEG.Survey.BaseSurvey :members: :undoc-members: +.. autoclass:: SimPEG.Survey.BaseSrc + :members: + :undoc-members: + +.. autoclass:: SimPEG.Survey.BaseRx + :members: + :undoc-members: + +.. autoclass:: SimPEG.Survey.BaseTimeRx + :members: + :undoc-members: + +.. autoclass:: SimPEG.Survey.Data + :members: + :undoc-members: diff --git a/docs/api_InnerProducts.rst b/docs/api_InnerProducts.rst index a57a4c91..13d532eb 100644 --- a/docs/api_InnerProducts.rst +++ b/docs/api_InnerProducts.rst @@ -266,6 +266,6 @@ These are computed for each of the 8 projections, horizontally concatenated, and The API ------- -.. autoclass:: SimPEG.Mesh.InnerProducts +.. autoclass:: SimPEG.Mesh.InnerProducts.InnerProducts :members: :undoc-members: diff --git a/docs/api_Inversion.rst b/docs/api_Inversion.rst index ec98ba0d..a20924cc 100644 --- a/docs/api_Inversion.rst +++ b/docs/api_Inversion.rst @@ -3,7 +3,7 @@ InvProblem ********** -.. autoclass:: SimPEG.InvProblem +.. autoclass:: SimPEG.InvProblem.BaseInvProblem :show-inheritance: :members: :undoc-members: @@ -12,7 +12,7 @@ InvProblem Inversion ********* -.. autoclass:: SimPEG.Inversion +.. autoclass:: SimPEG.Inversion.BaseInversion :show-inheritance: :members: :undoc-members: @@ -20,7 +20,7 @@ Inversion Directives ********** -.. autoclass:: SimPEG.Directives +.. automodule:: SimPEG.Directives :show-inheritance: :members: :undoc-members: diff --git a/docs/api_Maps.rst b/docs/api_Maps.rst index 887f42ef..a5de8a2f 100644 --- a/docs/api_Maps.rst +++ b/docs/api_Maps.rst @@ -124,6 +124,8 @@ When these are used in the inverse problem, this is extremely important!! The API ======= +The :code:`IdentityMap` is the base class for all mappings, and it does absolutely nothing. + .. autoclass:: SimPEG.Maps.IdentityMap :members: :undoc-members: @@ -132,7 +134,6 @@ The API Common Maps =========== - Exponential Map --------------- @@ -198,8 +199,8 @@ Mesh to Mesh Map :undoc-members: -Some Extras -=========== +Under the Hood +============== Combo Map --------- diff --git a/docs/api_Mesh.rst b/docs/api_Mesh.rst index 1043703b..93767ee2 100644 --- a/docs/api_Mesh.rst +++ b/docs/api_Mesh.rst @@ -188,6 +188,6 @@ other types of meshes in this SimPEG framework. The API ======= -.. autoclass:: SimPEG.Mesh.BaseMesh +.. autoclass:: SimPEG.Mesh.BaseMesh.BaseMesh :members: :undoc-members: diff --git a/docs/api_MeshCode.rst b/docs/api_MeshCode.rst index aab8a849..39f168a1 100644 --- a/docs/api_MeshCode.rst +++ b/docs/api_MeshCode.rst @@ -19,7 +19,7 @@ Cylindrical Mesh Tree Mesh ========= -.. autoclass:: SimPEG.Mesh.TreeMesh.TreeMesh +.. autoclass:: SimPEG.Mesh.TreeMesh :members: :undoc-members: :show-inheritance: @@ -30,4 +30,39 @@ Curvilinear Mesh .. autoclass:: SimPEG.Mesh.CurvilinearMesh :members: :undoc-members: - :show-inheritance: \ No newline at end of file + :show-inheritance: + + +Base Rectangular Mesh +===================== + +.. autoclass:: SimPEG.Mesh.BaseMesh.BaseRectangularMesh + :members: + :undoc-members: + :show-inheritance: + +Base Tensor Mesh +================ + +.. autoclass:: SimPEG.Mesh.TensorMesh.BaseTensorMesh + :members: + :undoc-members: + :show-inheritance: + + +Mesh IO +======= + +.. automodule:: SimPEG.Mesh.MeshIO + :members: + :undoc-members: + :show-inheritance: + + +Mesh Viewing +============ + +.. automodule:: SimPEG.Mesh.View + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/api_PropMaps.rst b/docs/api_PropMaps.rst new file mode 100644 index 00000000..1d0f951d --- /dev/null +++ b/docs/api_PropMaps.rst @@ -0,0 +1,29 @@ +SimPEG PropMaps +*************** + +The API +======= + +Property +-------- + +.. autoclass:: SimPEG.PropMaps.Property + :members: + :undoc-members: + + +PropMap +------- + +.. autoclass:: SimPEG.PropMaps.PropMap + :members: + :undoc-members: + + +PropModel +--------- + +.. autoclass:: SimPEG.PropMaps.PropModel + :members: + :undoc-members: + diff --git a/docs/api_Utilities.rst b/docs/api_Utilities.rst index c3a08b30..2f03c54e 100644 --- a/docs/api_Utilities.rst +++ b/docs/api_Utilities.rst @@ -6,5 +6,6 @@ Utilities api_Solver api_Maps + api_PropMaps api_Utils api_Tests diff --git a/docs/api_bigPicture.rst b/docs/api_bigPicture.rst index 90266650..e24037ab 100644 --- a/docs/api_bigPicture.rst +++ b/docs/api_bigPicture.rst @@ -51,9 +51,9 @@ There are an overwhelming amount of choices to be made as one works through the :alt: Framework :align: center -The process of obtaining an acceptable model from an inversion generally requires the geophysicist to perform several iterations of the inversion workflow, rethinking and redesigning each piece of the framework to ensure it is appropriate in the current context. Inversions are experimental and empirical by nature and our software package is designed to facilitate this iterative process. To accomplish this, we have divided the inversion methodology into eight major components (See figure above). The (:class:`SimPEG.Mesh.BaseMesh`) class handles the discretization of the earth and also provides numerical operators. The forward simulation is split into two classes, the (:class:`SimPEG.Survey.BaseSurvey`) and the (:class:`SimPEG.Problem.BaseProblem`). The (:class:`SimPEG.Survey.BaseSurvey`) class handles the geometry of a geophysical problem as well as sources. The (:class:`SimPEG.Problem.BaseProblem`) class handles the simulation of the physics for the geophysical problem of interest. Although created independently, these two classes must be paired to form all of the components necessary for a geophysical forward simulation and calculation of the sensitivity. The (:class:`SimPEG.Problem.BaseProblem`) creates geophysical fields given a source from the (:class:`SimPEG.Survey.BaseSurvey`). The (:class:`SimPEG.Survey.BaseSurvey`) interpolates these fields to the receiver locations and converts them to the appropriate data type, for example, by selecting only the measured components of the field. Each of these operations may have associated derivatives with respect to the model and the computed field; these are included in the calculation of the sensitivity. For the inversion, a (:class:`SimPEG.DataMisfit.BaseDataMisfit`) is chosen to capture the goodness of fit of the predicted data and a (:class:`SimPEG.Regularization.BaseRegularization`) is chosen to handle the non-uniqueness. These inversion elements and an Optimization routine are combined into an inverse problem class (:class:`SimPEG.InvProblem.BaseInvProblem`). (:class:`SimPEG.InvProblem.BaseInvProblem`) is the mathematical statement that will be numerically solved by running an Inversion. The (:class:`SimPEG.Inversion.BaseInversion`) class handles organization and dispatch of directives between all of the various pieces of the framework. +The process of obtaining an acceptable model from an inversion generally requires the geophysicist to perform several iterations of the inversion workflow, rethinking and redesigning each piece of the framework to ensure it is appropriate in the current context. Inversions are experimental and empirical by nature and our software package is designed to facilitate this iterative process. To accomplish this, we have divided the inversion methodology into eight major components (See figure above). The :class:`SimPEG.Mesh.BaseMesh.BaseMesh` class handles the discretization of the earth and also provides numerical operators. The forward simulation is split into two classes, the :class:`SimPEG.Survey.BaseSurvey` and the :class:`SimPEG.Problem.BaseProblem`. The :class:`SimPEG.Survey.BaseSurvey` class handles the geometry of a geophysical problem as well as sources. The :class:`SimPEG.Problem.BaseProblem` class handles the simulation of the physics for the geophysical problem of interest. Although created independently, these two classes must be paired to form all of the components necessary for a geophysical forward simulation and calculation of the sensitivity. The :class:`SimPEG.Problem.BaseProblem` creates geophysical fields given a source from the :class:`SimPEG.Survey.BaseSurvey`. The :class:`SimPEG.Survey.BaseSurvey` interpolates these fields to the receiver locations and converts them to the appropriate data type, for example, by selecting only the measured components of the field. Each of these operations may have associated derivatives with respect to the model and the computed field; these are included in the calculation of the sensitivity. For the inversion, a :class:`SimPEG.DataMisfit.BaseDataMisfit` is chosen to capture the goodness of fit of the predicted data and a :class:`SimPEG.Regularization.BaseRegularization` is chosen to handle the non-uniqueness. These inversion elements and an Optimization routine are combined into an inverse problem class :class:`SimPEG.InvProblem.BaseInvProblem`. :class:`SimPEG.InvProblem.BaseInvProblem` is the mathematical statement that will be numerically solved by running an Inversion. The :class:`SimPEG.Inversion.BaseInversion` class handles organization and dispatch of directives between all of the various pieces of the framework. -The arrows in the figure above indicate what each class takes as a primary argument. For example, both the (:class:`SimPEG.Problem.BaseProblem`) and (:class:`SimPEG.Regularization.BaseRegularization`) classes take a (:class:`SimPEG.Mesh.BaseMesh`) class as an argument. The diagram does not show class inheritance, as each of the base classes outlined have many subtypes that can be interchanged. The (:class:`SimPEG.Mesh.BaseMesh`) class, for example, could be a regular Cartesian mesh (:class:`SimPEG.Mesh.TensorMesh`) or a cylindrical coordinate mesh (:class:`SimPEG.Mesh.CylMesh`), which have many properties in common. These common features, such as both meshes being created from tensor products, can be exploited through inheritance of base classes, and differences can be expressed through subtype polymorphism. Please look at the documentation here for more in-depth information. +The arrows in the figure above indicate what each class takes as a primary argument. For example, both the :class:`SimPEG.Problem.BaseProblem` and :class:`SimPEG.Regularization.BaseRegularization` classes take a :class:`SimPEG.Mesh.BaseMesh.BaseMesh` class as an argument. The diagram does not show class inheritance, as each of the base classes outlined have many subtypes that can be interchanged. The :class:`SimPEG.Mesh.BaseMesh.BaseMesh` class, for example, could be a regular Cartesian mesh :class:`SimPEG.Mesh.TensorMesh` or a cylindrical coordinate mesh :class:`SimPEG.Mesh.CylMesh`, which have many properties in common. These common features, such as both meshes being created from tensor products, can be exploited through inheritance of base classes, and differences can be expressed through subtype polymorphism. Please look at the documentation here for more in-depth information. .. include:: ../CITATION.rst diff --git a/docs/conf.py b/docs/conf.py index d9bcfae7..2db771bf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -269,3 +269,24 @@ def _supress_nonlocal_image_warn(self, msg, node): self._warnfunc(msg, '%s:%s' % get_source_line(node)) supress_nonlocal_image_warn() + + +nitpick_ignore = [ + ('py:class', 'IdentityMap'), + ('py:class', 'BaseSurvey'), + ('py:class', 'BaseSrc'), + ('py:class', 'BaseRx'), + ('py:class', 'Survey'), + ('py:class', 'FieldsFDEM'), + ('py:class', 'Fields3D_e'), + ('py:class', 'Fields3D_b'), + ('py:class', 'Fields3D_j'), + ('py:class', 'Fields3D_h'), + ('py:class', 'SurveyTDEM'), + ('py:class', 'SrcTDEM'), + ('py:class', 'EMPropMap'), + ('py:class', 'Data'), + ('py:class', 'SurveyDC'), + ('py:class', 'BaseMTFields'), + ('py:class', 'SolverLU'), +] diff --git a/docs/em/api_TDEM.rst b/docs/em/api_TDEM.rst index fe3dc613..4944ca52 100644 --- a/docs/em/api_TDEM.rst +++ b/docs/em/api_TDEM.rst @@ -359,7 +359,7 @@ TDEM - B formulation Field Storage ============= -.. autoclass:: SimPEG.EM.TDEM.SurveyTDEM.FieldsTDEM +.. autoclass:: SimPEG.EM.TDEM.BaseTDEM.FieldsTDEM :show-inheritance: :members: :undoc-members: diff --git a/docs/em/api_basic.rst b/docs/em/api_basic.rst new file mode 100644 index 00000000..1113108c --- /dev/null +++ b/docs/em/api_basic.rst @@ -0,0 +1,33 @@ +Overview of Electromagnetics in SimPEG +************************************** + + +The API +======= + +Physical Properties +------------------- + +.. autoclass:: SimPEG.EM.Base.EMPropMap + :show-inheritance: + :members: + :undoc-members: + +Problem +------- + +.. autoclass:: SimPEG.EM.Base.BaseEMProblem + :show-inheritance: + :members: + :undoc-members: + + +Survey +------ + +.. autoclass:: SimPEG.EM.Base.BaseEMSurvey + :show-inheritance: + :members: + :undoc-members: + + diff --git a/docs/em/index.rst b/docs/em/index.rst index a86ebb69..4f95a339 100644 --- a/docs/em/index.rst +++ b/docs/em/index.rst @@ -3,13 +3,13 @@ Electromagnetics ================ `SimPEG.EM` uses SimPEG as the framework for the forward and inverse -electromagnetics geophysical problems. +electromagnetics geophysical problems. To solve for predicted data, we follow the framework shown below. The model is what we invert for. This is mapped to a physical property on the simulation mesh. A source which is used to excite the system is specified. Having a model and a source, we can solve Maxwell's equations for fields. We sample these -fields with recievers to give us predicted data. +fields with recievers to give us predicted data. .. image:: ../images/simpegEM_noMath.png @@ -19,6 +19,7 @@ fields with recievers to give us predicted data. .. toctree:: :maxdepth: 2 + api_basic api_FDEM api_TDEM api_Utils diff --git a/docs/examples/EM_Schenkel_Morrison_Casing.rst b/docs/examples/EM_Schenkel_Morrison_Casing.rst index 55f00168..5ff3432e 100644 --- a/docs/examples/EM_Schenkel_Morrison_Casing.rst +++ b/docs/examples/EM_Schenkel_Morrison_Casing.rst @@ -17,10 +17,13 @@ current inside a steel-cased. The model is based on the Schenkel and Morrison Casing Model, and the results are used in a 2016 SEG abstract by Yang et al. -- Schenkel, C.J., and H.F. Morrison, 1990, Effects of well casing on potential field measurements using downhole current sources: Geophysical prospecting, 38, 663-686. +.. code-block:: text + + Schenkel, C.J., and H.F. Morrison, 1990, Effects of well casing on potential field measurements using downhole current sources: Geophysical prospecting, 38, 663-686. The model consists of: + - Air: Conductivity 1e-8 S/m, above z = 0 - Background: conductivity 1e-2 S/m, below z = 0 - Casing: conductivity 1e6 S/m diff --git a/tests/docs/test_docs.py b/tests/docs/test_docs.py index 4bd10d6c..9b986632 100644 --- a/tests/docs/test_docs.py +++ b/tests/docs/test_docs.py @@ -13,9 +13,9 @@ class Doc_Test(unittest.TestCase): doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) html_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['html']) - check = subprocess.call(["sphinx-build", "-nW", "-b", "html", "-d", - "%s"%(doctrees_path) , - "%s"%(self.path_to_docs), + check = subprocess.call(["sphinx-build", "-nW", "-b", "html", "-d", + "%s"%(doctrees_path) , + "%s"%(self.path_to_docs), "%s"%(html_path)]) assert check == 0 @@ -23,9 +23,9 @@ class Doc_Test(unittest.TestCase): # doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) # latex_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['latex']) - # check = subprocess.call(["sphinx-build", "-nW", "-b", "latex", "-d", - # "%s"%(doctrees_path), - # "%s"%(self.path_to_docs), + # check = subprocess.call(["sphinx-build", "-nW", "-b", "latex", "-d", + # "%s"%(doctrees_path), + # "%s"%(self.path_to_docs), # "%s"%(latex_path)]) # assert check == 0 @@ -33,11 +33,11 @@ class Doc_Test(unittest.TestCase): # doctrees_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']+['doctrees']) # link_path = os.path.sep.join(self.path_to_docs.split(os.path.sep) + ['_build']) - # check = subprocess.call(["sphinx-build", "-nW", "-b", "linkcheck", "-d", - # "%s"%(doctrees_path), - # "%s"%(self.path_to_docs), + # check = subprocess.call(["sphinx-build", "-nW", "-b", "linkcheck", "-d", + # "%s"%(doctrees_path), + # "%s"%(self.path_to_docs), # "%s"%(link_path)]) - # assert check == 0 + # assert check == 0 if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() From 5e8d3fbc782e7286cfa7d15602c322651fcbcada Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Mon, 30 May 2016 17:06:29 -0700 Subject: [PATCH 50/77] organizing the docs - put the content in a `content` folder. put the SimPEG core api docs in `core_api` --- SimPEG/Examples/__init__.py | 6 +- docs/api_FiniteVolume.rst | 19 ----- .../{ => content/api_core}/api_DataMisfit.rst | 0 docs/{ => content/api_core}/api_DiffOps.rst | 0 docs/{ => content/api_core}/api_Examples.rst | 2 +- docs/content/api_core/api_FiniteVolume.rst | 27 +++++++ .../api_core}/api_ForwardProblem.rst | 6 +- .../api_core}/api_InnerProducts.rst | 72 +++++++++++++----- docs/{ => content/api_core}/api_Inversion.rst | 0 .../api_core}/api_InversionComponents.rst | 0 docs/{ => content/api_core}/api_Maps.rst | 0 docs/{ => content/api_core}/api_Mesh.rst | 0 docs/{ => content/api_core}/api_MeshCode.rst | 0 .../api_core}/api_Optimization.rst | 0 docs/{ => content/api_core}/api_PropMaps.rst | 0 .../api_core}/api_Regularization.rst | 0 docs/{ => content/api_core}/api_Solver.rst | 0 docs/{ => content/api_core}/api_Tests.rst | 0 docs/{ => content/api_core}/api_Utilities.rst | 0 docs/{ => content/api_core}/api_Utils.rst | 0 .../{ => content/api_core}/api_bigPicture.rst | 10 +-- .../{ => content/api_core}/api_installing.rst | 0 docs/{ => content}/dc/index.rst | 0 docs/{ => content}/em/api_FDEM.rst | 23 ++++-- docs/{ => content}/em/api_TDEM.rst | 0 docs/{ => content}/em/api_Utils.rst | 0 docs/{ => content}/em/api_basic.rst | 0 docs/{ => content}/em/index.rst | 2 +- .../examples/DC_Analytic_Dipole.rst | 0 .../examples/DC_Forward_PseudoSection.rst | 0 .../examples/EM_FDEM_1D_Inversion.rst | 0 .../EM_FDEM_Analytic_MagDipoleWholespace.rst | 0 .../examples/EM_Schenkel_Morrison_Casing.rst | 0 .../examples/EM_TDEM_1D_Inversion.rst | 0 .../examples/FLOW_Richards_1D_Celia1990.rst | 0 .../examples/Inversion_Linear.rst | 0 .../examples/MT_1D_ForwardAndInversion.rst | 0 docs/{ => content}/examples/MT_3D_Foward.rst | 0 .../examples/Mesh_Basic_ForwardDC.rst | 0 .../examples/Mesh_Basic_PlotImage.rst | 0 .../examples/Mesh_Basic_Types.rst | 0 .../examples/Mesh_Operators_CahnHilliard.rst | 0 .../examples/Mesh_QuadTree_Creation.rst | 0 .../examples/Mesh_QuadTree_FaceDiv.rst | 0 .../examples/Mesh_QuadTree_HangingNodes.rst | 0 .../examples/Mesh_Tensor_Creation.rst | 0 .../examples/Utils_surface2ind_topo.rst | 0 docs/{ => content}/flow/index.rst | 0 docs/{ => content}/ip/index.rst | 0 docs/{ => content}/mt/index.rst | 0 docs/examples/Inversion_IRLS.rst | 26 ------- .../InversionWorkflow-PreSimPEG.png | Bin docs/{ => images}/InversionWorkflow.png | Bin docs/{ => images}/SimPEGFrameworkRevised.png | Bin docs/{ => images}/simpeg-framework.png | Bin docs/{ => images}/simpeg-logo.png | Bin docs/index.rst | 24 +++--- 57 files changed, 122 insertions(+), 95 deletions(-) delete mode 100644 docs/api_FiniteVolume.rst rename docs/{ => content/api_core}/api_DataMisfit.rst (100%) rename docs/{ => content/api_core}/api_DiffOps.rst (100%) rename docs/{ => content/api_core}/api_Examples.rst (93%) create mode 100644 docs/content/api_core/api_FiniteVolume.rst rename docs/{ => content/api_core}/api_ForwardProblem.rst (94%) rename docs/{ => content/api_core}/api_InnerProducts.rst (75%) rename docs/{ => content/api_core}/api_Inversion.rst (100%) rename docs/{ => content/api_core}/api_InversionComponents.rst (100%) rename docs/{ => content/api_core}/api_Maps.rst (100%) rename docs/{ => content/api_core}/api_Mesh.rst (100%) rename docs/{ => content/api_core}/api_MeshCode.rst (100%) rename docs/{ => content/api_core}/api_Optimization.rst (100%) rename docs/{ => content/api_core}/api_PropMaps.rst (100%) rename docs/{ => content/api_core}/api_Regularization.rst (100%) rename docs/{ => content/api_core}/api_Solver.rst (100%) rename docs/{ => content/api_core}/api_Tests.rst (100%) rename docs/{ => content/api_core}/api_Utilities.rst (100%) rename docs/{ => content/api_core}/api_Utils.rst (100%) rename docs/{ => content/api_core}/api_bigPicture.rst (97%) rename docs/{ => content/api_core}/api_installing.rst (100%) rename docs/{ => content}/dc/index.rst (100%) rename docs/{ => content}/em/api_FDEM.rst (87%) rename docs/{ => content}/em/api_TDEM.rst (100%) rename docs/{ => content}/em/api_Utils.rst (100%) rename docs/{ => content}/em/api_basic.rst (100%) rename docs/{ => content}/em/index.rst (93%) rename docs/{ => content}/examples/DC_Analytic_Dipole.rst (100%) rename docs/{ => content}/examples/DC_Forward_PseudoSection.rst (100%) rename docs/{ => content}/examples/EM_FDEM_1D_Inversion.rst (100%) rename docs/{ => content}/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst (100%) rename docs/{ => content}/examples/EM_Schenkel_Morrison_Casing.rst (100%) rename docs/{ => content}/examples/EM_TDEM_1D_Inversion.rst (100%) rename docs/{ => content}/examples/FLOW_Richards_1D_Celia1990.rst (100%) rename docs/{ => content}/examples/Inversion_Linear.rst (100%) rename docs/{ => content}/examples/MT_1D_ForwardAndInversion.rst (100%) rename docs/{ => content}/examples/MT_3D_Foward.rst (100%) rename docs/{ => content}/examples/Mesh_Basic_ForwardDC.rst (100%) rename docs/{ => content}/examples/Mesh_Basic_PlotImage.rst (100%) rename docs/{ => content}/examples/Mesh_Basic_Types.rst (100%) rename docs/{ => content}/examples/Mesh_Operators_CahnHilliard.rst (100%) rename docs/{ => content}/examples/Mesh_QuadTree_Creation.rst (100%) rename docs/{ => content}/examples/Mesh_QuadTree_FaceDiv.rst (100%) rename docs/{ => content}/examples/Mesh_QuadTree_HangingNodes.rst (100%) rename docs/{ => content}/examples/Mesh_Tensor_Creation.rst (100%) rename docs/{ => content}/examples/Utils_surface2ind_topo.rst (100%) rename docs/{ => content}/flow/index.rst (100%) rename docs/{ => content}/ip/index.rst (100%) rename docs/{ => content}/mt/index.rst (100%) delete mode 100644 docs/examples/Inversion_IRLS.rst rename docs/{ => images}/InversionWorkflow-PreSimPEG.png (100%) rename docs/{ => images}/InversionWorkflow.png (100%) rename docs/{ => images}/SimPEGFrameworkRevised.png (100%) rename docs/{ => images}/simpeg-framework.png (100%) rename docs/{ => images}/simpeg-logo.png (100%) diff --git a/SimPEG/Examples/__init__.py b/SimPEG/Examples/__init__.py index 3c771f77..e788cd4c 100644 --- a/SimPEG/Examples/__init__.py +++ b/SimPEG/Examples/__init__.py @@ -38,7 +38,7 @@ if __name__ == '__main__': # Create the examples dir in the docs folder. fName = os.path.realpath(__file__) - docExamplesDir = os.path.sep.join(fName.split(os.path.sep)[:-3] + ['docs', 'examples']) + docExamplesDir = os.path.sep.join(fName.split(os.path.sep)[:-3] + ['docs', 'content', 'examples']) shutil.rmtree(docExamplesDir) os.makedirs(docExamplesDir) @@ -95,12 +95,12 @@ if __name__ == '__main__': from SimPEG import Examples Examples.%s.run() -.. literalinclude:: ../../SimPEG/Examples/%s.py +.. literalinclude:: ../../../../SimPEG/Examples/%s.py :language: python :linenos: """%(name,doc,name,name) - rst = os.path.sep.join((filePath.split(os.path.sep)[:-3] + ['docs', 'examples', name + '.rst'])) + rst = os.path.sep.join((filePath.split(os.path.sep)[:-3] + ['docs', 'content', 'examples', name + '.rst'])) print 'Creating: %s.rst'%name f = open(rst, 'w') diff --git a/docs/api_FiniteVolume.rst b/docs/api_FiniteVolume.rst deleted file mode 100644 index 40e9b879..00000000 --- a/docs/api_FiniteVolume.rst +++ /dev/null @@ -1,19 +0,0 @@ -.. _api_FiniteVolume: - -Finite Volume -************* - -Any numerical implementation requires the discretization of continuous functions into discrete approximations. These approximations are typically organized in a mesh, which defines boundaries, locations, and connectivity. Of specific interest to geophysical simulations, we require that averaging, interpolation and differential operators be defined for any mesh. In SimPEG, we have implemented a staggered mimetic finite volume approach (`Hyman and Shashkov, 1999 `_). This approach requires the definitions of variables at either cell-centers, nodes, faces, or edges as seen in the figure below. - -.. image:: images/finitevolrealestate.png - :width: 400 px - :alt: FiniteVolume - :align: center - - -.. toctree:: - :maxdepth: 2 - - api_Mesh - api_DiffOps - api_InnerProducts diff --git a/docs/api_DataMisfit.rst b/docs/content/api_core/api_DataMisfit.rst similarity index 100% rename from docs/api_DataMisfit.rst rename to docs/content/api_core/api_DataMisfit.rst diff --git a/docs/api_DiffOps.rst b/docs/content/api_core/api_DiffOps.rst similarity index 100% rename from docs/api_DiffOps.rst rename to docs/content/api_core/api_DiffOps.rst diff --git a/docs/api_Examples.rst b/docs/content/api_core/api_Examples.rst similarity index 93% rename from docs/api_Examples.rst rename to docs/content/api_core/api_Examples.rst index 68589fb3..40b34949 100644 --- a/docs/api_Examples.rst +++ b/docs/content/api_core/api_Examples.rst @@ -7,7 +7,7 @@ Examples :maxdepth: 1 :glob: - examples/* + ../examples/* External Notebooks diff --git a/docs/content/api_core/api_FiniteVolume.rst b/docs/content/api_core/api_FiniteVolume.rst new file mode 100644 index 00000000..7952c56a --- /dev/null +++ b/docs/content/api_core/api_FiniteVolume.rst @@ -0,0 +1,27 @@ +.. _api_FiniteVolume: + +Finite Volume +************* + +Any numerical implementation requires the discretization of continuous +functions into discrete approximations. These approximations are typically +organized in a mesh, which defines boundaries, locations, and connectivity. Of +specific interest to geophysical simulations, we require that averaging, +interpolation and differential operators be defined for any mesh. In SimPEG, +we have implemented a staggered mimetic finite volume approach (`Hyman and +Shashkov, 1999 `_). This +approach requires the definitions of variables at either cell-centers, nodes, +faces, or edges as seen in the figure below. + +.. image:: ../../images/finitevolrealestate.png + :width: 400 px + :alt: FiniteVolume + :align: center + + +.. toctree:: + :maxdepth: 2 + + api_Mesh + api_DiffOps + api_InnerProducts diff --git a/docs/api_ForwardProblem.rst b/docs/content/api_core/api_ForwardProblem.rst similarity index 94% rename from docs/api_ForwardProblem.rst rename to docs/content/api_core/api_ForwardProblem.rst index 250a3618..7d85aab5 100644 --- a/docs/api_ForwardProblem.rst +++ b/docs/content/api_core/api_ForwardProblem.rst @@ -52,13 +52,15 @@ We can take the derivative of the PDE: \nabla_m c(m, u) \partial m + \nabla_u c(m, u) \partial u = 0 -If the forward problem is invertible, then we can rearrange for \\(\\frac{\\partial u}{\\partial m}\\): +If the forward problem is invertible, then we can rearrange for +\\(\\frac{\\partial u}{\\partial m}\\): .. math:: J = - P \left( \nabla_u c(m, u) \right)^{-1} \nabla_m c(m, u) -This can often be computed given a vector (i.e. \\(J(v)\\)) rather than stored, as \\(J\\) is a large dense matrix. +This can often be computed given a vector (i.e. \\(J(v)\\)) rather than +stored, as \\(J\\) is a large dense matrix. diff --git a/docs/api_InnerProducts.rst b/docs/content/api_core/api_InnerProducts.rst similarity index 75% rename from docs/api_InnerProducts.rst rename to docs/content/api_core/api_InnerProducts.rst index 13d532eb..b1d253b1 100644 --- a/docs/api_InnerProducts.rst +++ b/docs/content/api_core/api_InnerProducts.rst @@ -4,7 +4,10 @@ Inner Products ************** -By using the weak formulation of many of the PDEs in geophysical applications, we can rapidly develop discretizations. Much of this work, however, needs a good understanding of how to approximate inner products on our discretized meshes. We will define the inner product as: +By using the weak formulation of many of the PDEs in geophysical applications, +we can rapidly develop discretizations. Much of this work, however, needs a +good understanding of how to approximate inner products on our discretized +meshes. We will define the inner product as: .. math:: @@ -14,12 +17,15 @@ where a and b are either scalars or vectors. .. note:: - The InnerProducts class is a base class providing inner product matrices for meshes and cannot run on its own. + The InnerProducts class is a base class providing inner product matrices + for meshes and cannot run on its own. Example problem for DC resistivity ---------------------------------- -We will start with the formulation of the Direct Current (DC) resistivity problem in geophysics. + +We will start with the formulation of the Direct Current (DC) resistivity +problem in geophysics. .. math:: @@ -28,12 +34,13 @@ We will start with the formulation of the Direct Current (DC) resistivity proble \nabla\cdot \vec{j} = q -In the following discretization, \\\( \\sigma \\\) and \\\( \\phi \\\) -will be discretized on the cell-centers and the flux, \\\(\\vec{j}\\\), +In the following discretization, :math:`\sigma` and :math:`\phi` +will be discretized on the cell-centers and the flux, :math:`\vec{j}`, will be on the faces. We will use the weak formulation to discretize the DC resistivity equation. -We can define in weak form by integrating with a general face function \\\(\\vec{f}\\\): +We can define in weak form by integrating with a general face function +:math:`\vec{f}`: .. math:: @@ -61,9 +68,16 @@ We can then discretize for every cell: .. note:: - We have discretized the dot product above, but remember that we do not really have a single vector \\\(\\mathbf{J}\\\), but approximations of \\\(\\vec{j}\\\) on each face of our cell. In 2D that means 2 approximations of \\\(\\mathbf{J}_x\\\) and 2 approximations of \\\(\\mathbf{J}_y\\\). In 3D we also have 2 approximations of \\\(\\mathbf{J}_z\\\). + We have discretized the dot product above, but remember that we do not + really have a single vector :math:`\mathbf{J}`, but approximations of + :math:`\vec{j}` on each face of our cell. In 2D that means 2 + approximations of :math:`\mathbf{J}_x` and 2 approximations of + :math:`\mathbf{J}_y`. In 3D we also have 2 approximations of + :math:`\mathbf{J}_z`. -Regardless of how we choose to approximate this dot product, we can represent this in vector form (again this is for every cell), and will generalize for the case of anisotropic (tensor) sigma. +Regardless of how we choose to approximate this dot product, we can represent +this in vector form (again this is for every cell), and will generalize for +the case of anisotropic (tensor) sigma. .. math:: @@ -71,14 +85,17 @@ Regardless of how we choose to approximate this dot product, we can represent th -\phi^{\top} v_{\text{cell}} \mathbf{D}_{\text{cell}} \mathbf{F}) + \text{BC} -We multiply by square-root of volume on each side of the tensor conductivity to keep symmetry in the system. Here \\\(\\mathbf{J}_c\\\) is the Cartesian \\\(\\mathbf{J}\\\) (on the faces that we choose to use in our approximation) and must be calculated differently depending on the mesh: +We multiply by square-root of volume on each side of the tensor conductivity +to keep symmetry in the system. Here :math:`\mathbf{J}_c` is the Cartesian +:math:`\mathbf{J}` (on the faces that we choose to use in our approximation) +and must be calculated differently depending on the mesh: .. math:: \mathbf{J}_c = \mathbf{Q}_{(i)}\mathbf{J}_\text{TENSOR} \\ \mathbf{J}_c = \mathbf{N}_{(i)}^{-1}\mathbf{Q}_{(i)}\mathbf{J}_\text{Curv} -Here the \\\(i\\\) index refers to where we choose to approximate this integral, as discussed in the note above. -We will approximate this integral by taking the fluxes clustered around every node of the cell, there are 8 combinations in 3D, and 4 in 2D. We will use a projection matrix \\\( \\mathbf{Q}_{(i)} \\\) to pick the appropriate fluxes. So, now that we have 8 approximations of this integral, we will just take the average. For the TensorMesh, this looks like: +Here the :math:`i` index refers to where we choose to approximate this integral, as discussed in the note above. +We will approximate this integral by taking the fluxes clustered around every node of the cell, there are 8 combinations in 3D, and 4 in 2D. We will use a projection matrix :math:`\mathbf{Q}_{(i)}` to pick the appropriate fluxes. So, now that we have 8 approximations of this integral, we will just take the average. For the TensorMesh, this looks like: .. math:: @@ -107,10 +124,12 @@ By defining the faceInnerProduct (8 combinations of fluxes in 3D, 4 in 2D, 2 in \sum_{i=1}^{2^d} \mathbf{P}_{(i)}^{\top} \Sigma^{-1} \mathbf{P}_{(i)} -Where \\\(d\\\) is the dimension of the mesh. -The \\\( \\mathbf{M}^f \\\) is returned when given the input of \\\( \\Sigma^{-1} \\\). +Where :math:`d` is the dimension of the mesh. +The :math:`\mathbf{M}^f` is returned when given the input of :math:`\Sigma^{-1}`. -Here each \\( \\mathbf{P} \\in \\mathbb{R}^{(d*nC, nF)} \\\) is a combination of the projection, volume, and any normalization to Cartesian coordinates (where the dot product is well defined): +Here each :math:`\mathbf{P} ~ \in ~ \mathbb{R}^{(d*nC, nF)}` is a combination +of the projection, volume, and any normalization to Cartesian coordinates +(where the dot product is well defined): .. math:: @@ -129,7 +148,10 @@ If ``returnP=True`` is requested in any of these methods the projection matrices # In 1D P = [P0, P1] -The derivation for ``edgeInnerProducts`` is exactly the same, however, when we approximate the integral using the fields around each node, the projection matrices look a bit different because we have 12 edges in 3D instead of just 6 faces. The interface to the code is exactly the same. +The derivation for ``edgeInnerProducts`` is exactly the same, however, when we +approximate the integral using the fields around each node, the projection +matrices look a bit different because we have 12 edges in 3D instead of just 6 +faces. The interface to the code is exactly the same. Defining Tensor Properties @@ -137,7 +159,8 @@ Defining Tensor Properties **For 3D:** -Depending on the number of columns (either 1, 3, or 6) of mu, the material property is interpreted as follows: +Depending on the number of columns (either 1, 3, or 6) of mu, the material +property is interpreted as follows: .. math:: @@ -188,13 +211,16 @@ Which is nice and easy to invert if necessary, however, in the fully anisotropic Taking Derivatives ------------------ -We will take the derivative of the fully anisotropic tensor for a 3D mesh, the other cases are easier and will not be discussed here. Let us start with one part of the sum which makes up \\\(\\mathbf{M}^f_\\Sigma\\\) and take the derivative when this is multiplied by some vector \\\(\\mathbf{v}\\\): +We will take the derivative of the fully anisotropic tensor for a 3D mesh, the +other cases are easier and will not be discussed here. Let us start with one +part of the sum which makes up :math:`\mathbf{M}^f_\Sigma` and take the +derivative when this is multiplied by some vector :math:`\mathbf{v}`: .. math:: \mathbf{P}^\top \boldsymbol{\Sigma} \mathbf{Pv} -Here we will let \\\( \\mathbf{Pv} = \\mathbf{y} \\\) and \\\(\\mathbf{y}\\\) will have the form: +Here we will let :math:`\mathbf{Pv} = \mathbf{y}` and :math:`\mathbf{y}` will have the form: .. math:: @@ -233,7 +259,9 @@ Here we will let \\\( \\mathbf{Pv} = \\mathbf{y} \\\) and \\\(\\mathbf{y}\\\) wi \end{matrix} \right] -Now it is easy to take the derivative with respect to any one of the parameters, for example, \\\(\\frac{\\partial}{\\partial\\boldsymbol{\\sigma}_1}\\\) +Now it is easy to take the derivative with respect to any one of the +parameters, for example, +:math:`\frac{\partial}{\partial\boldsymbol{\sigma}_1}` .. math:: \frac{\partial}{\partial \boldsymbol{\sigma}_1}\left(\mathbf{P}^\top\Sigma\mathbf{y}\right) @@ -247,7 +275,8 @@ Now it is easy to take the derivative with respect to any one of the parameters, \end{matrix} \right] -Whereas \\\(\\frac{\\partial}{\\partial\\boldsymbol{\\sigma}_4}\\\), for example, is: +Whereas :math:`\frac{\partial}{\partial\boldsymbol{\sigma}_4}`, for +example, is: .. math:: \frac{\partial}{\partial \boldsymbol{\sigma}_4}\left(\mathbf{P}^\top\Sigma\mathbf{y}\right) @@ -261,7 +290,8 @@ Whereas \\\(\\frac{\\partial}{\\partial\\boldsymbol{\\sigma}_4}\\\), for example \end{matrix} \right] -These are computed for each of the 8 projections, horizontally concatenated, and returned. +These are computed for each of the 8 projections, horizontally concatenated, +and returned. The API ------- diff --git a/docs/api_Inversion.rst b/docs/content/api_core/api_Inversion.rst similarity index 100% rename from docs/api_Inversion.rst rename to docs/content/api_core/api_Inversion.rst diff --git a/docs/api_InversionComponents.rst b/docs/content/api_core/api_InversionComponents.rst similarity index 100% rename from docs/api_InversionComponents.rst rename to docs/content/api_core/api_InversionComponents.rst diff --git a/docs/api_Maps.rst b/docs/content/api_core/api_Maps.rst similarity index 100% rename from docs/api_Maps.rst rename to docs/content/api_core/api_Maps.rst diff --git a/docs/api_Mesh.rst b/docs/content/api_core/api_Mesh.rst similarity index 100% rename from docs/api_Mesh.rst rename to docs/content/api_core/api_Mesh.rst diff --git a/docs/api_MeshCode.rst b/docs/content/api_core/api_MeshCode.rst similarity index 100% rename from docs/api_MeshCode.rst rename to docs/content/api_core/api_MeshCode.rst diff --git a/docs/api_Optimization.rst b/docs/content/api_core/api_Optimization.rst similarity index 100% rename from docs/api_Optimization.rst rename to docs/content/api_core/api_Optimization.rst diff --git a/docs/api_PropMaps.rst b/docs/content/api_core/api_PropMaps.rst similarity index 100% rename from docs/api_PropMaps.rst rename to docs/content/api_core/api_PropMaps.rst diff --git a/docs/api_Regularization.rst b/docs/content/api_core/api_Regularization.rst similarity index 100% rename from docs/api_Regularization.rst rename to docs/content/api_core/api_Regularization.rst diff --git a/docs/api_Solver.rst b/docs/content/api_core/api_Solver.rst similarity index 100% rename from docs/api_Solver.rst rename to docs/content/api_core/api_Solver.rst diff --git a/docs/api_Tests.rst b/docs/content/api_core/api_Tests.rst similarity index 100% rename from docs/api_Tests.rst rename to docs/content/api_core/api_Tests.rst diff --git a/docs/api_Utilities.rst b/docs/content/api_core/api_Utilities.rst similarity index 100% rename from docs/api_Utilities.rst rename to docs/content/api_core/api_Utilities.rst diff --git a/docs/api_Utils.rst b/docs/content/api_core/api_Utils.rst similarity index 100% rename from docs/api_Utils.rst rename to docs/content/api_core/api_Utils.rst diff --git a/docs/api_bigPicture.rst b/docs/content/api_core/api_bigPicture.rst similarity index 97% rename from docs/api_bigPicture.rst rename to docs/content/api_core/api_bigPicture.rst index e24037ab..0b0f1110 100644 --- a/docs/api_bigPicture.rst +++ b/docs/content/api_core/api_bigPicture.rst @@ -35,7 +35,7 @@ The Big Picture Defining a well-posed inverse problem and solving it is a complex task that requires many components that must interact. It is helpful to view this task as a workflow in which various elements are explicitly identified and integrated. The figure below outlines the inversion components that consists of inputs, implementation, and evaluation. The inputs are composed of the geophysical data, the equations which are a mathematical description of the governing physics, and prior knowledge or assumptions about the setting. The implementation consists of two broad categories: the forward simulation and the inversion. The **forward simulation** is the means by which we solve the governing equations given a model and the **inversion components** evaluate and update this model. We are considering a gradient based approach, which updates the model through an optimization routine. The output of this implementation is a model, which, prior to interpretation, must be evaluated. This requires considering, and often re-assessing, the choices and assumptions made in both the input and implementation stages. -.. image:: InversionWorkflow-PreSimPEG.png +.. image:: ../../images/InversionWorkflow-PreSimPEG.png :width: 400 px :alt: Components :align: center @@ -46,7 +46,7 @@ A Comprehensive Framework There are an overwhelming amount of choices to be made as one works through the forward modeling and inversion process (see figure above). As a result, software implementations of this workflow often become complex and highly interdependent, making it difficult to interact with and to ask other scientists to pick up and change. Our approach to handling this complexity is to propose a framework, (see below), that compartmentalizes the implementation of inversions into various units. We present it in this specific modular style, as each unit contains a targeted subset of choices crucial to the inversion process. -.. image:: InversionWorkflow.png +.. image:: ../../images/InversionWorkflow.png :width: 400 px :alt: Framework :align: center @@ -56,14 +56,14 @@ The process of obtaining an acceptable model from an inversion generally require The arrows in the figure above indicate what each class takes as a primary argument. For example, both the :class:`SimPEG.Problem.BaseProblem` and :class:`SimPEG.Regularization.BaseRegularization` classes take a :class:`SimPEG.Mesh.BaseMesh.BaseMesh` class as an argument. The diagram does not show class inheritance, as each of the base classes outlined have many subtypes that can be interchanged. The :class:`SimPEG.Mesh.BaseMesh.BaseMesh` class, for example, could be a regular Cartesian mesh :class:`SimPEG.Mesh.TensorMesh` or a cylindrical coordinate mesh :class:`SimPEG.Mesh.CylMesh`, which have many properties in common. These common features, such as both meshes being created from tensor products, can be exploited through inheritance of base classes, and differences can be expressed through subtype polymorphism. Please look at the documentation here for more in-depth information. -.. include:: ../CITATION.rst +.. include:: ../../../CITATION.rst Authors ------- -.. include:: ../AUTHORS.rst +.. include:: ../../../AUTHORS.rst License ------- -.. include:: ../LICENSE +.. include:: ../../../LICENSE diff --git a/docs/api_installing.rst b/docs/content/api_core/api_installing.rst similarity index 100% rename from docs/api_installing.rst rename to docs/content/api_core/api_installing.rst diff --git a/docs/dc/index.rst b/docs/content/dc/index.rst similarity index 100% rename from docs/dc/index.rst rename to docs/content/dc/index.rst diff --git a/docs/em/api_FDEM.rst b/docs/content/em/api_FDEM.rst similarity index 87% rename from docs/em/api_FDEM.rst rename to docs/content/em/api_FDEM.rst index 60b38d1c..65589c70 100644 --- a/docs/em/api_FDEM.rst +++ b/docs/content/em/api_FDEM.rst @@ -9,17 +9,28 @@ Frequency Domain Electromagnetics ********************************* -Electromagnetic (EM) geophysical methods are used in a variety of applications from resource exploration, including for hydrocarbons and minerals, to environmental applications, such as groundwater monitoring. The primary physical property of interest in EM is electrical conductivity, which describes the ease with which electric current flows through a material. +Electromagnetic (EM) geophysical methods are used in a variety of applications +from resource exploration, including for hydrocarbons and minerals, to +environmental applications, such as groundwater monitoring. The primary +physical property of interest in EM is electrical conductivity, which +describes the ease with which electric current flows through a material. Background ========== -Electromagnetic phenomena are governed by Maxwell's equations. They describe the behavior of EM fields and fluxes. Electromagnetic theory for geophysical applications by Ward and Hohmann (1988) is a highly recommended resource on this topic. +Electromagnetic phenomena are governed by Maxwell's equations. They describe +the behavior of EM fields and fluxes. Electromagnetic theory for geophysical +applications by Ward and Hohmann (1988) is a highly recommended resource on +this topic. Fourier Transform Convention ---------------------------- -In order to examine Maxwell's equations in the frequency domain, we must first define our choice of harmonic time-dependence by choosing a Fourier transform convention. We use the :math:`e^{i \omega t}` convention, so we define our Fourier Transform pair as + +In order to examine Maxwell's equations in the frequency domain, we must first +define our choice of harmonic time-dependence by choosing a Fourier transform +convention. We use the :math:`e^{i \omega t}` convention, so we define our +Fourier Transform pair as .. math :: F(\omega) = \int_{-\infty}^{\infty} f(t) e^{- i \omega t} dt \\ @@ -31,6 +42,7 @@ where :math:`\omega` is angular frequency, :math:`t` is time, :math:`F(\omega)` Maxwell's Equations =================== + In the frequency domain, Maxwell's equations are given by .. math :: @@ -104,19 +116,20 @@ The H-J formulation is in terms of the current density and the magnetic field: Discretizing ------------ + For both formulations, we use a finite volume discretization and discretize fields on cell edges, fluxes on cell faces and physical properties in cell centers. This is particularly important when using symmetry to reduce the dimensionality of a problem (for instance on a 2D CylMesh, there are :math:`r`, :math:`z` faces and :math:`\theta` edges) -.. figure:: ../images/finitevolrealestate.png +.. figure:: ../../images/finitevolrealestate.png :align: center :scale: 60 % For the two formulations, the discretization of the physical properties, fields and fluxes are summarized below. -.. figure:: ../images/ebjhdiscretizations.png +.. figure:: ../../images/ebjhdiscretizations.png :align: center :scale: 60 % diff --git a/docs/em/api_TDEM.rst b/docs/content/em/api_TDEM.rst similarity index 100% rename from docs/em/api_TDEM.rst rename to docs/content/em/api_TDEM.rst diff --git a/docs/em/api_Utils.rst b/docs/content/em/api_Utils.rst similarity index 100% rename from docs/em/api_Utils.rst rename to docs/content/em/api_Utils.rst diff --git a/docs/em/api_basic.rst b/docs/content/em/api_basic.rst similarity index 100% rename from docs/em/api_basic.rst rename to docs/content/em/api_basic.rst diff --git a/docs/em/index.rst b/docs/content/em/index.rst similarity index 93% rename from docs/em/index.rst rename to docs/content/em/index.rst index 4f95a339..c94c6fc2 100644 --- a/docs/em/index.rst +++ b/docs/content/em/index.rst @@ -12,7 +12,7 @@ and a source, we can solve Maxwell's equations for fields. We sample these fields with recievers to give us predicted data. -.. image:: ../images/simpegEM_noMath.png +.. image:: ../../images/simpegEM_noMath.png :scale: 50% diff --git a/docs/examples/DC_Analytic_Dipole.rst b/docs/content/examples/DC_Analytic_Dipole.rst similarity index 100% rename from docs/examples/DC_Analytic_Dipole.rst rename to docs/content/examples/DC_Analytic_Dipole.rst diff --git a/docs/examples/DC_Forward_PseudoSection.rst b/docs/content/examples/DC_Forward_PseudoSection.rst similarity index 100% rename from docs/examples/DC_Forward_PseudoSection.rst rename to docs/content/examples/DC_Forward_PseudoSection.rst diff --git a/docs/examples/EM_FDEM_1D_Inversion.rst b/docs/content/examples/EM_FDEM_1D_Inversion.rst similarity index 100% rename from docs/examples/EM_FDEM_1D_Inversion.rst rename to docs/content/examples/EM_FDEM_1D_Inversion.rst diff --git a/docs/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst b/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst similarity index 100% rename from docs/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst rename to docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst diff --git a/docs/examples/EM_Schenkel_Morrison_Casing.rst b/docs/content/examples/EM_Schenkel_Morrison_Casing.rst similarity index 100% rename from docs/examples/EM_Schenkel_Morrison_Casing.rst rename to docs/content/examples/EM_Schenkel_Morrison_Casing.rst diff --git a/docs/examples/EM_TDEM_1D_Inversion.rst b/docs/content/examples/EM_TDEM_1D_Inversion.rst similarity index 100% rename from docs/examples/EM_TDEM_1D_Inversion.rst rename to docs/content/examples/EM_TDEM_1D_Inversion.rst diff --git a/docs/examples/FLOW_Richards_1D_Celia1990.rst b/docs/content/examples/FLOW_Richards_1D_Celia1990.rst similarity index 100% rename from docs/examples/FLOW_Richards_1D_Celia1990.rst rename to docs/content/examples/FLOW_Richards_1D_Celia1990.rst diff --git a/docs/examples/Inversion_Linear.rst b/docs/content/examples/Inversion_Linear.rst similarity index 100% rename from docs/examples/Inversion_Linear.rst rename to docs/content/examples/Inversion_Linear.rst diff --git a/docs/examples/MT_1D_ForwardAndInversion.rst b/docs/content/examples/MT_1D_ForwardAndInversion.rst similarity index 100% rename from docs/examples/MT_1D_ForwardAndInversion.rst rename to docs/content/examples/MT_1D_ForwardAndInversion.rst diff --git a/docs/examples/MT_3D_Foward.rst b/docs/content/examples/MT_3D_Foward.rst similarity index 100% rename from docs/examples/MT_3D_Foward.rst rename to docs/content/examples/MT_3D_Foward.rst diff --git a/docs/examples/Mesh_Basic_ForwardDC.rst b/docs/content/examples/Mesh_Basic_ForwardDC.rst similarity index 100% rename from docs/examples/Mesh_Basic_ForwardDC.rst rename to docs/content/examples/Mesh_Basic_ForwardDC.rst diff --git a/docs/examples/Mesh_Basic_PlotImage.rst b/docs/content/examples/Mesh_Basic_PlotImage.rst similarity index 100% rename from docs/examples/Mesh_Basic_PlotImage.rst rename to docs/content/examples/Mesh_Basic_PlotImage.rst diff --git a/docs/examples/Mesh_Basic_Types.rst b/docs/content/examples/Mesh_Basic_Types.rst similarity index 100% rename from docs/examples/Mesh_Basic_Types.rst rename to docs/content/examples/Mesh_Basic_Types.rst diff --git a/docs/examples/Mesh_Operators_CahnHilliard.rst b/docs/content/examples/Mesh_Operators_CahnHilliard.rst similarity index 100% rename from docs/examples/Mesh_Operators_CahnHilliard.rst rename to docs/content/examples/Mesh_Operators_CahnHilliard.rst diff --git a/docs/examples/Mesh_QuadTree_Creation.rst b/docs/content/examples/Mesh_QuadTree_Creation.rst similarity index 100% rename from docs/examples/Mesh_QuadTree_Creation.rst rename to docs/content/examples/Mesh_QuadTree_Creation.rst diff --git a/docs/examples/Mesh_QuadTree_FaceDiv.rst b/docs/content/examples/Mesh_QuadTree_FaceDiv.rst similarity index 100% rename from docs/examples/Mesh_QuadTree_FaceDiv.rst rename to docs/content/examples/Mesh_QuadTree_FaceDiv.rst diff --git a/docs/examples/Mesh_QuadTree_HangingNodes.rst b/docs/content/examples/Mesh_QuadTree_HangingNodes.rst similarity index 100% rename from docs/examples/Mesh_QuadTree_HangingNodes.rst rename to docs/content/examples/Mesh_QuadTree_HangingNodes.rst diff --git a/docs/examples/Mesh_Tensor_Creation.rst b/docs/content/examples/Mesh_Tensor_Creation.rst similarity index 100% rename from docs/examples/Mesh_Tensor_Creation.rst rename to docs/content/examples/Mesh_Tensor_Creation.rst diff --git a/docs/examples/Utils_surface2ind_topo.rst b/docs/content/examples/Utils_surface2ind_topo.rst similarity index 100% rename from docs/examples/Utils_surface2ind_topo.rst rename to docs/content/examples/Utils_surface2ind_topo.rst diff --git a/docs/flow/index.rst b/docs/content/flow/index.rst similarity index 100% rename from docs/flow/index.rst rename to docs/content/flow/index.rst diff --git a/docs/ip/index.rst b/docs/content/ip/index.rst similarity index 100% rename from docs/ip/index.rst rename to docs/content/ip/index.rst diff --git a/docs/mt/index.rst b/docs/content/mt/index.rst similarity index 100% rename from docs/mt/index.rst rename to docs/content/mt/index.rst diff --git a/docs/examples/Inversion_IRLS.rst b/docs/examples/Inversion_IRLS.rst deleted file mode 100644 index 64a072f1..00000000 --- a/docs/examples/Inversion_IRLS.rst +++ /dev/null @@ -1,26 +0,0 @@ -.. _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: diff --git a/docs/InversionWorkflow-PreSimPEG.png b/docs/images/InversionWorkflow-PreSimPEG.png similarity index 100% rename from docs/InversionWorkflow-PreSimPEG.png rename to docs/images/InversionWorkflow-PreSimPEG.png diff --git a/docs/InversionWorkflow.png b/docs/images/InversionWorkflow.png similarity index 100% rename from docs/InversionWorkflow.png rename to docs/images/InversionWorkflow.png diff --git a/docs/SimPEGFrameworkRevised.png b/docs/images/SimPEGFrameworkRevised.png similarity index 100% rename from docs/SimPEGFrameworkRevised.png rename to docs/images/SimPEGFrameworkRevised.png diff --git a/docs/simpeg-framework.png b/docs/images/simpeg-framework.png similarity index 100% rename from docs/simpeg-framework.png rename to docs/images/simpeg-framework.png diff --git a/docs/simpeg-logo.png b/docs/images/simpeg-logo.png similarity index 100% rename from docs/simpeg-logo.png rename to docs/images/simpeg-logo.png diff --git a/docs/index.rst b/docs/index.rst index 8b27ee1b..fb6fb4f3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -41,8 +41,8 @@ About SimPEG .. toctree:: :maxdepth: 2 - api_bigPicture - api_installing + content/api_core/api_bigPicture + content/api_core/api_installing Examples ******** @@ -50,7 +50,7 @@ Examples .. toctree:: :maxdepth: 2 - api_Examples + content/api_core/api_Examples Packages ******** @@ -58,11 +58,11 @@ Packages .. toctree:: :maxdepth: 3 - em/index - dc/index - ip/index - mt/index - flow/index + content/em/index + content/dc/index + content/ip/index + content/mt/index + content/flow/index Finite Volume ************* @@ -70,7 +70,7 @@ Finite Volume .. toctree:: :maxdepth: 3 - api_FiniteVolume + content/api_core/api_FiniteVolume Forward Problems **************** @@ -78,7 +78,7 @@ Forward Problems .. toctree:: :maxdepth: 3 - api_ForwardProblem + content/api_core/api_ForwardProblem Inversion Components ******************** @@ -86,7 +86,7 @@ Inversion Components .. toctree:: :maxdepth: 3 - api_InversionComponents + content/api_core/api_InversionComponents Utility Codes ************* @@ -94,7 +94,7 @@ Utility Codes .. toctree:: :maxdepth: 3 - api_Utilities + content/api_core/api_Utilities Project Index & Search From 2a159e20b9c5a294271ac7d914cb5703ab5df03f Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Mon, 30 May 2016 20:34:10 -0700 Subject: [PATCH 51/77] update docs for examples to point to the correct path --- docs/content/examples/DC_Analytic_Dipole.rst | 2 +- docs/content/examples/DC_Forward_PseudoSection.rst | 2 +- docs/content/examples/EM_FDEM_1D_Inversion.rst | 2 +- docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst | 2 +- docs/content/examples/EM_Schenkel_Morrison_Casing.rst | 2 +- docs/content/examples/EM_TDEM_1D_Inversion.rst | 2 +- docs/content/examples/FLOW_Richards_1D_Celia1990.rst | 2 +- docs/content/examples/Inversion_Linear.rst | 2 +- docs/content/examples/MT_1D_ForwardAndInversion.rst | 2 +- docs/content/examples/MT_3D_Foward.rst | 2 +- docs/content/examples/Mesh_Basic_ForwardDC.rst | 2 +- docs/content/examples/Mesh_Basic_PlotImage.rst | 2 +- docs/content/examples/Mesh_Basic_Types.rst | 2 +- docs/content/examples/Mesh_Operators_CahnHilliard.rst | 2 +- docs/content/examples/Mesh_QuadTree_Creation.rst | 2 +- docs/content/examples/Mesh_QuadTree_FaceDiv.rst | 2 +- docs/content/examples/Mesh_QuadTree_HangingNodes.rst | 2 +- docs/content/examples/Mesh_Tensor_Creation.rst | 2 +- docs/content/examples/Utils_surface2ind_topo.rst | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/content/examples/DC_Analytic_Dipole.rst b/docs/content/examples/DC_Analytic_Dipole.rst index f3d06058..9f895944 100644 --- a/docs/content/examples/DC_Analytic_Dipole.rst +++ b/docs/content/examples/DC_Analytic_Dipole.rst @@ -16,6 +16,6 @@ DC Analytic Dipole from SimPEG import Examples Examples.DC_Analytic_Dipole.run() -.. literalinclude:: ../../SimPEG/Examples/DC_Analytic_Dipole.py +.. literalinclude:: ../../../../SimPEG/Examples/DC_Analytic_Dipole.py :language: python :linenos: diff --git a/docs/content/examples/DC_Forward_PseudoSection.rst b/docs/content/examples/DC_Forward_PseudoSection.rst index 4231e944..2afb4a34 100644 --- a/docs/content/examples/DC_Forward_PseudoSection.rst +++ b/docs/content/examples/DC_Forward_PseudoSection.rst @@ -31,6 +31,6 @@ Created by @fourndo from SimPEG import Examples Examples.DC_Forward_PseudoSection.run() -.. literalinclude:: ../../SimPEG/Examples/DC_Forward_PseudoSection.py +.. literalinclude:: ../../../../SimPEG/Examples/DC_Forward_PseudoSection.py :language: python :linenos: diff --git a/docs/content/examples/EM_FDEM_1D_Inversion.rst b/docs/content/examples/EM_FDEM_1D_Inversion.rst index acbc8cdc..c087d81a 100644 --- a/docs/content/examples/EM_FDEM_1D_Inversion.rst +++ b/docs/content/examples/EM_FDEM_1D_Inversion.rst @@ -21,6 +21,6 @@ Here we will create and run a FDEM 1D inversion. from SimPEG import Examples Examples.EM_FDEM_1D_Inversion.run() -.. literalinclude:: ../../SimPEG/Examples/EM_FDEM_1D_Inversion.py +.. literalinclude:: ../../../../SimPEG/Examples/EM_FDEM_1D_Inversion.py :language: python :linenos: diff --git a/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst b/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst index 0e1b2d93..418175db 100644 --- a/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst +++ b/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst @@ -21,6 +21,6 @@ Here we plot the magnetic flux density from a harmonic dipole in a wholespace. from SimPEG import Examples Examples.EM_FDEM_Analytic_MagDipoleWholespace.run() -.. literalinclude:: ../../SimPEG/Examples/EM_FDEM_Analytic_MagDipoleWholespace.py +.. literalinclude:: ../../../../SimPEG/Examples/EM_FDEM_Analytic_MagDipoleWholespace.py :language: python :linenos: diff --git a/docs/content/examples/EM_Schenkel_Morrison_Casing.rst b/docs/content/examples/EM_Schenkel_Morrison_Casing.rst index 5ff3432e..e845105b 100644 --- a/docs/content/examples/EM_Schenkel_Morrison_Casing.rst +++ b/docs/content/examples/EM_Schenkel_Morrison_Casing.rst @@ -56,6 +56,6 @@ citation would be much appreciated! from SimPEG import Examples Examples.EM_Schenkel_Morrison_Casing.run() -.. literalinclude:: ../../SimPEG/Examples/EM_Schenkel_Morrison_Casing.py +.. literalinclude:: ../../../../SimPEG/Examples/EM_Schenkel_Morrison_Casing.py :language: python :linenos: diff --git a/docs/content/examples/EM_TDEM_1D_Inversion.rst b/docs/content/examples/EM_TDEM_1D_Inversion.rst index 53f6f9ef..7619305b 100644 --- a/docs/content/examples/EM_TDEM_1D_Inversion.rst +++ b/docs/content/examples/EM_TDEM_1D_Inversion.rst @@ -21,6 +21,6 @@ Here we will create and run a TDEM 1D inversion. from SimPEG import Examples Examples.EM_TDEM_1D_Inversion.run() -.. literalinclude:: ../../SimPEG/Examples/EM_TDEM_1D_Inversion.py +.. literalinclude:: ../../../../SimPEG/Examples/EM_TDEM_1D_Inversion.py :language: python :linenos: diff --git a/docs/content/examples/FLOW_Richards_1D_Celia1990.rst b/docs/content/examples/FLOW_Richards_1D_Celia1990.rst index d2e01c13..cb4c0e02 100644 --- a/docs/content/examples/FLOW_Richards_1D_Celia1990.rst +++ b/docs/content/examples/FLOW_Richards_1D_Celia1990.rst @@ -47,6 +47,6 @@ Here we reproduce the results from Celia1990_ demonstrating the head-based formu from SimPEG import Examples Examples.FLOW_Richards_1D_Celia1990.run() -.. literalinclude:: ../../SimPEG/Examples/FLOW_Richards_1D_Celia1990.py +.. literalinclude:: ../../../../SimPEG/Examples/FLOW_Richards_1D_Celia1990.py :language: python :linenos: diff --git a/docs/content/examples/Inversion_Linear.rst b/docs/content/examples/Inversion_Linear.rst index d635d8e1..83109128 100644 --- a/docs/content/examples/Inversion_Linear.rst +++ b/docs/content/examples/Inversion_Linear.rst @@ -21,6 +21,6 @@ Here we go over the basics of creating a linear problem and inversion. from SimPEG import Examples Examples.Inversion_Linear.run() -.. literalinclude:: ../../SimPEG/Examples/Inversion_Linear.py +.. literalinclude:: ../../../../SimPEG/Examples/Inversion_Linear.py :language: python :linenos: diff --git a/docs/content/examples/MT_1D_ForwardAndInversion.rst b/docs/content/examples/MT_1D_ForwardAndInversion.rst index bc834215..d137bcb0 100644 --- a/docs/content/examples/MT_1D_ForwardAndInversion.rst +++ b/docs/content/examples/MT_1D_ForwardAndInversion.rst @@ -22,6 +22,6 @@ Setup and run a MT 1D inversion. from SimPEG import Examples Examples.MT_1D_ForwardAndInversion.run() -.. literalinclude:: ../../SimPEG/Examples/MT_1D_ForwardAndInversion.py +.. literalinclude:: ../../../../SimPEG/Examples/MT_1D_ForwardAndInversion.py :language: python :linenos: diff --git a/docs/content/examples/MT_3D_Foward.rst b/docs/content/examples/MT_3D_Foward.rst index 142a62a4..916c47cd 100644 --- a/docs/content/examples/MT_3D_Foward.rst +++ b/docs/content/examples/MT_3D_Foward.rst @@ -21,6 +21,6 @@ Forward model 3D MT data. from SimPEG import Examples Examples.MT_3D_Foward.run() -.. literalinclude:: ../../SimPEG/Examples/MT_3D_Foward.py +.. literalinclude:: ../../../../SimPEG/Examples/MT_3D_Foward.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Basic_ForwardDC.rst b/docs/content/examples/Mesh_Basic_ForwardDC.rst index df18050e..fe158027 100644 --- a/docs/content/examples/Mesh_Basic_ForwardDC.rst +++ b/docs/content/examples/Mesh_Basic_ForwardDC.rst @@ -20,6 +20,6 @@ Mesh: Basic Forward 2D DC Resistivity from SimPEG import Examples Examples.Mesh_Basic_ForwardDC.run() -.. literalinclude:: ../../SimPEG/Examples/Mesh_Basic_ForwardDC.py +.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Basic_ForwardDC.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Basic_PlotImage.rst b/docs/content/examples/Mesh_Basic_PlotImage.rst index a730f303..63d8c93b 100644 --- a/docs/content/examples/Mesh_Basic_PlotImage.rst +++ b/docs/content/examples/Mesh_Basic_PlotImage.rst @@ -22,6 +22,6 @@ You can use M.PlotImage to plot images on all of the Meshes. from SimPEG import Examples Examples.Mesh_Basic_PlotImage.run() -.. literalinclude:: ../../SimPEG/Examples/Mesh_Basic_PlotImage.py +.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Basic_PlotImage.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Basic_Types.rst b/docs/content/examples/Mesh_Basic_Types.rst index 9bbce0e8..b77e7a6f 100644 --- a/docs/content/examples/Mesh_Basic_Types.rst +++ b/docs/content/examples/Mesh_Basic_Types.rst @@ -21,6 +21,6 @@ Here we show SimPEG used to create three different types of meshes. from SimPEG import Examples Examples.Mesh_Basic_Types.run() -.. literalinclude:: ../../SimPEG/Examples/Mesh_Basic_Types.py +.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Basic_Types.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Operators_CahnHilliard.rst b/docs/content/examples/Mesh_Operators_CahnHilliard.rst index 9786e911..ece0eef9 100644 --- a/docs/content/examples/Mesh_Operators_CahnHilliard.rst +++ b/docs/content/examples/Mesh_Operators_CahnHilliard.rst @@ -52,6 +52,6 @@ field separating as the time increases. from SimPEG import Examples Examples.Mesh_Operators_CahnHilliard.run() -.. literalinclude:: ../../SimPEG/Examples/Mesh_Operators_CahnHilliard.py +.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Operators_CahnHilliard.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_QuadTree_Creation.rst b/docs/content/examples/Mesh_QuadTree_Creation.rst index 5db5a982..0e8e1a2d 100644 --- a/docs/content/examples/Mesh_QuadTree_Creation.rst +++ b/docs/content/examples/Mesh_QuadTree_Creation.rst @@ -26,6 +26,6 @@ on an 8x8 mesh (2^3). from SimPEG import Examples Examples.Mesh_QuadTree_Creation.run() -.. literalinclude:: ../../SimPEG/Examples/Mesh_QuadTree_Creation.py +.. literalinclude:: ../../../../SimPEG/Examples/Mesh_QuadTree_Creation.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_QuadTree_FaceDiv.rst b/docs/content/examples/Mesh_QuadTree_FaceDiv.rst index 6bfdd47f..ac1b6fb8 100644 --- a/docs/content/examples/Mesh_QuadTree_FaceDiv.rst +++ b/docs/content/examples/Mesh_QuadTree_FaceDiv.rst @@ -21,6 +21,6 @@ Mesh: QuadTree: FaceDiv from SimPEG import Examples Examples.Mesh_QuadTree_FaceDiv.run() -.. literalinclude:: ../../SimPEG/Examples/Mesh_QuadTree_FaceDiv.py +.. literalinclude:: ../../../../SimPEG/Examples/Mesh_QuadTree_FaceDiv.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_QuadTree_HangingNodes.rst b/docs/content/examples/Mesh_QuadTree_HangingNodes.rst index 93875478..829632d3 100644 --- a/docs/content/examples/Mesh_QuadTree_HangingNodes.rst +++ b/docs/content/examples/Mesh_QuadTree_HangingNodes.rst @@ -26,6 +26,6 @@ on an 8x8 mesh (2^3). from SimPEG import Examples Examples.Mesh_QuadTree_HangingNodes.run() -.. literalinclude:: ../../SimPEG/Examples/Mesh_QuadTree_HangingNodes.py +.. literalinclude:: ../../../../SimPEG/Examples/Mesh_QuadTree_HangingNodes.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Tensor_Creation.rst b/docs/content/examples/Mesh_Tensor_Creation.rst index e6cc5b67..90c94d43 100644 --- a/docs/content/examples/Mesh_Tensor_Creation.rst +++ b/docs/content/examples/Mesh_Tensor_Creation.rst @@ -38,6 +38,6 @@ notation:: from SimPEG import Examples Examples.Mesh_Tensor_Creation.run() -.. literalinclude:: ../../SimPEG/Examples/Mesh_Tensor_Creation.py +.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Tensor_Creation.py :language: python :linenos: diff --git a/docs/content/examples/Utils_surface2ind_topo.rst b/docs/content/examples/Utils_surface2ind_topo.rst index 7ff007d1..ef08eae8 100644 --- a/docs/content/examples/Utils_surface2ind_topo.rst +++ b/docs/content/examples/Utils_surface2ind_topo.rst @@ -23,6 +23,6 @@ a topographic surface. from SimPEG import Examples Examples.Utils_surface2ind_topo.run() -.. literalinclude:: ../../SimPEG/Examples/Utils_surface2ind_topo.py +.. literalinclude:: ../../../../SimPEG/Examples/Utils_surface2ind_topo.py :language: python :linenos: From 9fbdaaf0a570ef0ad8afa337dd8a7c6eba52fec3 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Mon, 30 May 2016 21:12:31 -0700 Subject: [PATCH 52/77] fix typo in examples path --- SimPEG/Examples/__init__.py | 2 +- docs/content/examples/DC_Analytic_Dipole.rst | 2 +- docs/content/examples/DC_Forward_PseudoSection.rst | 2 +- docs/content/examples/EM_FDEM_1D_Inversion.rst | 2 +- docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst | 2 +- docs/content/examples/EM_Schenkel_Morrison_Casing.rst | 2 +- docs/content/examples/EM_TDEM_1D_Inversion.rst | 2 +- docs/content/examples/FLOW_Richards_1D_Celia1990.rst | 2 +- docs/content/examples/Inversion_Linear.rst | 2 +- docs/content/examples/MT_1D_ForwardAndInversion.rst | 2 +- docs/content/examples/MT_3D_Foward.rst | 2 +- docs/content/examples/Mesh_Basic_ForwardDC.rst | 2 +- docs/content/examples/Mesh_Basic_PlotImage.rst | 2 +- docs/content/examples/Mesh_Basic_Types.rst | 2 +- docs/content/examples/Mesh_Operators_CahnHilliard.rst | 2 +- docs/content/examples/Mesh_QuadTree_Creation.rst | 2 +- docs/content/examples/Mesh_QuadTree_FaceDiv.rst | 2 +- docs/content/examples/Mesh_QuadTree_HangingNodes.rst | 2 +- docs/content/examples/Mesh_Tensor_Creation.rst | 2 +- docs/content/examples/Utils_surface2ind_topo.rst | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/SimPEG/Examples/__init__.py b/SimPEG/Examples/__init__.py index e788cd4c..2ee4eb6d 100644 --- a/SimPEG/Examples/__init__.py +++ b/SimPEG/Examples/__init__.py @@ -95,7 +95,7 @@ if __name__ == '__main__': from SimPEG import Examples Examples.%s.run() -.. literalinclude:: ../../../../SimPEG/Examples/%s.py +.. literalinclude:: ../../../SimPEG/Examples/%s.py :language: python :linenos: """%(name,doc,name,name) diff --git a/docs/content/examples/DC_Analytic_Dipole.rst b/docs/content/examples/DC_Analytic_Dipole.rst index 9f895944..955ddf10 100644 --- a/docs/content/examples/DC_Analytic_Dipole.rst +++ b/docs/content/examples/DC_Analytic_Dipole.rst @@ -16,6 +16,6 @@ DC Analytic Dipole from SimPEG import Examples Examples.DC_Analytic_Dipole.run() -.. literalinclude:: ../../../../SimPEG/Examples/DC_Analytic_Dipole.py +.. literalinclude:: ../../../SimPEG/Examples/DC_Analytic_Dipole.py :language: python :linenos: diff --git a/docs/content/examples/DC_Forward_PseudoSection.rst b/docs/content/examples/DC_Forward_PseudoSection.rst index 2afb4a34..a59aec60 100644 --- a/docs/content/examples/DC_Forward_PseudoSection.rst +++ b/docs/content/examples/DC_Forward_PseudoSection.rst @@ -31,6 +31,6 @@ Created by @fourndo from SimPEG import Examples Examples.DC_Forward_PseudoSection.run() -.. literalinclude:: ../../../../SimPEG/Examples/DC_Forward_PseudoSection.py +.. literalinclude:: ../../../SimPEG/Examples/DC_Forward_PseudoSection.py :language: python :linenos: diff --git a/docs/content/examples/EM_FDEM_1D_Inversion.rst b/docs/content/examples/EM_FDEM_1D_Inversion.rst index c087d81a..3cac55db 100644 --- a/docs/content/examples/EM_FDEM_1D_Inversion.rst +++ b/docs/content/examples/EM_FDEM_1D_Inversion.rst @@ -21,6 +21,6 @@ Here we will create and run a FDEM 1D inversion. from SimPEG import Examples Examples.EM_FDEM_1D_Inversion.run() -.. literalinclude:: ../../../../SimPEG/Examples/EM_FDEM_1D_Inversion.py +.. literalinclude:: ../../../SimPEG/Examples/EM_FDEM_1D_Inversion.py :language: python :linenos: diff --git a/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst b/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst index 418175db..81a4cb00 100644 --- a/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst +++ b/docs/content/examples/EM_FDEM_Analytic_MagDipoleWholespace.rst @@ -21,6 +21,6 @@ Here we plot the magnetic flux density from a harmonic dipole in a wholespace. from SimPEG import Examples Examples.EM_FDEM_Analytic_MagDipoleWholespace.run() -.. literalinclude:: ../../../../SimPEG/Examples/EM_FDEM_Analytic_MagDipoleWholespace.py +.. literalinclude:: ../../../SimPEG/Examples/EM_FDEM_Analytic_MagDipoleWholespace.py :language: python :linenos: diff --git a/docs/content/examples/EM_Schenkel_Morrison_Casing.rst b/docs/content/examples/EM_Schenkel_Morrison_Casing.rst index e845105b..c82a1ad0 100644 --- a/docs/content/examples/EM_Schenkel_Morrison_Casing.rst +++ b/docs/content/examples/EM_Schenkel_Morrison_Casing.rst @@ -56,6 +56,6 @@ citation would be much appreciated! from SimPEG import Examples Examples.EM_Schenkel_Morrison_Casing.run() -.. literalinclude:: ../../../../SimPEG/Examples/EM_Schenkel_Morrison_Casing.py +.. literalinclude:: ../../../SimPEG/Examples/EM_Schenkel_Morrison_Casing.py :language: python :linenos: diff --git a/docs/content/examples/EM_TDEM_1D_Inversion.rst b/docs/content/examples/EM_TDEM_1D_Inversion.rst index 7619305b..dd308472 100644 --- a/docs/content/examples/EM_TDEM_1D_Inversion.rst +++ b/docs/content/examples/EM_TDEM_1D_Inversion.rst @@ -21,6 +21,6 @@ Here we will create and run a TDEM 1D inversion. from SimPEG import Examples Examples.EM_TDEM_1D_Inversion.run() -.. literalinclude:: ../../../../SimPEG/Examples/EM_TDEM_1D_Inversion.py +.. literalinclude:: ../../../SimPEG/Examples/EM_TDEM_1D_Inversion.py :language: python :linenos: diff --git a/docs/content/examples/FLOW_Richards_1D_Celia1990.rst b/docs/content/examples/FLOW_Richards_1D_Celia1990.rst index cb4c0e02..5bad1485 100644 --- a/docs/content/examples/FLOW_Richards_1D_Celia1990.rst +++ b/docs/content/examples/FLOW_Richards_1D_Celia1990.rst @@ -47,6 +47,6 @@ Here we reproduce the results from Celia1990_ demonstrating the head-based formu from SimPEG import Examples Examples.FLOW_Richards_1D_Celia1990.run() -.. literalinclude:: ../../../../SimPEG/Examples/FLOW_Richards_1D_Celia1990.py +.. literalinclude:: ../../../SimPEG/Examples/FLOW_Richards_1D_Celia1990.py :language: python :linenos: diff --git a/docs/content/examples/Inversion_Linear.rst b/docs/content/examples/Inversion_Linear.rst index 83109128..922cf4e0 100644 --- a/docs/content/examples/Inversion_Linear.rst +++ b/docs/content/examples/Inversion_Linear.rst @@ -21,6 +21,6 @@ Here we go over the basics of creating a linear problem and inversion. from SimPEG import Examples Examples.Inversion_Linear.run() -.. literalinclude:: ../../../../SimPEG/Examples/Inversion_Linear.py +.. literalinclude:: ../../../SimPEG/Examples/Inversion_Linear.py :language: python :linenos: diff --git a/docs/content/examples/MT_1D_ForwardAndInversion.rst b/docs/content/examples/MT_1D_ForwardAndInversion.rst index d137bcb0..79c11cfc 100644 --- a/docs/content/examples/MT_1D_ForwardAndInversion.rst +++ b/docs/content/examples/MT_1D_ForwardAndInversion.rst @@ -22,6 +22,6 @@ Setup and run a MT 1D inversion. from SimPEG import Examples Examples.MT_1D_ForwardAndInversion.run() -.. literalinclude:: ../../../../SimPEG/Examples/MT_1D_ForwardAndInversion.py +.. literalinclude:: ../../../SimPEG/Examples/MT_1D_ForwardAndInversion.py :language: python :linenos: diff --git a/docs/content/examples/MT_3D_Foward.rst b/docs/content/examples/MT_3D_Foward.rst index 916c47cd..a07fbdaf 100644 --- a/docs/content/examples/MT_3D_Foward.rst +++ b/docs/content/examples/MT_3D_Foward.rst @@ -21,6 +21,6 @@ Forward model 3D MT data. from SimPEG import Examples Examples.MT_3D_Foward.run() -.. literalinclude:: ../../../../SimPEG/Examples/MT_3D_Foward.py +.. literalinclude:: ../../../SimPEG/Examples/MT_3D_Foward.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Basic_ForwardDC.rst b/docs/content/examples/Mesh_Basic_ForwardDC.rst index fe158027..b2660555 100644 --- a/docs/content/examples/Mesh_Basic_ForwardDC.rst +++ b/docs/content/examples/Mesh_Basic_ForwardDC.rst @@ -20,6 +20,6 @@ Mesh: Basic Forward 2D DC Resistivity from SimPEG import Examples Examples.Mesh_Basic_ForwardDC.run() -.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Basic_ForwardDC.py +.. literalinclude:: ../../../SimPEG/Examples/Mesh_Basic_ForwardDC.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Basic_PlotImage.rst b/docs/content/examples/Mesh_Basic_PlotImage.rst index 63d8c93b..6761ff7e 100644 --- a/docs/content/examples/Mesh_Basic_PlotImage.rst +++ b/docs/content/examples/Mesh_Basic_PlotImage.rst @@ -22,6 +22,6 @@ You can use M.PlotImage to plot images on all of the Meshes. from SimPEG import Examples Examples.Mesh_Basic_PlotImage.run() -.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Basic_PlotImage.py +.. literalinclude:: ../../../SimPEG/Examples/Mesh_Basic_PlotImage.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Basic_Types.rst b/docs/content/examples/Mesh_Basic_Types.rst index b77e7a6f..4bd4cf7c 100644 --- a/docs/content/examples/Mesh_Basic_Types.rst +++ b/docs/content/examples/Mesh_Basic_Types.rst @@ -21,6 +21,6 @@ Here we show SimPEG used to create three different types of meshes. from SimPEG import Examples Examples.Mesh_Basic_Types.run() -.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Basic_Types.py +.. literalinclude:: ../../../SimPEG/Examples/Mesh_Basic_Types.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Operators_CahnHilliard.rst b/docs/content/examples/Mesh_Operators_CahnHilliard.rst index ece0eef9..dd43aa45 100644 --- a/docs/content/examples/Mesh_Operators_CahnHilliard.rst +++ b/docs/content/examples/Mesh_Operators_CahnHilliard.rst @@ -52,6 +52,6 @@ field separating as the time increases. from SimPEG import Examples Examples.Mesh_Operators_CahnHilliard.run() -.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Operators_CahnHilliard.py +.. literalinclude:: ../../../SimPEG/Examples/Mesh_Operators_CahnHilliard.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_QuadTree_Creation.rst b/docs/content/examples/Mesh_QuadTree_Creation.rst index 0e8e1a2d..d77f6fea 100644 --- a/docs/content/examples/Mesh_QuadTree_Creation.rst +++ b/docs/content/examples/Mesh_QuadTree_Creation.rst @@ -26,6 +26,6 @@ on an 8x8 mesh (2^3). from SimPEG import Examples Examples.Mesh_QuadTree_Creation.run() -.. literalinclude:: ../../../../SimPEG/Examples/Mesh_QuadTree_Creation.py +.. literalinclude:: ../../../SimPEG/Examples/Mesh_QuadTree_Creation.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_QuadTree_FaceDiv.rst b/docs/content/examples/Mesh_QuadTree_FaceDiv.rst index ac1b6fb8..2ecf154b 100644 --- a/docs/content/examples/Mesh_QuadTree_FaceDiv.rst +++ b/docs/content/examples/Mesh_QuadTree_FaceDiv.rst @@ -21,6 +21,6 @@ Mesh: QuadTree: FaceDiv from SimPEG import Examples Examples.Mesh_QuadTree_FaceDiv.run() -.. literalinclude:: ../../../../SimPEG/Examples/Mesh_QuadTree_FaceDiv.py +.. literalinclude:: ../../../SimPEG/Examples/Mesh_QuadTree_FaceDiv.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_QuadTree_HangingNodes.rst b/docs/content/examples/Mesh_QuadTree_HangingNodes.rst index 829632d3..e1d26b0b 100644 --- a/docs/content/examples/Mesh_QuadTree_HangingNodes.rst +++ b/docs/content/examples/Mesh_QuadTree_HangingNodes.rst @@ -26,6 +26,6 @@ on an 8x8 mesh (2^3). from SimPEG import Examples Examples.Mesh_QuadTree_HangingNodes.run() -.. literalinclude:: ../../../../SimPEG/Examples/Mesh_QuadTree_HangingNodes.py +.. literalinclude:: ../../../SimPEG/Examples/Mesh_QuadTree_HangingNodes.py :language: python :linenos: diff --git a/docs/content/examples/Mesh_Tensor_Creation.rst b/docs/content/examples/Mesh_Tensor_Creation.rst index 90c94d43..ee3af326 100644 --- a/docs/content/examples/Mesh_Tensor_Creation.rst +++ b/docs/content/examples/Mesh_Tensor_Creation.rst @@ -38,6 +38,6 @@ notation:: from SimPEG import Examples Examples.Mesh_Tensor_Creation.run() -.. literalinclude:: ../../../../SimPEG/Examples/Mesh_Tensor_Creation.py +.. literalinclude:: ../../../SimPEG/Examples/Mesh_Tensor_Creation.py :language: python :linenos: diff --git a/docs/content/examples/Utils_surface2ind_topo.rst b/docs/content/examples/Utils_surface2ind_topo.rst index ef08eae8..5d217562 100644 --- a/docs/content/examples/Utils_surface2ind_topo.rst +++ b/docs/content/examples/Utils_surface2ind_topo.rst @@ -23,6 +23,6 @@ a topographic surface. from SimPEG import Examples Examples.Utils_surface2ind_topo.run() -.. literalinclude:: ../../../../SimPEG/Examples/Utils_surface2ind_topo.py +.. literalinclude:: ../../../SimPEG/Examples/Utils_surface2ind_topo.py :language: python :linenos: From 01e19e4227dbc2d31d47d5022846d7805db12c04 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Mon, 30 May 2016 22:01:15 -0700 Subject: [PATCH 53/77] start of gae site --- docs/app.yaml | 95 +++++++++++++++++++++++++++++++++++++ docs/conf.py | 2 +- docs/images/logo-block.ico | Bin 0 -> 19548 bytes docs/index.yaml | 11 +++++ docs/simpegdocs.py | 90 +++++++++++++++++++++++++++++++++++ 5 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 docs/app.yaml create mode 100644 docs/images/logo-block.ico create mode 100644 docs/index.yaml create mode 100644 docs/simpegdocs.py diff --git a/docs/app.yaml b/docs/app.yaml new file mode 100644 index 00000000..f37fb743 --- /dev/null +++ b/docs/app.yaml @@ -0,0 +1,95 @@ +# application: simpegdocs +# version: 1 +runtime: python27 +api_version: 1 +threadsafe: yes + +handlers: + +# favicon +- url: /images/logo-block\.ico + static_files: /images/logo-block.ico + upload: /images/logo-block\.ico + +# all css +- url: /(.*\.css) + mime_type: text/css + static_files: _build/html/\1 + upload: _build/html/(.*\.css) + +# webfonts +- url: /(.*\.(eot|svg|ttf|woff|woff2|otf)) + static_files: _build/html/\1 + upload: _build/html/(.*\.(eot|svg|ttf|woff|woff2|otf)) + +# javascript +- url: /(.*\.js) + mime_type: text/javascript + static_files: _build/html/\1 + upload: _build/html/(.*\.js) + +# plain text source +- url: /(.*\.txt) + mime_type: text/plain + static_files: _build/html/\1 + upload: _build/html/(.*\.txt) + +# images +- url: /_images/(.*\.(gif|png|jpg|ico)) + static_files: _build/html/_images/\1 + upload: _build/html/_images/(.*\.(gif|png|jpg|ico)) + +# redirect en/latest traffic +- url: /en/latest/(.*\.html) + script: simpegdocs.app + +# raw html +- url: /(.*\.html) + mime_type: text/html + static_files: _build/html/\1 + upload: _build/html/(.*\.html) + +# serve index files +- url: /(.+)/ + static_files: _build/html/\1/index.html + upload: _build/html/(.+)/index.html + +- url: /(.+) + static_files: _build/html/\1/index.html + upload: _build/html/(.+)/index.html + +- url: / + static_files: _build/html/index.html + upload: _build/html/index.html + +- url: .* + script: simpegdocs.app + +# Recommended file skipping declaration from the GAE tutorials +skip_files: + - ^(.*/)?app\.yaml + - ^(.*/)?app\.yml + - ^(.*/)?#.*# + - ^(.*/)?.*~ + - ^(.*/)?.*\.py[co] + - ^(.*/)?.*/RCS/.* + - ^(.*/)?\..* + - ^(.*/)?tests$ + - ^(.*/)?test$ + - ^test/(.*/)? + - ^COPYING.LESSER + - ^README\..* + - \.gitignore + - ^\.git/.* + - \.*\.lint$ + - ^(.*/)?.*\.doctree$ + +libraries: +- name: webapp2 + version: "2.5.2" +- name: PIL + version: "1.1.7" +- name: numpy + version: "latest" +- name: jinja2 + version: "latest" diff --git a/docs/conf.py b/docs/conf.py index 2db771bf..bbc3cb6b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -124,7 +124,7 @@ except Exception, e: # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +html_favicon = './images/logo-block.ico' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/docs/images/logo-block.ico b/docs/images/logo-block.ico new file mode 100644 index 0000000000000000000000000000000000000000..91b6a1f16f39b0b7eaede6f42c3a055e47992af4 GIT binary patch literal 19548 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

Pmjq^CXs6^OfKBSnFHfd zELVIC@tI)AUTHruKL4r15ya}f8+7sF#q+PrzD0T`0Tj6oRj0m2_!gn_pYoz*cxQqV z-;>j=xLqy_SetcjJhFK8`~|hH%T>&mw7f`tycXqMYUug#T%^xdRNtoA?;&bEuwsm< zx}AIiwKCoX-P?h7=%_mPcxcz*@`y9#biq1fYn_Ss9@tQ6)u;W2y&A`ag=0r{DSgc=*S$S1+vL&Ip0vl zKd82-=pD6V>kH4mVa4TBH*sUNwEuRU(Ntg&m}K`BI$5~dVzF14qdaUwPHJT6QyFXA znCfR{k(Gh=hDI3xdfY;LI8NAR;65q_sO+;%$UX~)?0iXnz>b^u`@OeGu!6i+6-Vis z14G}nm)KCXHNBoB2M2jcfkdfe$;*EyxSX$H*72*aKtrLE5^52jzOv|N+6-u{>CE&M zl{X_twSg%g;&N0^Zip;A8$l|C_?d2lPd2W@3a;{U2YyUZDO$Us`%0+WvZBewn^x-s zWUafE%dZ`&f!N!aT5@@_4$*Wu^3NZfe{Fd>Y_vJVcqX^*RghBH?>O;m6Zdh|?` z$spE?ji0$or9eoC=wmyhGHp+pG#DYKV7QMq5yi57EN1H3O)1IJU;2rSZHv+=;ueeU znh5btsVvXjn_Euu?>GSbk;qn+5*obcy_ncZfFgw}tyaM*W z2ysI~Ba(%$K>R9Nk3LVa69eg9cVpW>*<=QI$W14~Z>_Y^b!IsR#M$ELd5gT(42#8+ zPg4-jK;|O<7P&raPl3we6*_j8)2g-o^P-hScx)X#Li8JvS&6b#c$mT`WI?^{*YwG} zsl577aXlCrl%(QPRE$~cmHQ*z=j|bW+7zT%pD10C$}W%!G_u-%^{xylMu+hd=xT;5 zwiL;>h$%k5(T95>eSY9Nm|M+DY)?jum+*Jf+W8wSlKXD&9haQXt4AvCZ&&G^gxe-B z7QULE`=FO*cz*g50D!4xpUK0vCCmnL`>D|`vO{ZlBe}sauL7o*xcQ}TP57lR=k(tn zL!{txRMS3LoEj`M$We4m6qM`#+Ge*UHnF#kmq>-SO#6GNFAz9$>o9r4tLcX`{A_d5 z-5j=7cbxC}>$CRk`RgS$vD^7YZ)w)V2!`)@#qT0|M=bQnls!Te=wZiY2Z|Sb} zhT5xk$%cg;<1KUr&EzM#I(#))uts9yr-&WAAmZ^~}_wxwOVe$D4kgt^;>GktR5ZDNkVlBQ*O&#rjYGi0lDU>>LL?sazlAiH$b_?wpv+=fwPRHeSAOH12nwLG7)PzbP; zlWv(hm-$rJ`-|P*Z+EI&yHA}7ESyEdfaQ<7n>fUdQpVJ$xw}5@i~}|%Cts}IXuq=b zhiTZk?VF6&{LpdZ)jKBw*lz@pVc zd)*tckTiCYz^iq@#?QW~cMq*vT#>cM&j%RXZ{)+vxHYW%JZ73o-aYr5&w8)Xg)<#R zK@qlJwzhy8)cXokzb`PdUH~lk%I?-*@%a;F4GhcZh_}*FM?muT3RAZ?yt)c>-@}yl zrNULRA!%+?uL`D~zM!-W7*glB*VIW&eDy6OWc@VX7j8Z~6<6g*hk;CPIIziT!JLYY z^>=HVWzPdWA23riG|WBZ`k}5Fz$x(^=Ih>wg!uKY^83zTX6f4-yXe%LhF6stf%i>y>FMHQtCIZ7iFoai_V4svo?P7a<7Raz8^X zvP@>;rcVO#`&&ZIr$@bT4SC7AY?{3CBB17iq!i$K_c^=HuZaBcb?=-bc^WgKYI`OC zoxR}t#H(*FyfT^d%W_SY*u7=fj-D?CZrcSp%CApH-F2$;;Z#_$U2rkrmhrX@ z4d4|2FVih^q(aN?v|rg(5FPECq`m-Xhr+g9!l8G$R>!^f&Whc&H`H7AMVA&6cxRn_ z^xYmU+yk^`Ul`Q0Nh1pall@+rIqiyH)#=W%t?@d8q+{en5X5IC}Bwx%ZXZ zzj4pgJ33kNf7`-9two%`thB>;&l{Pry%z!l1bsm38{C}F Date: Tue, 31 May 2016 15:33:19 -0700 Subject: [PATCH 54/77] use templates in conf.py, add google analytics to docs --- docs/_templates/layout.html | 22 ++++++++++++++++++++++ docs/conf.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 docs/_templates/layout.html diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html new file mode 100644 index 00000000..a06350d4 --- /dev/null +++ b/docs/_templates/layout.html @@ -0,0 +1,22 @@ +{# Import the theme's layout. #} +{% extends "!layout.html" %} + +{% block extrahead %} +{{ super() }} + + + + + + + +{% endblock %} diff --git a/docs/conf.py b/docs/conf.py index bbc3cb6b..aec5cca4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,7 +44,7 @@ master_doc = 'index' # General information about the project. project = u'SimPEG' -copyright = u'2013, SimPEG Developers' +copyright = u'2013 - 2016, SimPEG Developers' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the From 279bd49b4c8cb401023aa8a62091575c8919993a Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 31 May 2016 15:38:05 -0700 Subject: [PATCH 55/77] =?UTF-8?q?Bump=20version:=200.1.10=20=E2=86=92=200.?= =?UTF-8?q?1.11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- SimPEG/__init__.py | 2 +- docs/conf.py | 4 ++-- setup.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 84469e3f..3ca3f780 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,4 +1,4 @@ [bumpversion] -current_version = 0.1.10 +current_version = 0.1.11 files = setup.py SimPEG/__init__.py docs/conf.py diff --git a/SimPEG/__init__.py b/SimPEG/__init__.py index a1e989b6..23d4de4a 100644 --- a/SimPEG/__init__.py +++ b/SimPEG/__init__.py @@ -15,7 +15,7 @@ import Directives import Inversion import Tests -__version__ = '0.1.10' +__version__ = '0.1.11' __author__ = 'Rowan Cockett' __license__ = 'MIT' __copyright__ = 'Copyright 2014 Rowan Cockett' diff --git a/docs/conf.py b/docs/conf.py index 45407435..67351319 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,9 +51,9 @@ copyright = u'2013, SimPEG Developers' # built documents. # # The short X.Y version. -version = '0.1.10' +version = '0.1.11' # The full version, including alpha/beta/rc tags. -release = '0.1.10' +release = '0.1.11' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 5308db47..06cd9b27 100644 --- a/setup.py +++ b/setup.py @@ -83,7 +83,7 @@ with open("README.rst") as f: setup( name = "SimPEG", - version = "0.1.10", + version = "0.1.11", packages = find_packages(), install_requires = ['numpy>=1.7', 'scipy>=0.13', From b023adbb33b2fa03b79a7aa3f42171a8c8dd6bc6 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 31 May 2016 23:03:55 -0700 Subject: [PATCH 56/77] add encrypted credentials for gae site and decrypt on travis --- .travis.yml | 15 +++++++++------ docs/credentials.tar.gz.enc | Bin 0 -> 4272 bytes 2 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 docs/credentials.tar.gz.enc diff --git a/.travis.yml b/.travis.yml index 10d66819..3baf44e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,13 +28,16 @@ env: # Setup anaconda before_install: - - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh -O miniconda.sh; fi - - chmod +x miniconda.sh - - ./miniconda.sh -b - - export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH - - conda update --yes conda - # Install packages +- openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv + -in credentials.tar.gz.enc -out credentials.tar.gz -d +- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh + -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh + -O miniconda.sh; fi +- chmod +x miniconda.sh +- ./miniconda.sh -b +- export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH +- conda update --yes conda install: - conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython ipython nose vtk sphinx - pip install nose-cov python-coveralls diff --git a/docs/credentials.tar.gz.enc b/docs/credentials.tar.gz.enc new file mode 100644 index 0000000000000000000000000000000000000000..d47988942bf03e4f88ebb833a819f87aaa1fccc6 GIT binary patch literal 4272 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 Date: Tue, 31 May 2016 23:15:50 -0700 Subject: [PATCH 57/77] move unpacking of credentials to after success, point credentials to docs folder --- .travis.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3baf44e7..cdd3f08a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,15 +29,14 @@ env: # Setup anaconda before_install: # Install packages -- openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv - -in credentials.tar.gz.enc -out credentials.tar.gz -d -- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh - -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh - -O miniconda.sh; fi -- chmod +x miniconda.sh -- ./miniconda.sh -b -- export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH -- conda update --yes conda + - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh + -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh + -O miniconda.sh; fi + - chmod +x miniconda.sh + - ./miniconda.sh -b + - export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH + - conda update --yes conda + install: - conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython ipython nose vtk sphinx - pip install nose-cov python-coveralls @@ -58,6 +57,10 @@ script: after_success: - coveralls --config_file .coveragerc + script: + - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv + -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d + notifications: email: - rowanc1@gmail.com From e3462666bd6c576e1a8e01d66bdb155306884cae Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Tue, 31 May 2016 23:27:32 -0700 Subject: [PATCH 58/77] working on travis decrypt --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cdd3f08a..f8075b71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,9 @@ env: # Setup anaconda before_install: + - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv + -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d + # Install packages - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh @@ -57,9 +60,7 @@ script: after_success: - coveralls --config_file .coveragerc - script: - - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv - -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d + notifications: email: From 75647f8fc3287e9c5ecda2a475d0d6fc74fef3a6 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Wed, 1 Jun 2016 00:00:27 -0700 Subject: [PATCH 59/77] first pass at gae deploy --- .travis.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f8075b71..d49f551c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,12 +25,11 @@ env: - TEST_DIR=tests/em/fdem/inverse/adjoint - TEST_DIR=tests/em/fdem/forward - TEST_DIR=tests/docs + - GAE_PYTHONPATH=${HOME}/.cache/google_appengine PATH=$PATH:${HOME}/google-cloud-sdk/bin + PYTHONPATH=${PYTHONPATH}:${GAE_PYTHONPATH} CLOUDSDK_CORE_DISABLE_PROMPTS=1 # Setup anaconda before_install: - - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv - -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d - # Install packages - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh @@ -60,6 +59,22 @@ script: after_success: - coveralls --config_file .coveragerc + - python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}"); + - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv + -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d + - if [ ! -d ${HOME}/google-cloud-sdk ]; then + curl https://sdk.cloud.google.com | bash; + fi + - tar -xzf credentials.tar.gz + # Here we use the decrypted service account credentials to authenticate the command line tool + - gcloud auth activate-service-account --key-file client-secret.json + + - gcloud config set project simpegdocs + - gcloud -q components update gae-python + + # - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then + - gcloud -q preview app deploy ./simpegdocs/app.yaml --version 1 --promote; + # fi notifications: From 504592c8deb6fe82833f316dd633957be4d25b12 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Wed, 1 Jun 2016 08:12:21 -0700 Subject: [PATCH 60/77] travis typo fixes --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d49f551c..fc813ea0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ env: - TEST_DIR=tests/em/fdem/forward - TEST_DIR=tests/docs - GAE_PYTHONPATH=${HOME}/.cache/google_appengine PATH=$PATH:${HOME}/google-cloud-sdk/bin - PYTHONPATH=${PYTHONPATH}:${GAE_PYTHONPATH} CLOUDSDK_CORE_DISABLE_PROMPTS=1 + PYTHONPATH=${PYTHONPATH}:${GAE_PYTHONPATH} CLOUDSDK_CORE_DISABLE_PROMPTS=1 # Setup anaconda before_install: From 291da78b97cbdd1dd80921c3c5fa85bf213066fc Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Fri, 10 Jun 2016 15:16:56 -0700 Subject: [PATCH 61/77] try deploying only from docs branch --- .travis.yml | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc813ea0..a8ad60af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,9 +24,11 @@ env: - TEST_DIR=tests/examples - TEST_DIR=tests/em/fdem/inverse/adjoint - TEST_DIR=tests/em/fdem/forward - - TEST_DIR=tests/docs - - GAE_PYTHONPATH=${HOME}/.cache/google_appengine PATH=$PATH:${HOME}/google-cloud-sdk/bin - PYTHONPATH=${PYTHONPATH}:${GAE_PYTHONPATH} CLOUDSDK_CORE_DISABLE_PROMPTS=1 + - TEST_DIR=tests/docs; + GAE_PYTHONPATH=${HOME}/.cache/google_appengine; + PATH=$PATH:${HOME}/google-cloud-sdk/bin; + PYTHONPATH=${PYTHONPATH}:${GAE_PYTHONPATH}; + CLOUDSDK_CORE_DISABLE_PROMPTS=1 # Setup anaconda before_install: @@ -54,27 +56,23 @@ script: # test docs - nosetests $TEST_DIR --with-cov --cov SimPEG --cov-config .coveragerc -v -s - # Calculate coverage after_success: - coveralls --config_file .coveragerc - - python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}"); - - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv - -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d - - if [ ! -d ${HOME}/google-cloud-sdk ]; then - curl https://sdk.cloud.google.com | bash; + - if [ ${TEST_DIR} == "tests/docs" ]; then + - python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}"); + - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv + -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d ; + - if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash; fi ; + - tar -xzf credentials.tar.gz ; + - gcloud auth activate-service-account --key-file client-secret.json ; + - gcloud config set project simpegdocs; + - gcloud -q components update gae-python; + - gcloud -q preview app deploy ./simpegdocs/app.yaml --version 1 --promote; fi - - tar -xzf credentials.tar.gz - # Here we use the decrypted service account credentials to authenticate the command line tool - - gcloud auth activate-service-account --key-file client-secret.json - - gcloud config set project simpegdocs - - gcloud -q components update gae-python - - # - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then - - gcloud -q preview app deploy ./simpegdocs/app.yaml --version 1 --promote; - # fi +# if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then notifications: From 7a06453c421abfa16737f48d1442739398d6a954 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Fri, 10 Jun 2016 18:54:31 -0700 Subject: [PATCH 62/77] editing travis deploy --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8ad60af..78b3f022 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,7 +61,7 @@ after_success: - coveralls --config_file .coveragerc - if [ ${TEST_DIR} == "tests/docs" ]; then - - python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}"); + python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}"); - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d ; - if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash; fi ; From 5ca52cf49fa293d02cb8454dfd2a97fbeba3f093 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Fri, 10 Jun 2016 19:14:24 -0700 Subject: [PATCH 63/77] linting travis deploy of docs --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78b3f022..8dccee5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,14 +62,14 @@ after_success: - if [ ${TEST_DIR} == "tests/docs" ]; then python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}"); - - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv + openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d ; - - if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash; fi ; - - tar -xzf credentials.tar.gz ; - - gcloud auth activate-service-account --key-file client-secret.json ; - - gcloud config set project simpegdocs; - - gcloud -q components update gae-python; - - gcloud -q preview app deploy ./simpegdocs/app.yaml --version 1 --promote; + if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash; fi ; + tar -xzf credentials.tar.gz ; + gcloud auth activate-service-account --key-file client-secret.json ; + gcloud config set project simpegdocs; + gcloud -q components update gae-python; + gcloud -q preview app deploy ./simpegdocs/app.yaml --version 1 --promote; fi # if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then From fea508a5071d031ffdfec26e2a989c06f309519a Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Fri, 10 Jun 2016 19:39:02 -0700 Subject: [PATCH 64/77] fix path to app.yaml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8dccee5c..2d1a53fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,7 +69,7 @@ after_success: gcloud auth activate-service-account --key-file client-secret.json ; gcloud config set project simpegdocs; gcloud -q components update gae-python; - gcloud -q preview app deploy ./simpegdocs/app.yaml --version 1 --promote; + gcloud -q preview app deploy ./docs/app.yaml --version 1 --promote; fi # if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then From 3fc855f3c9c116bd0ad72c0b9206a7838750b6c1 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Fri, 10 Jun 2016 20:50:41 -0700 Subject: [PATCH 65/77] only push on master --- .travis.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2d1a53fc..e3aaedb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,20 +60,20 @@ script: after_success: - coveralls --config_file .coveragerc - - if [ ${TEST_DIR} == "tests/docs" ]; then - python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}"); - openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv - -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d ; - if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash; fi ; - tar -xzf credentials.tar.gz ; - gcloud auth activate-service-account --key-file client-secret.json ; - gcloud config set project simpegdocs; - gcloud -q components update gae-python; - gcloud -q preview app deploy ./docs/app.yaml --version 1 --promote; + - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then + if [ ${TEST_DIR} == "tests/docs" ]; then + python scripts/fetch_gae_sdk.py $(dirname "${GAE_PYTHONPATH}"); + openssl aes-256-cbc -K $encrypted_93066031461c_key -iv $encrypted_93066031461c_iv + -in docs/credentials.tar.gz.enc -out credentials.tar.gz -d ; + if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash; fi ; + tar -xzf credentials.tar.gz ; + gcloud auth activate-service-account --key-file client-secret.json ; + gcloud config set project simpegdocs; + gcloud -q components update gae-python; + gcloud -q preview app deploy ./docs/app.yaml --version 1 --promote; + fi; fi -# if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then - notifications: email: From 845c3c10ab77409b9b14241ab39dd8bd87488d58 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sat, 11 Jun 2016 07:48:24 -0700 Subject: [PATCH 66/77] version on travis commit --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e3aaedb3..6fab6238 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,7 +70,7 @@ after_success: gcloud auth activate-service-account --key-file client-secret.json ; gcloud config set project simpegdocs; gcloud -q components update gae-python; - gcloud -q preview app deploy ./docs/app.yaml --version 1 --promote; + gcloud -q preview app deploy ./docs/app.yaml --version ${TRAVIS_COMMIT} --promote; fi; fi From 7a82f57367870c346c8905f821ec85d07b98f02b Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sat, 11 Jun 2016 08:16:22 -0700 Subject: [PATCH 67/77] - doc the simple regularization, sparse regularization and regularization mesh - typo fix in MT_3D_Forward example - Solver - use EM.Static.DC for DC example --- SimPEG/Examples/DC_Analytic_Dipole.py | 10 +++++----- SimPEG/Examples/MT_3D_Foward.py | 6 +++--- docs/content/api_core/api_Regularization.rst | 11 +++++++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/SimPEG/Examples/DC_Analytic_Dipole.py b/SimPEG/Examples/DC_Analytic_Dipole.py index aed5eed4..ba999fa3 100644 --- a/SimPEG/Examples/DC_Analytic_Dipole.py +++ b/SimPEG/Examples/DC_Analytic_Dipole.py @@ -1,5 +1,5 @@ from SimPEG import * -import SimPEG.DCIP as DC +import SimPEG.EM.Static.DC as DC def run(plotIt=False): cs = 25. @@ -21,10 +21,10 @@ def run(plotIt=False): # ax.plot(xyz_rxP[:,0],xyz_rxP[:,1], 'w.') # ax.plot(xyz_rxN[:,0],xyz_rxN[:,1], 'r.', ms = 3) - rx = DC.RxDipole(xyz_rxP, xyz_rxN) - src = DC.SrcDipole([rx], [-200, 0, -12.5], [+200, 0, -12.5]) - survey = DC.SurveyDC([src]) - problem = DC.ProblemDC_CC(mesh) + rx = DC.Rx.Dipole(xyz_rxP, xyz_rxN) + src = DC.Src.Dipole([rx], np.r_[-200, 0, -12.5], np.r_[+200, 0, -12.5]) + survey = DC.Survey([src]) + problem = DC.Problem3D_CC(mesh) problem.pair(survey) try: from pymatsolver import MumpsSolver diff --git a/SimPEG/Examples/MT_3D_Foward.py b/SimPEG/Examples/MT_3D_Foward.py index 3baf55a1..1d0db148 100644 --- a/SimPEG/Examples/MT_3D_Foward.py +++ b/SimPEG/Examples/MT_3D_Foward.py @@ -5,9 +5,9 @@ import SimPEG as simpeg from SimPEG import MT import numpy as np try: - from pymatsolver import MumpsSolver as solver + from pymatsolver import MumpsSolver as Solver except: - from SimPEG import solver + from SimPEG import Solver def run(plotIt=True, nFreq=1): """ @@ -46,7 +46,7 @@ def run(plotIt=True, nFreq=1): survey = MT.Survey(srcList) ## Setup the problem object - problem = MT.Problem3D.eForm_ps(M, sigmaPrimary=sigBG, Solver=solver) + problem = MT.Problem3D.eForm_ps(M, sigmaPrimary=sigBG, Solver=Solver) problem.pair(survey) # Calculate the data diff --git a/docs/content/api_core/api_Regularization.rst b/docs/content/api_core/api_Regularization.rst index 4ea1a554..b958e98c 100644 --- a/docs/content/api_core/api_Regularization.rst +++ b/docs/content/api_core/api_Regularization.rst @@ -91,10 +91,21 @@ The API :members: :undoc-members: +.. autoclass:: SimPEG.Regularization.Simple + :show-inheritance: + :members: .. autoclass:: SimPEG.Regularization.Tikhonov :show-inheritance: :members: +.. autoclass:: SimPEG.Regularization.Sparse + :show-inheritance: + :members: + +.. autoclass:: SimPEG.Regularization.RegularizationMesh + :show-inheritance: + :members: + From a3a5c860088bfb58d388c47b6d2d26c933573e49 Mon Sep 17 00:00:00 2001 From: seogi_macbook Date: Sat, 11 Jun 2016 21:58:03 +0200 Subject: [PATCH 68/77] Fix couple bugs in FDEM analytics --- SimPEG/EM/Analytics/FDEM_fields.py | 21 +++++++++------------ SimPEG/EM/Analytics/__init__.py | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEM_fields.py index abf956e8..e0ac1b34 100644 --- a/SimPEG/EM/Analytics/FDEM_fields.py +++ b/SimPEG/EM/Analytics/FDEM_fields.py @@ -11,9 +11,8 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check - if XYZ.shape[0] > 1 & f.length > 1 - except: - print "I/O type error: For multiple field locations only a single frequency can be specified." + if XYZ.shape[0] > 1 & f.shape[0] > 1: + raise Exception("I/O type error: For multiple field locations only a single frequency can be specified.") dx = XYZ[:,0]-srcLoc[0] dy = XYZ[:,1]-srcLoc[1] @@ -51,7 +50,7 @@ def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., Jx = sig*Ex Jy = sig*Ey Jz = sig*Ez - return Jx, Jy, Jz + return Jx, Jy, Jz def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): @@ -60,10 +59,9 @@ def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check - if XYZ.shape[0] > 1 & f.length > 1 - except: - print "I/O type error: For multiple field locations only a single frequency can be specified." - + if XYZ.shape[0] > 1 & f.shape[0] > 1: + raise Exception("I/O type error: For multiple field locations only a single frequency can be specified.") + dx = XYZ[:,0]-srcLoc[0] dy = XYZ[:,1]-srcLoc[1] dz = XYZ[:,2]-srcLoc[2] @@ -99,7 +97,7 @@ def B_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., By = mu*Hy Bz = mu*Hz return Bx, By, Bz - + def A_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) @@ -107,9 +105,8 @@ def A_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check - if XYZ.shape[0] > 1 & f.length > 1 - except: - print "I/O type error: For multiple field locations only a single frequency can be specified." + if XYZ.shape[0] > 1 & f.shape[0] > 1: + raise Exception("I/O type error: For multiple field locations only a single frequency can be specified.") dx = XYZ[:,0]-srcLoc[0] dy = XYZ[:,1]-srcLoc[1] diff --git a/SimPEG/EM/Analytics/__init__.py b/SimPEG/EM/Analytics/__init__.py index 9df2aef7..9c5e5e28 100644 --- a/SimPEG/EM/Analytics/__init__.py +++ b/SimPEG/EM/Analytics/__init__.py @@ -2,3 +2,4 @@ from TDEM import hzAnalyticDipoleT from FDEM import hzAnalyticDipoleF from FDEMcasing import * from DC import DCAnalyticHalf, DCAnalyticSphere +from FDEM_fields import * From 5e3c1da8e2626db11b14578b489faa17e0bad90a Mon Sep 17 00:00:00 2001 From: seogi_macbook Date: Mon, 13 Jun 2016 16:41:59 -0700 Subject: [PATCH 69/77] add place holder for galvanic and inductive electric fields... --- SimPEG/EM/Analytics/FDEM_fields.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEM_fields.py index e0ac1b34..4a521ba1 100644 --- a/SimPEG/EM/Analytics/FDEM_fields.py +++ b/SimPEG/EM/Analytics/FDEM_fields.py @@ -5,6 +5,9 @@ from scipy.special import erf from SimPEG import Utils +# def E_galvanic_from_ElectricDipoleWholeSpaced +# def E_inductive_from_ElectricDipoleWholeSpaced + def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) omega = 2.*np.pi*f @@ -45,6 +48,10 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., Ey = front*(dz*dy / r**2)*mid return Ex, Ey, Ez + +# def J_galvanic_from_ElectricDipoleWholeSpaced +# def J_inductive_from_ElectricDipoleWholeSpaced + def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): Ex, Ey, Ez = E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) Jx = sig*Ex From 093f441331c034e8dfb27ce91d4495c13e690efb Mon Sep 17 00:00:00 2001 From: micmitch Date: Mon, 13 Jun 2016 17:35:52 -0700 Subject: [PATCH 70/77] Added functions to split electric field into "galvanic" and "inductive" portions. --- SimPEG/EM/Analytics/FDEM_fields.py | 102 +++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 6 deletions(-) diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEM_fields.py index 4a521ba1..ac18da7f 100644 --- a/SimPEG/EM/Analytics/FDEM_fields.py +++ b/SimPEG/EM/Analytics/FDEM_fields.py @@ -4,10 +4,6 @@ from scipy.constants import mu_0, pi from scipy.special import erf from SimPEG import Utils - -# def E_galvanic_from_ElectricDipoleWholeSpaced -# def E_inductive_from_ElectricDipoleWholeSpaced - def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) omega = 2.*np.pi*f @@ -49,8 +45,86 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., return Ex, Ey, Ez -# def J_galvanic_from_ElectricDipoleWholeSpaced -# def J_inductive_from_ElectricDipoleWholeSpaced +def E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + epsilon = 8.854187817*(10.**-12) + omega = 2.*np.pi*f + + XYZ = Utils.asArray_N_x_Dim(XYZ, 3) + # Check + if XYZ.shape[0] > 1 & f.shape[0] > 1: + raise Exception("I/O type error: For multiple field locations only a single frequency can be specified.") + + dx = XYZ[:,0]-srcLoc[0] + dy = XYZ[:,1]-srcLoc[1] + dz = XYZ[:,2]-srcLoc[2] + + r = np.sqrt( dx**2. + dy**2. + dz**2.) + # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) + k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + + front = current * length / (4.*np.pi*sig* r**3) * np.exp(-1j*k*r) + mid = -k**2 * r**2 + 3*1j*k*r + 3 + + if orientation.upper() == 'X': + Ex_galvanic = front*((dx**2 / r**2)*mid + (-1j*k*r-1.)) + Ey_galvanic = front*(dx*dy / r**2)*mid + Ez_galvanic = front*(dx*dz / r**2)*mid + return Ex_galvanic, Ey_galvanic, Ez_galvanic + + elif orientation.upper() == 'Y': + # x--> y, y--> z, z-->x + Ey_galvanic = front*((dy**2 / r**2)*mid + (-1j*k*r-1.)) + Ez_galvanic = front*(dy*dz / r**2)*mid + Ex_galvanic = front*(dy*dx / r**2)*mid + return Ex_galvanic, Ey_galvanic, Ez_galvanic + + elif orientation.upper() == 'Z': + # x --> z, y --> x, z --> y + Ez_galvanic = front*((dz**2 / r**2)*mid + (-1j*k*r-1.)) + Ex_galvanic = front*(dz*dx / r**2)*mid + Ey_galvanic = front*(dz*dy / r**2)*mid + return Ex_galvanic, Ey_galvanic, Ez_galvanic + + +def E_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + epsilon = 8.854187817*(10.**-12) + omega = 2.*np.pi*f + + XYZ = Utils.asArray_N_x_Dim(XYZ, 3) + # Check + if XYZ.shape[0] > 1 & f.shape[0] > 1: + raise Exception("I/O type error: For multiple field locations only a single frequency can be specified.") + + dx = XYZ[:,0]-srcLoc[0] + dy = XYZ[:,1]-srcLoc[1] + dz = XYZ[:,2]-srcLoc[2] + + r = np.sqrt( dx**2. + dy**2. + dz**2.) + # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) + k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + + front = current * length / (4.*np.pi*sig* r**3) * np.exp(-1j*k*r) + + if orientation.upper() == 'X': + Ex_inductive = front*(k**2 * r**2) + Ey_inductive = 0 + Ez_inductive = 0 + return Ex_inductive, Ey_inductive, Ez_inductive + + elif orientation.upper() == 'Y': + # x--> y, y--> z, z-->x + Ey_inductive = front*(k**2 * r**2) + Ez_inductive = 0 + Ex_inductive = 0 + return Ex_inductive, Ey_inductive, Ez_inductive + + elif orientation.upper() == 'Z': + # x --> z, y --> x, z --> y + Ez_inductive = front*(k**2 * r**2) + Ex_inductive = 0 + Ey_inductive = 0 + return Ex_inductive, Ey_inductive, Ez_inductive + def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): Ex, Ey, Ez = E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) @@ -60,6 +134,22 @@ def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., return Jx, Jy, Jz +def J_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + Ex_galvanic, Ey_galvanic, Ez_galvanic = E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) + Jx_galvanic = sig*Ex_galvanic + Jy_galvanic = sig*Ey_galvanic + Jz_galvanic = sig*Ez_galvanic + return Jx_galvanic, Jy_galvanic, Jz_galvanic + + +def J_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): + Ex_inductive, Ey_inductive, Ez_inductive = E_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) + Jx_inductive = sig*Ex_inductive + Jy_inductive = sig*Ey_inductive + Jz_inductive = sig*Ez_inductive + return Jx_inductive, Jy_inductive, Jz_inductive + + def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) omega = 2.*np.pi*f From b9d30af4a88903da8941e4afa6355cece6c939eb Mon Sep 17 00:00:00 2001 From: micmitch Date: Mon, 13 Jun 2016 17:47:46 -0700 Subject: [PATCH 71/77] Changed \sigma to \hat{\sigma} = \sigma + i \omega \epsilon in the E field calculations. --- SimPEG/EM/Analytics/FDEM_fields.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEM_fields.py index ac18da7f..467407af 100644 --- a/SimPEG/EM/Analytics/FDEM_fields.py +++ b/SimPEG/EM/Analytics/FDEM_fields.py @@ -7,6 +7,7 @@ from SimPEG import Utils def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) omega = 2.*np.pi*f + sig_hat = sig + 1j*omega*epsilon XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check @@ -21,7 +22,7 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) - front = current * length / (4.*np.pi*sig* r**3) * np.exp(-1j*k*r) + front = current * length / (4.*np.pi*sig_hat* r**3) * np.exp(-1j*k*r) mid = -k**2 * r**2 + 3*1j*k*r + 3 if orientation.upper() == 'X': @@ -48,6 +49,7 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., def E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) omega = 2.*np.pi*f + sig_hat = sig + 1j*omega*epsilon XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check @@ -62,7 +64,7 @@ def E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., l # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) - front = current * length / (4.*np.pi*sig* r**3) * np.exp(-1j*k*r) + front = current * length / (4.*np.pi*sig_hat* r**3) * np.exp(-1j*k*r) mid = -k**2 * r**2 + 3*1j*k*r + 3 if orientation.upper() == 'X': @@ -89,6 +91,7 @@ def E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., l def E_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) omega = 2.*np.pi*f + sig_hat = sig + 1j*omega*epsilon XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check @@ -103,7 +106,7 @@ def E_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) - front = current * length / (4.*np.pi*sig* r**3) * np.exp(-1j*k*r) + front = current * length / (4.*np.pi*sig_hat* r**3) * np.exp(-1j*k*r) if orientation.upper() == 'X': Ex_inductive = front*(k**2 * r**2) From e815ddaec79d59e142a9a3899d0fc1bac7434340 Mon Sep 17 00:00:00 2001 From: micmitch Date: Tue, 14 Jun 2016 15:15:53 -0700 Subject: [PATCH 72/77] Removed d typos from the end of function names. --- SimPEG/EM/Analytics/FDEM_fields.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEM_fields.py index 467407af..bd1ee368 100644 --- a/SimPEG/EM/Analytics/FDEM_fields.py +++ b/SimPEG/EM/Analytics/FDEM_fields.py @@ -46,7 +46,7 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., return Ex, Ey, Ez -def E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): +def E_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) omega = 2.*np.pi*f sig_hat = sig + 1j*omega*epsilon @@ -88,7 +88,7 @@ def E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., l return Ex_galvanic, Ey_galvanic, Ez_galvanic -def E_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): +def E_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): epsilon = 8.854187817*(10.**-12) omega = 2.*np.pi*f sig_hat = sig + 1j*omega*epsilon @@ -137,7 +137,7 @@ def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., return Jx, Jy, Jz -def J_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): +def J_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): Ex_galvanic, Ey_galvanic, Ez_galvanic = E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) Jx_galvanic = sig*Ex_galvanic Jy_galvanic = sig*Ey_galvanic @@ -145,7 +145,7 @@ def J_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., l return Jx_galvanic, Jy_galvanic, Jz_galvanic -def J_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): +def J_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): Ex_inductive, Ey_inductive, Ez_inductive = E_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) Jx_inductive = sig*Ex_inductive Jy_inductive = sig*Ey_inductive From f0944362c8afded6dc263629681775705fb73256 Mon Sep 17 00:00:00 2001 From: micmitch Date: Tue, 14 Jun 2016 15:22:36 -0700 Subject: [PATCH 73/77] Silly mistake... needed zero arrays instead of scalars. --- SimPEG/EM/Analytics/FDEM_fields.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEM_fields.py index bd1ee368..ca250ad6 100644 --- a/SimPEG/EM/Analytics/FDEM_fields.py +++ b/SimPEG/EM/Analytics/FDEM_fields.py @@ -110,22 +110,22 @@ def E_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., l if orientation.upper() == 'X': Ex_inductive = front*(k**2 * r**2) - Ey_inductive = 0 - Ez_inductive = 0 + Ey_inductive = np.zeros_like(Ex_inductive) + Ez_inductive = np.zeros_like(Ex_inductive) return Ex_inductive, Ey_inductive, Ez_inductive elif orientation.upper() == 'Y': # x--> y, y--> z, z-->x Ey_inductive = front*(k**2 * r**2) - Ez_inductive = 0 - Ex_inductive = 0 + Ez_inductive = np.zeros_like(Ey_inductive) + Ex_inductive = np.zeros_like(Ey_inductive) return Ex_inductive, Ey_inductive, Ez_inductive elif orientation.upper() == 'Z': # x --> z, y --> x, z --> y Ez_inductive = front*(k**2 * r**2) - Ex_inductive = 0 - Ey_inductive = 0 + Ex_inductive = np.zeros_like(Ez_inductive) + Ey_inductive = np.zeros_like(Ez_inductive) return Ex_inductive, Ey_inductive, Ez_inductive From a54713f54688c268ecb7d5e3ed261c3ff2ae3881 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Wed, 22 Jun 2016 11:32:54 -0600 Subject: [PATCH 74/77] Change to NotImplementedError. --- SimPEG/Survey.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SimPEG/Survey.py b/SimPEG/Survey.py index fbc88276..65c46972 100644 --- a/SimPEG/Survey.py +++ b/SimPEG/Survey.py @@ -311,7 +311,6 @@ class BaseSurvey(object): if f is None: f = self.prob.fields(m) return Utils.mkvc(self.eval(f)) - @Utils.count def eval(self, f): """eval(f) @@ -322,7 +321,7 @@ class BaseSurvey(object): d_\\text{pred} = \mathbf{P} f(m) """ - raise NotImplemented('eval is not yet implemented.') + raise NotImplementedError('eval is not yet implemented.') @Utils.count def evalDeriv(self, f): @@ -334,7 +333,7 @@ class BaseSurvey(object): \\frac{\partial d_\\text{pred}}{\partial u} = \mathbf{P} """ - raise NotImplemented('eval is not yet implemented.') + raise NotImplementedError('eval is not yet implemented.') @Utils.count def residual(self, m, f=None): From e1ba80883d1dcaaac8f7804812ec216b8b974fea Mon Sep 17 00:00:00 2001 From: seogi_macbook Date: Thu, 23 Jun 2016 09:10:50 -0700 Subject: [PATCH 75/77] Incorporate Lindsey's suggestoins --- .../{FDEM_fields.py => FDEMDipolarfields.py} | 125 +++++++++++++----- 1 file changed, 93 insertions(+), 32 deletions(-) rename SimPEG/EM/Analytics/{FDEM_fields.py => FDEMDipolarfields.py} (69%) diff --git a/SimPEG/EM/Analytics/FDEM_fields.py b/SimPEG/EM/Analytics/FDEMDipolarfields.py similarity index 69% rename from SimPEG/EM/Analytics/FDEM_fields.py rename to SimPEG/EM/Analytics/FDEMDipolarfields.py index ca250ad6..ef724542 100644 --- a/SimPEG/EM/Analytics/FDEM_fields.py +++ b/SimPEG/EM/Analytics/FDEMDipolarfields.py @@ -1,13 +1,24 @@ from __future__ import division import numpy as np -from scipy.constants import mu_0, pi +from scipy.constants import mu_0, pi, epsilon_0 from scipy.special import erf from SimPEG import Utils -def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - epsilon = 8.854187817*(10.**-12) - omega = 2.*np.pi*f - sig_hat = sig + 1j*omega*epsilon +omega = lambda f: 2.*np.pi*f +# TODO: +# r = lambda dx, dy, dz: np.sqrt( dx**2. + dy**2. + dz**2.) +# k = lambda f, mu, epsilon, sig: np.sqrt( omega(f)**2. *mu*epsilon -1j*omega(f)*mu*sig ) + +def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=0., epsr=1.): + + """ + Computing Analytic Electric fields from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + mu = mu_0*(1+kappa) + epsilon = epsilon_0*epsr + sig_hat = sig + 1j*omeg*epsilon XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check @@ -20,7 +31,7 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., r = np.sqrt( dx**2. + dy**2. + dz**2.) # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) - k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + k = np.sqrt( omega(f)**2. *mu*epsilon -1j*omega(f)*mu*sig ) front = current * length / (4.*np.pi*sig_hat* r**3) * np.exp(-1j*k*r) mid = -k**2 * r**2 + 3*1j*k*r + 3 @@ -46,10 +57,16 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., return Ex, Ey, Ez -def E_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - epsilon = 8.854187817*(10.**-12) - omega = 2.*np.pi*f - sig_hat = sig + 1j*omega*epsilon +def E_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.): + + """ + Computing Galvanic portion of Electric fields from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + mu = mu_0*(1+kappa) + epsilon = epsilon_0*epsr + sig_hat = sig + 1j*omeg*epsilon XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check @@ -62,7 +79,7 @@ def E_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., le r = np.sqrt( dx**2. + dy**2. + dz**2.) # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) - k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + k = np.sqrt( omega(f)**2. *mu*epsilon -1j*omega(f)*mu*sig ) front = current * length / (4.*np.pi*sig_hat* r**3) * np.exp(-1j*k*r) mid = -k**2 * r**2 + 3*1j*k*r + 3 @@ -88,10 +105,16 @@ def E_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., le return Ex_galvanic, Ey_galvanic, Ez_galvanic -def E_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - epsilon = 8.854187817*(10.**-12) - omega = 2.*np.pi*f - sig_hat = sig + 1j*omega*epsilon +def E_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.): + + """ + Computing Inductive portion of Electric fields from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + mu = mu_0*(1+kappa) + epsilon = epsilon_0*epsr + sig_hat = sig + 1j*omeg*epsilon XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check @@ -104,7 +127,7 @@ def E_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., l r = np.sqrt( dx**2. + dy**2. + dz**2.) # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) - k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + k = np.sqrt( omega(f)**2. *mu*epsilon -1j*omega(f)*mu*sig ) front = current * length / (4.*np.pi*sig_hat* r**3) * np.exp(-1j*k*r) @@ -129,34 +152,60 @@ def E_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., l return Ex_inductive, Ey_inductive, Ez_inductive -def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - Ex, Ey, Ez = E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) +def J_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.): + + """ + Computing Current densities from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + + Ex, Ey, Ez = E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.) Jx = sig*Ex Jy = sig*Ey Jz = sig*Ez return Jx, Jy, Jz -def J_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - Ex_galvanic, Ey_galvanic, Ez_galvanic = E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) +def J_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.): + + """ + Computing Galvanic portion of Current densities from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + + Ex_galvanic, Ey_galvanic, Ez_galvanic = E_galvanic_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.) Jx_galvanic = sig*Ex_galvanic Jy_galvanic = sig*Ey_galvanic Jz_galvanic = sig*Ez_galvanic return Jx_galvanic, Jy_galvanic, Jz_galvanic -def J_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - Ex_inductive, Ey_inductive, Ez_inductive = E_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) +def J_inductive_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.): + + """ + Computing Inductive portion of Current densities from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + + Ex_inductive, Ey_inductive, Ez_inductive = E_inductive_from_ElectricDipoleWholeSpaced(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.) Jx_inductive = sig*Ex_inductive Jy_inductive = sig*Ey_inductive Jz_inductive = sig*Ez_inductive return Jx_inductive, Jy_inductive, Jz_inductive -def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - epsilon = 8.854187817*(10.**-12) - omega = 2.*np.pi*f +def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.): + """ + Computing Magnetic fields from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + mu = mu_0*(1+kappa) + epsilon = epsilon_0*epsr XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check if XYZ.shape[0] > 1 & f.shape[0] > 1: @@ -168,7 +217,7 @@ def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., r = np.sqrt( dx**2. + dy**2. + dz**2.) # k = np.sqrt( -1j*2.*np.pi*f*mu*sig ) - k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + k = np.sqrt( omega(f)**2. *mu*epsilon -1j*omega(f)*mu*sig ) front = current * length / (4.*np.pi* r**2) * (-1j*k*r + 1) * np.exp(-1j*k*r) @@ -191,18 +240,30 @@ def H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., return Hx, Hy, Hz -def B_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - Hx, Hy, Hz = H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0) +def B_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.): + + """ + Computing Magnetic flux densites from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + + Hx, Hy, Hz = H_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.) Bx = mu*Hx By = mu*Hy Bz = mu*Hz return Bx, By, Bz -def A_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', mu=mu_0): - epsilon = 8.854187817*(10.**-12) - omega = 2.*np.pi*f +def A_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., orientation='X', kappa=1., epsr=1.): + """ + Computing Electric vector potentials from Electrical Dipole in a Wholespace + TODO: + Add description of parameters + """ + mu = mu_0*(1+kappa) + epsilon = epsilon_0*epsr XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check if XYZ.shape[0] > 1 & f.shape[0] > 1: @@ -213,7 +274,7 @@ def A_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., dz = XYZ[:,2]-srcLoc[2] r = np.sqrt( dx**2. + dy**2. + dz**2.) - k = np.sqrt( omega**2. *mu*epsilon -1j*omega*mu*sig ) + k = np.sqrt( omega(f)**2. *mu*epsilon -1j*omega(f)*mu*sig ) front = current * length / (4.*np.pi*r) From 8b44f8d96b91dec91a1f0d5dc1cad1c96e59cf43 Mon Sep 17 00:00:00 2001 From: seogi_macbook Date: Thu, 23 Jun 2016 10:14:13 -0700 Subject: [PATCH 76/77] change FDEM_fields.py to FDEMDipolarfield.py --- SimPEG/EM/Analytics/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimPEG/EM/Analytics/__init__.py b/SimPEG/EM/Analytics/__init__.py index 9c5e5e28..8331501d 100644 --- a/SimPEG/EM/Analytics/__init__.py +++ b/SimPEG/EM/Analytics/__init__.py @@ -2,4 +2,4 @@ from TDEM import hzAnalyticDipoleT from FDEM import hzAnalyticDipoleF from FDEMcasing import * from DC import DCAnalyticHalf, DCAnalyticSphere -from FDEM_fields import * +from FDEMDipolarfields import * From 0763925743e4ff26ce2e4831824870b78ab5e0c7 Mon Sep 17 00:00:00 2001 From: seogi_macbook Date: Thu, 23 Jun 2016 14:12:49 -0700 Subject: [PATCH 77/77] fix minor bugs in analytics --- SimPEG/EM/Analytics/FDEMDipolarfields.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SimPEG/EM/Analytics/FDEMDipolarfields.py b/SimPEG/EM/Analytics/FDEMDipolarfields.py index ef724542..7b79a680 100644 --- a/SimPEG/EM/Analytics/FDEMDipolarfields.py +++ b/SimPEG/EM/Analytics/FDEMDipolarfields.py @@ -18,7 +18,7 @@ def E_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., length=1., """ mu = mu_0*(1+kappa) epsilon = epsilon_0*epsr - sig_hat = sig + 1j*omeg*epsilon + sig_hat = sig + 1j*omega(f)*epsilon XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check @@ -66,7 +66,7 @@ def E_galvanic_from_ElectricDipoleWholeSpace(XYZ, srcLoc, sig, f, current=1., le """ mu = mu_0*(1+kappa) epsilon = epsilon_0*epsr - sig_hat = sig + 1j*omeg*epsilon + sig_hat = sig + 1j*omega(f)*epsilon XYZ = Utils.asArray_N_x_Dim(XYZ, 3) # Check