Print out array items greater than a specific Value in Python
Question: I am trying to print out values greater than 100000 on an array MSLP But I
keep on getting this error :The truth value of an array with more than one
element is ambiguous. Use a.any() or a.all()

Here is my code:

    
    
    import numpy as np
    import netCDF4
    from numpy import *
    from netCDF4 import Dataset
    
    ncfile= Dataset('test.nc','r')
    lat  =ncfile.variables['lat'][:]
    lon  =ncfile.variables['lon'][:]
    time =ncfile.variables['time'][:] 
    MSLP =ncfile.variables['PSL'][:]
    
    for item in MSLP:
     if item>100000:
     print item
    


Answer: The error gives the answer:

> The truth value of an array with more than one element is ambiguous

When you do `if item>100000:`, `item` is an array of truth values--not a
single element.

If you want the values, you can use
[`numpy.where`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html):

    
    
    MSLP[numpy.where(MSLP > 100000)]
    

Remember: prefer the numpy functions over iterating through arrays whenever
possible.

