1
"""Input and output support for data."""
2

3 2
from .converters import convert_to_inference_data
4 2
from .inference_data import InferenceData
5

6

7 2
def from_netcdf(filename):
8
    """Load netcdf file back into an arviz.InferenceData.
9

10
    Parameters
11
    ----------
12
    filename : str
13
        name or path of the file to load trace
14

15
    Returns
16
    -------
17
        InferenceData object
18

19
    Notes
20
    -----
21
    By default, the datasets of the InferenceData object will be lazily loaded instead
22
    of loaded into memory. This behaviour is regulated by the value of
23
    ``az.rcParams["data.load"]``.
24
    """
25 2
    return InferenceData.from_netcdf(filename)
26

27

28 2
def to_netcdf(data, filename, *, group="posterior", coords=None, dims=None):
29
    """Save dataset as a netcdf file.
30

31
    WARNING: Only idempotent in case `data` is InferenceData
32

33
    Parameters
34
    ----------
35
    data : InferenceData, or any object accepted by `convert_to_inference_data`
36
        Object to be saved
37
    filename : str
38
        name or path of the file to load trace
39
    group : str (optional)
40
        In case `data` is not InferenceData, this is the group it will be saved to
41
    coords : dict (optional)
42
        See `convert_to_inference_data`
43
    dims : dict (optional)
44
        See `convert_to_inference_data`
45

46
    Returns
47
    -------
48
    str
49
        filename saved to
50
    """
51 2
    inference_data = convert_to_inference_data(data, group=group, coords=coords, dims=dims)
52 2
    file_name = inference_data.to_netcdf(filename)
53 2
    return file_name

Read our documentation on viewing source code .

Loading