Phase#

Phase operations: shifting, wrapping and random perturbations.

Utility functions to apply wavelength-dependent phase shifts, wrap phases into an interval, and add Gaussian noise.

phise.modules.phase.shift_jit(
ψ: complex | ndarray,
δφ: float | ndarray,
λ: float,
) complex | ndarray#

Phase rotation (njit) of an electric field.

Parameters:
  • ψ – Complex electric field (scalar or array).

  • δφ – Applied phase shift (same unit as λ once converted).

  • λ – Wavelength (scalar, in length units).

Returns:

Field with phase shift applied, same shape as ψ.

phise.modules.phase.shift(
ψ: complex | ndarray,
δφ: Quantity,
λ: Quantity,
) complex | ndarray[source]#

Apply a phase shift with unit handling.

Converts Quantity inputs to numeric values then calls shift_jit().

Parameters:
  • ψ – Complex electric field (scalar or array).

  • δφ – Phase shift (length Quantity, e.g. meters).

  • λ – Wavelength (length Quantity) used in 2π δφ/λ.

Returns:

Field with phase shift applied, same shape as ψ.

phise.modules.phase.bound(
φ: Quantity,
λ: Quantity,
) Quantity[source]#

Wrap a phase into [0, λ[ while preserving units.

Parameters:
  • φ – Phase (length Quantity) to wrap.

  • λ – Wavelength (length Quantity) defining the interval.

Returns:

Wrapped phase in [0, λ[ with the unit of φ.

phise.modules.phase.bound_jit(φ: float, λ: float) float#

Wrap a scalar phase into [0, λ[ (njit version).

Parameters:
  • φ – Scalar phase to wrap.

  • λ – Scalar wavelength defining the interval.

Returns:

Wrapped phase in [0, λ[ (implicit same unit as inputs).

phise.modules.phase.perturb(
φ: ndarray,
rms: Quantity,
) Quantity[source]#

Add Gaussian noise to phases with standard deviation rms.

Parameters:
  • φ – Array of phases as Quantity (all with the same unit).

  • rms – Noise standard deviation, same unit as φ.

Returns:

Quantity array of the same shape as φ with noisy phases.