refmod.hapke.functions.vectors#

Module Contents#

refmod.hapke.functions.vectors.normalize(x, axis=-1)#

Normalizes a vector or a batch of vectors.

Calculates the L2 norm (Euclidean norm) of the input array along the specified axis.

Parameters:
  • x (npt.NDArray) – Input array representing a vector or a batch of vectors.

  • axis (int, optional) – Axis along which to compute the norm, by default -1.

Returns:

The L2 norm of the input array. If x is a batch of vectors, the output will be an array of norms.

Return type:

npt.NDArray

refmod.hapke.functions.vectors.normalize_keepdims(x, axis=-1)#

Normalizes a vector or batch of vectors, keeping dimensions.

Calculates the L2 norm of the input array along the specified axis, then expands the dimensions of the output to match the input array’s dimension along the normalization axis. This is useful for broadcasting the norm for division.

Parameters:
  • x (npt.NDArray) – Input array representing a vector or a batch of vectors.

  • axis (int, optional) – Axis along which to compute the norm, by default -1.

Returns:

The L2 norm of the input array, with dimensions kept for broadcasting.

Return type:

npt.NDArray

refmod.hapke.functions.vectors.angle_processing_base(vec_a, vec_b, axis=-1)#

Computes cosine and sine of the angle between two vectors.

Parameters:
  • vec_a (npt.NDArray) – First vector or batch of vectors.

  • vec_b (npt.NDArray) – Second vector or batch of vectors. Must have the same shape as vec_a.

  • axis (int, optional) – Axis along which the dot product is performed, by default -1.

Returns:

A tuple containing:
  • cos_phinpt.NDArray

    Cosine of the angle(s) between vec_a and vec_b.

  • sin_phinpt.NDArray

    Sine of the angle(s) between vec_a and vec_b.

Return type:

tuple[npt.NDArray, npt.NDArray]

refmod.hapke.functions.vectors.angle_processing(vec_a, vec_b, axis=-1)#

Computes various trigonometric quantities related to the angle between two vectors.

Parameters:
  • vec_a (npt.NDArray) – First vector or batch of vectors.

  • vec_b (npt.NDArray) – Second vector or batch of vectors. Must have the same shape as vec_a.

  • axis (int, optional) – Axis along which the dot product is performed, by default -1.

Returns:

A tuple containing:
  • cos_phinpt.NDArray

    Cosine of the angle(s) between vec_a and vec_b.

  • sin_phinpt.NDArray

    Sine of the angle(s) between vec_a and vec_b.

  • cot_phinpt.NDArray

    Cotangent of the angle(s) between vec_a and vec_b. (Returns np.inf where sin_phi is 0).

  • inpt.NDArray

    The angle(s) in radians between vec_a and vec_b (i.e., arccos(cos_phi)).

Return type:

tuple[npt.NDArray, npt.NDArray, npt.NDArray, npt.NDArray]