rball package

Subpackages

Submodules

rball.rballlike module

class rball.rballlike.RBallLike(name: str, observation, response_database: rball.response_database.ResponseDatabase, background=None, free_position: bool = True, **kwargs)[source]

Bases: threeML.plugins.DispersionSpectrumLike.DispersionSpectrumLike

__init__(name: str, observation, response_database: rball.response_database.ResponseDatabase, background=None, free_position: bool = True, **kwargs)[source]

A plugin for generic spectral data with energy dispersion, accepts an observed binned spectrum, and a background binned spectrum or plugin with the background data.

In the case of a binned background spectrum, the background model is profiled out and the appropriate profile-likelihood is used to fit the total spectrum. In this case, caution must be used when there are zero background counts in bins as the profiled background parameters (one per channel) will then have zero information from which to constrain the background. It is recommended to bin the spectrum such that there is one background count per channel.

If either an SpectrumLike or XYLike instance is provided as background, it is assumed that this is the background data and the likelihood model from this plugin is used to simultaneously fit the background and source.

Parameters
  • name – the plugin name

  • observation – the observed spectrum

  • background – the background spectrum or a plugin from which the background will be modeled

  • background_exposure – (optional) adjust the background exposure of the modeled background data comes from and

XYLike plugin :param verbose: turn on/off verbose logging

set_model(likelihood_model: astromodels.core.model.Model) None[source]

Set the model and free the location parameters

Parameters

likelihood_model

Returns

None

get_model(precalc_fluxes=None)[source]

The model integrated over the energy bins. Note that it only returns the model for the currently active channels/measurements

Returns

array of folded model

classmethod from_spectrumlike(spectrum_like: threeML.plugins.DispersionSpectrumLike.DispersionSpectrumLike, response_database: rball.response_database.ResponseDatabase, free_position: bool = True, **kwargs)[source]

Generate a RBallLike from an existing SpectrumLike child

Parameters
  • spectrum_like – the existing spectrumlike

  • response_database – a response database

  • free_position – if the position should be free

Returns

classmethod from_ogip(name: str, observation: str, response_database: rball.response_database.ResponseDatabase, background: Optional[str] = None, spectrum_number: Optional[int] = None, free_position: bool = True, **kwargs)[source]

Create an RBallLike from OGIP files

Parameters
  • cls

  • name (str) –

  • observation (str) –

  • background (str) –

  • response_database (ResponseDatabase) –

  • spectrum_number (Optional[int]) –

  • free_position (bool) –

Returns

get_simulated_dataset(new_name=None, **kwargs)[source]

Returns another DispersionSpectrumLike instance where data have been obtained by randomizing the current expectation from the model, as well as from the background (depending on the respective noise models)

Returns

a DispersionSpectrumLike simulated instance

rball.response_database module

class rball.response_database.ResponseDatabase(list_of_matrices: numpy.ndarray, theta: numpy.ndarray, phi: numpy.ndarray, ebounds: numpy.ndarray, monte_carlo_energies: numpy.ndarray)[source]

Bases: object

__init__(list_of_matrices: numpy.ndarray, theta: numpy.ndarray, phi: numpy.ndarray, ebounds: numpy.ndarray, monte_carlo_energies: numpy.ndarray)[source]
Parameters
  • list_of_matrices (np.ndarray) –

  • theta (np.ndarray) –

  • phi (np.ndarray) –

  • ebounds (np.ndarray) –

  • monte_carlo_energies (np.ndarray) –

:: :returns:

property current_response: threeML.utils.OGIP.response.InstrumentResponse
property grid_points: numpy.ndarray
property n_grid_points: int

the number of grid points in the response database :returns:

_transform_to_instrument_coordinates(ra: float, dec: float) Tuple[float][source]

This is a stub function that should take and RA/Dec pair (in degrees) and convert it into the coordinate system of the intruments which may or may not be in motion.

The function should return a spherical theta, phi tuple in radian

Parameters
  • ra

  • dec

Returns

(theta, phi) in radian

interpolate_to_position(ra: float, dec: float) None[source]
property current_sky_position: Tuple[float]
plot_verticies() matplotlib.figure.Figure[source]
plot_verticies_ipv(selected_location: Optional[Iterable[float]] = None)[source]
Parameters

selected_location – ra, dec tuple in degree

Module contents

Top-level package for rball.