I'm trying to plot magnetic field lines (mlab.pipeline.streamline), in addition 
to two image planes of density (mlab.pipeline.image_plane_widget) in a cubic 
(512^3) grid.  In general this is working well, but occasionally the 
streamlines' bounding box is no longer aligned with that of the image planes; 
each time the streamlines' box becomes elongated along a single direction*.  
The data is always in a 512^3 grid, but only some snapshots create this problem 
--- so it seems to be an issue with the autoscaling based on the shape of the 
streamlines.

Is there a way to manually set the aspect ratio of the streamlines?

Here is the script I'm using which acts on a scalar array 'scal' (512x512x512), 
and vector array 'vect' (512x512x512x3):



mlab.options.offscreen = True
fig    = mlab.figure(size=[1000,1000])
extent = [0,1,0,1,0,1]
shape  = np.shape(scal)
x,y,z  = np.mgrid[ 0:1.0:1j*shape[0] , 0:1.0:1j*shape[1] , 0:1.0:1j*shape[2] ]

# Draw vector field                                                             
                                                                                
               
u,v,w      = vect[...,0], vect[...,1], vect[...,2]
vect_field = mlab.pipeline.vector_field(x,y,z, u,v,w)
streams    = mlab.pipeline.streamline(vect_field, figure=fig, extent=extent, 
reset_zoom=False, seedtype='plane', seed_scale=2.0, colormap='Greens')

streams.stream_tracer.integration_direction = 'both'
mlab.outline()
seed = streams.seed.widget
seed.set( normal=[0.0,0.0,1.0] )
seed.set( center=[0.5,0.5,0.5] )
seed.set( resolution=SEED_RESOLUTION )
seed.enabled = False
                            
# Draw scalar field
scal       = np.log10(scal)
scal_field = mlab.pipeline.scalar_field(x,y,z, scal)
midz       = np.int(np.floor(shape[2]*0.5))
plane1 = mlab.pipeline.image_plane_widget(scal_field, figure=fig, 
plane_orientation='z_axes', slice_index=midz, opacity=0.1, transparent=True, 
extent=extent, reset_zoom=False )
plane2 = mlab.pipeline.image_plane_widget(scal_field, figure=fig, 
plane_orientation='x_axes', slice_index=0, opacity=0.1, extent=extent, 
reset_zoom=False )

mlab.colorbar()
mlab.view(35, 75, 3.0, focalpoint=[0.5,0.5,0.4])



Thanks!

*Images posted to SO: 
http://stackoverflow.com/questions/25653776/mayavi-misaligned-streamline-and-image-plane-when-overplotted
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to