[Mayavi] Ploting a 3D vector field

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Mayavi] Ploting a 3D vector field

Zunbeltz Izaola
Hi,

I am new to mayavi, and I can not to figure how to plot a vector field.
My magnetic vector field como from a simulation in a file with the
following syntax:

x y z Bx By Bz

When loading the data, mayavi says closes to the data file name
timeseries. Then I can not figure out what  modules to use.

Thanks for any help.

--
Zunbeltz Izaola
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Mayavi] Ploting a 3D vector field

Hanno Klemm

Hi,

I only use mayavi from the ipython Shell. If that's what you're after, try something like this:

import numpy as np
import mayavi.mlab as mlab

bb = np.array([
[0, 0, 0, 0.3, 0.4, 0.5],
[1, 2, 3, 0.4, 0.6, 0.2],
[2, 3, 4, 0.5, 0.2,0.3]])

mlab.quiver3d(*bb.T)
#a shortcut for
#mlab.quiver3d(bb[:,0], bb[:,1], bb[:,2], bb[:,3], bb[:,4], bb[:,5])


and run this in an ipython session started with ipython --gui='wx'

If your data come from a file, you do something like:

bb = np.loadtxt('myfile')


Hope this helps,
Hanno


Hanno Klemm
[hidden email]



On Nov 21, 2012, at 12:48, Zunbeltz Izaola wrote:

> Hi,
>
> I am new to mayavi, and I can not to figure how to plot a vector field.
> My magnetic vector field como from a simulation in a file with the
> following syntax:
>
> x y z Bx By Bz
>
> When loading the data, mayavi says closes to the data file name
> timeseries. Then I can not figure out what  modules to use.
>
> Thanks for any help.
>
> --
> Zunbeltz Izaola
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Mayavi] Ploting a 3D vector field

Zunbeltz Izaola
Thanks Hanno,

I am now trying to view cuts. I have read mlab thoroughly.

Zunbeltz

az., 2012.eko azaren 21a 20:42(e)an, Hanno Klemm(e)k idatzi zuen:

> Hi,
>
> I only use mayavi from the ipython Shell. If that's what you're after, try something like this:
>
> import numpy as np
> import mayavi.mlab as mlab
>
> bb = np.array([
> [0, 0, 0, 0.3, 0.4, 0.5],
> [1, 2, 3, 0.4, 0.6, 0.2],
> [2, 3, 4, 0.5, 0.2,0.3]])
>
> mlab.quiver3d(*bb.T)
> #a shortcut for
> #mlab.quiver3d(bb[:,0], bb[:,1], bb[:,2], bb[:,3], bb[:,4], bb[:,5])
>
>
> and run this in an ipython session started with ipython --gui='wx'
>
> If your data come from a file, you do something like:
>
> bb = np.loadtxt('myfile')
>
>
> Hope this helps,
> Hanno
>
>
> Hanno Klemm
> [hidden email]
>
>
>
> On Nov 21, 2012, at 12:48, Zunbeltz Izaola wrote:
>
>> Hi,
>>
>> I am new to mayavi, and I can not to figure how to plot a vector field.
>> My magnetic vector field como from a simulation in a file with the
>> following syntax:
>>
>> x y z Bx By Bz
>>
>> When loading the data, mayavi says closes to the data file name
>> timeseries. Then I can not figure out what  modules to use.
>>
>> Thanks for any help.
>>
>> --
>> Zunbeltz Izaola
>> _______________________________________________
>> Enthought-Dev mailing list
>> [hidden email]
>> https://mail.enthought.com/mailman/listinfo/enthought-dev
>>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev


--
Zunbeltz Izaola

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Mayavi] Ploting a 3D vector field

Gael Varoquaux
On Thu, Nov 22, 2012 at 10:55:20AM +0100, Zunbeltz Izaola wrote:
> I am now trying to view cuts. I have read mlab thoroughly.

Then you will know that you have to take a different path for this:
http://docs.enthought.com/mayavi/mayavi/mlab.html#visualizing-a-vector-field

In particular, you have to shape your x, y, z, Bx, By, Bz array to
reflect the connectivity structure of the data.

G
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev