Representation#
- class FarField(*, scatterer, sampling, distance)[source]#
Bases:
BaseRepresentation
Represents the scattering far-field in spherical coordinates.
Inherits from BaseRepresentation and visualizes the far-field pattern characterized by the perpendicular and parallel components of the electric field in spherical coordinates.
\[\text{Fields} = E_{||}(\phi,\theta)^2, E_{\perp}(\phi,\theta)^2\]- Methods:
compute_components: Calculates the field components. This implementation is a placeholder, as the components are precomputed. plot: Visualizes the far-field pattern in a 3D plot.
- Parameters:
scatterer (object)
sampling (int)
distance (Quantity)
- add_phi_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')#
Adds a vector field to the 3D plot, representing vectors in the phi direction.
- Parameters:
scene (pyvista.Plotter) – The 3D plotting scene to which the vectors will be added.
n_points (int) – Number of points to generate along the theta and phi directions. Default is 100.
opacity (float) – Opacity of the vectors. Default is 1.0.
radius (float) – Radius at which to place the vectors. Default is 1.0.
color (str) – Color of the vectors. Default is ‘black’.
- Return type:
None
- add_theta_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')#
Adds a vector field to the 3D plot, representing vectors in the theta direction.
- Parameters:
scene (pyvista.Plotter) – The 3D plotting scene to which the vectors will be added.
n_points (int) – Number of points to generate along the theta and phi directions. Default is 100.
opacity (float) – Opacity of the vectors. Default is 1.0.
radius (float) – Radius at which to place the vectors. Default is 1.0.
color (str) – Color of the vectors. Default is ‘black’.
- Return type:
None
- compute_components()[source]#
Placeholder method in FarField class. Does not perform any computation as field components are precomputed.
This method is intended to be consistent with the structure of BaseRepresentation but does not need to modify or compute any attributes for FarField instances.
- Return type:
None
- distance: Quantity#
- plot(unit_size=(400, 400), background_color='white', show_edges=False, colormap=<matplotlib.colors.LinearSegmentedColormap object>, opacity=1.0, symmetric_colormap=False, show_axis_label=False)[source]#
Visualizes the Far field (in phi and theta vector projections) on a 3D plot.
- Parameters:
unit_size (List[float]) – The size of each subplot in pixels (width, height). Default is (400, 400).
background_color (str) – The background color of the plot. Default is ‘white’.
show_edges (bool) – If True, displays the edges of the mesh. Default is False.
colormap (str) – The colormap to use for scalar mapping. Default is ‘blue_black_red’.
opacity (float) – The opacity of the mesh. Default is 1.0.
symmetric_colormap (bool) – If True, the colormap will be symmetric around zero. Default is False.
show_axis_label (bool) – If True, shows the axis labels. Default is False.
- Return type:
None
- sampling: int#
- scatterer: object#
- class Stokes(*, scatterer, sampling, distance)[source]#
Bases:
BaseRepresentation
Represents the scattering far-field in the Stokes representation.
Inherits from BaseRepresentation and calculates the Stokes parameters which describe the polarization state of light.
The Stokes parameters (I, Q, U, V) are defined according to their conventional definitions, representing the total intensity, difference in intensities between horizontal and vertical polarizations, difference in intensities between two diagonal polarizations, and the right and left circular polarizations, respectively.
The stokes parameters are:I : intensity of the fieldsQ : linear polarization parallel to incident polarizationU : linear polarization 45 degree to incident polarizationV : Circular polarization- Methods:
compute_components: Computes the Stokes parameters based on the electric field components. plot: Visualizes the Stokes parameters on a 3D plot.
- Parameters:
scatterer (object)
sampling (int)
distance (Quantity)
- add_phi_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')#
Adds a vector field to the 3D plot, representing vectors in the phi direction.
- Parameters:
scene (pyvista.Plotter) – The 3D plotting scene to which the vectors will be added.
n_points (int) – Number of points to generate along the theta and phi directions. Default is 100.
opacity (float) – Opacity of the vectors. Default is 1.0.
radius (float) – Radius at which to place the vectors. Default is 1.0.
color (str) – Color of the vectors. Default is ‘black’.
- Return type:
None
- add_theta_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')#
Adds a vector field to the 3D plot, representing vectors in the theta direction.
- Parameters:
scene (pyvista.Plotter) – The 3D plotting scene to which the vectors will be added.
n_points (int) – Number of points to generate along the theta and phi directions. Default is 100.
opacity (float) – Opacity of the vectors. Default is 1.0.
radius (float) – Radius at which to place the vectors. Default is 1.0.
color (str) – Color of the vectors. Default is ‘black’.
- Return type:
None
- compute_components()[source]#
Computes the Stokes parameters (I, Q, U, V) based on the electric field components (E_phi and E_theta).
The method calculates the normalized intensity (I), linear polarizations (Q and U), and circular polarization (V) of the light scattered by the particle, using the electric field components in spherical coordinates.
The Stokes parameters are calculated using the following formulas:
The results are stored as attributes of the instance: I, Q, U, and V.
- Return type:
None
- distance: Quantity#
- plot(unit_size=(400, 400), background_color='white', show_edges=False, colormap=<matplotlib.colors.LinearSegmentedColormap object>, opacity=1.0, symmetric_colormap=False, show_axis_label=False)[source]#
Visualizes the Stokes parameters (I, Q, U, V) on a 3D plot.
- Parameters:
unit_size (List[float]) – The size of each subplot in pixels (width, height). Default is (400, 400).
background_color (str) – The background color of the plot. Default is ‘white’.
show_edges (bool) – If True, displays the edges of the mesh. Default is False.
colormap (str) – The colormap to use for scalar mapping. Default is ‘blue_black_red’.
opacity (float) – The opacity of the mesh. Default is 1.0.
symmetric_colormap (bool) – If True, the colormap will be symmetric around zero. Default is False.
show_axis_label (bool) – If True, shows the axis labels. Default is False.
- Return type:
None
- sampling: int#
- scatterer: object#
- class SPF(*, scatterer, sampling, distance)[source]#
Bases:
BaseRepresentation
Represents the Scattering Phase Function (SPF).
Inherits from BaseRepresentation and computes the SPF, which is a measure of how light is scattered by a particle at different angles.
\[\text{SPF} = E_{\parallel}(\phi,\theta)^2 + E_{\perp}(\phi,\theta)^2\]- Methods:
compute_components: Computes the SPF based on the electric field components. plot: Visualizes the SPF on a 3D plot.
- Parameters:
scatterer (object)
sampling (int)
distance (Quantity)
- add_phi_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')#
Adds a vector field to the 3D plot, representing vectors in the phi direction.
- Parameters:
scene (pyvista.Plotter) – The 3D plotting scene to which the vectors will be added.
n_points (int) – Number of points to generate along the theta and phi directions. Default is 100.
opacity (float) – Opacity of the vectors. Default is 1.0.
radius (float) – Radius at which to place the vectors. Default is 1.0.
color (str) – Color of the vectors. Default is ‘black’.
- Return type:
None
- add_theta_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')#
Adds a vector field to the 3D plot, representing vectors in the theta direction.
- Parameters:
scene (pyvista.Plotter) – The 3D plotting scene to which the vectors will be added.
n_points (int) – Number of points to generate along the theta and phi directions. Default is 100.
opacity (float) – Opacity of the vectors. Default is 1.0.
radius (float) – Radius at which to place the vectors. Default is 1.0.
color (str) – Color of the vectors. Default is ‘black’.
- Return type:
None
- compute_components()[source]#
Computes the Scattering Phase Function (SPF) based on the electric field components (E_phi and E_theta).
The SPF is calculated as the square root of the sum of the squared magnitudes of the electric field components, representing the total scattering intensity distribution as a function of angles.
The result is stored as the SPF attribute of the instance.
- Return type:
None
- distance: Quantity#
- plot(unit_size=(400, 400), background_color='white', show_edges=False, colormap='viridis', opacity=1.0, set_surface=True, show_axis_label=False)[source]#
Visualizes the scattering phase function on a 3D plot.
This method creates a 3D visualization of the scattering phase function (SPF). It allows customization of the plot’s appearance, including the colormap, mesh opacity, and whether or not to display mesh edges and axis labels.
- Parameters:
unit_size (List[float]) – The size of the plot window in pixels (width, height). Default is (400, 400).
background_color (str) – The background color of the plot. Default is ‘white’.
show_edges (bool) – If True, displays the edges of the mesh. Default is False.
colormap (str) – The colormap to use for scalar mapping. Default is ‘viridis’.
opacity (float) – The opacity of the mesh. Default is 1.0.
set_surface (bool) – If True, the surface represents the scaled SPF; if False, a unit sphere is used. Default is True.
show_axis_label (bool) – If True, shows the axis labels. Default is False.
- Return type:
None
- sampling: int#
- scatterer: object#
- class S1S2(*, scatterer, sampling, distance)[source]#
Bases:
BaseRepresentation
Represents the S1 and S2 scattering functions, which are components of the scattering matrix.
- Parameters:
scatterer (BaseScatterer) – The scatterer object.
sampling (int) – Number of points for evaluating the S1 and S2 functions.
distance (Quantity) – Distance at which the fields are evaluated.
Methods – compute_components: Computes the S1 and S2 functions based on the scatterer’s properties. plot: Visualizes the S1 and S2 functions on a polar plot.
- add_phi_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')#
Adds a vector field to the 3D plot, representing vectors in the phi direction.
- Parameters:
scene (pyvista.Plotter) – The 3D plotting scene to which the vectors will be added.
n_points (int) – Number of points to generate along the theta and phi directions. Default is 100.
opacity (float) – Opacity of the vectors. Default is 1.0.
radius (float) – Radius at which to place the vectors. Default is 1.0.
color (str) – Color of the vectors. Default is ‘black’.
- Return type:
None
- add_theta_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')#
Adds a vector field to the 3D plot, representing vectors in the theta direction.
- Parameters:
scene (pyvista.Plotter) – The 3D plotting scene to which the vectors will be added.
n_points (int) – Number of points to generate along the theta and phi directions. Default is 100.
opacity (float) – Opacity of the vectors. Default is 1.0.
radius (float) – Radius at which to place the vectors. Default is 1.0.
color (str) – Color of the vectors. Default is ‘black’.
- Return type:
None
- compute_components()[source]#
Computes the S1 and S2 scattering parameters based on the scatterer’s properties and the scattering angle phi.
S1 and S2 are integral parts of the scattering matrix describing the change in polarization state of light upon scattering.
The method calculates these parameters for a range of phi angles and stores them as the S1 and S2 attributes of the instance.
- Return type:
None
- distance: Quantity#
- plot()[source]#
Plots the S1 and S2 Stokes parameters on polar plots.
The method generates two polar plots: one for the absolute values of the S1 parameter and another for the S2 parameter, filling the area between the radial axis and the parameter values.
- Returns:
This method does not return a value. It displays the polar plots.
- Return type:
None
- sampling: int#
- scatterer: object#
- class Footprint(*, detector, scatterer, sampling=200, padding_factor=20)[source]#
Bases:
object
Represents the footprint of the scatterer as detected by various detectors.
\[\text{Footprint} = \big| \mathscr{F}^{-1} \big\{ \tilde{ \psi }\ (\xi, \nu), \tilde{ \phi}_{l,m}(\xi, \nu) \big\} \ (\delta_x, \delta_y) \big|^2\]- Parameters:
detector (BaseDetector) – The detector object.
scatterer (BaseScatterer) – The scatterer object.
sampling (int) – Number of points to evaluate the Stokes parameters in spherical coordinates (default is 500).
padding_factor (int) – Padding factor for the Fourier transform (default is 20).
Methods – compute_footprint: Computes the footprint based on the far-field patterns and detector characteristics. plot: Visualizes the computed footprint.
- compute_footprint()[source]#
Computes the footprint of the scatterer as detected by the specified detector.
The footprint is calculated based on the far-field scattering patterns and the characteristics of the detector, using a Fourier transform to project the far-field onto the detector plane.
The computed footprint and the corresponding spatial coordinates are stored as attributes of the instance.
Warning: this function do not currently take account of the cache block on the detector.
- detector: object#
- get_fourier_component(scalar)[source]#
Computes the Fourier component of a given scalar field.
This method performs a two-dimensional inverse Fourier transform on the input scalar field, which represents a projection (either parallel or perpendicular) of the far-field pattern. It then extracts a central portion of the result, effectively applying a padding factor to increase the resolution of the Fourier transform.
- Parameters:
scalar (-) – A two-dimensional numpy array representing the scalar field of which the Fourier component is to be computed. This field could represent either the parallel or perpendicular projection of the far-field pattern onto the detector plane.
- Returns:
numpy.ndarray – A two-dimensional numpy array representing the computed Fourier component. This array is a square section, extracted from the center of the full Fourier transform, with dimensions determined by the original sampling rate and the padding factor of the instance. The values in the array represent the intensity distribution of the light in the detector plane, providing insights into the spatial characteristics of the scattering pattern.
The method uses numpy’s fft module to perform the Fourier transform, applying a padding factor to the input to
achieve a higher resolution in the Fourier domain. The resulting Fourier transform is then squared and fftshifted
to center the zero-frequency component, and a central portion is extracted to match the intended output size.
- Return type:
- padding_factor: int = 20#
- plot(colormap='gray')[source]#
Plots the scatterer footprint using a 2D colormap.
The method generates a plot representing the footprint of the scatterer, with the X and Y axes showing offset distances in micrometers, and the colormap depicting the mapping values.
- Parameters:
colormap (str) – The colormap to use for the plot. Default is ‘gray’.
- Return type:
None
- sampling: int = 200#
- scatterer: object#