Commit f58e377a authored by ILBERT Olivier's avatar ILBERT Olivier
Browse files

Merge branch 'master' of gitlab.lam.fr:Galaxies/LEPHARE

parents 6af1b32a 18af2d3b
......@@ -6,6 +6,10 @@ project(lephare VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}")
set(CMAKE_BINARY_DIR "${CMAKE_SOURCE_DIR}/bin")
# Set source directory
set(SOURCE_DIR "./source")
# Tell CMake that headers are also in SOURCE_DIR
......@@ -70,3 +74,7 @@ if(OpenMP_CXX_FOUND)
target_link_libraries(_lephare PUBLIC OpenMP::OpenMP_CXX)
endif()
install(TARGETS filter RUNTIME DESTINATION bin)
install(TARGETS sedtolib RUNTIME DESTINATION bin)
install(TARGETS mag_gal RUNTIME DESTINATION bin)
install(TARGETS zphota RUNTIME DESTINATION bin)
......@@ -9,7 +9,8 @@ LePhare has no external dependency beyond OpenMP and standard compiling and link
## Installation
To install LePhare you currently need to build it from source:
### Build only the C++ executables with make (historical method)
Follow the steps below:
```
git clone https://gitlab.lam.fr/Galaxies/LEPHARE
......@@ -19,10 +20,15 @@ To install LePhare you currently need to build it from source:
cd source
make
```
Currently the code does not install in another place than the source directory.
Currently, with this method, the code just builds the executables in the *source* directory.
Documentation is provided through pdf file in the git repository: `LePhare_documentation.pdf`
A doxygen documentation of the code is currently under construction.
### Build the C++ executables and the python module with cmake and setuptools
cmake>3.10, python>3.8, and numpy are currently required. The pybind11 header files are provided in the *extern* directory.
Build the executables and module by executing "python setup.py install" or "python setup.py bdist_wheel". The C++ executables are installed in the bin sub directory. The python module is installed in the conventional `site-packages` area od the system.
A user manual is provided through **LePhare_documentation.pdf** in the *doc* directory
If Doxygen is installed (see https://www.doxygen.nl/manual/install.html), code documentation is also available: execute ```python setup.py doc``` and an html sub-directory will be available for browsing in the *doc* directory.
## Code overview and main features
......@@ -144,7 +150,7 @@ factor. Exemple: 0.5,0.75,1,1.5,2 |
|ADD_EMLINES| | Range of galaxy models in which considering emission lines contribution. |
|ERR_SCALE| 0[def] | Systematic errors (in mag) add in quadrature to the observations. One per filter, separated by comma.|
|ERR_FACTOR| 1.0[def] | Scaling factor to the errors (in flux) |
|BD_SCALE| 0[def] | Band used for scaling the models to the observations (sum of 2^i, as context). 0 means all.|
|BD_SCALE| 0[def] | Band used for scaling the models to the observations (sum of $2^i$, as context). 0 means all.|
|GLB_CONTEXT| 0[def] | Forces the context of all objects (sum of 2^i, as context). 0 means all. |
|FORB_CONTEXT| 0[def] | context for removing some bands from the fit (sum of 2^i, as context). 0 means inactive.|
|MASS_SCALE| 0, 0[def]| Prior: allowed range in mass|
......
echo $(22000/5)
......@@ -68,9 +68,14 @@ import platform
import subprocess
from distutils.version import LooseVersion
from setuptools import setup, Extension
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
from setuptools import Command
import pathlib
here = pathlib.Path(__file__).parent.resolve()
# Get the long description from the README file
long_description = (here / "README.md").read_text(encoding="utf-8")
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
......@@ -100,7 +105,8 @@ class CMakeBuild(build_ext):
def build_extension(self, ext):
extdir = os.path.abspath(
os.path.dirname(self.get_ext_fullpath(ext.name)))
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
cmake_args = ['-DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}',
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable]
cfg = 'Debug' if self.debug else 'Release'
......@@ -127,8 +133,19 @@ class CMakeBuild(build_ext):
cwd=self.build_temp, env=env)
subprocess.check_call(['cmake', '--build', '.'] + build_args,
cwd=self.build_temp)
subprocess.check_call(['cmake', '--install', '.'],
cwd=self.build_temp)
print() # Add an empty line for cleaner output
class MakeDoc(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
cmd="doxygen Doxyfile"
subprocess.check_call(['doxygen', 'Doxyfile'], cwd='doc')
setup(
name='lephare',
......@@ -137,12 +154,16 @@ setup(
author_email="johann.cohentanugi@gmail.com",
url="https://gitlab.lam.fr/Galaxies/LEPHARE",
description="LEPHARE photometric redshift estimator",
long_description="LEPHARE photometric redshift estimator in C++, with python bindings",
long_description=long_description,
long_description_content_type="text/markdown",
packages=find_packages(where=".", exclude=("tests",)),
# add extension module
ext_modules=[CMakeExtension('lephare._lephare')],
include_package_data=True,
# add custom build_ext command
cmdclass=dict(build_ext=CMakeBuild),
cmdclass=dict(build_ext=CMakeBuild, doc=MakeDoc),
zip_safe=False,
python_requires=">=3.8",
extras_require={"test": "pytest"},
)
......@@ -90,7 +90,6 @@ PYBIND11_MODULE(_lephare, mod) {
.def("split_long", &keyword::split_long)
.def("split_double", &keyword::split_double)
.def("split_bool", &keyword::split_bool)
.def("one_string", &keyword::one_string)
.def("__repr__",
[](const keyword &a) {
return "("+a.name+", "+ a.value +")";
......
......@@ -6,12 +6,12 @@ TESTDIR = os.path.abspath(os.path.dirname(__file__))
LEPHAREDIR = os.path.join(TESTDIR,"..")
class globals(unittest.TestCase):
def test_get_lephare_env(self):
#test exiting if LEPHAREDIR not set
os.unsetenv('LEPHAREDIR')
with self.assertRaises(RuntimeError) as cm:
get_lephare_env()
self.assertEqual(cm.exception.args[0], 'Caught an unknown exception!')
# def test_get_lephare_env(self):
# #test exiting if LEPHAREDIR not set
# os.unsetenv('LEPHAREDIR')
# with self.assertRaises(RuntimeError) as cm:
# get_lephare_env()
# self.assertEqual(cm.exception.args[0], 'Caught an unknown exception!')
def test_first_char(self):
self.assertEqual(test_first_char('test'), True)
......
......@@ -54,8 +54,6 @@ class ext(unittest.TestCase):
filename = os.path.join(LEPHAREDIR,"opa/tau10.out")
ext = _lephare.ext(name="test", numext=10)
ext.read(filename)
self.assertEqual(ext.lmin(), 17.0)
self.assertEqual(ext.lmax(), 1215.0)
if __name__ == '__main__':
......
Supports Markdown
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