gpm.visualization package

Contents

gpm.visualization package#

Submodules#

gpm.visualization.facetgrid module#

This module contains the FacetGrid classes.

class gpm.visualization.facetgrid.CartopyFacetGrid(data, projection, col: Hashable | None = None, row: Hashable | None = None, col_wrap: int | None = None, axes_pad: tuple[float, float] | None = None, add_colorbar: bool = True, cbar_kwargs: dict | None = None, fig_kwargs: dict | None = None, facet_height: float = 3.0, facet_aspect: float = 1.0)[source]#

Bases: CustomFacetGrid

optimize_layout()[source]#

Optimize the figure size and layout of the Figure.

This function must be called only once !

set_extent(extent)[source]#

Modify extent of all Cartopy subplots.

class gpm.visualization.facetgrid.CustomFacetGrid(data, col: Hashable | None = None, row: Hashable | None = None, col_wrap: int | None = None, axes_pad: tuple[float, float] | None = None, aspect: bool = True, add_colorbar: bool = True, facet_height: float = 3.0, facet_aspect: float = 1.0, cbar_kwargs: dict | None = None, fig_kwargs: dict | None = None, axes_class=None)[source]#

Bases: FacetGrid, ABC

adapt_fig_size()[source]#

Adjusts the figure height of the plot based on the aspect ratio of cartopy subplots.

This function is intended to be called after all plotting has been completed. It operates under the assumption that all subplots within the figure share the same aspect ratio.

The implementation is inspired by Mathias Hauser’s mplotutils set_map_layout function.

add_colorbar(**cbar_kwargs) None[source]#

Draw a colorbar.

remove_duplicated_axis_labels()[source]#

Remove axis labels which are not located on the left or bottom of the figure.

remove_title_dimension_prefix()[source]#

Remove the dimension prefix from the subplot labels.

set_title(title, horizontalalignment='center', **kwargs)[source]#

Add a title above all sublots.

The y argument controls the spacing to the subplots. Decreasing or increasing the y argument (from a default value of 1) reduce/increase the spacing.

class gpm.visualization.facetgrid.ImageFacetGrid(data, col: Hashable | None = None, row: Hashable | None = None, col_wrap: int | None = None, axes_pad: tuple[float, float] | None = None, aspect: bool = False, add_colorbar: bool = True, cbar_kwargs: dict | None = None, fig_kwargs: dict | None = None, facet_height: float = 3.0, facet_aspect: float = 1.0)[source]#

Bases: CustomFacetGrid

gpm.visualization.facetgrid.sanitize_facetgrid_plot_kwargs(plot_kwargs)[source]#

Remove defaults values set by FacetGrid.map_dataarray.

gpm.visualization.grid module#

This module contains functions to visualize GPM-API GRID data.

gpm.visualization.grid.plot_grid_image(da, x='lon', y='lat', ax=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot DataArray 2D field with cartopy.

gpm.visualization.grid.plot_grid_map(da, x='lon', y='lat', ax=None, add_colorbar=True, interpolation='nearest', add_background=True, fig_kwargs=None, subplot_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot DataArray 2D field with cartopy.

gpm.visualization.grid.plot_grid_mesh(xr_obj, x='lon', y='lat', ax=None, edgecolors='k', linewidth=0.1, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source]#

Plot GPM grid mesh in a cartographic map.

gpm.visualization.orbit module#

This module contains functions to visualize GPM-API ORBIT data.

gpm.visualization.orbit.plot_orbit_image(da, x='lon', y='lat', ax=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot DataArray 2D field with cartopy.

gpm.visualization.orbit.plot_orbit_map(da, ax=None, x='lon', y='lat', add_colorbar=True, add_swath_lines=True, add_background=True, rgb=False, fig_kwargs=None, subplot_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot DataArray 2D field with cartopy.

gpm.visualization.orbit.plot_orbit_mesh(da, ax=None, x='lon', y='lat', edgecolors='k', linewidth=0.1, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source]#

Plot GPM orbit granule mesh in a cartographic map.

gpm.visualization.orbit.plot_swath(ds, ax=None, facecolor='orange', edgecolor='black', alpha=0.4, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source]#

Plot GPM orbit granule.

gpm.visualization.orbit.plot_swath_lines(da, ax=None, x='lon', y='lat', linestyle='--', color='k', add_background=True, subplot_kwargs=None, fig_kwargs=None, **plot_kwargs)[source]#

Plot GPM orbit granule swath lines.

gpm.visualization.plot module#

This module contains basic functions for GPM-API data visualization.

gpm.visualization.plot.adapt_fig_size(ax, nrow=1, ncol=1)[source]#

Adjusts the figure height of the plot based on the aspect ratio of cartopy subplots.

This function is intended to be called after all plotting has been completed. It operates under the assumption that all subplots within the figure share the same aspect ratio.

Assumes that the first axis in the collection of axes is representative of all others. This means that all subplots are expected to have the same aspect ratio and size.

The implementation is inspired by Mathias Hauser’s mplotutils set_map_layout function.

gpm.visualization.plot.add_map_inset(ax, loc='upper left', inset_height=0.2, projection=None, inside_figure=True)[source]#

Adds an inset map to a matplotlib axis using Cartopy, highlighting the extent of the main plot.

This function creates a smaller map inset within a larger map plot to show a global view or contextual location of the main plot’s extent.

It uses Cartopy for map projections and plotting, and it outlines the extent of the main plot within the inset to provide geographical context.

Parameters:
  • ax ((matplotlib.axes.Axes, cartopy.mpl.geoaxes.GeoAxes)) – The main matplotlib or cartopy axis object where the geographic data is plotted.

  • loc (str, optional) – The location of the inset map within the main plot. Options include ‘lower left’, ‘lower right’, ‘upper left’, ‘upper right’. The default is ‘upper left’.

  • inset_height (float) – The size of the inset height, specified as a fraction of the figure’s height. For example, a value of 0.2 indicates that the inset’s height will be 20% of the figure’s height. The aspect ratio (of the map inset) will govern the inset_width.

  • inside_figure (bool, optional) – Determines whether the inset is constrained to be fully inside the figure bounds. If True (default), the inset is placed fully within the figure. If False, the inset can extend beyond the figure’s edges, allowing for a half-outside placement.

  • projection (cartopy.crs.Projection) – A cartopy projection. If None, am Orthographic projection centered on the extent center is used.

Returns:

ax2 – The Cartopy GeoAxesSubplot object for the inset map.

Return type:

cartopy.mpl.geoaxes.GeoAxes

Notes

The function adjusts the extent of the inset map based on the main plot’s extent, adding a slight padding for visual clarity. It then overlays a red outline indicating the main plot’s geographical extent.

Examples

>>> p = da.gpm.plot_map()
>>> add_map_inset(ax=p.axes, loc="upper left", inset_height=0.15)

This example creates a main plot with a specified extent and adds an upper-left inset map showing the global context of the main plot’s extent.

gpm.visualization.plot.add_optimize_layout_method(p)[source]#

Add a method to optimize the figure layout using monkey patching.

gpm.visualization.plot.create_grid_mesh_data_array(xr_obj, x, y)[source]#

Create a 2D mesh coordinates DataArray.

Takes as input the 1D coordinate arrays from an existing xarray object (Dataset or DataArray).

The function creates a 2D grid (mesh) of x and y coordinates and initializes the data values to NaN.

Parameters:
  • xr_obj (xarray.DataArray or xarray.Dataset) – The input xarray object containing the 1D coordinate arrays.

  • x (str) – The name of the x-coordinate in xr_obj.

  • y (str) – The name of the y-coordinate in xr_obj.

Returns:

da_mesh – A 2D xarray DataArray with mesh coordinates for x and y, and NaN values for data points.

Return type:

xarray.DataArray

Notes

The resulting DataArray has dimensions named ‘y’ and ‘x’, corresponding to the y and x coordinates respectively. The coordinate values are taken directly from the input 1D coordinate arrays, and the data values are set to NaN.

gpm.visualization.plot.get_antimeridian_mask(lons)[source]#

Get mask of longitude coordinates neighbors crossing the antimeridian.

gpm.visualization.plot.get_dataarray_extent(da, x='lon', y='lat')[source]#
gpm.visualization.plot.get_inset_bounds(ax, loc='upper right', inset_height=0.2, inside_figure=True, aspect_ratio=1)[source]#

Calculate the bounds for an inset axes in a matplotlib figure.

This function computes the normalized figure coordinates for placing an inset axes within a figure, based on the specified location, size, and whether the inset should be fully inside the figure bounds. It is designed to be used with matplotlib figures to facilitate the addition of insets (e.g., for maps or zoomed plots) at predefined positions.

Parameters:
  • loc (str) – The location of the inset within the figure. Valid options are ‘lower left’, ‘lower right’, ‘upper left’, and ‘upper right’. The default is ‘upper right’.

  • inset_height (float) – The size of the inset height, specified as a fraction of the figure’s height. For example, a value of 0.2 indicates that the inset’s height will be 20% of the figure’s height. The aspect ratio will govern the inset_width.

  • inside_figure (bool, optional) – Determines whether the inset is constrained to be fully inside the figure bounds. If True (default), the inset is placed fully within the figure. If False, the inset can extend beyond the figure’s edges, allowing for a half-outside placement.

  • aspect_ratio (float, optional) – The width-to-height ratio of the inset figure. A value greater than 1 indicates an inset figure wider than it is tall, and a value less than 1 indicates an inset figure taller than it is wide. The default value is 1.0, indicating a square inset figure.

Returns:

inset_bounds – The calculated bounds of the inset, in the format [x0, y0, width, height], where x0 and y0 are the normalized figure coordinates of the lower left corner of the inset, and width and height are the normalized width and height of the inset, respectively.

Return type:

list of float

gpm.visualization.plot.get_valid_pcolormesh_inputs(x, y, data, rgb=False, mask_data=True)[source]#

Infill invalid coordinates.

Interpolate the coordinates within the convex hull of data. Use nearest neighbour outside the convex hull of data.

This operation is required to plot with pcolormesh since it does not accept non-finite values in the coordinates.

If mask_data=True, data values with invalid coordinates are masked and a numpy masked array is returned. Masked data values are not displayed in pcolormesh ! If rgb=True, it assumes the RGB dimension is the last data dimension.

gpm.visualization.plot.infill_invalid_coords(xr_obj, x='lon', y='lat')[source]#

Infill invalid coordinates.

Interpolate the coordinates within the convex hull of data. Use nearest neighbour outside the convex hull of data.

gpm.visualization.plot.initialize_cartopy_plot(ax, fig_kwargs, subplot_kwargs, add_background)[source]#

Initialize figure for cartopy plot if necessary.

gpm.visualization.plot.is_generator(obj)[source]#
gpm.visualization.plot.plot_cartopy_background(ax)[source]#

Plot cartopy background.

gpm.visualization.plot.plot_colorbar(p, ax, cbar_kwargs=None)[source]#

Add a colorbar to a matplotlib/cartopy plot.

cbar_kwargs ‘size’ and ‘pad’ controls the size of the colorbar. and the padding between the plot and the colorbar.

p: matplotlib.image.AxesImage ax: cartopy.mpl.geoaxes.GeoAxesSubplot^

gpm.visualization.plot.plot_image(da, x=None, y=None, ax=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot data using imshow.

Parameters:
  • da (xr.DataArray) – xarray DataArray.

  • x (str, optional) – X dimension name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Y dimension name. If None, takes the first dimension. The default is None.

  • ax (cartopy.GeoAxes, optional) – The matplotlib axes where to plot the image. If None, a figure is initialized using the specified fig_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • interpolation (str, optional) – Argument to be passed to imshow. The default is “nearest”.

  • fig_kwargs (dict, optional) – Figure options to be passed to plt.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Subplot options to be passed to plt.subplots. The default is None. Only used if ax is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap.

gpm.visualization.plot.plot_labels(obj, label_name=None, max_n_labels=50, add_colorbar=True, interpolation='nearest', cmap='Paired', fig_kwargs=None, **plot_kwargs)[source]#
gpm.visualization.plot.plot_map(da, x='lon', y='lat', ax=None, add_colorbar=True, add_swath_lines=True, add_background=True, rgb=False, interpolation='nearest', fig_kwargs=None, subplot_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot data on a geographic map.

Parameters:
  • da (xr.DataArray) – xarray DataArray.

  • x (str, optional) – Longitude coordinate name. The default is “lon”.

  • y (str, optional) – Latitude coordinate name. The default is “lat”.

  • ax (cartopy.GeoAxes, optional) – The cartopy GeoAxes where to plot the map. If None, a figure is initialized using the specified fig_kwargs`and `subplot_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • add_swath_lines (bool, optional) – Whether to plot the swath sides with a dashed line. The default is True. This argument only applies for ORBIT objects.

  • add_background (bool, optional) – Whether to add the map background. The default is True.

  • rgb (bool, optional) – Whether the input DataArray has a rgb dimension. The default is False.

  • interpolation (str, optional) – Argument to be passed to imshow. Only applies for GRID objects. The default is “nearest”.

  • fig_kwargs (dict, optional) – Figure options to be passed to plt.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Dictionary of keyword arguments for Matplotlib subplots. Must contain the Cartopy CRS ‘projection’ key if specified. The default is None. Only used if ax is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap.

gpm.visualization.plot.plot_map_mesh(xr_obj, x='lon', y='lat', ax=None, edgecolors='k', linewidth=0.1, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source]#
gpm.visualization.plot.plot_map_mesh_centroids(xr_obj, x='lon', y='lat', ax=None, c='r', s=1, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source]#

Plot GPM orbit granule mesh centroids in a cartographic map.

gpm.visualization.plot.plot_patches(patch_gen, variable=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot patches.

gpm.visualization.plot.plot_sides(sides, ax, **plot_kwargs)[source]#

Plot boundary sides.

Expects a list of (lon, lat) tuples.

gpm.visualization.plot.preprocess_figure_args(ax, fig_kwargs=None, subplot_kwargs=None)[source]#
gpm.visualization.plot.preprocess_subplot_kwargs(subplot_kwargs)[source]#
gpm.visualization.plot.set_colorbar_fully_transparent(p)[source]#

Add a fully transparent colorbar.

This is useful for animation where the colorbar should not always in all frames but the plot area must be fixed.

gpm.visualization.plot_3d module#

This module contains functions for 3D visualization of GPM-API RADAR data.

class gpm.visualization.plot_3d.IsosurfaceSlider(vol, method='contour', isovalue=None)[source]#

Bases: object

update()[source]#
class gpm.visualization.plot_3d.OpacitySlider(pl_actor)[source]#

Bases: object

Opacity Slider for pyvista pl.add_slider_widget.

class gpm.visualization.plot_3d.OrthogonalSlicesSlider(vol, x=1, y=1, z=1)[source]#

Bases: object

update()[source]#
gpm.visualization.plot_3d.add_3d_isosurface_slider(vol, pl, method='contour', isovalue=None, **mesh_kwargs)[source]#

Add a 3D isosurface slider enabling to slide through the 3D volume.

gpm.visualization.plot_3d.add_3d_isosurfaces(vol, pl, isovalues=[30, 40, 50], opacities=[0.3, 0.5, 1], method='contour', style='surface', add_sliders=False, **mesh_kwargs)[source]#

Add 3D isosurface to a pyvista plotter object.

If add_sliders=True, isosurface opacity can be adjusted interactively.

gpm.visualization.plot_3d.add_3d_orthogonal_slices(vol, pl, x=None, y=None, z=None, add_sliders=False, **mesh_kwargs)[source]#

Add 3D orthogonal slices with interactive sliders.

gpm.visualization.plot_3d.create_pyvista_2d_surface(data_array, spacing=(1, 1, 1), origin=(0, 0, 0))[source]#

Create pyvista ImageData object from 2D xr.DataArray.

gpm.visualization.plot_3d.create_pyvista_3d_volume(data_array, spacing=(1, 1, 0.25), origin=(0, 0, 0))[source]#

Create pyvista ImageData object from 3D xr.DataArray.

gpm.visualization.plot_3d.get_slider_button_positions(i, num_buttons, spacing_factor=0.04)[source]#

Return the pointa and pointb parameters for pl.add_slider_widget.

gpm.visualization.profile module#

This module contains functions to visualize radar transects.

gpm.visualization.profile.get_transect_slices(xr_obj, direction='cross_track', lon=None, lat=None, variable=None, transect_kwargs={})[source]#

Define transect isel dictionary slices.

If lon and lat are provided, it returns the transect closest to such point. Otherwise, it returns the transect passing through the maximum value of ‘variable’

Parameters:
  • xr_obj (TYPE) – DESCRIPTION.

  • direction (TYPE, optional) – DESCRIPTION. The default is “cross_track”.

  • lon (TYPE, optional) – DESCRIPTION. The default is None.

  • lat (TYPE, optional) – DESCRIPTION. The default is None.

  • variable (TYPE, optional) – DESCRIPTION. The default is None.

  • transect_kwargs (TYPE, optional) – DESCRIPTION. The default is None.

Returns:

transect_slices – DESCRIPTION.

Return type:

TYPE

gpm.visualization.profile.plot_transect(da, ax=None, add_colorbar=True, zoom=True, fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot GPM transect.

gpm.visualization.profile.plot_transect_line(ds, ax, add_direction=True, text_kwargs={}, line_kwargs={}, **common_kwargs)[source]#
gpm.visualization.profile.select_transect(xr_obj, direction='cross_track', lon=None, lat=None, variable=None, transect_kwargs={}, keep_only_valid_variables=True)[source]#

gpm.visualization.title module#

This module contains utilities to define plot titles.

gpm.visualization.title.get_dataarray_title(da, prefix_product=True, add_timestep=True, time_idx=None, resolution='m', timezone='UTC')[source]#

Generate the GPM xarray DataArray title.

Parameters:
  • da (xr.DataArray) – GPM xarray DataArray.

  • prefix_product (bool, optional) – Whether to add the GPM product as prefix. The default is True.

  • add_timestep (bool, optional) – Whether to add time information to the title. The default is True. For GRID objects (like IMERG), the timestep is added only if the DataArray has 1 timestep.

  • time_idx (int, optional) – Index of timestep to select, instead of selecting the middle. The default is None.

  • resolution (str, optional) – The maximum temporal resolution to display. The default is “m” (for minutes).

  • timezone (str, optional) – The timezone of the time to display. The default is “UTC” (as the reference timezone of the dataset).

Returns:

title_str – Title of the DataArray.

Return type:

str

gpm.visualization.title.get_dataset_title(ds, add_timestep=True, time_idx=None, resolution='m', timezone='UTC')[source]#

Generate the GPM Dataset title.

Parameters:
  • ds (xr.Dataset) – GPM xarray Dataset.

  • add_timestep (bool, optional) – Whether to add time information to the title. The default is True. For GRID objects (like IMERG), the timestep is added only if the DataArray has 1 timestep.

  • time_idx (int, optional) – Index of timestep to select, instead of selecting the middle. The default is None.

  • resolution (str, optional) – The maximum temporal resolution to display. The default is “m” (for minutes).

  • timezone (str, optional) – The timezone of the time to display. The default is “UTC” (as the reference timezone of the dataset).

Returns:

title_str – Title of the Dataset.

Return type:

str

gpm.visualization.title.get_time_str(timesteps, time_idx=None, resolution='m', timezone='UTC')[source]#

Return the time string from a single timestep or array of timesteps.

If an array, it takes the timesteps in the middle of the array.

Module contents#

This directory contains the GPM-API data visualization tools.

gpm.visualization.add_map_inset(ax, loc='upper left', inset_height=0.2, projection=None, inside_figure=True)[source]#

Adds an inset map to a matplotlib axis using Cartopy, highlighting the extent of the main plot.

This function creates a smaller map inset within a larger map plot to show a global view or contextual location of the main plot’s extent.

It uses Cartopy for map projections and plotting, and it outlines the extent of the main plot within the inset to provide geographical context.

Parameters:
  • ax ((matplotlib.axes.Axes, cartopy.mpl.geoaxes.GeoAxes)) – The main matplotlib or cartopy axis object where the geographic data is plotted.

  • loc (str, optional) – The location of the inset map within the main plot. Options include ‘lower left’, ‘lower right’, ‘upper left’, ‘upper right’. The default is ‘upper left’.

  • inset_height (float) – The size of the inset height, specified as a fraction of the figure’s height. For example, a value of 0.2 indicates that the inset’s height will be 20% of the figure’s height. The aspect ratio (of the map inset) will govern the inset_width.

  • inside_figure (bool, optional) – Determines whether the inset is constrained to be fully inside the figure bounds. If True (default), the inset is placed fully within the figure. If False, the inset can extend beyond the figure’s edges, allowing for a half-outside placement.

  • projection (cartopy.crs.Projection) – A cartopy projection. If None, am Orthographic projection centered on the extent center is used.

Returns:

ax2 – The Cartopy GeoAxesSubplot object for the inset map.

Return type:

cartopy.mpl.geoaxes.GeoAxes

Notes

The function adjusts the extent of the inset map based on the main plot’s extent, adding a slight padding for visual clarity. It then overlays a red outline indicating the main plot’s geographical extent.

Examples

>>> p = da.gpm.plot_map()
>>> add_map_inset(ax=p.axes, loc="upper left", inset_height=0.15)

This example creates a main plot with a specified extent and adds an upper-left inset map showing the global context of the main plot’s extent.

gpm.visualization.plot_image(da, x=None, y=None, ax=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot data using imshow.

Parameters:
  • da (xr.DataArray) – xarray DataArray.

  • x (str, optional) – X dimension name. If None, takes the second dimension. The default is None.

  • y (str, optional) – Y dimension name. If None, takes the first dimension. The default is None.

  • ax (cartopy.GeoAxes, optional) – The matplotlib axes where to plot the image. If None, a figure is initialized using the specified fig_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • interpolation (str, optional) – Argument to be passed to imshow. The default is “nearest”.

  • fig_kwargs (dict, optional) – Figure options to be passed to plt.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Subplot options to be passed to plt.subplots. The default is None. Only used if ax is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap.

gpm.visualization.plot_labels(obj, label_name=None, max_n_labels=50, add_colorbar=True, interpolation='nearest', cmap='Paired', fig_kwargs=None, **plot_kwargs)[source]#
gpm.visualization.plot_map(da, x='lon', y='lat', ax=None, add_colorbar=True, add_swath_lines=True, add_background=True, rgb=False, interpolation='nearest', fig_kwargs=None, subplot_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot data on a geographic map.

Parameters:
  • da (xr.DataArray) – xarray DataArray.

  • x (str, optional) – Longitude coordinate name. The default is “lon”.

  • y (str, optional) – Latitude coordinate name. The default is “lat”.

  • ax (cartopy.GeoAxes, optional) – The cartopy GeoAxes where to plot the map. If None, a figure is initialized using the specified fig_kwargs`and `subplot_kwargs. The default is None.

  • add_colorbar (bool, optional) – Whether to add a colorbar. The default is True.

  • add_swath_lines (bool, optional) – Whether to plot the swath sides with a dashed line. The default is True. This argument only applies for ORBIT objects.

  • add_background (bool, optional) – Whether to add the map background. The default is True.

  • rgb (bool, optional) – Whether the input DataArray has a rgb dimension. The default is False.

  • interpolation (str, optional) – Argument to be passed to imshow. Only applies for GRID objects. The default is “nearest”.

  • fig_kwargs (dict, optional) – Figure options to be passed to plt.subplots. The default is None. Only used if ax is None.

  • subplot_kwargs (dict, optional) – Dictionary of keyword arguments for Matplotlib subplots. Must contain the Cartopy CRS ‘projection’ key if specified. The default is None. Only used if ax is None.

  • cbar_kwargs (dict, optional) – Colorbar options. The default is None.

  • **plot_kwargs – Additional arguments to be passed to the plotting function. Examples include cmap, norm, vmin, vmax, levels, … For FacetGrid plots, specify row, col and col_wrap.

gpm.visualization.plot_map_mesh(xr_obj, x='lon', y='lat', ax=None, edgecolors='k', linewidth=0.1, add_background=True, fig_kwargs=None, subplot_kwargs=None, **plot_kwargs)[source]#
gpm.visualization.plot_patches(patch_gen, variable=None, add_colorbar=True, interpolation='nearest', fig_kwargs=None, cbar_kwargs=None, **plot_kwargs)[source]#

Plot patches.