Skip to content
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

Add Magnetic Streamlines to Field and Density Plots #33

Merged
merged 7 commits into from
Sep 6, 2024

Conversation

bcaddy
Copy link
Collaborator

@bcaddy bcaddy commented Aug 29, 2024

Summary

This PR adds the option to overlay magnetic streamlines (streamplots) over the Field and Density plots. In the respective settings panels for those two plot types there is a new Streamline Settings: section that controls the presence of streamlines along with the following options:

  • Stride: controls the subsampling of the data plotted. The magnetic fields are subsampled with a stride, default 10, to speed up plotting. Setting stride=1 turns off subsampling. In my testing, a stride of 1 took 10-15s to plot and a stride of 10 took 300-400ms. Increasing the stride past 10 did not yield significant improvements though this will likely vary by dataset
  • Line Density controls the density of streamlines plotted, defaults to 1
  • Line Color sets the color of the streamline. Any color string that matplotlib would normally expect should work

Note

Modifying the opacity of the streamlines is possible. Unfortunately, the StreamplotSet object that matplotlib.axes.Axes.streamplot returns is not as fully featured as returned objects from most other plotting functions. As a result setting the opacity is non-trivial and bears the chance of impacting other elements of the plot, though that is unlikely in this particular application. If there's a need to add an opacity option I can do so.

Cloning Instructions

if you already have that repo cloned locally then

$ cd path/to/bob-iseult
$ git fetch origin
$ git checkout --track origin/master-streamplot

if not

$ git clone [email protected]:bcaddy/Iseult.git bob-iseult
$ cd bob-iseult
$ git checkout --track origin/master-streamplot

Resolves #11

bcaddy added 3 commits August 29, 2024 14:28
Added a module that plugs into the FieldsPanel and FieldSettings
classes and enables plotting an overlay of the magnetic field lines
src/streamlines.py Outdated Show resolved Hide resolved
@ntoles
Copy link
Collaborator

ntoles commented Aug 30, 2024 via email

bcaddy added 4 commits August 30, 2024 11:36
Also, properly select which pairs of fields to use in a streamplot,
since only two fields are parallel to the plane at any one time there
is only one correct pair to use. Removed option to select the pair and
now select it automatically
If the magnetic fields had not already been loaded the density and
fields plot would not load them when they were needed for the
streamlines. Added a function to add magnetic fields to the list of
things to load if they are turned on.
@ntoles ntoles merged commit f470d37 into PrincetonUniversity:master Sep 6, 2024
1 check passed
@bcaddy bcaddy deleted the master-streamplot branch September 20, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add field lines to 2D plots
3 participants