Skip to content

Commit 7cec00c

Browse files
twhughestylerflex
authored andcommitted
mode sources and monitors work with conversion
1 parent d076eb5 commit 7cec00c

File tree

11 files changed

+445
-672
lines changed

11 files changed

+445
-672
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,6 @@ https://www.atlassian.com/git/tutorials/merging-vs-rebasing
188188
- [x] Simplify MonitorData
189189
- [x] remove MonitorData.monitor and MonitorData.monitor_name attributes.
190190
- [x] remove MonitorData.load() and MonitorData.export()
191-
- [ ] assert all SimulationData.monitor_data.keys() are in SimulationData.simulation.monitor.keys() <- not necessry.
192-
- [ ] provide optional args to SimulationData.export() to only export some MonitorData by key <- not necessary?
193-
- [ ] Move any interfaces in MonitorData to SimulationData (geometry, plotting, etc).
194191
- [x] Make monitordata.load_from_group aware of lists
195192
- [x] Use shapely for geometry ops / plotting? `Geometry.geo(x=0)` -> shapely representation.
196193
- [x] Fix all tests.
@@ -208,12 +205,13 @@ https://www.atlassian.com/git/tutorials/merging-vs-rebasing
208205
- [ ] Handle Inf as it's own keyword that depends on simulation bounds.
209206
- [ ] Make Uniform Samplers separate classes? (dont evaluate / store freqs, times)?
210207
- [ ] setup.cfg for installing packages with more granularity (base, docs, tests)
208+
- [ ] Move any interfaces in MonitorData to SimulationData (geometry, plotting, etc).
211209

212210

213211
#### Requires some focused time
214212
- [ ] Nail down simulationData interfaces for plotting.
215213
- [ ] Figue out webAPI running progress issues. (can we get separate status for time-stepping?)
216-
- [ ] **Conversion for mode monitors / mode sources.**
214+
- [x] Conversion for mode monitors / mode sources.
217215
- [ ] Get near2far working correctly.
218216
- [ ] Use mode solver for the relevant example notebooks.
219217
- [ ] Document everything fully.

notebooks/Modal_sources_monitors.ipynb

Lines changed: 373 additions & 600 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notebooks/data/mode_converter.hdf5

2.8 MB
Binary file not shown.

notebooks/data/simulation.hdf5

10.3 KB
Binary file not shown.
1.44 MB
Binary file not shown.

notebooks/simulation_data.hdf5

-1.35 MB
Binary file not shown.

simulation_data.hdf5

-65.9 MB
Binary file not shown.

tidy3d/components/data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ def load_from_group(cls, hdf5_grp):
167167
kwargs[data_name] = np.array(data_value)
168168

169169
# handle data stored as np.array() of bytes instead of strings
170-
# for str_kwarg in ("field", "direction"):
171-
# if kwargs.get(str_kwarg) is not None:
172-
# kwargs[str_kwarg] = decode_bytes_array(kwargs[str_kwarg])
170+
for str_kwarg in ("direction",):
171+
if kwargs.get(str_kwarg) is not None:
172+
kwargs[str_kwarg] = decode_bytes_array(kwargs[str_kwarg])
173173

174174
# handle data stored as np.array() of bytes instead of strings
175175
# for str_kwarg in ("x", "y", "z"):

tidy3d/components/mode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from .base import Tidy3dBaseModel
88
from .types import Symmetry
9-
from ..log import log
109

1110

1211
class Mode(Tidy3dBaseModel):

tidy3d/web/webapi.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ def download(task_id: TaskId, simulation: Simulation, path: str = "simulation_da
253253

254254

255255
def load_data(
256-
task_id: TaskId, simulation: Simulation, path: str = "simulation_data.hdf5"
256+
task_id: TaskId,
257+
simulation: Simulation,
258+
path: str = "simulation_data.hdf5",
259+
replace_existing=True,
257260
) -> SimulationData:
258261
"""Download and Load simultion results into ``SimulationData`` object.
259262
@@ -263,13 +266,15 @@ def load_data(
263266
Unique identifier of task on server.
264267
path : ``str``
265268
Download path to .hdf5 data file (including filename).
269+
replace_existing: ``bool``
270+
Downloads even if file exists (overwriting).
266271
267272
Returns
268273
-------
269274
:class:`SimulationData`
270275
Object containing simulation data.
271276
"""
272-
if not os.path.exists(path):
277+
if not os.path.exists(path) or replace_existing:
273278
download(task_id=task_id, simulation=simulation, path=path)
274279

275280
log.info(f"loading SimulationData from {path}")

0 commit comments

Comments
 (0)