physical_apertures.base

Physical Apertures Base Module

This module contains the base classes for physical apertures. The BaseAperture class is an abstract base class that defines the interface for physical apertures. The BaseBooleanAperture class is an abstract base class for boolean operations on apertures. The UnionAperture, IntersectionAperture, and DifferenceAperture classes are concrete classes that implement the union, intersection, and difference of two apertures, respectively.

Kramer Harrison, 2024

Classes

BaseAperture()

Base class for physical apertures.

BaseBooleanAperture(a, b)

Base class for boolean operations on apertures.

DifferenceAperture(a, b)

Class for difference of two apertures.

IntersectionAperture(a, b)

Class for intersection of two apertures.

UnionAperture(a, b)

Class for union of two apertures.

class BaseAperture[source]

Base class for physical apertures.

clip(RealRays)[source]

Clips the given rays based on the aperture’s shape.

clip(rays: RealRays)[source]

Clips the given rays based on the aperture’s shape.

Parameters:

rays (RealRays) – List of rays to be clipped.

Returns:

List of clipped rays.

Return type:

list

abstract contains(x: BEArray, y: BEArray) BEArray[source]

Checks if the given point is inside the aperture.

Parameters:
  • x (be.ndarray) – The x-coordinate of the point.

  • y (be.ndarray) – The y-coordinate of the point.

Returns:

Boolean array indicating if the point is inside the

aperture

Return type:

be.ndarray

abstract property extent: tuple[float, float, float, float]

Returns the extent of the aperture.

Returns:

The extent of the aperture in the x and y directions.

Return type:

tuple

classmethod from_dict(data: dict) BaseAperture[source]

Create an aperture from a dictionary representation.

Parameters:

data (dict) – The dictionary representation of the aperture.

Returns:

The aperture object.

Return type:

BaseAperture

abstract scale(scale_factor: float)[source]

Scales the aperture by the given factor.

Parameters:

scale_factor (float) – The factor by which to scale the aperture.

to_dict() dict[source]

Convert the aperture to a dictionary.

Returns:

The dictionary representation of the aperture.

Return type:

dict

view(nx: int = 256, ny: int = 256, ax: Axes | None = None, buffer: float = 1.1, **kwargs) tuple[Figure, Axes][source]

Visualize the aperture.

Parameters:
  • nx (int) – The number of points in the x-direction.

  • ny (int) – The number of points in the y-direction.

  • ax (Axes) – The axes to plot on.

  • buffer (float) – The buffer around the aperture.

  • **kwargs – Additional keyword arguments to pass to the plot function.

Returns:

A tuple containing the figure and axes objects.

Return type:

tuple

class BaseBooleanAperture(a: BaseAperture, b: BaseAperture)[source]

Base class for boolean operations on apertures.

Parameters:
clip(rays: RealRays)

Clips the given rays based on the aperture’s shape.

Parameters:

rays (RealRays) – List of rays to be clipped.

Returns:

List of clipped rays.

Return type:

list

abstract contains(x, y) BEArray[source]

Checks if the given point is inside the aperture.

Parameters:
  • x (be.ndarray) – The x-coordinate of the point.

  • y (be.ndarray) – The y-coordinate of the point.

Returns:

Boolean array indicating if the point is inside the

aperture

Return type:

be.ndarray

property extent: tuple[float, float, float, float]

Returns the extent of the aperture.

Returns:

The extent of the aperture in the x and y directions.

Return type:

tuple

classmethod from_dict(data: dict)[source]

Create an aperture from a dictionary representation.

Parameters:

data (dict) – The dictionary representation of the aperture.

Returns:

The aperture object.

Return type:

BaseBooleanAperture

scale(scale_factor: float)[source]

Scales the aperture by the given factor.

Parameters:

scale_factor (float) – The factor by which to scale the aperture.

to_dict() dict[source]

Convert the aperture to a dictionary.

Returns:

The dictionary representation of the aperture.

Return type:

dict

view(nx: int = 256, ny: int = 256, ax: Axes | None = None, buffer: float = 1.1, **kwargs) tuple[Figure, Axes]

Visualize the aperture.

Parameters:
  • nx (int) – The number of points in the x-direction.

  • ny (int) – The number of points in the y-direction.

  • ax (Axes) – The axes to plot on.

  • buffer (float) – The buffer around the aperture.

  • **kwargs – Additional keyword arguments to pass to the plot function.

Returns:

A tuple containing the figure and axes objects.

Return type:

tuple

class DifferenceAperture(a: BaseAperture, b: BaseAperture)[source]

Class for difference of two apertures.

Parameters:
clip(rays: RealRays)

Clips the given rays based on the aperture’s shape.

Parameters:

rays (RealRays) – List of rays to be clipped.

Returns:

List of clipped rays.

Return type:

list

contains(x: BEArray, y: BEArray) BEArray[source]

Checks if the given point is inside the aperture.

Parameters:
  • x (be.ndarray) – The x-coordinate of the point.

  • y (be.ndarray) – The y-coordinate of the point.

Returns:

Boolean array indicating if the point is inside the

aperture

Return type:

be.ndarray

property extent: tuple[float, float, float, float]

Returns the extent of the aperture.

Returns:

The extent of the aperture in the x and y directions.

Return type:

tuple

classmethod from_dict(data: dict)

Create an aperture from a dictionary representation.

Parameters:

data (dict) – The dictionary representation of the aperture.

Returns:

The aperture object.

Return type:

BaseBooleanAperture

scale(scale_factor: float)

Scales the aperture by the given factor.

Parameters:

scale_factor (float) – The factor by which to scale the aperture.

to_dict() dict

Convert the aperture to a dictionary.

Returns:

The dictionary representation of the aperture.

Return type:

dict

view(nx: int = 256, ny: int = 256, ax: Axes | None = None, buffer: float = 1.1, **kwargs) tuple[Figure, Axes]

Visualize the aperture.

Parameters:
  • nx (int) – The number of points in the x-direction.

  • ny (int) – The number of points in the y-direction.

  • ax (Axes) – The axes to plot on.

  • buffer (float) – The buffer around the aperture.

  • **kwargs – Additional keyword arguments to pass to the plot function.

Returns:

A tuple containing the figure and axes objects.

Return type:

tuple

class IntersectionAperture(a: BaseAperture, b: BaseAperture)[source]

Class for intersection of two apertures.

Parameters:
clip(rays: RealRays)

Clips the given rays based on the aperture’s shape.

Parameters:

rays (RealRays) – List of rays to be clipped.

Returns:

List of clipped rays.

Return type:

list

contains(x: BEArray, y: BEArray) BEArray[source]

Checks if the given point is inside the aperture.

Parameters:
  • x (be.ndarray) – The x-coordinate of the point.

  • y (be.ndarray) – The y-coordinate of the point.

Returns:

Boolean array indicating if the point is inside the

aperture

Return type:

be.ndarray

property extent: tuple[float, float, float, float]

Returns the extent of the aperture.

Returns:

The extent of the aperture in the x and y directions.

Return type:

tuple

classmethod from_dict(data: dict)

Create an aperture from a dictionary representation.

Parameters:

data (dict) – The dictionary representation of the aperture.

Returns:

The aperture object.

Return type:

BaseBooleanAperture

scale(scale_factor: float)

Scales the aperture by the given factor.

Parameters:

scale_factor (float) – The factor by which to scale the aperture.

to_dict() dict

Convert the aperture to a dictionary.

Returns:

The dictionary representation of the aperture.

Return type:

dict

view(nx: int = 256, ny: int = 256, ax: Axes | None = None, buffer: float = 1.1, **kwargs) tuple[Figure, Axes]

Visualize the aperture.

Parameters:
  • nx (int) – The number of points in the x-direction.

  • ny (int) – The number of points in the y-direction.

  • ax (Axes) – The axes to plot on.

  • buffer (float) – The buffer around the aperture.

  • **kwargs – Additional keyword arguments to pass to the plot function.

Returns:

A tuple containing the figure and axes objects.

Return type:

tuple

class UnionAperture(a: BaseAperture, b: BaseAperture)[source]

Class for union of two apertures.

Parameters:
clip(rays: RealRays)

Clips the given rays based on the aperture’s shape.

Parameters:

rays (RealRays) – List of rays to be clipped.

Returns:

List of clipped rays.

Return type:

list

contains(x: BEArray, y: BEArray) BEArray[source]

Checks if the given point is inside either aperture.

Parameters:
  • x (be.ndarray) – The x-coordinate of the point.

  • y (be.ndarray) – The y-coordinate of the point.

Returns:

Boolean array indicating if the point is inside the

aperture

Return type:

be.ndarray

property extent: tuple[float, float, float, float]

Returns the extent of the aperture.

Returns:

The extent of the aperture in the x and y directions.

Return type:

tuple

classmethod from_dict(data: dict)

Create an aperture from a dictionary representation.

Parameters:

data (dict) – The dictionary representation of the aperture.

Returns:

The aperture object.

Return type:

BaseBooleanAperture

scale(scale_factor: float)

Scales the aperture by the given factor.

Parameters:

scale_factor (float) – The factor by which to scale the aperture.

to_dict() dict

Convert the aperture to a dictionary.

Returns:

The dictionary representation of the aperture.

Return type:

dict

view(nx: int = 256, ny: int = 256, ax: Axes | None = None, buffer: float = 1.1, **kwargs) tuple[Figure, Axes]

Visualize the aperture.

Parameters:
  • nx (int) – The number of points in the x-direction.

  • ny (int) – The number of points in the y-direction.

  • ax (Axes) – The axes to plot on.

  • buffer (float) – The buffer around the aperture.

  • **kwargs – Additional keyword arguments to pass to the plot function.

Returns:

A tuple containing the figure and axes objects.

Return type:

tuple