TransientArraySpectrum#

class scarlet2.TransientArraySpectrum(data, epochs=None, epoch_selector=<function TransientArraySpectrum.<lambda>>)[source]#

Bases: Spectrum

Variable source in a transient scene with possible quiescent periods

In the frames of transient scenes, the attribute channels are overloaded and defined with a spectral and a temporal component, e.g. channel = (band, epoch). This class is for models that vary in time, especially if they have periods of inactivity. The length of data is given by the number of active channels in the model frame; calling this spectrum reinserts a zero for every inactive (quiescent) channel, so that the result matches the full length and order of the model frame’s channels.

Parameters:
  • data (array) – Spectrum array, restricted to the active epochs. Contains as many elements as there are spectro-temporal channels in the model for which epoch_selector(channel) is in epochs.

  • epochs (list, array, optional) – List of temporal “epoch” identifiers for the active phases of the source. If None, all epochs are considered active.

  • epoch_selector (callable, optional) – Identify the temporal “epoch” component from the name/ID used in the channels of the model frame

Examples

>>> # model channels: [('G',0),('G',1),('R',0),('R',1),('R',2)]
>>> spectrum = jnp.ones(4)  # one value per active (band, epoch) channel
>>> epochs = [0, 1]
>>> epoch_selector = lambda channel: channel[1]
>>> TransientArraySpectrum(spectrum, epochs, epoch_selector=epoch_selector)

This defines a spectrum with one free parameter for every channel active during epochs 0 and 1, i.e. all but (‘R’,2). Calling this spectrum reinserts a zero for that inactive channel, so that the returned vector again has 5 elements, matching the model frame.

__call__()[source]#

What to run when the TransientArraySpectrum is called

data: array#

Data to describe the variable spectrum, restricted to the active channels.

The order in this array follows the order of the active (i.e. non-quiescent) channels in the model frame, i.e. those for which epochs selects an active epoch.

epochs: list#

Identifier for the list of active epochs. If set to None, all epochs are considered active

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

property parameters#

Parameters defined for this module

Returns:

name: (node, param) mapping for all parameters

Return type:

dict

replace(name, value)#

Replace member attribuge name with value

Parameters:
  • name (str) – Name of member to replace

  • value (any) – Value to replace member with

Returns:

The modified module.

Return type:

Module

replace_subtree(where, value, parameters=None)#

Replace the subtree where(self) with value and carry over all other parameters

Unlike replace(), value does not need to have the same structure as the subtree it replaces, e.g. an array morphology can be replaced by a SersicMorphology. Parameters defined for this module remain attached to the same nodes, except those inside the replaced subtree, which are dropped.

Parameters:
  • where (callable) – Function module -> node that selects the subtree to replace, as in equinox.tree_at()

  • value (any) – Replacement for the subtree. If this module has a frame, attributes of value given in sky coordinates are converted to pixel coordinates of that frame.

  • parameters (callable, optional) – Function module -> None that is called with the new module inside of a Parameters context to define parameters for the replacement, e.g. by calling Parameter on nodes of value.

Returns:

The modified module.

Return type:

Module

Examples

>>> sersic = SersicMorphology(n=jnp.array(2.), size=jnp.array(2.), shape=morph.shape)
>>> def sersic_parameters(morph):
>>>     Parameter(morph.n, name="n:0", prior=dist.Uniform(0.5, 6))
>>>     Parameter(morph.size, name="size:0", constraint=constraints.positive, stepsize=0.1)
>>>
>>> scene_ = scene.replace_subtree(lambda sc: sc.sources[0].morphology, sersic, sersic_parameters)

See also

remap()

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

property shape#

The shape of the spectrum as seen by the model frame, i.e. including the (zero-valued) quiescent channels