[1]:
%load_ext autoreload
%autoreload 2
[2]:
import numpy as np

Source Definition

SkyLLH provides the base class SourceModel to define a source class. The SourceModel class is derived from the Model class, which is the base class for all kind of models in SkyLLH. A source model can have an astronomical classification and a source weight w.r.t. other sources.

Point-Like Sources

SkyLLH provides the PointLikeSource class for a point-like source at a certain right-ascention and declination coordinate.

[3]:
from skyllh.core.source_model import PointLikeSource
[4]:
src = PointLikeSource(
    name='TXS 0506+056',
    ra=np.radians(77.35),
    dec=np.radians(5.7),
    classification=None)
print(src)
PointLikeSource: "TXS 0506+056": { ra=77.350 deg, dec=5.700 deg }

Source Catalogs

SkyLLH provides the class SourceCatalog for creating a catalog of sources.

[5]:
from skyllh.core.catalog import SourceCatalog
[6]:
catalog = SourceCatalog('My Point-Source Catalog')

Sources can be added to a catalog via the in-place add operator:

[7]:
catalog += (
    PointLikeSource(
        name='TXS 0506+056',
        ra=np.radians(77.35),
        dec=np.radians(5.7),
        classification='BLL'),
    PointLikeSource(
        name='NGC 1068',
        ra=np.radians(40.67),
        dec=np.radians(-0.01),
        classification='SBG')
)

The catalog can be printed easily with the print function:

[8]:
print(catalog)
"My Point-Source Catalog" SourceCatalog: {
    PointLikeSource: "TXS 0506+056": { ra=77.350 deg, dec=5.700 deg, classification=BLL },
    PointLikeSource: "NGC 1068": { ra=40.670 deg, dec=-0.010 deg, classification=SBG }
}

The SourceCatalog class is derived from the SourceCollection class, which is derived from the ModelCollection class, which is derived from the NamedObjectCollection class. Hence, it implements the iterator protocol. Thus, the user can easily interate over the sources in the catalog:

[9]:
for source in catalog:
    print(source)
PointLikeSource: "TXS 0506+056": { ra=77.350 deg, dec=5.700 deg, classification=BLL }
PointLikeSource: "NGC 1068": { ra=40.670 deg, dec=-0.010 deg, classification=SBG }

The fact that SourceCatalog is derived from the NamedObjectCollection class has the advantage that sources can be accessed in the cataog like in a dictionary through their names:

[10]:
source = catalog['NGC 1068']
print(source)
PointLikeSource: "NGC 1068": { ra=40.670 deg, dec=-0.010 deg, classification=SBG }

Source Hypothesis Grouping

An analysis might test for several sources of the same kind, e.g. point-like sources. The SkyLLH framework can utilize the fact that calculations for same-kind sources are identical. Hence, SkyLLH provides the SourceHypoGroupManager class and the SourceHypoGroup to organize and manage groups of same-kind sources within the framework.

[11]:
from skyllh.core.source_hypo_grouping import SourceHypoGroupManager
from skyllh.core.source_hypo_grouping import SourceHypoGroup
A source hypothesis group groups several same-kind sources together for which the same flux model, detector signal yield builder, and signal generation method can be used.

After creating a SourceHypoGroup instance, a SourceHypoGroupManager can be created by passing a sequence of SourceHypoGroup instances to the constructor of the SourceHypoGroupManager class.