Skip to content

Commit 7f6b1b7

Browse files
committed
Fix to failing ruff and dropping normal dim in 'intensity' already
1 parent e892c26 commit 7f6b1b7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tidy3d/components/data/monitor_data.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,13 @@ def grid_corrected_copy(self) -> ElectromagneticFieldData:
481481
@property
482482
def intensity(self) -> ScalarFieldDataArray:
483483
"""Return the sum of the squared absolute electric field components."""
484+
normal_dim = "xyz"[self.monitor.size.index(0)]
484485
fields = self._colocated_fields
485486
components = ("Ex", "Ey", "Ez")
486487
if any(cmp not in fields for cmp in components):
487488
raise KeyError("Can't compute intensity, all E field components must be present.")
488-
return sum(fields[cmp].abs ** 2 for cmp in components)
489+
intensity = sum(fields[cmp].abs ** 2 for cmp in components)
490+
return intensity.squeeze(dim=normal_dim, drop=True)
489491

490492
@property
491493
def poynting(self) -> ScalarFieldDataArray:
@@ -524,8 +526,7 @@ def mode_area(self) -> FreqModeDataArray:
524526
525527
Effective mode area is calculated as: (∫|E|²dA)² / (∫|E|⁴dA)
526528
"""
527-
normal_dim = "xyz"[self.monitor.size.index(0)]
528-
intensity = self.intensity.squeeze(dim=normal_dim, drop=True)
529+
intensity = self.intensity
529530
# integrate over the plane
530531
d_area = self._diff_area
531532
num = (intensity * d_area).sum(dim=d_area.dims) ** 2
@@ -1324,7 +1325,7 @@ def to_dataframe(self) -> DataFrame:
13241325
dataset = self.modes_info
13251326
drop = []
13261327

1327-
if np.all(dataset["group index"] == None):
1328+
if not np.any(dataset["group index"].values):
13281329
drop.append("group index")
13291330
if np.all(dataset["loss (dB/cm)"] == 0):
13301331
drop.append("loss (dB/cm)")

0 commit comments

Comments
 (0)