Commit 9771ab0f authored by Maude Le Jeune's avatar Maude Le Jeune
Browse files

Merge branch 'master' of gitorious.org:spherelib/spherelib

Conflicts:
	python/wscript
parents e983ce31 5a78c454
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en">
<head>
<title>spherelib</title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<meta name="generator" content="Org-mode"/>
<meta name="generated" content="2013-02-21 13:58:59 CET"/>
<meta name="author" content="M. Le Jeune"/>
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; }
.todo { color: red; }
.done { color: green; }
.tag { background-color:lightblue; font-weight:normal }
.target { }
.timestamp { color: grey }
.timestamp-kwd { color: CadetBlue }
p.verse { margin-left: 3% }
pre {
border: 1pt solid #AEBDCC;
background-color: #F3F5F7;
padding: 5pt;
font-family: courier, monospace;
font-size: 90%;
overflow:auto;
}
table { border-collapse: collapse; }
td, th { vertical-align: top; }
dt { font-weight: bold; }
div.figure { padding: 0.5em; }
div.figure p { text-align: center; }
.linenr { font-size:smaller }
.code-highlighted {background-color:#ffff00;}
.org-info-js_info-navigation { border-style:none; }
#org-info-js_console-label { font-size:10px; font-weight:bold;
white-space:nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
font-weight:bold; }
/*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="org.css" />
<script type="text/javascript">
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*/-->
</script>
</head><body>
<h1 class="title">spherelib</h1>
<p>The spherelib package extends the healpix functionnalities. It includes:
</p><ul>
<li>
a c++ librabry (/lib)
</li>
<li>
a python package (/python)
</li>
<li>
a needlet ilc binary (/nilc) See NILC<sub>README</sub>.org for more info
</li>
</ul>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1 Installation of the python package </a>
<ul>
<li><a href="#sec-1.1">1.1 Dependencies </a></li>
<li><a href="#sec-1.2">1.2 Installing the spherelib python package </a></li>
</ul>
</li>
<li><a href="#sec-2">2 Using the C++ library </a></li>
</ul>
</div>
</div>
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">1 Installation of the python package </h2>
<div id="text-1">
</div>
<div id="outline-container-1.1" class="outline-3">
<h3 id="sec-1.1">1.1 Dependencies </h3>
<div id="text-1.1">
<p>
The spherelib python package relies on healpy python package
(<a href="https://github.com/healpy/healpy">https://github.com/healpy/healpy</a>) and Healpix C++ library.
The Healpix software provides both (<a href="http://sourceforge.net/projects/healpix/">http://sourceforge.net/projects/healpix/</a>)
The healpy package can also be installed through <code>pip</code> tools.
</p>
<p>
The following libraries are also required:
</p><ul>
<li>
<b>GSL</b>
</li>
<li>
<b>FFTW3</b>
</li>
</ul>
<p>The <b>swig</b> program is used to interface c++ with python, together with the numpy
core headers (in particular numpy/arrayobject.h)
</p>
</div>
</div>
<div id="outline-container-1.2" class="outline-3">
<h3 id="sec-1.2">1.2 Installing the spherelib python package </h3>
<div id="text-1.2">
<p>
<code>cd spherelib/python</code>
<code>./waf configure --healpix_prefix=$HEALPIX/src/cxx/$HEALPIX_TARGET --prefix=$HOME</code>
<code>./waf install</code>
<code>export PYTHONPATH=$HOME/lib/python2.6/site-packages:$PYTHONPATH</code>
<code>export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH</code>
</p>
</div>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">2 Using the C++ library </h2>
<div id="text-2">
</div>
</div>
<div id="postamble"><p class="author"> Author: M. Le Jeune
<a href="mailto:lejeune@apc.univ-paris7.fr">&lt;lejeune@apc.univ-paris7.fr&gt;</a>
</p>
<p class="date"> Date: 2013-02-21 13:58:59 CET</p>
<p>HTML generated by org-mode 6.21b in emacs 23</p>
</div></body>
</html>
......@@ -13,8 +13,10 @@ The spherelib package extends the healpix functionnalities. It includes:
** Dependencies
The spherelib python package relies on healpy (https://github.com/healpy/healpy).
The healpy package has to be installed separately.
The spherelib python package relies on healpy python package
(https://github.com/healpy/healpy) and Healpix C++ library.
The Healpix software provides both (http://sourceforge.net/projects/healpix/)
The healpy package can also be installed through =pip= tools.
The following libraries are also required:
+ *GSL*
......@@ -26,11 +28,13 @@ core headers (in particular numpy/arrayobject.h)
** Installing the spherelib python package
=cd python=
=./waf configure --with_healpy=path/to/healpy=
=./waf install=
=cd spherelib/python=
=./waf configure --healpix_prefix=$HEALPIX/src/cxx/$HEALPIX_TARGET --prefix=$HOME=
=./waf install=
=export PYTHONPATH=$HOME/lib/python2.6/site-packages:$PYTHONPATH=
=export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH=
* Using the C++ library
......@@ -29,15 +29,8 @@ The NILC tool also uses the *GSL* library.
*** Compiling Healpix
A recent version of the Healpix library is provided with the source
under the =healpix= directory.
See http://sourceforge.net/projects/healpix/
Change to this directory and run:
=HEALPIX_TARGET=generic_gcc; make=
The Healpix compilation step will be included to the main construction
script in the near future.
*** Compiling the NILC binary
......
......@@ -34,6 +34,29 @@ tropicalYear=3.15569259747e7
tcmb = 2.726
prefixes = {'n':1e-9,'u':1e-6,'m':1e-3,'k':1e3,'M':1e6,'G':1e9}
def greybody (freqs_GHz, T_K, emiss):
"""Emission for a greybody at temp K with emissivity index emiss.
The results are for a set of frequencies and are NOT normalised
"""
GB_RJ = plancklaw_RJ(T_K, freqs_GHz * 1e9 ) * (freqs_GHz**(emiss) )
return GB_RJ
def plancklaw_RJ (T, nu):
"""Returns the BB spectral radiance according to Planck's law
input: SI units
Outpout : K_RJ unit
"""
h = hPlanck
c = speedOfLight#299792458
k = kBoltzmann#1.380e-23
fac = k**3*T**3/c**2/h**2
nud = (h/k/T)*nu ## now dimensionless
BB_SI = 2* fac * nud**3 / ( exp(nud) - 1 ) ## In SI units
BB_RJ = BB_SI / (2*k*nu**2/c**2) ## in KRJ
return BB_RJ
def Jy(freq):
""" Return conversion factor from Jansky to SI at a given frequency.
......
......@@ -246,9 +246,9 @@ def smooth_cl (cl, dloverl=0.1):
for l in range(lmax+1):
llo = max(int(round(ell[l]*(1-dloverl/2.0))), 0)
lhi = min(int(round(ell[l]*(1+dloverl/2.0))), lmax)
if llo==lhi:
if llo==lhi and lhi!=lmax+1:
lhi=llo+1
clsmooth[l] = mean(cl[llo:lhi])
clsmooth[l] = mean(cl[llo:lhi+1])
return clsmooth
......
......@@ -49,7 +49,7 @@ def beam_correction (cov, beams, max_inv=10000):
return ib
def mask_correction (cov, mask, corr="fsky", nmode=None):
def mask_correction (cov, mask, corr="fsky", nmode=None, mll=None):
"""
Parameters
......@@ -71,7 +71,8 @@ def mask_correction (cov, mask, corr="fsky", nmode=None):
return fsky
elif corr=="mll":
lmax = shape(cov)[2]-1
mll = map.mask2mll (mask, lmax)
if mll is None:
mll = map.mask2mll (mask, lmax)
fsky = sum(mll[0,:])
nmap = shape(cov)[0]
for i in range(nmap):
......
......@@ -6,13 +6,11 @@ out = 'build'
def set_options(ctx):
ctx.add_option('--with_healpy', action='store', default='', help='healpy location')
ctx.add_option('--cfitsio_prefix', action='store', default='/usr', help='cfitsio location')
ctx.add_option('--healpix_prefix', action='store', default='/usr/local', help='healpix location')
ctx.add_option('--with_gsl', action='store', default='', help='location of gsl')
ctx.add_option('--with_fftw3', action='store', default='', help='location of fftw3')
ctx.add_option('--with_numpy_core', action='store', default='', help='location of numpy core headers')
ctx.add_option('--with_gsl', action='store', default='/usr', help='location of gsl')
ctx.add_option('--with_fftw3', action='store', default='/usr', help='location of fftw3')
ctx.add_option('--with_numpy_core', action='store', default='/usr/lib64/python2.6/site-packages/numpy/core', help='location of numpy core headers')
ctx.tool_options('compiler_cxx')
ctx.tool_options('python')
......@@ -29,40 +27,21 @@ def configure(ctx):
ctx.check_tool('swig')
ctx.check_tool('compiler_cxx')
print('→ find healpix from healpy')
ctx.env["HEALPIX_EXT_PREFIX"] = str(Options.options.with_healpy)#+'/hpbeta/healpy'
ctx.env["HEALPIX_EXT_LIB"] = ctx.env["HEALPIX_EXT_PREFIX"]#+'/lib'
ctx.env["HEALPIX_EXT_INC"] = ctx.env["HEALPIX_EXT_PREFIX"]#+'/include'
try:
ctx.env['CXXFLAGS'].append("-I"+ctx.env["HEALPIX_EXT_INC"])
ctx.check(header_name=['alm.h'],compile_mode='cxx', mandatory=True)
except:
print('→ find healpix from healpix_prefix')
ctx.env["HEALPIX_EXT_PREFIX"] = str(Options.options.healpix_prefix)
ctx.env["HEALPIX_EXT_LIB"] = ctx.env["HEALPIX_EXT_PREFIX"]+'/lib'
ctx.env["HEALPIX_EXT_INC"] = ctx.env["HEALPIX_EXT_PREFIX"]+'/include'
ctx.env['CXXFLAGS'].append("-I"+ctx.env["HEALPIX_EXT_INC"])
ctx.check(header_name=['alm.h'],compile_mode='cxx', mandatory=True)
print('→ find cfitsio from healpy')
ctx.env["CFITSIO_PREFIX"] = str(Options.options.with_healpy)+'/hpbeta/healpy'
print('→ find healpix from healpix_prefix')
ctx.env["HEALPIX_EXT_PREFIX"] = str(Options.options.healpix_prefix)
ctx.env["HEALPIX_EXT_LIB"] = ctx.env["HEALPIX_EXT_PREFIX"]+'/lib'
ctx.env["HEALPIX_EXT_INC"] = ctx.env["HEALPIX_EXT_PREFIX"]+'/include'
ctx.env['CXXFLAGS'].append("-I"+ctx.env["HEALPIX_EXT_INC"])
ctx.check(header_name=['alm.h'],compile_mode='cxx', mandatory=True)
ctx.check_cxx(lib=['cxxsupport', 'fftpack', 'healpix_cxx','sharp','c_utils'],libpath=ctx.env["HEALPIX_EXT_LIB"], uselib_store='healpix',mandatory=True)
print('→ find cfitsio from cfitsio_prefix')
ctx.env["CFITSIO_PREFIX"] = str(Options.options.cfitsio_prefix)
ctx.env["CFITSIO_EXT_LIB"] = ctx.env["CFITSIO_PREFIX"]+'/lib'
ctx.env["CFITSIO_EXT_INC"] = ctx.env["CFITSIO_PREFIX"]+'/include'
try:
ctx.env['CXXFLAGS'].append("-I"+ctx.env["CFITSIO_EXT_INC"])
ctx.check(header_name=['fitsio.h'],compile_mode='cxx', mandatory=True)
except:
print('→ find cfitsio from cfitsio_prefix')
ctx.env["CFITSIO_PREFIX"] = str(Options.options.cfitsio_prefix)
ctx.env["CFITSIO_EXT_LIB"] = ctx.env["CFITSIO_PREFIX"]+'/lib'
ctx.env["CFITSIO_EXT_INC"] = ctx.env["CFITSIO_PREFIX"]+'/include'
ctx.env['CXXFLAGS'].append("-I"+ctx.env["CFITSIO_EXT_INC"])
ctx.check(header_name=['fitsio.h'],compile_mode='cxx', mandatory=True)
ctx.env["HEALPIX_TARGET"] = "healpy"
ctx.env["CFITSIO_EXT_INC"] = ctx.env["CFITSIO_PREFIX"]+'/include/cfitsio'
ctx.env['CXXFLAGS'].append("-I"+ctx.env["CFITSIO_EXT_INC"])
ctx.check(header_name=['fitsio.h'],compile_mode='cxx', mandatory=True)
ctx.check_cxx(lib=['cfitsio'], libpath=ctx.env["CFITSIO_EXT_LIB"], uselib_store='cfitsio', mandatory=True)
ctx.check_cxx(lib=['cxxsupport', 'fftpack', 'healpix_cxx','psht','c_utils'],libpath=ctx.env["HEALPIX_EXT_LIB"], uselib_store='healpix',mandatory=True)
ctx.env['CXXFLAGS'].append("-I"+str(Options.options.with_gsl)+"/include")
ctx.env['CXXFLAGS'].append("-I"+str(Options.options.with_fftw3)+"/include")
......@@ -76,7 +55,7 @@ def configure(ctx):
ctx.check_cxx(lib=['gsl', 'gslcblas'], libpath=str(Options.options.with_gsl)+"/lib", uselib_store='gsl', mandatory=True)
ctx.check_cxx(lib=['fftw3'], libpath=str(Options.options.with_fftw3)+"/lib", uselib_store='fftw3', mandatory=True)
ctx.check_python_module('healpy')
#ctx.find_file('numpy/arrayobject.h', mandatory=True)
def get_version():
return VERSION
......@@ -85,11 +64,10 @@ def build(bld):
print('→ building spherelib')
hp_data = 'HEALPIXDATA="'+bld.env["HEALPIX_EXT_PREFIX"]+'/data"'
libs = ['gsl', 'gslcblas']
libs = ['cfitsio', 'gsl', 'gslcblas']
import Options
import os
libs.append('gomp' )
#libs.append('iomp5')
libs.append('pthread')
target=bld.env["HEALPIX_TARGET"]
......@@ -105,7 +83,7 @@ def build(bld):
lib = libs,
uselib = libs,
libpath = [bld.env["HEALPIX_EXT_LIB"],bld.env["CFITSIO_EXT_LIB"]],
staticlib = [ 'cxxsupport', 'cfitsio', 'fftpack', 'healpix_cxx','psht','c_utils' ],
staticlib = [ 'cxxsupport', 'fftpack', 'healpix_cxx','sharp','c_utils' ],
name = 'spherelib'
)
cxx_spherelib.install_path = '${PREFIX}/lib'
......@@ -121,7 +99,7 @@ def build(bld):
lib = libs+['fftw3', 'm'],
uselib = libs+['fftw3', 'm'],
libpath = [bld.env["HEALPIX_EXT_LIB"],bld.env["CFITSIO_EXT_LIB"]],
staticlib = [ 'cxxsupport','cfitsio', 'fftpack', 'healpix_cxx','psht','c_utils'],
staticlib = [ 'cxxsupport', 'fftpack', 'healpix_cxx','sharp','c_utils'],
name = 'libatlas'
)
cxx_atlas.install_path = '${PREFIX}/lib'
......@@ -137,7 +115,7 @@ def build(bld):
defines = [hp_data],
lib = libs,
libpath = [bld.env["HEALPIX_EXT_LIB"],bld.env["CFITSIO_EXT_LIB"]],
staticlib = ['cxxsupport', 'cfitsio', 'fftpack', 'healpix_cxx','psht','c_utils'],
staticlib = ['cxxsupport', 'fftpack', 'healpix_cxx','sharp','c_utils'],
uselib_local = ['spherelib', 'libatlas']
)
......@@ -151,7 +129,7 @@ def build(bld):
defines = [hp_data],
lib = libs,
libpath = [bld.env["HEALPIX_EXT_LIB"],bld.env["CFITSIO_EXT_LIB"]],
staticlib = ['cxxsupport', 'cfitsio', 'fftpack', 'healpix_cxx','psht','c_utils'],
staticlib = ['cxxsupport', 'fftpack', 'healpix_cxx','sharp','c_utils'],
uselib_local = 'spherelib')
swig_spherelib_bin = bld(
......@@ -164,17 +142,14 @@ def build(bld):
defines = [hp_data],
lib = libs,
libpath = [bld.env["HEALPIX_EXT_LIB"],bld.env["CFITSIO_EXT_LIB"]],
staticlib = ['cxxsupport', 'cfitsio', 'fftpack', 'healpix_cxx','psht','c_utils'],
staticlib = ['cxxsupport', 'fftpack', 'healpix_cxx','sharp','c_utils'],
uselib_local = 'spherelib')
swig_spherelib_map.install_path = '${PYTHONDIR}/spherelib'
swig_spherelib_alm.install_path = '${PYTHONDIR}/spherelib'
swig_spherelib_bin.install_path = '${PYTHONDIR}/spherelib'
obj = bld(features = 'py')
print out
obj.find_sources_in_dirs( ['./spherelib', out+'/default/spherelib'], exts=['.py'] )
obj.find_sources_in_dirs( [out+'/default/spherelib'], exts=['.py'] )
obj.install_path = '${PYTHONDIR}/spherelib'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment