Retrieve closest x and y coordinates (column, row indices) for the
specified geolocation (lon,lat) if inside area. If lon,lat is a point a
ValueError is raised if the return point is outside the area domain. If
lon,lat is a tuple of sequences of longitudes and latitudes, a tuple of
masked arrays are returned.

Input:

lon : point or sequence (list or array) of longitudes
lat : point or sequence (list or array) of latitudes

Changed in version 1.8.0: BaseDefinition no longer checks the validity of the provided
longitude and latitude coordinates to improve performance. Longitude
arrays are expected to be between -180 and 180 degrees, latitude -90
to 90 degrees. Use pyresample.utils.check_and_wrap to preprocess
your arrays.

The purpose of this class is to be able to adapt the area extent and size
of the area to a given set of longitudes and latitudes, such that e.g.
polar satellite granules can be resampled optimaly to a give projection.

By default, the projection is Oblique Mercator (omerc in proj.4), in
which case the right projection angle alpha is computed from the
swath centerline. For other projections, only the appropriate center of
projection and area extents are computed.

weight_funcs (list of function objects or function object, optional) – List of weight functions f(dist) to use for the weighting
of each channel 1 to k.
If only one channel is resampled weight_funcs is
a single function object.
Must be supplied when using ‘custom’ resample type

fill_value (int or None, optional) – Set undetermined pixels to this value.
If fill_value is None a masked array is returned
with undetermined pixels masked

weight_funcs (list of function objects or function object) – List of weight functions f(dist) to use for the weighting
of each channel 1 to k.
If only one channel is resampled weight_funcs is
a single function object.

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

The ms2gt C executables “ll2cr” and “fornav” were rewritten for the
Polar2Grid software package created by the Space Science Engineering Center
(SSEC)/Cooperative Institute for Meteorological Satellite Studies. They were
rewritten as a combination of C++ and Cython to make them more python friendly
by David Hoese and were then copied and modified here in pyresample. The
rewrite of “ll2cr” also included an important switch from using the “mapx”
library to using the more popular and capable pyproj (PROJ.4) library.

The EWA algorithm consists of two parts “ll2cr” and “fornav” and are described
below.

The “ll2cr” process is the first step in the EWA algorithm. It stands for
“latitude/longitude to column/row”. Its main purpose is to convert
input longitude and latitude coordinates to column and row coordinates
of the destination grid. These coordinates are then used in the next step
“fornav”.

The “fornav” or “Forward Navigation” step of the EWA algorithm is where
the actual Elliptical Weighted Averaging algorithm is run. The algorithm
maps input swath pixels to output grid pixels by averaging multiple input
pixels based on an elliptical region and other coefficients, some of which
are determined at run time.

For more information on these steps see the documentation for the
corresponding modules.

This algorithm works under the assumption that the data is observed
one scan line at a time. However, good results can still be achieved
for non-scan based data is provided if rows_per_scan is set to the
number of rows in the entire swath or by setting it to None.

rows_per_scan (int or None, optional) – Number of data rows for every observed scanline. If None then the
entire swath is treated as one large scanline.

fill (float/int or None, optional) – If data_in is made of numpy arrays then this represents the fill
value used to mark invalid data pixels. This value will also be
used in the output array(s). If None, then np.nan will be used
for float arrays and -999 will be used for integer arrays.

out (numpy array or tuple of numpy arrays, optional) – Specify a numpy array to be written to for each input array. This can
be used as an optimization by providing np.memmap arrays or other
array-like objects.

weight_count (int, optional) – number of elements to create in the gaussian weight table.
Default is 10000. Must be at least 2

weight_min (float, optional) – the minimum value to store in the last position of the
weight table. Default is 0.01, which, with a
weight_distance_max of 1.0 produces a weight of 0.01
at a grid cell distance of 1.0. Must be greater than 0.

weight_distance_max (float, optional) – distance in grid cell units at which to
apply a weight of weight_min. Default is
1.0. Must be greater than 0.

weight_delta_max (float, optional) – maximum distance in grid cells in each grid
dimension over which to distribute a single swath cell.
Default is 10.0.

weight_sum_min (float, optional) – minimum weight sum value. Cells whose weight sums
are less than weight_sum_min are set to the grid fill value.
Default is EPSILON.

maximum_weight_mode (bool, optional) – If False (default), a weighted average of
all swath cells that map to a particular grid cell is used.
If True, the swath cell having the maximum weight of all
swath cells that map to a particular grid cell is used. This
option should be used for coded/category data, i.e. snow cover.

Returns:

(valid grid points, output arrays) – The valid_grid_points tuple holds the number of output grid pixels that
were written with valid data. The second element in the tuple is a tuple of
output grid numpy arrays for each input array. If there was only one input
array provided then the returned tuple is simply the singe points integer
and single output grid array.