cpymad.libmadx

Low level cython binding to MAD-X.

CAUTION: End users should usually not import this module directly! Use cpymad.madx.Madx instead.

  • The API of this module is considered private, i.e. it may change between versions without further notice.

  • Importing this module means loading MAD-X directly into the process space. This means that any crash in the (sometimes fragile) MAD-X interpreter will crash the importing process with it.

  • All functions in this module operate on a shared global state.

  • this module exposes a very C-ish API that is not convenient to work with.

Functions

get_version_number()

Get the version number of loaded MAD-X interpreter.

get_version_date()

Get the release date of loaded MAD-X interpreter.

is_started()

Check whether MAD-X has been initialized.

start()

Initialize MAD-X.

finish()

Cleanup MAD-X.

input(cmd)

Pass one input command to MAD-X.

eval(expression)

Evaluates an expression and returns the result as double.

get_var(name)

Get the value of a global variable.

num_globals()

Return the number of global variables.

get_globals()

Get a list of names of all global variables.

get_var_type(name)

Get the type of the variable: :rtype: int

get_options()

Get the current option values.

get_current_beam()

Get properties of current default beam.

sequence_exists(sequence_name)

Check if the sequence exists.

get_sequence_names()

Get a list of all sequences currently in memory.

get_sequence_count()

Get the number of all sequences currently in memory.

get_active_sequence_name()

Get the name of the active sequence.

get_sequence_twiss_table_name(sequence_name)

Get the last calculated twiss table for the given sequence.

get_sequence_beam(sequence_name)

Get the beam associated to the sequence.

is_sequence_expanded(sequence_name)

Check whether a sequence has already been expanded.

table_exists(table_name)

Check if the table exists.

get_table_names()

Return list of all table names.

get_table_count()

Return number of existing tables.

get_table_summary(table_name)

Get table summary.

get_table_column_names(table_name[, selected])

Get a list of all column names in the table.

get_table_column_count(table_name[, selected])

Get a number of columns in the table.

get_table_column(table_name, column_name[, rows])

Get data from the specified table.

get_table_row(table_name, row_index[, columns])

Return row as tuple of values.

get_table_row_count(table_name)

Return total number of rows in the table.

get_table_row_names(table_name[, indices])

Return row names for every index (row number) in the list.

get_table_selected_rows(table_name)

Return list of selected row indices in table (may be empty).

get_table_selected_rows_mask(table_name)

Return boolean mask of which rows are selected in a table.

apply_table_selections(table_name)

Apply the SELECT/DESELECT commands for table columns/rows.

get_element(sequence_name, element_index)

Return requested element in the original sequence.

get_element_name(sequence_name, element_index)

Get list with the names of all elements of a specific sequence.

get_element_positions(sequence_name)

Get list with positions of all elements of a specific sequence.

get_element_names(sequence_name)

Get list with the names of all elements of a specific sequence.

get_element_index(sequence_name, element_name)

Return index of element with specified name in the original sequence.

get_element_index_by_position(sequence_name, ...)

Return index of element at specified position in the original sequence.

get_element_count(sequence_name)

Return number of elements in the original sequence.

get_expanded_element(sequence_name, ...)

Return requested element in the expanded sequence.

get_expanded_element_name(sequence_name, ...)

Get list with the names of all elements of a specific sequence.

get_expanded_element_positions(sequence_name)

Get list with positions of all elements of a specific sequence.

get_expanded_element_names(sequence_name)

Get list with the names of all elements of a specific sequence.

get_expanded_element_index(sequence_name, ...)

Return index of element with specified name in the expanded sequence.

get_expanded_element_index_by_position(...)

Return index of element at specified position in the expanded sequence.

get_expanded_element_count(sequence_name)

Return number of elements in the expanded sequence.

get_global_element(element_index)

Return requested element in the expanded sequence.

get_global_element_name(element_index)

Return name of element.

get_global_element_index(element_name)

Return index of element with specified name in the global element list.

get_global_element_count()

Return number of globally visible elements.

get_base_type_names()

Return list of element names for base types.

get_defined_command(command_name)

Return MAD-X command as dict of values.

get_defined_command_names()

Return list of MAD-X command names.

get_beam(beam_name)

Return MAD-X beam as dict of values.

get_beam_names()

Return list of MAD-X beam names.

getcwd()

Return the current working directory.