PyNGL Home > Functions > Array query

Ngl.ind

Gets the indices of a Python list where the list values are true.

Prototype

tindex = Ngl.ind(plist)

Arguments

plist

A Python list, tuple, or one-dimensional NumPy array.

Return value

tindex

A list of integer indices where plist is True, that is, non-zero.

Description

This function takes a Python list, tuple, or one-dimensional NumPy array as its only argument and returns a list of indices where the values in the input are true.

Examples

The following script:

import Ngl
plist = [False, True, True, False, False, True]
tlist = Ngl.ind(plist)
print tlist
Ngl.end()
produces:
[1, 2, 5]