Table Base Class

This module defines the class for TABLE entries in BDP’s

class admit.util.Table.Table(**keyval)

Defines the basic table structure used in ADMIT

The Table class is a container for holding data in tabluar format. The table can hold data in column-row format and also in plane-column-row format. Data can be added in instantiation, by columns, by rows, or by entire planes.

Parameters:keyval : any valid attributes can be specified to the constructor

Attributes

columns (List containing the column headers, optional) (defaults to an empty list)
units (List containing the units of each column, optional) (defaults to an empty list)
planes (List containing labels for each plane, optional) (defaults to an empty list)
data (A numpy array containing the data, can be 1D, 2D, or 3D, optional) (defaults to an empty array)
desc (A string for a description/caption of the table, optional) (defaults to an empty string)columns : List containing the column headers

Methods

addColumn(data[, col]) Add a column to the table
addPlane(data[, plane]) Add a plane to the table
addRow(row) Add a row to the table
exportTable(fileName[, plane]) Method to export a table to ascii text
getColumn(col) Get a column by its index
getColumnByName(name) Get a column by its name
getHeader()
getPlane(pln)
getRow(row)
histogram(x[, title, figname, xlab, hrange, ...]) simple histogram of one or more columns
isequal(table) Determine if two Tables are identical
plotter(x, y[, title, figname, xlab, ylab]) simple plotter of multiple columns against one column
setData(data) Set the data of the table all at once
setkey([name, value]) set keys, two styles are possible:
write(root, name) Method to write an xml entry for a Admit_table Any modifications to this method could break the I/O system.
addColumn(data, col='')

Add a column to the table

Adds the given column to the table and recomputes the minimum and maximum. The column must have the same length as the other columns or numpy will throw an exception.

Parameters:

data : list or numpy array

The data of the column to be added

col : str, optional

The name of the column

Returns:

None

addPlane(data, plane='')

Add a plane to the table

Adds the given plane to the table and recomputes the minimum and maximum. The plane must have the same dimmensions as the other planes or numpy will throw an exception.

Parameters:

data : list or numpy array

The data of the plane to be added

plane : str, optional

The name of the plane

Returns:

None

addRow(row)

Add a row to the table

Adds the given row to the table and recomputes the minimum and maximum.

Parameters:

row : list or numpy array

The data of the row to be added

Returns:

None

exportTable(fileName, plane=0)

Method to export a table to ascii text

Parameters:

fileName : str

The name of the file to write the table to

plane : int, optional

What plane to export, defaults to the first plane (0). Note that multiple planes cannot be written out to ascii at this time

Returns:

None

getColumn(col)

Get a column by its index

Parameters:

name : int

The index of the column to retrieve

Returns:

The data from the column as a numpy array, or None if the column index

does not exist.

getColumnByName(name)

Get a column by its name

Parameters:

name : str

The name of the column to retrieve

Returns:

The data from the column as a numpy array, or None if the column name

does not exist.

getHeader()
getPlane(pln)
getRow(row)
histogram(x, title=None, figname=None, xlab=None, hrange=None, bins=80)

simple histogram of one or more columns

isequal(table)

Determine if two Tables are identical

Parameters:

table : Table

The Table to compare to this one.

Returns:

Boolean

Whether or not the two Tables are identical

Notes

This is a useful method for testing but not intended for production. Experimental.

plotter(x, y, title=None, figname=None, xlab=None, ylab=None)

simple plotter of multiple columns against one column

setData(data)

Set the data of the table all at once

Parameters:

data : list or numpy array

The actual data to insert into the table

Returns:

None

setkey(name='', value='')

set keys, two styles are possible:

  1. name = {key:val} e.g. setkey({“a”:1})
  2. name = “key”, value = val e.g. setkey(“a”,1)

This method checks the type of the keyword value, as it must remain the same. Also new keywords cannot be added.

Parameters:

name : dictionary or string

Dictionary of keyword value pais to set or a string with the name of a single key

value : any

The value to change the keyword to

Returns:

None

write(root, name)

Method to write an xml entry for a Admit_table Any modifications to this method could break the I/O system. Please test thoroughly before checking in the changes.

Parameters:

root : A reference to the parent ElementTree

name : str

The name of the node to be written

Returns:

A reference to the SubElement that was created and populated

This Page