def to_netcdf(volume, filename, timestep=None):
    """ Save XRadVolume to netcdf compliant file.

    Parameters
    ----------
    volume : XRadVolume object
    filename : str
        output filename
    timestep : int, slice
        timestep/slice of wanted volume
    """
    volume.root.load()
    root = volume.root.copy(deep=True)
    root.attrs['Conventions'] = 'Cf/Radial'
    root.attrs['version'] = '2.0'
    root.to_netcdf(filename, mode='w', group='/')
    for idx, key in enumerate(root.sweep_group_name.values):
        swp = volume[idx].data.isel(time=timestep)
        swp.to_netcdf(filename, mode='a', group=key)
