[AstroPy] How can I take the index of "True" value and minimum "True" in list with python ?

THƯỜNG Hoàng Đức hoangthuong.hust at gmail.com
Tue Apr 8 09:57:26 EDT 2014


Dear AstroPyer,

I have problem with ideals !
Firstly, I have two array. "ek" (one dimension - value in logspace) and
"gE0[]" (two dimension - value in logspace). After that I scan value ek in
array gE0 to find the equal value, It mean that abs(ek-gE0[:,0]) = 0. Due
to the numerical that in logspace, it can not equal zeros(There are some
point near the 0), and then I put the error for example err < 0.08 >>>>
abs(ek-gE0[:,0]) < 0.08. You can see the value below. The result I would to
take is True but it has several value < 0.08 also true, then how can i take
smallest if have several True.


In [53]: abs(ek-gE0[:,0]) < 0.08
Out[53]: array([False,  True, False, False, False, False,  True,  True,
True,  True], dtype=bool)

ek = 0.1
In [52]: gE0[:,0]
Out[52]:
array([ 0.01      ,  0.04641589,  0.21544347,  1.        ,  1.93593016,
        0.51306049,  0.15479754,  0.06105322,  0.04410808,  0.04849499])

How can i take only the value: i = 1, value = 0.04641589 and i = 9, value =
0.04410808


Thankyou very muck

Merci beaucoup,

Thuong

================================================
THUONG Hoang Duc

Université des Sciences et des Technologies de Hanoi(USTH)
University of Science and Technology of Hanoi(USTH)
Hanoi University of Science and Technology (HUST)

Email: hoangthuong.hust at gmail.com
Tel: +33 06 52 92 00 96
Tel: +84 01692887738
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20140408/6c43768f/attachment.html>


More information about the AstroPy mailing list