Get the index of the max value using argmax in numpy array
<ol>
<li><p>I have allocated about 34G of memory and read the data in: sst = np.empty([365,3600,7200], dtype-np.float32)</p></li>
<li><p>using the argmax(sst,axis=0) to get the index of the max value for each pixel. </p></li>
<li><p>the memory error problem appeared when running the program.</p></li>
</ol>

<p>Can anyone help me with this? Are there any other ways to get the index of the max value for each pixel [365,3600,7200]? Thank you!</p>

<p><a href="https://github.com/numpy/numpy/blob/v1.11.0/numpy/core/fromnumeric.py#L917-L974" rel="nofollow">This source code</a> shows that argMax returns an array populated by the max on that axis. Instead of doing this, you could say allocate a new array for each axis, and do np.argMax on that array. If you make sure to overwrite the old array after getting the index of that max value you should have less memory issues. </p>

<p>If you're doing a lot of stuff dealing with out-of-memory problems, it may be worth looking into <a href="http://dask.pydata.org/en/latest/array.html" rel="nofollow">dask</a>.</p>

python numpy