I am trying to plot 2D surface plots in 3d using mplot3d module.
I know how to "manually" find the max value and its position (in terms of row and column), which is very important in what I am doing. Is there a way to plot that information onto the peak ? That is, writing (maxval,row,col) next to the peak ?
P.S. while I am asking this. Maybe there is an easy way to identify the second peak (or any other peaks for that matter?). I am currently using a mask, to mask out the first peak and to find the second, but I have to be very careful in choosing the sides, because if I happen to mask too little, some of the non-peak stuff will be identified as a peak, and the real second peak will not be identified, messing up a measurement called "peak to peak" signal to noise ratio.
The code I am currently using is :
frame_a = gdal.Open( "frame_{0:05d}.tif".format(274) ).ReadAsArray()
# in case this helps, this is how the images are read, they are 16-bit GS tiffs.
frame_b = gdal.Open( "frame_{0:05d}.tif".format(287) ).ReadAsArray()
#this does some clever stuff but basically it returns a 2-D 32x32 array.
corr = correlate_windows( windows_a[99], windows_b[99], corr_method = corr_method, nfftx=nfftx, nffty=nffty )
#this is how I find the position of max value.
column = np.argmax(np.max(corr, axis=0))
row = np.argmax(np.max(corr, axis=1))
maximum = corr.max()
print 'column = ' + str(column)
print 'row = ' +str(row)
print 'peak_1 = ' + str(maximum)
import matplotlib.cm as cmps
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import LinearLocator, FormatStrFormatter
fig = pl.figure()
ax = Axes3D(fig)
# window size is 32 in this case
nx, ny = window_size*2, window_size*2
xx = range(nx)
yy = range(ny)
X, Y = np.meshgrid(xx, yy)
ax.plot_surface(X , Y , corr , rstride = 1, cstride = 1 )
pl.show()