-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quiver arrows reverse in all polar projections except orthographic. Why? #157
Comments
For reasons not yet clear to me, you have to reverse the sign of the vectors that come back from transform_vector for SH polar plots, i.e. ups = -ups; vps = -vps in your test script right after the call to transform_vector. Must have something to do with how the projection coordinates are defined in proj4. |
Thanks. That solved it. You're probably right in that its not a basemap issue per se but rather a proj4 thing... |
Still, it seems to me that transform_vector should take care of this transparently, so I am reopening this. |
I think that the reason for this behavior is that when using polar projections at the southern hemisphere the ranges of the axes are negative:
combined with the default value of the option
When using 'angles=xy', vectors are plotted properly. # Define a displacement (dlon, dlat) that moves all
# positions (lons, lats) a small distance in the
# direction of the original vector.
dc = 1E-5 * np.exp(theta*1j)
dlat = dc.imag * np.cos(np.radians(lats))
dlon = dc.real What is the foundation of that computation? Should not this be: # Define a displacement (dlon, dlat) that moves all
# positions (lons, lats) a small distance in the
# direction of the original vector.
dc = 1E-5 * np.exp(theta*1j)
dlat = dc.imag
dlon = dc.real / np.cos(np.radians(lats)) ??? |
Hi: Yes you are right it should be divided by cos in dlon, but that might cause a division by 0 problem, so I suppose he multiplied the vector (i.e. both components) by cos. And it is OK to multiply since cos(lat) is not negative and preserves direction. Cheers |
Thanks @guzly. I came to that conclusion too. I just wondered
The wording does not specify it, and other mapping systems use angular units |
I think this function would work for any units. Spherical coordinates, as I Cheers 2015-09-14 7:28 GMT-04:00 Joan Pau Beltran notifications@github.com:
Sasha |
Not actually. If the velocity components are eastward and northward but already expressed in deg/s
Since only one component is affected, this is not a scaling: the direction of the I am not asking to change the current behavior to this one. |
Maybe it is a bit tricky to understand... I'll try to explain later or Cheers 2015-09-14 9:00 GMT-04:00 Joan Pau Beltran notifications@github.com:
Sasha |
Actually ... You are right, sorry)) I hope nobody will try to use it this way.... Confusing ...)) 2015-09-14 9:26 GMT-04:00 Oleksandr Huziy guziy.sasha@gmail.com:
Sasha |
Hi
I'm trying to plot vectors in the Southern ocean using basemap and matplotlib.
To illustrate my problem I've created a zonal jet at 60S.
I have U and V as 2D arrays and lon and lat as 1D arrays, all with cyclic point added and lon is from -180 to 180.
If I plot in orthographic projection the vectors correctly shows eastward motion, but if I use any of the polar projections (spstere, splaea spaeqd) the vectors reverse!
This is really strange and oddly enough it does not seem to happen if I make the same plot over the North Pole.
I've noted that in the southern hemisphere lon_0 has a different meaning for orthographic projection than for spstere, splaea etc.
So to orient the maps the same way I must pass lon_0=0 in orthographic projection and lon_0=180 in polar stereographic projection if I plot southern hemisphere.
But this is not the case in the Northern hemisphere.
Could this be part of the problem?
Here's the script that creates the results:
https://dl.dropboxusercontent.com/u/86754720/plot_quiver_bug_test.py
Here's the contourf of u and v
https://dl.dropboxusercontent.com/u/86754720/velocity_bug_contourf.png
and here are the vectors
https://dl.dropboxusercontent.com/u/86754720/velocity_bug_quiver.png
The text was updated successfully, but these errors were encountered: