def save_data(data, filename='posterior.nc'):
    """
    Save posterior samples to a netcdf file.

    Parameters
    ----------
    data : xarray.Dataset
        Posterior samples. Use arviz.convert_to_xarray to turn samples from
        other libraries into xarray.
    filename : str
        name or path of the file to save data
    """
    return data.to_netcdf(filename)