Package gavo :: Package votable :: Module simple
[frames] | no frames]

Module simple

source code

A simplified API to single-table VOTables.

The basic idea is: open(...) -> (table, metadata),

where table is a numpy array.

Classes
  TableMetadata
Metadata for a VOTable table instance, i.e., column definitions, groups, etc.
Functions
 
makeDtype(tableMetadata, defaultStringLength=20)
returns an record array datatype for a given table metadata.
source code
 
load(source, raiseOnInvalid=True)
returns (data, metadata) from the first table of a VOTable.
source code
 
loads(stuff, raiseOnInvalid=True)
returns data,metadata for a VOTable literal in stuff.
source code
 
save(data, tableDef, destF)
saves (data, tableDef) in VOTable format to destF.
source code
Variables
  numpyType = {'boolean': <type 'bool'>, 'char': <type 'numpy.st...
  __package__ = 'gavo.votable'
Function Details

makeDtype(tableMetadata, defaultStringLength=20)

source code 

returns an record array datatype for a given table metadata.

defaultStringLength lets you specify a length for char(*) fields; since makeDtype has no access to the tabular data and numpy insists on having string length, DaCHS needs to guess here.

If this isn't fine-grained enough for you, you can always path tableMetadata, replacing * arraysizes with more appropriate values in individual cases.

load(source, raiseOnInvalid=True)

source code 

returns (data, metadata) from the first table of a VOTable.

data is a list of records (as a list), metadata a TableMetadata instance.

source can be a string that is then interpreted as a local file name, or it can be a file-like object.

save(data, tableDef, destF)

source code 

saves (data, tableDef) in VOTable format to destF.

data is a sequence of tuples, tableDef V.TABLE instance as, for example, obtainable from metadata.votTable as returned by load. data must contain type-right python values that match the table definition.

A load-save cycle loses all top-level and resource level metadata in the simplified interface. Use the full interface if that hurts you.


Variables Details

numpyType

Value:
{'boolean': <type 'bool'>,
 'char': <type 'numpy.string_'>,
 'double': <type 'numpy.float64'>,
 'doubleComplex': <type 'numpy.complex128'>,
 'float': <type 'numpy.float32'>,
 'floatComplex': <type 'numpy.complex64'>,
 'int': <type 'numpy.int32'>,
 'long': <type 'numpy.int64'>,
...