stack_observations

stack_observations#

scarlet2.stack_observations(observations, model_frame, name=None)[source]#

Stack observations into a single one on the grid of model_frame

Observations from different instruments or epochs can be treated as extra channels of one observation. Rendering then vectorizes over all channels at once instead of looping over observations (see #287).

Any observation that does not already sample the same sky pixel grid as model_frame (the same WCS orientation and scale, up to an integer pixel offset) is first resampled onto it via CorrelatedObservation.from_resampling(), which turns it into a CorrelatedObservation. If that makes even one input observation correlated (because it was passed in that way, or because it needed resampling), every other observation is promoted to a CorrelatedObservation as well, via CorrelatedObservation.from_observation(), so that they can all be concatenated as one consistent noise model.

The data, PSF and (for CorrelatedObservation) mask and correlation_function of each observation are padded (marking the new pixels invalid) or trimmed to the spatial extent of model_frame and concatenated along the channel axis; the channel lists are concatenated as well.

Parameters:
  • observations (list of Observation) – Observations to stack. They must all carry a PSF, and their channels must be mutually distinct.

  • model_frame (Frame) – Frame defining the common spatial grid, typically scarlet2.Scene.frame.

  • name (str, optional) – Name of the stacked observation. Defaults to the joined names of the inputs.

Returns:

A single observation on the spatial grid of model_frame, with as many channels as all observations combined. CorrelatedObservation unless every input is a plain Observation that already shares the grid of model_frame.

Return type:

Observation or CorrelatedObservation