Error on using xarray open_mfdataset function
<p>I am trying to combine multiple netCDF files with the same dimensions, their dimensions are as follows:</p>

<pre><code>OrderedDict([(u'lat', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lat', size = 720
), (u'lon', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lon', size = 1440
), (u'time', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'time', size = 96
), (u'nv', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'nv', size = 2
)])
OrderedDict([(u'lat', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lat', size = 720
), (u'lon', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lon', size = 1440
), (u'time', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'time', size = 96
), (u'nv', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'nv', size = 2
)])
OrderedDict([(u'lat', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lat', size = 720
), (u'lon', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lon', size = 1440
), (u'time', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'time', size = 96
), (u'nv', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'nv', size = 2
)])
OrderedDict([(u'lat', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lat', size = 720
), (u'lon', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lon', size = 1440
), (u'time', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'time', size = 96
), (u'nv', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'nv', size = 2
)])
OrderedDict([(u'lat', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lat', size = 720
), (u'lon', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lon', size = 1440
), (u'time', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'time', size = 96
), (u'nv', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'nv', size = 2
)])
OrderedDict([(u'lat', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lat', size = 720
), (u'lon', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lon', size = 1440
), (u'time', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'time', size = 96
), (u'nv', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'nv', size = 2
)])
OrderedDict([(u'lat', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lat', size = 720
), (u'lon', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'lon', size = 1440
), (u'time', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'time', size = 96
), (u'nv', &lt;type 'netCDF4._netCDF4.Dimension'&gt;: name = 'nv', size = 2
)])
</code></pre>

<p>However, on using open_mfdataset, I get this error:</p>

<pre><code>xr.open_mfdataset(path_file, decode_times=False)

*** ValueError: cannot infer dimension to concatenate: supply the ``concat_dim`` argument explicitly
</code></pre>

<p>How to fix this error? My dimensions are the same in all the files</p>

<p>This error message is probably arising because you have two files with the same variables and coordinate values, and xarray doesn't know whether it should stack them together along a new dimension or simply check to make sure none of the values conflict.</p>

<p>It would be nice if explicitly calling <code>open_mfdataset</code> with <code>concat_dim=None</code> disabled all attempts at concatenation. <a href="https://github.com/pydata/xarray/pull/1007" rel="nofollow">This change</a> should make it into the next release of xarray (v0.9.0).</p>

<p>In the meantime, you can work around this by opening the files individually and merging them explicitly, e.g.,</p>

<pre><code>def open_mfdataset_merge_only(paths, **kwargs):
    if isinstance(paths, basestring):
        paths = sorted(glob(paths))
    return xr.merge([xr.open_dataset(path, **kwargs) for path in paths])
</code></pre>

<p>Under the covers, this is basically all that <code>open_mfdataset</code> is doing.</p>

python numpy netcdf python-xarray netcdf4