Skip to content

Commit

Permalink
Adding ElectromagneticFieldData._check_fields_stored
Browse files Browse the repository at this point in the history
  • Loading branch information
momchil-flex committed Dec 13, 2024
1 parent e8904ea commit 51a55af
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tidy3d/components/data/monitor_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,15 @@ def time_reversed_copy(self) -> FieldData:
new_data[comp] = np.conj(field)
return self.copy(update=new_data)

def _check_fields_stored(self, components: list[str]):
"""Check that all requested field components are stored in the data."""
missing_comps = [comp for comp in components if comp not in self.field_components.keys()]
if len(missing_comps) > 0:
raise DataError(
f"Field components {missing_comps} not included in this data object. Use "
"the 'fields' argument of a field monitor to select which components are stored."
)


class FieldData(FieldDataset, ElectromagneticFieldData):
"""
Expand Down

0 comments on commit 51a55af

Please sign in to comment.