pyresample.bilinear package

Submodules

pyresample.bilinear.xarr module

XArray version of bilinear interpolation.

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

Bases: object

Bilinear interpolation using XArray.

get_bil_info()

Return neighbour info.

Returns

  • t__ (numpy array) – Vertical fractional distances from corner to the new points

  • s__ (numpy array) – Horizontal fractional distances from corner to the new points

  • valid_input_index (numpy array) – Valid indices in the input data

  • index_array (numpy array) – Mapping array from valid source points to target points

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

Resample using pre-computed resampling LUTs.

pyresample.bilinear.xarr.lonlat2xyz(lons, lats)

Convert geographic coordinates to cartesian 3D coordinates.

pyresample.bilinear.xarr.query_no_distance(target_lons, target_lats, valid_output_index, kdtree, neighbours, epsilon, radius)

Query the kdtree. No distances are returned.

Module contents

Code for resampling using bilinear algorithm for irregular grids.

The algorithm is taken from

http://www.ahinson.com/algorithms_general/Sections/InterpolationRegression/InterpolationIrregularBilinear.pdf

pyresample.bilinear.get_bil_info(source_geo_def, target_area_def, radius=50000.0, neighbours=32, nprocs=1, masked=False, reduce_data=True, segments=None, epsilon=0)

Calculate information needed for bilinear resampling.

source_geo_defobject

Geometry definition of source data

target_area_defobject

Geometry definition of target area

radiusfloat, optional

Cut-off distance in meters

neighboursint, optional

Number of neighbours to consider for each grid point when searching the closest corner points

nprocsint, optional

Number of processor cores to be used for getting neighbour info

maskedbool, optional

If true, return masked arrays, else return np.nan values for invalid points (default)

reduce_databool, optional

Perform initial coarse reduction of source dataset in order to reduce execution time

segmentsint or None

Number of segments to use when resampling. If set to None an estimate will be calculated

epsilonfloat, optional

Allowed uncertainty in meters. Increasing uncertainty reduces execution time

Returns

  • t__ (numpy array) – Vertical fractional distances from corner to the new points

  • s__ (numpy array) – Horizontal fractional distances from corner to the new points

  • input_idxs (numpy array) – Valid indices in the input data

  • idx_arr (numpy array) – Mapping array from valid source points to target points

pyresample.bilinear.get_sample_from_bil_info(data, t__, s__, input_idxs, idx_arr, output_shape=None)

Resample data using bilinear interpolation.

Parameters
  • data (numpy array) – 1d array to be resampled

  • t (numpy array) – Vertical fractional distances from corner to the new points

  • s (numpy array) – Horizontal fractional distances from corner to the new points

  • input_idxs (numpy array) – Valid indices in the input data

  • idx_arr (numpy array) – Mapping array from valid source points to target points

  • output_shape (tuple, optional) – Tuple of (y, x) dimension for the target projection. If None (default), do not reshape data.

Returns

result – Source data resampled to target geometry

Return type

numpy array

pyresample.bilinear.resample_bilinear(data, source_geo_def, target_area_def, radius=50000.0, neighbours=32, nprocs=1, fill_value=0, reduce_data=True, segments=None, epsilon=0)

Resample using bilinear interpolation.

datanumpy array

Array of single channel data points or (source_geo_def.shape, k) array of k channels of datapoints

source_geo_defobject

Geometry definition of source data

target_area_defobject

Geometry definition of target area

radiusfloat, optional

Cut-off distance in meters

neighboursint, optional

Number of neighbours to consider for each grid point when searching the closest corner points

nprocsint, optional

Number of processor cores to be used for getting neighbour info

fill_value{int, None}, optional

Set undetermined pixels to this value. If fill_value is None a masked array is returned with undetermined pixels masked

reduce_databool, optional

Perform initial coarse reduction of source dataset in order to reduce execution time

segmentsint or None

Number of segments to use when resampling. If set to None an estimate will be calculated

epsilonfloat, optional

Allowed uncertainty in meters. Increasing uncertainty reduces execution time

Returns

data – Source data resampled to target geometry

Return type

numpy array