dctools.data.datasets.dataloader.add_time_dim

dctools.data.datasets.dataloader.add_time_dim(ds, input_df, n_points_dim, time_coord, idx)

Ensure that dataset has a ‘time’ dimension compatible with swath/n-points structure.

Covers cases:
  • No time info available (fallback: mid_time from metadata).

  • One unique time value for all points.

  • Multiple time values (per-point time).

  • Existing time coordinate.

Parameters:
  • ds (xarray.Dataset) – The xarray Dataset to process.

  • input_df (pandas.DataFrame) – The metadata pandas DataFrame containing time information (date_start, date_end).

  • n_points_dim (str) – The name of the dimension representing data points.

  • time_coord (str | None) – The name of the existing time coordinate in ds, if any.

  • idx (int) – Index of the current item in input_df.

Returns:

The dataset with a properly formatted ‘time’ dimension/coordinate.

Return type:

xr.Dataset