def _convert_ascii_format(format, reverse=False):
 if reverse:
  (recformat, kind, dtype) = _dtype_to_recformat(format)
  itemsize = dtype.itemsize
  if (kind == 'a'):
   return ('A' + str(itemsize))
  elif (NUMPY2FITS.get(recformat) == 'L'):
   return 'A1'
  elif (kind == 'i'):
   width = (1 + len(str((2 ** (itemsize * 8)))))
   width = max(width, ASCII_DEFAULT_WIDTHS['I'][0])
   return ('I' + str(width))
  elif (kind == 'f'):
   if (itemsize >= 8):
    format = 'D'
   else:
    format = 'E'
   width = '.'.join((str(w) for w in ASCII_DEFAULT_WIDTHS[format]))
   return (format + width)
 else:
  (format, width, precision) = _parse_ascii_tformat(format)
  recformat = ASCII2NUMPY[format]
  if ((format == 'I') and (width <= 4)):
   recformat = 'i2'
  elif (format == 'A'):
   recformat += str(width)
  return recformat

def _convert_ascii_format ( format , reverse = False ) : if reverse : ( recformat , kind , dtype ) = _dtype_to_recformat ( format ) itemsize = dtype . itemsize if ( kind == 'a' ) : return ( 'A' + str ( itemsize ) ) elif ( NUMPY2FITS . get ( recformat ) == 'L' ) : return 'A1' elif ( kind == 'i' ) : width = ( 1 + len ( str ( ( 2 ** ( itemsize * 8 ) ) ) ) ) width = max ( width , ASCII_DEFAULT_WIDTHS [ 'I' ] [ 0 ] ) return ( 'I' + str ( width ) ) elif ( kind == 'f' ) : if ( itemsize >= 8 ) : format = 'D' else : format = 'E' width = '.' . join ( ( str ( w ) for w in ASCII_DEFAULT_WIDTHS [ format ] ) ) return ( format + width ) else : ( format , width , precision ) = _parse_ascii_tformat ( format ) recformat = ASCII2NUMPY [ format ] if ( ( format == 'I' ) and ( width <= 4 ) ) : recformat = 'i2' elif ( format == 'A' ) : recformat += str ( width ) return recformat
convert ascii table format spec to record format spec .