from_xarray#

gpjax.xarray.from_xarray(obj, target, inputs, *, dropna=True)[source]#

Flatten labelled xarray data into a Dataset.

Every input is broadcast onto the target’s grid, so an input on fewer dims (e.g. elevation(lat, lon) for a (time, lat, lon) target) repeats along the rest. Datetime inputs become float days since their earliest timestamp.

Parameters:
  • obj (Dataset | DataArray) – The labelled data. A DataArray must be named, and that name is the target.

  • target (str) – Name of the data variable to model. Its dims define the grid.

  • inputs (Sequence[str]) – Coordinates and/or data variables to use as inputs, in the order of the columns of X.

  • dropna (bool) – Drop grid cells where the target or any input is NaN. When False, such cells raise instead.

Returns:

The flattened Dataset and the GridSpec needed to map predictions back onto the grid.

Raises:
  • ValueError – If a name is missing, inputs is empty, repeats a name or includes the target, an input has a dim the target lacks, a DataArray is unnamed, or no cells survive NaN handling (or any NaN is present when dropna=False).

  • TypeError – If inputs is a single string, or the target or an input is not numeric (inputs may also be datetime64).

Return type:

tuple[Dataset, GridSpec]

Expand for references to gpjax.xarray.from_xarray

Gridded Data with xarray