title: Which precision is used by xarray weighted().mean()?
body: <p>I would like to understand when weighted().mean() is using simple or double precision.<br />
  There is a short example of the issue I have:</p>
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  import xarray as xr
  data = xr.tutorial.open_dataset(&quot;air_temperature&quot;)
  weights = np.cos( np.deg2rad(data.lat) )   # weights with the cosinus of the latitude
  
  # data are 32 bytes
  data.air.dtype   # --&gt; dtype('float32')
  weights.dtype    # --&gt; dtype('float32')
  
  # mean() uses 32b
  data.air.isel(time=1).mean().dtype   # --&gt; dtype('float32')
  
  # weighted().mean() uses 64b in some cases...
  data.air.isel(time=1).weighted(weights).mean().dtype            # --&gt; dtype('float64')
  data.air.isel(time=slice(1,2)).weighted(weights).mean().dtype   # --&gt; dtype('float64')
  
  # ... but weighted().mean() keep using 32b if mean is not applied to all dimensions, why?
  data.air.isel(time=slice(1,2)).weighted(weights).mean((&quot;lon&quot;, &quot;lat&quot;)).dtype   # --&gt; dtype('float32')
  </code></pre>
  <p>Why weighted().mean() is using 32 bytes instead of 64 if mean() is not applied to all dimensions?</p>