Skip to content

Commit 71f2ad7

Browse files
committed
Adding several utilities and example notebooks to the container
1 parent 3ecb7eb commit 71f2ad7

6 files changed

+1444
-97
lines changed

Dockerfile

+101-26
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,139 @@
1-
FROM jupyter/scipy-notebook
1+
#FROM jupyter/scipy-notebook:latest
2+
#FROM lambda-base
3+
FROM nasalambda/base-notebook
24

35
#Installing packages and updating stuff
46
USER root
5-
RUN apt-get -y update && apt-get install -y gcc gfortran
7+
RUN apt-get -y update && apt-get install -y gcc gfortran gsl-bin libgsl-dev libcfitsio-bin libcfitsio-dev libfftw3-bin libfftw3-dev git-svn libccfits0v5 libccfits-dev libclhep2.1v5 libclhep-dev libgcc-5-dev
68
RUN pip install --upgrade pip
79

10+
# Create a Python 2.x environment using conda including at least the ipython kernel
11+
# and the kernda utility.
12+
RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython kernda
13+
RUN conda install -n python2 ipykernel
14+
RUN conda clean -tipsy
15+
16+
USER root
17+
18+
# Create a global kernelspec in the image and modify it so that it properly activates
19+
# the python2 conda environment.
20+
#RUN $CONDA_DIR/envs/python2/bin/python -m ipykernel install && \
21+
# kernda -o -y /usr/local/share/jupyter/kernels/python2/kernel.json
22+
23+
#USER $NB_USER
24+
825
#So running python2 from command line runs the miniconda python2
926
RUN ln -s $CONDA_DIR/envs/python2/bin/python $CONDA_DIR/bin/python2
1027
RUN ln -s $CONDA_DIR/envs/python2/bin/easy_install $CONDA_DIR/bin/easy_install2
28+
RUN ln -s $CONDA_DIR/envs/python2/bin/pip $CONDA_DIR/bin/pip2
29+
RUN python2 -m ipykernel install
1130

12-
USER $NB_USER
31+
RUN conda install astropy healpy cython emcee
32+
RUN conda install -n python2 astropy healpy cython scipy numpy matplotlib emcee
1333

14-
RUN conda install astropy healpy cython
15-
RUN conda install -n python2 astropy healpy cython
34+
USER $NB_USER
1635

1736
#CMB Analysis Summer School jupyter notebooks
18-
RUN git clone https://github.com/jeffmcm1977/CMBAnalysis_SummerSchool.git /home/jovyan/work/CMBAnalysis_SummerSchool
37+
RUN git clone https://github.com/jeffmcm1977/CMBAnalysis_SummerSchool.git $HOME/work/CMBAnalysis_SummerSchool
1938

2039
#LAMBDA code
21-
RUN git clone https://github.com/nasa-lambda/cmb_footprint.git /home/jovyan/.ipython/cmb_footprint
22-
RUN git clone https://github.com/nasa-lambda/cmb_analysis.git /home/jovyan/.ipython/cmb_analysis
23-
RUN cp /home/jovyan/.ipython/cmb_footprint/footprint.cfg /home/jovyan/footprint.cfg
40+
RUN git clone https://github.com/nasa-lambda/cmb_footprint.git $HOME/.ipython/cmb_footprint
41+
RUN git clone https://github.com/nasa-lambda/cmb_analysis.git $HOME/.ipython/cmb_analysis
42+
RUN cp $HOME/.ipython/cmb_footprint/footprint.cfg $HOME/footprint.cfg
2443

2544
#Installing PyCAMB
26-
#RUN pip2 install --egg camb
27-
#RUN pip install --egg camb
28-
RUN git clone https://github.com/cmbant/CAMB.git /home/jovyan/camb
29-
WORKDIR /home/jovyan/camb/pycamb
45+
RUN git clone https://github.com/cmbant/CAMB.git $HOME/camb
46+
WORKDIR $HOME/camb/pycamb
3047
RUN python setup.py install --user
3148
RUN python2 setup.py install --user
3249

3350
USER $NB_USER
3451

3552
#CLASS and its python wrapper
36-
RUN git clone https://github.com/lesgourg/class_public.git /home/jovyan/class
37-
WORKDIR /home/jovyan/class
38-
COPY Makefile_class /home/jovyan/class/Makefile
53+
RUN git clone https://github.com/lesgourg/class_public.git $HOME/class
54+
WORKDIR $HOME/class
55+
COPY Makefile_class $HOME/class/Makefile
3956
RUN make
4057
RUN make clean
41-
COPY Makefile_class_py3 /home/jovyan/class/Makefile
42-
COPY setup_class_py3.py /home/jovyan/class/python/setup.py
58+
COPY Makefile_class_py3 $HOME/class/Makefile
59+
COPY setup_class_py3.py $HOME/class/python/setup.py
4360
RUN make
4461

45-
WORKDIR /home/jovyan/work
62+
WORKDIR $HOME/work
4663

4764
#ACTPol Python Likelihood
48-
RUN git clone https://github.com/ACTCollaboration/actpols2_like_py.git /home/jovyan/work/actpols2
65+
RUN git clone https://github.com/ACTCollaboration/actpols2_like_py.git $HOME/work/actpols2
4966

5067
#CMB power spectrum plotting
5168
RUN git clone https://github.com/nasa-lambda/cmbpol_plotting.git
5269

70+
#Healpix
71+
WORKDIR $HOME
72+
RUN wget https://downloads.sourceforge.net/project/healpix/Healpix_3.31/Healpix_3.31_2016Aug26.tar.gz
73+
RUN tar -zxvf Healpix_3.31_2016Aug26.tar.gz
74+
COPY Makefile_healpix $HOME/Healpix_3.31/Makefile
75+
WORKDIR $HOME/Healpix_3.31
76+
RUN mkdir bin
77+
RUN mkdir lib
78+
RUN mkdir include
79+
RUN make
80+
81+
#Hammurabi
82+
WORKDIR $HOME
83+
RUN git svn clone https://svn.code.sf.net/p/hammurabicode/code/trunk hammurabi
84+
WORKDIR $HOME/hammurabi
85+
COPY Makefile_hammurabi $HOME/hammurabi/Makefile
86+
RUN make
87+
ENV PYTHONPATH $HOME/hammurabi
88+
RUN cp $HOME/hammurabi/hampy/Hampy_quick-start.ipynb $HOME/work
89+
RUN cp "$HOME/hammurabi/hampy/Polarized CMB foregrounds.ipynb" $HOME/work/Polarized_CMB_foregrounds.ipynb
90+
WORKDIR $HOME/hammurabi/hampy
91+
RUN wget https://downloads.sourceforge.net/project/hammurabicode/supplementary/hampy_test.tgz
92+
RUN tar -zxvf hampy_test.tgz
93+
94+
#PyGSM
95+
USER root
96+
WORKDIR $HOME
97+
RUN git clone https://github.com/telegraphic/PyGSM
98+
WORKDIR $HOME/PyGSM
99+
RUN python setup.py install
100+
RUN conda install -n python2 h5py
101+
RUN python2 setup.py install
102+
USER $NB_USER
103+
104+
#Cosmosis
105+
#WORKDIR $HOME
106+
#RUN pip install emcee
107+
#RUN git clone http://bitbucket.org/joezuntz/cosmosis
108+
#WORKDIR $HOME/cosmosis
109+
#RUN git clone http://bitbucket.org/joezuntz/cosmosis-standard-library
110+
#WORKDIR $HOME/cosmosis/cosmosis-standard-library
111+
#RUN git checkout
112+
#WORKDIR $HOME/cosmosis
113+
#COPY setup-my-cosmosis $HOME/cosmosis/setup-my-cosmosis
114+
#RUN source setup-my-cosmosis
115+
#RUN make
116+
117+
#BICEP Likelihood
118+
WORKDIR $HOME
119+
COPY b1_hl_likelihood_example.ipynb $HOME/work
120+
COPY bicep1_util.py $HOME/work
121+
RUN wget http://bicep.rc.fas.harvard.edu/bicep1_3yr/b1_hl_likelihood.tgz
122+
RUN mkdir $HOME/work/b1_hl_likelihood
123+
RUN tar -xvzf b1_hl_likelihood.tgz -C $HOME/work/b1_hl_likelihood
124+
53125
#Copying notebooks to working directory
54-
COPY Introduction.ipynb /home/jovyan/work/
55-
COPY plot_footprints.ipynb /home/jovyan/work/
56-
COPY CAMBDemo.ipynb /home/jovyan/work
57-
COPY ClassDemo.ipynb /home/jovyan/work
58-
COPY actpol_likelihood_example_v4.ipynb /home/jovyan/work
126+
COPY Introduction.ipynb $HOME/work/
127+
COPY plot_footprints.ipynb $HOME/work/
128+
COPY CAMBDemo.ipynb $HOME/work/
129+
COPY ClassDemo.ipynb $HOME/work/
130+
COPY actpol_likelihood_example.ipynb $HOME/work/
131+
132+
WORKDIR $HOME/work
59133

60134
#COPY sets owner to root so this needs to be changed for files to
61135
#be editable and downloadable
62136
USER root
63-
RUN chown $NB_USER:users Introduction.ipynb plot_footprints.ipynb CAMBDemo.ipynb ClassDemo.ipynb actpol_likelihood_example_v4.ipynb
137+
RUN chown $NB_USER:users Introduction.ipynb plot_footprints.ipynb CAMBDemo.ipynb ClassDemo.ipynb actpol_likelihood_example.ipynb
138+
RUN chown $NB_USER:users b1_hl_likelihood_example.ipynb bicep1_util.py
64139
USER $NB_USER

Makefile_hammurabi

+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
#--------------------------------------------------------
2+
#--------------------------------------------------------
3+
#
4+
# This is the hammurabi Makefile. The first part needs to be configured for your system.
5+
#
6+
# You can choose to build:
7+
#
8+
# hammurabi: by default, the basic hammurabi, pure C++, for constant or grid TEs and simple analytic models for CREs
9+
# hammurabi.ne2001: including linking to the (smooth) NE2001 Fortran code using cfortran.h
10+
# hammurabi.galprop: including both NE2001 and Galprop to simulate the CRE propagation with the hammurabi magnetic field first.
11+
# hammurabi.debug: including all code, debug flags.
12+
# all: builds all of these.
13+
#
14+
#--------------------------------------------------------
15+
#--------------------------------------------------------
16+
17+
#
18+
# Give the locations of the various libraries. Should containt include and lib subdirectories.
19+
#
20+
BASE_DIR = $(HOME)/
21+
HAMMURABI_HOME = $(BASE_DIR)/hammurabi
22+
GSL = /usr
23+
FFTW = /usr
24+
CFITSIO = /usr
25+
HEALPIX = $(HOME)/Healpix_3.31
26+
HEALPIX_TARGET = basic_gcc
27+
SUBDIR = x86_64-linux-gnu
28+
29+
#
30+
# These are needed if you build with Galprop
31+
#
32+
#GALPROP = $(BASE_DIR)/galprop/galprop/build
33+
CCFITS = /usr
34+
CLHEP = /usr
35+
36+
#
37+
# What c++ compiler you are using?
38+
#
39+
CXX = g++
40+
#
41+
# On OSX, maybe
42+
#CXX = g++-mp-5
43+
44+
#
45+
# Compile options? 64bit system (-m64), optimization (-O2), openMP (-fopenmp), warnings (-Wall), etc.
46+
#
47+
#CXXFLAGS = -m64 -O2 -fopenmp -Wall
48+
#
49+
# With OSX g++-mp-4.3
50+
CXXFLAGS = -fopenmp -O2 -fno-inline-functions -Wall -Wextra -Wno-unknown-pragmas -ansi
51+
52+
#
53+
# Which Fortran compiler you are using? Only if compiling with NE2001 and/or Galprop
54+
#
55+
FC = gfortran
56+
#
57+
# On OSX, maybe
58+
#FC = gfortran-mp-5
59+
60+
# For gfortran
61+
FCFLAGS = -O2 -ffixed-form -ffixed-line-length-132 -c
62+
#
63+
# For ifort
64+
#FCFLAGS =-O -extend-source -c
65+
#
66+
# For f77 ?
67+
#FCFLAGS =
68+
69+
#
70+
# For linking to C++ with gcc
71+
#
72+
LFORTFLAGS= -Df2cFortran
73+
74+
#
75+
# Additional options depending on how you want to run:
76+
#
77+
# Use openMP. Right now, this is mandatory. (Contact
78+
# [email protected] for help compiling without if for some reason you
79+
# need it.)
80+
#LFLAGS_CUSTOM = -fopenmp
81+
#
82+
# OSX with gfortran-mp-4.3
83+
LFLAGS_CUSTOM = -fopenmp
84+
#
85+
86+
#
87+
#
88+
# For J. West using f77 and gcc 4.1.2?
89+
#
90+
#LFORTFLAGS += -L/usr/lib/gcc/x86_64-redhat-linux/3.4.6/ -lgcc -lg2c
91+
#LFLAGS_CUSTOM += -lgcc_s
92+
93+
94+
#------------------------------------------------------------
95+
#------------------------------------------------------------
96+
#
97+
# From here onwards, nothing should need to be changed.
98+
#
99+
#------------------------------------------------------------
100+
#------------------------------------------------------------
101+
102+
hammurabi.debug: CXXFLAGS=-m64 -g -Wall
103+
104+
105+
hammurabi: ALL_INC = -I$(CFITSIO)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/
106+
#hammurabi: ALL_INC = -I$(CFITSIO)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/cxxsupport
107+
hammurabi.ne2001: ALL_INC = -I$(CFITSIO)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/
108+
hammurabi.galprop: ALL_INC = -I$(CFITSIO)/include -I$(GALPROP)/.. -I$(GALPROP)/include/ -I$(CCFITS)/include/ -I$(CLHEP)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/
109+
hammurabi.debug: ALL_INC = -I$(CFITSIO)/include -I$(GALPROP)/.. -I$(GALPROP)/include/ -I$(CCFITS)/include/ -I$(CLHEP)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/
110+
libhamprop.a: ALL_INC = -I$(CFITSIO)/include -I$(GALPROP)/.. -I$(GALPROP)/include/ -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/
111+
112+
113+
hammurabi: ALL_L = -L$(CFITSIO)/lib/$(SUBDIR) -L$(GSL)/lib/$(SUBDIR) -L$(FFTW)/lib/$(SUBDIR) -L$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/lib/ -L.
114+
hammurabi.ne2001: ALL_L = -L$(CFITSIO)/lib/$(SUBDIR) -L$(GSL)/lib/$(SUBDIR) -L$(FFTW)/lib/$(SUBDIR) -L$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/lib/ -L.
115+
hammurabi.galprop: ALL_L = -L$(CFITSIO)/lib/$(SUBDIR) -L$(GALPROP)/lib/ -L$(CCFITS)/lib/$(SUBDIR) -L$(CLHEP)/lib/$(SUBDIR) -L$(GSL)/lib/$(SUBDIR) -L$(FFTW)/lib/$(SUBDIR) -L$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/lib/ -L.
116+
hammurabi.debug: ALL_L = -L$(CFITSIO)/lib/$(SUBDIR) -L$(GALPROP)/lib/ -L$(CCFITS)/lib/$(SUBDIR) -L$(CLHEP)/lib /$(SUBDIR) -L$(GSL)/lib/$(SUBDIR) -L$(FFTW)/lib/$(SUBDIR) -L$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/lib/ -L.
117+
118+
119+
hammurabi : CXXFLAGS+= $(ALL_INC) -c
120+
hammurabi.ne2001: CXXFLAGS+= $(ALL_INC) -c -DNE2001
121+
hammurabi.galprop: CXXFLAGS+= $(ALL_INC) -c -DGALDEF_PATH=\"./GALDEF\" -DFITSDATA_PATH=\"./FITS/\" -DDATA_PATH=\"./DATA\" -DGALPROP -DNE2001
122+
hammurabi.debug : CXXFLAGS+= $(ALL_INC) -c -DGALDEF_PATH=\"./GALDEF\" -DFITSDATA_PATH=\"./FITS/\" -DDATA_PATH=\"./DATA\" -DGALPROP -DNE2001 -g -Wall
123+
# Turns off sanity check to avoid some circularity. See Galprop README.tess
124+
libhamprop.a: CXXFLAGS+= $(ALL_INC) -c -DGALDEF_PATH=\"./GALDEF\" -DFITSDATA_PATH=\"./FITS/\" -DDATA_PATH=\"./DATA\" -DLIBHAMPROP -DGALPROP -DNE2001
125+
126+
127+
hammurabi: LFLAGS = $(ALL_L) -lhammurabi -lhealpix_cxx -lcxxsupport -lc_utils -lfftpack -lcfitsio -lgsl -lgslcblas -lm -lfftw3 -lfftw3_threads $(LFLAGS_CUSTOM)
128+
hammurabi.ne2001: LFLAGS = $(ALL_L) -lhammurabi -lNE2001 -lhealpix_cxx -lcxxsupport -lc_utils -lfftpack -lcfitsio -lgsl -lgslcblas -lm -lfftw3 -lfftw3_threads -lgfortran $(LFLAGS_CUSTOM)
129+
hammurabi.debug: LFLAGS = $(ALL_L) -lhammurabi -lNE2001 -lhealpix_cxx -lcxxsupport -lc_utils -lfftpack -lcfitsio -lgsl -lgslcblas -lm -lfftw3 -lfftw3_omp -lgfortran -lgalprop -lskymap -lCCfits -lCLHEP $(LFLAGS_CUSTOM)
130+
hammurabi.galprop: LFLAGS = $(ALL_L) -lhammurabi -lNE2001 -lhealpix_cxx -lcxxsupport -lc_utils -lfftpack -lcfitsio -lgsl -lgslcblas -lm -lfftw3 -lfftw3_omp -lgfortran -lgalprop -lskymap -lCCfits -lCLHEP $(LFLAGS_CUSTOM)
131+
132+
133+
134+
default:
135+
make hammurabi
136+
all:
137+
make clean ; make hammurabi ; make clean ; make hammurabi.ne2001; make clean; make hammurabi.galprop ; make clean ; make hammurabi.debug
138+
139+
%.o : %.cpp
140+
$(CXX) $(CXXFLAGS) -o $@ $<
141+
%.o : %.cc
142+
$(CXX) $(CXXFLAGS) -o $@ $<
143+
%.o : %.c
144+
$(CXX) $(CXXFLAGS) -o $@ $<
145+
%.o : %.f
146+
$(FC) $(FCFLAGS) -o $@ $<
147+
148+
class_TE_density.o: class_TE_density.cpp
149+
$(CXX) $(CXXFLAGS) $(LFORTFLAGS) -o $@ $<
150+
151+
NE2001_OBJ = dmdsm.NE2001.o density.NE2001.o neclumpN.o nevoidN.o neLISM.NE2001.o
152+
153+
HAMMURABI_OBJ = class_Integrator.o class_List.o class_B_field2.o tess_tools.o class_TE_density.o class_CRE.o namespace_Vec_Handling.o class_Dust.o
154+
155+
run:
156+
mkdir run
157+
158+
$(HAMMURABI_OBJ): hammurabi.h CGS_units_file.h proto*.h tess_tools.h
159+
160+
libNE2001.a: $(NE2001_OBJ)
161+
ar rc $@ $(NE2001_OBJ)
162+
ranlib $@
163+
164+
hammurabi: $(HAMMURABI_OBJ) libhammurabi.a run hammurabi.o
165+
$(CXX) -o run/hammurabi hammurabi.o $(LFLAGS) $(LFORTFLAGS)
166+
167+
hammurabi.ne2001: $(HAMMURABI_OBJ) $(NE2001_OBJ) $(NE2001_DATA) libNE2001.a libhammurabi.a run hammurabi.o
168+
$(CXX) -o run/hammurabi.ne2001 hammurabi.o $(LFLAGS) $(LFORTFLAGS)
169+
170+
hammurabi.galprop: $(HAMMURABI_OBJ) $(NE2001_OBJ) $(NE2001_DATA) libNE2001.a libhammurabi.a run hammurabi.o
171+
$(CXX) -o run/hammurabi.galprop hammurabi.o $(LFLAGS) $(LFORTFLAGS)
172+
173+
hammurabi.debug: $(HAMMURABI_OBJ) $(NE2001_DATA) libNE2001.a libhammurabi.a run hammurabi.o
174+
$(CXX) -o run/hammurabi.debug hammurabi.o $(LFLAGS) $(LFORTFLAGS)
175+
ifeq ($(OSTYPE),darwin)
176+
install_name_tool -change "@rpath/libCLHEP-2.3.3.1.dylib" "$(CLHEP)/lib/libCLHEP-2.3.3.1.dylib" run/hammurabi.debug
177+
endif
178+
179+
print_constants: print_constants.o
180+
$(CXX) -o run/print_constants print_constants.o
181+
182+
# To link in B_field to galprop, use this:
183+
libhamprop.a: class_B_field2.o tess_tools.o namespace_Vec_Handling.o
184+
ar cru libhamprop.a class_B_field2.o tess_tools.o namespace_Vec_Handling.o
185+
186+
libhammurabi.a: $(HAMMURABI_OBJ)
187+
ar cru libhammurabi.a $(HAMMURABI_OBJ)
188+
189+
190+
clean:
191+
rm *.a *.o
192+
193+
test:
194+
(cd unit_test; ./test.csh)
195+
196+
test_big:
197+
(cd unit_test; ./test.csh big)
198+
199+
200+
tarfile:
201+
tar cvzf hammurabi.tgz *cpp *h Makefile *.f README hampy
202+
203+
unittar:
204+
tar cvzf hammurabi_unit_test.tgz unit_test/inputs unit_test/GALDEF unit_test/FITS unit_test/negrid_n400.bin unit_test/ref.mini unit_test/ref unit_test/ref.big

0 commit comments

Comments
 (0)