From 810cae93ba8eda6ae41ca0efdeab1fd796dbcab9 Mon Sep 17 00:00:00 2001 From: Douglas Burke Date: Tue, 21 Jul 2015 19:33:34 -0400 Subject: [PATCH] Use the same API for convolution models as other models. It turns out that the load_xsXXX() routines aren't necessary, since the models can be created using the same interface as the other models (after this change is made): e.g. ui.set_source(ui.xsphabs.gal * ui.xscflux.mdl(ui.xspowerlaw.pl)) This commit leaves in the load_xsXXX() routines, but they will probably be removed in the next commit. --- sherpa/astro/ui/__init__.py | 6 +++++- sherpa/astro/xspec/tests/test_xspec.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sherpa/astro/ui/__init__.py b/sherpa/astro/ui/__init__.py index e21c4c08bd..fae15b848f 100644 --- a/sherpa/astro/ui/__init__.py +++ b/sherpa/astro/ui/__init__.py @@ -48,7 +48,9 @@ if hasattr(sherpa.astro, 'xspec'): _session._add_model_types(sherpa.astro.xspec, (sherpa.astro.xspec.XSAdditiveModel, - sherpa.astro.xspec.XSMultiplicativeModel)) + sherpa.astro.xspec.XSMultiplicativeModel, + sherpa.astro.xspec.XSConvolutionKernel) + ) # Perhaps everything exported by the xspec module should be exported # here? @@ -64,6 +66,8 @@ # names, to make it easier to support different versions of # the XSpec library. # + # Is this still needed now that the models are added directly? + # for n in [n for n in dir(sherpa.astro.xspec) if n.startswith('load_xs') and n != 'load_xsconvolve']: globals()[n] = getattr(sherpa.astro.xspec, n) diff --git a/sherpa/astro/xspec/tests/test_xspec.py b/sherpa/astro/xspec/tests/test_xspec.py index b429606e77..d94e340106 100644 --- a/sherpa/astro/xspec/tests/test_xspec.py +++ b/sherpa/astro/xspec/tests/test_xspec.py @@ -164,7 +164,8 @@ def test_convolution_models(self): # (log 10 of this is -8.8). lflux = -5.0 #xs.load_xscflux("cmdl") - ui.load_xscflux("cmdl") + #ui.load_xscflux("cmdl") + ui.create_model_component('xscflux', 'cmdl') # If the test is run directly, this is not needed (i.e. the # variable cmdl is defined), but if run via 'python setup.py test'