tidy3d
tidy3d copied to clipboard
Improved plotting API for FieldMonitor in 1D
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").
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)?
How would
sim_data["field_monitor"].plot("Ex")differ fromsim_data["field_monitor"].Ex.plot()andsim_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").