pygmi.raster.modest_ioimage#

Modest IO Image.

Modification of Chris Beaumont’s mpl-modest-image package to allow the use of set_extent as well as better integration into PyGMI. It is changed to read data directly from disk.

Classes#

ModestImage

Computationally modest image class.

Functions#

imshow(axes, X[, cmap, norm, aspect, interpolation, ...])

Similar to matplotlib's imshow command, but produces a ModestImage.

extract_matched_slices([axes, shape, transform])

Determine the slice parameters to use, matched to the screen.

Module Contents#

class pygmi.raster.modest_ioimage.ModestImage(*args, **kwargs)#

Bases: matplotlib.image.AxesImage

Computationally modest image class.

ModestImage is an extension of the Matplotlib AxesImage class better suited for the interactive display of larger images. Before drawing, ModestImage resamples the data array based on the screen resolution and view window. This has very little affect on the appearance of the image, but can substantially cut down on computation since calculations of unresolved or clipped pixels are skipped.

The interface of ModestImage is the same as AxesImage. However, it does not currently support setting the ‘extent’ property. There may also be weird coordinate warping operations for images that I’m not aware of. Don’t expect those to work either.

set_data(A)#

Set data.

Parameters:

A (numpy/PIL Image A) – A numpy or PIL image.

Raises:

TypeError – Error when data has incorrect dimensions.

Return type:

None.

set_shade(doshade, cell=None, theta=None, phi=None, alpha=None)#

Set the shade information.

Parameters:
  • doshade (bool) – Check for whether to shade or not.

  • cell (float, optional) – Sunshade detail, between 1 and 100. The default is None.

  • theta (float, optional) – Sun inclination or elevation. The default is None.

  • phi (float, optional) – Sun declination or azimuth. The default is None.

  • alpha (float, optional) – Light reflectance, between 0 and 1. The default is None.

Return type:

None.

invalidate_cache()#

Invalidate cache.

Return type:

None.

set_extent(extent, **kwargs)#

Set extent.

Parameters:

extent (tuple) – Extent of data.

Return type:

None.

get_array()#

Override to return the full-resolution array.

Returns:

Return data array of full resolution.

Return type:

numpy array

get_cursor_data(event)#

Correct z-value display when zoomed.

Parameters:

event (matplotlib cursor event.) – Cursor event.

Returns:

z-value or NAN.

Return type:

float

format_cursor_data(data)#

Format z data on graph.

Parameters:

data (float) – Data value to display.

Returns:

zval – Formatted string to display.

Return type:

str

draw(renderer, *args, **kwargs)#

Draw.

draw_ternary()#

Draw ternary.

Return type:

None.

draw_sunshade(colormap=None)#

Apply sunshading.

Return type:

None.

set_clim_std(mult)#

Set the vmin and vmax to mult*std(self._A).

This routine only works on a 2D array.

Parameters:

mult (float) – Multiplier.

Return type:

None.

pygmi.raster.modest_ioimage.imshow(axes, X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, shape=None, filternorm=1, filterrad=4.0, imlim=None, resample=None, url=None, suncell=None, suntheta=None, sunphi=None, sunalpha=None, piter=iter, showlog=print, **kwargs)#

Similar to matplotlib’s imshow command, but produces a ModestImage.

Unlike matplotlib version, must explicitly specify axes.

pygmi.raster.modest_ioimage.extract_matched_slices(axes=None, shape=None, transform=IDENTITY_TRANSFORM)#

Determine the slice parameters to use, matched to the screen.

Indexing the full resolution array as array[y0:y1:sy, x0:x1:sx] returns a view well-matched to the axes’ resolution and extent

Parameters:
  • axes (Axes, optional) – Axes object to query. It’s extent and pixel size determine the slice parameters. The default is None.

  • shape (tuple, optional) – Tuple of the full image shape to slice into. Upper boundaries for slices will be cropped to fit within this shape. The default is None.

  • transform (rasterio transform, optional) – Rasterio transform. The default is IDENTITY_TRANSFORM.

Returns:

  • x0 (int) – x minimum.

  • x1 (int) – x maximum.

  • sx (int) – x stride.

  • y0 (int) – y minimum.

  • y1 (int) – y maximum.

  • sy (int) – y stride.