-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from simpeg/feat/em
Feat/em
- Loading branch information
Showing
28 changed files
with
1,869 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[bumpversion] | ||
current_version = 0.0.1 | ||
files = setup.py geoana/__init__.py docs/conf.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
PACKAGE_NAME=geoana | ||
|
||
.PHONY: install coverage lint graphs tests docs clean deploy | ||
|
||
install: | ||
python setup.py install | ||
|
||
coverage: | ||
nosetests --logging-level=INFO --with-coverage --cover-package=geoana --cover-html | ||
open cover/index.html | ||
|
||
lint: | ||
pylint $(PACKAGE_NAME) | ||
|
||
lint-html: | ||
pylint --output-format=html $(PACKAGE_NAME) > pylint.html | ||
|
||
graphs: | ||
pyreverse -my -A -o pdf -p geoana geoana/**.py geoana/**/**.py | ||
|
||
tests: | ||
nosetests --logging-level=INFO | ||
|
||
docs: | ||
cd docs;make html | ||
|
||
clean_pyc: | ||
find . -name "*.pyc" | xargs -I {} rm -v "{}" | ||
|
||
clean: clean_pyc | ||
cd docs;make clean | ||
|
||
deploy: | ||
python setup.py sdist upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# AppVeyor.com is a Continuous Integration service to build and run tests under Windows | ||
|
||
build: off | ||
|
||
environment: | ||
matrix: | ||
- PYTHON: 2.7 | ||
MINICONDA: C:\Miniconda | ||
PYTHON_ARCH: 32 | ||
|
||
- PYTHON: 3.5 | ||
MINICONDA: C:\Miniconda3 | ||
PYTHON_ARCH: 32 | ||
|
||
- PYTHON: 3.6 | ||
MINICONDA: C:\Miniconda3 | ||
PYTHON_ARCH: 32 | ||
|
||
- PYTHON: 2.7 | ||
MINICONDA: C:\Miniconda | ||
PYTHON_ARCH: 64 | ||
|
||
- PYTHON: 3.5 | ||
MINICONDA: C:\Miniconda3 | ||
PYTHON_ARCH: 64 | ||
|
||
- PYTHON: 3.6 | ||
MINICONDA: C:\Miniconda3 | ||
PYTHON_ARCH: 64 | ||
|
||
init: | ||
- "ECHO %PYTHON% %MINICONDA%" | ||
|
||
install: | ||
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%" | ||
- conda config --set always_yes yes --set changeps1 no | ||
- conda update -q conda | ||
- conda info -a | ||
- "conda create -q -n test-environment python=%PYTHON% numpy scipy matplotlib cython jupyter ipython pillow wheel" | ||
- activate test-environment | ||
- pip install -r requirements_dev.txt | ||
- python setup.py install | ||
|
||
test_script: | ||
- nosetests tests -v -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. _earthquake: | ||
|
||
Earthquake | ||
========== | ||
|
||
.. autoclass:: geoana.earthquake | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.. _em: | ||
|
||
Electromagnetics | ||
================ | ||
|
||
.. autoclass:: geoana.em | ||
:members: | ||
:undoc-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
.. _index: | ||
|
||
|
||
.. include:: ../README.rst | ||
|
||
Contents: | ||
|
||
**Contents:** | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` | ||
content/earthquake | ||
content/em | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Examples | ||
******** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Electromagnetics | ||
**************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
""" | ||
Electric Dipole in a Whole Space: Frequency Domain | ||
================================================== | ||
In this example, we plot electric and magnetic flux density due to an electric | ||
dipole in a whole space. Note that you can also examine the current density | ||
and magnetic field. | ||
We can vary the conductivity, magnetic permeability and dielectric permittivity | ||
of the wholespace, the frequency of the source and whether or not the | ||
quasistatic assumption is imposed. | ||
""" | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from matplotlib.colors import LogNorm | ||
from scipy.constants import mu_0, epsilon_0 | ||
|
||
from geoana import utils, spatial | ||
from geoana.em import fdem | ||
|
||
# define frequencies that we want to look at | ||
frequencies = np.logspace(0, 4, 3) | ||
|
||
# Build the electric dipole object | ||
edipole = fdem.ElectricDipoleWholeSpace( | ||
sigma=1., # conductivity of 1 S/m | ||
mu=mu_0, # permeability of free space (this is the default) | ||
epsilon=epsilon_0, # permittivity of free space (this is the default) | ||
location=np.r_[0., 0., 0.], # location of the dipole | ||
orientation='Z', # vertical dipole (can also be a unit-vector) | ||
quasistatic=False # don't use the quasistatic assumption | ||
) | ||
|
||
# construct a grid where we want to plot electric fields | ||
x = np.linspace(-50, 50, 100) | ||
z = np.linspace(-50, 50, 100) | ||
xyz = utils.ndgrid([x, np.r_[0], z]) | ||
|
||
|
||
# plot amplitude | ||
def plot_amplitude(ax, v): | ||
v = spatial.vector_magnitude(v) | ||
plt.colorbar( | ||
ax.pcolormesh( | ||
x, z, v.reshape(len(x), len(z), order='F'), norm=LogNorm() | ||
), ax=ax | ||
) | ||
ax.axis('square') | ||
ax.set_xlabel('x (m)') | ||
ax.set_ylabel('z (m)') | ||
|
||
|
||
# plot streamlines | ||
def plot_streamlines(ax, v): | ||
vx = v[:, 0].reshape(len(x), len(z), order='F') | ||
vz = v[:, 2].reshape(len(x), len(z), order='F') | ||
ax.streamplot(x, z, vx.T, vz.T, color='k') | ||
|
||
|
||
# create fig, ax for electric fields and magnetic flux | ||
fig_e, ax_e = plt.subplots( | ||
2, len(frequencies), figsize=(5*len(frequencies), 7) | ||
) | ||
fig_b, ax_b = plt.subplots( | ||
2, len(frequencies), figsize=(5*len(frequencies), 7) | ||
) | ||
|
||
# loop over frequencies and plot | ||
for i, frequency in enumerate(frequencies): | ||
|
||
# set the frequency of the dipole | ||
edipole.frequency = frequency | ||
|
||
# evaluate the electric field and magnetic flux density | ||
electric_field = edipole.electric_field(xyz) | ||
magnetic_flux_density = edipole.magnetic_flux_density(xyz) | ||
|
||
# plot amplitude of electric field | ||
for ax, reim in zip(ax_e[:, i], ['real', 'imag']): | ||
# grab real or imag component | ||
e_plot = getattr(electric_field, reim) | ||
|
||
# plot both amplitude and streamlines | ||
plot_amplitude(ax, e_plot) | ||
plot_streamlines(ax, e_plot) | ||
|
||
# set the title | ||
ax.set_title( | ||
'E {} at {:1.1e} Hz'.format(reim, frequency) | ||
) | ||
|
||
# plot the amplitude of the magnetic field (note the magnetic field is into | ||
# and out of the page in this geometry, so we don't plot vectors) | ||
for ax, reim in zip(ax_b[:, i], ['real', 'imag']): | ||
# grab real or imag component | ||
b_plot = getattr(magnetic_flux_density, reim) | ||
|
||
# plot amplitude | ||
plot_amplitude(ax, b_plot) | ||
|
||
# set the title | ||
ax.set_title( | ||
'B {} at {:1.1e} Hz'.format(reim, frequency) | ||
) | ||
|
||
# format so text doesn't overlap | ||
fig_e.tight_layout() | ||
fig_b.tight_layout() | ||
plt.show() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
from . import earthquake | ||
from . import em | ||
from . import utils | ||
|
||
__version__ = '0.0.1' | ||
__author__ = 'SimPEG developers' | ||
__license__ = 'MIT' | ||
__copyright__ = 'Copyright 2017 SimPEG developers' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import static | ||
from . import fdem | ||
from . import tdem |
Oops, something went wrong.