<br><br><div class="gmail_quote">On Tue, Sep 21, 2010 at 6:20 PM, Timothy W. Hilton <span dir="ltr"><<a href="mailto:hilton@meteo.psu.edu">hilton@meteo.psu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<br>
<br>
I have an indexing problem which I suspect has a simple solution, but<br>
I've not been able to piece together various threads I've read on this<br>
list to solve.<br>
<br>
I have an 80x1200x1200 nd.array of floats this_par. I have a<br>
1200x1200 boolean array idx, and an 80-element float array pars. For<br>
each element of idx that is True, I wish to replace the corresponding<br>
80x1x1 slice of this_par with the elements of pars.<br>
<br>
I've tried lots of variations on the theme of<br>
>>>this_par[idx[np.newaxis, ...]] = pars[:, np.newaxis, np.newaxis]<br>
but so far, no dice.<br>
<br>
Any help greatly appreciated!<br>
<br>
Thanks,<br>
Tim<br></blockquote><div><br></div><div>This is a tough indexing question for me. I can visualize the arrays and the required selections in my mind, but hard to put them into application as in this case. Beyond 2D array operations indexing and broadcasting operations get somewhat complex to interpret at the first look and likewise later when I read and decipher my own code, not to mention if someone else wants to understand that same code.</div>
<div><br></div><div>What do you do with such big arrays? It is good to see new atmospheric sciences people in the lists. Our department is still swarming with IDL and Matlab users. </div></div><br>-- <br>Gökhan<br>