Skip to content

Commit 8263d38

Browse files
committed
Add coords='skip_nondim'
1 parent 66f907e commit 8263d38

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

xarray/core/concat.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ def concat(objs, dim=None, data_vars='all', coords='different',
4343
coords : {'minimal', 'different', 'all' or list of str}, optional
4444
These coordinate variables will be concatenated together:
4545
* 'minimal': Only coordinates in which the dimension already appears
46-
are included.
46+
are concatenated. Non-dimensional coordinates will be checked for
47+
equality.
48+
* 'skip_nondim': Same as minimal but avoids checking nondimensional
49+
coordinates for equality.
4750
* 'different': Coordinates which are not equal (ignoring attributes)
4851
across all datasets are also concatenated (as well as all for which
4952
dimension already appears). Beware: this option may load the data
@@ -190,6 +193,8 @@ def process_subset_opt(opt, subset):
190193
set(datasets[0].dims))
191194
elif opt == 'minimal':
192195
pass
196+
elif opt == 'skip_nondim' and subset == 'coords':
197+
pass
193198
else:
194199
raise ValueError("unexpected value for %s: %s" % (subset, opt))
195200
else:
@@ -258,6 +263,13 @@ def insert_result_variable(k, v):
258263
elif (k in result_coord_names) != (k in ds.coords):
259264
raise ValueError('%r is a coordinate in some datasets but not '
260265
'others' % k)
266+
elif ((k in result_coord_names)
267+
and (k in result_vars)
268+
and (k not in ds.dims)
269+
and (coords == 'skip_nondim')):
270+
# skip comparison of non dimensional coords when ask to
271+
# concatenate only over dim_coords if needed
272+
pass
261273
elif k in result_vars and k != dim:
262274
# Don't use Variable.identical as it internally invokes
263275
# Variable.equals, and we may already know the answer

0 commit comments

Comments
 (0)