我有一个奇怪的问题,我很难解决。我正在使用python绘制netcdf文件中的一些变量。在这种情况下降水。当我在我的Mac上运行代码时,并不是所有的滴答都显示在颜色条上。但是,当我在我的linux服务器上运行完全相同的代码时,所有滴答都会显示出来。
我的mac上的python路径是:
~:which python
/opt/local/bin/python
我真的很感激有关问题的建议。
MAC缺少蜱虫:
Linux上没有丢失蜱虫:
我的代码是
#!/usr/bin/env python
import matplotlib
matplotlib.use('Agg')
import numpy as np
import netCDF4 as nc
import matplotlib.pyplot as plt
import os,sys
from mpl_toolkits.basemap import Basemap
fil = str(sys.argv[1])
nc_f = nc.Dataset(fil,'r')
lats = nc_f.variables['XLAT'][0,:,:]
lons = nc_f.variables['XLONG'][0,:,:]
precip = nc_f.variables['PREC'][:,:,:]
nc_wrf.close()
precip_lvl=[0.0,0.1,0.5,1.0,1.5,2.0,3.0,4.0,5.0,7.0,10.0,15.0,20.0,25.0,30.0,35.0,40.0]
precip_color = [(1.00, 1.00, 1.00), (0.84, 0.69, 0.63),
(0.72,0.56,0.51), (0.80,0.86,1.00),(0.65,0.73,1.00),(0.49,0.63,1.00),
(0.37,0.42,0.97),(0.31,0.33,0.98),(0.13,0.57,0.09),
(0.20,0.71,0.18),(0.65,0.80,0.36),(0.68,0.99,0.36),(1.0,1.0,0.08),
(0.99,0.57,0.05),(0.86,0.00,0.02),(0.68,0.00,0.02),(0.42,0.00,0.02)]
m = Basemap(projection='merc',llcrnrlat=50,urcrnrlat=60,\
llcrnrlon=0,urcrnrlon=20,lat_ts=0,resolution='i')
x,y=m(lons,lats)
for indx in xrange(36):
tmp = precip[indx,:,:]
fig = plt.figure(figsize=(10,8))
m.contourf(x,y,tmp,levels=precip_lvl, extend='both', colors=precip_color)
plt.colorbar(shrink=0.8,ticks=precip_lvl)
typ='.png'
name='prec'
plt.savefig(name+str(indx)+typ)
答案 0 :(得分:1)
我将首先比较两台机器之间的版本号。
import matplotlib
import mpl_toolkits.basemap
print(matplotlib.__version)
print(mpl_toolkits.basemap.__version__)