nearest_gridpoint
- nearest_gridpoint(fs, lats, lons[, mode])
- nearest_gridpoint(fs, location[, mode])
- nearest_gridpoint(fs, gpt[, mode])
Returns the nearest gridpoint value from
fsfor a given location (or locations).- Parameters
fs (
Fieldset) – input fieldsetlats (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 geopointsmode (str) – specifies the way missing values are handled. The only allowed value is “valid”.
- Return type
number or list or ndarray or
Geopoints
fsmust be a gridded field.The nearest gridpoint extraction depends on the arguments:
locationdefines a single location. The return value is a number whenfsonly contains one field, and list otherwise.latsandlonscan 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 forlocation. For multiple locations an ndarray is returned.when
gptis specified only the first field offsis used. The result is aGeopointscontaining the the nearest gridpoint values for all the locations ingpt. Where it is not possible to generate a sensible value due to lack of valid data infs, the internal geopoints missing value is used (this value can be checked for with the built-in variable geo_missing_value or removed with the functionremove_missing_values()).
Parameter
modecontrols the return value when the nearest gridpoint value is a missing value or the location is out of the grid area:by default, None is returned for a single location and nan for multiple locations.
if
modeis ‘valid’ then from out of the surrounding gridpoints the nearest valid one is returned; None or nan will still be returned if all the surrounding points are missing.
Note
See also interpolate(), nearest_gridpoint_info() and surrounding_points_indexes().