Adding custom models to pymagglobal permanently

The command line interface provides an option to add your own models to pymagglobal permanently. This feature is somewhat experimental, so please contact us, if you run into trouble. The models will be added only locally. Below we show several approaches, how models can be added to pymagglobal.

Adding a single model

The most straight-forward way to add a model is probably calling pymagglobal and providing a name and path to the model file. Say you have a model called MyModel1k at /home/name/models/my_model_1k.dat. Then you can permanently include this model via:

$ pymagglobal --add-model MyModel1k /home/name/models/my_model_1k.dat

Internally, name and path are stored in a file in pymagglobal’s data-directory. The model will now be included in the model list, as well as calls to built_in_models from the python backend. Whenever built_in_models is called, a check is performed and models that no longer exist at the specified path are removed from the list.

Adding multiple models at once

There are two ways to add multiple models at once. You can either pass the path to a directory, in which case all files in the directory will be considered model files and added to the list. The filenames will be used as model names. To do this in the above case, one would use

$ pymagglobal --add-model /home/name/models/

The other way is passing a file that contains a list of models and paths, seperated by comma and one model per line. So if you have a file model_list.txt at /home/name/ that looks like this

MyModel1k,/home/name/models/my_model_1k.dat

you can pass that file to pymagglobal via

$ pymagglobal --add-model /home/name/model_list.txt

to add all models listed in the file. Internally, the file is simply appended to pymagglobals custom models file and a cleanup will be performed by calling built_in_models.