# Bumps documentation

## options - Command line options processor

`BumpsOpts` | Option parser for bumps.
`ChoiceList` |
`FIT_CONFIG` | FitConfig singleton for the common case in which only one config is needed.
`FitConfig` | Fit settings configuration object.
`ParseOpts` | Options parser.
`getopts` | Process command line options.
`parse_int` |
`yesno` |

Option parser for bumps command line

class bumps.options.BumpsOpts(args)

  Bases: `ParseOpts`

  Option parser for bumps.

  FLAGS = {'batch', 'chisq', 'cov', 'edit', 'err', 'i', 'mpi', 'multiprocessing-fork', 'noshow', 'overwrite', 'preview', 'profile', 'remote', 'shake', 'simrandom', 'simulate', 'staj', 'stepmon', 'time_model', 'worker'}
  IMPLICIT_VALUES = {'entropy': 'llf', 'parallel': '0', 'resume': '-'}

    Value to use if a value flag is is present without ‘=’. This is different from the default value if the flag is not present, which is the default value set in the calling class.

  MINARGS = 1
  PLOTTERS = ('linear', 'log', 'residuals')
  TRANSPORTS = ('amqp', 'mp', 'mpi', 'celery')
  USAGE = 'Usage: bumps [options] modelfile [modelargs]\n\nThe modelfile is a Python script (i.e., a series of Python commands)\nwhich sets up the data, the models, and the fittable parameters.\nThe model arguments are available in the modelfile as sys.argv[1:].\nModel arguments may not start with \'-\'.\n\nOptions:\n\n --preview\n display model but do not perform a fitting operation\n --pars=filename or store path\n initial parameter values; fit results are saved as path/<modelname>.par\n --plot=log [linear|log|residuals]\n type of plot to display\n --trim=true\n trim any remaining burn before displaying plots [dream only]\n --simulate\n simulate a dataset using the initial problem parameters\n --simrandom\n simulate a dataset using random problem parameters\n --shake\n set random parameters before fitting\n --noise=5%\n percent noise to add to the simulated data\n --seed=integer\n random number seed\n --err\n show uncertainty estimate from curvature at the minimum\n --cov\n show the covariance matrix for the model when done\n --entropy=gmm|mvn|wnn|llf\n compute entropy on posterior distribution [dream only]\n --staj\n output staj file when done [Refl1D only]\n --edit\n start the gui\n --view=linear|log\n one of the predefined problem views; reflectometry also has fresnel,\n logfresnel, q4 and residuals\n\n --store=path\n output directory for plots and models\n --overwrite\n if store already exists, replace it\n --resume=path [dream]\n resume a fit from previous stored state; if path is \'-\' then use the\n path given by --store, if it exists\n --parallel=n\n run fit using multiprocessing for parallelism; use --parallel=0 for all cpus\n --mpi\n run fit using MPI for parallelism (use command "mpirun -n cpus ...")\n --batch\n batch mode; save output in .mon file and don\'t show plots after fit\n --noshow\n semi-batch; send output to console but don\'t show plots after fit\n --time=inf\n run for a maximum number of hours\n --checkpoint=0\n save fit state every n hours, or 0 for no checkpoints\n\n --fit=amoeba [amoeba|de|dream|lm|newton|pt]\n fitting engine to use; see manual for details\n --steps=0 [amoeba|de|dream|lm|newton|pt]\n number of fit iterations after any burn-in time; use samples if steps=0\n --samples=1e4 [dream]\n set steps=samples/(pop*#pars) so the target number of samples is drawn\n --xtol=1e-4 [de, amoeba]\n minimum population diameter\n --ftol=1e-4 [de, amoeba]\n minimum population flatness\n --alpha=0.0 [dream]\n p-level for rejecting convergence; with fewer samples use a stricter\n stopping condition, such as --alpha=0.01 --samples=20000\n --outliers=none [dream]\n name of test used for removing outlier chains every N samples:\n none: no outlier removal\n iqr: use interquartile range on likelihood\n grubbs: use t-test on likelihood\n mahal: use distance from parameter values on the best chain\n --pop=10 [dream, de, rl, ps]\n population size is pop times number of fitted parameters; if pop is\n negative, then set population size to -pop.\n --burn=100 [dream, pt]\n number of burn-in iterations before accumulating stats\n --thin=1 [dream]\n number of fit iterations between steps\n --nT=25\n --Tmin=0.1\n --Tmax=10 [pt]\n temperatures vector; use a higher maximum temperature and a larger\n nT if your fit is getting stuck in local minima\n --CR=0.9 [de, rl, pt]\n crossover ratio for population mixing\n --starts=1 [newton, rl, amoeba]\n number of times to run the fit from random starting points.\n --near_best\n when running with multiple starts, restart from a point near the\n last minimum rather than using a completely random starting point.\n --init=eps [dream]\n population initialization method:\n eps: ball around initial parameter set\n lhs: latin hypercube sampling\n cov: normally distributed according to covariance matrix\n random: uniformly distributed within parameter ranges\n --stepmon\n show details for each step\n --resynth=0\n run resynthesis error analysis for n generations\n\n --time_model\n run the model --steps times in order to estimate total run time.\n --profile\n run the python profiler on the model; use --steps to run multiple\n models for better statistics\n --chisq\n print the model description and chisq value and exit\n -m/-c/-p command\n run the python interpreter with bumps on the path:\n m: command is a module such as bumps.cli, run as __main__\n c: command is a python one-line command\n p: command is the name of a python script\n -i\n start the interactive interpreter\n -?/-h/--help\n display this help\n'
  VALUES = {'CR', 'F', 'Tmax', 'Tmin', 'alpha', 'burn', 'c', 'checkpoint', 'entropy', 'fit', 'ftol', 'init', 'jump', 'm', 'nT', 'near_best', 'noise', 'notify', 'outliers', 'p', 'parallel', 'pars', 'plot', 'pop', 'queue', 'radius', 'resume', 'resynth', 'samples', 'seed', 'starts', 'steps', 'stop', 'store', 'thin', 'time', 'transport', 'trim', 'view', 'xtol'}
  alpha = 0.0
  checkpoint = '0'
  entropy = None
  property fit
  fit_config = <bumps.options.FitConfig object>
  meshsteps = 40
  noise = '5'
  notify = ''
  parallel = ''
  pars = None
  property plot
  queue = None
  resume = None
  resynth = '0'
  seed = ''
  starts = '1'
  store = None
  time = 'inf'
  property transport
  trim = 'true'
  view = None

class bumps.options.ChoiceList(*choices)

  Bases: `object`

bumps.options.FIT_CONFIG = <bumps.options.FitConfig object>

  FitConfig singleton for the common case in which only one config is needed. There may be other use cases, such as saving the fit config along with the rest of the state so that on resume the fit options are restored, but in that case the application will not be using the singleton.

class bumps.options.FitConfig(default='amoeba', active=['amoeba', 'de', 'dream', 'newton', 'lm'])

  Bases: `object`

  Fit settings configuration object.

  The command line parser will define a FitConfig object which contains the fitter that was given on the command line and all its options. For embedded bumps, which does not use the bumps command line parser, a new FitConfig object can be created with its own selected options.

  Attributes

  ids = [id, id, …] is a list available fitters in “preferred” order. Depending on usage, you may want to sort them, or alternatively, sort by long name with [id for _,id in sorted((v,k) for k,v in self.names]

  fitters = {id: fitclasss} maps ids to fitters.

  names = {id: name}* maps ids to long names

  settings = {id: [(option, default), …]} maps ids to default settings. The order of the settings is the preferred order to present the settings to the user in a GUI dialog for example.

  values = {id: {option: value, …}} maps ids to the settings for each fitter. Note that in the GUI, different fitters may have their settings recorded and preserved even when not selected.

  active_ids = [id, id, …] is the list of fitters to show the user in a GUI dialog for example. The other fitters should still be available from the command line.

  default_id = id is the fitter to use by default.

  selected_id = id is the fitter that was selected, either by command line or by GUI.

  selected_values = {option: value} returns the settings for the current fitter.

  selected_name = name returns the name of the selected fitter.

  selected_fitter = FitClass returns the class of the selected fitter.

  property selected_fitter
  property selected_name
  property selected_values
  set_from_cli(opts)

    Use the BumpsOpts command line parser values to set the selected fitter and its configuration options.

class bumps.options.ParseOpts(args)

  Bases: `object`

  Options parser.

  Subclass should define MINARGS, FLAGS, VALUES and USAGE.

  MINARGS is the minimum number of positional arguments.

  FLAGS is a set of arguments that may be present or absent.

  VALUES is a set of arguments that take values. Value checking can be done in the setter for each argument in the set. Default values should be set in the corresponding object attribute.

  USAGE is the help string to display for option “help”.

  The constructor will invoke the command line parser, leaving the values set by the command line as attribute values. Flag options will be True or False.

  FLAGS = {}
  IMPLICIT_VALUES = {}

    Value to use if a value flag is is present without ‘=’. This is different from the default value if the flag is not present, which is the default value set in the calling class.

  MINARGS = 0
  USAGE = ''
  VALUES = {}

bumps.options.getopts()

  Process command line options.

  Option values will be stored as attributes in the returned object.

bumps.options.parse_int(value)

bumps.options.yesno(value)