示例#1
0
def makearrcoldesc (columnname, value, ndim=0,
                    shape=[], datamanagertype='',
                    datamanagergroup='', 
                    options=0, maxlen=0, comment='',
                    valuetype='', keywords={}):
    """Create description of an array column.

    A description for a scalar column can be created from a name for
    the column and a data value, which is used only to determine the
    type of the column. Note that a dict value is also possible.

    It is possible to create the column description in more detail
    by giving the dimensionality, shape, data manager name, group, option,
    and comment as well.

    The data manager type tells which data manager (storage manager)
    is used to store the columns. The data manager type and group are
    explained in more detail in the `casacore Tables
    <../../casacore/doc/html/group__Tables__module.html>`_ documentation.

    It returns a dict with fields `name` and `desc` which can thereafter be used
    to build a table description using function :func:`maketabdesc`.

    `name`
      The name of the column.
    `value`
      A data value, which is only used to determine the data type of the column.
      It is only used if argument `valuetype` is not given.
    `ndim`
      Optionally the number of dimensions. A value > 0 means that all
      arrays in the column must have that dimensionality. Note that the
      arrays can still differ in shape unless the shape vector is also given.
    `shape`
      An optional sequence of integers giving the shape of the array in each
      cell. If given, it forces option FixedShape (see below) and sets the
      number of dimensions (if not given). All arrays in the column get the
      given shape and the array is created as soon as a row is added.
      Note that the shape vector gives the shape in each table cell; the
      number of rows in the table should NOT be part of it.
    `datamanagertype`
      Type of data manager which can be one of StandardStMan (default),
      IncrementalStMan, TiledColumnStMan, TiledCellStMan, or TiledShapeStMan.
      The tiled storage managers are usually used for bigger data arrays.
    `datamanagergroup`
      Data manager group. Only for the expert user.
    `options`
      Optionally numeric array options which can be added to combine them.

      `1` means Direct.
          It tells that the data are directly stored in the table. Direct
          forces option FixedShape. If not given, the array is indirect, which
          means that the data will be stored in a separate file.  
      `4` means FixedShape.
          This option does not need to be given, because it is enforced if
          the shape is given. FixedShape means that the shape of the array must
          be the same in each cell of the column. Otherwise the array shapes may
          be different in each column cell and is it possible that a cell does
          not contain an array at all.
          Note that when given (or implicitly by option Direct), the
          shape argument must be given as well.

      Default is 0, thus indirect and variable shaped.
    `maxlen`
      Maximum length of string values in a column.
      Default 0 means unlimited.
    `comment`
      Comment: informational for user.
    `valuetype`
      A string giving the column's data type. Possible data types are
      bool (or boolean), uchar (or byte), short, int (or integer), uint,
      float, double, complex, dcomplex, and string.
    'keywords'
      A dict defining initial keywords for the column.

    For example::

      acd1= makescacoldesc("arr1", 1., 0, [2,3,4])
      td = maketabdesc(acd1)

    This creates a table description consisting of an array column `arr1`
    containing 3-dim arrays of doubles with shape [2,3,4].

    """
    vtype = valuetype
    if vtype == '':
        vtype = _value_type_name(value)
    if len(shape) > 0:
        if ndim <= 0:
            ndim = len(shape)
    rec2 = {'valueType' : vtype,
            'dataManagerType' : datamanagertype,
            'dataManagerGroup' : datamanagergroup,
            'ndim' : ndim,
            'shape' : shape,
            '_c_order' : True,
            'option' : options,
            'maxlen' : maxlen,
            'comment' : comment,
            'keywords' : keywords}
    return {'name' : columnname,
            'desc' : rec2}
示例#2
0
def makescacoldesc (columnname, value,
                    datamanagertype='', 
                    datamanagergroup='',
                    options=0, maxlen=0, comment='',
                    valuetype='', keywords={}):
    """Create description of a scalar column.

    A description for a scalar column can be created from a name for
    the column and a data value, which is used only to determine the
    type of the column. Note that a dict value is also possible.

    It is possible to create the column description in more detail
    by giving the data manager name, group, option, and comment as well.

    The data manager type tells which data manager (storage manager)
    is used to store the columns. The data manager type and group are
    explained in more detail in the `casacore Tables
    <../../casacore/doc/html/group__Tables__module.html>`_ documentation.

    It returns a dict with fields `name` and `desc` which can thereafter be used
    to build a table description using function :func:`maketabdesc`.

    `columname`
      Name of column
    `value`
      Example data value used to determine the column's data type.
      It is only used if argument `valuetype` is not given.
    `datamanagertype`
      Type of data manager which can be one of StandardStMan (default)
      or IncrementalStMan. The latter one can save disk space if many subsequent
      cells in the column will have the same value.
    `datamanagergroup`
      Data manager group. Only for the expert user.
    `options`
      Options. Need not be filled in.
    `maxlen`
      Maximum length of string values in a column.
      Default 0 means unlimited.
    `comment`
      Comment: informational for user.
    `valuetype`
      A string giving the column's data type. Possible data types are
      bool (or boolean), uchar (or byte), short, int (or integer), uint,
      float, double, complex, dcomplex, and string.
    'keywords'
      A dict defining initial keywords for the column.

    For example::

      scd1 = makescacoldesc("col2", ""))
      scd2 = makescacoldesc("col1", 1, "IncrementalStMan")
      td = maketabdesc([scd1, scd2])

    This creates a table description consisting of an integer column `col1`,
    and a string column `col2`. `col1` uses the IncrementalStMan storage manager,
    while `col2` uses the default storage manager StandardStMan.

    """
    vtype = valuetype
    if vtype == '':
        vtype = _value_type_name(value)
    rec2 = {'valueType' : vtype,
            'dataManagerType' : datamanagertype,
            'dataManagerGroup' : datamanagergroup,
            'option' : options,
            'maxlen' : maxlen,
            'comment' : comment,
            'keywords' : keywords}
    return {'name' : columnname,
            'desc' : rec2}