cli - Command line interface¶
Bumps options returned from the command line parser. |
|
Reload a bumps export directory. |
|
Reload individual parameter values from a saved .par file. |
|
Load a model file. |
|
Save the fit data, including parameter values, uncertainties and plots. |
|
Setup matplotlib to use a particular backend. |
|
Point the matplotlib config dir to %LOCALAPPDATA%{appdatadir}mplconfig. |
|
Replace symbols in |
Basic command line usage:
# Run a model from show its χ² value. This is useful for debugging the model file.
bumps model.py --chisq
# Run a simple batch fit on model.py, appending results to a store file.
bumps --batch --session=T1.hdf model.py
# Run a DREAM fit on model.py to explore parameter uncertainties
bumps --batch --session=T1.hdf model.py --fit=dream
# Load and resume the last fit in a session file. The model.py file is ignored.
bumps --batch --session=T1.hdf [model.py] --resume
Basic interactive usage:
# Open a web browser to the bumps application. Show the initial model if any.
bumps [model.py]
# Open a web browser and start a fit
bumps model.py --start
# Watch fit progress and exit when complete
bumps model.py --run --session=T1.hdf
There are many more options available to control the fit, particularly for batch mode fitting. To see them type:
bumps --help
- class bumps.cli.BumpsOptions(filename: str | None = None, args: List[str] | None = None, fit_options: Dict[str, ~typing.Any]=<factory>, resume: bool = False, show_cov: bool = False, show_err: bool = False, show_entropy: str | None = None, session: str | None = None, read_session: str | None = None, write_session: str | None = None, serializer: Literal['dataclass', 'pickle', 'cloudpickle', 'dill']='dataclass', checkpoint: int = 300, auto_history: bool = True, path: str | None = None, use_persistent_path: bool = False, reload_export: str | None = None, pars: str | None = None, simulate: bool = False, simrandom: bool = False, shake: bool = False, noise: float = 5.0, seed: int = 0, chisq: bool = False, export: str | None = None, trace: bool = False, loglevel: str = 'warn', parallel: int = 0, threads: bool = False, mpi: bool | None = None, mode: str = 'edit', headless: bool = False, external: bool = False, port: int = 0, hub: str | None = None, convergence_heartbeat: bool = False)[source]¶
Bases:
objectBumps options returned from the command line parser.
This can be used as a stand-alone object if you are invoking bumps from a script without using the command line parser.
- bumps.cli.config_matplotlib(backend=None)[source]¶
Setup matplotlib to use a particular backend.
The backend should be ‘WXAgg’ for interactive use, or ‘Agg’ for batch. This distinction allows us to run in environments such as cluster computers which do not have wx installed on the compute nodes.
This function must be called before any imports to matplotlib. To allow this, modules should not import matplotlib at the module level, but instead import it for each function/method that uses it. Exceptions can be made for modules which are completely dedicated to plotting, but these modules should never be imported at the module level.
- bumps.cli.install_plugin(p)[source]¶
Replace symbols in
bumps.pluginwith application specific methods.
- bumps.cli.interpret_fit_options(options: BumpsOptions)[source]¶
- bumps.cli.load_best(problem, path)¶
Reload individual parameter values from a saved .par file.
If the label does not exist in the file, use the value from the model as the default value. Ignore labels that do not exist in the model. In that way we can load parameters from an old fit with minimal fuss, even as we add, delete and move parameters in the model. If any parameters are missing, set problem.undefined to the a boolean index of the undefined parameters.
There is an interaction with –init=eps and the par file. If any parameters are missing from the par file they will be randomized across the entire parameter range using the equivalent of –init=lhs. That means you can drop a # at the beginning of the line in the .par file and that parameter will be shuffled on restart, with the remaining parameters starting near the initial value.
- bumps.cli.load_model(path: Path | str, args: list[str] | None = None)¶
Load a model file.
path contains the path to the model file. This could be a python script or a previously saved problem, serialized as .json, .cloudpickle, .pickle or .dill
args are any additional arguments to the model. The sys.argv variable will be set such that sys.argv[1:] == model_options.
- bumps.cli.main(options: BumpsOptions | None = None)[source]¶
- bumps.cli.reload_export(path: Path | str, modelfile: Path | str | None = None, args: list[str] | None = None) tuple[FitProblem, FitResult][source]¶
Reload a bumps export directory.
path is the path to the directory, or to a <model>.par file within that directory. Use the <model>.par file if you have multiple models exported to the same path.
If modelfile is provided then use it, otherwise use <model>.py in the current directory. That means you can change to the directory containing your model then run bumps with –reload-export=path without having to list <model>.py on the command line. This is handy if you have several variations saved to different filenames stored along with your data.
sys.argv is set to args before loading the model.