Exemplo n.º 1
0
def createTimeSeriesTable(self, where, name, series, title="",
                          filters=None, expectedrows=10000,
                          chunkshape=None, byteorder=None,
                          createparents=False):
    """
    Creates a :class:`TimeSeriesTable` from
    a :class:`~scikits.timeseries.TimeSeries` object.

    Parameters
    ----------
    where : Group
        Location of the table.
    name : string
        Name of the table.
    series : TimeSeries
        Series to store
    """
    parentNode = self._getOrCreatePath(where, createparents)
    _checkfilters(filters)
    return TimeSeriesTable(parentNode, name, series, title=title,
                           filters=filters, expectedrows=expectedrows,
                           chunkshape=chunkshape, byteorder=byteorder)
Exemplo n.º 2
0
def createMaskedTable(self, where, name, maskedarray, title="",
                      filters=None, expectedrows=10000,
                      chunkshape=None, byteorder=None,
                      createparents=False):
    """
    Creates a :class:`MaskedTable` from a masked array.

    Parameters
    ----------
    where : Group
        Location of the table.
    name : string
        Name of the table.
    maskedarray : MaskedArray
        Masked array to store
    title : {'', string}, optional
        Title of the table
    """
    parentNode = self._getOrCreatePath(where, createparents)
    _checkfilters(filters)
    return MaskedTable(parentNode, name, maskedarray,
                       title=title, filters=filters, 
                       expectedrows=expectedrows,
                       chunkshape=chunkshape, byteorder=byteorder)
Exemplo n.º 3
0
    def createTable(self,
                    where=None,
                    tableName=None,
                    description=None,
                    rowDefinition=None,
                    title="",
                    filters=None,
                    expectedrows=50000,
                    chunkshape=None,
                    byteorder=None,
                    createparents=False):
        """
		2012.12.20 overwrite the parent (stock) function
		
		Create a new table with the given name in where location.

		Parameters
		----------
		where : str or Group
			The parent group from which the new table will hang. It can be a
			path string (for example '/level1/leaf5'), or a Group instance
			(see :ref:`GroupClassDescr`).
		name : str
			The name of the new table.
		description : Description
			This is an object that describes the table, i.e. how
			many columns it has, their names, types, shapes, etc.  It
			can be any of the following:

				* *A user-defined class*: This should inherit from the
				  IsDescription class (see :ref:`IsDescriptionClassDescr`) where
				  table fields are specified.
				* *A dictionary*: For example, when you do not know beforehand
				  which structure your table will have).
				* *A Description instance*: You can use the description
				  attribute of another table to create a new one with the same
				  structure.
				* *A NumPy dtype*: A completely general structured NumPy dtype.
				* *A NumPy (structured) array instance*: The dtype of this
				  structured array will be used as the description.  Also, in
				  case the array has actual data, it will be injected into the
				  newly created table.
				* *A RecArray instance (deprecated)*: Object from the numarray
				  package.  This does not give you the possibility to create a
				  nested table.  Array data is injected into the new table.
				* *A NestedRecArray instance (deprecated)*: If you want to have
				  nested columns in your table and you are using numarray, you
				  can use this object. Array data is injected into the new
				  table.

		title : str
			A description for this node (it sets the TITLE HDF5 attribute
			on disk).
		filters : Filters
			An instance of the Filters class (see :ref:`FiltersClassDescr`) that
			provides information about the desired I/O filters to be applied
			during the life of this object.
		expectedrows : int
			A user estimate of the number of records that will be in the table.
			If not provided, the default value is EXPECTED_ROWS_TABLE (see
			:file:`tables/parameters.py`). If you plan to create a bigger table
			try providing a guess; this will optimize the HDF5 B-Tree creation
			and management process time and memory used.
		chunkshape
			The shape of the data chunk to be read or written in a single HDF5
			I/O operation. Filters are applied to those chunks of data. The rank
			of the chunkshape for tables must be 1. If None, a sensible value
			is calculated based on the expectedrows parameter (which is
			recommended).
		byteorder : str
			The byteorder of data *on disk*, specified as 'little' or 'big'.
			If this is not specified, the byteorder is that of the platform,
			unless you passed an array as the description, in which case
			its byteorder will be used.
		createparents : bool
			Whether to create the needed groups for the parent path to exist
			(not done by default).

		See Also
		--------
		Table : for more information on tables

		"""
        if rowDefinition is None:
            rowDefinition = self.rowDefinition
        if description is None:  #2012.12.20 rowDefinition is backup of description
            description = rowDefinition
        parentNode = self._getOrCreatePath(where, createparents)
        _checkfilters(filters)
        tableObject = YHTable(parentNode=parentNode,
                              tableName=tableName,
                              description=description,
                              title=title,
                              filters=filters,
                              expectedrows=expectedrows,
                              chunkshape=chunkshape,
                              byteorder=byteorder)
        if tableObject._v_pathname not in self.tablePath2Index:
            self._appendNewTable(tableObject)
        else:
            sys.stderr.write(
                "Error: table path name %s already in this PyTables file.\n" %
                (tableObject._v_pathname))
            sys.exit(3)
        return tableObject