How could I plot wind barbs using wind data from netCDF files of ECMWF?

Hello,

I 've seen the wind barb code in the IGOR manual. I tried to use it, but probably I can't apply it on my dataset. My dataset comes from ECMWF and it is in netCDF form.

Here, I have the two codes that I've written. Firstly, I use Function WindDir(u_1,v_1) using the waves of the attached file (so it is WindDir(nc_u10,nc_v10)) and then I run Function Barb_Plot().
The first code is to convert u and v components into speed and direction of the wind. The second is for plotting barbs.

Function WindDir(u_1,v_1)

wave u_1, v_1                                                        
Duplicate/o u_1, u_1_easterly
Duplicate/o v_1, v_1_northerly
u_1_easterly*=-1
v_1_northerly*=-1

Duplicate/O u_1_easterly, w_dir, w_spd
//w_dir= direction the wind is coming from
w_dir=mod(atan2(u_1_easterly,v_1_northerly)/pi*180+360,360)
w_spd=sqrt( (v_1_northerly*v_1_northerly)+(u_1_easterly*u_1_easterly))

end

//----------------------------------------------------------------------------------------------------------

Function Barb_Plot()

// Make XY data

wave w_spd, w_dir, nc_longitude, nc_latitude
variable rows, columns,i

Display  nc_latitude vs nc_longitude              // Make graph
ModifyGraph mode(nc_latitude) = 3        // Marker mode

rows=dimsize(w_spd,0)
columns=dimsize(w_spd,1)

Make/O/N=(rows,3) barbData    // Controls barb length, angle and number of barbs

//Edit /W=(439,47,820,240) barbData

For (i=0;i<rows;i+=1)
barbData[i][0] = 40
barbData[i][1] = w_dir[i] * pi/180
barbData[i][2] = (w_spd[i]/100*1.94)
EndFor
SetDimLabel 1, 2, WindBarb, barbData    // Set column label to WindBarb

RemoveFromGraph/Z barbData                        // Remove it if it is already on the graph
AppendToGraph nc_latitude vs nc_longitude
ModifyGraph mode=3,arrowMarker(nc_latitude)={barbData,1,10,1,1}
ModifyGraph margin(top)=62,margin(right)=84
ModifyGraph rgb(nc_latitude)=(43690,43690,43690)   



End



Could anyone help please?
netcdf-atls07-a562cefde8a29a7288fa0b8b7f9413f7-85_jsV.zip
Quote:
Here, I have the two codes that I've written. Firstly, I use Function WindDir(u_1,v_1) using the waves of the attached file (so it is WindDir(nc_u10,nc_v10)) and then I run Function Barb_Plot().
The first code is to convert u and v components into speed and direction of the wind. The second is for plotting barbs.


You have not told us what the problem is.

Also, this seems to be a question about wind barbs, not about netCDF, so posting a netCDF file is of little use.

I recommend that you create the absolute simplest possible self-contained Igor experiment that shows the problem, and post that along with a description of what you expect and what you get. This will allow people to consider the issue without spending a lot of time on setup and boiling it down.
Sorry, you are right.

Actually, I am trying to get a plot of wind barbs, for example wind barbs over Europe in a random level pressure.

Instead of that I take no barbs, but just markers on a line. So the main problem is that I take markers with a wrong distribution, as you can see in the attachment.

The problem is definetely in the Function Barb_Plot(), but I don't know where. Besides, if I try random values of wind and space I can get barbs, but I can't when I use netCDF files, that's why I mention netCDF files in the title.

I hope that I am a bit more understandable now.

Thank you,

Stavros
wronggraph.png
Have you looked at the Barbs and Arrows example (File...Example Experiments...Feature Demos 2...Barbs and Arrows ?

As HRodstein said...

hrodstein wrote:
I recommend that you create the absolute simplest possible self-contained Igor experiment that shows the problem, and post that along with a description of what you expect and what you get. This will allow people to consider the issue without spending a lot of time on setup and boiling it down.


This would really help people to help you.
Hi all,

I finally solved this problem. If anyone wants to load netcdf files and plot wind barbs, he should put all the data in a 1-D wave. So for example, he should put all the wind values of a 2-D wave (e.g. for Europe) in a 1-D wave. In the same way, he should put longtide and latitude in 1-D waves, so IGOR to understand that the specific wind value is for specific latitude and longitude.

Stavros
I want to know how to define a 2-column wave(wind speed and wind direction). Thank you for your reply!
I would just edit the above function for it to return your 2D wave. It was a bit a mess. I did not compile it, but I hope you get the idea.
Function/Wave wind(easterly,northerly)
Wave easterly, northerly
Variable rows

rows = DimSize(easterly, 0)

// create wave, two columns: direction, speed
Make/FREE/N=(rows,2) wind
wind[p][0]=mod(atan2((-1) * easterly[p], (-1) * northerly[p])/pi*180+360,360)
wind[p][1]=sqrt( (northerly[p]^2)+(easterly[p]^2))

Return wind
End


for further information please run
displayhelptopic "make"