def contour_area(self,edges,resolution=0.1,**limits):
"""Return the area of each contour interval within the limits.
edges list containing the contour edges (1D array)
resolution resolution of the spline map used to calculate the area
TODO: better handling of limits
"""
lim = self.limits.copy()
lim.update(limits)
XX,YY = numpy.mgrid[lim['minNMP']:lim['maxNMP']:resolution,
lim['minLID']:lim['maxLID']:resolution]
A = self.F(XX,YY)
e = numpy.asarray(edges)
area = numpy.zeros(len(e)-1,dtype=int)
area[:] = [len(A[numpy.logical_and(lo <= A, A < hi)]) for lo,hi in zip(e[:-1],e[1:])]
return area * resolution**2
评论列表
文章目录