我想使用python pcolormesh绘制2019055至2019063的每日MODIS AOD数据。但是,某些图片有奇怪的水平线。我不知道为什么有些图片有线条,而其他图片没有。我附上我的图片和代码。
import glob
import numpy as np
from pyhdf.SD import SD, SDC
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
for j in range(55, 63):
date = str(j)
file_list = glob.glob('MOD04_L2.A20190'+date+'*.hdf')
hdf = SD(file_list[0], SDC.READ)
Aerosol_merge = hdf.select('Optical_Depth_Land_And_Ocean')
latitude_merge = hdf.select('Latitude')
longitude_merge = hdf.select('Longitude')
AOD_merge = Aerosol_merge[:,:]
lat_merge = latitude_merge[:,:]
lon_merge = longitude_merge[:,:]
for i in range(1, np.size(file_list)):
hdf = SD(file_list[i], SDC.READ)
Aerosol = hdf.select('Optical_Depth_Land_And_Ocean') #read AOD data
latitude = hdf.select('Latitude')
longitude = hdf.select('Longitude')
lat = latitude[:,:]
lon = longitude[:,:]
AOD = Aerosol[:,:]
AOD = np.ma.masked_where(AOD < 0 , AOD)
AOD = AOD*0.0010000000474974513
AOD_merge = np.vstack([AOD_merge,AOD])
lat_merge = np.vstack([lat_merge,lat])
lon_merge = np.vstack([lon_merge,lon])
AOD_merge = np.ma.masked_where(AOD_merge < 0, AOD_merge)
plt.hold(True)
map = Basemap(projection='cyl', resolution='l', llcrnrlat=-90, urcrnrlat=90, llcrnrlon=-180, urcrnrlon=180)
map.drawcoastlines(linewidth=0.5)
map.drawparallels(np.arange(-90., 90., 35.), labels=[1, 0, 0, 0])
map.drawmeridians(np.arange(-180., 180., 45.), labels=[0, 0, 0, 1])
x, y = map(lon_merge, lat_merge)
smap = map.pcolormesh(x, y, AOD_merge, cmap='jet')
plt.clim(0, 1.5)
smaplegend = map.colorbar(smap,location='bottom',pad="10%")
smaplegend.set_label('AOD')
plt.title("MODIS AOD "+date)
fig = plt.gcf()
plt.show()
fig.savefig('MODIS AOD '+date+'_global'+'.png',dpi = 500)