1.1. py_pol.py_pol module

This is the file with the base classes all py_pol main classes will inherit from. They will have some basic methods common to all classes. These classes is not intended to use except for inheritance.

Class fields
  • M: Array containing the physical information of the object.

  • name: Name of the object for print purposes.

  • shape: Shape desired for the outputs.

  • size: Number of stores Jones vectors.

  • type: Type of the object. This is used for determining the object class as using isinstance may throw unexpected results in .ipynb files.

Manipulation methods
  • clear: Removes data and name form Jones vector.

  • copy: Creates a copy of the Jones_vector object.

  • stretch: Stretches a Jones vector of size 1.

  • shape_like: Takes the shape of another object to use as its own.

  • reshape: Changes the shape of the object.

  • flatten: Transforms N-D objects into 1-D objects (0-D if only 1 element).

  • flip: Flips the object along some dimensions.

  • get_list: Creates a list with single elements.

  • from_list: Creates the object from a list of single elements.

  • concatenate: Canocatenates several objects into a single one.

  • draw: Draws the components of the object.

  • clear: Clears the information of the object.

py_pol.py_pol.get_options()[source]

TODO

py_pol.py_pol.set_option(key, value)[source]

TODO

class py_pol.py_pol.Py_pol(name='', _class='Py_pol')[source]

Bases: object

Basic class where all py_pol main classes will inherit from.

property name
property type
property M
property size
property shape
property ndim
get_list(out_number=True, shape_vectors=True)[source]

Returns a list of np.ndarrays. Each array is a vector or matrix corresponding with one element or light source.

Parameters:
  • out_number (bool) – if True and the object is size 1, return an array instead of a list. Default: True.

  • shape_vectors (bool) – If True and the object is Jones_vector or Stokes, the output arrays will have dimension 2x1 and 4x1 instead 2 and 4 respectively. Default: True.

Returns:

Created object.

Return type:

(numpy.ndarray or list)

from_list(l, shape_like=None, shape=None)[source]

Create a Py_pol object from a list of numpy arrays of the correct size.

Parameters:
  • l (list) – list of np.ndarrays, lists, tuples or Py_pol objects.

  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.

  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.

Returns:

Created object.

Return type:

(Py_pol)

concatenate(objs, shape_like=None, shape=None, keep=False, change_name=False)[source]

Create a Py_pol object from an iterable of Py_pol objects.

Parameters:
  • objs (iterable) – iterable of Py_pol objects.

  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.

  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.

  • keep (bool) – if True, the original element is not updated. Default: False.

  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.

Returns:

Created object.

Return type:

(Py_pol)

flip(axis=None, keep=False, change_name=False)[source]

Flips the order of the elements stored in the object.

Parameters:
  • axis (int, list or tuple) – Axes along which the flip is performed. If None, the object is flipped as flattened. Default: None.

  • keep (bool) – if True, the original element is not updated. Default: False.

  • change_name (bool) – If True, changes the object name adding Recip. of at the beggining of the name. Default: True.

Returns:

Modified object.

Return type:

(Jones_vector)

stretch(length, keep=False)[source]

Function that stretches an object with a single element to have a higher number of equal elements.

Parameters:
  • length (int) – Number of elements.

  • keep (bool) – If True, self is not updated. Default: False.

Returns:

Recalculated Jones vector.

Return type:

(Jones_vector)

copy(N=1)[source]

Creates a copy of the object.

Parameters:

N (int) – Number of copies. Default: 1.

Returns:

Copied object.

Return type:

(Py_pol)

reshape(shape)[source]

Changes the shape of the object.

Parameter:

shape (tuple, list or 1-D np.ndarray): New shape.

shape_like(obj)[source]

Takes the shape of another object.

Parameter:

obj (Py_pol or nd.array): Object to take the shape.

flatten(keep=False)[source]

Method that flattens the objcet (transforms N-D objects in 1D objects if N>=1).

Parameters:

keep (bool) – If True, self is not updated. Default: False.

Returns:

Flattened object.

Return type:

(Py_pol)

draw(verbose=True, shape_like=None, shape=None, kind='jones')[source]

Draw the components of the object. This is a wrap of parameters.components.

Parameters:
  • verbose (bool) – if True prints the parameter. Default: False.

  • shape_like (numpy.ndarray or py_pol object) – Use the shape of this object. Default: None.

  • shape (tuple or list) – If no shape_like array is given, use this shape instead. Default: None.

clear()[source]

Removes data and name form the object.

class py_pol.py_pol.Py_pol_Iterator(object)[source]

Bases: object

Iterator of the Py_pol classes.