stilt.flux.sample_field#

stilt.flux.sample_field(field, x, y, z=None, times=None)[source]#

Return the field’s value in the cell nearest each point.

A point outside the field horizontally gives NaN, since a missing mole fraction is unknown rather than zero (sample_flux() fills with zero instead). Longitudes are wrapped to the field’s convention (-180 to 180 or 0 to 360).

Parameters:
  • field (DataArray) – Field with horizontal dimensions (lat and lon, or y and x), and optionally a vertical dimension and time.

  • x (TypeAliasType) – Point coordinates: longitude and latitude for a lat/lon field.

  • y (TypeAliasType) – Point coordinates: longitude and latitude for a lat/lon field.

  • z (TypeAliasType | None) – Vertical coordinate of each point, in the units of the field’s vertical dimension. Required when the field has one. Matched to the nearest level, so a point above the top level takes the top level.

  • times (TypeAliasType | None) – Time of each point. Required when the field has a time dimension. Matched to the nearest time.

Returns:

One value per point.

Return type:

ndarray