save#

gala.potential.potential.save(potential, f)[source]#

Save a potential object to a YAML file.

This function serializes a PotentialBase object to YAML format and writes it to a file. The resulting file can be loaded using load().

Parameters:
potentialPotentialBase

The potential object to save.

fstr, file-like

Output filename or file-like object to write the potential specification to.

See also

load

Load potential from YAML file.

to_dict

Convert potential to dictionary representation.

Examples

Save a potential to file:

>>> pot = HernquistPotential(m=1e11*u.Msun, c=2*u.kpc)
>>> save(pot, 'hernquist_potential.yml')

Save to a string buffer:

>>> from io import StringIO
>>> buffer = StringIO()
>>> save(pot, buffer)
>>> yaml_content = buffer.getvalue()