Table

class Table(name, libmadx, *, columns='all', rows='all', _check=True)[source]

Bases: _Mapping

MAD-X twiss table.

Loads individual columns from the MAD-X process lazily only on demand.

Attributes Summary

range

Get the element names (first, last) of the valid range.

summary

Get the table summary.

Methods Summary

col_names([columns])

Get list of all columns in the table.

column(column[, rows])

Retrieve all specified rows in the given column of the table.

copy([columns, rows])

Return a frozen table with the desired columns.

dframe([columns, rows, index])

Return table as pandas.DataFrame.

get(k[,d])

getmat(name, idx, *dim)

items()

keys()

kvec(idx[, dim])

Kicks.

reload(column)

Reload (recache) one column from MAD-X.

rmat(idx[, dim])

Sectormap.

row(index[, columns])

Retrieve one row from the table.

row_names([rows])

Get table row names.

selected_columns()

Get list of column names that were selected by the user (can be empty).

selected_rows()

Get list of row indices that were selected by the user (can be empty).

selection([columns, rows])

Return a Table object that only retrieves the specified rows and columns by default.

sigmat(idx[, dim])

Beam matrix.

tmat(idx[, dim])

2nd order sectormap.

values()

Attributes Documentation

range

Get the element names (first, last) of the valid range.

summary

Get the table summary.

Methods Documentation

col_names(columns=None)[source]

Get list of all columns in the table.

column(column, rows=None)[source]

Retrieve all specified rows in the given column of the table.

Parameters:
  • column (str) – column name

  • rows – a list of row indices or 'all' or 'selected'

Return type:

ndarray

copy(columns=None, rows=None)[source]

Return a frozen table with the desired columns.

Parameters:

columns (list) – column names or None for all columns.

Return type:

dict

Returns:

column data

Raises:

ValueError – if the table name is invalid

dframe(columns=None, rows=None, *, index=None)[source]

Return table as pandas.DataFrame.

Parameters:
  • columns – column names or ‘all’ or ‘selected’

  • rows – row indices or ‘all’ or ‘selected’

  • index (str) – column name or sequence to be used as index, or None for using the row_names

Returns:

column data as pandas.DataFrame

Raises:

ValueError – if the table name is invalid

WARNING: using index=None is unsafe after calling USE. In this case, please manually specify another column to be used, e.g. index="name".

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
getmat(name, idx, *dim)[source]
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
kvec(idx, dim=6)[source]

Kicks.

reload(column)[source]

Reload (recache) one column from MAD-X.

rmat(idx, dim=6)[source]

Sectormap.

row(index, columns=None)[source]

Retrieve one row from the table.

row_names(rows=None)[source]

Get table row names.

WARNING: using row_names after calling USE (before recomputing the table) is unsafe and may lead to segmentation faults or incorrect results.

selected_columns()[source]

Get list of column names that were selected by the user (can be empty).

selected_rows()[source]

Get list of row indices that were selected by the user (can be empty).

selection(columns='selected', rows=None)[source]

Return a Table object that only retrieves the specified rows and columns by default.

Parameters:
  • columns – list of names or ‘all’ or ‘selected’

  • rows – list of indices or ‘all’ or ‘selected’

Return type:

Table

If only columns is given, rows defaults to ‘selected’ unless columns is set to ‘all’ in which case it also defaults to ‘all’.

sigmat(idx, dim=6)[source]

Beam matrix.

tmat(idx, dim=6)[source]

2nd order sectormap.

values() an object providing a view on D's values