metobs_toolkit.sensordata.SensorData.to_xr#

SensorData.to_xr() xrDataset[source]#

Convert Sensordata (observations, including labels) to an xarray.Dataset.

The returned Dataset contains one variable named after the observation type (e.g. ‘temperature’). Its DataArray has:

  • kind dimension with two entries:

    • ‘obs’ -> the measured (and possibly processed) numerical values

    • ‘label’ -> the associated integer / categorical QC or gap labels

  • datetime dimension with the observation timestamps.

The ‘obs’ slice holds the physical observation values. The ‘label’ slice holds the label codes; QC and gap-fill method metadata are stored as attributes on that slice (accessible via the DataArray attributes).

Parameters:
  • sensordata (Sensordata) – Sensor data object with ‘value’ and ‘label’ columns.

  • fmt_datetime_coordinate (bool, optional) – If True, format datetime for CF compliance. Default is True.

Returns:

Dataset with dimensions (‘kind’, ‘datetime’), where kind=[‘obs’, ‘label’].

Return type:

xarray.Dataset