pyresample API

pyresample.geometry

pyresample.image

pyresample.grid

pyresample.kd_tree

pyresample.bilinear

pyresample.utils

Utility functions for pyresample

exception utils.AreaNotFound

Exception raised when specified are is no found in file

utils.check_and_wrap(lons, lats)

Wrap longitude to [-180:+180[ and check latitude for validity.

Parameters:
  • lons (ndarray) – Longitude degrees
  • lats (ndarray) – Latitude degrees
Returns:

Longitude degrees in the range [-180:180[ and the original

latitude array

Return type:

lons, lats

Raises:

ValueError – If latitude array is not between -90 and 90

utils.convert_proj_floats(proj_pairs)

Convert PROJ.4 parameters to floats if possible.

utils.fwhm2sigma(fwhm)

Calculate sigma for gauss function from FWHM (3 dB level)

Parameters:fwhm (float) – FWHM of gauss function (3 dB level of beam footprint)
Returns:sigma – sigma for use in resampling gauss function
Return type:float
utils.generate_nearest_neighbour_linesample_arrays(source_area_def, target_area_def, radius_of_influence, nprocs=1)

Generate linesample arrays for nearest neighbour grid resampling

Parameters:
  • source_area_def (object) – Source area definition as geometry definition object
  • target_area_def (object) – Target area definition as geometry definition object
  • radius_of_influence (float) – Cut off distance in meters
  • nprocs (int, optional) – Number of processor cores to be used
Returns:

(row_indices, col_indices)

Return type:

tuple of numpy arrays

utils.generate_quick_linesample_arrays(source_area_def, target_area_def, nprocs=1)

Generate linesample arrays for quick grid resampling

Parameters:
  • source_area_def (object) – Source area definition as geometry definition object
  • target_area_def (object) – Target area definition as geometry definition object
  • nprocs (int, optional) – Number of processor cores to be used
Returns:

(row_indices, col_indices)

Return type:

tuple of numpy arrays

utils.get_area_def(area_id, area_name, proj_id, proj4_args, x_size, y_size, area_extent, rotation=0)

Construct AreaDefinition object from arguments

Parameters:
  • area_id (str) – ID of area
  • proj_id (str) – ID of projection
  • area_name (str) – Description of area
  • proj4_args (list or str) – Proj4 arguments as list of arguments or string
  • x_size (int) – Number of pixel in x dimension
  • y_size (int) – Number of pixel in y dimension
  • rotation (float) – Rotation in degrees (negative is cw)
  • area_extent (list) – Area extent as a list of ints (LL_x, LL_y, UR_x, UR_y)
Returns:

area_def – AreaDefinition object

Return type:

object

utils.load_area(area_file_name, *regions)

Load area(s) from area file

Parameters:
  • area_file_name (str) – Path to area definition file
  • regions (str argument list) – Regions to parse. If no regions are specified all regions in the file are returned
Returns:

area_defs – If one area name is specified a single AreaDefinition object is returned If several area names are specified a list of AreaDefinition objects is returned

Return type:

object or list

Raises:

AreaNotFound: – If a specified area name is not found

utils.parse_area_file(area_file_name, *regions)

Parse area information from area file

Parameters:
  • area_file_name (str) – Path to area definition file
  • regions (str argument list) – Regions to parse. If no regions are specified all regions in the file are returned
Returns:

area_defs – List of AreaDefinition objects

Return type:

list

Raises:

AreaNotFound: – If a specified area is not found

utils.proj4_dict_to_str(proj4_dict, sort=False)

Convert a dictionary of PROJ.4 parameters to a valid PROJ.4 string

utils.proj4_radius_parameters(proj4_dict)

Calculate ‘a’ and ‘b’ radius parameters.

Parameters:proj4_dict (str or dict) – PROJ.4 parameters
Returns:equatorial and polar radius
Return type:a (float), b (float)
utils.proj4_str_to_dict(proj4_str)

Convert PROJ.4 compatible string definition to dict

Note: Key only parameters will be assigned a value of True.

utils.recursive_dict_update(d, u)

Recursive dictionary update using

Copied from:

utils.wrap_longitudes(lons)

Wrap longitudes to the [-180:+180[ validity range (preserves dtype)

Parameters:lons (numpy array) – Longitudes in degrees
Returns:lons – Longitudes wrapped into [-180:+180[ validity range
Return type:numpy array

pyresample.data_reduce

Reduce data sets based on geographical information

data_reduce.get_valid_index_from_cartesian_grid(cart_grid, lons, lats, radius_of_influence)

Calculates relevant data indices using coarse data reduction of swath data by comparison with cartesian grid

Parameters:
  • chart_grid (numpy array) – Grid of area cartesian coordinates
  • lons (numpy array) – Swath lons
  • lats (numpy array) – Swath lats
  • data (numpy array) – Swath data
  • radius_of_influence (float) – Cut off distance in meters
Returns:

valid_index – Boolean array of same size as lons and lats indicating relevant indices

Return type:

numpy array

data_reduce.get_valid_index_from_lonlat_boundaries(boundary_lons, boundary_lats, lons, lats, radius_of_influence)

Find relevant indices from grid boundaries using the winding number theorem

data_reduce.get_valid_index_from_lonlat_grid(grid_lons, grid_lats, lons, lats, radius_of_influence)

Calculates relevant data indices using coarse data reduction of swath data by comparison with lon lat grid

Parameters:
  • chart_grid (numpy array) – Grid of area cartesian coordinates
  • lons (numpy array) – Swath lons
  • lats (numpy array) – Swath lats
  • data (numpy array) – Swath data
  • radius_of_influence (float) – Cut off distance in meters
Returns:

valid_index – Boolean array of same size as lon and lat indicating relevant indices

Return type:

numpy array

data_reduce.swath_from_cartesian_grid(cart_grid, lons, lats, data, radius_of_influence)

Makes coarse data reduction of swath data by comparison with cartesian grid

Parameters:
  • chart_grid (numpy array) – Grid of area cartesian coordinates
  • lons (numpy array) – Swath lons
  • lats (numpy array) – Swath lats
  • data (numpy array) – Swath data
  • radius_of_influence (float) – Cut off distance in meters
Returns:

(lons, lats, data) – Reduced swath data and coordinate set

Return type:

list of numpy arrays

data_reduce.swath_from_lonlat_boundaries(boundary_lons, boundary_lats, lons, lats, data, radius_of_influence)

Makes coarse data reduction of swath data by comparison with lon lat boundary

Parameters:
  • boundary_lons (numpy array) – Grid of area lons
  • boundary_lats (numpy array) – Grid of area lats
  • lons (numpy array) – Swath lons
  • lats (numpy array) – Swath lats
  • data (numpy array) – Swath data
  • radius_of_influence (float) – Cut off distance in meters
Returns:

(lons, lats, data) – Reduced swath data and coordinate set

Return type:

list of numpy arrays

data_reduce.swath_from_lonlat_grid(grid_lons, grid_lats, lons, lats, data, radius_of_influence)

Makes coarse data reduction of swath data by comparison with lon lat grid

Parameters:
  • grid_lons (numpy array) – Grid of area lons
  • grid_lats (numpy array) – Grid of area lats
  • lons (numpy array) – Swath lons
  • lats (numpy array) – Swath lats
  • data (numpy array) – Swath data
  • radius_of_influence (float) – Cut off distance in meters
Returns:

(lons, lats, data) – Reduced swath data and coordinate set

Return type:

list of numpy arrays

pyresample.plot

plot.area_def2basemap(area_def, **kwargs)

Get Basemap object from AreaDefinition

Parameters:
  • area_def (object) – geometry.AreaDefinition object
  • **kwargs (Keyword arguments) – Additional initialization arguments for Basemap
Returns:

bmap

Return type:

Basemap object

plot.ellps2axis(ellps_name)

Get semi-major and semi-minor axis from ellipsis definition

Parameters:ellps_name (str) – Standard name of ellipsis
Returns:(a, b)
Return type:semi-major and semi-minor axis
plot.save_quicklook(filename, area_def, data, vmin=None, vmax=None, label='Variable (units)', num_meridians=45, num_parallels=10, coast_res='110m', backend='AGG', cmap='jet')

Display default quicklook plot

Parameters:
  • filename (str) – path to output file
  • area_def (object) – geometry.AreaDefinition object
  • data (numpy array | numpy masked array) – 2D array matching area_def. Use masked array for transparent values
  • vmin (float, optional) – Min value for luminescence scaling
  • vmax (float, optional) – Max value for luminescence scaling
  • label (str, optional) – Label for data
  • num_meridians (int, optional) – Number of meridians to plot on the globe
  • num_parallels (int, optional) – Number of parallels to plot on the globe
  • coast_res ({'c', 'l', 'i', 'h', 'f'}, optional) – Resolution of coastlines
  • backend (str, optional) – matplotlib backend to use’
plot.show_quicklook(area_def, data, vmin=None, vmax=None, label='Variable (units)', num_meridians=45, num_parallels=10, coast_res='110m', cmap='jet')

Display default quicklook plot

Parameters:
  • area_def (object) – geometry.AreaDefinition object
  • data (numpy array | numpy masked array) – 2D array matching area_def. Use masked array for transparent values
  • vmin (float, optional) – Min value for luminescence scaling
  • vmax (float, optional) – Max value for luminescence scaling
  • label (str, optional) – Label for data
  • num_meridians (int, optional) – Number of meridians to plot on the globe
  • num_parallels (int, optional) – Number of parallels to plot on the globe
  • coast_res ({'c', 'l', 'i', 'h', 'f'}, optional) – Resolution of coastlines
Returns:

bmap

Return type:

Basemap object

pyresample.ewa