earth2studio.data
.fetch_data#
- earth2studio.data.fetch_data(source, time, variable, lead_time=array([0], dtype='timedelta64[h]'), device='cpu', interp_to=None, interp_method='nearest')[source]#
Utility function to fetch data for models and load data on the target device. 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:
source (DataSource) – The data source to fetch from
time (TimeArray) – Timestamps to return data for (UTC).
variable (VariableArray) – Strings or list of strings that refer to variables to return
lead_time (LeadTimeArray, optional) – Lead times to fetch for each provided time, by default np.array(np.timedelta64(0, “h”))
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]