title: Slicing xarray dataset with coordinate dependent variable
body: <p>I built an xarray dataset in python3 with coordinates <code>(time, levels)</code> to identify all cloud bases and cloud tops during one day of observations. The variable <code>levels</code> is the dimension for the cloud base/tops that can be identified at a given time. It stores cloud base/top heights values for each time.</p>
  <p>Now I want to select all the cloud bases and tops that are located within a given range of heights that change in time. The height range is identified by the arrays <code>bottom_mod</code> and <code>top_mod</code>. These arrays have a <code>time</code> dimension and contain the edges of the range of heights to be selected.</p>
  <p>The xarray dataset is <code>cloudStandard_mod_reshaped</code>:</p>
  <pre><code>Dimensions:     (levels: 8, time: 9600)
  Coordinates:
    * levels      (levels) int64 0 1 2 3 4 5 6 7
    * time        (time) datetime64[ns] 2013-04-14 ... 2013-04-14T23:59:51
  Data variables:
      cloudTop    (time, levels) float64 nan nan nan nan nan ... nan nan nan nan
      cloudThick  (time, levels) float64 nan nan nan nan nan ... nan nan nan nan
      cloudBase   (time, levels) float64 nan nan nan nan nan ... nan nan nan nan
  </code></pre>
  <p>I tried to select the heights in the range identified by top and bottom array as follows:</p>
  <pre><code>PBLclouds = cloudStandard_mod_reshaped.sel(levels=slice(bottom_mod[:], top_mod[:]))
  </code></pre>
  <p>but this instruction does accept only scalar values for the slice command.</p>
  <p>Do you know how to slice with values that are coordinate-dependent?</p>