, , : , - . , , contour(), .
, , . collections , contour(), Path , . figure :
import matplotlib
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
delta = 0.025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-2.0, 2.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = 10.0 * (Z2 - Z1)
plt.figure()
CS = plt.contour(X, Y, Z)
for level in CS.collections:
for kp,path in reversed(list(enumerate(level.get_paths()))):
verts = path.vertices
diameter = np.max(verts.max(axis=0) - verts.min(axis=0))
if diameter<1:
del(level.get_paths()[kp])
plt.gcf().canvas.draw()
() () 1 ( 0 ):

, , , collections, . , CS.collections[k].remove(), , , ( , ).
, , , 2:

.
, . , level , np, . 2 ( arange, , p1 p2). , levels contour, , V=2 .
import numpy as np
import matplotlib.pyplot as plt
Z = np.loadtxt('mslp.txt',delimiter=',')
X,Y = np.meshgrid(np.linspace(0,300000,Z.shape[1]),np.linspace(0,200000,Z.shape[0]))
p1,p2 = 1006,1018
levels = np.arange(np.maximum(Z.min(),p1),np.minimum(Z.max(),p2),2)
plt.figure()
CS = plt.contour(X, Y, Z, colors='b', linewidths=2, levels=levels)
plt.figure()
CS = plt.contour(X, Y, Z, colors='b', linewidths=2, levels=levels)
for level in CS.collections:
for kp,path in reversed(list(enumerate(level.get_paths()))):
verts = path.vertices
diameter = np.max(verts.max(axis=0) - verts.min(axis=0))
if diameter<15000:
del(level.get_paths()[kp])
plt.gcf().canvas.draw()
plt.show()
, () ():

. , , - , griddata (). , . , :
import scipy.interpolate as interp
dN = 10
my_slice = [slice(None,None,dN),slice(None,None,dN)]
X2,Y2,Z2 = X[my_slice],Y[my_slice],Z[my_slice]
Zsmooth = interp.griddata(np.array([X2.ravel(),Y2.ravel()]).T,Z2.ravel(),(X,Y),method='cubic')
plt.figure()
CS = plt.contour(X, Y, Zsmooth, colors='b', linewidths=2, levels=levels)
, , , . : 'linear' , .
() upsampling ():

, , (, , ). , , - , , / . , , griddata, .