pyresample.utils package¶
Submodules¶
pyresample.utils.cartopy module¶
Classes for geometry operations
-
pyresample.utils.cartopy.from_proj(proj4_terms, globe=None, bounds=None)¶ Not-as-good version of cartopy’s ‘from_proj’ function.
The user doesn’t have a newer version of Cartopy so there is no from_proj function to use which does a fancier job of creating CRS objects from PROJ.4 strings than this does.
pyresample.utils.cf module¶
Load an AreaDefinition object from a netCDF/CF file.
-
pyresample.utils.cf.load_cf_area(nc_file, variable=None, y=None, x=None)¶ Load an AreaDefinition object from a netCDF/CF file.
- Parameters
nc_file (string or object) – path to a netCDF/CF file, or opened xarray.Dataset object
variable (string, optional) – name of the variable to load the AreaDefinition from. If the variable is not a CF grid_mapping container variable, it should be a variable having a :grid_mapping attribute. If variable is None the file will be searched for valid CF area definitions
y (string, optional) – name of the variable to use as ‘y’ axis of the CF area definition If y is None an appropriate ‘y’ axis will be deduced from the CF file
x (string, optional) – name of the variable to use as ‘x’ axis of the CF area definition If x is None an appropriate ‘x’ axis will be deduced from the CF file
- Returns
are_def, cf_info – cf_info holds info about how the AreaDefinition was defined in the CF file.
- Return type
geometry.AreaDefinition object, dict
pyresample.utils.proj4 module¶
-
pyresample.utils.proj4.convert_proj_floats(proj_pairs)¶ Convert PROJ.4 parameters to floats if possible.
-
pyresample.utils.proj4.proj4_dict_to_str(proj4_dict, sort=False)¶ Convert a dictionary of PROJ.4 parameters to a valid PROJ.4 string
-
pyresample.utils.proj4.proj4_radius_parameters(proj4_dict)¶ Calculate ‘a’ and ‘b’ radius parameters.
-
pyresample.utils.proj4.proj4_str_to_dict(proj4_str)¶ Convert PROJ.4 compatible string definition to dict
EPSG codes should be provided as “EPSG:XXXX” where “XXXX” is the EPSG number code. It can also be provided as
"+init=EPSG:XXXX"as long as the underlying PROJ library supports it (deprecated in PROJ 6.0+).Note: Key only parameters will be assigned a value of True.
pyresample.utils.rasterio module¶
-
pyresample.utils.rasterio.get_area_def_from_raster(source, area_id=None, name=None, proj_id=None, proj_dict=None)¶ Construct AreaDefinition object from raster.
- Parameters
source (str, Dataset, DatasetReader or DatasetWriter) – A file name. Also it can be
osgeo.gdal.Dataset,rasterio.io.DatasetReaderorrasterio.io.DatasetWriterarea_id (str, optional) – ID of area
name (str, optional) – Name of area
proj_id (str, optional) – ID of projection
proj_dict (dict, optional) – PROJ.4 parameters
- Returns
area_def – AreaDefinition object
- Return type
Module contents¶
Miscellaneous utility functions for pyresample.
-
pyresample.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
-
pyresample.utils.check_slice_orientation(sli)¶ Check that the slice is slicing the right way.
-
pyresample.utils.convert_def_to_yaml(*args, **kwargs)¶
-
pyresample.utils.create_area_def(*args, **kwargs)¶
-
pyresample.utils.fwhm2sigma(fwhm)¶ Calculate sigma for gauss function from FWHM (3 dB level)
-
pyresample.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
- Returns
(row_indices, col_indices)
- Return type
tuple of numpy arrays
-
pyresample.utils.generate_quick_linesample_arrays(source_area_def, target_area_def, nprocs=1)¶ Generate linesample arrays for quick grid resampling
- Parameters
- Returns
(row_indices, col_indices)
- Return type
tuple of numpy arrays
-
pyresample.utils.get_area_def(*args, **kwargs)¶
-
pyresample.utils.is_pyproj2()¶ Determine whether the current pyproj version is >= 2.0
-
pyresample.utils.load_area(*args, **kwargs)¶
-
pyresample.utils.parse_area_file(*args, **kwargs)¶
-
pyresample.utils.recursive_dict_update(d, u)¶ Recursive dictionary update using
Copied from:
-
pyresample.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