save

emg3d.io.save(fname, **kwargs)[source]

Save surveys, meshes, models, fields, and more to disk.

Serialize and save data to disk in different formats (see parameter description of fname for the supported file formats).

Any other (non-emg3d) object can be added too, as long as it knows how to serialize itself.

The serialized instances will be de-serialized if loaded with load().

Parameters:
fname : str

File name inclusive ending, which defines the used data format. Implemented are currently:

  • .h5: Uses h5py to store inputs to a hierarchical, compressed binary hdf5 file. Recommended file format, but requires the module h5py.
  • .npz: Uses numpy to store inputs to a flat, compressed binary file.
  • .json: Uses json to store inputs to a hierarchical, plain text file.
compression : int or str, optional

Passed through to h5py, default is ‘gzip’.

json_indent : int or None

Passed through to json, default is 2.

verb : int

If 1 (default) verbose, if 0 silent; if -1 it returns the info as string instead of printing it.

kwargs : Keyword arguments, optional

Data to save using its key as name. The classes listed in emg3d.io.KNOWN_CLASSES will be properly serialized: and de-serialized again if loaded with :func:`load. These instances are collected in their own group if h5py is used.

Note that the provided data cannot contain the before described parameters as keys.

Returns:
info : str

Info-string if verb<0.