Python barbs wrong direction -


there simple answer , i'm asking last resort answers searching can't figure out or find answer. i'm plotting wind barbs in python pointing in wrong direction , don't know why.

data imported file , put lists, found on stackoverflow post how set u, v barbs using np.sin , np.cos, results in correct wind speed direction wrong. i'm plotting simple tephigram or skew-t.

# program read in radiosonde data file named "raob.dat"  # import numpy since going use numpy arrays , loadtxt # function. import numpy np import matplotlib.pyplot plt  # open file reading , store file handle "f" # filename 'raob.dat'  f=open('data.dat') # read data file handle f.  np.loadtxt() useful reading # simply-formatted text files. datain=np.loadtxt(f) # close file. f.close();  # can copy different columns # pressure, temperature , dewpoint temperature  # note colon means consider elements in dimension. # , remember indices start 0 p=datain[:,0] temp=datain[:,1] temp_dew=datain[:,2] wind_dir=datain[:,3] wind_spd=datain[:,4]  print 'pressure/hpa: ', p print 'temperature/c: ', temp print 'dewpoint temperature: ', temp_dew print 'wind direction/deg: ', wind_dir print 'wind speed/kts: ', wind_spd  # barb vectors. bit think causing problem u=wind_spd*np.sin(wind_dir) v=wind_spd*np.cos(wind_dir)  #change units #p=p/10 #temp=temp/10 #temp_dew=temp_dew/10  #plot graphs fig1=plt.figure() x1=temp x2=temp_dew y1=p y2=p x=np.linspace(50,50,len(y1)) #print x plt.plot(x1,y1,'r',label='temp') plt.plot(x2,y2,'g',label='dew point temp') plt.legend(loc=3,fontsize='x-small') plt.gca().invert_yaxis() #fig2=plt.figure() plt.barbs(x,y1,u,v) plt.yticks(y1) plt.grid(axis='y') plt.show() 

the barbs should in same direction can see in direction in degrees data.

any appreciated. thank you.

here data used:

996 25.2    24.9    290 12 963.2   24.5    22.6    315 42 930.4   23.8    20.1    325 43 929 23.8    20  325 43 925 23.4    19.6    325 43 900 22  17  325 43 898.6   21.9    17  325 43 867.6   20.1    16.5    320 41 850 19  16.2    320 44 807.9   16.8    14  320 43 779.4   15.2    12.4    320 44 752 13.7    10.9    325 43 725.5   12.2    9.3 320 44 700 10.6    7.8 325 45 649.7   7   4.9 315 44 603.2   3.4 1.9 325 49 563 0   -0.8    325 50 559.6   -0.2    -1  325 50 500 -3.5    -4.9    335 52 499.3   -3.5    -5  330 54 491 -4.1    -5.5    332 52 480.3   -5  -6.4    335 50 427.2   -9.7    -11 330 45 413 -11.1   -12.3   335 43 400 -12.7   -14.4   340 42 363.9   -16.9   -19.2   350 37 300 -26.3   -30.2   325 40 250 -36.7   -41.2   330 35 200 -49.9   0   335 0 150 -66.6   0   0   10 100 -83.5   0   0   30 

liam

# barb vectors. bit think causing problem u=wind_spd*np.sin(wind_dir) v=wind_spd*np.cos(wind_dir) 

instead try:

u=wind_spd*np.sin((np.pi/180)*wind_dir) v=wind_spd*np.cos((np.pi/180)*wind_dir) 

(http://tornado.sfsu.edu/geosciences/classes/m430/wind/winddirection.html)


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -