Skip to content

Commit 17d9c9a

Browse files
committed
Raise exception when catalog gap detected
1 parent e827038 commit 17d9c9a

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

pysynphot/catalog.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ def _getSpectrum(self, parlist, basename):
204204
os.path.join(basename,filename))
205205
sp = spectrum.TabularSourceSpectrum(filename, fluxname=column)
206206

207+
totflux = sp.integrate()
208+
if not N.isfinite(totflux) or totflux <= 0:
209+
raise exceptions.ParameterOutOfBounds(
210+
"Parameter '{0}' has no valid data.".format(parlist))
211+
207212
result = []
208213
for member in parlist:
209214
result.append(member)

pysynphot/test/test_catalog.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ def test_flux(self):
6666

6767
@use_cdbs
6868
@pytest.mark.parametrize(
69-
('teff', 'z', 'logg'),
70-
[(6440, 0, 10),
71-
(6440, 0, -1),
72-
(1.e6, 0, 4.3),
73-
(100, 0, 4.3),
74-
(6440, 2, 4.3),
75-
(6440, -6, 4.3)])
69+
('teff', 'z', 'logg'),
70+
[(6440, 0, 10),
71+
(6440, 0, -1),
72+
(1.e6, 0, 4.3),
73+
(100, 0, 4.3),
74+
(6440, 2, 4.3),
75+
(6440, -6, 4.3)])
7676
def test_Icat_exceptions(teff, z, logg):
7777
"""
7878
Tests for changes related to Trac ticket #211.
@@ -82,6 +82,18 @@ def test_Icat_exceptions(teff, z, logg):
8282
Icat('k93models', teff, z, logg)
8383

8484

85+
@use_cdbs
86+
def test_phoenix_gap():
87+
"""
88+
https://github.com/spacetelescope/pysynphot/issues/68
89+
"""
90+
Icat('phoenix', 2700, -1, 5.1) # OK
91+
with pytest.raises(ParameterOutOfBounds):
92+
Icat('phoenix', 2700, -0.5, 5.1)
93+
with pytest.raises(ParameterOutOfBounds):
94+
Icat('phoenix', 2700, -0.501, 5.1)
95+
96+
8597
@use_cdbs
8698
class TestCatalogCache(object):
8799
"""

0 commit comments

Comments
 (0)