astropy/astropy — pull request #511 by taldcroft (2013-01-24 03:22:47+00:00)
Title: io.ascii daophot pprint crashes on row with INDEF

Input file (direct output from daophot)::

#N IMAGE XINIT YINIT ID COORDS LID \
#U imagename pixels pixels ## filename ## \
#F %-23s %-10.3f %-10.3f %-6d %-23s %-6d
#
#N XCENTER YCENTER XSHIFT YSHIFT XERR YERR CIER CERROR \
#U pixels pixels pixels pixels pixels pixels ## cerrors \
#F %-14.3f %-11.3f %-8.3f %-8.3f %-8.3f %-15.3f %-5d %-9s
#
#N MSKY STDEV SSKEW NSKY NSREJ SIER SERROR \
#U counts counts counts npix npix ## serrors \
#F %-18.7g %-15.7g %-15.7g %-7d %-9d %-5d %-9s
#
#N ITIME XAIRMASS IFILTER OTIME \
#U timeunit number name timeunit \
#F %-18.7g %-15.7g %-23s %-23s
#
#N RAPERT SUM AREA FLUX MAG MERR PIER PERROR \
#U scale counts pixels counts mag mag ## perrors \
#F %-12.2f %-14.7g %-11.7g %-14.7g %-7.3f %-6.3f %-5d %-9s
#
n8q624e8q_cal.fits[1] 76.102 2.280 1 test.stars 1 \
76.150 2.182 0.048 -0.098 0.016 0.014 108 BadPixels \
0.5378259 0.1369367 0.1002712 604 176 0 NoError \
1407.892 INDEF F160W INDEF \
4.00 0. 0. 0. INDEF INDEF 301 OffImage
n8q624e8q_cal.fits[1] 81.730 3.167 2 test.stars 2 \
76.150 2.182 -5.580 -0.985 0.016 0.014 108 BadPixels \
0.5378259 0.1369367 0.1002712 604 176 0 NoError \
1407.892 INDEF F160W INDEF \
4.00 0. 0. 0. INDEF INDEF 301 OffImage

Commands using the latest astropy master plus #510 fix:

>>> from astropy.io import ascii
>>> reader = ascii.Daophot()
>>> photfile = reader.read('test.phot')
>>> photfile.pprint(max_lines=1)

Error message::

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 1 photfile.pprint(max_lines=1)

/home/lib/python2.7/site-packages/astropy/table/table.pyc in pprint(self, max_lines, max_width, show_name, show_units)
1054
1055 lines, n_header = _pformat_table(self, max_lines, max_width, show_name,
-> 1056 show_units)
1057 for i, line in enumerate(lines):
1058 if i < n_header:

/home/lib/python2.7/site-packages/astropy/table/pprint.pyc in _pformat_table(table, max_lines, max_width, show_name, show_units, html)
256 for col in table.columns.values():
257 lines, n_header = _pformat_col(col, max_lines, show_name,
--> 258 show_units)
259 cols.append(lines)
260

/home/lib/python2.7/site-packages/astropy/table/pprint.pyc in _pformat_col(col, max_lines, show_name, show_units)
128 """
129 outs = {} # Some values from _pformat_col_iter iterator that are needed here
--> 130 col_strs = list(_pformat_col_iter(col, max_lines, show_name, show_units, outs))
131 col_width = max(len(x) for x in col_strs)
132

/home/lib/python2.7/site-packages/astropy/table/pprint.pyc in _pformat_col_iter(col, max_lines, show_name, show_units, outs)
211 format_func(col.format, col[(i,) + multidim1]))
212 else:
--> 213 col_str = format_func(col.format, col[i])
214 yield col_str
215 elif i == i0:

/home/lib/python2.7/site-packages/astropy/table/pprint.pyc in (format_, val)
96 if out == format_:
97 raise ValueError
---> 98 format_func = lambda format_, val: format_ % val
99 except:
100 raise ValueError('Unable to parse format string {0}'

TypeError: float argument required, not numpy.string_

ERROR: TypeError: float argument required, not numpy.string_ [astropy.table.pprint]

`pprint` works fine when I replaced "INDEF" with "0 " but I really don't want to do that to all my phot output files.