@@ -136,7 +136,7 @@ def _check_shape_tile_ids(combined_tile_ids):
136
136
137
137
def _combine_nd (combined_ids , concat_dims , data_vars = 'all' ,
138
138
coords = 'different' , compat = 'no_conflicts' ,
139
- fill_value = dtypes .NA ):
139
+ fill_value = dtypes .NA , join = 'outer' ):
140
140
"""
141
141
Combines an N-dimensional structure of datasets into one by applying a
142
142
series of either concat and merge operations along each dimension.
@@ -177,13 +177,14 @@ def _combine_nd(combined_ids, concat_dims, data_vars='all',
177
177
data_vars = data_vars ,
178
178
coords = coords ,
179
179
compat = compat ,
180
- fill_value = fill_value )
180
+ fill_value = fill_value ,
181
+ join = join )
181
182
(combined_ds ,) = combined_ids .values ()
182
183
return combined_ds
183
184
184
185
185
186
def _combine_all_along_first_dim (combined_ids , dim , data_vars , coords , compat ,
186
- fill_value = dtypes .NA ):
187
+ fill_value = dtypes .NA , join = 'outer' ):
187
188
188
189
# Group into lines of datasets which must be combined along dim
189
190
# need to sort by _new_tile_id first for groupby to work
@@ -197,12 +198,13 @@ def _combine_all_along_first_dim(combined_ids, dim, data_vars, coords, compat,
197
198
combined_ids = OrderedDict (sorted (group ))
198
199
datasets = combined_ids .values ()
199
200
new_combined_ids [new_id ] = _combine_1d (datasets , dim , compat ,
200
- data_vars , coords , fill_value )
201
+ data_vars , coords , fill_value ,
202
+ join )
201
203
return new_combined_ids
202
204
203
205
204
206
def _combine_1d (datasets , concat_dim , compat = 'no_conflicts' , data_vars = 'all' ,
205
- coords = 'different' , fill_value = dtypes .NA ):
207
+ coords = 'different' , fill_value = dtypes .NA , join = 'outer' ):
206
208
"""
207
209
Applies either concat or merge to 1D list of datasets depending on value
208
210
of concat_dim
@@ -222,7 +224,8 @@ def _combine_1d(datasets, concat_dim, compat='no_conflicts', data_vars='all',
222
224
else :
223
225
raise
224
226
else :
225
- combined = merge (datasets , compat = compat , fill_value = fill_value )
227
+ combined = merge (datasets , compat = compat , fill_value = fill_value ,
228
+ join = join )
226
229
227
230
return combined
228
231
@@ -233,7 +236,7 @@ def _new_tile_id(single_id_ds_pair):
233
236
234
237
235
238
def _nested_combine (datasets , concat_dims , compat , data_vars , coords , ids ,
236
- fill_value = dtypes .NA ):
239
+ fill_value = dtypes .NA , join = 'outer' ):
237
240
238
241
if len (datasets ) == 0 :
239
242
return Dataset ()
@@ -254,12 +257,13 @@ def _nested_combine(datasets, concat_dims, compat, data_vars, coords, ids,
254
257
# Apply series of concatenate or merge operations along each dimension
255
258
combined = _combine_nd (combined_ids , concat_dims , compat = compat ,
256
259
data_vars = data_vars , coords = coords ,
257
- fill_value = fill_value )
260
+ fill_value = fill_value , join = join )
258
261
return combined
259
262
260
263
261
264
def combine_nested (datasets , concat_dim , compat = 'no_conflicts' ,
262
- data_vars = 'all' , coords = 'different' , fill_value = dtypes .NA ):
265
+ data_vars = 'all' , coords = 'different' , fill_value = dtypes .NA ,
266
+ join = 'outer' ):
263
267
"""
264
268
Explicitly combine an N-dimensional grid of datasets into one by using a
265
269
succession of concat and merge operations along each dimension of the grid.
@@ -312,6 +316,8 @@ def combine_nested(datasets, concat_dim, compat='no_conflicts',
312
316
Details are in the documentation of concat
313
317
fill_value : scalar, optional
314
318
Value to use for newly missing values
319
+ join : {'outer', 'inner', 'left', 'right', 'exact'}, optional
320
+ How to combine objects with different indexes.
315
321
316
322
Returns
317
323
-------
@@ -383,15 +389,15 @@ def combine_nested(datasets, concat_dim, compat='no_conflicts',
383
389
# The IDs argument tells _manual_combine that datasets aren't yet sorted
384
390
return _nested_combine (datasets , concat_dims = concat_dim , compat = compat ,
385
391
data_vars = data_vars , coords = coords , ids = False ,
386
- fill_value = fill_value )
392
+ fill_value = fill_value , join = join )
387
393
388
394
389
395
def vars_as_keys (ds ):
390
396
return tuple (sorted (ds ))
391
397
392
398
393
399
def combine_by_coords (datasets , compat = 'no_conflicts' , data_vars = 'all' ,
394
- coords = 'different' , fill_value = dtypes .NA ):
400
+ coords = 'different' , fill_value = dtypes .NA , join = 'outer' ):
395
401
"""
396
402
Attempt to auto-magically combine the given datasets into one by using
397
403
dimension coordinates.
@@ -439,6 +445,8 @@ def combine_by_coords(datasets, compat='no_conflicts', data_vars='all',
439
445
Details are in the documentation of concat
440
446
fill_value : scalar, optional
441
447
Value to use for newly missing values
448
+ join : {'outer', 'inner', 'left', 'right', 'exact'}, optional
449
+ How to combine objects with different indexes.
442
450
443
451
Returns
444
452
-------
@@ -523,7 +531,8 @@ def combine_by_coords(datasets, compat='no_conflicts', data_vars='all',
523
531
524
532
525
533
def auto_combine (datasets , concat_dim = '_not_supplied' , compat = 'no_conflicts' ,
526
- data_vars = 'all' , coords = 'different' , fill_value = dtypes .NA ):
534
+ data_vars = 'all' , coords = 'different' , fill_value = dtypes .NA ,
535
+ join = 'outer' ):
527
536
"""
528
537
Attempt to auto-magically combine the given datasets into one.
529
538
@@ -571,6 +580,8 @@ def auto_combine(datasets, concat_dim='_not_supplied', compat='no_conflicts',
571
580
Details are in the documentation of concat
572
581
fill_value : scalar, optional
573
582
Value to use for newly missing values
583
+ join : {'outer', 'inner', 'left', 'right', 'exact'}, optional
584
+ How to combine objects with different indexes.
574
585
575
586
Returns
576
587
-------
@@ -626,7 +637,8 @@ def auto_combine(datasets, concat_dim='_not_supplied', compat='no_conflicts',
626
637
627
638
return _old_auto_combine (datasets , concat_dim = concat_dim ,
628
639
compat = compat , data_vars = data_vars ,
629
- coords = coords , fill_value = fill_value )
640
+ coords = coords , fill_value = fill_value ,
641
+ join = join )
630
642
631
643
632
644
def _dimension_coords_exist (datasets ):
@@ -667,7 +679,7 @@ def _requires_concat_and_merge(datasets):
667
679
def _old_auto_combine (datasets , concat_dim = _CONCAT_DIM_DEFAULT ,
668
680
compat = 'no_conflicts' ,
669
681
data_vars = 'all' , coords = 'different' ,
670
- fill_value = dtypes .NA ):
682
+ fill_value = dtypes .NA , join = 'outer' ):
671
683
if concat_dim is not None :
672
684
dim = None if concat_dim is _CONCAT_DIM_DEFAULT else concat_dim
673
685
@@ -676,16 +688,17 @@ def _old_auto_combine(datasets, concat_dim=_CONCAT_DIM_DEFAULT,
676
688
677
689
concatenated = [_auto_concat (list (datasets ), dim = dim ,
678
690
data_vars = data_vars , coords = coords ,
679
- fill_value = fill_value )
691
+ fill_value = fill_value , join = join )
680
692
for vars , datasets in grouped ]
681
693
else :
682
694
concatenated = datasets
683
- merged = merge (concatenated , compat = compat , fill_value = fill_value )
695
+ merged = merge (concatenated , compat = compat , fill_value = fill_value ,
696
+ join = join )
684
697
return merged
685
698
686
699
687
700
def _auto_concat (datasets , dim = None , data_vars = 'all' , coords = 'different' ,
688
- fill_value = dtypes .NA ):
701
+ fill_value = dtypes .NA , join = 'outer' ):
689
702
if len (datasets ) == 1 and dim is None :
690
703
# There is nothing more to combine, so kick out early.
691
704
return datasets [0 ]
0 commit comments