vcs
vcs copied to clipboard
vector not projected (at robinson at least)
import vcs
import cdms2
x = vcs.init()
tmp = vcs.createtemplate()
tmp.ytic1.x1= tmp.data.x1
tmp.ytic1.x2= tmp.data.x1 - .02
f = cdms2.open(vcs.sample_data+"/clt.nc")
#gm = vcs.createboxfill()
#gm.projection="robinson"
clt = f('clt', latitude=(-90.0, 90.0), squeeze=1,
longitude=(-180, 200.0), time=('1979-01', '1988-12'),)
gm = x.createvector()#'a_robinson_boxfill')
gm.scale =10
u = f("u")
gm.projection = "robinson"
gm.datawc_x1 = -180
gm.datawc_x2 = -150
gm.datawc_y1= 0
gm.datawc_y2= 90
x.plot(u-u,u, gm, tmp)
gives (all vector are straight up, they should be curved a bit)

and for polar projection we get :+1:

@scottwittenburg @aashish24 at your convenience pull the commit from the good branch
@scottwittenburg we should check if this is still true.
Will do. I suspect it is still true, since I haven't addressed it myself yet. Thanks for the reminder.
@doutriaux1 @scottwittenburg I'll start looking at this.
@doutriaux1 Why are you saying that the vectors should be curved? In the code, one of the vector components is 0 (you are doing u - u) so it is correct that the vectors are straight up.
straight up means toward the north pole. In robinson, at the "north" the arrow should not be staright up be slightly tilted. does this makes sense?
At the moment, there is no transform applied to the vector as far as I know. So I guess, you are expecting to to transform the points of the arrow using the same transform as for the points of the mesh.
yes exactly
Sounds good, I'll look into doing this.
A problem with transforming the vectors is that the transformation may not equidistant. So the same size vector would look different sizes in different parts of the map. Is this something we want to have?
@danlipsa i think so, but for the legend, let's use the length at the equator (or mid lat/lon of the plot)
Points in the dataset are in lat lon, and vectors are in meters per second (I will assume that this will always be the case). This means that I will have to convert points from lat lon to UTM, compute the vector heads in UTM and than convert back to lat lon. Each point is potentially in a different UTM zone that means that I will do a different conversion for each point which may be slow.
I think it makes sense to add vector projection as an option (if vectors are somehow abstract and not related to meters) - What should the default be? On? Comments @doutriaux1 @scottwittenburg @aashish24 ?
To me it seems to be incorrect not to project the vectors if the rest of the plot is in some projection, so I would think if it's an option, it should default to ON. But maybe I'm missing something?
I agree with @scottwittenburg
@danlipsa i get your point about units. But how do we do it in the "normal" case. I mean would the vector length change if the values are the same but units switch from "m/s" to "km/s" ?
Let's do it for m/s and then it would be easy to look at the unit and make adjustments if we need to. The problem is that likely the vector size and direction will change differently depending where on where the vector is on the map. So the fact that we scale the vectors anyway to show them won't help. I agree, projection will be ON by default.
Here are some images with the fix. I'll need to upgrade VTK.
for polar projection
for robinson projection with gm.datawc_x2 = -50 and plot (ratio="autot")

Looking great @danlipsa
A consequence of the projection is that the vector range changes, for robinson especially at the poles.
The this the projected vector: range 0, 150
and the original vector: range 0, 70
The pattern (after clamping the projected vector) looks almost the same except at the poles.