|
Charting Geostrophic U-V Components |
Posted by Pete on Nov-15-2012 07:26 |
|
Hi Peter,
I have a question!
Have 2 matrix of gridded data. One is a 'U' Matrix and one a 'V' Matrix. The U represents the East/West component of Wind and the V represents the North/South Component. (In metres/second) From these two data matrix it is apparently possible to calculate the Wind Speed and the Wind Direction between two points.
Here is an overview of this type of data here:
http://www.aprweather.com/pages/wind.htm
So, when plotted I should be able to display, from this U and V matrix, the Speed of Wind and the Direction of Wind on a 2D plane - which is this case represents Geographical data. The Grid being Latitude and Longitude based.
Is there anyway of implementing this using Chart Director, and the Vector Charts method, so I can display Vector Arrows showing Wind Direction and then the Wind Speed using colour gradients to represent the Wind Field, whereby the scale will show Speed in Miles / Hour respresented by a usual Colour Gradient for the Wind Speed. Of coarse I could also use arrow size to also represent Speed!
Hope you can help! |
Re: Charting Geostrophic U-V Components |
Posted by Peter Kwan on Nov-16-2012 01:02 |
|
Hi Pete,
You may consider to plot the wind as vectors (arrows), in which the direction of the wind is represented by the direction of the vector, and the strength of the wind is represented by the length of the vector.
To do this, you would need a method to convert the wind speed to a length. For example, suppose the wind speed can be convert to a length using length = 0.1 x speed. You would also need to know the position of that wind, which I assume is based on the position in the matrix. We still need to know the unit you would like to use. In the following example, I just assume the position is the same as the array index.
So the vectors can be defined as (in Java):
int noOfVectors = widthOfMatrix * heightOfMatrix;
double[] vectorStartX = new double[noOfVectors];
double[] vectorStartY = new double[noOfVectors];
double[] vectorendX = new double[noOfVectors];
double[] vectorendY = new double[noOfVectors];
double speedToLength = 0.1;
int count = 0;
for (int x = 0; x < widthOfMatrix; ++x) {
for (int y = 0; y < heightOfMatrix; ++y) {
vectorStartX[count] = x; // x-coordinate is just the x-matrix-index
vectorStartY[count] = y; // y-coordinate is just the x-matrix-index
vectorEndX[count] = x + U[x][y] * speedToLength;
vectorEndY[count] = y + V[x][y] * speedToLength;
++count;
}
}
After getting all the vectors, you can plot them with a vector layer:
c.addVectorLayer(vectorStartX, vectorStartY, vectorEndX, vectorEndY, Chart.EndPoints, 0x000000);
Hope this can help.
Regards
Peter Kwan |
Re: Charting Geostrophic U-V Components |
Posted by Peter on Nov-16-2012 19:25 |
|
Hi Peter,
Thanks for your reply.
The values in U and V are meters/s, although I will be converting this to Miles/Hour - which is not an issue!
I have infact done a bit more research (from a Sailing website would you believe!) and the U and V x-y Matrices that I have can be converted to Speed and Direction as follows:
Wind Speed = sqrt(U? + V?)
Wind Direction :
If (V > 0) then A = 180
If (U < 0) and (V < 0) then A = 0
If (U > 0) and (V < 0) then A = 360
then:
Wind Direction = (180 / pi) * arctan(U / V) + A
This gives a Vector from 0-360.
I have already applied the Wind Speed calculation and that seems OK, I need to do my Arrow Vector Layer next. I have never used a Vector Layer before, but I presume I can Map the 0-360 values into the layer?
For your interest, as I've occasionally asked you questions over the years. All the Chart Director Graphs I am using are being applied to this new website I am building:
http://weatherandclimate.co.uk/index.php/model-viewer
There's quite a wide range of Charts there, using various aspects of Chart Director.
The one I am working on at the moment for Wind Speed and Direction can be seen on the Charts "Wind" and "Jet" - the two main winds used at the Surface and up in the Jet Stream.
They will look perfect when I add some arrows! |
|