任何点我有一个数组anomalies_ind
这是以这种方式创建:散点图不上绘制底图
data_path = r"C:\Users\matth\Downloads\TRMM_3B42RT\3B42RT_Daily.201001.7.nc4"
f = Dataset(data_path)
latbounds = [ -45 , -10 ]
lonbounds = [ 105, 160 ]
lats = f.variables['lat'][:]
lons = f.variables['lon'][:]
# latitude lower and upper index
latli = np.argmin(np.abs(lats - latbounds[0]))
latui = np.argmin(np.abs(lats - latbounds[1]))
# longitude lower and upper index
lonli = np.argmin(np.abs(lons - lonbounds[0]))
lonui = np.argmin(np.abs(lons - lonbounds[1]))
precip_subset = f.variables['precipitation'][ : , lonli:lonui , latli:latui ]
data_low_indices1 = np.where((precip_subset > 0) & (precip_subset < 1))
data_low_indices2 = np.array(np.where((precip_subset > 0) & (precip_subset < 1))).T
anomalies_ind = []
for ind in data_low_indices2:
anomalies_ind.append(ind)
print(np.asarray(anomalies_ind))
这样做的输出是这样的:
[[1, 23, 45]
[3, 45, 56]
...
[31, 45, 89]]
第一元素表示天在1月份,第二和第三元素分别代表经度和纬度。我想在地图上给出像这样的经度和纬度积点:
foo = np.asarray(anomalies_ind)
longs = foo[:,1]
lat = foo[:,2]
m = Basemap(llcrnrlon=105.,llcrnrlat=-45,urcrnrlon=160,urcrnrlat=-10)
m.drawcoastlines()
m.fillcontinents(color = 'lightgray', zorder = 0)
m.scatter(longs, lat, marker = 'o', color = 'k', zorder=10)
plt.show()
然而,没有点在地图上。有谁知道什么是错的?
编辑:这里是真正的foo
阵列”
[[ 0 0 0]
[ 0 0 16]
[ 0 0 17]
...,
[ 30 219 113]
[ 30 219 114]
[ 30 219 116]]
如果您不要填满大陆,你能看到分散?如果你甚至不画海岸线呢? – cphlewis
@cphlewis:我已经试过了。我认为这个问题可能是'longs = foo [:,1]'和'lat = foo [:,2]' –