def find_z(s, s_axis, x_range = [0,0], y_range = [0, -1]): # determine the range to be plotted x_min, x_max, y_min, y_max = P.find_axes(s_axis[2], s_axis[0], x_range, y_range) # make the contours # first find the area to be plotted # not the most elegant way I guess try: y_min_i = numpy.where(s_axis[0] < y_min)[0][-1] except: y_min_i = 0 try: y_max_i = numpy.where(s_axis[0] > y_max)[0][0] except: y_max_i = len(s_axis[0]) try: x_min_i = numpy.where(s_axis[2] < x_min)[0][-1] except: x_min_i = 0 try: x_max_i = numpy.where(s_axis[2] > x_max)[0][0] except: x_max_i = len(s_axis[2]) ma = numpy.amax(s[y_min_i:y_max_i, x_min_i:x_max_i]) mi = numpy.amin(s[y_min_i:y_max_i, x_min_i:x_max_i]) return ma, mi