interpolate

interpolate(fs, lats, lons)
interpolate(fs, location)
interpolate(fs, gpt)

Interpolate the values of fs to a given location(s) using bilinear interpolation.

Parameters
  • fs (Fieldset) – input fieldset

  • lats (number or ndarray) – target latitude(s)

  • lons (number or ndarray) – target longitudes(s)

  • location (list) – single target location defined as a list of [lat, lon]

  • gpt (Geopoints) – input geopoints

Return type

number or ndarray or Geopoints or None

The interpolated point extraction depends on the arguments:

  • location defines a single location. The return value is a number when fs only contains one field, and a list otherwise. Where it is not possible to generate a sensible value due to lack of valid data in fs, None is returned.

  • lats and lons can define either a single location (as number) or multiple locations (as ndarray). If a single location is specified the return value is the same as for location. For multiple locations an ndarray is returned (or a list of ndarrays if there are multiple fields).

  • when gpt is specified only the first field of fs is used. The result is a Geopoints containing the the nearest gridpoint values for all the locations in gpt and taking the date, time and level from fs. Where it is not possible to generate a sensible value due to lack of valid data in fs, NaN is used (this value can be removed from the output with the function remove_missing_values()).

Note

See also nearest_gridpoint().