Skip to content

Commit b9a4ad4

Browse files
rebase fixes
1 parent d1d5995 commit b9a4ad4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

tidy3d/components/data/monitor_data.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,10 +1464,11 @@ def normalize(self, source_spectrum_fn: Callable[[float], complex]) -> FieldData
14641464
for field_name, field_data in self.field_components.items():
14651465
fields_norm[field_name] = [None, None]
14661466
for ind in range(2):
1467-
src_amps = source_spectrum_fn(field_data[ind].values.f)
1468-
fields_norm[field_name][ind] = field_data[ind].updated_copy(
1469-
values=(field_data[ind].values / src_amps).astype(field_data[ind].values.dtype)
1470-
)
1467+
if field_data[ind] is not None:
1468+
src_amps = source_spectrum_fn(field_data[ind].values.f)
1469+
fields_norm[field_name][ind] = field_data[ind].updated_copy(
1470+
values=(field_data[ind].values / src_amps).astype(field_data[ind].values.dtype)
1471+
)
14711472

14721473
return self.copy(update=fields_norm)
14731474

tidy3d/components/data/unstructured/surface.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ def sel(
176176
raise Tidy3dNotImplementedError("Surface datasets do not support selection along x, y, or z yet.")
177177

178178
return self._non_spatial_sel(method=method, **sel_kwargs)
179+
180+
def get_cell_volumes(self):
181+
"""Get areas associated to each cell of the grid."""
182+
v0 = self.points[self.cells.sel(vertex_index=0)]
183+
e01 = self.points[self.cells.sel(vertex_index=1)] - v0
184+
e02 = self.points[self.cells.sel(vertex_index=2)] - v0
185+
186+
return 0.5 * np.abs(np.cross(e01, e02))
179187

180188

181189
""" Plotting """

0 commit comments

Comments
 (0)