Box

class kszx.Box(npix, pixsize, cpos=None)

The Box class represents a pixelization of an N-dimensional box.

The Box class requires the caller to manually choose the box size and observer location. See BoundingBox for a subclass which automatically chooses these parameters to match a galaxy survey.

Constructor args:

  • npix (tuple or 1-d array):

    Grid dimensions, e.g. (1024,1024,1024) For a non-cubic box, use unequal dimensions, e.g. (512,512,1024).

  • pixsize (float):

    Pixel side length (caller-specified units, usually Mpc). Note that pixsize is a scalar, i.e. pixels are always cubic.

  • cpos (tuple, 1-d array, or None):

    Location of box center, in coordinate system with observer at origin.

    Defaults to cpos=(npix*pixsize)/2, i.e. observer at lower-left corner. For a box with observer at the center, use cpos=(0,0,0).

    The observer location matters in some situations (e.g. gridding a galaxy catalog, where galaxy locations are specified in observer coordinates), but not others (e.g. taking an FFT).

Maps and array shapes:

Note that we define a Box class, but not a Map class.

Instead, a real-space map is represented by a pair (box, arr), where ‘arr’ is a numpy array with dtype=float. Similarly, a Fourier-space map is represented by a pair (box, arr), where ‘arr’ is a numpy array with dtype=complex.

The real-space and Fourier-space array shapes are related as follows:

\[(\mbox{real-space shape}) = (n_0, n_1, \cdots, n_{d-1})\]
\[(\mbox{Fourier-space shape})= (n_0, n_1, \cdots, \lfloor n_{d-1}/2 \rfloor + 1)\]

Members:

  • ndim (integer): Number of dimensions (usually 3).

  • pixsize (float): Pixel side length in user-defined coordinates.

  • boxsize (length-ndim array): Box side lengths in user-defined coordinates (equal to npix * pixsize).

  • npix (length-ndim array): Real-space map shape, represented as numpy array.

  • real_space_shape (tuple): same as ‘npix’, but represented as tuple instead of 1-d array

  • nk (length-ndim array): Fourier-space map shape, represented as numpy array.

  • fourier_space_shape (tuple) same as ‘nk’, but represented as tuple instead of 1-d array

  • cpos (length-ndim array): location of box center, in observer coordinates

  • lpos (length-ndim array): location of lower left box corner, in observer coordinates

  • rpos (length-ndim array): location of upper right box corner, in observer coordinates

  • kfund (length-ndim array): Lowest frequency on each axis (equal to 2pi/boxsize)

  • knyq (float): Nyquist frequency (equal to pi/pixsize)

  • box_volume (float): Box volume (equal to prod(boxsize))

  • pixel_volume (float): Pixel volume (equal to pixsize^N)

Fourier conventions:

\[f(k) = V_{pix} \sum_x f(x) e^{-ik\cdot x}\]

\[f(x) = V_{box}^{-1} \sum_k f(k) e^{ik\cdot x}\]

\[\langle f(k) f(k')^* \rangle = V_{box} P(k) \delta_{k,k'}\]