better plotting of magnetic field lines

Hi all,

I would like to plot the magnetic field lines for a simulation and am
finding that streamplot is in adequate in a few ways. First, it breaks
lines when they get too close together. I think this can be configured
with the density parameter. More fundamentally, one usually wants the
density of field lines to indicate the strength of the magnetic field. So
a clever selection of start_points could in principle accomplish this, I
think. That may be the way I go, but I wonder if someone hasn't already
come up with a solution for this. If so, I'd love to hear about it.

Regards,
Jon

···

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20161215/ec94f647/attachment.html>

yt uses an implementation of the line integral convolution recipe from
scipy that works very nicely (IMO):

http://yt-project.org/docs/dev/visualizing/callbacks.html#overplot-line-integral-convolution

I don't think there's an easy way to do this with pure matplotlib right
now, but you can take a look at yt's implementation if you're curious:

https://bitbucket.org/yt_analysis/yt/src/011cd19563215cefb3facfd5d6f575b6b38de0db/yt/visualization/plot_modifications.py?at=yt&fileviewer=file-view-default#plot_modifications.py-2347

https://bitbucket.org/yt_analysis/yt/src/011cd19563215cefb3facfd5d6f575b6b38de0db/yt/utilities/lib/line_integral_convolution.pyx?at=yt&fileviewer=file-view-default

···

On Thu, Dec 15, 2016 at 10:38 AM, Slavin, Jonathan <jslavin at cfa.harvard.edu> wrote:

Hi all,

I would like to plot the magnetic field lines for a simulation and am
finding that streamplot is in adequate in a few ways. First, it breaks
lines when they get too close together. I think this can be configured
with the density parameter. More fundamentally, one usually wants the
density of field lines to indicate the strength of the magnetic field. So
a clever selection of start_points could in principle accomplish this, I
think. That may be the way I go, but I wonder if someone hasn't already
come up with a solution for this. If so, I'd love to hear about it.

Regards,
Jon

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20161215/87145f37/attachment.html>

Thanks Nathan. I'll check it out.

Jon

···

On Thu, Dec 15, 2016 at 11:41 AM, Nathan Goldbaum <nathan12343 at gmail.com> wrote:

yt uses an implementation of the line integral convolution recipe from
scipy that works very nicely (IMO):

http://yt-project.org/docs/dev/visualizing/callbacks.
html#overplot-line-integral-convolution

I don't think there's an easy way to do this with pure matplotlib right
now, but you can take a look at yt's implementation if you're curious:

https://bitbucket.org/yt_analysis/yt/src/011cd19563215cefb3facfd5d6f575
b6b38de0db/yt/visualization/plot_modifications.py?at=yt&
fileviewer=file-view-default#plot_modifications.py-2347

https://bitbucket.org/yt_analysis/yt/src/011cd19563215cefb3facfd5d6f575
b6b38de0db/yt/utilities/lib/line_integral_convolution.pyx?
at=yt&fileviewer=file-view-default

On Thu, Dec 15, 2016 at 10:38 AM, Slavin, Jonathan < > jslavin at cfa.harvard.edu> wrote:

Hi all,

I would like to plot the magnetic field lines for a simulation and am
finding that streamplot is in adequate in a few ways. First, it breaks
lines when they get too close together. I think this can be configured
with the density parameter. More fundamentally, one usually wants the
density of field lines to indicate the strength of the magnetic field. So
a clever selection of start_points could in principle accomplish this, I
think. That may be the way I go, but I wonder if someone hasn't already
come up with a solution for this. If so, I'd love to hear about it.

Regards,
Jon

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20161215/97456976/attachment.html>

Hi Nathan,

That's interesting but not quite what I had in mind. See the attached
figure to see what I'm looking for. I created that by using uniformly
spaced start_points along the upper boundary of the plot. The only problem
then is that I need to use the negative of Bx and By to get the field lines
to get propagated in the correct directions. And then the arrows are in
the wrong direction.

One thought I had was to do this, get the output streamlines and then use
the end points of those streamlines for start points. However it's not
clear to me how to get those end points from the LineCollection that is
part of the StreamplotSet container that's returned by streamplot. I can
get segments from the LineCollection, but I don't know how to get the line
endpoint out of those. Do you know how to do that?

Jon

···

On Thu, Dec 15, 2016 at 12:00 PM, Slavin, Jonathan <jslavin at cfa.harvard.edu> wrote:

Thanks Nathan. I'll check it out.

Jon

On Thu, Dec 15, 2016 at 11:41 AM, Nathan Goldbaum <nathan12343 at gmail.com> > wrote:

yt uses an implementation of the line integral convolution recipe from
scipy that works very nicely (IMO):

http://yt-project.org/docs/dev/visualizing/callbacks.html#
overplot-line-integral-convolution

I don't think there's an easy way to do this with pure matplotlib right
now, but you can take a look at yt's implementation if you're curious:

https://bitbucket.org/yt_analysis/yt/src/011cd19563215cefb3f
acfd5d6f575b6b38de0db/yt/visualization/plot_
modifications.py?at=yt&fileviewer=file-view-default#plot_
modifications.py-2347

https://bitbucket.org/yt_analysis/yt/src/011cd19563215cefb3f
acfd5d6f575b6b38de0db/yt/utilities/lib/line_integral_
convolution.pyx?at=yt&fileviewer=file-view-default

On Thu, Dec 15, 2016 at 10:38 AM, Slavin, Jonathan < >> jslavin at cfa.harvard.edu> wrote:

Hi all,

I would like to plot the magnetic field lines for a simulation and am
finding that streamplot is in adequate in a few ways. First, it breaks
lines when they get too close together. I think this can be configured
with the density parameter. More fundamentally, one usually wants the
density of field lines to indicate the strength of the magnetic field. So
a clever selection of start_points could in principle accomplish this, I
think. That may be the way I go, but I wonder if someone hasn't already
come up with a solution for this. If so, I'd love to hear about it.

Regards,
Jon

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20161216/9e8d8bd9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bmag_w_fieldlines.png
Type: image/png
Size: 261372 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20161216/9e8d8bd9/attachment-0001.png>