iact_estimator.core#

Core module of the package.

Module Contents#

Functions#

setup_logging(log_level, source_name)

Create a logger.

get_horizon_stereo_profile(M1_data, M2_data)

Merge the horizon profiles into a stereo one.

check_input_configuration(config)

Import and initialize a spectral model.

initialize_model(config)

Import and initialize a spectral model.

observed_flux(energy, redshift, flux_int)

Get the attenuated flux of the source.

get_sed(energy, flux)

Compute the Spectral Energy Distribution (SED) from the source flux.

significance_li_ma(n_on, n_off, alpha[, mu_sig])

Get the Li & Ma significance.

prepare_data(config)

Extract the performance data.

source_detection(sigmas, observation_time)

Determine if the source can be detected.

calculate(energy_bins, gamma_rate, background_rate, ...)

Produce the necessary information to build an SED.

iact_estimator.core.setup_logging(log_level, source_name)[source]#

Create a logger.

The logger will have a console and file handler, saving to a file with the name of the required source.

Parameters:
log_levelstr

Logging level to use for the console handler. The file handler always uses DEBUG (all calls are saved).

source_namestr

Name of the source provided by the user via the command line interface. A log file with the source name as prefix will be created at the output path.

Returns:
logger~logging.Logger

Logger instance.

iact_estimator.core.get_horizon_stereo_profile(M1_data, M2_data)[source]#

Merge the horizon profiles into a stereo one.

Parameters:
M1_dataQTable

Horizone profile seen from M1. The table must have columns ‘azimuth’ and ‘zenith’, both in units of degrees.

M2_dataQTable

Horizone profile seen from M2. The table must have columns ‘azimuth’ and ‘zenith’, both in units of degrees.

Returns:
azarray-like

Azimuth values within the maximum range of the separate measurements.

zdarray-like

Zenith angle values for the merged horizon profile.

iact_estimator.core.check_input_configuration(config)[source]#

Import and initialize a spectral model.

Parameters:
configdict

Configuration data in form of a Python dictionary.

Returns:
validbool

Initialized instance of a spectral model.

iact_estimator.core.initialize_model(config)[source]#

Import and initialize a spectral model.

Parameters:
configdict

Configuration data in form of a Python dictionary.

Returns:
initialized_model~gammapy.modeling.models.SpectralModel

Initialized instance of a spectral model.

iact_estimator.core.observed_flux(energy, redshift, flux_int)[source]#

Get the attenuated flux of the source.

Parameters:
energy~astropy.units.Quantity

Array of energy values.

redshiftfloat

Redshift of the source.

flux_int~astropy.units.Quantity

TBD.

Returns:
validbool

Initialized instance of a spectral model.

iact_estimator.core.get_sed(energy, flux)[source]#

Compute the Spectral Energy Distribution (SED) from the source flux.

Parameters:
energy~astropy.units.Quantity

Energy values.

flux~astropy.units.Quantity

Source energy flux values.

Returns:
sed~astropy.units.Quantity

Spectral Energy Distribution.

iact_estimator.core.significance_li_ma(n_on, n_off, alpha, mu_sig=None)[source]#

Get the Li & Ma significance.

This is equivalent to eq.17 of [1].

Parameters:
n_onint

Measured counts in ON region.

n_offint

Measured counts in OFF region.

alphafloat

Acceptance ratio of ON and OFF measurements.

mu_sigfloat

Expected signal counts in ON region.

Returns:
sqrt_tsfloat`

Significance as the square root of the Test Statistic.

Notes

The implementation uses gammapy.stats.WStatCountsStatistic and takes the square root of the Test Statistic.

References

[1]

Li, T.-P. & Ma, Y.-Q., ApJ, 1983, 272, 317, 10.1086/161295.

iact_estimator.core.prepare_data(config)[source]#

Extract the performance data.

Parameters:
configdict

Configuration data in form of a Python dictionary.

Returns:
energy_bins~astropy.units.Quantity

Values of the energy bin edges.

gamma_rate~astropy.units.Quantity

Rate of gamma-ray events from performance data.

background_rate~astropy.units.Quantity

Rate of background events from performance data.

iact_estimator.core.source_detection(sigmas, observation_time)[source]#

Determine if the source can be detected.

Parameters:
sigmaslist of float

Values of the significance for each energy bin.

observation_timefloat

Observation time.

Returns:
combined_significancefloat

Combined significance.

iact_estimator.core.calculate(energy_bins, gamma_rate, background_rate, config, assumed_spectrum)[source]#

Produce the necessary information to build an SED.

Parameters:
energy_bins~astropy.units.Quantity

Values of the energy bin edges.

gamma_rate~astropy.units.Quantity

Rate of gamma-ray events from performance data.

background_rate~astropy.units.Quantity

Rate of background events from performance data.

configdict

Configuration data as a Python disctionary.

assumed_spectrum~gammapy.modeling.models.SpectralModel

Assumed spectral model of the source.

Returns:
enlist of float

Energy values.

sedlist of float

Values for the Spectral energy distribution.

dsedlist of float

Error on Spectral energy distribution.

sigmaslist of float

Significance for each energy bin.

detectedlist of bool

True if source is detected in energy bin, False otherwise.