Skip to content
forked from pydata/xarray

Commit

Permalink
Add coords='skip_nondim'
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Aug 1, 2019
1 parent 66f907e commit 8263d38
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion xarray/core/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def concat(objs, dim=None, data_vars='all', coords='different',
coords : {'minimal', 'different', 'all' or list of str}, optional
These coordinate variables will be concatenated together:
* 'minimal': Only coordinates in which the dimension already appears
are included.
are concatenated. Non-dimensional coordinates will be checked for
equality.
* 'skip_nondim': Same as minimal but avoids checking nondimensional
coordinates for equality.
* 'different': Coordinates which are not equal (ignoring attributes)
across all datasets are also concatenated (as well as all for which
dimension already appears). Beware: this option may load the data
Expand Down Expand Up @@ -190,6 +193,8 @@ def process_subset_opt(opt, subset):
set(datasets[0].dims))
elif opt == 'minimal':
pass
elif opt == 'skip_nondim' and subset == 'coords':
pass
else:
raise ValueError("unexpected value for %s: %s" % (subset, opt))
else:
Expand Down Expand Up @@ -258,6 +263,13 @@ def insert_result_variable(k, v):
elif (k in result_coord_names) != (k in ds.coords):
raise ValueError('%r is a coordinate in some datasets but not '
'others' % k)
elif ((k in result_coord_names)
and (k in result_vars)
and (k not in ds.dims)
and (coords == 'skip_nondim')):
# skip comparison of non dimensional coords when ask to
# concatenate only over dim_coords if needed
pass
elif k in result_vars and k != dim:
# Don't use Variable.identical as it internally invokes
# Variable.equals, and we may already know the answer
Expand Down

0 comments on commit 8263d38

Please sign in to comment.