Plotting vectors and calculating field lines and flux

Hi all,

  • gmtvector can take x,y or x,y,z as input, while grdvector can only take x,y. Why can’t grdvector eat z-components? How does an x,y-vector differ from an x,y,z vector on a plot?
  • Is it possible to draw field lines?
  • Is it possible to calculate, and plot, a flux?

Thanks for any (enlightening) answers!

Do you need something like example 13?

Well, I was thinking about stuff that goes beyond that. I’m not very familiar with vector fields and this stuff, but if I’ve understood correctly, one can draw field lines as well, which is something different that plotting the vector (arrow) itself.

And then there is the flux, which is very new to me. What additional information this would yield, I’m not sure of.

Mmm I see. I think that I also would like to draw field lines.

I am thinking out loud. Maybe we could calculate an aspect grid (with grdgradient -Da) and them use grdcountour?

Here I modified a bit the example 13. I made the upper right graph with:

	gmt grdgradient z.nc -Da -Ga.nc		
    gmt grdcontour a.nc -C5 -L1/359 -c0,1

I think I am missing something.

Here I create a more fine grid (-I0.01 in gmt grdmath -R-2/2/-2/2 -I0.01 X Y R2 NEG EXP X MUL = z.nc) and the lines are better.

I don’t know how to avoid the thicker line at 360º. Maybe a bug?

See the purpose of -Z+p in grdcontour.

1 Like

Thanks Paul. It works.

Now I have I doubt. I add the original vectors and I hoped that they will have the same direction than the lines but they don’t. Are the graph ok? How can I get lines that follow the vectors?

Looks to me the lines are wrong. Since there is symmetry across x = 0 all vectors should be horizontal there, but the contours from grdgradient are not. THe vectors are correct (pretty sure). The contours are angles (scalars) while the vectors are, well, vectors.

Wow, Esteban. Really nice suggestions. I’ll play some more with this and your ideas.

Thanks. But I am not sure if the aspect grid is what do you need.

Gradient or aspect should be the same since the field lines would be identical (just multiplied by -1, I think).
Your solution looks good I think @Esteban82.

Here is an(other) example:

gmt begin grdvector-test png
  gmt grdmath -R-15/15/-15/15 -I0.5 X X MUL Y Y MUL ADD = circle.nc

  gmt grdimage circle.nc -t50
  gmt grdgradient circle.nc -Gtheta.nc -Sr.nc -Dca
  gmt makecpt -Crainbow -T0/42/1
  gmt grdvector -A r.nc theta.nc -Q0.35c+e -Gblack -Sl2c -I2 -l"gradient descent" -C -W+c
  gmt grdcontour -C45 -Wred theta.nc -Z+p -Bxaf -Byaf -B+t"Gradient descent" -l"field lines"
gmt end show

rm circle.nc theta.nc r.nc

Sorry for bumping old thread.

1 Like