Data Structures API#

This section provides detailed API documentation for Furax data structures.

Stokes Parameters#

Abstract Base Class#

class furax.obs.stokes.Stokes[source]#

Bases: ABC

stokes: ClassVar[Literal['I', 'QU', 'IQU', 'IQUV']]#
property shape: tuple[int, ...]#
property dtype: str | type[Any] | dtype | SupportsDType#
property structure: PyTree[jax._src.api.ShapeDtypeStruct]#
__matmul__(other)[source]#

Scalar product between Stokes pytrees.

Parameters:

other (Any)

Return type:

Any

ravel()[source]#

Ravels each Stokes component.

Return type:

Self

reshape(shape)[source]#

Reshape each Stokes component.

Parameters:

shape (tuple[int, ...])

Return type:

Self

classmethod class_for(stokes: Literal['I']) type[StokesI][source]#
classmethod class_for(stokes: Literal['QU']) type[StokesQU]
classmethod class_for(stokes: Literal['IQU']) type[StokesIQU]
classmethod class_for(stokes: Literal['IQUV']) type[StokesIQUV]

Returns the StokesPyTree subclass associated to the specified Stokes types.

classmethod structure_for(shape, dtype=<class 'numpy.float64'>)[source]#
Parameters:
Return type:

Self

classmethod from_stokes(i: Array | ndarray | bool | number | bool | int | float | complex) StokesI[source]#
classmethod from_stokes(i: ShapeDtypeStruct) StokesI
classmethod from_stokes(q: Array | ndarray | bool | number | bool | int | float | complex, u: Array | ndarray | bool | number | bool | int | float | complex) StokesQU
classmethod from_stokes(q: ShapeDtypeStruct, u: ShapeDtypeStruct) StokesQU
classmethod from_stokes(i: Array | ndarray | bool | number | bool | int | float | complex, q: Array | ndarray | bool | number | bool | int | float | complex, u: Array | ndarray | bool | number | bool | int | float | complex) StokesIQU
classmethod from_stokes(i: ShapeDtypeStruct, q: ShapeDtypeStruct, u: ShapeDtypeStruct) StokesIQU
classmethod from_stokes(i: Array | ndarray | bool | number | bool | int | float | complex, q: Array | ndarray | bool | number | bool | int | float | complex, u: Array | ndarray | bool | number | bool | int | float | complex, v: Array | ndarray | bool | number | bool | int | float | complex) StokesIQUV
classmethod from_stokes(i: ShapeDtypeStruct, q: ShapeDtypeStruct, u: ShapeDtypeStruct, v: ShapeDtypeStruct) StokesIQUV

Returns a StokesPyTree according to the specified Stokes vectors.

Examples

>>> tod_i = Stokes.from_stokes(i)
>>> tod_qu = Stokes.from_stokes(q, u)
>>> tod_iqu = Stokes.from_stokes(i, q, u)
>>> tod_iquv = Stokes.from_stokes(i, q, u, v)
abstract classmethod from_iquv(i, q, u, v)[source]#

Returns a StokesPyTree ignoring the Stokes components not in the type.

Parameters:
  • i (Float[Array, '...'])

  • q (Float[Array, '...'])

  • u (Float[Array, '...'])

  • v (Float[Array, '...'])

Return type:

Self

classmethod zeros(shape, dtype=<class 'float'>)[source]#
Parameters:
Return type:

Self

classmethod ones(shape, dtype=<class 'float'>)[source]#
Parameters:
Return type:

Self

classmethod full(shape, fill_value, dtype=<class 'float'>)[source]#
Parameters:
Return type:

Self

classmethod normal(key, shape, dtype=<class 'float'>)[source]#
Parameters:
Return type:

Self

classmethod uniform(shape, key, dtype=<class 'float'>, low=0.0, high=1.0)[source]#
Parameters:
Return type:

Self

Stokes Implementations#

class furax.obs.stokes.StokesI(i: jax.Array)[source]#

Bases: Stokes

Parameters:

i (Array)

stokes: ClassVar[Literal['I', 'QU', 'IQU', 'IQUV']] = 'I'#
i: Array#
classmethod from_iquv(i, q, u, v)[source]#

Returns a StokesPyTree ignoring the Stokes components not in the type.

Parameters:
  • i (Float[Array, '...'])

  • q (Float[Array, '...'])

  • u (Float[Array, '...'])

  • v (Float[Array, '...'])

Return type:

Self

class furax.obs.stokes.StokesQU(q: jax.Array, u: jax.Array)[source]#

Bases: Stokes

Parameters:
stokes: ClassVar[Literal['I', 'QU', 'IQU', 'IQUV']] = 'QU'#
q: Array#
u: Array#
classmethod from_iquv(i, q, u, v)[source]#

Returns a StokesPyTree ignoring the Stokes components not in the type.

Parameters:
  • i (Float[Array, '...'])

  • q (Float[Array, '...'])

  • u (Float[Array, '...'])

  • v (Float[Array, '...'])

Return type:

Self

class furax.obs.stokes.StokesIQU(i: jax.Array, q: jax.Array, u: jax.Array)[source]#

Bases: Stokes

Parameters:
stokes: ClassVar[Literal['I', 'QU', 'IQU', 'IQUV']] = 'IQU'#
i: Array#
q: Array#
u: Array#
classmethod from_iquv(i, q, u, v)[source]#

Returns a StokesPyTree ignoring the Stokes components not in the type.

Parameters:
  • i (Float[Array, '...'])

  • q (Float[Array, '...'])

  • u (Float[Array, '...'])

  • v (Float[Array, '...'])

Return type:

Self

class furax.obs.stokes.StokesIQUV(i: jax.Array, q: jax.Array, u: jax.Array, v: jax.Array)[source]#

Bases: Stokes

Parameters:
stokes: ClassVar[Literal['I', 'QU', 'IQU', 'IQUV']] = 'IQUV'#
i: Array#
q: Array#
u: Array#
v: Array#
classmethod from_iquv(i, q, u, v)[source]#

Returns a StokesPyTree ignoring the Stokes components not in the type.

Parameters:
  • i (Float[Array, '...'])

  • q (Float[Array, '...'])

  • u (Float[Array, '...'])

  • v (Float[Array, '...'])

Return type:

Self

Landscapes#

Abstract Base Classes#

class furax.obs.landscapes.Landscape(shape, dtype=<class 'numpy.float64'>)[source]#

Bases: ABC

Parameters:
property size: int#
abstract normal(key)[source]#
Parameters:

key (Key[Array, ''])

Return type:

PyTree[jaxtyping.Shaped[Array, ‘…’]]

abstract uniform(key, minval=0.0, maxval=1.0)[source]#
Parameters:
  • key (Key[Array, ''])

  • minval (float)

  • maxval (float)

Return type:

PyTree[jaxtyping.Shaped[Array, ‘…’]]

abstract full(fill_value)[source]#
Parameters:

fill_value (Shaped[Array, ''] | Shaped[ndarray, ''] | bool | number | bool | int | float | complex)

Return type:

PyTree[jaxtyping.Shaped[Array, ‘…’]]

zeros()[source]#
Return type:

PyTree[jaxtyping.Shaped[Array, ‘…’]]

ones()[source]#
Return type:

PyTree[jaxtyping.Shaped[Array, ‘…’]]

class furax.obs.landscapes.StokesLandscape(shape=None, stokes='IQU', dtype=<class 'numpy.float64'>, pixel_shape=None)[source]#

Bases: Landscape

Class representing a multidimensional map of Stokes vectors.

We assume that integer pixel values fall at the center of pixels (as in the FITS WCS standard, see Section 2.1.4 of Greisen et al., 2002, A&A 446, 747).

Variables:
  • shape – The shape of the array that stores the map values. The dimensions are in the reverse order of the FITS NAXIS* keywords. For a 2-dimensional map, the shape corresponds to (NAXIS2, NAXIS1) or (\(n_\mathrm{row}\), \(n_\mathrm{col}\)), i.e. (\(n_y\), \(n_x\)).

  • pixel_shape – The shape in reversed order. For a 2-dimensional map, the shape corresponds to (NAXIS1, NAXIS2) or (\(n_\mathrm{col}\), \(n_\mathrm{row}\)), i.e. (\(n_x\), \(n_y\)).

  • stokes – The identifier for the Stokes vectors (I, QU, IQU or IQUV)

  • dtype – The data type for the values of the landscape.

Parameters:
property size: int#
property structure: PyTree[jax._src.api.ShapeDtypeStruct]#
full(fill_value)[source]#
Parameters:

fill_value (Shaped[Array, ''] | Shaped[ndarray, ''] | bool | number | bool | int | float | complex)

Return type:

PyTree[jaxtyping.Shaped[Array, ‘{self.npixel}’]]

normal(key)[source]#
Parameters:

key (Key[Array, ''])

Return type:

PyTree[jaxtyping.Shaped[Array, ‘{self.npixel}’]]

uniform(key, minval=0.0, maxval=1.0)[source]#
Parameters:
  • key (Key[Array, ''])

  • minval (float)

  • maxval (float)

Return type:

PyTree[jaxtyping.Shaped[Array, ‘{self.npixel}’]]

get_coverage(arg)[source]#
Parameters:

arg (Sampling)

Return type:

Integer[Array, ‘{self.npixel}’]

world2index(theta, phi)[source]#
Parameters:
  • theta (Float[Array, '*dims'])

  • phi (Float[Array, '*dims'])

Return type:

Integer[Array, ‘*dims’]

abstract world2pixel(theta, phi)[source]#

Converts angles from WCS to pixel coordinates

Parameters:
  • theta (float) – Spherical \(\theta\) angle.

  • phi (float) – Spherical \(\phi\) angle.

Returns:

x, y, z, … pixel coordinates

Return type:

tuple[float, …]

pixel2index(*coords)[source]#

Converts multidimensional pixel coordinates into 1-dimensional indices.

For a map of shape \((n_y, n_x)\), the indices of the pixels are walked from the rightmost dimension \(n_x\) to the leftmost dimension \(n_y\) (row-major layout). In such a map, the pixel with float coordinates \((p_x, p_y)\) has an index \(i = round(p_x) + n_x round(p_y)\).

The indices travel from bottom to top, like the Y-coordinates.

Integer values of the pixel coordinates correspond to the pixel centers. The points \((p_x, p_y)\) strictly inside a pixel centered on the integer coordinates \((i_x, i_y)\) verify

  • \(i_x - ½ < p_x < i_x + ½\)

  • \(i_y - ½ < p_y < i_y + ½\)

The convention for pixels and indices is that the first one starts at zero.

Parameters:

*coords (Float[Array, '*dims']) – The floating-point pixel coordinates along the X, Y, Z, … axes.

Returns:

The 1-dimensional integer indices associated to the pixel coordinates. The data type is int32, unless the landscape largest index would overflow, in which case it is int64.

Return type:

Integer[Array, ‘*ndims’]

quat2pixel(quat)[source]#

Converts quaternion to floating-point pixel coordinates.

Parameters:

quat (Float[Array, '*dims 4'])

Return type:

tuple[Float[Array, ‘*dims’], …]

quat2index(quat)[source]#

Converts quaternion to 1-dimensional pixel indices.

Parameters:

quat (Float[Array, '*dims 4'])

Return type:

Integer[Array, ‘*dims’]

world2interp(theta, phi)[source]#

Returns (indices, weights) with a trailing neighbor dimension for interpolation.

Subclasses must override this to support interpolated pointing.

Parameters:
  • theta (Float[Array, '*dims'])

  • phi (Float[Array, '*dims'])

Return type:

tuple[Integer[Array, ‘…’], Float[Array, ‘…’]]

quat2interp(quat)[source]#

Converts quaternion to (indices, weights) for interpolation.

Parameters:

quat (Float[Array, '*dims 4'])

Return type:

tuple[Integer[Array, ‘…’], Float[Array, ‘…’]]

Implementations#

class furax.obs.landscapes.HealpixLandscape(nside, stokes='IQU', dtype=<class 'numpy.float64'>, nested=False)[source]#

Bases: StokesLandscape

Class representing a Healpix-projected map of Stokes vectors.

Parameters:
quat2index(quat)[source]#

Convert quaternion to HEALPix pixel index.

Parameters:

quat (float) – Quaternion.

Returns:

HEALPix pixel index.

Return type:

int

world2interp(theta, phi)[source]#

Returns (indices, weights) for bilinear HEALPix interpolation (n=4).

Parameters:
  • theta (Float[Array, '*dims'])

  • phi (Float[Array, '*dims'])

Return type:

tuple[Integer[Array, ‘*dims 4’], Float[Array, ‘*dims 4’]]

world2pixel(theta, phi)[source]#

Convert angles to HEALPix pixel index.

Parameters:
  • theta (float) – Spherical \(\theta\) angle.

  • phi (float) – Spherical \(\phi\) angle.

Returns:

HEALPix pixel index.

Return type:

int

class furax.obs.landscapes.FrequencyLandscape(nside, frequencies, stokes='IQU', dtype=<class 'numpy.float64'>)[source]#

Bases: HealpixLandscape

Parameters: