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
PotentialBaseobject. The file format should match the dictionary structure expected byfrom_dict().- Parameters:
- f
str, 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.
- module
module, optional Python module namespace to search for potential classes. If not provided, uses
gala.potential.
- f
- Returns:
- potential
PotentialBase The loaded potential object.
- potential
See also
saveSave potential to YAML file.
from_dictCreate 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)