Skip to content

Commit

Permalink
fix filterset bug and test; bump to version 2.0-alpha.
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-j committed Jun 19, 2022
1 parent 7e84dae commit 8b9f68c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
18 changes: 4 additions & 14 deletions prospect/models/sedmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def predict_phot(self, filterset):
ndarray of shape ``(len(filters),)``, in units of maggies.
If ``filters`` is None, this returns 0.0
"""
if filters is None:
if filterset is None:
return 0.0

# generate photometry w/o emission lines
Expand Down Expand Up @@ -610,7 +610,7 @@ def wave_to_x(self, wavelength=None, mask=slice(None), **extras):
def spec_calibration(self, **kwargs):
return np.ones_like(self._outwave)

def absolute_rest_maggies(self, filters):
def absolute_rest_maggies(self, filterset):
"""Return absolute rest-frame maggies (=10**(-0.4*M)) of the last
computed spectrum.
Expand All @@ -632,28 +632,18 @@ def absolute_rest_maggies(self, filters):
fmaggies = self._norm_spec / (1 + self._zred) * (ld / 10)**2
# convert to erg/s/cm^2/AA for sedpy and get absolute magnitudes
flambda = fmaggies * lightspeed / self._wave**2 * (3631*jansky_cgs)
abs_rest_maggies = 10**(-0.4 * np.atleast_1d(getSED(self._wave, flambda, filters)))
# TODO: below is faster for sedpy > 0.2.0
#abs_rest_maggies = np.atleast_1d(getSED(self._wave, flambda, filters, linear_flux=True))
abs_rest_maggies = np.atleast_1d(getSED(self._wave, flambda, filterset, linear_flux=True))

# add emission lines
if bool(self.params.get('nebemlineinspec', False)) is False:
eline_z = self.params.get("eline_delta_zred", 0.0)
elams = (1 + eline_z) * self._eline_wave
elums = self._eline_lum * self.flux_norm() / (1 + self._zred) * (3631*jansky_cgs) * (ld / 10)**2
emaggies = self.nebline_photometry(filters, elams=elams, elums=elums)
emaggies = self.nebline_photometry(filterset, elams=elams, elums=elums)
abs_rest_maggies += emaggies

return abs_rest_maggies

def mean_model(self, theta, obs, sps=None, sigma=None, **extras):
"""Legacy wrapper around predict()
"""
from ..utils.observation import from_oldstyle
obslist = from_oldstyle(obs)
predictions, mfrac = self.predict(theta, obslist, sps=sps, sigma_spec=sigma, **extras)
return predictions[0], predictions[1], mfrac


class PolySpecModel(SpecModel):

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
setup

#githash = subprocess.check_output(["git", "log", "--format=%h"], universal_newlines=True).split('\n')[0]
vers = "1.1.0"
vers = "2.0-alpha"
githash = ""
with open('prospect/_version.py', "w") as f:
f.write('__version__ = "{}"\n'.format(vers))
Expand Down
3 changes: 2 additions & 1 deletion tests/test_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from prospect.data import Spectrum, Photometry


#@pytest.fixture(scope="module")
@pytest.fixture(scope="module")
def build_sps():
sps = CSPSpecBasis(zcontinuous=1)
return sps
Expand Down Expand Up @@ -59,6 +59,7 @@ def test_prediction_nodata(build_sps):
sobs.uncertainty = None
pred, mfrac = model.predict(model.theta, observations=[sobs, pobs], sps=sps)
assert len(pred[0]) == len(sps.wavelengths)
assert len(pred[1]) == len(pobs.filterset)


def test_multispec(build_sps):
Expand Down

0 comments on commit 8b9f68c

Please sign in to comment.