-1

I am on PyCharm (community edition 4.0.2) retrieving data from a .fits file. z = data.field [SDSS_Z] results in TypeError: 'instancemethod' object has no attribute 'getitem'. On other Field of the same .fits file I have no problems

import pyfits
import pylab as plt
import numpy as np
plt.close('all')
hdu = pyfits.open('cat.v9.group_v22.fits')

print hdu[1].columns

data = hdu[1].data

u = data.field('U')
r = data.field('R')
k = data.field('LOG_MSTELLAR_KS')
morph = data["GZ1_MORPHOLOGY"]              
lum = data["L_O3"]                          
z = data.field ["SDSS_Z"]
yole
  • 92,896
  • 20
  • 260
  • 197
rbaer
  • 11
  • 1
  • 3
  • 1
    As Arnaud P noted you just have a syntax error in the last line. Note you can also just do `data['SDSS_Z']` which is equivalent to `data.field('SDSS_Z')`. I see that in your code you are using both conventions. Best to to just stick with one, but for stylistic purity and to prevent confusion like this in the future. – Iguananaut Jan 09 '15 at 22:13

1 Answers1

2

Looking at the lines you say work ('U', 'R', etc..), it seems you simply went astray with the syntax on the last one. Just keep to what you've been doing:

z = data.field("SDSS_Z")

And it should roll fine.

Arnaud P
  • 12,022
  • 7
  • 56
  • 67