Skip to content

Commit

Permalink
attribute name and normalisation in
Browse files Browse the repository at this point in the history
  • Loading branch information
paranoya committed Oct 4, 2024
1 parent 97b8d3b commit e4a6f31
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/pst/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def alpha_powerlaw(self, value):

def ism_metallicity(self, times):
m = self.stellar_mass_formed(times)
return self.ism_metallicity_today * np.power(m / m[-1], self.alpha_powerlaw)
return self.ism_metallicity_today * np.power(m / self.mass_today, self.alpha_powerlaw)

def sfh_quenching_decorator(stellar_mass_formed):
"""A decorator for including a quenching event in a given SFH."""
Expand Down Expand Up @@ -403,7 +403,7 @@ def __init__(self, **kwargs):
self.mass_norm = 1
mtoday = self.stellar_mass_formed(self.today)
self.mass_norm = self.mass_today / mtoday
self.metallicity_today = kwargs['metallicity_today']
self.ism_metallicity_today = kwargs['ism_metallicity_today']

@u.quantity_input
def stellar_mass_formed(self, times: u.Quantity):
Expand All @@ -414,7 +414,7 @@ def stellar_mass_formed(self, times: u.Quantity):

@u.quantity_input
def ism_metallicity(self, time : u.Gyr):
return np.full(time.size, fill_value=self.metallicity_today)
return np.full(time.size, fill_value=self.ism_metallicity_today)


class LogNormalZPowerLawCEM(MassPropMetallicityMixin, LogNormalCEM):
Expand Down
30 changes: 17 additions & 13 deletions tutorials/models/analytical.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"source": [
"today = 13 << u.Gyr\n",
"mass_today = 1e11 << u.Msun\n",
"metallicity_today = 0.02 << u.dimensionless_unscaled\n",
"ism_metallicity_today = 0.02 << u.dimensionless_unscaled\n",
"alpha_powerlaw = 1.5\n",
"t0 = 20.0 << u.Gyr\n",
"scale = 2.0\n",
Expand All @@ -138,11 +138,11 @@
"metadata": {},
"outputs": [],
"source": [
"#model = models.LogNormalQuenchedCEM(\n",
"model = models.LogNormalCEM(\n",
"model = models.LogNormalQuenchedCEM(\n",
"#model = models.LogNormalCEM(\n",
" today=today,\n",
" mass_today=mass_today, t0=t0, scale=scale, quenching_time=quenching_time,\n",
" metallicity_today=metallicity_today, alpha_powerlaw=alpha_powerlaw,\n",
" ism_metallicity_today=ism_metallicity_today, alpha_powerlaw=alpha_powerlaw,\n",
")"
]
},
Expand Down Expand Up @@ -228,6 +228,16 @@
"ssp_weights = model.interpolate_ssp_masses(ssp, t_obs=today)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d91db156-54a7-4ef2-8a0f-9316bc8e2322",
"metadata": {},
"outputs": [],
"source": [
"model.ism_metallicity(2*u.Gyr)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -245,7 +255,9 @@
"\n",
"mappable = ax.pcolormesh(ssp.ages.to_value(\"Gyr\"), ssp.metallicities, ssp_weights.to_value(u.Msun), norm=LogNorm())\n",
"\n",
"plt.colorbar(mappable, ax=ax, label=r\"SSP mass (M$_\\odot$)\")"
"plt.colorbar(mappable, ax=ax, label=r\"SSP mass (M$_\\odot$)\")\n",
"\n",
"ax.plot(today-cosmic_time, model.ism_metallicity(cosmic_time), 'k-', alpha=.5)\n"
]
},
{
Expand Down Expand Up @@ -283,14 +295,6 @@
"\n",
"ax.plot(ssp.wavelength, sed)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "21a1fcf8-9faf-4339-b272-ccf636d3de49",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit e4a6f31

Please sign in to comment.