ptypy.core.classes.View#

class ptypy.core.classes.View(container, ID=None, accessrule=None, **kwargs)#

Bases: Base

A ‘window’ on a Container.

A view stores all the slicing information to extract a 2D piece of Container.

Note

The final structure of this class is yet up to debate and the constructor signature may change. Especially since ‘DEFAULT_ACCESSRULE’ is yet so small, its contents could be incorporated in the constructor call.

__init__(container, ID=None, accessrule=None, **kwargs)#
Parameters:
  • container (Container) – The Container instance this view applies to.

  • ID (str or int) – ID for this view. Automatically built from ID if None.

  • accessrule (dict) – All the information necessary to access the wanted slice. Maybe subject to change as code evolve. See keyword arguments Almost all keys of accessrule will be available as attributes in the constructed View instance.

Keyword Arguments:
  • storageID (str) – ID of storage, If the Storage does not exist it will be created! (default is None)

  • shape (int or tuple of int) – Shape of the view in pixels (default is None)

  • coord (2-tuple of float,) – Physical coordinates (meter) of the center of the view.

  • psize (float or tuple of float) – Pixel size in (meter) . Required for storage initialization.

  • layer (int) – Index of the third dimension if applicable. (default is 0)

  • active (bool) – Whether this view is active (default is True)

Methods

__init__(container[, ID, accessrule])

calc_mem_usage()

copy([ID, update])

Attributes

ID

numID

owner

storage

The Storage instance that this view applies to by default.

storageID

The storage ID that this view will be forward to if applied to a Container.

error

DEFAULT_ACCESSRULE

active

Active state.

coord

The View's physical coordinate (meters)

data

The view content in data buffer of associated storage.

dcoord

Center coordinate (index) in data buffer.

dhigh

High side of the View's data range.

dlayer

The "layer" i.e. first axis index in Storage data buffer.

dlow

Low side of the View's data range.

layer

ndim

pcoord

The physical coordinate in pixel space

pod

Returns first POD in the self.pods dict.

pods

Returns all PODs still connected to this view as a dict.

psize

Pixel size of the View.

shape

Two dimensional shape of View.

slice

Returns a slice-tuple according to self.layer, self.dlow and self.dhigh.

sp

The subpixel difference (meters) between physical coordinate and data coordinate.

property active#

Active state. If False this view will be ignored when resizing the data buffer of the associated Storage.

property coord#

The View’s physical coordinate (meters)

property data#

The view content in data buffer of associated storage.

property dcoord#

Center coordinate (index) in data buffer.

property dhigh#

High side of the View’s data range.

property dlayer#

The “layer” i.e. first axis index in Storage data buffer

property dlow#

Low side of the View’s data range.

property pcoord#

The physical coordinate in pixel space

property pod#

Returns first POD in the self.pods dict. This is a common call in the code and has therefore found its way here. May return None if there is no pod connected.

property pods#

Returns all PODs still connected to this view as a dict.

property psize#

Pixel size of the View.

property shape#

Two dimensional shape of View.

property slice#

Returns a slice-tuple according to self.layer, self.dlow and self.dhigh. Please note, that this may not always makes sense

property sp#

The subpixel difference (meters) between physical coordinate and data coordinate.

storage#

The Storage instance that this view applies to by default.

storageID#

The storage ID that this view will be forward to if applied to a Container.