earth2studio.utils.coords.map_coords#

earth2studio.utils.coords.map_coords(x, input_coords, output_coords, method='nearest')[source]#

A basic interpolation util to map between coordinate systems with common dimensions. Namely, output_coords should consist of keys are present in input_coords. Note that output_coords do not need have all the dimensions of the input_coords. Does not support more advanced interpolation, such as between a regular and curvilinear grid. For such use-cases, use fetch_data or prep_data_array from data/utils.

Parameters:
  • x (torch.Tensor) – Input data to map

  • input_coords (CoordSystem) – Respective input coordinate system

  • output_coords (CoordSystem) – Target output coordinates to map.

  • method (Literal["nearest"], optional) – Method to use for mapping numeric coordinates, by default “nearest”

Returns:

Mapped data and coordinate system.

Return type:

tuple[torch.Tensor, CoordSystem]

Warning

Use this function with caution. Only certain coordinate transformations are supported / tested. Consider doing complex transforms manually in the inference pipeline.

Raises:
  • KeyError: – If output coordinate has a dimension not in the input coordinate

  • ValueError – If value in non-numeric output coordinate is not in input coordinate If asked to interpolate between 2D lat/lon (curvilinear) coordinates

Parameters:
  • x (Tensor)

  • input_coords (OrderedDict[str, ndarray])

  • output_coords (OrderedDict[str, ndarray])

  • method (Literal['nearest'])

Return type:

tuple[Tensor, OrderedDict[str, ndarray]]

Examples using earth2studio.utils.coords.map_coords#

Generative Downscaling

Generative Downscaling

Statistical Inference

Statistical Inference