improver.regrid.idw module

Inverse distance weighting interpolation functions

ecef_coords(lats, lons)[source]

Transform latitude-longitude coordinates to earth centred, earth fixed cartesian XYZ coordinates.

Parameters:
  • lats (ndarray) – Latitude coordinates.

  • lons (ndarray) – Longitude coordinates.

Return type:

Tuple[ndarray, ndarray, ndarray]

Returns:

  • X transformed coordinates.

  • Y transformed coordinates.

  • Z transformed coordinates.

inverse_distance_weighting(idw_out_indexes, in_latlons, out_latlons, indexes, weights, in_classified, out_classified)[source]

Locating source points and calculating inverse distance weights for selective target points.

Parameters:
  • idw_out_indexes (ndarray) – Selected target points which will use Inverse Distance Weighting(idw) approach.

  • in_latlons (ndarray) – Source points’s latitude-longitudes.

  • out_latlons (ndarray) – Target points’s latitude-longitudes.

  • indexes (ndarray) – Array of source grid point number for all target grid points.

  • weights (ndarray) – Array of source grid point weighting for all target grid points.

  • in_classified (ndarray) – Land_sea type for source grid points (land ->True).

  • out_classified (ndarray) – Land_sea type for target grid points (land ->True).

Return type:

Tuple[ndarray, ndarray, ndarray]

Returns:

  • Updated Indexes - source grid point number for all target grid points.

  • Updated weights - array from each target grid point to its source grid points.

  • Output_points_no_match - special target points without matching source points.

nearest_input_pts(in_latlons, out_latlons, k)[source]

Find k nearest source (input) points to each target (output) point, using a KDtree.

Parameters:
  • in_latlons (ndarray) – Source grid points’ latitude-longitudes (N x 2).

  • out_latlons (ndarray) – Target grid points’ latitude-longitudes (M x 2).

  • k (int) – Number of points surrounding each output point.

Return type:

Tuple[ndarray, ndarray]

Returns:

  • Distances from target grid point to source grid points (M x K).

  • Indexes of those source points (M x K).