Skip to content

Commit

Permalink
Add option to plot vertical lines from heliographic equatorial plane …
Browse files Browse the repository at this point in the history
…in 3D visualizations
  • Loading branch information
jgieseler committed Nov 15, 2024
1 parent 4f05185 commit fc5b57c
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions solarmach/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,8 @@ def legend_arrow(width, height, **_):
return fig, ax

def pfss_3d(self, active_area=(None, None, None, None), color_code='object', rss=2.5,
plot_spirals=True, plot_sun_body_line=False, markers=False, numbered_markers=False, plot_equatorial_plane=True, plot_3d_grid=True,
plot_spirals=True, plot_sun_body_line=False, plot_vertical_line=False,
markers=False, numbered_markers=False, plot_equatorial_plane=True, plot_3d_grid=True,
reference_vsw=400, zoom_out=False, return_plot_object=False):
"""
Plots a 3D visualization of the Potential Field Source Surface (PFSS) model using Plotly.
Expand All @@ -1709,6 +1710,8 @@ def pfss_3d(self, active_area=(None, None, None, None), color_code='object', rss
If True, plots the Parker spirals. Default is True.
plot_sun_body_line : bool, optional
If True, plots the direct line from the Sun to the body. Default is False.
plot_vertical_line : bool, optional
If True, plots vertical lines from the heliographic equatorial plane to each body. Default is False.
markers : bool or str, optional
If True or 'letters'/'numbers', plot markers at body positions. Default is False.
plot_equatorial_plane : bool, optional
Expand Down Expand Up @@ -1954,6 +1957,27 @@ def pfss_3d(self, active_area=(None, None, None, None), color_code='object', rss
# thetaunit="radians"
))

if plot_vertical_line:
x, y, z = spheric2cartesian([dist_body*np.cos(np.deg2rad(body_lat)), dist_body], [0.0, np.deg2rad(body_lat)], [np.deg2rad(body_long), np.deg2rad(body_long)])

fig.add_trace(go.Scatter3d(x=x,
y=y,
z=z,
mode='lines',
name=f'{body_id} direct line',
showlegend=False,
line=dict(width=5, color=body_dict[body_id][2], dash='dot'),
# thetaunit="radians"
))
fig.add_trace(go.Scatter3d(x=[x[0]],
y=[y[0]],
z=[z[0]],
mode='markers',
name=body_id,
showlegend=False,
marker=dict(symbol='circle', size=3, color=body_dict[body_id][2]),
))

if markers:
if markers.lower()=='numbers':
str_number = f'<b>{i+1}</b>'
Expand Down Expand Up @@ -2206,7 +2230,7 @@ def add_ring(fig, radius, line=dict(color="black", dash="dot")):
else:
return

def plot_3d(self, plot_spirals=True, plot_sun_body_line=True, markers=False, numbered_markers=False, plot_equatorial_plane=True, plot_3d_grid=True, reference_vsw=400, return_plot_object=False):
def plot_3d(self, plot_spirals=True, plot_sun_body_line=True, plot_vertical_line=False, markers=False, numbered_markers=False, plot_equatorial_plane=True, plot_3d_grid=True, reference_vsw=400, return_plot_object=False):
"""
Generates a 3D plot of the solar system with various optional features.
Expand All @@ -2216,6 +2240,8 @@ def plot_3d(self, plot_spirals=True, plot_sun_body_line=True, markers=False, num
If True, plots the magnetic field lines as spirals. Default is True.
plot_sun_body_line : bool, optional
If True, plots direct lines from the Sun to each body. Default is True.
plot_vertical_line : bool, optional
If True, plots vertical lines from the heliographic equatorial plane to each body. Default is False.
markers : bool or str, optional
If True or 'letters'/'numbers', plot markers at body positions. Default is False.
plot_equatorial_plane : bool, optional
Expand Down Expand Up @@ -2319,6 +2345,27 @@ def plot_3d(self, plot_spirals=True, plot_sun_body_line=True, markers=False, num
# thetaunit="radians"
))

if plot_vertical_line:
x, y, z = spheric2cartesian([dist_body*np.cos(np.deg2rad(body_lat)), dist_body], [0.0, np.deg2rad(body_lat)], [np.deg2rad(body_long), np.deg2rad(body_long)])

fig.add_trace(go.Scatter3d(x=x,
y=y,
z=z,
mode='lines',
name=f'{body_id} direct line',
showlegend=False,
line=dict(width=5, color=body_dict[body_id][2], dash='dot'),
# thetaunit="radians"
))
fig.add_trace(go.Scatter3d(x=[x[0]],
y=[y[0]],
z=[z[0]],
mode='markers',
name=body_id,
showlegend=False,
marker=dict(symbol='circle', size=3, color=body_dict[body_id][2]),
))

if markers:
if markers.lower()=='numbers':
str_number = f'<b>{i+1}</b>'
Expand Down

0 comments on commit fc5b57c

Please sign in to comment.