plotting module

Plotting utilities for VisuSat.

This module centralizes all visualization functions, ensuring that Cartopy/Matplotlib dependencies do not pollute data-access modules (Copernicus, EUMETSAT, …).

visusat.plotting.animate_geotiff_sequence(directory, *, cmap='Greys_r', fps=2, radiance=True, outfile='animation.gif', figsize=(7, 7), percentile_clip=(1, 99), projection=None, dpi=100)

Create an animation (GIF/MP4) from a directory of GeoTIFF files.

Parameters:
  • directory (str) – Folder containing GeoTIFFs (all frames).

  • cmap (str) – Matplotlib colormap.

  • fps (int) – Frames per second in output animation. Defaults to 2

  • outfile (str) – Output filename (gif or mp4).

  • figsize (tuple) – Size of the matplotlib figure.

  • percentile_clip ((pmin, pmax)) – Percentile limits for global colorbar normalisation.

  • projection (cartopy.crs.Projection, optional) – Defaults to "PlateCarree".

Returns:

Path to the generated animation.

Return type:

Path

visusat.plotting.plot_field(lon, lat, val, *, title='', subdomain=None, cmap='Spectral_r', cbar_label='unknown', figsize=(12, 6), dpi=200, proj=None, show_coastlines=True, show_borders=True, coast_resolution='110m', shading='auto', savepath=None, saveformat='png')

Plot a geophysical field on a map using Cartopy.

This function generates a 2D colormesh plot of a field defined on a regular longitude–latitude grid. It supports global plots as well as regional zooms, and includes coastlines, borders, and custom colorbar formatting. The output figure can optionally be saved to disk.

Parameters:
  • lon (2D np.ndarray) – Geographic grids.

  • lat (2D np.ndarray) – Geographic grids.

  • val (2D np.ndarray) – Field to plot. 2D data field to plot (e.g. radiance, SST, wind speed).

  • title (str, optional) – Figure title. Defaults to an empty string.

  • subdomain (list of float, optional) – Geographic extent specified as [lon_min, lon_max, lat_min, lat_max]. If provided, the plot is zoomed to this region. Defaults to None.

  • cmap (str, optional) – Matplotlib colormap name. Defaults to "Spectral_r".

  • cbar_label (str, optional) – Label for the colorbar. Defaults to "unknown".

  • figsize (tuple, optional) – Figure size in inches. Default (12, 6).

  • dpi (int, optional) – Resolution of output figure. Default 200.

  • proj (cartopy.crs.Projection, optional) – Map projection for the plot. Defaults to ccrs.PlateCarree().

  • show_coastlines (bool, optional) – Whether to draw coastlines. Default True.

  • show_borders (bool, optional) – Whether to draw national borders. Default True.

  • coast_resolution (str, optional) – Resolution for coastlines. Default `"110m"`.

  • shading (str, optional) – pcolormesh shading. Default `"auto"`

  • savepath (str or path-like, optional) – Path where the figure will be saved. If None, the figure is only returned. Defaults to None.

  • saveformat (str, optional) – Output format for saving (e.g. "png", "pdf"). Defaults to "png".

Returns:

A tuple (fig, ax) where:
  • fig is the created Matplotlib figure.

  • ax is the Cartopy GeoAxes object.

Return type:

tuple

Notes

  • lon and lat must match the shape of val.

  • subdomain must follow Plate Carrée coordinates.

  • If savepath is provided, the figure is saved with the specified format.