vcs icon indicating copy to clipboard operation
vcs copied to clipboard

vector not projected (at robinson at least)

Open doutriaux1 opened this issue 7 years ago • 19 comments

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)

crp

and for polar projection we get :+1: crp

doutriaux1 avatar Jul 26 '18 23:07 doutriaux1

@scottwittenburg @aashish24 at your convenience pull the commit from the good branch

doutriaux1 avatar Jul 26 '18 23:07 doutriaux1

@scottwittenburg we should check if this is still true.

doutriaux1 avatar Mar 27 '19 14:03 doutriaux1

Will do. I suspect it is still true, since I haven't addressed it myself yet. Thanks for the reminder.

scottwittenburg avatar Mar 27 '19 15:03 scottwittenburg

@doutriaux1 @scottwittenburg I'll start looking at this.

danlipsa avatar Jun 11 '19 17:06 danlipsa

@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.

danlipsa avatar Jun 11 '19 19:06 danlipsa

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?

doutriaux1 avatar Jun 11 '19 19:06 doutriaux1

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.

danlipsa avatar Jun 11 '19 19:06 danlipsa

yes exactly

doutriaux1 avatar Jun 11 '19 19:06 doutriaux1

Sounds good, I'll look into doing this.

danlipsa avatar Jun 11 '19 19:06 danlipsa

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 avatar Jun 13 '19 15:06 danlipsa

@danlipsa i think so, but for the legend, let's use the length at the equator (or mid lat/lon of the plot)

doutriaux1 avatar Jun 13 '19 16:06 doutriaux1

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 ?

danlipsa avatar Jul 18 '19 15:07 danlipsa

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?

scottwittenburg avatar Jul 19 '19 16:07 scottwittenburg

I agree with @scottwittenburg

doutriaux1 avatar Jul 19 '19 16:07 doutriaux1

@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" ?

doutriaux1 avatar Jul 19 '19 16:07 doutriaux1

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.

danlipsa avatar Jul 19 '19 17:07 danlipsa

Here are some images with the fix. I'll need to upgrade VTK. for polar projection test for robinson projection with gm.datawc_x2 = -50 and plot (ratio="autot") test

danlipsa avatar Nov 01 '19 14:11 danlipsa

Looking great @danlipsa

aashish24 avatar Nov 01 '19 20:11 aashish24

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 vector and the original vector: range 0, 70 original_vector The pattern (after clamping the projected vector) looks almost the same except at the poles.

danlipsa avatar Nov 18 '19 14:11 danlipsa