'Save raw data to file.
Parameters
fname : string
File name of the new dataset. This has to be a new filename
unless data have been preloaded. Filenames should end with
raw.fif, raw.fif.gz, raw_sss.fif, raw_sss.fif.gz, raw_tsss.fif
or raw_tsss.fif.gz.
picks : array-like of int | None
Indices of channels to include. If None all channels are kept.
tmin : float | None
Time in seconds of first sample to save. If None first sample
is used.
tmax : float | None
Time in seconds of last sample to save. If None last sample
is used.
buffer_size_sec : float | None
Size of data chunks in seconds. If None (default), the buffer
size of the original file is used.
drop_small_buffer : bool
Drop or not the last buffer. It is required by maxfilter (SSS)
that only accepts raw files with buffers of the same size.
proj : bool
If True the data is saved with the projections applied (active).
.. note:: If ``apply_proj()`` was used to apply the projections,
the projectons will be active even if ``proj`` is False.
fmt : str
Format to use to save raw data. Valid options are \'double\',
\'single\', \'int\', and \'short\' for 64- or 32-bit float, or 32- or
16-bit integers, respectively. It is **strongly** recommended to
use \'single\', as this is backward-compatible, and is standard for
maintaining precision. Note that using \'short\' or \'int\' may result
in loss of precision, complex data cannot be saved as \'short\',
and neither complex data types nor real data stored as \'double\'
can be loaded with the MNE command-line tools. See raw.orig_format
to determine the format the original data were stored in.
overwrite : bool
If True, the destination file (if it exists) will be overwritten.
If False (default), an error will be raised if the file exists.
split_size : string | int
Large raw files are automatically split into multiple pieces. This
parameter specifies the maximum size of each piece. If the
parameter is an integer, it specifies the size in Bytes. It is
also possible to pass a human-readable string, e.g., 100MB.
.. note:: Due to FIFF file limitations, the maximum split
size is 2GB.
verbose : bool, str, int, or None
If not None, override default verbose level (see
:func:`mne.verbose` and :ref:`Logging documentation <tut_logging>`
for more). Defaults to self.verbose.
Notes
If Raw is a concatenation of several raw files, **be warned** that
only the measurement information from the first raw file is stored.
This likely means that certain operations with external tools may not
work properly on a saved concatenated file (e.g., probably some
or all forms of SSS). It is recommended not to concatenate and
then save raw files for this reason.'

@verbose
def save(self, fname, picks=None, tmin=0, tmax=None, buffer_size_sec=None, drop_small_buffer=False, proj=False, fmt='single', overwrite=False, split_size='2GB', verbose=None):

    check_fname(fname, 'raw', ('raw.fif', 'raw_sss.fif', 'raw_tsss.fif', 'raw.fif.gz', 'raw_sss.fif.gz', 'raw_tsss.fif.gz'))
    split_size = _get_split_size(split_size)
    fname = op.realpath(fname)
    if ((not self.preload) and (fname in self._filenames)):
        raise ValueError('You    cannot    save    data    to    the    same    file.    Please    use    a    different    filename.')
    if self.preload:
        if np.iscomplexobj(self._data):
            warn('Saving    raw    file    with    complex    data.    Loading    with    command-line    MNE    tools    will    not    work.')
    type_dict = dict(short=FIFF.FIFFT_DAU_PACK16, int=FIFF.FIFFT_INT, single=FIFF.FIFFT_FLOAT, double=FIFF.FIFFT_DOUBLE)
    if (fmt not in type_dict.keys()):
        raise ValueError('fmt    must    be    "short",    "int",    "single",    or    "double"')
    reset_dict = dict(short=False, int=False, single=True, double=True)
    reset_range = reset_dict[fmt]
    data_type = type_dict[fmt]
    data_test = self[(0, 0)][0]
    if ((fmt == 'short') and np.iscomplexobj(data_test)):
        raise ValueError('Complex    data    must    be    saved    as    "single"    or    "double",    not    "short"')
    _check_fname(fname, overwrite)
    if proj:
        info = copy.deepcopy(self.info)
        (projector, info) = setup_proj(info)
        activate_proj(info['projs'], copy=False)
    else:
        info = self.info
        projector = None
    start = int(np.floor((tmin * self.info['sfreq'])))
    if (tmax is None):
        stop = np.inf
    else:
        stop = (self.time_as_index(float(tmax), use_rounding=True)[0] + 1)
    stop = min(stop, ((self.last_samp - self.first_samp) + 1))
    buffer_size = self._get_buffer_size(buffer_size_sec)
    _write_raw(fname, self, info, picks, fmt, data_type, reset_range, start, stop, buffer_size, projector, drop_small_buffer, split_size, 0, None)
