earth2studio.data
.prep_data_array#
- earth2studio.data.prep_data_array(da, device='cpu', interp_to=None, interp_method='nearest')[source]#
Prepares a data array from a data source for inference workflows by converting the data array to a torch tensor and the coordinate system to an OrderedDict.
If desired, xarray interpolation/regridding in the spatial domain can be used by passing a target coordinate system via the optional interp_to argument.
- Parameters:
da (xr.DataArray) – Input data array
device (torch.device, optional) – Torch devive to load data tensor to, by default “cpu”
interp_to (CoordSystem, optional) – If provided, the fetched data will be interpolated to the coordinates specified by lat/lon arrays in this CoordSystem
interp_method (str) – Interpolation method to use with xarray (by default ‘nearest’)
- Returns:
Tuple containing output tensor and coordinate OrderedDict
- Return type:
tuple[torch.Tensor, CoordSystem]