-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds SimulationData.mnt_data_from_file()
method to load individual MonitorData
#1249
Conversation
bf38d92
to
3514eef
Compare
3514eef
to
370eb2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one small clarification below.
tidy3d/components/data/sim_data.py
Outdated
@@ -369,6 +376,65 @@ def get_intensity(self, field_monitor_name: str) -> xr.DataArray: | |||
field_monitor_name=field_monitor_name, field_name="E", val="abs^2" | |||
) | |||
|
|||
@classmethod | |||
def mnt_data_from_file(cls, fname: str, mnt_name: str, **parse_obj_kwargs) -> MonitorDataType: | |||
"""Loads a monitor data from .hdf5, or .hdf5.gz file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check below (line 404) does not seem to allow .hdf5.gz
. Does pathlib.Path(fname)
internally extract .gz
files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right, no the pathlib.path just is to check the extension but I'll make the docstring clearer that it only works for hdf5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if we start gzipping simulation data files, we should still unzip them right after download.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, it seems like a bit of a complication to do the unzipping in this function, would need to specify another path for the new file I think. might be possible to do it through a temporary file but perhaps it's too complicated for this application.
370eb2e
to
e5e1c5b
Compare
Syntax:
loads a monitor data from a subgroup in the
SimulationData
file.JSON_STRING
to get the monitor type info.MonitorDataType
MonitorData.from_file()
with a constructed group path to do the loading.Some error checking thrown in, only works with
.hdf5
files at the moment.