title: Create and write xarray DataArray to NetCDF in chunks
body: <p>Is it also possible to create an out-of-core DataArray, and write it chunk-by-chunk to a NetCDF4 file using xarray?</p>
  
  <p>For example, I want to be able to do this in an out-of-core fashion when the dimensions are much bigger and I thus cannot store the whole array in memory:</p>
  
  <pre><code>num_steps = 20
  num_times = 100
  #Create DataArray
  d = xr.DataArray(np.zeros([num_steps, num_times], np.float32),
                   {'Step': np.arange(num_steps),
                    'Time': np.arange(num_times)},
                   ('Step', 'Time'))
  #Computatation
  for i in range(num_steps):
      d[i, :] = i
  #Write to file
  d.to_netcdf('test.nc')
  </code></pre>
  
  <p>So I don't want to have to create the whole NumPy array in memory, and I want the Computation and Write to file stages to be done one chunk at a time (chunked over the Step dimension in this example).</p>
  
  <p>Update:
  It seems (from @jhamman's answer) that it may not be possible to implement my example above using xarray. I am mainly interested in developing a greater understanding of out-of-core computation with xarray, so I do not have a specific computation that I am asking about, but, since I have been asked for a more complicated example, one potential application I have is:</p>
  
  <pre><code>for i in range(num_steps):
      u[:] = f(u)
      s[:] = g(s)
      d[i, :] = u[:] * s[:]
  </code></pre>
  
  <p>where <code>u</code> and <code>s</code> are xr.DataArrays of dimension Time, and <code>f</code> and <code>g</code> are PDE solvers that only depend on the input array from the previous step. Let's say there are 1000 steps, but the Time dimension is so big that I can only store one or two in memory, so assignments to <code>d</code> must be written to disk and then the associated memory freed.</p>