nbodykit.io.stack

Classes

FileStack(filetype, path, *args, **kwargs) A file object that offers a continuous view of a stack of subclasses of FileType instances.
class nbodykit.io.stack.FileStack(filetype, path, *args, **kwargs)[source]

A file object that offers a continuous view of a stack of subclasses of FileType instances.

This allows data to be accessed across multiple files from a single file object. The “stack” is a concatenation of one file to the end of the previous file.

Parameters:
  • filetype (subclass of FileType) – the type of file class to initialize
  • path (str) – list of file names, or string specifying single file or containing a glob-like ‘*’ pattern
  • *args – additional arguments to pass to the filetype instance during initialization
  • **kwargs – additional keyword arguments passed to the filetype instance during initialization

Attributes

attrs Dictionary of meta-data for the stack
columns A list of the names of the columns in the file.
dtype A numpy.dtype object holding the data types of each column in the file.
ncol The number of data columns in the file.
nfiles The number of files in the FileStack
shape The shape of the file, which defaults to (size, )
size The size of the file, i.e., number of rows

Methods

asarray() Return a view of the file, where the fields of the
get_dask(column[, blocksize]) Return the specified column as a dask array, which
keys() Aliased function to return columns
read(columns, start, stop[, step]) Read the specified column(s) over the given range,
attrs

Dictionary of meta-data for the stack

nfiles

The number of files in the FileStack

read(columns, start, stop, step=1)[source]

Read the specified column(s) over the given range, returning a structured numpy array

Parameters:
  • columns (str, list of str) – the name of the column(s) to return
  • start (int) – the row integer to start reading at
  • stop (int) – the row integer to stop reading at
  • step (int, optional) – the step size to use when reading; default is 1
Returns:

data – a numpy structured array holding the requested data

Return type:

array_like