Skip to content

Commit

Permalink
Finish v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-murray committed Jun 7, 2017
2 parents 5126e9c + d6ae539 commit c79c355
Show file tree
Hide file tree
Showing 41 changed files with 1,258 additions and 549 deletions.
25 changes: 19 additions & 6 deletions .travis.yml
@@ -1,6 +1,12 @@
language: python
sudo: required


python:
- 2.7
- 3.5
- 3.6

notifications:
email:
recipients:
Expand All @@ -14,9 +20,15 @@ deploy:
password:
secure: lAM0ScaCdOTbixtJf908INAKIpVCIPLSu4ZpqSxdp0zzMsTJJoTLo00wlmzzjeQDsxqgpiUIvjnwlpdur7Q+IPmwFa9hkg4VX4Mqe0keoDaoUQaUzpypZqYF0w4egVgc62NnXCGg3B/JuqUFuyM692uvmjvokGmadXLevXvPaxM=

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gfortran-6

# Setup anaconda
before_install:
- sudo apt-get install gfortran
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
else
Expand All @@ -31,16 +43,17 @@ before_install:
- conda info -a

install:
- conda install python=$TRAVIS_PYTHON_VERSION numpy scipy mpmath nose astropy
- conda install python=$TRAVIS_PYTHON_VERSION numpy scipy mpmath nose astropy libgfortran
- pip install python-coveralls
- pip install coverage
- pip install emcee
- pip install mrpy
- CAMBURL=http://camb.info/CAMB_Mar13.tar.gz pip install git+git://github.com/steven-murray/pycamb.git
- pip install cached_property
#- CAMBURL=http://camb.info/CAMB_Mar13.tar.gz pip install git+git://github.com/steven-murray/pycamb.git
- sudo ln -s /usr/bin/gfortran-6 /usr/bin/gfortran
- pip install --egg camb
- pip install coveralls

script:
- nosetests --with-coverage --cover-package=hmf
- coverage run --source=hmf --omit=hmf/fitting/* $(which nosetests)


# Calculate coverage
Expand Down
26 changes: 25 additions & 1 deletion CHANGELOG.rst
@@ -1,9 +1,32 @@
Releases
========

v3.0.0 [7th June 2017]
----------------------
**Features**

- Now provides compatibility with Python 3.x. Support for 2.x will be removed in hmf v3.1 (whenever that comes).
- Complete overhaul of the caching system. Should be invisible to the user, but streamlines writing of framework
code considerably. Removes required manual specification of dependencies between quantities, and adds ability
to specify parameter kinds (model, param, res, option, switch).

**Bugfixes**

- Fixed bug in Caroll1992 GrowthFactor class which affected high-redshift growth factors (thanks to Olmo Piana).
- Fixed astropy dependency to be >= 1.1
- Fixed bug where Takahashi parameters were always passed through regardess of ``takahashi`` setting.
- Fixed small bug where the functional.get_label method returned differently ordered parameters because of dicts.
- Note that the fitting subpackage is temporarily unsupported and I discourage its use for the time being.

**Enhancement**

- Completely removes dependence on archaic pycamb package. Now supports natively supplied python interface to CAMB.
Install camb with ``pip install --egg camb``. This means that much more modern versions of CAMB can be used.
- Many new tests, to bring total coverage up to >80%, and continuous testing on Python 2.7, 3.5 and 3.6


v2.0.5 [12th January 2017]
--------------------------

**Bugfixes**

- Fixed bug in GrowthFactor which gave ripples in functions of z when a coarse grid was used. Thanks to @mirochaj and
Expand All @@ -15,6 +38,7 @@ v2.0.5 [12th January 2017]
- Totally removed dependency on the Cache (super)class -- caching indexes now inherent to the called class.
- More robust parameter information based on introspection.


v2.0.4 [11th November, 2016]
------

Expand Down
4 changes: 4 additions & 0 deletions README.rst
Expand Up @@ -12,11 +12,15 @@ hmf
:target: https://pypi.python.org/pypi/hmf
.. image:: https://coveralls.io/repos/github/steven-murray/hmf/badge.svg?branch=master
:target: https://coveralls.io/github/steven-murray/hmf?branch=master
.. image:: https://img.shields.io/pypi/pyversions/hmf.svg

`hmf` is a python application that provides a flexible and simple way to calculate the
Halo Mass Function for a range of varying parameters. It is also the backend to
`HMFcalc <http://hmf.icrar.org>`_, the online HMF calculator.

.. warning:: Due to the general trend of moving to Python 3 by important projects such as IPython and astropy, from
version 2.1, hmf is compatible with Python 3, and from version 3.0, it will drop support for Python 2.

Documentation
-------------
`Read the docs. <http://hmf.readthedocs.org>`_
Expand Down
1 change: 1 addition & 0 deletions development/.gitignore
@@ -0,0 +1 @@
*.out
2 changes: 2 additions & 0 deletions development/Plots/.gitignore
@@ -0,0 +1,2 @@
*.jpg
*.mp4
213 changes: 213 additions & 0 deletions development/halofit_testing.ipynb

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions development/hmf_z.py
@@ -0,0 +1,113 @@
"""
Info script for Steven.
Results show issues at higher redshift.
"""

import hmf
from astropy.cosmology import LambdaCDM
from astropy.io import ascii
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import numpy as np
import subprocess
import glob
import os


# --- Set parameter values. ---

logMmin = 12.5
logMmax = 16
z = 0.01

hmf_model = "Tinker08"
delta_wrt = "crit"
delta_h = 500.0

H0 = 67.11
Om0 = 0.3175
Ob0 = 0.049
Ode0 = 0.6825

sigma_8 = 0.8344
n = 0.9624
transfer_model = "EH"

# -----------------------------


# --- Create cosmology and set its parameter values. ---

cosmo_model = LambdaCDM(H0=H0, Om0=Om0, Ob0=Ob0, Ode0=Ode0)
print ""
print "Cosmological model and parameter values:"
print cosmo_model
print "sigma_8 =", sigma_8, ", n =", n, ", transfer_model =", transfer_model

# -----------------------------------------------------


# --- Create mass function. ---

mf = hmf.MassFunction(Mmin=logMmin, Mmax=logMmax, z=z,
hmf_model=hmf_model, delta_wrt=delta_wrt, delta_h=delta_h,
cosmo_model=cosmo_model,
sigma_8=sigma_8, n=n, transfer_model=transfer_model)

print ""
print "Mass function and parameter values:"
print mf.parameter_values
print ""

# -----------------------------

# Different zs:
#zmin = np.log10(0.01)
#zmax = np.log10(2)

zmin = 0.01
zmax = 2
nz = 200
outdir = 'Plots/'
if not os.path.exists(outdir):
print "The directory ", outdir, "does not exist. Creating it..."
os.makedirs(outdir)

filnam = outdir + 'hmf_challenge'
exten_ima = '.jpg'
all_imas = filnam + "*" + exten_ima
all_imas_gl = glob.glob(all_imas)
#args = 'rm -f' + all_imas_gl
#outcmd = subprocess.Popen(args)
# Doesn't work for some reason (also don't want to set shell=True).

for filerm in all_imas_gl:
os.remove(filerm)

i = 0
print "Calculating and plotting mass functions at", nz, "redshifts..."
#for z in np.logspace(zmin,zmax,nz):

for z in np.linspace(zmin,zmax,nz):
mf.update(z=z)
plt.plot(mf.m,mf.dndm,color="darkblue",alpha=1)
outfil = filnam + str(i).zfill(3)
plt.xlim(1e12, 1e16)
plt.ylim(1e-50, 1e-15)
plt.xscale('log')
plt.yscale('log')
plt.xlabel(r"Mass, $[h^{-1}M_\odot]$")
plt.ylabel(r"$dn/dm$, $[h^{4}{\rm Mpc}^{-3}M_\odot^{-1}]$")
plt.text(5e12, 1e-40, '$z = $'+str(format(z, '6.4f')), fontsize=15)
plt.savefig(outfil + exten_ima)
plt.close()
i = i + 1

movie_nam = filnam + '.mp4'
ffmpeg_out = 'ffmpeg.out'
outcmd = subprocess.call(['rm', '-f', movie_nam])
argus = ['ffmpeg', '-f', 'image2', '-r', '10', '-pattern_type', 'glob', '-i', all_imas, movie_nam]
f_std = open(ffmpeg_out, 'w')
outcmd = subprocess.Popen(argus, stdout=f_std, stderr=subprocess.STDOUT)
f_std.close()

14 changes: 12 additions & 2 deletions docs/examples/deal_with_cosmology.ipynb
Expand Up @@ -434,7 +434,7 @@
"metadata": {
"hide_input": true,
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python [default]",
"language": "python",
"name": "python2"
},
Expand All @@ -448,14 +448,24 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
"version": "2.7.13"
},
"latex_envs": {
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 0
},
"nav_menu": {},
"toc": {
"navigate_menu": true,
"number_sections": true,
"sideBar": true,
"threshold": 6,
"toc_cell": false,
"toc_section_display": "block",
"toc_window_display": true
}
},
"nbformat": 4,
Expand Down
12 changes: 4 additions & 8 deletions docs/index.rst
Expand Up @@ -5,6 +5,7 @@
.. include:: ../README.rst


Features
--------
* Calculate mass functions and related quantities extremely easily.
Expand All @@ -26,6 +27,7 @@ Features
* Nonlinear power spectra via HALOFIT
* Functions for sampling the mass function.
* CLI scripts both for producing any quantity included, or fitting any quantity.
* Python 2 and 3 compatible

Installation
------------
Expand All @@ -35,14 +37,8 @@ installed when installing `hmf`, except for one. Explicitly, the dependencies ar
numpy, scipy, scitools, cosmolopy and emcee.

You will only need `emcee` if you are going to be using the fitting capabilities
of `hmf`. The final, optional, library is pycamb, which can not be installed
using pip currently.

Please follow the guidelines on its `readme page <https://github.com/steven-murray/pycamb.git>`_.
installation instructions.

.. note :: At present, versions of CAMB post March 2013 are not working with
`pycamb`. Please use earlier versions until further notice.
of `hmf`. The final, optional, library is `camb <https://github.com/cmbant/CAMB/pycamb>`_,
for which you should consult the repository for install instructions.

Finally the `hmf` package needs to be installed: ``pip install hmf``. If you want
to install the latest build (not necessarily stable), grab it `here
Expand Down
12 changes: 6 additions & 6 deletions hmf/__init__.py
@@ -1,6 +1,6 @@
__version__ = "2.0.5"
from hmf import MassFunction
import fitting_functions as fits
from cosmo import Cosmology
from transfer import Transfer
from sample import sample_mf
__version__ = "3.0.0"
from .hmf import MassFunction
from . import fitting_functions as fits
from .cosmo import Cosmology
from .transfer import Transfer
from .sample import sample_mf

0 comments on commit c79c355

Please sign in to comment.