- 积分
- 1807
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-3-13
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 adam_5 于 2017-5-22 19:54 编辑
用MICAPS第11类数据画流场,但是一直画不出来,请大神帮忙看看吧,不知道怎么去除下载数据扣金钱的规则,不好意思
错误信息
- import matplotlib.pyplot as plt
- from mpl_toolkits.basemap import Basemap
- from matplotlib.collections import PathCollection
- from matplotlib.path import Path
- from matplotlib import cm
- import numpy as np
- class MicapsData11:
- def ReadData(self,filename):
- file000=open(filename)
- lines=file000.readlines()
- foredata=lines[0].split()+lines[1].split()+lines[2].split()
- dataflag = foredata[0]
- style = foredata[1]
- title = foredata[2]
- yy = int(foredata[3])
- mm = int(foredata[4])
- dd = int(foredata[5])
- hh = int(foredata[6])
- forehh = int(foredata[7])
- level = foredata[8]
- deltalon = float(foredata[9])
- deltalat = float(foredata[10])
- beginlon = float(foredata[11])
- endlon = float(foredata[12])
- beginlat = float(foredata[13])
- endlat = float(foredata[14])
- sumlon = int(foredata[15])
- sumlat = int(foredata[16])
- value=[]
- for i in range(len(lines)-3):
- line= lines[i+3].split()
- value+=line
- self.U = np.array(value[:sumlat*sumlon],dtype=float).reshape(sumlat,sumlon)
- self.V = np.array(value[sumlat*sumlon:],dtype=float).reshape(sumlat,sumlon)
- self.Z = np.zeros((sumlat, sumlon))
- for i in range(sumlon):
- for j in range(sumlat):
- self.Z[j,i]=np.sqrt(self.U[j,i]**2+self.V[j,i]**2)
- x = np.arange(beginlon, endlon + deltalon, deltalon)
- y = np.arange(beginlat, endlat + deltalat, deltalat)
- self.X, self.Y= np.meshgrid(x,y)
- def Draw(self):
- fig=plt.figure()
- ax=fig.add_subplot(111)
- bmap = Basemap(width=6000000, height=5000000,
- resolution='l', projection='lcc',
- lat_1=45., lat_2=25, lat_0=35, lon_0=105., ax=ax)
- bmap.drawcoastlines()
- bmap.fillcontinents(color='ivory', lake_color='skyblue', zorder=0)
- shp_info = bmap.readshapefile("E:\\python\\projects\\MicapsDataDraw-master\\shapefile\\bou2_4l", 'states',
- drawbounds=True)
- paths = []
- for line in shp_info[4]._paths:
- paths.append(Path(line.vertices, codes=line.codes))
- PathCollection(paths, linewidths=5, facecolors=cm.jet(np.random.rand(1)), zorder=1)
-
- bmap.drawmeridians(range(30, 160, 10), linewidth=0.5, dashes=[4, 2], labels=[0, 0, 0, 1], color='k', zorder=1,
- fontsize=10)
- bmap.drawparallels(range(10, 80, 10), linewidth=0.5, dashes=[4, 2], labels=[1, 1, 0, 0], color='k', zorder=1,
- fontsize=10)
-
- bmap.drawmapboundary(fill_color='skyblue')
- U_rot,V_rot, X,Y,= bmap.rotate_vector(self.U,self.V,self.X,self.Y,returnxy=True)
- ax.streamplot(X,Y,U_rot,V_rot,density=[1,1],zorder=0)
- plt.show()
- if __name__ == '__main__':
- micapsData11 = MicapsData11()
- micapsData11.ReadData('E:\\micaps\\qxj\\micaps\\high\\uv\\500\\16110908.000')
- micapsData11.Draw()
复制代码
|
|