VariableSourceSpectrumGenerator

class gdt.core.simulate.generators.VariableSourceSpectrumGenerator(rsp, function, params, exposure, rng=None)[source]

Bases: SourceSpectrumGenerator

Simulation generator for a Poisson source spectrum, efficient for generating deviates when the source spectrum amplitude changes.

Once initialized, a single deviate or many deviates can be generated:

gen = AmpFreeSourceSpectrumGenerator(rsp, function params, exposure)

# generate a single deviate
next(gen)

# generate 10 deviates
[next(gen) for i in range(10)]

# change amplitude, and generate a new deviate
gen.amp = 0.01
next(gen)
Parameters:
  • rsp (Rsp) – A detector response object

  • function (Function) – A photon model function

  • params (iterable) – The parameters for the function

  • exposure (float) – The source exposure

  • seed (int, optional) – The RNG seed

Yields:

(EnergyBins) – A Poisson random deviate of the initialized source spectrum

Attributes Summary

amp

The amplitude, relative to initialized spectrum.

Methods Summary

set_rng(rng)

Set/change the generator.

Attributes Documentation

amp

The amplitude, relative to initialized spectrum. Setting amp=1 gives the initialized amplitude.

Type:

(float)

Methods Documentation

set_rng(rng)

Set/change the generator.

Parameters:

rng (numpy.random.Generator) – random number generator