Python Camb Casarini Halofit

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Post Reply
Matthew Digman
Posts: 7
Joined: February 03 2017
Affiliation: The Ohio State University

Python Camb Casarini Halofit

Post by Matthew Digman » February 03 2017

I see that the latest update of the python camb wrapper adds halofit_casarini to the list of possible halofit versions. Setting w with set_dark_energy appears to change w0, but I cannot find a way to set wa. Is there a way to do this?

Antony Lewis
Posts: 1353
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Python Camb Casarini Halofit

Post by Antony Lewis » February 03 2017

The "devel" branch (on CAMB's github) supports switching the dark energy model, e.g. using wa/=0 with ppf. (requires gfortran 6+)

Matthew Digman
Posts: 7
Joined: February 03 2017
Affiliation: The Ohio State University

Python Camb Casarini Halofit

Post by Matthew Digman » February 04 2017

Okay I downloaded the devel branch and make runs okay, but I get following when I try to run

Code: Select allp>

pip install –egg . 
from the pycamb directory:

Code: Select allp>

  Running setup.py install for camb ... error
    Complete output from command /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;_file__='/private/tmp/pip-KKwJ_N-build/setup.py';f=getattr(tokenize, 'open', open)(_file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, _file__, 'exec'))" install –record /tmp/pip-ftunUE-record/install-record.txt –compile:
    running install
    error: [Errno 2] No such file or directory: '/private/tmp/pip-KKwJ_N-build/fortran'
    
    —————————————-
Command "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;_file__='/private/tmp/pip-KKwJ_N-build/setup.py';f=getattr(tokenize, 'open', open)(_file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, _file__, 'exec'))" install –record /tmp/pip-ftunUE-record/install-record.txt –compile" failed with error code 1 in /private/tmp/pip-KKwJ_N-build/
I actually get the same error when I try to install from the master branch, but have no problems with the version from pypi. Do you know what is causing this?[/quote]

Antony Lewis
Posts: 1353
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Python Camb Casarini Halofit

Post by Antony Lewis » February 04 2017

Not sure, try running setup.py directly?

Matthew Digman
Posts: 7
Joined: February 03 2017
Affiliation: The Ohio State University

Python Camb Casarini Halofit

Post by Matthew Digman » February 06 2017

When I run

Code: Select allp>

python ./setup.py install
I get this:

Code: Select allp>

running install
Compiling source...
mkdir -p Releaselib
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C Releaselib -f ../Makefile_main libcamb_recfast.a F90FLAGS="-shared -fPIC -O3 -fopenmp -MMD -cpp -ffree-line-length-none -fmax-errors=4"
make&#91;1&#93;&#58; Circular precision.mod <- precision.mod dependency dropped.
make&#91;1&#93;&#58; Circular recdata.mod <- recdata.mod dependency dropped.
make&#91;1&#93;&#58; Circular recdata.mod <- recdata.mod dependency dropped.
make&#91;1&#93;&#58; Circular recdata.mod <- recdata.mod dependency dropped.
make&#91;1&#93;&#58; Circular recdata.mod <- recdata.mod dependency dropped.
make&#91;1&#93;&#58; Circular recdata.mod <- recdata.mod dependency dropped.
make&#91;1&#93;&#58; Circular redshiftspacedata.mod <- redshiftspacedata.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- redshiftspacedata.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- redshiftspacedata.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- lvalues.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- redshiftspacedata.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- lvalues.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- massivenu.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- redshiftspacedata.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- lvalues.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- massivenu.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modeldata.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modeldata.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modeldata.mod <- massivenu.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- redshiftspacedata.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- lvalues.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- massivenu.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modeldata.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modeldata.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- massivenu.mod dependency dropped.
make&#91;1&#93;&#58; Circular transfer.mod <- transfer.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular massivenu.mod <- massivenu.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular lvalues.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular modelparams.mod <- modelparams.mod dependency dropped.
make&#91;1&#93;&#58; Circular spherbessels.mod <- spherbessels.mod dependency dropped.
make&#91;1&#93;&#58; Circular gaugeinterface.mod <- gaugeinterface.mod dependency dropped.
make&#91;1&#93;&#58; Circular nonlinear.mod <- nonlinear.mod dependency dropped.
make&#91;1&#93;&#58; Circular nonlinear.mod <- nonlinear.mod dependency dropped.
make&#91;1&#93;&#58; `libcamb_recfast.a' is up to date.
gfortran -shared -fPIC -O3 -fopenmp -MMD -cpp -ffree-line-length-none -fmax-errors=4 -JReleaselib -IReleaselib/ -I/Users/mcdigman/Documents/hirata_research/forutils-master//Release/  \
		camb_python.f90 Releaselib/libcamb_recfast.a -lstdc++ -L/Users/mcdigman/Documents/hirata_research/forutils-master//Release -lforutils -o pycamb/camb/camblib.so
Compilation failed

Antony Lewis
Posts: 1353
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Python Camb Casarini Halofit

Post by Antony Lewis » February 06 2017

The silent error is not very helpful! Make sure you've downloaded a "forutils" directory with shared modules:

git clone –depth=1 https://github.com/cmbant/forutils.git forutils

(it looks as though you should have already built it into Users/mcdigman/Documents/hirata_research/forutils-master//Release/)

After doing that the automated Travis-CI test just runs tests/run_tests.sh which installs the package: it runs OK on the current devel head. Might also want to check you have an up to date gfortran.

Matthew Digman
Posts: 7
Joined: February 03 2017
Affiliation: The Ohio State University

Python Camb Casarini Halofit

Post by Matthew Digman » February 07 2017

It doesn't run. In case it was due to changes from the previous attempts, I changed the first part of the test file so it clones a completely clean version of everything camb related:

Code: Select allp>

git clone -b devel –depth=1 https&#58;//github.com/cmbant/CAMB.git camb
cd camb
git clone –depth=1 https&#58;//github.com/cmbant/forutils.git forutils
cd forutils
make Release
cd ..
make Release
I get the same error message I included before, followed by

Code: Select allp>

Compiling source...
Compilation failed
running test
running egg_info
creating camb.egg-info
writing camb.egg-info/PKG-INFO
writing top-level names to camb.egg-info/top_level.txt
writing dependency_links to camb.egg-info/dependency_links.txt
writing manifest file 'camb.egg-info/SOURCES.txt'
reading manifest file 'camb.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning&#58; no previously-included files matching '*.dll' found under directory 'camb'
warning&#58; no previously-included files matching '*.dat' found under directory 'camb'
warning&#58; no files found matching 'Makefile*' under directory 'fortran'
warning&#58; no files found matching '*.dat' under directory 'fortran'
warning&#58; no files found matching '*.?90' under directory 'fortran'
writing manifest file 'camb.egg-info/SOURCES.txt'
running build_ext
Traceback &#40;most recent call last&#41;&#58;
  File "setup.py", line 124, in <module>
    keywords=&#91;'cosmology', 'CAMB'&#93;
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands&#40;&#41;
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command&#40;cmd&#41;
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run&#40;&#41;
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools/command/test.py", line 211, in run
    self.run_tests&#40;&#41;
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools/command/test.py", line 234, in run_tests
    **exit_kwarg
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in _init__
    self.parseArgs&#40;argv&#41;
I have gfortran 6 installed:

Code: Select allp>

gfortran –version
GNU Fortran &#40;MacPorts gcc6 6.3.0_1&#41; 6.3.0
Copyright &#40;C&#41; 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I also tried switching to gfortran 7, which doesn't run either.

Antony Lewis
Posts: 1353
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Python Camb Casarini Halofit

Post by Antony Lewis » February 07 2017

setuptools installed? Only other difference I can see with the tests/run_tests.sh seems to be that you are using a Mac (can always run in CosmoBox VM instead).

Federico Bianchini
Posts: 9
Joined: June 25 2013
Affiliation: University of Melbourne
Contact:

Python Camb Casarini Halofit

Post by Federico Bianchini » April 14 2017

Hi there,

I was wondering whether there have been any updates on this issue.

I manage to compile the fortran CAMB-devel but when I try to install the python wrapper I get the same errors as Matthew.

FYI, I have fortran 6.3.0 installed as well as forutils and my OS is macOS Sierra 10.12.4.

Cheers!

Antony Lewis
Posts: 1353
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Python Camb Casarini Halofit

Post by Antony Lewis » April 14 2017

I can only refer to my previous message. If a Mac user could investigate and make a pull request with a fix that would be great (I use Windows).

Meanwhile, you could use CosmoBox.

Federico Bianchini
Posts: 9
Joined: June 25 2013
Affiliation: University of Melbourne
Contact:

Python Camb Casarini Halofit

Post by Federico Bianchini » April 15 2017

Hi Antony and thanks for your reply!

Just a quick update: I'm not sure as to why, but I was able to install the python wrapper for the CAMB-devel version by commenting out https://github.com/cmbant/CAMB/blob/dev ... py#L91-L92 in the setup.py file and rerunning the python setup.py install –user command (after compiling the source code of course), see the output below.

However, when I try to set wa to a value different from 0, i.e. pars.set_dark_energy(w=−1, wa=0.5, dark_energy_model='ppf'), https://github.com/cmbant/CAMB/blob/dev ... el.py#L480 throws the following error

Code: Select allp>

CAMBError&#58; fluid dark energy model does not support wa<>0
Shouldn't lines 480−481 of the above files read as

Code: Select allp>

if dark_energy_model == 'fluid' and wa&#58;
    raise CAMBError&#40;'fluid dark energy model does not support wa<>0'&#41;
Even if I change those lines, I get the following error

Code: Select allp>

ValueError&#58; 'ppf' is not in list
thrown by L484.
Am I missing something trivial and/or I'm doing something wrong?

Thanks again for the help!

Code: Select allp>

6400L−128763-M&#58;pycamb fbianchini&#36; python setup.py install –user
running install
Compiling source...
chmod&#58; Releaselib/camblib.so&#58; No such file or directory
cp&#58; Releaselib/camblib.so&#58; No such file or directory
running build
running build_py
creating build
creating build/lib
creating build/lib/camb
copying camb/__init__.py -> build/lib/camb
copying camb/baseconfig.py -> build/lib/camb
copying camb/bbn.py -> build/lib/camb
copying camb/bispectrum.py -> build/lib/camb
copying camb/camb.py -> build/lib/camb
copying camb/constants.py -> build/lib/camb
copying camb/correlations.py -> build/lib/camb
copying camb/initialpower.py -> build/lib/camb
copying camb/lensing.py -> build/lib/camb
copying camb/model.py -> build/lib/camb
copying camb/nonlinear.py -> build/lib/camb
copying camb/recombination.py -> build/lib/camb
copying camb/reionization.py -> build/lib/camb
creating build/lib/camb_tests
copying camb_tests/__init__.py -> build/lib/camb_tests
copying camb_tests/camb_test.py -> build/lib/camb_tests
copying camb/camblib.so -> build/lib/camb
copying camb/HighLExtrapTemplate_lenspotentialCls.dat -> build/lib/camb
running install_lib
copying build/lib/camb/HighLExtrapTemplate_lenspotentialCls.dat -> /Users/fbianchini/.local/lib/python2.7/site-packages/camb
copying build/lib/camb/model.py -> /Users/fbianchini/.local/lib/python2.7/site-packages/camb
byte-compiling /Users/fbianchini/.local/lib/python2.7/site-packages/camb/model.py to model.pyc
running install_egg_info
running egg_info
writing camb.egg-info/PKG-INFO
writing top-level names to camb.egg-info/top_level.txt
writing dependency_links to camb.egg-info/dependency_links.txt
reading manifest file 'camb.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning&#58; no previously-included files matching '*.dll' found under directory 'camb'
warning&#58; no files found matching 'Makefile*' under directory 'fortran'
warning&#58; no files found matching '*.dat' under directory 'fortran'
warning&#58; no files found matching '*.?90' under directory 'fortran'
writing manifest file 'camb.egg-info/SOURCES.txt'
removing '/Users/fbianchini/.local/lib/python2.7/site-packages/camb−0.1.4-py2.7.egg-info' &#40;and everything under it&#41;
Copying camb.egg-info to /Users/fbianchini/.local/lib/python2.7/site-packages/camb−0.1.4-py2.7.egg-info
Cleaning intermediate files...

Antony Lewis
Posts: 1353
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Python Camb Casarini Halofit

Post by Antony Lewis » April 18 2017

Thanks, I fixed two typos preventing the ppf option from working, try it now?

The "Compilation failed" message was also a bug, since the file is already produced in the right directory in the devel branch.

Federico Bianchini
Posts: 9
Joined: June 25 2013
Affiliation: University of Melbourne
Contact:

Python Camb Casarini Halofit

Post by Federico Bianchini » April 20 2017

Perfect, I confirm that I could easily install the wrapper and now it works like a charm. I'll play with it a little bit more in the upcoming days.

Post Reply