Skip to content

Commit

Permalink
fix emline test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-j committed Jun 19, 2022
1 parent 4ee9be4 commit 97543c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions prospect/data/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ def __init__(self, filters=[], name="PhotA", **kwargs):
name : string, optional
The name for this set of data
"""
self.set_filters(filters)
super(Photometry, self).__init__(name=name, **kwargs)

def set_filters(self, filters):
if not filters:
self.filters = filters
self.filternames = []
self.filterset = None
return

if type(filters[0]) is str:
self.filternames = filters
else:
Expand All @@ -206,8 +216,6 @@ def __init__(self, filters=[], name="PhotA", **kwargs):
# filters on the gridded resolution
self.filters = [f for f in self.filterset.filters]

super(Photometry, self).__init__(name=name, **kwargs)

@property
def wavelength(self):
return np.array([f.wave_effective for f in self.filters])
Expand Down Expand Up @@ -354,7 +362,8 @@ def __init__(self,
def from_oldstyle(obs, **kwargs):
"""Convert from an oldstyle dictionary to a list of observations
"""
obslist = [Spectrum(**obs), Photometry(**obs)]
spec, phot = Spectrum(**obs), Photometry(**obs)
#phot.set_filters(phot.filters)
#[o.rectify() for o in obslist]

return obslist
return [spec, phot]
6 changes: 3 additions & 3 deletions tests/test_eline.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def test_nebline_phot_addition():
(s2, p2), _ = m2.predict(m2.theta, obslist, sps)

# make sure some of the lines were important
p1n = m1.nebline_photometry(filts)
p1n = m1.nebline_photometry(obslist[-1].filterset)
assert np.any(p1n / p1[1] > 0.05)

# make sure you got the same answer
assert np.all(np.abs(p1 - p2) / p1 < 1e-3)
# make sure you got the same-ish answer
assert np.all((np.abs(p1 - p2) / p1) < 1e-2)


def test_filtersets():
Expand Down

0 comments on commit 97543c5

Please sign in to comment.