py4sci

Table Of Contents

Previous topic

Plot Beta

Next topic

CPyMad implementation

This Page

PyMad API

Module pymad

The pymad package contains all parts of the general API. The abstract classes are placed in cern.pymad.abc. In additions we have some tools which are used by both implementations, found in cern.pymad.tools

Module cern.pymad.abc

Module cern.pymad.abc.service

Created on 15 Aug 2011

@author: kfuchsbe

class cern.pymad.abc.service.PyMadService[source]

The abstract class for a model-service.

am[source]

Returns the active model

cleanup()[source]

Can be overridden by subclass to do necessary cleanup steps

create_model(modeldef)[source]

Create a model instance from a model definition.

Arguments: modeldef – the model definition from which to create the model as an

object or just its name. If a name is given, then the modeldefinition is first searched in the available model definitions.
delete_model(model)[source]

cleans up the given model and deletes a model from the available models

mdefnames[source]

Returns all the names of the available model definitions

mdefs[source]

Returns all the available model definitions as a list

models[source]

Returns all the instantiated models as a list

Module cern.pymad.abc.model

Created on 15 Aug 2011

Module author: Kajetan Fuchsberger <Kajetan.Fuchsberger@cern.ch>

class cern.pymad.abc.model.PyMadModel[source]

The abstract class for models

mdef[source]

returns the model definition from which the model was created

name[source]

Returns the name of this model

set_optic(opticname)[source]

Sets the actual optic with that of the given name. If the optic is not contained in the definitions, then a ValueError is raised.

twiss(seqname=None, columns=[], elementpatterns=['.*'], file=None)[source]

Runs a twiss on the model and returns a result containing the variables and the elements given.

Additional tools

A collection of tools which can be useful to the end user are documented here.

Module cern.pymad.tfs

Simple function which loads a tfs file:

from cern import pymad
table,summary=pymad.tfs('file.tfs')

You can then access e.g. the horizontal beta in several equivalent ways:

table.betx
table.BETX
table['betx']
table['BETX']

All these four methods will return the same object. Naming scheme follows the convention from Mad-X.

It is possible to get the list of available keys:

table.keys()
summary.keys()