I have tried to make 1 sigma, 2 sigma and 3 sigma contours of my data.
To calculate the levels. I took my 2d array (lets call it data).
I sorted sortData = sort(data.flatten())[::-1]
I normalized it: normSortData = sortData / sum(sortData)
Then I did the cumulative sum: cumSum = np.cumsum(normSortData)
Then I found the id with : idx = cumSum.searchsorted(0.68 this is 1 sigma for 2 sigma its 0.954)
Then I got my level: level = sortData[idx]
I tried this out with a 2d gaussian and that level for 1 sigma was two much. It worked when I gave it 2*level(1 sigma).
I don't know what's going wrong.