- 积分
- 1061
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-5-18
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 冰原1 于 2017-6-3 18:57 编辑
学习札记:
python在水色遥感中的应用(2):QuikScat风场数据读取,区域截取及可视化。
1.结果:
2.源代码
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 03 14:17:35 2017
@author: qiwei
"""
from quikscat_averaged_v4 import QuikScatAveraged
filename = 'qscat_200001v4.gz'
dataset = QuikScatAveraged(filename)
wspdname = 'windspd'
wdirname = 'winddir'
#missing = -999
wspd = dataset.variables[wspdname][:]
wdir = dataset.variables[wdirname][:]
#land = dataset.variables['land'][:]
#get lon/lat
lon = dataset.variables['longitude'][:]
lat = dataset.variables['latitude'][:]
#get u and v
from bytemaps import get_uv
import numpy as np
u,v = get_uv(wspd,wdir)
bad = np.where(wspd<0)
wspd[bad] = 0.
u[bad] = 0.
v[bad] = 0.
#get region to plot
latindex = np.arange(len(lat))
lonindex = np.arange(len(lon))
latindex2 = np.max(latindex[lat <=0])
latindex22 = np.min(latindex[lat >= 25])
lonindex2 = np.min(lonindex[lon >= 105])
lonindex22 = np.min(lonindex[lon >= 125])
#get region of you study
lat2 = lat[latindex2:latindex22]
lon2 = lon[lonindex2:lonindex22]
wspd2 = wspd[latindex2:latindex22, lonindex2:lonindex22]
u2 = u[latindex2:latindex22, lonindex2:lonindex22]
v2 = v[latindex2:latindex22, lonindex2:lonindex22]
#modules needed for this example
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import cmaps
#
fig=plt.figure(figsize=(12, 8))
#
m = Basemap(projection = 'cyl',llcrnrlat = 0,urcrnrlat = 25,llcrnrlon = 105,urcrnrlon = 125,resolution='l')
m.fillcontinents(color='silver')
m.drawparallels(np.arange(0.,25.,5.),labels=[1,0,0,0], linewidth = 0) # draw parallels
m.drawmeridians(np.arange(108.,125.,5.),labels=[0,0,0,1],linewidth = 0) # draw meridians
#m.drawcoastlines(color='darkgrey')
m.drawcountries(color='darkgrey')
m.drawmapboundary(fill_color='white')
#
x, y = m(*np.meshgrid(lon2, lat2))
yy = np.arange(0, y.shape[0], 4)
xx = np.arange(0, x.shape[1], 4)
points = np.meshgrid(yy, xx)
#
obj = m.quiver(x[points], y[points], u2[points], v2[points], wspd2[points], width = 0.004, cmap = cmaps.BkBlAqGrYeOrReViWh200)
cbar = m.colorbar(obj, label = "m/s")
#plt.grid()
plt.title('Wind Speed of QuikScat in January, 2000')
plt.savefig('SSW2.png', dpi=300)
plt.show()
3.模块和数据
|
评分
-
查看全部评分
|