<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks!. very useful. although doesn't really work with padded array (as in the case of real_map object). but found my way round.<div><br></div><div>best</div><div>mona<br><div><div>On Oct 18, 2011, at 11:17 AM, Ralf Grosse-Kunstleve wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Mona,<div><br></div><div>Try this:</div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">from scitbx.array_family import flex</font></div><div><font class="Apple-style-span" face="'courier new', monospace">a=flex.double([1,4,5,7,5,6,6,1])</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">a.set_selected(a &gt; 5, 5)</font></div><div><font class="Apple-style-span" face="'courier new', monospace">print list(a)</font></div><div>
<br></div><div>Or in smaller steps:</div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">bool_selection = a &gt; 5</font></div><div><font class="Apple-style-span" face="'courier new', monospace">assert bool_selection.size() == a.size()</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">print list(bool_selection)</font></div><div><font class="Apple-style-span" face="'courier new', monospace">a.set_selected(bool_selection, 5)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">print list(a)</font></div></div><div><br></div><div>You can also call <font class="Apple-style-span" face="'courier new', monospace">a.set_selected(bool_selection, b)</font></div>
<div>where <font class="Apple-style-span" face="'courier new', monospace">b</font> is an array with as many elements as you have <font class="Apple-style-span" face="'courier new', monospace">True</font> in the <font class="Apple-style-span" face="'courier new', monospace">bool_selection</font>.</div>
<div><br></div><div>This kind of working with selections is very typical within cctbx/phenix.</div><div>If you look through our sources you'll find a lot of examples; in passing, we have two types of selections, bool selections as above, and integer selections. The latter are useful for permutations, e.g. to sort array elements, or if you know you select only a small number of elements from a large array. Let me know if you have more questions about selections and I'll be happy to explain.&nbsp;(I guess one day I should write a "Working with selections" tutorial.)</div>
<div><br></div><div>Ralf</div><div><br></div><div class="gmail_quote">On Tue, Oct 18, 2011 at 2:54 AM, Monarin Uervirojnangkoorn <span dir="ltr">&lt;<a href="mailto:monarin@biochem.uni-luebeck.de">monarin@biochem.uni-luebeck.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word">Hi,<div><br></div><div>I'm using flex and 'd like to get an access to elements fall beyond/ below certain value. eg.</div>
<div>a=[1,4,5,7,5,6,6,1]</div><div>anything beyond 5 should be set to 5. (in matlab then a(a&gt;5)=5;)</div><div>if you could tell me how to do this quickly for flex, that would be great. for now i use loop and that is... pretty slow.</div>
<div><br></div><div>many thanks.</div><div>mona</div><div><br></div><div><br></div><div><br><div>
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><div style="word-wrap:break-word">
<div>^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^</div><div>Institute of Biochemistry,<br>Institut f�r Neuro- und Bioinformatik,<br>Graduate School for Computing in Medicine and Life Sciences<br>University of L�beck,<br>
Ratzeburger Allee 160<br>L�beck 23538<br>Germany<br>Tel: <a href="tel:%2B49451-5004072" value="+494515004072" target="_blank">+49451-5004072</a><br>Fax: <a href="tel:%2B49451-5004068" value="+494515004068" target="_blank">+49451-5004068</a></div>
<div><br></div></div></span><br></span><br>
</div>
<br></div></div><br>_______________________________________________<br>
cctbxbb mailing list<br>
<a href="mailto:cctbxbb@phenix-online.org">cctbxbb@phenix-online.org</a><br>
<a href="http://phenix-online.org/mailman/listinfo/cctbxbb" target="_blank">http://phenix-online.org/mailman/listinfo/cctbxbb</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>cctbxbb mailing list<br><a href="mailto:cctbxbb@phenix-online.org">cctbxbb@phenix-online.org</a><br>http://phenix-online.org/mailman/listinfo/cctbxbb<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^</div><div>Institute of Biochemistry,<br>Institut f�r Neuro- und Bioinformatik,<br>Graduate School for Computing in Medicine and Life Sciences<br>University of L�beck,<br>Ratzeburger Allee 160<br>L�beck 23538<br>Germany<br>Tel: +49451-5004072<br>Fax: +49451-5004068</div><div><br></div></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>