save#
- gala.potential.potential.save(potential, f)[source]#
Save a potential object to a YAML file.
This function serializes a
PotentialBaseobject to YAML format and writes it to a file. The resulting file can be loaded usingload().- Parameters:
- potential
PotentialBase The potential object to save.
- f
str, file-like Output filename or file-like object to write the potential specification to.
- potential
See also
loadLoad potential from YAML file.
to_dictConvert 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()