TwiceAsNice  2019-02-18
Functions
laospy.arraytools Namespace Reference

Functions

def add_circular_mask (array, radius=-1, center=-1)
 
def rebin (a, new_shape)
 
def mk_rad_mask (r0, r1=None, norm=True, center=None, dtype=np.float)
 
def mk_xinetics_actuatormap (alongRows=False)
 
def gaussian (height, center_x, center_y, width_x, width_y)
 
def moments (data)
 
def fitgaussian (data)
 
def find_transform (a, b)
 

Function Documentation

◆ add_circular_mask()

def laospy.arraytools.add_circular_mask (   array,
  radius = -1,
  center = -1 
)
@brief Create a circular mask in a masked array. circular mask is ORed to to the mask of array

:param array: masked array in which the masking takes place

:param [radius]: radius of the circle in pixels

:param [center]: index of the center

:returns: boolean array 

◆ find_transform()

def laospy.arraytools.find_transform (   a,
  b 
)
Returns the least-squares solution to the linear transformation between two coordinate systems
  
The solution m will allow to transform between coordinate systems in the form: 

b[0] = m[0,0] * a[0] + m[1,0] * a[1] + m[2,0]
b[1] = m[0,1] * a[0] + m[1,1] * a[1] + m[2,1]

In order to not under determine the linear equations, the coordinates of at least 3 points 
have to be specified

   
Parameters
----------
a : ndarray (Nx2)
    coordinates of N points in native coordinate system 
b : ndarray (Nx2)
    corresponding coordinates of the same N points in the target coordinate system
    
Returns
-------
m : ndarray (3x2)
    transformation matrix

◆ fitgaussian()

def laospy.arraytools.fitgaussian (   data)
Returns (height, x, y, width_x, width_y)
the gaussian parameters of a 2D distribution found by a fit

source: http://wiki.scipy.org/Cookbook/FittingData

◆ gaussian()

def laospy.arraytools.gaussian (   height,
  center_x,
  center_y,
  width_x,
  width_y 
)
Returns a gaussian function with the given parameters

source: http://wiki.scipy.org/Cookbook/FittingData

◆ mk_rad_mask()

def laospy.arraytools.mk_rad_mask (   r0,
  r1 = None,
  norm = True,
  center = None,
  dtype = np.float 
)
Make a rectangular matrix of size (r0, r1) where the value of each 
element is the Euclidean distance to **center**. If **center** is not 
given, it is the middle of the matrix. If **norm** is True (default), 
the distance is normalized to half the radius, i.e. values will range 
from [-1, 1] for both axes.

If only r0 is given, the matrix will be (r0, r0). If r1 is also given, 
the matrix will be (r0, r1)

To make a circular binary mask of (r0, r0), use
        mk_rad_mask(r0) < 1

@param [in] r0 The width (and height if r1==None) of the mask.
@param [in] r1 The height of the mask.
@param [in] norm Normalize the distance such that 2/(r0, r1) equals a distance of 1.
@param [in] center Set distance origin to **center** (defaults to the middle of the rectangle)
@package libtim.im
@author Tim van Werkhoven (werkhoven@strw.leidenuniv.nl)
@copyright Creative Commons Attribution-Share Alike license versions 3.0 or higher, see http://creativecommons.org/licenses/by-sa/3.0/
@date 20120403

◆ mk_xinetics_actuatormap()

def laospy.arraytools.mk_xinetics_actuatormap (   alongRows = False)
Creates a masked array with the actuator indices

:returns: masked array

◆ moments()

def laospy.arraytools.moments (   data)
Returns (height, x, y, width_x, width_y)
the gaussian parameters of a 2D distribution by calculating its
moments 

source: http://wiki.scipy.org/Cookbook/FittingData

◆ rebin()

def laospy.arraytools.rebin (   a,
  new_shape 
)
Resizes a 2d array by averaging or repeating elements,
new dimensions must be integral factors of original dimensions

Parameters
----------
a : array_like
Input array.
new_shape : tuple of int
Shape of the output array

Returns
-------
rebinned_array : ndarray
If the new shape is smaller of the input array, the data are averaged,
if the new shape is bigger array elements are repeated

See Also
--------
resize : Return a new array with the specified shape.

Examples
--------
>>> a = np.array([[0, 1], [2, 3]])
>>> b = rebin(a, (4, 6)) #upsize
>>> b
array([[0, 0, 0, 1, 1, 1],
[0, 0, 0, 1, 1, 1],
[2, 2, 2, 3, 3, 3],
[2, 2, 2, 3, 3, 3]])

>>> c = rebin(b, (2, 3)) #downsize
>>> c
array([[ 0. , 0.5, 1. ],
[ 2. , 2.5, 3. ]])