pyresample.bilinear._base module

Code for resampling using bilinear algorithm for irregular grids.

The algorithm is taken from here.

class pyresample.bilinear._base.BilinearBase(source_geo_def, target_geo_def, radius_of_influence, neighbours=32, epsilon=0, reduce_data=True)

Bases: object

Base class for bilinear interpolation.

Initialize resampler.

Parameters:
  • source_geo_def (object) – Geometry definition of source

  • target_geo_def (object) – Geometry definition of target

  • radius_of_influence (float) – Cut off distance in meters

  • neighbours (int, optional) – The number of neigbours to consider for each grid point

  • epsilon (float, optional) – Allowed uncertainty in meters. Increasing uncertainty reduces execution time

  • reduce_data (bool, optional) – Perform initial coarse reduction of source dataset in order to reduce execution time

__init__(source_geo_def, target_geo_def, radius_of_influence, neighbours=32, epsilon=0, reduce_data=True)

Initialize resampler.

Parameters:
  • source_geo_def (object) – Geometry definition of source

  • target_geo_def (object) – Geometry definition of target

  • radius_of_influence (float) – Cut off distance in meters

  • neighbours (int, optional) – The number of neigbours to consider for each grid point

  • epsilon (float, optional) – Allowed uncertainty in meters. Increasing uncertainty reduces execution time

  • reduce_data (bool, optional) – Perform initial coarse reduction of source dataset in order to reduce execution time

_create_empty_bil_info()
_create_resample_kdtree(kdtree_class=<class 'pykdtree.kdtree.KDTree'>, nprocs=1)

Set up kd tree on input.

_finalize_output_data(data, res, fill_value)
_get_fractional_distances()
_get_index_array()
_get_input_xy()
_get_output_xy()
_get_slices()
_get_target_proj_vectors()
_get_valid_input_index_and_input_coords()
_get_valid_input_index_and_kdtree(kdtree_class=<class 'pykdtree.kdtree.KDTree'>, nprocs=1)
_get_valid_output_indices()
_reduce_index_array(index_array)
_slice_data(data, fill_value)
get_bil_info(kdtree_class=<class 'pykdtree.kdtree.KDTree'>, nprocs=1)

Calculate bilinear neighbour info.

get_sample_from_bil_info(data, fill_value=None, output_shape=None)

Resample using pre-computed resampling LUTs.

load_resampling_info(filename)

Load bilinear resampling look-up tables and initialize the resampler.

resample(data, fill_value=None, nprocs=1)

Resample the given data.

save_resampling_info(filename)

Save bilinear resampling look-up tables.

pyresample.bilinear._base._calc_abc(corner_points, out_y, out_x)

Calculate coefficients for quadratic equation.

In this order of arguments used for _get_fractional_distances_irregular() and _get_fractional_distances_uprights(). For _get_fractional_distances_uprights switch order of pt_2 and pt_3.

pyresample.bilinear._base._check_fill_value(fill_value, dtype)

Check that fill value is usable for the data.

pyresample.bilinear._base._ensure_array(val)

Ensure that val is an array-like object.

pyresample.bilinear._base._get_corner(stride, valid, in_x, in_y, index_array)

Get closest set of coordinates from the valid locations.

pyresample.bilinear._base._get_four_closest_corners(in_x, in_y, out_x, out_y, neighbours, index_array)

Get bounding corners.

Get four closest locations from (in_x, in_y) so that they form a bounding rectangle around the requested location given by (out_x, out_y).

pyresample.bilinear._base._get_fractional_distances(corner_points, out_x, out_y)

Calculate vertical and horizontal fractional distances t and s.

pyresample.bilinear._base._get_fractional_distances_irregular(corner_points, out_y, out_x)

Get parameters for the case where none of the sides are parallel.

pyresample.bilinear._base._get_fractional_distances_parallellogram(points, out_y, out_x)

Get parameters for the case where uprights are parallel.

pyresample.bilinear._base._get_fractional_distances_uprights_parallel(corner_points, out_y, out_x)

Get parameters for the case where uprights are parallel.

pyresample.bilinear._base._get_input_xy(source_geo_def, proj, valid_input_index, index_array)

Get x/y coordinates for the input area and reduce the data.

pyresample.bilinear._base._get_output_xy(target_geo_def)
pyresample.bilinear._base._get_raveled_lonlats(geo_def)
pyresample.bilinear._base._get_stride_and_valid_corner_indices(out_x, out_y, in_x, in_y, neighbours)
pyresample.bilinear._base._get_valid_input_index(source_geo_def, target_geo_def, reduce_data, radius_of_influence)

Find indices of reduced input data.

pyresample.bilinear._base._invalid_s_and_t_to_nan(t__, s__)
pyresample.bilinear._base._np_where_for_multiple_arrays(idxs, values_for_idxs, otherwise_arrays)
pyresample.bilinear._base._query_no_distance(target_lons, target_lats, valid_output_index, kdtree, neighbours, epsilon, radius)

Query the kdtree. No distances are returned.

pyresample.bilinear._base._resample(corner_points, fractional_distances)
pyresample.bilinear._base._slice2d(values, sl_x, sl_y, mask, fill_value)
pyresample.bilinear._base._slice3d(values, sl_x, sl_y, mask, fill_value)
pyresample.bilinear._base._slice_2d_with_stride_and_indices_for_multiple_arrays(arrays, stride, idxs)
pyresample.bilinear._base._solve_another_fractional_distance(f__, y_corners, out_y)

Solve parameter t__ from s__, or vice versa.

For solving s__, switch order of y_2 and y_3.

pyresample.bilinear._base._solve_quadratic(a__, b__, c__, min_val=0.0, max_val=1.0)

Solve quadratic equation.

Solve quadratic equation and return the valid roots from interval [min_val, max_val].

pyresample.bilinear._base._tile_output_coordinate_vector(vector, neighbours)
pyresample.bilinear._base._update_fractional_distances(func, t__, s__, corner_points, out_x, out_y)
pyresample.bilinear._base.array_slice_for_multiple_arrays(idxs, data)

Slices multiple arrays using the same indices.

pyresample.bilinear._base.find_indices_outside_min_and_max(data, min_val, max_val)

Return array indices outside the given minimum and maximum values.

pyresample.bilinear._base.get_slicer(data)

Get slicing function for 2D or 3D arrays, depending on the data.

pyresample.bilinear._base.get_valid_indices_from_lonlat_boundaries(target_geo_def, source_lons, source_lats, radius_of_influence)

Get valid indices from lonlat boundaries.

pyresample.bilinear._base.is_swath_to_grid_or_grid_to_grid(source_geo_def, target_geo_def)

Check whether the resampling is from swath or grid to grid.

pyresample.bilinear._base.mask_coordinates(lons, lats)

Mask invalid coordinate values.