cls_Aarray - almarklein/visvis GitHub Wiki

Inherits from ndarray.

Anisotropic array; inherits from numpy.ndarray and adds a sampling and origin property which gives the sample distance and offset for each dimension.

Parameters

shape_or_array : shape-tuple or numpy.ndarray
Specifies the shape of the produced array. If an array instance is given, the returned Aarray is a view of the same data (i.e. no data is copied).
sampling : tuple of ndim elements
Specifies the sample distance (i.e. spacing between elements) for each dimension. Default is all ones.
origin : tuple of ndim elements
Specifies the world coordinate at the first element for each dimension. Default is all zeros.
fill : scalar (optional)
If given, and the first argument is not an existing array, fills the array with this given value.
dtype : any valid numpy data type
The type of the data

All extra arguments are fed to the constructor of numpy.ndarray.

Implemented properties and methods

  • sampling - The distance between samples as a tuple
  • origin - The origin of the data as a tuple
  • get_start() - Get the origin of the data as a Point instance
  • get_end() - Get the end of the data as a Point instance
  • get_size() - Get the size of the data as a Point instance
  • sample() - Sample the value at the given point
  • point_to_index() - Given a poin, returns the index in the array
  • index_to_point() - Given an index, returns the world coordinate

Slicing

This class is aware of slicing. This means that when obtaining a part of the data (for exampled 'data[10:20,::2]'), the origin and sampling of the resulting array are set appropriately.

When applying mathematical opertaions to the data, or applying functions that do not change the shape of the data, the sampling and origin are copied to the new array. If a function does change the shape of the data, the sampling are set to all zeros and ones for the origin and sampling, respectively.

World coordinates vs tuples

World coordinates are expressed as Point instances (except for the "origin" property). Indices as well as the "sampling" and "origin" attributes are expressed as tuples in z,y,x order.

The Aarray class implements the following properties:
origin, sampling

The Aarray class implements the following methods:
get_end, get_size, get_start, index_to_point, point_to_index, sample

Properties

A tuple with the origin for each dimension.

A tuple with the sample distance for each dimension.

Methods

Get the end of the array expressed in world coordinates.

Get the size (as a vector) of the array expressed in world coordinates.

Get the origin of the array expressed in world coordinates. Differs from the property 'origin' in that this method returns a point rather than indices z,y,x.

Given a multidimensional index, get the corresponding point in world coordinates.

Given a point returns the sample index (z,y,x,..) closest to the given point. Returns a tuple with as many elements as there are dimensions.

If the point is outside the array an IndexError is raised by default, and None is returned when non_on_index_error == True.

Take a sample of the array, given the given point in world-coordinates, i.e. transformed using sampling. By default raises an IndexError if the point is not inside the array, and returns the value of "default" if it is given.

⚠️ **GitHub.com Fallback** ⚠️