Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions idstools/compute/equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,9 @@ def get_equilibria(self, selection=None):
name = self.ids.code.name
if homogeneous_time == 1:
time = self.ids.time
else:
# Extract time from time_slice array
time = np.array([ts.time for ts in self.ids.time_slice]) if len(self.ids.time_slice) > 0 else np.array([])
nt = time.size

data = {}
Expand Down Expand Up @@ -1378,10 +1381,10 @@ def get_equilibria(self, selection=None):
z = time_slice.profiles_2d[0].grid.dim2

# Initialize boundary arrays - each time slice can have different size
if need_boundaries and n3 > 0:
rb = [] if "rb" in selection else None
zb = [] if "zb" in selection else None
rb = [] if "rb" in selection else None
zb = [] if "zb" in selection else None

if need_boundaries:
for i, time_slice in enumerate(self.ids.time_slice):
if time_slice.boundary.outline.r.size > 0 and rb is not None:
rb.append(time_slice.boundary.outline.r)
Expand Down
12 changes: 8 additions & 4 deletions idstools/view/equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ def view_profile_plot(self, ax, time_index1, equilibrium2_ids=None, time_index2=
logger.warning(f"Equilibrium1 {name}: No valid r or jtor data available")

# Set ylim with check for identical values to avoid matplotlib warning
if abs(y_max - y_min) < 1e-10:
if not np.isfinite(y_min) or not np.isfinite(y_max):
y_min, y_max = -1.0, 1.0
elif abs(y_max - y_min) < 1e-10:
# If y_min and y_max are essentially equal, create a small range around the value
if abs(y_min) < 1e-10:
# If both are near zero, use a default range
Expand Down Expand Up @@ -619,14 +621,16 @@ def view_current_plot(self, ax, time_index1, equilibrium2_ids=None):
line31.set_xdata(time)
line31.set_ydata(ip / 1e6)
xlims = np.array([min(time), max(time)])
ylims = np.array([min(ip), max(ip)]) / 1e6
ip_valid = ip[np.isfinite(ip)]
ylims = np.array([ip_valid.min(), ip_valid.max()]) / 1e6 if ip_valid.size > 0 else np.array([-1.0, 1.0])
if data2 is not None:
line32.set_xdata(timeE)
line32.set_ydata(ipE / 1e6)
ipE_valid = ipE[np.isfinite(ipE)]
xlims[0] = np.minimum(xlims[0], np.min(timeE))
ylims[0] = np.minimum(ylims[0], np.min(ipE / 1e6))
ylims[0] = np.minimum(ylims[0], np.min(ipE_valid / 1e6)) if ipE_valid.size > 0 else ylims[0]
xlims[1] = np.maximum(xlims[1], np.max(timeE))
ylims[1] = np.maximum(ylims[1], np.max(ipE / 1e6))
ylims[1] = np.maximum(ylims[1], np.max(ipE_valid / 1e6)) if ipE_valid.size > 0 else ylims[1]
dy = ylims[1] - ylims[0]
if dy > 0:
ylims[0] = ylims[0] - 0.01 * dy
Expand Down
Loading