'Closes the NetCDF file.'

def close(self):

    if (not self.fp.closed):
        try:
            self.flush()
        finally:
            self.variables = OrderedDict()
            if (self._mm_buf is not None):
                ref = weakref.ref(self._mm_buf)
                self._mm_buf = None
                if (ref() is None):
                    self._mm.close()
                else:
                    warnings.warn('Cannot    close    a    netcdf_file    opened    with    mmap=True,    when    netcdf_variables    or    arrays    referring    to    its    data    still    exist.    All    data    arrays    obtained    from    such    files    refer    directly    to    data    on    disk,    and    must    be    copied    before    the    file    can    be    cleanly    closed.    (See    netcdf_file    docstring    for    more    information    on    mmap.)', category=RuntimeWarning)
            self._mm = None
            self.fp.close()
