Skip to content

Commit

Permalink
Update dockerfile (#27)
Browse files Browse the repository at this point in the history
* update libgl1 installation

* allow breaking of system packages

* check pip version for command line options

* use venv

* reformat files with Black
  • Loading branch information
sfarrens authored Aug 10, 2024
1 parent b25d475 commit 6bc56da
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 211 deletions.
23 changes: 16 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,35 @@ ARG CC=gcc-9
ARG CXX=g++-9

RUN apt-get update && \
apt-get install -y autoconf automake libtool pkg-config libgl1-mesa-glx && \
apt-get install -y autoconf automake libtool pkg-config && \
apt-get install -y gcc-9 g++-9 && \
apt-get install -y cmake git wget && \
apt-get install -y libarmadillo-dev && \
apt-get install -y libcfitsio-dev && \
apt-get install -y libfftw3-dev && \
apt-get install -y libgl1 && \
apt-get install -y libgsl-dev && \
apt-get install -y libsharp-dev && \
apt-get install -y libhealpix-cxx-dev && \
apt-get install -y healpy-data && \
apt-get install -y python3 python3-pip && \
apt-get install -y python3 python3-pip python3-venv && \
apt-get clean

ENV HEALPIX /usr/share/healpy
ENV HEALPIX=/usr/share/healpy

RUN python3 -m pip install jupyter
RUN python3 -m venv /venv

RUN source /venv/bin/activate && \
pip install --upgrade pip

RUN source /venv/bin/activate && \
pip install jupyter

COPY . /home

RUN cd /home && \
python3 -m pip install .
RUN source /venv/bin/activate && \
pip install /home

RUN echo "source /venv/bin/activate" >> ~/.bashrc

RUN echo -e '#!/bin/bash\njupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root' > /usr/bin/notebook && chmod +x /usr/bin/notebook
RUN echo -e '#!/bin/bash\nsource /venv/bin/activate\njupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root' > /usr/bin/notebook && chmod +x /usr/bin/notebook
12 changes: 6 additions & 6 deletions pycs/astro/wl/mass_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,9 +913,9 @@ def _prepare_data(self, InshearData, msg=None, niter=None, Nsigma=None):
mask = (InshearData.Ncov != 0).astype(int) # shape = (nx, ny)
else:
mask = InshearData.mask
InshearData.Ncov[InshearData.Ncov == 0] = (
1e9 # infinite value for no measurement
)
InshearData.Ncov[
InshearData.Ncov == 0
] = 1e9 # infinite value for no measurement
Ncv = InshearData.Ncov / 2.0 # shape = (nx, ny)

# find the minimum noise variance
Expand All @@ -929,9 +929,9 @@ def _prepare_data(self, InshearData, msg=None, niter=None, Nsigma=None):
eta = tau
# compute signal coefficient
Esn = eta / Ncv # shape = (nx, ny)
Esn[Esn == np.inf] = (
0 # TODO: useless if we have set Ncv[mask == 0] = 1e9 before
)
Esn[
Esn == np.inf
] = 0 # TODO: useless if we have set Ncv[mask == 0] = 1e9 before

return gamma1, gamma2, nx, ny, eta, Esn, mask, ind, tau, niter, Nsigma

Expand Down
23 changes: 12 additions & 11 deletions pycs/sparsity/sparse2d/mr_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from datetime import datetime
from astropy.io import fits
import shlex


##
# Function that calls mr_filter to perform a wavelet filtering on the
# input data.
Expand All @@ -29,27 +31,26 @@
#
# %load_ext autoreload
# %autoreload 2
def mr_filter(data, opt=None, path='./', remove_files=True):

def mr_filter(data, opt=None, path="./", remove_files=True):
# Create a unique string using the current date and time.
# print('mr_filter ', opt)
unique_string = datetime.now().strftime('%Y.%m.%d_%H.%M.%S')
result=0
unique_string = datetime.now().strftime("%Y.%m.%d_%H.%M.%S")
result = 0
# Set the ouput file names.
file_name = path + 'mr_temp_' + unique_string
file_fits = file_name + '.fits'
file_out = file_name + '_out.fits'
file_name = path + "mr_temp_" + unique_string
file_fits = file_name + ".fits"
file_out = file_name + "_out.fits"

# Write the input data to a fits file.
fits.writeto(file_fits, data)

cmd = 'mr_filter '
cmd = "mr_filter "

if isinstance(opt, type(None)):
optF=' '
optF = " "
else:
optF=opt
cmd = cmd + optF + ' ' + file_fits + ' ' + file_out
optF = opt
cmd = cmd + optF + " " + file_fits + " " + file_out
# print 'CMD = ', cmd
args = shlex.split(cmd)
# print('args ', args)
Expand Down
33 changes: 16 additions & 17 deletions pycs/sparsity/sparse2d/mr_gmca.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from pycs.misc.cosmostat_init import *
from pycs.misc.cosmostat_init import writefits


##
# Function that calls mr_gmca to perform blind source separation on the
# input data.
Expand All @@ -32,20 +33,19 @@
#
# %load_ext autoreload
# %autoreload 2
def mr_gmca(data, opt=None, path='./', remove_files=True, verbose=False, FileOut=None):

def mr_gmca(data, opt=None, path="./", remove_files=True, verbose=False, FileOut=None):
# Create a unique string using the current date and time.
# print('mr_filter ', opt)
prog="mr_gmca"
unique_string = datetime.now().strftime('%Y.%m.%d_%H.%M.%S')
result=0
prog = "mr_gmca"
unique_string = datetime.now().strftime("%Y.%m.%d_%H.%M.%S")
result = 0
# Set the ouput file names.
file_name = path + 'mr_temp_' + unique_string
file_fits = file_name + '.fits'
file_name = path + "mr_temp_" + unique_string
file_fits = file_name + ".fits"
if FileOut is not None:
file_out = FileOut
else:
file_out = file_name + '_out'
file_out = file_name + "_out"

# Write the input data to a fits file.
writefits(file_fits, data)
Expand All @@ -54,15 +54,15 @@ def mr_gmca(data, opt=None, path='./', remove_files=True, verbose=False, FileOut
cmd = prog

if isinstance(opt, type(None)):
optF=' '
optF = " "
else:
optF= opt
optF = opt
if verbose:
optF = optF + " -v "

cmd = cmd + " " + optF + " " + file_fits + " " + file_out
cmd = cmd + " " + optF + " " + file_fits + " " + file_out
if verbose:
print ('CMD = ', cmd)
print("CMD = ", cmd)

args = shlex.split(cmd)
# print('args ', args)
Expand All @@ -72,19 +72,18 @@ def mr_gmca(data, opt=None, path='./', remove_files=True, verbose=False, FileOut
file_out_source = file_out + ".fits"
file_out_mat = path + "xx_EstMixmat.fits"
file_out_invmat = path + "xx_InvMixingMat.fits"

result = readfits(file_out_source)
est_mixmat = readfits(file_out_mat)
est_invmixmat = readfits (file_out_invmat)
est_invmixmat = readfits(file_out_invmat)


# Return the mr_transform results (and the output file names).
if remove_files:
remove(file_fits)
remove(file_out_source)
remove(file_out_mat)
remove(file_out_invmat)

return result,est_mixmat,est_invmixmat
return result, est_mixmat, est_invmixmat
else:
return result,est_mixmat,est_invmixmat
return result, est_mixmat, est_invmixmat
Loading

0 comments on commit 6bc56da

Please sign in to comment.