Plotting vector fields

32 views
Skip to first unread message

Krishna

unread,
Apr 18, 2023, 2:16:32 AM4/18/23
to SunPy
Hello,

I'm trying to plot vector fields using quivers .

I've been able to plot the vector hair using code  "https://github.com/mbobra/SHARPs/blob/master/hedgehog.ipynb" but I wanted to to try and plot the actual vectors so that the direction of horizontal fields can be better visualized.

This is what I did:
(1) hmi.sharp_cea_720s - Br, Bp, Bt
(2) Assigned
      (a) Bz = Br
      (b) Bx = Bp
      (c) By = - Bt
(3) created a plotting grid:
      xloc = np.linspace(0,int(xsize-1),num=100)
      yloc = np.linspace(0,int(ysize-1),num=100)
      X, Y = np.meshgrid(xloc,yloc)
where
xsize = mapBz.meta['naxis1'] and ysize = mapBz.meta['naxis2']
(4) Resized the By, Bx images to (100,100)  and assigned
      => U = Bx_resize, V = By_resize
(5) Plotted the quivers like so (using defaults for quiver in this plot):
plt.imshow(Bz, cmap='Greys_r', norm=colors.Normalize(-500,500),origin='lower')
plt.quiver(X, Y, U, V, color='blue')
plt.show()

Here's the figure (White is Positive and Black is Negative, x- and y-axis units are pixel coordinates; specific dataset corresponds to "hmi.sharp_cea_720s.4478.20140827_000000"):
Figure_1.png
My queries are
(1) How can I adjust the length of the arrows? And how do I make sure none of the "background field" arrows get plotted? How can I avoid plotting the radial vectors from the main sunspots?
I played around with "scale_units" and normalized "u" and "v" by the "magnitude = sqrt(u^2 + v^2)" etc and I think I'm missing a whole lot about how quivers are supposed to work.
(2) If I'd have to plot, say, red arrows originating from positive Bz fields and blue arrows ending in negative fields ... how would it be done?
(3) How do you make this kind of a plot into a map? Do I have to reproject each "X" "Y" coordinate into the required Heliographic etc coordinate space?

Looking forward to your help!
Thanks,
Krishna
Reply all
Reply to author
Forward
0 new messages