from_xarray#

gpjax.xarray.from_xarray(obj, target, inputs, *, transforms=(), 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. The transforms then run in order, fitted on the kept cells, to give the columns of X; GridSpec.columns names them.

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 before any transforms.

  • transforms (Sequence[InputTransform]) – Input transforms, such as Standardise, UnitSphere or Cyclic, applied in order.

  • 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, no cells survive NaN handling (or any NaN is present when dropna=False), or a transform rejects its columns.

  • 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

Infilling Global Surface Temperature

Working with Gridded Data