I am trying to use scipy interpolate griddata to interpolate a regular grid of lat/lon data points. When I try to run the script however I get the 'Zipped' line printed, then a pause, then the script ends without printing anything else or plotting the contour plot. There are no errror messages displayed. What am I doing wrong. See relavent section of code below.
general_file = r'datal3bx
etcdf
0024ir2_20160815_114117_232_l3bx_v10.nc'
file_data = Dataset(general_file) #Reading in the data
m = Basemap(projection='moll', resolution=None, lat_0=0, lon_0=0)
axis1 = file_data.variables['axis1'][:].data #Extracting values neeed
axis2 = file_data.variables['axis2'][:].data
rad = file_data.variables['radiance'][0].data
lon = file_data.variables['lon'][:][0].data
lat = file_data.variables['lat'][:][0].data
xi = np.arange(-180,190,10)
yi = np.arange(-90,100,10)
grid_x, grid_y = np.meshgrid(xi,yi)
rad = rad.flatten()
lon = lon.flatten()
lat = lat.flatten()
points = np.array(list(zip(lon,lat)))
print('Zipped')
grid_z = interpolate(points, rad, grid_x, grid_y)
plt.contourf(grid_x, grid_y, grid_z,25,cmap='Greys_r')
plt.colorbar()
plt.show()
print('End')
def interpolate(points, rad, grid_x, grid_y):
grid_z = griddata((lon, lat), rad, (grid_x, grid_y), method='nearest')
print('Interpolated')
return grid_z
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…