问题描述
我有 12 个 1 月到 12 月的海面温度数据集。数据集有 3 个字段经度、纬度和 sst。
我想以这样的方式绘制 hovmoller 图,即我的 y 轴代表范围从北纬 9 度到北纬 16 度的纬度。而 x 轴代表从一月到十二月的月份。 在这里,经度将保持不变,即 15。
我想要相同的 python 代码。
这是我想要的示例图片
我可以使用 matplotlib 的 contourf 函数绘制各个月份的数据。
#Data for january-2019 to December-2019
months = ["January","February","march","April","May","June","July","August","September","October","November","December"]
for i in range(0,12):
data_file_name = "sst_" + months[i] + "_2019.nc"
local_file_path = 'C:/Users/hp/Desktop/ISRO/MOdis DATA NEW/'
local_file_path += data_file_name
file_handle = Dataset(local_file_path,mode = 'r',format ="NETCDF4")
fig = plt.figure(figsize = (15,8))
#Extracting all the columns from given .nc file
lat_scale = file_handle.variables['lat'][:] # 1D
lon_scale = file_handle.variables['lon'][:] # 1D
sst = file_handle.variables['sst'][:]
mBase2 = Basemap(llcrnrlon=50,llcrnrlat= 0,urcrnrlon= 100,urcrnrlat=27)
mBase2.drawmapboundary(color = 'green')
mBase2.drawcountries(linewidth = 2)
mBase2.drawcoastlines(linewidth = 2)
mBase2.drawparallels(np.arange(-90,90,5),labels=[True,False,False])
mBase2.drawmeridians(np.arange(-180,180,labels=[0,1])
v = np.linspace(22,32,50,endpoint=True)
mymap2 = plt.contourf(lon_scale,lat_scale,sst,v,cmap=plt.cm.jet)
plt.colorbar(mymap2,orientation = 'vertical')
title = "Sea Surface Temperature for " + months[i] + " - 2019"
plt.title(title)
image_name = str(i + 1) + "_sst_" + months[i] + "_2019"
plt.savefig(image_name)
对于上面的代码,我得到了以下所有 12 个月的结果。
The above image is only for January,similarly,I got other images for 11 months.
提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)