bliss package

bliss.api module

bliss.generate module

bliss.train module

bliss.predict module

bliss.metrics module

bliss.plotting module

bliss.catalog module

class bliss.catalog.BaseTileCatalog(d: Dict[str, Tensor])[source]
class bliss.catalog.FullCatalog(height: int, width: int, d: Dict[str, Tensor])[source]
apply_param_bin(pname: str, p_min: float, p_max: float)[source]

Apply magnitude bin to given parameters.

classmethod from_file(cat_path, wcs, height, width, **kwargs) FullCatalog[source]

Loads FullCatalog from disk.

one_source(b: int, s: int)[source]

Return a dict containing all parameter for one specified light source.

static plocs_from_ra_dec(ras, decs, wcs: WCS)[source]
Converts RA/DEC coordinates into BLISS’s pixel coordinates.

BLISS pixel coordinates have (0, 0) as the lower-left corner, whereas standard pixel coordinates begin at (-0.5, -0.5). BLISS pixel coordinates are in row-column order, whereas standard pixel coordinates are in column-row order.

Parameters:
  • ras (Tensor) – (b, n) tensor of RA coordinates in degrees.

  • decs (Tensor) – (b, n) tensor of DEC coordinates in degrees.

  • wcs (WCS) – WCS object to use for transformation.

Returns:

A 1xNx2 tensor containing the locations of the light sources in pixel coordinates. This function does not write self[“plocs”], so you should do that manually if necessary.

to_tile_catalog(tile_slen: int, max_sources_per_tile: int, *, ignore_extra_sources=False, filter_oob=False, stable=True, inter_int_type=torch.int32) TileCatalog[source]

Returns the TileCatalog corresponding to this FullCatalog.

Parameters:
  • tile_slen – The side length of the tiles.

  • max_sources_per_tile – The maximum number of sources in one tile.

  • ignore_extra_sources – If False (default), raises an error if the number of sources in one tile exceeds the max_sources_per_tile. If True, only adds the tile parameters of the first max_sources_per_tile sources to the new TileCatalog.

  • filter_oob – If filter_oob is True (default is False), filter out the sources outside the image. (e.g. In case of data augmentation, there is a chance of some sources located outside the image)

  • stable – It stable is True (default), on tiles with more than one sources, the sources will be arranged in a stable order. Some speedup can be gained if you disable this tag.

  • inter_int_type – The dtype for the tensors counting the sources per tile. Default is torch.int32, and you can change it to torch.int8 to get speedup. But the overflow may happen without any warning.

Returns:

TileCatalog correspond to the each source in the FullCatalog.

Raises:
  • ValueError – If the number of sources in one tile exceeds max_sources_per_tile and ignore_extra_sources is False.

  • KeyError – If the tile_params contain plocs or n_sources.

class bliss.catalog.SourceType(value)[source]

An enumeration.

class bliss.catalog.TileCatalog(d: Dict[str, Tensor])[source]
filter_by_flux(min_flux=0, band=2)[source]

Restricts TileCatalog to sources that have a flux between min_flux and max_flux.

Parameters:
  • min_flux (float) – Minimum flux value to keep. Defaults to 0.

  • band (int) – The band to compare fluxes in. Defaults to 2 (r-band).

Returns:

a new catalog with only sources within the flux range. Note that the size

of the tensors stays the same, but params at sources outside the range are set to 0.

Return type:

TileCatalog

get_brightest_sources_per_tile(top_k=1, exclude_num=0, band=2)[source]

Restrict TileCatalog to only the brightest ‘on’ source per tile.

Parameters:
  • top_k (int) – The number of sources to keep per tile. Defaults to 1.

  • exclude_num (int) – A number of the brightest sources to exclude. Defaults to 0.

  • band (int) – The band to compare fluxes in. Defaults to 2 (r-band).

Returns:

a new catalog with only one source per tile

Return type:

TileCatalog

get_indices_of_on_sources() Tuple[Tensor, Tensor][source]

Get the indices of detected sources from each tile.

Returns:

A 2-D tensor of integers with shape n_samples x max(n_sources), where max(n_sources) is the maximum number of sources detected across all samples.

Each element of this tensor is an index of a particular source within a particular tile. For a particular sample i that had N detections, the first N indices of indices_sorted[i. :] will be the detected sources. This is accomplished by flattening the n_tiles_per_image and max_detections. For example, if we had 3 tiles with a maximum of two sources each, the elements of this tensor would take values from 0 up to and including 5.

property is_on_mask: Tensor

Provides tensor which indicates how many sources are present for each batch.

Return a boolean array of shape=(*n_sources.shape, max_sources) whose (*,l)th entry indicates whether there are more than l sources on the *th index.

Returns:

Tensor indicating how many sources are present for each batch.

to_full_catalog(tile_slen)[source]

Converts image parameters in tiles to parameters of full image.

Parameters:

tile_slen – The side length of the square tiles (in pixels).

Returns:

The FullCatalog instance corresponding to the TileCatalog instance.

NOTE: The locations (“locs”) are between 0 and 1. The output also contains pixel locations (“plocs”) that are between 0 and slen.

union(other, disjoint=False)[source]

Returns a new TileCatalog containing the union of the sources in self and other. The maximum number of sources in the returned catalog is the sum of the maximum number of sources in self and other if disjoint is false, otherwise it is unchanged.

Parameters:
  • other – Another TileCatalog.

  • disjoint – whether the catalogs cannot have sources in the same tiles

Returns:

A new TileCatalog containing the union of the sources in self and other.

bliss.catalog.convert_flux_to_magnitude(flux, zero_point)[source]

Convert from flux to magnitude.

For DC2, please set c to 3631e9. The conversion is described in “2.10 AB magnitudes” at https://pstn-001.lsst.io/fluxunits.pdf

Parameters:
  • flux – the flux in any linear unit

  • zero_point – you may change this according to your survey dataset;

Returns:

Tensor indicating fluxes in magnitude

bliss.encoder module

bliss.surveys module

bliss.simulator module