MapEventSampler

class gammapy.utils.random.MapEventSampler(npred_map, t_min, t_max, t_delta='1 s', temporal_model=None, random_state=0)[source]

Bases: object

Map event sampler.

Parameters:
npred_map : Map

Predicted number of counts map.

t_min : Time

Start time of the sampling.

t_max : Time

Stop time of the sampling.

t_delta : Quantity

Time step used for sampling of the temporal model.

temporal_model : LightCurveTableModel or PhaseCurveTableModel

Input light (or phase)-curve model of the source, given with columns labelled as “time” (or “phase)” and “normalization” (arbitrary units).

random_state : {int, ‘random-seed’, ‘global-rng’, RandomState}

Defines random number generator initialisation. Passed to get_random_state.

Attributes Summary

npred_total Sample the total number of predicted events.
ontime On time (Quantity)
time_unit

Methods Summary

sample_events(self[, n_events]) It converts the given sampled event list into an astropy table.
sample_position_energy(self[, n_events]) Sample position and energy of events.
sample_time(self[, n_events]) Sample arrival times of events.

Attributes Documentation

npred_total

Sample the total number of predicted events.

Returns:
npred_total : int

Number of predicted events.

ontime

On time (Quantity)

time_unit = Unit("s")

Methods Documentation

sample_events(self, n_events=None)[source]

It converts the given sampled event list into an astropy table.

Parameters:
n_events : int

Number of events to sample.

Returns:
events : table

Sampled event list in an astropy table format.

sample_position_energy(self, n_events=None)[source]

Sample position and energy of events.

Parameters:
n_events : int

Number of events to sample.

Returns:
coords : MapCoord object.

Sequence of coordinates and energies of the sampled events.

sample_time(self, n_events=None)[source]

Sample arrival times of events.

Parameters:
n_events : int

Number of events to sample.

Returns:
time : Quantity

Array with times of the sampled events.