CorrelatedObservation#

class scarlet2.CorrelatedObservation(data, psf=None, wcs=None, channels=None, renderer=None, name='', power_spectrum=None, correlation_function=None, mask=None)[source]#

Bases: Observation

Content and definition of an observation with pixel correlations

The noise model is still assumed to be Gaussian, but with correlations between pixels. The implementation computes the goodness of fit in Fourier space from the noise power spectrum to avoid the expensive computation of/with an inverse banded matrix in configuration space.

property N#

Number of unmasked pixels in the observation

__call__()#

Evaluate the model

check_set_renderer(frame)#

Check existence of renderer, or set it by calling match()

Parameters:

frame (Frame) – The frame to match

Return type:

None

data: jnp.ndarray#

Observed data

eval_chi_square_in_box_and_border(scene, border_width=3)#

Evaluate the weighted mean (weighted by the inverse variance weights) of the squared residuals for each source. Chi square is also computed for the perimeter outside the box of with border_width.

Parameters:
  • scene (Scene) – Scene containing the sources

  • border_width (int) – width of the border around the source box

Return type:

Dict of sources indices and their corresponding Dict of residuals inside and outside source box.

frame: Frame#

Metadata to describe what view of the sky data amounts to

classmethod from_observation(obs, patch_size=50, maxlength=2, resample_to_frame=None, lanczos_order=9, resample_psf=True)[source]#

Create a CorrelatedObservation from Observation

The method will construct a new Observation instance with a modified likelihood that takes into account the pixel correlation. To do so, it finds a patch of size L with as few sources as possible, measures the pixel correlations in that patch, and compute the corresponding 2D power spectrum.

Parameters:
  • obs (Observation) – Observation containing the data and original weight map

  • patch_size (int) – Linear size of the patch for measuring the correlation function

  • maxlength (int) – Maximum distance (in pixels) for the 2D correlation function

  • resample_to_frame (None, Frame) – Frame describing the desired spatial sampling

  • lanczos_order (int) – Lanczos order used by the resampling operation The argument has no effect if resample_to_frame is None.

  • resample_psf (bool, optional) – Whether to resample obs.psf to resample_to_frame. Should be set to False only if PSF is already sampled with the resolution of resample_to_frame. The argument has no effect if resample_to_frame is None.

Return type:

CorrelatedObservation

get(name=None)#

Get parameter(s) from this module

Parameters:

name (str, optional) – Name of parameter. If not set, returns all parameters.

Returns:

requested data arrays for parameters

Return type:

dict

goodness_of_fit(model)#

Evaluate the goodness of the model fit to the data

For a Gaussian noise model, the gof is defined as the averaged squared deviation of the model from the data, scaled by the variance of the data, aka mean chi squared :math:`

rac{1}{N}sum_i=1^N w_i (m_i - d_i)^2` with inverse variance weights \(w_i\).

Up to a normalization, the gof is identical to log-likelihood.

model: array

The (pre-rendered) predicted data cube, typically from evaluating Scene

float

log_likelihood(model)#

The logarithm the likelihood of data given model

Parameters:

model (array) – The (pre-rendered) predicted data cube, typically from evaluating Scene

Return type:

float

mask: Array#

Mask for invalid pixels

match(frame, renderer=None)#

Construct the mapping between frame (from the model) and this observation frame

Parameters:
  • frame (Frame) – Model frame, typically scarlet2.Scene.frame for the current scene.

  • renderer (Renderer, optional) – Custom transformation to translate the frame (from the model) to this observation frame. If not set, this method will attempt to create the mapping from the information in both frames.

Return type:

None

name: str#

Name to describe the observation

property parameters#

Parameters defined for this module

Returns:

name: (node, param) mapping for all parameters

Return type:

dict

power_spectrum: Array#

Noise power spectrum for log_likelihood()

render(model)#

Render model in the frame of this observation

Parameters:

model (array) – The (pre-rendered) predicted data cube, typically from evaluating Scene

Returns:

Prediction of the observation given the model. Has the same shape as data.

Return type:

array

renderer: None, Renderer, eqx.nn.Sequential#

Renderer to translate from the model frame the observation frame

set(values)#

Set parameter(s) from this module with values

Parameters:

values (dict[str,jnp.array]) – values to replace parameters with, identified by their name

Returns:

new module with parameter(s) replaced by values

Return type:

Module

weights: jnp.ndarray#

Statistical weights (usually inverse variance) for log_likelihood()