无法使用底图渲染北美数据

Cannot render North America data with Basemap

我想使用来自欧洲中期天气预报中心的 netcdf 文件渲染整个地图和北美部分地区,但只显示了地图的一半。

import netCDF4 as nc
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

fn = '_grib2netcdf-webmars-public-svc-green-007-6fe5cac1a363ec1525f54343b6cc9fd8-b5oXS9.nc'
ds = nc.Dataset(fn)

#variables
#longitude, latitude, time, pm1

lons = ds.variables['longitude'][:]
lats = ds.variables['latitude'][:]
time = ds.variables['time'][:]
pm = ds.variables['pm1'][:]

mp = Basemap(projection='merc',llcrnrlat=-80,urcrnrlat=80,\
            llcrnrlon=-180,urcrnrlon=180,lat_ts=20,resolution='c')

lon, lat = np.meshgrid(lons, lats)
x, y = mp(lon, lat)

cscheme = mp.pcolor(x, y, np.squeeze(pm[0,:,:]), cmap = 'plasma', shading='auto')
mp.drawcoastlines()
mp.drawstates()
mp.drawcountries()

cbar = mp.colorbar(cscheme, location = 'right')
plt.title('Particulate matter d < 1 um')
plt.show()

这是图片 https://i.imgur.com/EaU4Gqx.png

我用 Panoply 检查了 netcdf 文件,看起来不错。

https://i.imgur.com/JH02FVe.png

找到解决方案:

lons[lons>180]-=360

来自