Matplotlib是Python常用的數(shù)據(jù)繪制包,其繪圖功能強大;而Basemap則是Matplotlib的一個子包,負責(zé)地圖繪制。本文簡單介紹如何利用該程序包繪制風(fēng)向圖。具體操作如下:
導(dǎo)入命令
1)設(shè)置工作環(huán)境并導(dǎo)入程序包
%cd "F:\\Dropbox\\python" import numpy as np import matplotlib.pyplot as plt import datetime from mpl_toolkits.basemap import Basemap, shiftgrid from netCDF4 import Dataset
3)設(shè)定時間并讀取數(shù)據(jù)
yyyy=1993; mm=03; dd=14; hh=00 date = datetime.datetime(yyyy,mm,dd,hh) URLbase="http://nomads.ncdc.noaa.gov/thredds/dodsC/modeldata/cmd_pgbh/" URL=URLbase+"%04i/%04i%02i/%04i%02i%02i/pgbh00.gdas.%04i%02i%02i%02i.grb2" %\ (yyyy,yyyy,mm,yyyy,mm,dd,yyyy,mm,dd,hh) data = Dataset(URL)
4)數(shù)據(jù)預(yù)處理
latitudes = data.variables['lat'][::-1] longitudes = data.variables['lon'][:].tolist() slpin = 0.01*data.variables['Pressure_msl'][:].squeeze() slp[:,0:-1] = slpin[::-1]; slp[:,-1] = slpin[::-1,0]u = np.zeros((uin.shape[0],uin.shape[1]+1),np.float64) u[:,0:-1] = uin[::-1]; u[:,-1] = uin[::-1,0]v = np.zeros((vin.shape[0],vin.shape[1]+1),np.float64)v[:,0:-1] = vin[::-1]; v[:,-1] = vin[::-1,0]longitudes.append(360.); longitudes = np.array(longitudes)lons, lats = np.meshgrid(longitudes,latitudes)
5)設(shè)定并繪制圖示
m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)fig1 = plt.figure(figsize=(8,10)) ax = fig1.add_axes([0.1,0.1,0.8,0.8])clevs = np.arange(960,1061,5)x, y = m(lons, lats)parallels = np.arange(-80.,90,20.) meridians = np.arange(0.,360.,20.)CS1 = m.contour(x,y,slp,clevs,linewidths=0.5,colors='k',animated=True) CS2 = m.contourf(x,y,slp,clevs,cmap=plt.cm.RdBu_r,animated=True)ugrid,newlons = shiftgrid(180.,u,longitudes,start=False) vgrid,newlons = shiftgrid(180.,v,longitudes,start=False) uproj,vproj,xx,yy = \ m.transform_vector(ugrid,vgrid,newlons,latitudes,31,31,returnxy=True,masked=True) Q = m.quiver(xx,yy,uproj,vproj,scale=700)qk = plt.quiverkey(Q, 0.1, 0.1, 20, '20 m/s', labelpos='W')m.drawcoastlines(linewidth=1.5) m.drawparallels(parallels) m.drawmeridians(meridians) cb = m.colorbar(CS2,"bottom", size="5%", pad="2%") cb.set_label('hPa') ax.set_title('SLP and Wind Vectors '+str(date)) plt.show()
輸出圖像如下
以上就是【Python教程】地理可視化的內(nèi)容,更多相關(guān)內(nèi)容請關(guān)注PHP中文網(wǎng)(m.miracleart.cn)!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

Seaborn 's Loctplot? ???? ? ?? ?? ??? ??? ???? ??????. 2. ?? ???? sns.jointPlot (data = tips, x = "total_bill", y = "tip", ?? = "scatter")? ?? ?????. ??? ????? ?????? ??? ??? ?????. 3. ???? ?? ??? ??? = "reg"? ???? marginal_kws? ???? ?? ?? ???? ?????. 4. ??? ??? ? ?? "Hex"? ???? ?? ????.

??? ??? ".join (Words)? ?? join () ???? ?? ? ? ????. 2. ?? ??? ???? ?? MAP (str, ??) ?? [str (x) forxinnumbers]??? ???? ???????. 3. ?? ?? ??? ???? ??? ??? ?????? ???? ?? ?? ? ? ????. 4. '|'.join (f "[{item}]"furiteminitems) ??? ?? join ()? ?? ? ??? ????? ??? ?? ??? ??? ? ????.

PyoDBC ?? : PipinStallPyODBC ??? ???? ?????? ??????. 2. SQLSERVER ?? : PYODBC.connect () ???? ?? ????, ??, ??????, UID/PWD ?? Trusted_Connection? ?? ? ?? ???? ???? SQL ?? ?? Windows ??? ?? ?????. 3. ??? ????? ?????? : pyodbc.drivers ()? ???? 'sqlserver'? ?? ? ???? ??? ????? ??? ???? ??? 'sqlserver ? Odbcdriver17? ?? ??? ???? ??? ????? ??????. 4. ?? ???? ? ?? ??

pandas.melt ()? ???? ?? ???? ? ???? ???? ? ?????. ?? ID_VARS? ???? ? ? ??? ???? ????. ??, 4.Value_name = 'score'? ?? ?? ? ? ??? ???? ????? ??, ?? ? ??? ??? ? ?? ?????.

?? ??, ??? ? ??? ??? ?? ? ContactForm ??? ?????. 2.????, ?? ??? ?? ??? ???? ????, ??? ?? ? ? cleaned_data? ???? ??? ?????. ??? ??? ? ??? ??????. 3. ????? {{form.as_p}}? ???? ??? ????? {%csrf_token%}? ???? CSRF ??? ?????. 4. URL ???? Point / Contact / Contact_View??? ?????. modelform? ???? ??? ?? ???? ??? ??? ??????. ?? ?? ??? ??, HTML ??? ? ?? ????? ?? ??? ????, ?? ??? ?? ??? ?? ??? ?????.

pythontanbeoptimizedformemory-boundoperations? Headgroughgenerations, ??? ? ??? ??, ? ManagingObjectLifetimes.first, usegeneratorsinsteadoflistStoprocessLargedAtasetSoneitematime, theintintomemory.second? ?????

?? ?? ?? ? ?? ?? ??? ??? ??? ???? ?? ???? ?? ???? ???? ?? ?????. ?? ??? ?? ???? ??? ?, ? ?? ??? ????? ?? ???? ??? ? ??? ?? ??? ???? ??? ????. ???? ??? ??? ???? ?? ?? ?? ??? ???? ????? ????? ???? ?????? ????. ??? ??? ?? ??? ?????? ???? ?? ?? ??? ?????. cryptocurrency ???? ??? ?? ??? ?? ?? ??? ? ???? ??? ???? ?? ?? ?? ????. ?? ?? ??? ?? ?? ??? 24 ?? ?? ???? ??? ??, ?? ??? ?? ? ?? ?????? ?? ?????. ? ??? ?? ??? ?? ?? ?? ??? ??? ???? ?????.

iter ()? ??? ??? ?? ? ???? ?? ()? ?? ??? ?? ? ?????. 1. iterator ()? ???? ??? ?? ?? ??? ??? ???? ?????. 2. ?? ()? ???? ??? ??? ?? ??? ?? ? ? ??? ?? ??? ??; 3. ?? (???, ???)? ???? ??? ?????. 4. ??? ???? ?? ??? ???? ?? __iter __ () ? __next __ () ???? ???????. ???? ???? ?? ??? ??????? ???? ???? ?? ????? ???? ??????.
