SpatialFluxComponent#

class jolideco.models.SpatialFluxComponent(flux_upsampled, flux_upsampled_error=None, mask=None, use_log_flux=True, upsampling_factor=1, prior=None, frozen=False, wcs=None)[source]#

Bases: Module

Flux component

flux_upsampled#

Initial flux tensor

Type:

~torch.Tensor

flux_upsampled_error#

Flux tensor error

Type:

~torch.Tensor

use_log_flux#

Use log scaling for flux

Type:

bool

upsampling_factor#

Spatial upsampling factor for the flux.

Type:

None

prior#

Prior for this flux component.

Type:

Prior

frozen#

Whether to freeze component.

Type:

bool

wcs#

World coordinate transform object

Type:

~astropy.wcs.WCS

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Attributes Summary

flux

Flux as torch tensor

flux_numpy

Flux as numpy array

flux_upsampled

Flux

flux_upsampled_error

Flux error as torch tensor

flux_upsampled_error_numpy

Flux error upsampled as numpy array

flux_upsampled_numpy

Flux upsampled as numpy array

is_sparse

shape

Shape of the flux component

shape_image

Image shape of the flux component

use_log_flux

Use log flux

wcs

Flux error

Methods Summary

as_gp_map()

Convert to Gammapy map

from_dict(data)

Create flux component from dict

from_flux_init_datasets(datasets, **kwargs)

Compute flux init from datasets by averaging over the raw flux estimate.

from_numpy(flux[, mask])

Create flux component from downsampled data.

parameters([recurse])

Parameter list

plot([ax, kwargs_norm])

Plot flux component as sky image

read(filename[, format])

Read flux component from file

to_dict([include_data])

Convert flux component configuration to dict, with simple data types.

write(filename[, format, overwrite])

Write flux component to file

Attributes Documentation

flux#

Flux as torch tensor

flux_numpy#

Flux as numpy array

flux_upsampled#

Flux

flux_upsampled_error#

Flux error as torch tensor

flux_upsampled_error_numpy#

Flux error upsampled as numpy array

flux_upsampled_numpy#

Flux upsampled as numpy array

is_sparse = False#
shape#

Shape of the flux component

shape_image#

Image shape of the flux component

use_log_flux#

Use log flux

wcs#

Flux error

Methods Documentation

as_gp_map()[source]#

Convert to Gammapy map

Returns:

map – Gammapy WCS map

Return type:

~gammapy.maps.WcsNDmap

classmethod from_dict(data)[source]#

Create flux component from dict

Parameters:

data (dict) – Parameter dict.

Returns:

flux_component – Flux component

Return type:

FluxComponent

classmethod from_flux_init_datasets(datasets, **kwargs)[source]#

Compute flux init from datasets by averaging over the raw flux estimate.

Parameters:
  • datasets (list of dict) – List of dictionaries containing, “counts”, “psf”, “background” and “exposure”.

  • **kwargs (dict) – Keyword arguments passed to FluxComponent

Returns:

flux_init – Initial flux estimate.

Return type:

~numpy.ndarray

classmethod from_numpy(flux, mask=None, **kwargs)[source]#

Create flux component from downsampled data.

Parameters:
  • flux (~numpy.ndarray) – Flux init array with 2 dimensions

  • **kwargs (dict) – Keyword arguments passed to FluxComponent

Returns:

flux_component – Flux component

Return type:

FluxComponent

parameters(recurse=True)[source]#

Parameter list

plot(ax=None, kwargs_norm=None, **kwargs)[source]#

Plot flux component as sky image

Parameters:
  • ax (~matplotlib.pyplot.Axes) – Plotting axes

  • kwargs_norm (dict) – Keyword arguments passed to ~astropy.visualization.simple_norm

  • **kwargs (dict) – Keywords forwarded to ~matplotlib.pyplot.imshow

Returns:

ax – Plotting axes

Return type:

~matplotlib.pyplot.Axes

classmethod read(filename, format=None)[source]#

Read flux component from file

Parameters:
  • filename (str or Path) – Output filename

  • format ({'asdf', 'yaml', 'fits'}) – Format to use.

Returns:

flux_component – Flux component

Return type:

FluxComponent

to_dict(include_data=None) dict[str, Any][source]#

Convert flux component configuration to dict, with simple data types.

Parameters:

include_data (None or {"numpy"}) – Optionally include data array in the given format

Returns:

data – Parameter dict.

Return type:

dict

write(filename, format=None, overwrite=False, **kwargs)[source]#

Write flux component to file

Parameters:
  • filename (str or Path) – Output filename

  • overwrite (bool) – Overwrite file.

  • format ({'asdf', 'yaml', 'fits'}) – Format to use.