How to use the sherpa.astro.ui function in sherpa

To help you get started, we’ve selected a few sherpa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gammapy / gammapy / gammapy / scripts / image_fit.py View on Github external
def cli_image_fit(counts, exposure, background, psf,
                  sources, roi, outfile):
    """Fit morphology model to image using Sherpa.

    Uses initial parameters from a JSON file (for now only Gaussians).
    """
    import sherpa.astro.ui
    from ..irf import SherpaMultiGaussPSF

    # ---------------------------------------------------------
    # Load images, PSF and sources
    # ---------------------------------------------------------
    log.info('Clearing the sherpa session')
    sherpa.astro.ui.clean()

    log.info('Reading counts: {}'.format(counts))
    sherpa.astro.ui.load_image(counts)

    log.info('Reading exposure: {}'.format(exposure))
    sherpa.astro.ui.load_table_model('exposure', exposure)

    log.info('Reading background: {}'.format(background))
    sherpa.astro.ui.load_table_model('background', background)

    if psf:
        log.info('Reading PSF: {}'.format(psf))
        SherpaMultiGaussPSF(psf).set()
    else:
        log.warning("No PSF convolution.")
github gammapy / gammapy / gammapy / scripts / image_fit.py View on Github external
def _set(name, par, val):
    """Set a source parameter."""
    import sherpa.astro.ui as sau
    sau.set_par('{name}.{par}'.format(**locals()), val)
github sherpa / sherpa / sherpa / astro / datastack / ds.py View on Github external
get_bkg_scale = simple_wrapper(ui.get_bkg_scale)
    group_adapt = simple_wrapper(ui.group_adapt)
    group_adapt_snr = simple_wrapper(ui.group_adapt_snr)
    group_bins = simple_wrapper(ui.group_bins)
    group_counts = simple_wrapper(ui.group_counts)
    group_snr = simple_wrapper(ui.group_snr)
    group_width = simple_wrapper(ui.group_width)
    load_arf = simple_wrapper(ui.load_arf)
    load_rmf = simple_wrapper(ui.load_rmf)
    load_bkg_arf = simple_wrapper(ui.load_bkg_arf)
    load_bkg_rmf = simple_wrapper(ui.load_bkg_rmf)
    load_filter = simple_wrapper(ui.load_filter)
    load_grouping = simple_wrapper(ui.load_grouping)
    fit_bkg = fit_wrapper(ui.fit_bkg)
    fit = fit_wrapper(ui.fit)
    conf = fit_wrapper(ui.conf)
    plot_arf = plot_wrapper(ui.plot_arf)
    plot_bkg_fit = plot_wrapper(ui.plot_bkg_fit)
    plot_bkg_ratio = plot_wrapper(ui.plot_bkg_ratio)
    plot_chisqr = plot_wrapper(ui.plot_chisqr)
    plot_fit_delchi = plot_wrapper(ui.plot_fit_delchi)
    plot_psf = plot_wrapper(ui.plot_psf)
    plot_bkg = plot_wrapper(ui.plot_bkg)
    plot_bkg_fit_delchi = plot_wrapper(ui.plot_bkg_fit_delchi)
    plot_bkg_resid = plot_wrapper(ui.plot_bkg_resid)
    plot_data = plot_wrapper(ui.plot_data)
    plot_fit_resid = plot_wrapper(ui.plot_fit_resid)
    plot_ratio = plot_wrapper(ui.plot_ratio)
    plot_bkg_chisqr = plot_wrapper(ui.plot_bkg_chisqr)
    plot_bkg_fit_resid = plot_wrapper(ui.plot_bkg_fit_resid)
    plot_bkg_source = plot_wrapper(ui.plot_bkg_source)
    plot_delchi = plot_wrapper(ui.plot_delchi)
github sherpa / sherpa / sherpa / astro / datastack / ds.py View on Github external
get_model = simple_wrapper(ui.get_model)
    get_bkg_model = simple_wrapper(ui.get_bkg_model)
    get_bkg_scale = simple_wrapper(ui.get_bkg_scale)
    group_adapt = simple_wrapper(ui.group_adapt)
    group_adapt_snr = simple_wrapper(ui.group_adapt_snr)
    group_bins = simple_wrapper(ui.group_bins)
    group_counts = simple_wrapper(ui.group_counts)
    group_snr = simple_wrapper(ui.group_snr)
    group_width = simple_wrapper(ui.group_width)
    load_arf = simple_wrapper(ui.load_arf)
    load_rmf = simple_wrapper(ui.load_rmf)
    load_bkg_arf = simple_wrapper(ui.load_bkg_arf)
    load_bkg_rmf = simple_wrapper(ui.load_bkg_rmf)
    load_filter = simple_wrapper(ui.load_filter)
    load_grouping = simple_wrapper(ui.load_grouping)
    fit_bkg = fit_wrapper(ui.fit_bkg)
    fit = fit_wrapper(ui.fit)
    conf = fit_wrapper(ui.conf)
    plot_arf = plot_wrapper(ui.plot_arf)
    plot_bkg_fit = plot_wrapper(ui.plot_bkg_fit)
    plot_bkg_ratio = plot_wrapper(ui.plot_bkg_ratio)
    plot_chisqr = plot_wrapper(ui.plot_chisqr)
    plot_fit_delchi = plot_wrapper(ui.plot_fit_delchi)
    plot_psf = plot_wrapper(ui.plot_psf)
    plot_bkg = plot_wrapper(ui.plot_bkg)
    plot_bkg_fit_delchi = plot_wrapper(ui.plot_bkg_fit_delchi)
    plot_bkg_resid = plot_wrapper(ui.plot_bkg_resid)
    plot_data = plot_wrapper(ui.plot_data)
    plot_fit_resid = plot_wrapper(ui.plot_fit_resid)
    plot_ratio = plot_wrapper(ui.plot_ratio)
    plot_bkg_chisqr = plot_wrapper(ui.plot_bkg_chisqr)
    plot_bkg_fit_resid = plot_wrapper(ui.plot_bkg_fit_resid)
github sherpa / sherpa / sherpa / astro / datastack / ds.py View on Github external
list may be empty.

        See Also
        --------
        query, query_by_header_keyword

        Examples
        --------

        >>> query_by_obsid(7867)
        [3]

        """
        return self.query_by_header_keyword('OBS_ID', value)

    load_ascii = load_wrapper(ui.load_ascii)
    load_data = load_wrapper(ui.load_data)
    load_bkg = load_wrapper(ui.load_bkg)
    set_source = model_wrapper(ui.set_source)
    set_model = model_wrapper(ui.set_model)
    set_bkg_model = model_wrapper(ui.set_bkg_model)
    set_full_model = model_wrapper(ui.set_full_model)
    set_bkg_full_model = model_wrapper(ui.set_bkg_full_model)
    subtract = simple_wrapper(ui.subtract)
    notice = simple_wrapper(ui.notice_id)
    ignore = simple_wrapper(ui.ignore_id)
    get_arf = simple_wrapper(ui.get_arf)
    get_rmf = simple_wrapper(ui.get_rmf)
    get_response = simple_wrapper(ui.get_response)
    get_bkg_arf = simple_wrapper(ui.get_bkg_arf)
    get_bkg_rmf = simple_wrapper(ui.get_bkg_rmf)
    get_bkg = simple_wrapper(ui.get_bkg)
github sherpa / sherpa / sherpa / astro / datastack / ds.py View on Github external
[3]

        """
        return self.query_by_header_keyword('OBS_ID', value)

    load_ascii = load_wrapper(ui.load_ascii)
    load_data = load_wrapper(ui.load_data)
    load_bkg = load_wrapper(ui.load_bkg)
    set_source = model_wrapper(ui.set_source)
    set_model = model_wrapper(ui.set_model)
    set_bkg_model = model_wrapper(ui.set_bkg_model)
    set_full_model = model_wrapper(ui.set_full_model)
    set_bkg_full_model = model_wrapper(ui.set_bkg_full_model)
    subtract = simple_wrapper(ui.subtract)
    notice = simple_wrapper(ui.notice_id)
    ignore = simple_wrapper(ui.ignore_id)
    get_arf = simple_wrapper(ui.get_arf)
    get_rmf = simple_wrapper(ui.get_rmf)
    get_response = simple_wrapper(ui.get_response)
    get_bkg_arf = simple_wrapper(ui.get_bkg_arf)
    get_bkg_rmf = simple_wrapper(ui.get_bkg_rmf)
    get_bkg = simple_wrapper(ui.get_bkg)
    get_source = simple_wrapper(ui.get_source)
    get_model = simple_wrapper(ui.get_model)
    get_bkg_model = simple_wrapper(ui.get_bkg_model)
    get_bkg_scale = simple_wrapper(ui.get_bkg_scale)
    group_adapt = simple_wrapper(ui.group_adapt)
    group_adapt_snr = simple_wrapper(ui.group_adapt_snr)
    group_bins = simple_wrapper(ui.group_bins)
    group_counts = simple_wrapper(ui.group_counts)
    group_snr = simple_wrapper(ui.group_snr)
    group_width = simple_wrapper(ui.group_width)
github gammapy / gammapy / gammapy / hspec / read_spectra.py View on Github external
def __init__(self, name, filename):  # name means datid!!
        self.name = name
        sau.load_pha(name, filename)
        self.data = sau.get_data(name)
        self.arf = sau.get_data(name)
        self.rmf = sau.get_data(name)

        try:  # Read keywords from pha header
            self.threshold = self.data.header['ETH']
        except KeyError:
            print(" ! WARNING: no threshold found, using 200 GeV")
            self.threshold = 2e8  # default value 200 GeV
        self.emax = 1e11  # default value 100 TeV

        try:
            self.zenith = self.data.header['ZENITH']
        except KeyError:
            print("WARNING: no mean zenith angle found, using 45 deg")
            self.zenith = 45.0  # default value 200 GeV

        try:
github sherpa / sherpa / sherpa / astro / datastack / ds.py View on Github external
get_bkg_arf = simple_wrapper(ui.get_bkg_arf)
    get_bkg_rmf = simple_wrapper(ui.get_bkg_rmf)
    get_bkg = simple_wrapper(ui.get_bkg)
    get_source = simple_wrapper(ui.get_source)
    get_model = simple_wrapper(ui.get_model)
    get_bkg_model = simple_wrapper(ui.get_bkg_model)
    get_bkg_scale = simple_wrapper(ui.get_bkg_scale)
    group_adapt = simple_wrapper(ui.group_adapt)
    group_adapt_snr = simple_wrapper(ui.group_adapt_snr)
    group_bins = simple_wrapper(ui.group_bins)
    group_counts = simple_wrapper(ui.group_counts)
    group_snr = simple_wrapper(ui.group_snr)
    group_width = simple_wrapper(ui.group_width)
    load_arf = simple_wrapper(ui.load_arf)
    load_rmf = simple_wrapper(ui.load_rmf)
    load_bkg_arf = simple_wrapper(ui.load_bkg_arf)
    load_bkg_rmf = simple_wrapper(ui.load_bkg_rmf)
    load_filter = simple_wrapper(ui.load_filter)
    load_grouping = simple_wrapper(ui.load_grouping)
    fit_bkg = fit_wrapper(ui.fit_bkg)
    fit = fit_wrapper(ui.fit)
    conf = fit_wrapper(ui.conf)
    plot_arf = plot_wrapper(ui.plot_arf)
    plot_bkg_fit = plot_wrapper(ui.plot_bkg_fit)
    plot_bkg_ratio = plot_wrapper(ui.plot_bkg_ratio)
    plot_chisqr = plot_wrapper(ui.plot_chisqr)
    plot_fit_delchi = plot_wrapper(ui.plot_fit_delchi)
    plot_psf = plot_wrapper(ui.plot_psf)
    plot_bkg = plot_wrapper(ui.plot_bkg)
    plot_bkg_fit_delchi = plot_wrapper(ui.plot_bkg_fit_delchi)
    plot_bkg_resid = plot_wrapper(ui.plot_bkg_resid)
    plot_data = plot_wrapper(ui.plot_data)
github sherpa / sherpa / sherpa / astro / datastack / ds.py View on Github external
get_arf = simple_wrapper(ui.get_arf)
    get_rmf = simple_wrapper(ui.get_rmf)
    get_response = simple_wrapper(ui.get_response)
    get_bkg_arf = simple_wrapper(ui.get_bkg_arf)
    get_bkg_rmf = simple_wrapper(ui.get_bkg_rmf)
    get_bkg = simple_wrapper(ui.get_bkg)
    get_source = simple_wrapper(ui.get_source)
    get_model = simple_wrapper(ui.get_model)
    get_bkg_model = simple_wrapper(ui.get_bkg_model)
    get_bkg_scale = simple_wrapper(ui.get_bkg_scale)
    group_adapt = simple_wrapper(ui.group_adapt)
    group_adapt_snr = simple_wrapper(ui.group_adapt_snr)
    group_bins = simple_wrapper(ui.group_bins)
    group_counts = simple_wrapper(ui.group_counts)
    group_snr = simple_wrapper(ui.group_snr)
    group_width = simple_wrapper(ui.group_width)
    load_arf = simple_wrapper(ui.load_arf)
    load_rmf = simple_wrapper(ui.load_rmf)
    load_bkg_arf = simple_wrapper(ui.load_bkg_arf)
    load_bkg_rmf = simple_wrapper(ui.load_bkg_rmf)
    load_filter = simple_wrapper(ui.load_filter)
    load_grouping = simple_wrapper(ui.load_grouping)
    fit_bkg = fit_wrapper(ui.fit_bkg)
    fit = fit_wrapper(ui.fit)
    conf = fit_wrapper(ui.conf)
    plot_arf = plot_wrapper(ui.plot_arf)
    plot_bkg_fit = plot_wrapper(ui.plot_bkg_fit)
    plot_bkg_ratio = plot_wrapper(ui.plot_bkg_ratio)
    plot_chisqr = plot_wrapper(ui.plot_chisqr)
    plot_fit_delchi = plot_wrapper(ui.plot_fit_delchi)
    plot_psf = plot_wrapper(ui.plot_psf)
    plot_bkg = plot_wrapper(ui.plot_bkg)
github sherpa / sherpa / sherpa / astro / datastack / ds.py View on Github external
load_data = load_wrapper(ui.load_data)
    load_bkg = load_wrapper(ui.load_bkg)
    set_source = model_wrapper(ui.set_source)
    set_model = model_wrapper(ui.set_model)
    set_bkg_model = model_wrapper(ui.set_bkg_model)
    set_full_model = model_wrapper(ui.set_full_model)
    set_bkg_full_model = model_wrapper(ui.set_bkg_full_model)
    subtract = simple_wrapper(ui.subtract)
    notice = simple_wrapper(ui.notice_id)
    ignore = simple_wrapper(ui.ignore_id)
    get_arf = simple_wrapper(ui.get_arf)
    get_rmf = simple_wrapper(ui.get_rmf)
    get_response = simple_wrapper(ui.get_response)
    get_bkg_arf = simple_wrapper(ui.get_bkg_arf)
    get_bkg_rmf = simple_wrapper(ui.get_bkg_rmf)
    get_bkg = simple_wrapper(ui.get_bkg)
    get_source = simple_wrapper(ui.get_source)
    get_model = simple_wrapper(ui.get_model)
    get_bkg_model = simple_wrapper(ui.get_bkg_model)
    get_bkg_scale = simple_wrapper(ui.get_bkg_scale)
    group_adapt = simple_wrapper(ui.group_adapt)
    group_adapt_snr = simple_wrapper(ui.group_adapt_snr)
    group_bins = simple_wrapper(ui.group_bins)
    group_counts = simple_wrapper(ui.group_counts)
    group_snr = simple_wrapper(ui.group_snr)
    group_width = simple_wrapper(ui.group_width)
    load_arf = simple_wrapper(ui.load_arf)
    load_rmf = simple_wrapper(ui.load_rmf)
    load_bkg_arf = simple_wrapper(ui.load_bkg_arf)
    load_bkg_rmf = simple_wrapper(ui.load_bkg_rmf)
    load_filter = simple_wrapper(ui.load_filter)
    load_grouping = simple_wrapper(ui.load_grouping)