akleeman/xray — pull request #68 by shoyer (2014-03-15 22:04:09+00:00)
Title: More flexible math with variables from different datasets

PR #33 was definitely a useful change -- item access via [] should return
items still in the context of the dataset they were pulled from.

However, it doesn't make sense to always keep track of all dataset variables.
A particular example is when doing math between variables from different
datasets.

To be more concrete, suppose I have two datasets ("obs" and "sim"), each with
two measurement variables ("tmin" and "tmax"). It should be possible to
calculate `obs['tmin'] - sim['tmin']` without a merge conflict due to
conflicting values of "tmax". Unfortunately, this is exactly what the current
version of xray reports.

This PR fixes this behavior, by automatically including only coordinates
necessary to describe the arrays involved (via `DatasetArray.select`) when
merging datasets resulting from mathematical operations.

A possible downside is that occasionally auxiliary coordinates worth keeping
around will be lost (e.g., `(2 * obs['tmin']).dataset` no longer contains a
variable "tmax"). But on the whole I think this behavior is much more in line
with reasonable expectations.

This change also removes the DatasetArray methods `refocus` and `unselected`
from the public API. I think this is the right call, since these functions
were highly specific and really only useful for the prior version of the
internal API.