-
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 #13 from simpeg/magnetic_pole
magnetic pole
- Loading branch information
Showing
9 changed files
with
204 additions
and
10 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[bumpversion] | ||
current_version = 0.0.4 | ||
current_version = 0.0.5 | ||
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
120 changes: 120 additions & 0 deletions
120
examples/em/plot_static_magnetic_fields_from_pole_source.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
""" | ||
Total magnetic fields: Dipole and Pole sources | ||
============================================== | ||
In this example, we plot anomalous total magnetic field | ||
from a magnetic dipole and pole targets. These targets are | ||
excited by Earth magnetic fields. | ||
We can vary the direction of the Earth magnetic field, and | ||
magnetic moment of the target. | ||
:author: Seogi Kang (`@sgkang <https://github.com/sgkang>`_) | ||
:date: Aug 19, 2018 | ||
""" | ||
|
||
|
||
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 static | ||
|
||
############################################################################### | ||
# Setup | ||
# ----- | ||
# | ||
# define the location, orientation, and source, physical properties of the | ||
# wholespace and source parameters | ||
|
||
mu = mu_0 # permeability of free space (this is the default) | ||
location = np.r_[0., 0., -10.] # location of the dipole or pole | ||
|
||
# dipole parameters | ||
moment = 1 | ||
# inclination and declination (e.g. Vancouver) | ||
inclination, declination = 67., 0. | ||
|
||
|
||
############################################################################### | ||
# Magnetostatic Dipole and Loop | ||
# ----------------------------- | ||
# | ||
# Here, we build the geoana magnetic dipole and poie in a wholespace | ||
# using the parameters defined above. | ||
|
||
def id_to_cartesian(inclination, declination): | ||
ux = np.cos(inclination/180.*np.pi)*np.sin(declination/180.*np.pi) | ||
uy = np.cos(inclination/180.*np.pi)*np.cos(declination/180.*np.pi) | ||
uz = -np.sin(inclination/180.*np.pi) | ||
return np.r_[ux, uy, uz] | ||
|
||
orientation = id_to_cartesian(inclination, declination) | ||
|
||
dipole = static.MagneticDipoleWholeSpace( | ||
location=location, | ||
orientation=orientation, | ||
moment=moment | ||
) | ||
|
||
pole = static.MagneticPoleWholeSpace( | ||
location=location, | ||
orientation=orientation, | ||
moment=moment | ||
) | ||
|
||
############################################################################### | ||
# Evaluate magnetic fields | ||
# -------------------------- | ||
# | ||
# Next, we construct a grid where we want to plot the magentic fields and | ||
# evaluate | ||
|
||
x = np.linspace(-36, 36, 100) | ||
y = np.linspace(-36, 36, 100) | ||
xyz = utils.ndgrid([x, y, np.r_[1.]]) | ||
|
||
# evaluate the magnetic field | ||
b_vec_dipole = dipole.magnetic_flux_density(xyz) | ||
b_vec_pole = pole.magnetic_flux_density(xyz) | ||
b_total_dipole = dipole.dot_orientation(b_vec_dipole) | ||
b_total_pole = pole.dot_orientation(b_vec_pole) | ||
############################################################################### | ||
# | ||
# and define plotting code to plot an image of the amplitude of the vector | ||
# field / flux as well as the streamlines | ||
|
||
|
||
def plot_amplitude(ax, v): | ||
plt.colorbar( | ||
ax.pcolormesh( | ||
x, y, v.reshape(len(x), len(y), order='F') | ||
), ax=ax | ||
) | ||
ax.axis('square') | ||
ax.set_xlabel('y (east, m)') | ||
ax.set_ylabel('x (north, m)') | ||
|
||
############################################################################### | ||
# | ||
# Create subplots for plotting the results. Loop over frequencies and plot the | ||
# electric and magnetic fields along a slice through the center of the dipole. | ||
|
||
fig, ax = plt.subplots(1, 2, figsize=(12, 5)) | ||
|
||
# plot dipole vector potential | ||
plot_amplitude(ax[0], b_total_dipole) | ||
|
||
# plot loop vector potential | ||
plot_amplitude(ax[1], b_total_pole) | ||
|
||
|
||
# set the titles | ||
ax[0].set_title("Total field: dipole") | ||
ax[1].set_title("Total field: pole") | ||
|
||
# format so text doesn't overlap | ||
plt.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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters