pyresample.area_config module
Area config handling and creation utilities.
- exception pyresample.area_config.AreaNotFound
Bases:
KeyErrorException raised when specified are is no found in file.
- pyresample.area_config.convert_def_to_yaml(def_area_file, yaml_area_file)
Convert a legacy area def file to the yaml counter partself.
yaml_area_file will be overwritten by the operation.
- pyresample.area_config.create_area_def(area_id, projection, width=None, height=None, area_extent=None, shape=None, upper_left_extent=None, center=None, resolution=None, radius=None, units=None, optimize_projection=False, **kwargs)
Create AreaDefinition from whatever information is known.
- Parameters:
area_id (str) – ID of area
projection (pyproj CRS object, dict, str, int, tuple, object) – Projection parameters. This can be in any format understood by
pyproj.crs.CRS.from_user_input(), such as a pyproj CRS object, proj4 dict, proj4 string, EPSG integer code, or others.description (str, optional) – Description/name of area. Defaults to area_id
proj_id (str, optional) – ID of projection (deprecated)
units (str, optional) –
Units that provided arguments should be interpreted as. This can be one of ‘deg’, ‘degrees’, ‘meters’, ‘metres’, and any parameter supported by the cs2cs -lu command. Units are determined in the following priority:
units expressed with each variable through a DataArray’s attrs attribute.
units passed to
unitsunits used in
projectionmeters
width (str, optional) – Number of pixels in the x direction
height (str, optional) – Number of pixels in the y direction
area_extent (list, optional) – Area extent as a list (lower_left_x, lower_left_y, upper_right_x, upper_right_y)
shape (list, optional) – Number of pixels in the y and x direction (height, width)
upper_left_extent (list, optional) – Upper left corner of upper left pixel (x, y)
center (list, optional) – Center of projection (x, y)
resolution (list or float, optional) – Size of pixels: (dx, dy)
radius (list or float, optional) – Length from the center to the edges of the projection (dx, dy)
nprocs (int, optional) – Number of processor cores to be used
lons (numpy array, optional) – Grid lons
lats (numpy array, optional) – Grid lats
optimize_projection – Whether the projection parameters have to be optimized for a DynamicAreaDefinition.
- Returns:
area – If shape and area_extent are found, an AreaDefinition object is returned. If only shape or area_extent can be found, a DynamicAreaDefinition object is returned
- Return type:
pyresample.geometry.AreaDefinition or pyresample.geometry.DynamicAreaDefinition
- Raises:
ValueError: – If neither shape nor area_extent could be found
Notes
resolutionandradiuscan be specified with one value if dx == dyIf
resolutionandradiusare provided as angles, center must be given or findable. In such a case, they represent [projection x distance from center[0] to center[0]+dx, projection y distance from center[1] to center[1]+dy]
- pyresample.area_config.generate_area_def_rst_list(area_file)
Create rst list of available area definitions with overview plot.
- Parameters:
area_file (
str) – Path to area yaml file.- Return type:
str- Returns:
rst list formatted string.
- pyresample.area_config.get_area_def(area_id, area_name, proj_id, proj4_args, width, height, area_extent)
Construct AreaDefinition object from arguments.
- Parameters:
area_id (str) – ID of area
area_name (str) – Description of area
proj_id (str) – ID of projection
proj4_args (dict, CRS, or str) – Projection information passed to pyproj’s CRS object
width (int) – Number of pixel in x dimension
height (int) – Number of pixel in y dimension
area_extent (list | tuple) – Area extent as a list of ints (LL_x, LL_y, UR_x, UR_y)
- Returns:
area_def – AreaDefinition object
- Return type:
object
- pyresample.area_config.load_area(area_file_name, *regions)
Load area(s) from area file.
- Parameters:
area_file_name (str, pathlib.Path, stream, or list thereof) – List of paths or streams. Any str or pathlib.Path will be interpreted as a path to a file. Any stream will be interpreted as containing a yaml definition file. To read directly from a string, use
load_area_from_string().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:
- Raises:
AreaNotFound: – If a specified area name is not found
- pyresample.area_config.load_area_from_string(area_strs, *regions)
Load area(s) from area strings.
Like
load_area(), but load from string directly.For the opposite (i.e. to create a YAML string from an area), use
dump().- Parameters:
area_strs (str or List[str]) – Strings containing yaml definitions.
regions (str) – Regions to parse.
- 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:
- pyresample.area_config.parse_area_file(area_file_name, *regions)
Parse area information from area file.
- Parameters:
area_file_name (str or list) – One or more paths to area definition files
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