geoips.plugins.modules.interpolators.utils package#

Submodules#

geoips.plugins.modules.interpolators.utils.boxdefinitions module#

Classes for geometry operations allowing masked data in swath corners.

This package uses the pyresample geometry package as base classes:

# pyresample, Resampling of remote sensing image data in python # # Copyright (C) 2010-2015 # # Authors: # Esben S. Nielsen # Thomas Lavergne

class geoips.plugins.modules.interpolators.utils.boxdefinitions.Line(start, end)[source]#

Bases: object

A Line between two lat/lon points.

end = None#
intersection(other)[source]#

Identify intersection between two lines.

Says where, if two lines defined by the current line and the other_line intersect.

intersects(other_line)[source]#

Test two lines intersect.

Says if two lines defined by the current line and the other_line intersect. A line is defined as the shortest tracks between two points.

start = None#
class geoips.plugins.modules.interpolators.utils.boxdefinitions.MaskedCornersSwathDefinition(lons, lats, nprocs=1)[source]#

Bases: SwathDefinition

Swath defined by lons and lats.

Allows datasets with potentially masked data in the corners.

Parameters:
  • lons (numpy array) – Longitude values

  • lats (numpy array) – Latitude values

  • nprocs (int, optional) – Number of processor cores to be used for calculations.

shape#

Swath shape

Type:

tuple

size#

Number of elements in swath

Type:

int

ndims#

Swath dimensions

Type:

int

Properties#
----------
lons#

Swath lons

Type:

object

lats#

Swath lats

Type:

object

cartesian_coords#

Swath cartesian coordinates

Type:

object

property corners#

Return current area corners.

get_bounding_box_lonlats(npts=100)[source]#

Return lon/lats along bounding Arcs.

Parameters:

npts (int) – Number of points to return along each line

Returns:

  • (top, right, bottom, left) (4 tuples containing lists) – of len npts of lons/lats

  • retval = (list(tplons),list(tplats)), – (list(rtlons),list(rtlats)), (list(btlons),list(btlats)), (list(ltlons),list(ltlats))

  • eg for n=3 – ([tplon0,tplon1,tplon2],[tplat0,tplat1,tplat2]), ([rtlon0,rtlon1,rtlon2],[rtlat0,rtlat1,rtlat2]), ([btlon0,btlon1,btlon2],[btlat0,btlat1,btlat2]), ([ltlon0,ltlon1,ltlon2],[ltlat0,ltlat1,ltlat2]),

intersection(other)[source]#

Return current area intersection polygon corners.

other allows for potentially masked data in the corners.

Parameters:

other (object) – Instance of subclass of BaseDefinition

Returns:

(corner1, corner2, corner3, corner4)

Return type:

tuple of points

overlaps_minmaxlatlon(other)[source]#

Test current area overlaps other area.

This is based solely on the min/max lat/lon of areas, assuming the

boundaries to be along lat/lon lines.

Parameters:

other (object) – Instance of subclass of BaseDefinition

Returns:

overlaps

Return type:

bool

class geoips.plugins.modules.interpolators.utils.boxdefinitions.PlanarPolygonDefinition(lons, lats, nprocs=1)[source]#

Bases: CoordinateDefinition

Planar polygon definition.

property corners#

Return corners.

get_bounding_box_lonlats(npts=100)[source]#

Return array of lon/lats along the bounding lat/lon lines.

Parameters:

npts (int) – Number of points to return along each line

Returns:

  • (top, right, bottom, left) (4 tuples containing lists) – of len npts of lons/lats

  • retval = (list(tplons),list(tplats)), – (list(rtlons),list(rtlats)), (list(btlons),list(btlats)), (list(ltlons),list(ltlats))

  • eg for n=3 – ([tplon0,tplon1,tplon2],[tplat0,tplat1,tplat2]), ([rtlon0,rtlon1,rtlon2],[rtlat0,rtlat1,rtlat2]), ([btlon0,btlon1,btlon2],[btlat0,btlat1,btlat2]), ([ltlon0,ltlon1,ltlon2],[ltlat0,ltlat1,ltlat2]),

intersection(other)[source]#

Return current area intersection polygon corners against other.

Parameters:

other (object) – Instance of subclass of BaseDefinition

Returns:

(corner1, corner2, corner3, corner4)

Return type:

tuple of points

overlaps(other)[source]#

Test if the current area overlaps the other area.

This is based solely on the corners of areas, assuming the boundaries to be straight lines.

Parameters:

other (object) – Instance of subclass of BaseDefinition

Returns:

overlaps

Return type:

bool

overlaps_minmaxlatlon(other)[source]#

Determine if overlaps.

geoips.plugins.modules.interpolators.utils.boxdefinitions.get_2d_false_corners(box_def)[source]#

Identify false corners.

geoips.plugins.modules.interpolators.utils.boxdefinitions.planar_intersection_polygon(area_corners, segment_corners)[source]#

Get the intersection polygon between two areas.

geoips.plugins.modules.interpolators.utils.boxdefinitions.planar_point_inside(point, corners)[source]#

Identify point inside 4 corners.

This DOES NOT USE great circle arcs as area boundaries.

geoips.plugins.modules.interpolators.utils.interp_pyresample module#

Interpolation methods using pyresample routines.

geoips.plugins.modules.interpolators.utils.interp_pyresample.get_data_box_definition(source_name, lons, lats)[source]#

Obtain pyresample geometry definitions.

For use with pyresample based reprojections

Parameters:
  • source_name (str) – geoips source_name for data type

  • lons (ndarray) – Numpy array of longitudes, 0 to 360

  • lats (ndarray) – Numpy array of latitudes, -90 to 90

geoips.plugins.modules.interpolators.utils.interp_pyresample.interp_kd_tree(list_of_arrays, area_definition, data_box_definition, radius_of_influence, interp_type='nearest', sigmas=None, neighbours=None, nprocs=None, fill_value=None)[source]#

Interpolate using pyresample’s kd_tree.resample_nearest method.

Parameters:
  • list_of_array (list of numpy.ndarray) – list of arrays to be interpolated

  • area_definition (areadef) – pyresample area_definition object of current region of interest.

  • data_box_definition (datadef) – pyresample/geoips data_box_definition specifying region covered by source data.

  • radius_of_influence (float) – radius of influence for interpolation

  • interp_type (str, default='nearest') – One of ‘nearest’ or ‘gauss’ - kd_tree resampling methods.

  • sigmas (int, default=None) –

    Used for interp_type ‘gauss’ - multiplication factor for sigmas option:
    • sigmas = [sigmas]*len(list_of_arrays)

geoips.plugins.modules.interpolators.utils.interp_scipy module#

Interpolation routines from the scipy package.

geoips.plugins.modules.interpolators.utils.interp_scipy.interp_gaussian_kde(data_lons, data_lats, target_lons, target_lats, vw_method=None)[source]#

Interpolate a given array of non-uniform data using scipy.stats.gaussian_kde.

This is not finalized.

Parameters:
  • data_array (numpy.ma.core.MaskedArray) – numpy array of data to interpolate

  • data_lons (numpy.ma.core.MaskedArray) – numpy array of longitudes corresponding to original data, same shape as data_array

  • data_lats (numpy.ma.core.MaskedArray) – numpy array of latitudes corresponding to original data, same shape as data_array

  • target_lons (numpy.ma.core.MaskedArray) – 2d numpy array of desired longitudes

  • target_lats (numpy.ma.core.MaskedArray) – 2d numpy array of desired latitudes

  • bw_method (str) – Bandwidth selection method (see scipy.stats.gaussian_kde)|

See also

scipy.stats.gaussian_kde

geoips.plugins.modules.interpolators.utils.interp_scipy.interp_griddata(data_array, data_lons, data_lats, min_gridlon, max_gridlon, min_gridlat, max_gridlat, numx_grid, numy_grid, method='linear')[source]#

Interpolate a given array of non-uniform data to a specified grid.

Uses scipy.interpolate.griddata

Parameters:
  • data_array (numpy.ma.core.MaskedArray) – numpy array of original data to be interpolated

  • data_lons (numpy.ma.core.MaskedArray) – numpy array of longitudes corresponding to original data, same shape as data_array

  • data_lats (numpy.ma.core.MaskedArray) – numpy array of latitudes corresponding to original data, same shape as data_array

  • min_gridlon (float) –

    minimum desired lon for the output grid
    • -180.0 < min_gridlon < 180.0

  • max_gridlon (float) –

    maximum desired lon for the output grid
    • -180.0 < max_gridlon < 180.0

  • min_gridlat (float) –

    minimum desired lat for the output grid
    • -90.0 < min_gridlat < 90.0

  • max_gridlat (float) –

    maximum desired lat for the output grid
    • -90.0 < max_gridlat < 90.0

  • numx_grid (int) – number desired longitude points in the output grid

  • numy_grid (int) – number desired latitude points in the output grid

  • method (str, default='linear') – A string specifying the interpolation method to use for scipy.interpolate.griddata. One of ‘nearest’, ‘linear’ or ‘cubic’

Module contents#

Geoips interpolators utils init file.