title: Do xarray or dask really support memory-mapping?
body: <p>In my experimentation so far, I've tried:</p>
  
  <ul>
  <li><code>xr.open_dataset</code> with <code>chunks</code> arg, and it loads the data into memory.</li>
  <li>Set up a <code>NetCDF4DataStore</code>, and call <code>ds['field'].values</code> and it loads the data into memory.</li>
  <li>Set up a <code>ScipyDataStore</code> with <code>mmap='r'</code>, and <code>ds['field'].values</code> loads the data into memory.</li>
  </ul>
  
  <p>From what I have seen, the design seems to center not around actually applying numpy functions on memory-mapped arrays, but rather loading small chunks into memory (sometimes using memory-mapping to do so). For example, <a href="https://github.com/pydata/xarray/blob/f517be7b1b3f41090eca04d06d7f434916861a7c/xarray/backends/scipy_.py#L51" rel="noreferrer">this comment</a>. And somewhat related comment <a href="http://This%20works%20pretty%20cleanly,%20but%20in%20the%20process%20I%20discovered%20that%20there&#39;s%20no%20reliable%20way%20to%20check%20whether%20a%20numpy%20array%20is%20mem-mapped%20or%20not.%20The%20arrays%20scipy.io.netcdf%20returns%20are%20not%20np.memmap%20instances,%20but%20their%20data%20does%20point%20to%20a%20file%20on%20disk." rel="noreferrer">here</a> about not xarray not being able to determine whether a numpy array is mmapped or not.</p>
  
  <p>I'd like to be able to represent and slice data as an <code>xarray.Dataset</code>, and be able to call <code>.values</code> (or <code>.data</code>) to get an <code>ndarray</code>, but have it remain mmapped (for purposes of shared-memory and so on).</p>
  
  <p>It would also be nice if chunked dask operations could at least operate on the memory-mapped array until it actually needs to mutate something, which seems possible since dask seems to be designed around immutable arrays.</p>
  
  <p>I did find a trick with xarray, though, which is to do like so:</p>
  
  <pre><code>data=np.load('file.npy', mmap_mode='r')
  ds=xr.Dataset({'foo': (['dim1', 'dim2'], data)})
  </code></pre>
  
  <p>At this point, things like the following work without loading anything into memory:</p>
  
  <pre><code>np.sum(ds['foo'].values)
  np.sum(ds['foo'][::2,:].values)
  </code></pre>
  
  <p>...xarray apparently doesn't know that the array is mmapped, and can't afford to impose a <code>np.copy</code> for cases like these.</p>
  
  <p>Is there a "supported" way to do read-only memmapping (or copy-on write for that matter) in xarray or dask?</p>