Closed d-siden closed 1 year ago
Hi! This is intended behaviour. Streamlines are closer together in regions of larger amplitude and the length of the streamline is also a measure of (Lagrangian) speed of the particle.
A quick way of getting uniform streamlines might be by normalising the X and y speeds by the total velocity: aes(dx = u/(u^2 + v^2), dy = v/(u^2 + v^2))
.
Thank you!
Hi,
I'm using the
geom_streamline()
(v. 0.12.0) on my final paper on Meteorology and I came to a problem when plotting streamlines based on U and V wind components. The higher speed sector had extremely long lines, while the slower had only the arrow head. I solved this using some functions to remove the magnitude of vectors and remake the field with same length speed. I think this should be an easier feature to have as a parameter in this function, so I'm showing how I'm doing.First I create a dataframe which correlates the way R outputs angles ("r") and the conventional meteorological direction ("buss"):
The parameters for the right image are: L = 7, res = 5, jitter = 0.
The ones for the left image I forgot.
tabela.de.graus <- data.frame("r"=c(seq(-179,180)), "buss"=c(seq(269,0),seq(359,270)))
This gives 1 degree of resolution, which is enough for my observation scale. Then, when converting the U and V components into a dataframe, I do the following: Find the direction where this vector is pointing at, convert to degrees:atan2(V, U)*180/pi)
Round it and check if it became -180 if, yes, convert to 180, if not, procceed with value.ifelse(round(atan2(V, U)*180/pi)==-180,
180,
round(atan2(V, U)*180/pi))
Now we have our R angle, whose meteorological equivalent we shall find in the tabela.de.graus:tabela.de.graus[match(ifelse(round(atan2(V, U)*180/pi)==-180, 180, round(atan2(V, U)*180/pi)),tabela.de.graus$r),"buss"]
The table was written in degrees, so we convert it back to radians to use in our sin() and cos(), to decompose it in U and V relative to the north-south axis:Uu=sin(tabela.de.graus[match(ifelse(round(atan2(V, U)*180/pi)==-180, 180, round(atan2(V, U)*180/pi)),tabela.de.graus$r),"buss"]*pi/180)
Vv=cos(tabela.de.graus[match(ifelse(round(atan2(V, U)*180/pi)==-180, 180, round(atan2(V, U)*180/pi)),tabela.de.graus$r),"buss"]*pi/180)
Comparison between "crude" values and "uniformized", the equatorial streamlines are much more clearer, and the jet stream is less polluted: