topostats#

Topostats.

Submodules#

Attributes#

Classes#

ImageGrainCrops

Dataclass for storing the crops of grains in an image.

Colormap

Class for setting the Colormap.

TopoStats

Class for storing TopoStats objects.

Functions#

setup_logger(→ logging.Logger)

Logger setup.

Package Contents#

class topostats.ImageGrainCrops[source]#

Dataclass for storing the crops of grains in an image.

above#

Grains in the above direction.

Type:

GrainCropDirection | None

below#

Grains in the below direction.

Type:

GrainCropDirection | None

above: GrainCropsDirection | None#
below: GrainCropsDirection | None#
__eq__(other: object) bool[source]#

Check if two ImageGrainCrops objects are equal.

Parameters:

other (object) – Object to compare to.

Returns:

True if the objects are equal, False otherwise.

Return type:

bool

image_grain_crops_to_dict() dict[str, numpy.typing.NDArray[numpy.bool_] | dict[str:Any]][source]#

Convert ImageGrainCrops to dictionary indexed by attributes.

Returns:

Dictionary indexed by attribute of the grain attributes.

Return type:

dict[str, Any]

debug_locate_difference(other: object) None[source]#

Debug function to find the culprit when two ImageGrainCrops objects are not equal.

Parameters:

other (object) – Object to compare to.

Raises:

ValueError – If the objects are not equal.

topostats.setup_logger(log_name: str = LOGGER_NAME) logging.Logger[source]#

Logger setup.

The logger for the module is initialised when the module is loaded (as this functions is called from __init__.py). This creates two stream handlers, one for general output and one for errors which are formatted differently (there is greater information in the error formatter). To use in modules import the ‘LOGGER_NAME’ and create a logger as shown in the Examples, it will inherit the formatting and direction of messages to the correct stream.

Parameters:

log_name (str) – Name under which logging information occurs.

Returns:

Logger object.

Return type:

logging.Logger

Examples

To use the logger in (sub-)modules have the following.

import logging from topostats.logs.logs import LOGGER_NAME

LOGGER = logging.getLogger(LOGGER_NAME)

LOGGER.info(‘This is a log message.’)

class topostats.Colormap(name: str = 'nanoscope')[source]#

Class for setting the Colormap.

Parameters:

name (str) – Name of colormap to use.

name = 'nanoscope'#
cmap = None#
__str__() str[source]#

Return string representation of object.

Returns:

String detailing the colormap.

Return type:

str

set_cmap(name: str) None[source]#

Set the ColorMap.

Parameters:

name (str) – Name of the colormap to return.

get_cmap() matplotlib.cm[source]#

Return the matplotlib.cm colormap object.

Returns:

Matplotlib Color map object.

Return type:

matplotlib.cm

static nanoscope() matplotlib.colors.LinearSegmentedColormap[source]#

Matplotlib compatible colormap that replicates the Bruker Nanoscope colorscale.

The colormap is implemented in Gwyddion’s GwyGradient via ‘Nanoscope.txt’.

Returns:

MatplotLib LinearSegmentedColourmap that replicates Bruker Nanoscope colorscale.

Return type:

LinearSegmentedColormap

static gwyddion() matplotlib.colors.LinearSegmentedColormap[source]#

Set RGBA colour map for the Gwyddion.net colour gradient.

Returns:

The ‘gwyddion’ colormap.

Return type:

LinearSegmentedColormap

static blue() matplotlib.colors.ListedColormap[source]#

Set RGBA colour map of just the colour blue.

Returns:

The ‘blue’ colormap.

Return type:

ListedColormap

static blue_purple_green() matplotlib.colors.ListedColormap[source]#

RGBA colour map of just the colour blue/purple/green.

Returns:

The ‘blue/purple/green’ colormap.

Return type:

ListedColormap

topostats.LOGGER#
topostats.__version__#
topostats.__release__ = ''#
class topostats.TopoStats[source]#

Class for storing TopoStats objects.

image_grain_crops#

ImageGrainCrops of processed image.

Type:

ImageGrainCrops | None

filename#

Filename.

Type:

str | None

pixel_to_nm_scaling#

Pixel to nanometre scaling.

Type:

str | None

img_path#

Original path to image.

Type:

str | None

image#

Flattened image (post ‘’Filter()’’).

Type:

npt.NDArray | None

image_original#

Original image.

Type:

npt.NDArray | None

topostats_version#

TopoStats version.

Type:

str | None

property image_grain_crops: grains.ImageGrainCrops#

Getter for the Image Grain Crops.

Returns:

Image Grain Crops.

Return type:

ImageGrainCrops

property filename: str#

Getter for the ‘’filename’’ attribute.

Returns:

Image filename.

Return type:

str

property pixel_to_nm_scaling: str#

Getter for the ‘’pixel_to_nm_scaling’’ attribute.

Returns:

Image ‘’pixel_to_nm_scaling’’.

Return type:

str

property img_path: pathlib.Path#

Getter for the ‘’img_path’’ attribute.

Returns:

Path to original image on disk.

Return type:

Path

property image: str#

Getter for the ‘’image’’ attribute, post filtering.

Returns:

Image image.

Return type:

str

property image_original: str#

Getter for the ‘’image_original’’ attribute.

Returns:

Original image.

Return type:

str

property topostats_version: str#

Getter for the ‘’topostats_version’’ attribute, post filtering.

Returns:

Version of TopoStats the class was created with.

Return type:

str

__eq__(other: object) bool[source]#

Check if two TopoStats objects are equal.

Parameters:

other (object) – Object to compare to.

Returns:

True if the objects are equal, False otherwise.

Return type:

bool

topostats_to_dict() dict[str, str | grains.ImageGrainCrops | numpy.typing.NDArray][source]#

Convert ‘’TopoStats’’ object to dictionary.

Returns:

Dictionary of ‘’TopoStats’’ object.

Return type:

dict[str, str | ImageGrainCrops | npt.NDArray]