Skip to content

Commit

Permalink
Merge pull request #43 from mirochaj/galaxy_conventions
Browse files Browse the repository at this point in the history
more consistency in retrieving AUV now in Cohort and Ensemble classes
  • Loading branch information
mirochaj authored Jan 21, 2022
2 parents ed17b66 + 0589d1a commit a85b429
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 12 additions & 1 deletion ares/populations/GalaxyCohort.py
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,17 @@ def _ngtm_from_ham(self, z):

return self._ngtm_from_ham_[z]

def get_AUV(self, z, MUV):
"""
Return extinction in rest-UV at redshift `z` for absolute magnitude(s)
`MUV`.
.. note :: Just a wrapper around `self.dust.AUV`, which is using
empirical dust corrections.
"""
return self.dust.AUV(z, MUV)

def run_abundance_match(self, z, Mh, uvlf=None, wave=1600.):
"""
These are the star-formation efficiencies derived from abundance
Expand Down Expand Up @@ -1778,7 +1789,7 @@ def uvlf(z, mag):

mags = []
for mag in mags_obs:
mags.append(mag-self.dust.AUV(z_ham, mag))
mags.append(mag-self.get_AUV(z_ham, mag))

# Mass function
if self.pf['pop_histories'] is not None:
Expand Down
8 changes: 6 additions & 2 deletions ares/populations/GalaxyEnsemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,9 @@ def deposit_in(self, tnow, delay):

return inow + ifut

def get_fstar(self, z, Mh):
return self.guide.get_fstar(z=z, Mh=Mh)

def _gen_prescribed_galaxy_histories(self, zstop=0):
"""
Take halo histories and paint on galaxy histories in deterministic way.
Expand Down Expand Up @@ -1029,7 +1032,7 @@ def _gen_prescribed_galaxy_histories(self, zstop=0):
SFR = halos['SFR'][:,-1::-1]
else:
iz = np.argmin(np.abs(6. - z))
SFR = self.guide.SFE(z=z2d, Mh=Mh)
SFR = self.guide.get_fstar(z=z2d, Mh=Mh)
np.multiply(SFR, MAR, out=SFR)
SFR *= fb

Expand Down Expand Up @@ -3244,6 +3247,7 @@ def get_AUV(self, z, Mwave=1600., cam=None, MUV=None, Mstell=None,
AUV = AUV_r

assert MUV is None
MAB = None

# May specify a single magnitude at which to return AUV
if MUV is not None:
Expand All @@ -3258,7 +3262,7 @@ def get_AUV(self, z, Mwave=1600., cam=None, MUV=None, Mstell=None,
return np.interp(np.log10(Mstell), x1, y1, left=0., right=0.)

# Otherwise, return raw (or binned) results
return AUV
return MAB, AUV

def get_dBeta_dMUV(self, z, magbins, presets=None, model='exp',
return_funcs=False, maglim=None, dlam=20., magmethod='gmean',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_populations_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ def test():
assert 1e4 <= np.mean(Md) <= 1e10, "Dust masses unreasonable!"

# Test extinction
AUV = pop.get_AUV(6., magbins=mags_cr, return_binned=False)
x, AUV = pop.get_AUV(6., magbins=mags_cr, return_binned=False)

assert np.all(AUV >= 0), "AUV < 0! AUV={}".format(AUV)
assert 0 < np.mean(AUV) <= 3, "AUV unreasonable!"

AUV2 = pop.get_AUV(6., magbins=mags_cr, return_binned=True)
x2, AUV2 = pop.get_AUV(6., magbins=mags_cr, return_binned=True)
assert AUV2.size == mags_cr.size
AUV20 = AUV2[np.argmin(np.abs(mags_cr + 20))]
AUV16 = AUV2[np.argmin(np.abs(mags_cr + 16))]
Expand Down

0 comments on commit a85b429

Please sign in to comment.