Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH add NaMaster #7194

Merged
merged 15 commits into from
Dec 27, 2018
24 changes: 24 additions & 0 deletions recipes/namaster/Makefile.am.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/Makefile.am b/Makefile.am
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,17 +3,17 @@ EXTRA_DIST = doc README.md
lib_LTLIBRARIES = libnmt.la
libnmt_la_SOURCES = src/utils.c src/flatsky_utils.c src/healpix_extra.c src/nmt_bins.c src/nmt_bins_flat.c src/nmt_field.c src/nmt_field_flat.c src/nmt_mask.c src/nmt_mask_flat.c src/nmt_master.c src/nmt_covar.c src/nmt_master_flat.c src/nmt_covar_flat.c
libnmt_la_CPPFLAGS = $(OPENMP_CFLAGS) -I./src/
-libnmt_la_LDFLAGS = $(OPENP_CFLAGS) -lfftw3 -lfftw3_omp -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
+libnmt_la_LDFLAGS = $(OPENP_CFLAGS) -lfftw3 -lfftw3_threads -lpthread -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm

include_HEADERS = src/namaster.h

bin_PROGRAMS = namaster
namaster_SOURCES = src/nmt_main.c
namaster_CPPFLAGS = $(OPENMP_CFLAGS) -I./src/
-namaster_LDFLAGS = $(OPENMP_CFLAGS) -L./ -lnmt -lfftw3 -lfftw3_omp -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
+namaster_LDFLAGS = $(OPENMP_CFLAGS) -L./ -lnmt -lfftw3 -lfftw3_threads -lpthread -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm

noinst_PROGRAMS = test/check_nmt
TESTS = test/check_nmt
test_check_nmt_SOURCES = test/nmt_test.c test/nmt_test_utils.c test/nmt_test_fsk.c test/nmt_test_hpex.c test/nmt_test_bins.c test/nmt_test_field.c test/nmt_test_master.c test/nmt_test_covar.c test/nmt_test_bins_flat.c test/nmt_test_field_flat.c test/nmt_test_master_flat.c test/nmt_test_covar_flat.c test/nmt_test_mask.c
test_check_nmt_CPPFLAGS = $(OPENMP_CFLAGS) -I./test/ -I./src/
-test_check_nmt_LDFLAGS = $(OPENP_CFLAGS) -L./ -lnmt -lfftw3 -lfftw3_omp -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
+test_check_nmt_LDFLAGS = $(OPENP_CFLAGS) -L./ -lnmt -lfftw3 -lfftw3_threads -lpthread -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
20 changes: 20 additions & 0 deletions recipes/namaster/Makefile.in.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/Makefile.in b/Makefile.in
--- a/Makefile.in
+++ b/Makefile.in
@@ -410,14 +410,14 @@ EXTRA_DIST = doc README.md
lib_LTLIBRARIES = libnmt.la
libnmt_la_SOURCES = src/utils.c src/flatsky_utils.c src/healpix_extra.c src/nmt_bins.c src/nmt_bins_flat.c src/nmt_field.c src/nmt_field_flat.c src/nmt_mask.c src/nmt_mask_flat.c src/nmt_master.c src/nmt_covar.c src/nmt_master_flat.c src/nmt_covar_flat.c
libnmt_la_CPPFLAGS = $(OPENMP_CFLAGS) -I./src/
-libnmt_la_LDFLAGS = $(OPENP_CFLAGS) -lfftw3 -lfftw3_omp -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
+libnmt_la_LDFLAGS = $(OPENP_CFLAGS) -lfftw3 -lfftw3_threads -lpthread -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
include_HEADERS = src/namaster.h
namaster_SOURCES = src/nmt_main.c
namaster_CPPFLAGS = $(OPENMP_CFLAGS) -I./src/
-namaster_LDFLAGS = $(OPENMP_CFLAGS) -L./ -lnmt -lfftw3 -lfftw3_omp -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
+namaster_LDFLAGS = $(OPENMP_CFLAGS) -L./ -lnmt -lfftw3 -lfftw3_threads -lpthread -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
test_check_nmt_SOURCES = test/nmt_test.c test/nmt_test_utils.c test/nmt_test_fsk.c test/nmt_test_hpex.c test/nmt_test_bins.c test/nmt_test_field.c test/nmt_test_master.c test/nmt_test_covar.c test/nmt_test_bins_flat.c test/nmt_test_field_flat.c test/nmt_test_master_flat.c test/nmt_test_covar_flat.c test/nmt_test_mask.c
test_check_nmt_CPPFLAGS = $(OPENMP_CFLAGS) -I./test/ -I./src/
-test_check_nmt_LDFLAGS = $(OPENP_CFLAGS) -L./ -lnmt -lfftw3 -lfftw3_omp -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
+test_check_nmt_LDFLAGS = $(OPENP_CFLAGS) -L./ -lnmt -lfftw3 -lfftw3_threads -lpthread -lgsl -lgslcblas -lcfitsio -lsharp -lfftpack -lc_utils -lm
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
16 changes: 16 additions & 0 deletions recipes/namaster/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

if [[ `uname` == 'Darwin' ]]; then
./configure --prefix=${PREFIX} LIBS="-lomp"
else
./configure --prefix=${PREFIX} LIBS="-lgomp"
fi
make
make install

${PYTHON} -m pip install . -vv --no-deps

# run tests now since they are not around later
make check
77 changes: 77 additions & 0 deletions recipes/namaster/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{% set name = "NaMaster" %}
{% set version = "0.9" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
fn: {{ name }}-{{ version }}.tar.gz
url: https://github.com/LSSTDESC/NaMaster/archive/v{{ version }}.tar.gz
sha256: 1e2afa77fd91aa7384957a1f3d3a2ce9d47b9dd013a05c73ab70cee389ceb79e
patches:
- namaster.h.patch
- Makefile.in.patch
- Makefile.am.patch
- setup.py.patch
- test.patch

build:
number: 0
skip: True # [win]

requirements:
build:
- {{ compiler('c') }}
- make
host:
- python
- pip
- gsl
- fftw
- libsharp
- cfitsio
- chealpix
- numpy
- blas 1.1 openblas
- openblas
- llvm-openmp # [osx]
run:
- python
- gsl
- fftw
- libsharp
- cfitsio
- chealpix
- numpy
- blas 1.1 openblas
- openblas
- llvm-openmp # [osx]

test:
source_files:
- test/*
requires:
- healpy
imports:
- pymaster
commands:
- namaster -h

about:
home: https://github.com/LSSTDESC/NaMaster
license: BSD-3-Clause
license_family: BSD
license_file: LICENSE
summary: pseudo-Cl power spectra w/ masking for spin-0 and spin-2 fields
description: |
NaMaster is a C library, Python module and standalone program to compute
full-sky angular cross-power spectra of masked, spin-0 and spin-2 fields
with an arbitrary number of known contaminants using a pseudo-Cl
(aka MASTER) approach. The code also implements E/B-mode purification
and is available in both full-sky and flat-sky modes.
doc_url: https://namaster.readthedocs.io

extra:
recipe-maintainers:
- beckermr
11 changes: 11 additions & 0 deletions recipes/namaster/namaster.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/src/namaster.h b/src/namaster.h
--- a/src/namaster.h
+++ b/src/namaster.h
@@ -10,7 +10,6 @@
#include <math.h>
#include <time.h>
#include <complex.h>
-#include <omp.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_linalg.h>
5 changes: 5 additions & 0 deletions recipes/namaster/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -e

${PYTHON} -m unittest discover -v
19 changes: 19 additions & 0 deletions recipes/namaster/setup.py.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -14,11 +14,11 @@ except AttributeError:

use_icc=False #Set to True if you compiled libsharp with icc
if use_icc :
- libs=['nmt','fftw3','fftw3_omp','sharp','fftpack','c_utils','chealpix','cfitsio','gsl','gslcblas','m','gomp','iomp5']
- extra=['-openmp',]
+ libs=['nmt','fftw3','fftw3_threads', 'pthread','sharp','fftpack','c_utils','chealpix','cfitsio','gsl','gslcblas','m']
+ extra=[]
else :
- libs=['nmt','fftw3','fftw3_omp','sharp','fftpack','c_utils','chealpix','cfitsio','gsl','gslcblas','m','gomp']
- extra=['-O4', '-fopenmp',]
+ libs=['nmt','fftw3','fftw3_threads', 'pthread','sharp','fftpack','c_utils','chealpix','cfitsio','gsl','gslcblas','m']
+ extra=['-O4']


_nmtlib = Extension("_nmtlib",
13 changes: 13 additions & 0 deletions recipes/namaster/test.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/test/nmt_test_bins_flat.c b/test/nmt_test_bins_flat.c
index ca65558..3fa3ce4 100644
--- a/test/nmt_test_bins_flat.c
+++ b/test/nmt_test_bins_flat.c
@@ -68,7 +68,7 @@ CTEST(nmt,bins_flat_binning) {
nmt_ell_eff_flat(bin,leff);
nmt_unbin_cls_flat(bin,&cl_binned,lmax+1,cl,&cl,1);

- for(ii=0;ii<=bin->n_bands;ii++) {
+ for(ii=0;ii<bin->n_bands;ii++) {
ASSERT_DBL_NEAR_TOL(0.5*(bin->ell_0_list[ii]+bin->ell_f_list[ii]),leff[ii],1E-10);
ASSERT_DBL_NEAR_TOL(leff[ii],cl_binned[ii],1E-5);
}