Condtionally selecting values from a Numpy array returned from PyFITS
The expression data.field[('zquality' > 2) & ('pgal'==3)] is asking for fields where the string 'zquality' is greater than 2 (always true) and where the string 'pgal' is equal to 3 (also always false).
Actually chances are you're getting an exception because data.field is a method on the Numpy recarray objects that PyFITS returns tables in.
You want something like data[(data['zquality'] > 2) & (data['pgal'] == 3)].
This expression means "give me the rows of the 'zquality' column of data containing values greater than 2.  Then give me the rows of the 'pgal' column of data with values equal to three.  Now give me the full rows of data selected from the logical 'and' of the two row masks.
I have opened a FITS file in pyfits. The HEADER file reads XTENSION='BINTABLE' with DIMENSION= 52989R x 36C with 36 column tags like, 'ZBEST', 'ZQUALITY', 'M_B', 'UB', 'PGAL' etc.
Now, I have to choose objects from the data with 'ZQUALITY' greater than 2 & 'PGAL' equals to 3. Then I have to make a histogram for the 'ZBEST' of the corresponding objects obeying the above conditions. Also I have to plot 'M_B' vs 'UB' for those objects. 
At last I want to slice the 'ZBEST' into three slices (zbest < 0.5), (0.5 < zbest < 1.0), (zbest > 1.0) and want to plot histogram and 'M_B' vs 'UB' diagram of them separately. 
I am stuck at choosing the data obeying the two conditions. Can anyone please tell me how can I choose the objects from the data satisfying both the conditions ('ZQUALITY' > 2 & 'PGAL' == 3 )? I am using like: data.field[('zquality' > 2) & ('pgal'==3)] but it's not working.