Representation#
- class FarFields(setup, sampling=200, distance=<Quantity(1.0, 'meter')>)[source]#
Bases:
objectCompute the far-field scattering pattern for the scatterer.
The far fields describe the behavior of the scattered electromagnetic waves at a large distance from the scatterer, where the waves can be approximated as planar. The computed far fields represent the scattered electric field components in the directions parallel and perpendicular to the plane of incidence.
The far fields are computed as:
\[\text{Fields} = E_{||}(\phi, \theta)^2, \, E_{\perp}(\phi, \theta)^2\]These components represent the intensities of the scattered electric field in the parallel (( E_{||} )) and perpendicular (( E_{perp} )) directions as functions of the spherical angles ( phi ) (azimuthal) and ( theta ) (polar).
The fields are expressed up to a constant phase factor:
\[\exp{\left(-i k r \right)}\]Where:
\(k\): The wave number, related to the wavelength of the incident light.
\(r\): The distance from the scatterer (assumed to be large in the far-field approximation).
- Parameters:
sampling (int) – The number of angular points used to sample the far-field pattern. A higher sampling value increases the angular resolution of the computed far-field intensities.
distance (Length, optional) – The distance from the scatterer at which the far fields are evaluated. By default, this is set to 1 meter, but it can be adjusted to suit the specific experimental configuration.
setup (object)
- Returns:
An object containing the computed far-field components (parallel and perpendicular intensities), which represent the angular distribution of the scattered light in the far field.
- Return type:
representations.FarField
Notes
The far-field approximation assumes that the distance from the scatterer is large enough that the curvature of the wavefronts can be neglected, and the fields can be treated as planar.
This method is useful for determining the angular distribution of the scattered light, which is critical in applications such as radar cross-section analysis, optical scattering experiments, and remote sensing.
- add_phi_vector_to_3d_plot(scene, n_points=20, opacity=1.0, radius=1.0, color='black')[source]#
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')[source]#
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
- plot(unit_size=(400, 400), background_color='white', show_edges=False, colormap=<matplotlib.colors.LinearSegmentedColormap object>, opacity=1.0, 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.
show_axis_label (bool) – If True, shows the axis labels. Default is False.
- Return type:
None
- class Stokes(setup, sampling=200, distance=<Quantity(1.0, 'meter')>)[source]#
Bases:
objectCompute the four Stokes parameters: I, Q, U, and V, which describe the polarization state of scattered light.
The Stokes parameters provide a complete description of the polarization state of electromagnetic radiation, and are defined as follows:
\[\begin{split}I &= \big| E_x \big|^2 + \big| E_y \big|^2 \quad &\text{(total intensity)} \\ Q &= \big| E_x \big|^2 - \big| E_y \big|^2 \quad &\text{(linear polarization along x and y)} \\ U &= 2 \mathcal{Re} \big\{ E_x E_y^* \big\} \quad &\text{(linear polarization at +45° and -45°)} \\ V &= 2 \mathcal{Im} \big\{ E_x E_y^* \big\} \quad &\text{(circular polarization)}\end{split}\]Where:
\(I\): Total intensity of the scattered light.
\(Q\): The degree of linear polarization along the x and y axes.
\(U\): The degree of linear polarization at +45° and -45° to the axes.
\(V\): The degree of circular polarization.
These parameters provide a powerful way to represent the full polarization state of the scattered light.
- Parameters:
sampling (int) – The number of angular points used to sample the Stokes parameters. A higher sampling value increases the resolution of the computed polarization pattern.
distance (Length, optional) – The distance from the scatterer at which the Stokes parameters are evaluated. The default is 1 meter, but this can be adjusted based on the experimental setup.
setup (object)
- Returns:
An object containing the computed Stokes parameters (I, Q, U, V), which describe the polarization state of the scattered light.
- Return type:
Notes
The Stokes parameters are essential for understanding and characterizing the polarization of scattered light. They are used in a wide variety of applications, including atmospheric optics, remote sensing, and optical communication.
The sampling parameter controls the angular resolution of the calculated Stokes parameters. Higher values provide finer detail, which can be important in accurately modeling polarization effects in scattering experiments.
Example
You can use this method to compute the Stokes parameters for a spherical scatterer, helping you analyze how the scatterer affects the polarization state of light.
Example usage:
>>> stokes_params = scatterer.get_stokes(sampling=500) >>> print(stokes_params.I, stokes_params.Q, stokes_params.U, stokes_params.V)
- plot(unit_size=(400, 400), background_color='white', show_edges=False, colormap=<matplotlib.colors.LinearSegmentedColormap object>, opacity=1.0, 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.
show_axis_label (bool) – If True, shows the axis labels. Default is False.
- Return type:
None
- class SPF(setup, sampling=200)[source]#
Bases:
objectCompute the scattering phase function (SPF) for the scatterer.
The scattering phase function describes how the intensity of scattered light varies as a function of the scattering angles ( theta ) (polar) and ( phi ) (azimuthal). It is a key quantity in light scattering, as it characterizes the angular distribution of scattered light.
The scattering phase function is computed as:
\[\text{SPF} = \sqrt{ E_{\parallel}(\phi, \theta)^2 + E_{\perp}(\phi, \theta)^2 }\]Where:
\(E_{\parallel}\): The parallel component of the scattered electric field.
\(E_{\perp}\): The perpendicular component of the scattered electric field.
\(\phi\) and \(\theta\): The azimuthal and polar angles, respectively, which describe the angular position of the scattered light.
The SPF combines the intensity contributions from both polarization components to describe the total scattered intensity in different directions.
- Parameters:
sampling (int) – The number of angular points used to sample the scattering phase function. A higher sampling value increases the angular resolution of the computed SPF.
distance (Length, optional) – The distance from the scatterer at which the scattering phase function is evaluated. By default, this is set to 1 meter, but it can be adjusted depending on the specific experimental configuration.
- Returns:
An object containing the computed scattering phase function (SPF), representing the angular distribution of scattered light intensity.
- Return type:
Notes
The scattering phase function is a critical quantity in the study of light scattering, as it provides insight into the directionality of the scattered light. It is commonly used in fields like atmospheric optics, biomedical imaging, and remote sensing.
The sampling parameter controls the angular resolution of the SPF. Higher sampling values yield more detailed scattering patterns, especially important when capturing small angular features.
Example
You can use this method to compute the scattering phase function of a spherical scatterer, helping to understand the angular distribution of light scattered by the particle.
Example usage:
>>> spf = scatterer.get_spf(sampling=500) >>> print(spf)
- plot(unit_size=(800, 800), 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 (800, 800).
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
- class S1S2(setup, sampling=200)[source]#
Bases:
objectCompute the S1 and S2 scattering amplitude functions for a spherical scatterer.
The S1 and S2 parameters represent the scattering amplitudes for perpendicular and parallel polarizations of light, respectively. These parameters are fundamental in Mie theory, which describes the scattering of electromagnetic waves by spherical particles.
The formulas for ( S_1 ) and ( S_2 ) are:
\[\begin{split}S_1 = \sum\limits_{n=1}^{n_{\text{max}}} \frac{2n+1}{n(n+1)} \left( a_n \pi_n + b_n \tau_n \right) \\ S_2 = \sum\limits_{n=1}^{n_{\text{max}}} \frac{2n+1}{n(n+1)} \left( a_n \tau_n + b_n \pi_n \right)\end{split}\]Where:
\(a_n\) and \(b_n\): Mie coefficients, which depend on the size, shape, and refractive index of the scatterer.
\(\pi_n\) and \(\tau_n\) )`: Angular functions related to the angular components of the incident and scattered fields.
\(n_{\text{max}}\): Maximum number of terms in the series, determined by the size parameter of the scatterer.
These scattering amplitude functions are essential for calculating properties such as scattering phase functions, efficiencies, and angular distribution of scattered light.
- Parameters:
sampling (int) – The number of angular points used to sample the S1 and S2 functions. Higher sampling improves the resolution of the scattering pattern but increases computation time.
distance (Length, optional) – The distance from the scatterer at which the S1 and S2 parameters are evaluated. This is typically set to 1 meter by default, but can be adjusted for specific setups.
- Returns:
An object containing the computed S1 and S2 parameters, representing the scattering amplitudes for the two polarization components.
- Return type:
Notes
The S1 and S2 parameters are central to Mie scattering theory and are used to derive many important scattering properties, such as intensity distributions and polarization effects.
The sampling parameter controls how finely the angular distribution is resolved. A higher value of sampling provides more detailed scattering information, which can be critical for accurately modeling the far-field pattern.
Example
You can use this method to compute the scattering properties of spherical particles, particularly in experiments where the polarization and scattering pattern of the light are important.
Example usage:
>>> s1s2 = scatterer.get_s1s2(sampling=500) >>> print(s1s2.S1, s1s2.S2)
- plot(axes)[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.
Extra Parameters#
- showbool
Whether to display the plot after creation.
- save_asstr, optional
If provided, save the figure to this path.
- figure_sizetuple, optional
Size of the figure in inches.
- tight_layoutbool, default=True
Whether to use tight layout for the figure.
- axesmatplotlib.axes.Axes, optional
Axes to draw on. If None, a new figure+axes are created.
- xscalestr, optional
X-axis scale type (e.g., ‘linear’, ‘log’).
- yscalestr, optional
Y-axis scale type (e.g., ‘linear’, ‘log’).
- xlimtuple, optional
X-axis limits as (min, max).
- ylimtuple, optional
Y-axis limits as (min, max).
- stylestr, default=plot_style
Matplotlib style to use for the plot.
- **kwargs
Additional keyword arguments to pass to the plotting function.
- returns:
axes – The axes with the market prices plot.
- rtype:
matplotlib.axes.Axes
- Return type:
None
- class Footprint(setup, sampling=200, padding_factor=20)[source]#
Bases:
objectCompute the footprint of the scattered light coupling with the detector.
The footprint represents the spatial distribution of the scattered light as it couples with the detector. This is important for understanding how the scattered light interacts with the detector’s field of view and is influenced by both the scatterer’s properties and the detector configuration.
The footprint is computed using an inverse Fourier transform:
\[\big| \mathscr{F}^{-1} \big\{ \tilde{ \psi } (\xi, \nu),\ \tilde{ \phi}_{l,m}(\xi, \nu) \big\} (\delta_x, \delta_y) \big|^2\]Where:
\(\tilde{ \psi } (\xi, \nu)\): The Fourier transform of the scattered field.
\(\tilde{ \phi}_{l,m} (\xi, \nu)\): The Fourier transform of the detector’s capturing field.
\(\mathscr{F}^{-1}\): The inverse Fourier transform operator.
\((\delta_x, \delta_y)\): Spatial coordinates describing the footprint in the detector plane.
The inverse Fourier transform yields the spatial pattern of the scattered light’s interaction with the detector, which is then squared to compute the intensity of the footprint.
- Parameters:
detector (GenericDetector) – The detector object that defines the capturing field and geometry. This object provides information about the detector’s configuration, including its numerical aperture, position, and sensitivity.
setup (object)
sampling (int)
padding_factor (int)
- Returns:
An object containing the computed scatterer footprint, representing the spatial distribution of the scattered light on the detector plane.
- Return type:
Notes
The footprint provides valuable information about the coupling efficiency between the scattered light and the detector. This is useful in designing experiments where precise control of light detection is important, such as in microscopy, remote sensing, or optical measurements.
The interaction between the scattered field and the detector is influenced by factors such as the size, shape, and refractive index of the scatterer, as well as the detector’s aperture and positioning.
Example
You can use this method to compute the footprint of the scattered light on a detector, helping to visualize how light from the scatterer is spatially distributed on the detector.
Example usage:
>>> footprint = scatterer.get_footprint(detector=my_detector) >>> print(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.
- 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:
- 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