def numpy_to_votable_dtype(dtype, shape):
 if (dtype.num not in numpy_dtype_to_field_mapping):
  raise TypeError(u'{0!r} can not be represented in VOTable'.format(dtype))
 if (dtype.char == u'S'):
  return {u'datatype': u'char', u'arraysize': str(dtype.itemsize)}
 elif (dtype.char == u'U'):
  return {u'datatype': u'unicodeChar', u'arraysize': str((dtype.itemsize // 4))}
 else:
  result = {u'datatype': numpy_dtype_to_field_mapping[dtype.num]}
  if len(shape):
   result[u'arraysize'] = u'x'.join((str(x) for x in shape))
  return result

def numpy_to_votable_dtype ( dtype , shape ) : if ( dtype . num not in numpy_dtype_to_field_mapping ) : raise TypeError ( u'{0!r} can not be represented in VOTable' . format ( dtype ) ) if ( dtype . char == u'S' ) : return { u'datatype' : u'char' , u'arraysize' : str ( dtype . itemsize ) } elif ( dtype . char == u'U' ) : return { u'datatype' : u'unicodeChar' , u'arraysize' : str ( ( dtype . itemsize // 4 ) ) } else : result = { u'datatype' : numpy_dtype_to_field_mapping [ dtype . num ] } if len ( shape ) : result [ u'arraysize' ] = u'x' . join ( ( str ( x ) for x in shape ) ) return result
converts a numpy dtype and shape to a dictionary of attributes for a votable field element and correspond to that type .