Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convergence plot correction: Use step plots #2528

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions tardis/visualization/tools/convergence_plot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Convergence Plots to see the convergence of the simulation in real time."""

from collections import defaultdict
import matplotlib.cm as cm
import matplotlib.colors as clr
import numpy as np
import plotly.graph_objects as go
from IPython.display import display
import matplotlib as mpl
Expand Down Expand Up @@ -330,8 +332,11 @@ def update_plasma_plots(self):
# add a radiation temperature vs shell velocity trace to the plasma plot
self.plasma_plot.add_scatter(
x=velocity_km_s,
y=self.iterable_data["t_rad"],
y=np.append(
self.iterable_data["t_rad"], self.iterable_data["t_rad"][-1:]
),
line_color=self.plasma_colorscale[self.current_iteration - 1],
line_shape="hv",
row=1,
col=1,
name=self.current_iteration,
Expand All @@ -344,8 +349,9 @@ def update_plasma_plots(self):
# add a dilution factor vs shell velocity trace to the plasma plot
self.plasma_plot.add_scatter(
x=velocity_km_s,
y=self.iterable_data["w"],
y=np.append(self.iterable_data["w"], self.iterable_data["w"][-1:]),
line_color=self.plasma_colorscale[self.current_iteration - 1],
line_shape="hv",
row=1,
col=2,
legendgroup=f"group-{self.current_iteration}",
Expand All @@ -365,9 +371,9 @@ def update_t_inner_luminosities_plot(self):
self.t_inner_luminosities_plot.data[0].y = self.value_data[
"t_inner"
]
self.t_inner_luminosities_plot.data[
0
].hovertemplate = "<b>%{y:.3f}</b> at X = %{x:,.0f}<extra>Inner Boundary Temperature</extra>" # trace name in extra tag to avoid new lines in hoverdata
self.t_inner_luminosities_plot.data[0].hovertemplate = (
"<b>%{y:.3f}</b> at X = %{x:,.0f}<extra>Inner Boundary Temperature</extra>" # trace name in extra tag to avoid new lines in hoverdata
)

# the next three for emitted, absorbed and requested luminosities
for index, luminosity in zip(range(1, 4), self.luminosities):
Expand All @@ -389,9 +395,9 @@ def update_t_inner_luminosities_plot(self):

self.t_inner_luminosities_plot.data[4].x = x
self.t_inner_luminosities_plot.data[4].y = y
self.t_inner_luminosities_plot.data[
4
].hovertemplate = "<b>%{y:.2f}%</b> at X = %{x:,.0f}"
self.t_inner_luminosities_plot.data[4].hovertemplate = (
"<b>%{y:.2f}%</b> at X = %{x:,.0f}"
)

def update(self, export_convergence_plots=False, last=False):
"""
Expand Down
Loading