ParticleBasedForwardModel

class aquila_borg.forward.ParticleBasedForwardModel

Special abstract class to provide an API to access to particles used in the forward computation of certain models.

getNumberOfParticles(self: aquila_borg._borg.forward.ParticleBasedForwardModel) → int

Return the number of particles present on the current MPI task

getParticlePositions(self: aquila_borg._borg.forward.ParticleBasedForwardModel, positions: numpy.ndarray[numpy.float64]) → None

Return the positions of the particles in the provided numpy array

Parameters

positions (np.array) – Pre-allocated numpy array Nx3. N must be at least the number returned by ref:getNumberOfParticles

getParticleVelocities(self: aquila_borg._borg.forward.ParticleBasedForwardModel, velocities: numpy.ndarray[numpy.float64]) → None

Return the velocities of the particles in the provided numpy array

Parameters

velocities (np.array) – Pre-allocated numpy array Nx3. N must be at least the number returned by ref:getNumberOfParticles

setStepNotifier(self: aquila_borg._borg.forward.ParticleBasedForwardModel, arg0: object) → None

Setup a callback when a new step is being computed for particles.

TODO: The C++ side has access to particles, which has not yet been done for the Python callback

Parameters

callback (object) – A callable object. The object will be called with two arguments: the time and the number of particles on the current task.

Methods

__init__

Initialize self.

accumulateAdjoint(self, do_accumulate)

Request the model to accumulate adjoint vectors instead of resetting at each call.

adjointModel_v2(self, adjoint_gradient)

Pushes the adjoint gradient from a deeper part of the computation.

clearAdjointGradient(self)

Clear accumulated information to compute the adjoint gradient vector.

forwardModel(self, arg0, arg1)

forwardModel_v2(self, arg0)

Run the first part of the forward model (v2 API).

getAdjointModel(self, arg0)

getBoxModel(self)

Return the box on which is defined the input of the model is defined.

getCommunicator(self)

Build and return an MPI4PY communicator object that is linked to the internal MPI communicator of that object.

getDensityFinal(self, arg0)

Obtain the density field produced by the forward model (part 2 of the evaluation, v2 API).

getMPISlice(self)

Returns a tuple of integer indicating the way the slab is distributed among the node.

getModelParam(self, model, keyname)

This queries the current state of the parameters ‘keyname’ in model ‘model’.

getNumberOfParticles(self)

Return the number of particles present on the current MPI task

getOutputBoxModel(self)

Return the box on which is defined the output of the model is defined.

getOutputMPISlice(self)

Return a tuple indicating what is the expected output MPI slicing (startN0,localN0,N1,N2) (Warning! unstable API)

getParticlePositions(self, positions)

Return the positions of the particles in the provided numpy array

getParticleVelocities(self, velocities)

Return the velocities of the particles in the provided numpy array

getPreferredInput(self)

Returns the preferred output format (i.e.

getPreferredOutput(self)

Returns the preferred output format (i.e.

holdParticles(self)

setAdjointRequired(self, arg0)

Indicate whether the caller require the adjoint gradient to be computed later.

setCosmoParams(self, cosmo_params)

Setup the cosmological parameters that this model requires.

setModelParams(self, params)

Allow changing model parameters for different model indexed by the dictionnary key, each item is another dictionnary with key/value pairs.

setName(self, name)

Give a to localize more easily a model instance.

setStepNotifier(self, arg0)

Setup a callback when a new step is being computed for particles.