Skip to content

map_field

Import path: earth2studio.run.map_field

View source on GitHub

Documentation

Select the variables and domain of target from x.

Use it to fit fetched data or a model's output to another model's inputs, or to an output subset. batch, time and lead_time are kept from x, as are coordinates that target leaves empty. Exact contiguous selections are views; labels missing from a numeric coordinate select the nearest one. Curvilinear auxiliaries are never indexed as dimensions; model validation checks their geometry at the inference boundary.

map_field selects and never regrids. Nearest selection is accepted only when x covers target: a target label more than one source spacing beyond the source's range (a regional source on a global grid, or a -180..180 longitude source on a 0..360 grid) raises instead of copying edge values. Resolution is not checked, so a source coarser than the target (a 1 degree source on a 0.25 degree grid) repeats neighbouring values. Fetch such data with fetch_data(target_grid=...) or wrap the source in RegriddedSource.

Parameters:

  • x (DataArray) –

    Field to select from

  • target (DataArray | CoordSystem) –

    Signature to select, such as model.input_coords(), or a mapping of coordinate names to labels

Returns:

  • DataArray –

    x on target's coordinates, carrying target's grid metadata when target is a DataArray

Raises:

  • ValueError –

    If a label is missing from a non-numeric coordinate, a numeric coordinate of x does not cover target's range, or the geometry or CRS does not match a DataArray target.