Skip to content

Commit

Permalink
Add labels and use equal aspect ratio for axes in plots of radiation …
Browse files Browse the repository at this point in the history
…pattern in tutorial (#2725)

* add axis labels to and modify aspect ratio of plots of radiation pattern

* add note about dimensionful radial flux and its arbitrary units

* change single to double quotes in strings
  • Loading branch information
oskooi authored Nov 21, 2023
1 parent d7a44a7 commit 7bb4d55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doc/docs/Python_Tutorials/Near_to_Far_Field_Spectra.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ $$P_{total} = \int_0^{2\pi} \int_0^{\frac{\pi}{2}} P(\theta) r^2 \sin(\theta) d\

An angular grid of $N$ equally spaced points in $[0, \pi/2]$ has $\Delta \theta = \frac{\pi}{2(N - 1)}$. Note that the same $r^2 \sin(\theta)$ weighting is necessary for the power in any cone, not just over all angles.

A plot of the radiation pattern in polar coordinates and 3D is shown below. Note regarding the coordinate axes in the polar plot: 0° is in the $+z$ direction which is normal to the ground plane and 90° is in the $+r$ direction which is parallel to the ground plane. This is consistent with the convention for the polar angle $\theta$ used in spherical coordinates.
A plot of the radiation pattern in polar coordinates and 3D is shown below. Note regarding the coordinate axes in the polar plot: 0° is in the $+z$ direction which is normal to the ground plane and 90° is in the $+r$ direction which is parallel to the ground plane. This is consistent with the convention for the polar angle $\theta$ used in spherical coordinates. Also note that the radial flux is a dimensionful quantity but because Meep uses $c = 1$, $\varepsilon_0 = 1$, and $\mu_0 = 1$ its units are arbitrary.

![](../images/disc_radiation_pattern_polar_vs_3d.png#center)

Expand Down Expand Up @@ -443,6 +443,7 @@ def plot_radiation_pattern_polar(Ptheta: np.ndarray):
ax.set_thetalim(0, 0.5 * math.pi)
ax.grid(True)
ax.set_rlabel_position(22)
ax.set_ylabel("radial flux (a.u.)")
ax.set_title("radiation pattern in polar coordinates")

if mp.am_master():
Expand Down Expand Up @@ -474,6 +475,9 @@ def plot_radiation_pattern_3d(Ptheta: np.ndarray):
fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, figsize=(6,6))
ax.plot_surface(xs, ys, zs, cmap="inferno")
ax.set_title("radiation pattern in 3d")
ax.set_box_aspect((np.amax(xs), np.amax(ys), np.amax(zs)))
ax.set_zlabel("radial flux (a.u.)")
ax.set(xticklabels=[], yticklabels=[])

if mp.am_master():
fig.savefig(
Expand Down
Binary file modified doc/docs/images/disc_radiation_pattern_polar_vs_3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions python/examples/disc_radiation_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def plot_radiation_pattern_polar(Ptheta: np.ndarray):
ax.set_thetalim(0, 0.5 * math.pi)
ax.grid(True)
ax.set_rlabel_position(22)
ax.set_ylabel("radial flux (a.u.)")
ax.set_title("radiation pattern in polar coordinates")

if mp.am_master():
Expand Down Expand Up @@ -88,6 +89,9 @@ def plot_radiation_pattern_3d(Ptheta: np.ndarray):
fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, figsize=(6, 6))
ax.plot_surface(xs, ys, zs, cmap="inferno")
ax.set_title("radiation pattern in 3d")
ax.set_box_aspect((np.amax(xs), np.amax(ys), np.amax(zs)))
ax.set_zlabel("radial flux (a.u.)")
ax.set(xticklabels=[], yticklabels=[])

if mp.am_master():
fig.savefig(
Expand Down

0 comments on commit 7bb4d55

Please sign in to comment.