pysiral.grid
Created on Sun Jun 11 19:24:04 2017
@author: Stefan
Classes
A container class for geospatial grids. The main components are |
|
Implements fast extraction of gridded data along a track using Image Interpolation. |
Module Contents
- class pysiral.grid.GridDefinition(preset=None)
Bases:
pysiral.core.legacy_classes.DefaultLoggingClassA container class for geospatial grids. The main components are a) the projection (based on pyproj) and b) the extent and grid size. The class is currently designed for stereographic/equal area projection types.
- _preset = None
- _metadata
- _griddef_filename = None
- _proj = None
- _proj_dict
- _extent_dict
- set_from_griddef_file(filename)
Initialize the object with a grid definition (.yaml) file. Examples can be found in pysiral/settings/griddef
- set_projection(**kwargs)
- proj(longitude, latitude, **kwargs)
- grid_indices(longitude, latitude)
Computes the grid indices the given lon/lat pairs would be sorted into (no clipping)
- get_grid_coordinates(mode='center')
Returns longitude/latitude points for each grid cell Note: mode keyword only for future use. center coordinates are returned by default
- set_extent(**kwargs)
- _set_proj()
- property hemisphere
- property grid_id
- property grid_tag
- property grid_name
- property resolution_tag
- property proj_dict
- property extent
- property area_extent
- property resolution
- property pyresample_area_def
Returns a pyresample.geometry.AreaDefinition instance
- property xc
- property yc
- property xc_km
- property yc_km
- property netcdf_vardef
- class pysiral.grid.GridTrajectoryExtract(trajectory_longitude: numpy.typing.NDArray, trajectory_latitude: numpy.typing.NDArray, griddef: dict | pysiral.core.legacy_classes.AttrDict)
Bases:
objectImplements fast extraction of gridded data along a track using Image Interpolation. This class computes the track coordinates in image coordinates upon initialization and then allows to extract the multiple variables.
Requirements are the longitude, latitude values of the trajectory and the projection and extent of the grid.
Usage
grid2track = GridTrajectoryExtract(track_longitude, track_latitude, grid_def) track_var_01 = grid2track.get_from_grid_variable(grid_var_01, outside_value=outside_value_01) track_var_02 = grid2track.get_from_grid_variable(grid_var_02, outside_value=outside_value_02) ...
- trajectory_longitude
- trajectory_latitude
- griddef
- p
- _get_track_image_coordinates() Tuple[numpy.typing.NDArray, numpy.typing.NDArray]
Computes and returns the image coordinates, by converting the trajectory lon/lat values to projection coordinates and scaling them tho the grid extent
- Raises:
None
- Returns:
image x coordindate, image y coordinate
- get_from_grid_variable(grid_var: numpy.typing.NDArray, order: int = 0, flipud: bool = False, outside_value: Any = np.nan) numpy.typing.NDArray
Returns the grid variable along the trajectory using interpolation with the specified order. If required the grid var can be flipped upside down before extraction (flipud = True).
- Parameters:
grid_var – The gridded variable
order – Order of the image interpolation (see scipy.ndimage.map_coordinates)
flipud – Flag if the grid variable should be flipped before extraction.
outside_value – Value to be used for part of the trajectory outside the grid
- Raises:
None
- Returns:
The grid variable extracted and interpolation for the trajectory location