日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python台风动图绘制_使用Python绘制台风轨迹图的示例代码

發布時間:2023/12/15 python 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python台风动图绘制_使用Python绘制台风轨迹图的示例代码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考:

使用CMA熱帶氣旋最佳路徑數據集,對我國周邊的臺風進行繪制

import re

import os

import numpy as np

import matplotlib.pyplot as plt

from mpl_toolkits.basemap import Basemap

path=r"E:\Computer Science\數學建模\第二次模擬賽題\附件"

files= os.listdir(path) #得到文件夾下的所有文件名稱

data=[]

all=[]

for file in files: #遍歷文件夾

if not os.path.isdir(file): # 判斷是否是文件夾,不是文件夾才打開

f = open(path + "/" + file) # 打開文件

tmp=f.readlines()

for i in tmp:

line=i.split()

if(line[0]=='66666'):

if(len(all)>0):

data.append(all)

# print(line)

all=[]

else:

we=(int(line[2])*0.1,int(line[3])*0.1)

all.append(we)

# print(data)

print(len(data))

CHN='E:\Computer Science\數學建模\python_basemap'

plt.figure(figsize=(20,12))

map=Basemap(llcrnrlon=70,llcrnrlat=2,urcrnrlon=170,urcrnrlat=58)

map.drawcoastlines()

map.drawcountries()

#添加河流

# map.drawrivers(color='blue',linewidth=0.3)

#添加大陸

map.readshapefile(CHN+'\gadm36_CHN_shp\gadm36_CHN_1',

'states',color='blue',drawbounds=True)

map.readshapefile(CHN+'\gadm36_TWN_shp\gadm36_TWN_1',

'taiwan',color='blue',drawbounds=True)

#添加經緯線

parallels = np.linspace(3,55,5)

# print(parallels)

map.drawparallels(parallels,labels=[False,True,False,False],fontsize=5)

meridians = np.linspace(70,170,5)

# print(meridians)

map.drawmeridians(meridians,labels=[False,False,False,True],fontsize=5)

plt.rcParams['savefig.dpi'] = 300 #圖片像素

plt.rcParams['figure.dpi'] = 300 #分辨率

ans=1

x=[]

y=[]

for typhoon in data:

length=len(typhoon)

print("%d is process!" % ans)

ans += 1

for i in range(length):

x.append(typhoon[i][1])

y.append(typhoon[i][0])

# print(x,y)

# map.plot(x, y, 'c*-', linewidth=2)

map.plot(x, y, color='r',linewidth=1.5)

x = []

y = []

map.fillcontinents()

plt.title(r'$China\ Typhoon$',fontsize=24)

# plt.ylim(70, 170)

# plt.xlim(2, 58)

plt.show()

效果圖:

以上就是使用Python繪制臺風軌跡圖的示例代碼的詳細內容,更多關于Python繪制軌跡圖的資料請關注自學編程網其它相關文章!

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的python台风动图绘制_使用Python绘制台风轨迹图的示例代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。