Axis in streamline plotting
Dear yt: Is there a way to have normalized axis units for streamline plotting? I want my x axis (xmin, xmax) to be in the units of (xmin/30, xmax/30). Similarly, for y axis. Thank you in advance SCRIPT: import yt import numpy as np import os import matplotlib.pyplot as plt import matplotlib ms = 24000000 vector_max=ms-(ms/3) ms1=ms-vector_max dims = (200,200,200) x = np.genfromtxt("/work/jbi157/MODEL7/UPDATE_B/yo_n_t105.mtx",skip_header=2,usecols=1, dtype="f8") x = x.reshape((8000000, 3), order="F") field1 = x[:,2].reshape(dims, order="F") field2 = x[:,1].reshape(dims, order="F") field3 = x[:,0].reshape(dims, order="F") data = dict(velocity_x = field1, velocity_y = field2, velocity_z = field3) bbox = np.array([[-100, 99], [-100, 99], [-100, 99]]) ds = yt.load_uniform_grid(data, dims, 'km', bbox=bbox, nprocs=1) L = [0, 1, 0] north_vector = [0.87, 0, 0.5] slc = yt.OffAxisSlicePlot(ds, L, 'cutting_plane_velocity_x', center=[0,0,0], width=(180,'km'), north_vector=north_vector) vel = slc._frb['velocity_magnitude'] U = slc._frb['cutting_plane_velocity_y'] V = slc._frb['cutting_plane_velocity_x'] extentx = [slc.xlim[i].in_units('km') for i in (0, 1)] extenty = [slc.ylim[i].in_units('km') for i in (0, 1)] extent = extentx + extenty x = np.linspace(extentx[0], extentx[1], vel.shape[0]) y = np.linspace(extenty[1], extenty[0], vel.shape[1]) X, Y = np.meshgrid(x, y) normalize = False # Turn off normalize if you use streamplot if normalize is True: N = np.sqrt(U**2+V**2) U /= N V /= N else: U = U.d V = V.d factor = 40 #norm = matplotlib.colors.Normalize(vmin=vel.min(), vmax=vel.max(), clip=True) #norm = matplotlib.colors.LogNorm(vmin=vel.min(), vmax=vel.max(), clip=True) #norm = matplotlib.colors.NoNorm(vmin=vel.min(), vmax=vel.max(), clip=True) #norm = matplotlib.colors.PowerNorm(gamma=0.5,vmin=vel.min(), vmax=vel.max(), clip=True) norm = matplotlib.colors.SymLogNorm(linthresh=0.01,vmin=vel.min(), vmax=vel.max(), clip=True) plt.streamplot(np.array(X),np.array(Y),np.array(U),np.array(V), density=2,color='blue') # Here density adjusts the density of streamlines #plt.imshow(vel.d, extent=extent, norm=norm) #plt.imshow(vel.d, extent=extent, norm=norm, cmap='seismic') plt.imshow(vel.d, extent=extent, norm=norm, cmap=plt.cm.coolwarm) circle=plt.Circle((0,0),9,color='gray') fig = plt.gcf() fig.gca().add_artist(circle) plt.colorbar() #plt.title("Angle = 45$^{\circ}$, Grid size = 200\n Power Normalize, Gamma = 0.5") #plt.title("Angle = 45$^{\circ}$, Grid size = 200\n Linear Normalize") plt.title("Angle = 60$^{\circ}$, x-z plane") plt.axis([-72, 72, -72, 72]) plt.axis('off') #plt.savefig('stream_plot_Norm.png') #plt.savefig('stream_plot_LogNorm.png') #plt.savefig('stream_plot_NoNorm.png') #plt.savefig('stream_plot_PowerNorm.png') plt.savefig('stream_plot_t0105.png') -- *SK2* *"**Claiming that something can move faster than light is a good conversation-stopper in physics. People edge away from you in cocktail parties; friends never return phone calls. You just don’t mess with Albert Einstein.**"*
participants (1)
-
Sushilkumar