Applies either concat or merge to 1D list of datasets depending on value of concat_dim
(
datasets,
concat_dim,
compat: CompatOptions | CombineKwargDefault,
data_vars,
coords,
fill_value,
join: JoinOptions | CombineKwargDefault,
combine_attrs: CombineAttrsOptions,
)
| 305 | |
| 306 | |
| 307 | def _combine_1d( |
| 308 | datasets, |
| 309 | concat_dim, |
| 310 | compat: CompatOptions | CombineKwargDefault, |
| 311 | data_vars, |
| 312 | coords, |
| 313 | fill_value, |
| 314 | join: JoinOptions | CombineKwargDefault, |
| 315 | combine_attrs: CombineAttrsOptions, |
| 316 | ): |
| 317 | """ |
| 318 | Applies either concat or merge to 1D list of datasets depending on value |
| 319 | of concat_dim |
| 320 | """ |
| 321 | |
| 322 | if concat_dim is not None: |
| 323 | try: |
| 324 | combined = concat( |
| 325 | datasets, |
| 326 | dim=concat_dim, |
| 327 | data_vars=data_vars, |
| 328 | coords=coords, |
| 329 | compat=compat, |
| 330 | fill_value=fill_value, |
| 331 | join=join, |
| 332 | combine_attrs=combine_attrs, |
| 333 | ) |
| 334 | except ValueError as err: |
| 335 | if "encountered unexpected variable" in str(err): |
| 336 | raise ValueError( |
| 337 | "These objects cannot be combined using only " |
| 338 | "xarray.combine_nested, instead either use " |
| 339 | "xarray.combine_by_coords, or do it manually " |
| 340 | "with xarray.concat, xarray.merge and " |
| 341 | "xarray.align" |
| 342 | ) from err |
| 343 | else: |
| 344 | raise |
| 345 | else: |
| 346 | try: |
| 347 | combined = merge( |
| 348 | datasets, |
| 349 | compat=compat, |
| 350 | fill_value=fill_value, |
| 351 | join=join, |
| 352 | combine_attrs=combine_attrs, |
| 353 | ) |
| 354 | except AlignmentError as e: |
| 355 | e.add_note( |
| 356 | "If you are intending to concatenate datasets, please specify the concatenation dimension explicitly. " |
| 357 | "Using merge to concatenate is quite inefficient." |
| 358 | ) |
| 359 | raise e |
| 360 | |
| 361 | return combined |
| 362 | |
| 363 | |
| 364 | def _new_tile_id(single_id_ds_pair): |
no test coverage detected
searching dependent graphs…