MCPcopy
hub / github.com/pydata/xarray / combine_by_coords

Function combine_by_coords

xarray/structure/combine.py:798–1146  ·  view source on GitHub ↗

Attempt to auto-magically combine the given datasets (or data arrays) into one by using dimension coordinates. This function attempts to combine a group of datasets along any number of dimensions into a single entity by inspecting coords and metadata and using a combination of

(
    data_objects: Iterable[Dataset | DataArray] = [],
    compat: CompatOptions | CombineKwargDefault = _COMPAT_DEFAULT,
    data_vars: Literal["all", "minimal", "different"]
    | None
    | list[str]
    | CombineKwargDefault = _DATA_VARS_DEFAULT,
    coords: str | CombineKwargDefault = _COORDS_DEFAULT,
    fill_value: object = dtypes.NA,
    join: JoinOptions | CombineKwargDefault = _JOIN_DEFAULT,
    combine_attrs: CombineAttrsOptions = "no_conflicts",
)

Source from the content-addressed store, hash-verified

796
797
798def combine_by_coords(
799 data_objects: Iterable[Dataset | DataArray] = [],
800 compat: CompatOptions | CombineKwargDefault = _COMPAT_DEFAULT,
801 data_vars: Literal["all", "minimal", "different"]
802 | None
803 | list[str]
804 | CombineKwargDefault = _DATA_VARS_DEFAULT,
805 coords: str | CombineKwargDefault = _COORDS_DEFAULT,
806 fill_value: object = dtypes.NA,
807 join: JoinOptions | CombineKwargDefault = _JOIN_DEFAULT,
808 combine_attrs: CombineAttrsOptions = "no_conflicts",
809) -> Dataset | DataArray:
810 """
811
812 Attempt to auto-magically combine the given datasets (or data arrays)
813 into one by using dimension coordinates.
814
815 This function attempts to combine a group of datasets along any number of
816 dimensions into a single entity by inspecting coords and metadata and using
817 a combination of concat and merge.
818
819 Will attempt to order the datasets such that the values in their dimension
820 coordinates are monotonic along all dimensions. If it cannot determine the
821 order in which to concatenate the datasets, it will raise a ValueError.
822 Non-coordinate dimensions will be ignored, as will any coordinate
823 dimensions which do not vary between each dataset.
824
825 Aligns coordinates, but different variables on datasets can cause it
826 to fail under some scenarios. In complex cases, you may need to clean up
827 your data and use concat/merge explicitly (also see `combine_nested`).
828
829 Works well if, for example, you have N years of data and M data variables,
830 and each combination of a distinct time period and set of data variables is
831 saved as its own dataset. Also useful for if you have a simulation which is
832 parallelized in multiple dimensions, but has global coordinates saved in
833 each file specifying the positions of points within the global domain.
834
835 Parameters
836 ----------
837 data_objects : Iterable of Datasets or DataArrays
838 Data objects to combine.
839
840 compat : {"identical", "equals", "broadcast_equals", "no_conflicts", "override"}, \
841 default: "no_conflicts"
842 String indicating how to compare variables of the same name for
843 potential conflicts:
844
845 - "broadcast_equals": all values must be equal when variables are
846 broadcast against each other to ensure common dimensions.
847 - "equals": all values and dimensions must be the same.
848 - "identical": all values, dimensions and attributes must be the
849 same.
850 - "no_conflicts": only values which are not null in both datasets
851 must be equal. The returned dataset then contains the combination
852 of all non-null values.
853 - "override": skip comparing and pick variable from first dataset
854
855 data_vars : {"minimal", "different", "all", None} or list of str, default: "all"

Calls 8

DatasetClass · 0.90
DataArrayClass · 0.90
mergeFunction · 0.90
groupby_defaultdictFunction · 0.85
_to_temp_datasetMethod · 0.80
_from_temp_datasetMethod · 0.80
to_datasetMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…