Skip to content

Commit

Permalink
syncing up dev and default
Browse files Browse the repository at this point in the history
  • Loading branch information
mirochaj committed Nov 27, 2018
2 parents 192020b + 641978d commit 456ede0
Show file tree
Hide file tree
Showing 10 changed files with 629 additions and 611 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ A few papers on how it works:
- Parameter inference: `Mirocha, Harker, & Burns (2015) <http://adsabs.harvard.edu/abs/2015ApJ...813...11M>`_.
- Galaxy luminosity functions: `Mirocha, Furlanetto, & Sun (2016) <http://adsabs.harvard.edu/abs/2016arXiv160700386M>`_.

And some applications:

- `Mirocha & Furlanetto (2019) <http://adsabs.harvard.edu/abs/2018arXiv180303272M>`_
- `Schneider (2018) <http://adsabs.harvard.edu/abs/2018PhRvD..98f3021S>`_
- `Mirocha et al. (2018) <http://adsabs.harvard.edu/abs/2018MNRAS.478.5591M>`_

Be warned: this code is still under active development -- use at your own
risk! Correctness of results is not guaranteed.

Expand Down
30 changes: 23 additions & 7 deletions ares/populations/GalaxyEnsemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,10 @@ def _gen_deterministic_histories(self):
# SFR = (zform, time (but really redshift))
# So, halo identity is wrapped up in axis=0
# In Cohort, formation time defines initial mass and trajectory (in full)
histories = {'z': zall, 'w': nh, 'SFR': sfr, 'Mh': Mh,
'MAR': mar, 'SFE': sfe, 'nh': nh}
zobs = np.array([zall] * nh.shape[0])
histories = {'z': zall, 'zobs': zobs, 'w': nh, 'SFR': sfr, 'Mh': Mh,
'MAR': mar, 'SFE': sfe, 'nh': nh,
'Mg_c': Mh, 'Mg_h': Mh}

# Add in formation redshifts to match shape (useful after thinning)
histories['zform'] = self.tile(zall, thin)
Expand Down Expand Up @@ -478,9 +480,9 @@ def _gen_indeterminate_histories(self):
for i, zform in enumerate(all_zform):
t, z = self.get_timestamps(zform)

print(zform, len(t))
#print(zform, len(t))

tdyn = self.halos.DynamicalTime(1e10, z) / s_per_yr
#tdyn = self.halos.DynamicalTime(1e10, z) / s_per_yr
k = t.size

# Grab the things that we can't modify (too much)
Expand All @@ -498,6 +500,19 @@ def _gen_indeterminate_histories(self):

jmax = t.size - 1

# Sure would be nice to eliminate the following loop.
# Can only do that if there's no randomness that depends on
# previous timesteps.

# This can go faster...
if self.pf['pop_bcycling'] == False:
# Really want an internal feedback determinism switch.
pass





Mh[i,0] = _Mh[0]
Mg_h[i,0] = 0.0
Mg_c[i,0] = fbar * _Mh[0]
Expand Down Expand Up @@ -722,8 +737,9 @@ def LuminosityFunction(self, z, x, mags=True, wave=1600., band=None):
# For each unique object (or object bin), sum emission
# over past episodes of star formation.

L[k] = np.trapz(L_per_msun * self.histories['SFR'][k,iz:],
dx=dt[0:-1])
L[k] = np.sum(L_per_msun * self.histories['SFR'][k,iz:] * dt)
#L[k] = np.trapz(L_per_msun * self.histories['SFR'][k,iz:],
# dx=dt[0:-1])

else:
# In this case, the time-stepping is different for each
Expand Down Expand Up @@ -768,7 +784,7 @@ def LuminosityFunction(self, z, x, mags=True, wave=1600., band=None):
if len(ages) == 0:
print('ages has no elements!', k)
continue

# Need to be careful about interpolating within last
# dynamical time.

Expand Down
1 change: 1 addition & 0 deletions ares/util/SetDefaultParameterValues.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ def PopulationParameters():
# Cluster-centric model
"pop_poisson": False,
"pop_bcycling": False,
"pop_internal_feedback": False,
"pop_sf_via_inflow": True,
"pop_sf_via_reservior": False,

Expand Down
16 changes: 8 additions & 8 deletions doc/example_litdata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A very incomplete set of data from from the literature exist in ``$ARES/input/li

If any of these papers ring a bell, you can check out the contents in the following way: ::

litdata = ares.util.read_lit('mirocha2016') # a self-serving example
litdata = ares.util.read_lit('mirocha2017') # a self-serving example
or, look directly at the source code, which lives in ``$ARES/input/litdata``. Hopefully the contents of these files are fairly self-explanatory!

Expand Down Expand Up @@ -57,23 +57,23 @@ Reproducing Models from *ares* Papers
-------------------------------------
If you're interested in reproducing a model from a paper exactly, you can either (1) contact me directly for the model of interest, or preferably (someday) download it from my website, or (2) re-compute it yourself. In the latter case, you just need to make sure you supply the required parameters. To facilitate this, I store "parameter files" (just dictionaries) in the litdata framework as well. You can access them like any other dataset from the literature, e.g., ::

m16 = ares.util.read_lit('mirocha2016')
m17 = ares.util.read_lit('mirocha2017')
A few of the models we focused on most get their own dictionary, for example our reference double power law model for the star-formation efficiency is stored in the ``dpl`` variable: ::

sim = ares.simulations.Global21cm(**m16.dpl)
sim = ares.simulations.Global21cm(**m17.dpl)
sim.run()
sim.GlobalSignature() # voila!
Hopefully this results *exactly* in the solid black curve from Figure 2 of `Mirocha, Furlanetto, & Sun (2016) <http://adsabs.harvard.edu/abs/2016arXiv160700386M>`_, provided you're using *ares* version 0.2. If it doesn't, please contact me!

Alternatively, you can use the ``ParameterBundle`` framework, which also taps into our collection of data from the literature. To access the set of parameters for the "dpl" model, you simply do: ::

pars = ares.util.ParameterBundle('mirocha2016:dpl')
pars = ares.util.ParameterBundle('mirocha2017:dpl')
This tells *ares* to retrieve the ``dpl`` variable within the ``mirocha2016`` module. See :doc:`param_bundles` for more on these objects.
This tells *ares* to retrieve the ``dpl`` variable within the ``mirocha2017`` module. See :doc:`param_bundles` for more on these objects.

`Mirocha, Furlanetto, & Sun (2016) <http://adsabs.harvard.edu/abs/2016arXiv160700386M>`_ (``mirocha2016``)
`Mirocha, Furlanetto, & Sun (2016) <http://adsabs.harvard.edu/abs/2016arXiv160700386M>`_ (``mirocha2017``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This model has a few options: ``dpl``, and the extensions ``floor`` and ``steep``, as explored in the paper.

Expand All @@ -95,11 +95,11 @@ To re-make the right-hand panel of Figure 1 from the paper, you could do somethi

import ares
dpl = ares.util.ParameterBundle('mirocha2016:dpl')
dpl = ares.util.ParameterBundle('mirocha2017:dpl')
ax = None
for model in ['floor', 'dpl', 'steep']:
pars = dpl + ares.util.ParameterBundle('mirocha2016:%s' % model)
pars = dpl + ares.util.ParameterBundle('mirocha2017:%s' % model)
pars.update()
sim = ares.simulations.Global21cm(**pars)
sim.run()
Expand Down
5 changes: 5 additions & 0 deletions doc/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Development History

Here's an attempt to keep track of major changes to the code over time, which will be tagged in the bitbucket repository with version numbers. I haven't followed conventions for version numbering so far. Instead, I've simply tagged commits with a version number when a paper is submitted using that version of the code (e.g., v0.1 and v0.2), or when a series of noteworthy improvements or bug fixes have been made (v0.3).

v0.5
----
- This is the version of the code used in `Mirocha & Furlanetto (2019) <http://adsabs.harvard.edu/abs/2018arXiv180303272M>`_.
- Note that several ``litdata'' modules have been updated so that the year is reflective of the year the paper was *published*, not *submitted*!
v0.4
----
- This is the version of the code used in `Mirocha et al. (2018) <http://adsabs.harvard.edu/abs/2018MNRAS.478.5591M>`_. The main addition is global Lyman-Werner feedback, which raises the minimum mass of star-forming halos self-consistently using an iterative technique.
Expand Down
6 changes: 6 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ A few papers on how it works:
- Parameter inference: `Mirocha, Harker, & Burns (2015) <http://adsabs.harvard.edu/abs/2015ApJ...813...11M>`_.
- Galaxy luminosity functions: `Mirocha, Furlanetto, & Sun (2017) <http://adsabs.harvard.edu/abs/2017MNRAS.464.1365M>`_.

And some applications:

- `Mirocha & Furlanetto (2019) <http://adsabs.harvard.edu/abs/2018arXiv180303272M>`_
- `Schneider (2018) <http://adsabs.harvard.edu/abs/2018PhRvD..98f3021S>`_
- `Mirocha et al. (2018) <http://adsabs.harvard.edu/abs/2018MNRAS.478.5591M>`_

Be warned: this code is still under active development -- use at your own
risk! Correctness of results is not guaranteed. This documentation is as much of a work in progress as the code itself, so if you encounter gaps or errors please do let me know.

Expand Down
Loading

0 comments on commit 456ede0

Please sign in to comment.