Skip to content

Commit cdb8a9e

Browse files
committed
(Hopefully) Fixed a bug in HeatChargeSimulationData.plot_field() from tcad/data/sim_data.py. I don't know how to test this function yet.
1 parent 7faf00f commit cdb8a9e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

tidy3d/components/tcad/data/sim_data.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def plot_field(
157157
vmin: Optional[float] = None,
158158
vmax: Optional[float] = None,
159159
ax: Ax = None,
160+
swap_axes: bool = False,
160161
**sel_kwargs,
161162
) -> Ax:
162163
"""Plot the data for a monitor with simulation plot overlaid.
@@ -252,6 +253,7 @@ def plot_field(
252253
vmax=vmax,
253254
cbar_kwargs={"label": field_name},
254255
grid=False,
256+
swap_axes=swap_axes,
255257
)
256258

257259
# compute parameters for structures overlay plot
@@ -260,10 +262,8 @@ def plot_field(
260262

261263
# compute plot bounds
262264
field_data_bounds = field_data.bounds
263-
min_bounds = list(field_data_bounds[0])
264-
max_bounds = list(field_data_bounds[1])
265-
min_bounds.pop(axis)
266-
max_bounds.pop(axis)
265+
_, min_bounds = self.pop_axis_and_swap(field_data_bounds[0], axis, swap_axes=swap_axes)
266+
_, max_bounds = self.pop_axis_and_swap(field_data_bounds[1], axis, swap_axes=swap_axes)
267267

268268
if isinstance(field_data, SpatialDataArray):
269269
# interp out any monitor.size==0 dimensions
@@ -315,8 +315,8 @@ def plot_field(
315315
axis = "xyz".index(planar_coord)
316316
position = float(field_data.coords[planar_coord])
317317

318-
xy_coord_labels = list("xyz")
319-
xy_coord_labels.pop(axis)
318+
_, xy_coord_labels = self.pop_axis_and_swap(list("xyz"), axis=axis, swap_axes=swap_axes)
319+
320320
x_coord_label, y_coord_label = xy_coord_labels[0], xy_coord_labels[1]
321321
field_data.plot(
322322
ax=ax,
@@ -327,6 +327,7 @@ def plot_field(
327327
vmax=vmax,
328328
robust=robust,
329329
cbar_kwargs={"label": field_name},
330+
swap_axes=swap_axes,
330331
)
331332

332333
# compute plot bounds
@@ -344,6 +345,7 @@ def plot_field(
344345
alpha=structures_alpha,
345346
ax=ax,
346347
property=property_to_plot,
348+
swap_axes=swap_axes,
347349
**interp_kwarg,
348350
)
349351

tidy3d/components/tcad/simulation/heat_charge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ def plot_sources(
15881588
plane = Box(center=center, size=size)
15891589

15901590
source_shapes = self.scene._filter_structures_plane(
1591-
structures=structures, plane=plane, property_list=source_list
1591+
structures=structures, plane=plane, property_list=source_list, swap_axes=swap_axes
15921592
)
15931593

15941594
source_min, source_max = self.source_bounds(property=property)

0 commit comments

Comments
 (0)