-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added a module that plugs into the FieldsPanel and FieldSettings classes and enables plotting an overlay of the magnetic field lines
pcrumley
reviewed
Aug 29, 2024
Yes, Python flips Fortran arrays. .
…On Fri, Aug 30, 2024 at 10:50 AM bcaddy ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/streamlines.py
<#33 (comment)>
:
> + stride = panel.GetPlotParam("streamlines_stride")
+ line_density = panel.GetPlotParam("streamlines_density")
+ line_color = panel.GetPlotParam("streamlines_color")
+
+ # Grab the data, use aliases to make it easier to work with
+ if fields == "bxby":
+ bx_name, by_name = "bx", "by"
+ elif fields == "bybz":
+ bx_name, by_name = "by", "bz"
+ elif fields == "bxbz":
+ bx_name, by_name = "bx", "bz"
+ else:
+ raise ValueError(
+ f"Improper fields value of {fields} passed to draw_streamlines. "
+ )
+ bx = panel.parent.DataDict[bx_name][0, ::stride, ::stride]
Just to clarify, Iseult uses numpy's column major ordering ([x,y,z]) not
Fortran's row major ordering right? ([z,y,x]). I now Tristan uses the
latter but numpy defaults to the former.
—
Reply to this email directly, view it on GitHub
<#33 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AASJ7FGWNQSJIC7P5IPYGFDZUCBE5AVCNFSM6AAAAABNLAVFWKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDENZSGYZDANJYGU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
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.
pcrumley
approved these changes
Sep 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. Settingstride=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 datasetLine Density
controls the density of streamlines plotted, defaults to 1Line Color
sets the color of the streamline. Any color string that matplotlib would normally expect should workNote
Modifying the opacity of the streamlines is possible. Unfortunately, the
StreamplotSet
object thatmatplotlib.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
Resolves #11