nbodykit.algorithms.fftrecon

Classes

FFTRecon(data, ran, Nmesh[, bias, f, los, ...])

FFT based Lagrangian reconstruction algorithm in a periodic box.

class nbodykit.algorithms.fftrecon.FFTRecon(data, ran, Nmesh, bias=1.0, f=0.0, los=[0, 0, 1], R=20, position='Position', revert_rsd_random=False, scheme='LGS', BoxSize=None)[source]

FFT based Lagrangian reconstruction algorithm in a periodic box.

References

Eisenstein et al, 2007 http://adsabs.harvard.edu/abs/2007ApJ…664..675E Section 3, paragraph starting with ‘Restoring in full the …’

We follow a cleaner description in Schmitfull et al 2015,

Table I, and text below. Schemes are LGS, LF2 and LRR.

A slight difference against the paper is that Redshift distortion and bias are corrected in the linear order. The Random shifting followed Martin White’s suggestion to exclude the RSD by default. (with default revert_rsd_random=False.)

Parameters
  • data (CatalogSource,) – the data catalog, e.g. halos. data.attrs[‘BoxSize’] is used if argument BoxSize is not given.

  • ran (CatalogSource) – the random catalog, e.g. from a UniformCatalog object.

  • Nmesh (int) – The size of the FFT Mesh. Rule of thumb is that the size of a mesh cell shall be 2 ~ 4 times smaller than the smoothing length, R.

  • revert_rsd_random (boolean) – Revert the rsd for randoms as well as data. There are two conventions. either reverting rsd displacement in data displacement only(False) or in both data and randoms (True). Default is False.

  • R (float) – The radius of smoothing. 10 to 20 Mpc/h is usually cool.

  • bias (float) – The bias of the data catalog.

  • f (float) – The growth rate; if non-zero, correct for RSD

  • los (list) – The direction of the line of sight for RSD. Usually (default) [0, 0, 1].

  • position (string) – column to use for picking up the Position of the objects.

  • BoxSize (float or array_like) – the size of the periodic box, default is to infer from the data.

  • scheme (string) – The reconstruction scheme. LGS is the standard reconstruction (Lagrangian growth shift). LF2 is the F2 Lagrangian reconstruction. LRR is the random-random Lagrangian reconstruction.

Attributes
actions

A list of actions to apply to the density field when interpolating to the mesh.

attrs

A dictionary storing relevant meta-data about the CatalogSource.

Methods

apply(func[, kind, mode])

Return a view of the mesh, with actions updated to apply the specified function, either in Fourier space or configuration space, based on mode

compute([mode, Nmesh])

Compute / Fetch the mesh object into memory as a RealField or ComplexField object.

preview([axes, Nmesh, root])

Gather the mesh into as a numpy array, with (reduced) resolution.

save(output[, dataset, mode])

Save the mesh as a BigFileMesh on disk, either in real or complex space.

to_complex_field([out])

Convert the mesh source to the Fourier-space field, returning a pmesh.pm.ComplexField object.

to_field([mode, out])

Return the mesh as a pmesh Field object, either in Fourier space or configuration space, based on mode.

to_real_field()

Convert the mesh source to the configuration-space field, returning a pmesh.pm.RealField object.

view()

Return a "view" of the MeshSource, in the spirit of numpy's ndarray view.

paint

run

work_with

__finalize__(other)

Finalize the creation of a MeshSource object by copying over attributes from a second MeshSource.

Parameters

other (MeshSource) – the second MeshSource to copy over attributes from

__len__()

Length of a mesh source is zero

property actions

A list of actions to apply to the density field when interpolating to the mesh.

This stores tuples of (mode, func, kind); see apply() for more details.

apply(func, kind='wavenumber', mode='complex')

Return a view of the mesh, with actions updated to apply the specified function, either in Fourier space or configuration space, based on mode

Parameters
  • func (callable or a MeshFilter object) – func(x, y) where x is a list of r (k) values that broadcasts into a full array, when mode is ‘real’ (‘complex’); the value of x depends on kind. y is the value of the mesh field on the corresponding locations.

  • kind (string, optional) –

    if a MeshFilter object is given as func, this is ignored. The kind of value in x.

    • When mode is ‘complex’:

      • ’wavenumber’ means wavenumber from [- 2 pi / L * N / 2, 2 pi / L * N / 2).

      • ’circular’ means circular frequency from [- pi, pi).

      • ’index’ means [0, Nmesh )

    • When mode is ‘real’:

      • ’relative’ means distance from [-0.5 Boxsize, 0.5 BoxSize).

      • ’index’ means [0, Nmesh )

  • mode ('complex' or 'real', optional) – if a MeshFilter object is given as func, this is ignored. whether to apply the function to the mesh in configuration space or Fourier space

Returns

a view of the mesh object with the actions attribute updated to include the new action

Return type

MeshSource

property attrs

A dictionary storing relevant meta-data about the CatalogSource.

compute(mode='real', Nmesh=None)

Compute / Fetch the mesh object into memory as a RealField or ComplexField object.

preview(axes=None, Nmesh=None, root=0)

Gather the mesh into as a numpy array, with (reduced) resolution. The result is broadcast to all ranks, so this uses \(\mathrm{Nmesh}^3\) per rank.

Parameters
  • Nmesh (int, array_like) – The desired Nmesh of the result. Be aware this function allocates memory to hold a full Nmesh on each rank.

  • axes (int, array_like) – The axes to project the preview onto., e.g. (0, 1)

  • root (int, optional) – the rank number to treat as root when gathering to a single rank

Returns

out – An numpy array holding the real density field.

Return type

array_like

save(output, dataset='Field', mode='real')

Save the mesh as a BigFileMesh on disk, either in real or complex space.

Parameters
  • output (str) – name of the bigfile file

  • dataset (str, optional) – name of the bigfile data set where the field is stored

  • mode (str, optional) – real or complex; the form of the field to store

to_complex_field(out=None)

Convert the mesh source to the Fourier-space field, returning a pmesh.pm.ComplexField object.

Not implemented in the base class, unless object is a view.

to_field(mode='real', out=None)

Return the mesh as a pmesh Field object, either in Fourier space or configuration space, based on mode.

This will call to_real_field() or to_complex_field() based on mode.

Parameters

mode ('real' or 'complex') – the return type of the field

Returns

either a RealField of ComplexField, storing the value of the field on the mesh

Return type

RealField, ComplexField

to_real_field()[source]

Convert the mesh source to the configuration-space field, returning a pmesh.pm.RealField object.

Not implemented in the base class, unless object is a view.

view()

Return a “view” of the MeshSource, in the spirit of numpy’s ndarray view.

This returns a new MeshSource whose memory is owned by self.

Note that for CatalogMesh objects, this is overidden by the CatalogSource.view function.