load#

gala.potential.potential.load(f, module=None)[source]#

Load a potential from a YAML specification file.

This function reads a YAML file containing a potential specification and creates the corresponding PotentialBase object. The file format should match the dictionary structure expected by from_dict().

Parameters:
fstr, file-like

Path to a YAML file, a block of YAML text, or a file-like object containing the potential specification to parse and load.

modulemodule, optional

Python module namespace to search for potential classes. If not provided, uses gala.potential.

Returns:
potentialPotentialBase

The loaded potential object.

See also

save

Save potential to YAML file.

from_dict

Create potential from dictionary specification.

Examples

Load a potential from a YAML file:

>>> pot = load('my_potential.yml')

Load from a YAML string:

>>> yaml_spec = '''
... class: HernquistPotential
... parameters:
...   m: 1.0e11
...   c: 2.0
... '''
>>> pot = load(yaml_spec)