tidy3d icon indicating copy to clipboard operation
tidy3d copied to clipboard

Improved plotting API for FieldMonitor in 1D

Open caseyflex opened this issue 2 years ago • 2 comments

Currently, sim_data["field_monitor"].Ex.plot() works to plot the data from a 1D FieldMonitor. It would be nice to have sim_data.plot_field("field_monitor", "Ex") work for 1D FieldMonitors, but it currently raises the following error:

ERROR: Data after selection has 1 coordinates (['z']), must be 2 spatial coordinates for plotting on plane. Please add keyword arguments to plot_field() to select out the other coords.

It would also be nice to also have something like sim_data["field_monitor"].plot("Ex").

caseyflex avatar Jun 09 '23 17:06 caseyflex

How would sim_data["field_monitor"].plot("Ex") differ from sim_data["field_monitor"].Ex.plot() and sim_data.plot_field("field_monitor", "Ex") (assuming the latter is fixed)?

momchil-flex avatar Jun 23 '23 16:06 momchil-flex

How would sim_data["field_monitor"].plot("Ex") differ from sim_data["field_monitor"].Ex.plot() and sim_data.plot_field("field_monitor", "Ex") (assuming the latter is fixed)? function I was thinking they would all work the same way.

EDIT: The problem with sim_data["field_monitor"].Ex.plot() is that it doesn't know anything about the simulation. For example, if the grid in the z-direction is not uniform, then this method doesn't know that and the plot assumes uniform spacing. With sim_data.plot_field("field_monitor", "Ex"), we should plot with the correct simulation grid, and other simulation details like plot_field for 2D monitor data (when possible). There is probably no need for sim_data["field_monitor"].plot("Ex").

caseyflex avatar Jun 26 '23 13:06 caseyflex