def make_test_model(nsources=100, npix=500, ampl=100, fwhm=30, random_state='random-seed'): """Create a model of several Gaussian sources. Parameters ---------- random_state : {int, 'random-seed', 'global-rng', `~numpy.random.RandomState`} Defines random number generator initialisation. Passed to `~gammapy.utils.random.get_random_state`. """ from sherpa.astro.ui import set_source from morphology.utils import _set, _name # initialise random number generator random_state = get_random_state(random_state) model = ' + '.join([_name(ii) for ii in range(nsources)]) set_source(model) for ii in range(nsources): _set(_name(ii), 'xpos', random_state.uniform(0, npix)) _set(_name(ii), 'ypos', random_state.uniform(0, npix)) _set(_name(ii), 'ampl', random_state.uniform(0, ampl)) _set(_name(ii), 'fwhm', random_state.uniform(0, fwhm))
def make_test_model(nsources=100, npix=500, ampl=100, fwhm=30): """Create a model of several Gaussian sources""" from numpy.random import random from sherpa.astro.ui import set_source from morphology.utils import _set, _name model = ' + '.join([_name(ii) for ii in range(nsources)]) set_source(model) for ii in range(nsources): _set(_name(ii), 'xpos', npix * random()) _set(_name(ii), 'ypos', npix * random()) _set(_name(ii), 'ampl', ampl * random()) _set(_name(ii), 'fwhm', fwhm * random())
def make_test_model(nsources=100, npix=500, ampl=100, fwhm=30): """Create a model of several Gaussian sources. """ from numpy.random import random from sherpa.astro.ui import set_source from morphology.utils import _set, _name model = ' + '.join([_name(ii) for ii in range(nsources)]) set_source(model) for ii in range(nsources): _set(_name(ii), 'xpos', npix * random()) _set(_name(ii), 'ypos', npix * random()) _set(_name(ii), 'ampl', ampl * random()) _set(_name(ii), 'fwhm', fwhm * random())
def make_test_model(nsources=100, npix=500, ampl=100, fwhm=30, random_state="random-seed"): """Create a model of several Gaussian sources. Parameters ---------- random_state : {int, 'random-seed', 'global-rng', `~numpy.random.RandomState`} Defines random number generator initialisation. Passed to `~gammapy.utils.random.get_random_state`. """ from sherpa.astro.ui import set_source from morphology.utils import _set, _name # initialise random number generator random_state = get_random_state(random_state) model = " + ".join([_name(ii) for ii in range(nsources)]) set_source(model) for ii in range(nsources): _set(_name(ii), "xpos", random_state.uniform(0, npix)) _set(_name(ii), "ypos", random_state.uniform(0, npix)) _set(_name(ii), "ampl", random_state.uniform(0, ampl)) _set(_name(ii), "fwhm", random_state.uniform(0, fwhm))