COSMOS LePhare example

The default data for testing LePHARE is the COSMOS dataset.

In this example we use RAIL to run the standard LePHARE COSMOS example.

In this example we use fluxes not magnitudes. In order to use magnitudes you must both update the config and the values.

Note: If you’re interested in running this in pipeline mode, see 15_LePhare_COSMOS.ipynb in the pipeline_examples/estimation_examples/ folder.

import os
from collections import OrderedDict

import lephare as lp
import matplotlib.pyplot as plt
import numpy as np
from astropy.table import Table

from rail import interactive as ri
LEPHAREDIR is being set to the default cache directory:
/home/runner/.cache/lephare/data
More than 1Gb may be written there.
LEPHAREWORK is being set to the default cache directory:
/home/runner/.cache/lephare/work
Default work cache is already linked.
This is linked to the run directory:
/home/runner/.cache/lephare/runs/20260504T123336
Install FSPS with the following commands:
pip uninstall fsps
git clone --recursive https://github.com/dfm/python-fsps.git
cd python-fsps
python -m pip install .
export SPS_HOME=$(pwd)/src/fsps/libfsps
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.6 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel_launcher.py", line 18, in <module>
    app.launch_new_instance()
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/traitlets/config/application.py", line 1075, in launch_instance
    app.start()
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 758, in start
    self.io_loop.start()
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/tornado/platform/asyncio.py", line 211, in start
    self.asyncio_loop.run_forever()
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
    self._run_once()
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/asyncio/base_events.py", line 1909, in _run_once
    handle._run()
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel/utils.py", line 71, in preserve_context
    return await f(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel/kernelbase.py", line 621, in shell_main
    await self.dispatch_shell(msg, subshell_id=subshell_id)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel/kernelbase.py", line 478, in dispatch_shell
    await result
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel/ipkernel.py", line 372, in execute_request
    await super().execute_request(stream, ident, parent)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel/kernelbase.py", line 834, in execute_request
    reply_content = await reply_content
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel/ipkernel.py", line 464, in do_execute
    res = shell.run_cell(
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/ipykernel/zmqshell.py", line 663, in run_cell
    return super().run_cell(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3077, in run_cell
    result = self._run_cell(
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3132, in _run_cell
    result = runner(coro)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/IPython/core/async_helpers.py", line 128, in _pseudo_sync_runner
    coro.send(None)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3336, in run_cell_async
    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3519, in run_ast_nodes
    if await self.run_code(code, result, async_=asy):
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3579, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "/tmp/ipykernel_4685/2887657405.py", line 9, in <module>
    from rail import interactive as ri
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/rail/interactive/__init__.py", line 3, in <module>
    from . import calib, creation, estimation, evaluation, tools
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/rail/interactive/calib/__init__.py", line 3, in <module>
    from rail.utils.interactive.initialize_utils import _initialize_interactive_module
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/rail/utils/interactive/initialize_utils.py", line 17, in <module>
    from rail.utils.interactive.base_utils import (
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/rail/utils/interactive/base_utils.py", line 10, in <module>
    rail.stages.import_and_attach_all(silent=True)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/rail/stages/__init__.py", line 74, in import_and_attach_all
    RailEnv.import_all_packages(silent=silent)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/rail/core/introspection.py", line 541, in import_all_packages
    _imported_module = importlib.import_module(pkg)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/rail/som/__init__.py", line 1, in <module>
    from rail.creation.degraders.specz_som import *
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/rail/creation/degraders/specz_som.py", line 15, in <module>
    from somoclu import Somoclu
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/somoclu/__init__.py", line 11, in <module>
    from .train import Somoclu
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/somoclu/train.py", line 25, in <module>
    from .somoclu_wrap import train as wrap_train
  File "/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/somoclu/somoclu_wrap.py", line 11, in <module>
    import _somoclu_wrap
---------------------------------------------------------------------------

ImportError                               Traceback (most recent call last)

File /opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/numpy/core/_multiarray_umath.py:44, in __getattr__(attr_name)
     39     # Also print the message (with traceback).  This is because old versions
     40     # of NumPy unfortunately set up the import to replace (and hide) the
     41     # error.  The traceback shouldn't be needed, but e.g. pytest plugins
     42     # seem to swallow it and we should be failing anyway...
     43     sys.stderr.write(msg + tb_msg)
---> 44     raise ImportError(msg)
     46 ret = getattr(_multiarray_umath, attr_name, None)
     47 if ret is None:


ImportError:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.6 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.
Warning: the binary library cannot be imported. You cannot train maps, but you can load and analyze ones that you have already saved.
The problem occurs because either compilation failed when you installed Somoclu or a path is missing from the dependencies when you are trying to import it. Please refer to the documentation to see your options.

Here we load previously created synthetic data

Retrieve all the required filter and template files

lephare_config = lp.default_cosmos_config
# For useable science results you must use a denser redshift grid by commenting out the following line which will revert to the config dz of 0.01.
lephare_config["Z_STEP"] = ".1,0.,7."
nobj = 100  # Increase to run on more objects. Set to -1 to run on all.

lp.data_retrieval.get_auxiliary_data(
    keymap=lephare_config,
    additional_files=["examples/COSMOS.in", "examples/output.para"],
)
Registry file downloaded and saved as data_registry.txt.
Downloading file 'filt/hsc/gHSC.pb' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/hsc/gHSC.pb' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/hsc/iHSC.pb' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/hsc/iHSC.pb' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/hsc/rHSC.pb' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/hsc/rHSC.pb' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/u_cfht.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/u_cfht.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/u_new.pb' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/u_new.pb' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/hsc/yHSC.pb' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/hsc/yHSC.pb' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/vista/Y.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/vista/Y.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/hsc/zHSC.pb' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/hsc/zHSC.pb' to '/home/runner/.cache/lephare/data'.
Created directory: /home/runner/.cache/lephare/data/filt/hsc
Created directory: /home/runner/.cache/lephare/data/filt/cosmos
Created directory: /home/runner/.cache/lephare/data/filt/vista
Checking/downloading 445 files...
Downloading file 'filt/vista/J.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/vista/J.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/vista/H.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/vista/H.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/vista/K.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/vista/K.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB427.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB427.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB464.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB464.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB484.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB484.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB505.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB505.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB527.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB527.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB574.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB574.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB624.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB624.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB679.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB679.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB709.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB709.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB738.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB738.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB767.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB767.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/IB827.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/IB827.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/NB711.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/NB711.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/NB816.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/NB816.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/vista/NB118.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/vista/NB118.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/irac_ch1.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/irac_ch1.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/irac_ch2.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/irac_ch2.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/irac_ch3.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/irac_ch3.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'filt/cosmos/irac_ch4.lowres' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/filt/cosmos/irac_ch4.lowres' to '/home/runner/.cache/lephare/data'.
Downloading file 'examples/COSMOS.in' from 'https://raw.githubusercontent.com/lephare-photoz/lephare-data/main/examples/COSMOS.in' to '/home/runner/.cache/lephare/data'.
445 completed.
All files downloaded successfully and are non-empty.
Checking/downloading 2 files...
2 completed.
All files downloaded successfully and are non-empty.
bands = lephare_config["FILTER_LIST"].split(",")
len(bands)
30
# For a test lets just look at the first 100 objects
cosmos = Table.read(os.path.join(lp.LEPHAREDIR, "examples/COSMOS.in"), format="ascii")[
    :nobj
]
print(f"We will run on {len(cosmos)} objects.")
We will run on 100 objects.
# The example file is in the historical lephare format.
data = OrderedDict()
flux_cols = []
flux_err_cols = []
for n, b in enumerate(bands):
    # print(1+2*n,2+2*n)
    flux = cosmos[cosmos.colnames[1 + 2 * n]]
    flux_err = cosmos[cosmos.colnames[2 + 2 * n]]
    data[f"flux_{b}"] = flux
    flux_cols.append(f"flux_{b}")
    data[f"flux_err_{b}"] = flux_err
    flux_err_cols.append(f"flux_err_{b}")
data["redshift"] = np.array(cosmos[cosmos.colnames[-2]])

We use the inform stage to create the library of SEDs with various redshifts, extinction parameters, and reddening values.

lephare_model = ri.estimation.algos.lephare.lephare_informer(
    training_data=data,
    name="inform_COSMOS",
    nondetect_val=np.nan,
    hdf5_groupname="",
    lephare_config=lephare_config,
    bands=flux_cols,
    err_bands=flux_err_cols,
    ref_band=flux_cols[0],
)["model"]
Inserting handle into data store.  input: None, inform_COSMOS
rail_lephare is setting the Z_STEP config to 0.01,0.0,3.0 based on the informer params.
User defined LEPHAREDIR is set. Code runs depend on all required
auxiliary data being present at /home/runner/.cache/lephare/data.
User defined LEPHAREWORK is set. All intermediate files will be written to:
 /home/runner/.cache/lephare/runs/inform_COSMOS
# NAME                        IDENT      Lbda_mean Lbeff(Vega)       FWHM     AB-cor    TG-cor      VEGA M_sun(AB)   CALIB      Lb_eff    Fac_corr
u_cfht.lowres                 1             0.3844      0.3908      0.0538    0.3150   -0.3891  -20.6345    6.0327       0      0.3815      1.0000
u_new.pb                      2             0.3690      0.3750      0.0456    0.6195   -0.2745  -20.8527    6.3135       0      0.3668      1.0000
gHSC.pb                       3             0.4851      0.4760      0.1194   -0.0860   -0.2458  -20.7272    5.0764       0      0.4780      1.0000
rHSC.pb                       4             0.6241      0.6142      0.1539    0.1466    0.2580  -21.5143    4.6523       0      0.6178      1.0000
iHSC.pb                       5             0.7716      0.7637      0.1476    0.3942    0.6138  -22.2286    4.5323       0      0.7666      1.0000
zHSC.pb                       6             0.8915      0.8907      0.0768    0.5169    0.7625  -22.6733    4.5147       0      0.8903      1.0000
yHSC.pb                       7             0.9801      0.9771      0.0797    0.5534    0.7763  -22.9145    4.5081       0      0.9782      1.0000
Y.lowres                      8             1.0222      1.0196      0.0919    0.6043    0.8180  -23.0574    4.5130       0      1.0206      1.0000
J.lowres                      9             1.2555      1.2481      0.1712    0.9228  -99.0000  -23.8194    4.5638       0      1.2514      1.0000
H.lowres                      10            1.6497      1.6352      0.2893    1.3701  -99.0000  -24.8565    4.7045       0      1.6409      1.0000
K.lowres                      11            2.1577      2.1435      0.2926    1.8335  -99.0000  -25.9057    5.1316       0      2.1502      1.0000
IB427.lowres                  12            0.4264      0.4256      0.0207   -0.1446   -0.4942  -20.4117    5.5152       0      0.4262      1.0000
IB464.lowres                  13            0.4636      0.4633      0.0218   -0.1520   -0.3463  -20.5860    5.0658       0      0.4634      1.0000
IB484.lowres                  14            0.4851      0.4846      0.0228   -0.0241   -0.1770  -20.8122    4.9880       0      0.4849      1.0000
IB505.lowres                  15            0.5064      0.5061      0.0231   -0.0656   -0.1366  -20.8639    4.9423       0      0.5061      1.0000
IB527.lowres                  16            0.5262      0.5259      0.0242   -0.0260   -0.0464  -20.9871    4.8937       0      0.5260      1.0000
IB574.lowres                  17            0.5766      0.5762      0.0272    0.0657    0.1377  -21.2773    4.7042       0      0.5763      1.0000
IB624.lowres                  18            0.6234      0.6230      0.0301    0.1527    0.2768  -21.5339    4.6386       0      0.6232      1.0000
IB679.lowres                  19            0.6783      0.6779      0.0336    0.2542    0.4288  -21.8183    4.5709       0      0.6779      1.0000
IB709.lowres                  20            0.7075      0.7071      0.0316    0.2982    0.4968  -21.9541    4.5558       0      0.7072      1.0000
IB738.lowres                  21            0.7363      0.7358      0.0323    0.3460    0.5577  -22.0886    4.5449       0      0.7360      1.0000
IB767.lowres                  22            0.7687      0.7681      0.0364    0.3992    0.6164  -22.2351    4.5243       0      0.7683      1.0000
IB827.lowres                  23            0.8246      0.8241      0.0344    0.4891    0.7300  -22.4777    4.5161       0      0.8243      1.0000
NB711.lowres                  24            0.7120      0.7119      0.0073    0.3072    0.5084  -21.9774    4.5542       0      0.7120      1.0000
NB816.lowres                  25            0.8150      0.8149      0.0120    0.4713    0.7098  -22.4349    4.5154       0      0.8149      1.0000
NB118.lowres                  26            1.1909      1.1909      0.0112    0.8376  -99.0000  -23.6250    4.5554       0      1.1909      1.0000
irac_ch1.lowres               27            3.5763      3.5264      0.7411    2.7951  -99.0000  -27.9585    6.0679       1      3.5634      1.0036
irac_ch2.lowres               28            4.5290      4.4609      1.0105    3.2634  -99.0000  -28.9384    6.5680       1      4.5111      1.0040
irac_ch3.lowres               29            5.7873      5.6765      1.3509    3.7537  -99.0000  -29.9581    7.0472       1      5.7592      1.0050
irac_ch4.lowres               30            8.0442      7.7033      2.8394    4.3959  -99.0000  -31.2962    7.6701       1      7.9590      1.0110
#######################################
# It s translating SEDs to binary library #
# with the following options :
# Config file     :
# Library type     : STAR
# STAR_SED    :/home/runner/.cache/lephare/data/sed/STAR/STAR_MOD_ALL.list
# STAR_LIB    :LIB_STAR
# STAR_LIB doc:/home/runner/.cache/lephare/runs/inform_COSMOS/lib_bin/LIB_STAR.doc
# STAR_FSCALE :0.0000
#######################################
Number of SED in the list 254
WRONG NUMBER OF ARGUMENTS FOR OPTION MOD_EXTINC
We have 2 instead of 8
Use default value 0,0 for all filters
#######################################
# It s computing the SYNTHETIC MAGNITUDES #
# For Gal/QSO libraries with these OPTIONS #
# with the following options :
# Config file     :
# Filter file     : filter_cosmos
# Magnitude type     : AB
# COSMOLOGY   :70.0000,0.3000,0.7000
# STAR_LIB_IN    :/home/runner/.cache/lephare/runs/inform_COSMOS/lib_bin/LIB_STAR(.doc & .bin)
# STAR_LIB_OUT   :/home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/STAR_COSMOS(.doc & .bin)
# LIB_ASCII   YES
# CREATION_DATE Mon May  4 12:40:22 2026
#############################################
#######################################
# It s translating SEDs to binary library #
# with the following options :
# Config file     :
# Library type     : GAL
# GAL_SED    :/home/runner/.cache/lephare/data/sed/GAL/COSMOS_SED/COSMOS_MOD.list
# GAL_LIB    :LIB_CE
# GAL_LIB doc:/home/runner/.cache/lephare/runs/inform_COSMOS/lib_bin/LIB_CE.doc
# GAL_LIB phys:/home/runner/.cache/lephare/runs/inform_COSMOS/lib_bin/LIB_CE.phys
# SEL_AGE    :none
# GAL_FSCALE :1.0000
# AGE_RANGE   0.0000 15000000000.0000
#######################################
Number of SED in the list 31
#######################################
# It s computing the SYNTHETIC MAGNITUDES #
# For Gal/QSO libraries with these OPTIONS #
# with the following options :
# Config file     :
# Filter file     : filter_cosmos
# Magnitude type     : AB
# GAL_LIB_IN    :/home/runner/.cache/lephare/runs/inform_COSMOS/lib_bin/LIB_CE(.doc & .bin)
# GAL_LIB_OUT   :/home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/CE_COSMOS(.doc & .bin)
# Z_STEP   :0.0100 0.0000 3.0000
# COSMOLOGY   :70.0000,0.3000,0.7000
# EXTINC_LAW   :SMC_prevot.dat SB_calzetti.dat SB_calzetti_bump1.dat SB_calzetti_bump2.dat
# MOD_EXTINC   :18 26 26 33 26 33 26 33
# EB_V   :0.0000 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.5000
# EM_LINES   EMP_UV
# EM_DISPERSION   0.5000,0.7500,1.0000,1.5000,2.0000,
# LIB_ASCII   YES
# CREATION_DATE Mon May  4 12:40:23 2026
#############################################
#######################################
# It s translating SEDs to binary library #
# with the following options :
# Config file     :
# Library type     : QSO
# QSO_SED    :/home/runner/.cache/lephare/data/sed/QSO/SALVATO09/AGN_MOD.list
# QSO_LIB    :LIB_QSO
# QSO_LIB doc:/home/runner/.cache/lephare/runs/inform_COSMOS/lib_bin/LIB_QSO.doc
# QSO_FSCALE :1.0000
#######################################
Number of SED in the list 30
#######################################
# It s computing the SYNTHETIC MAGNITUDES #
# For Gal/QSO libraries with these OPTIONS #
# with the following options :
# Config file     :
# Filter file     : filter_cosmos
# Magnitude type     : AB
# QSO_LIB_IN    :/home/runner/.cache/lephare/runs/inform_COSMOS/lib_bin/LIB_QSO(.doc & .bin)
# QSO_LIB_OUT   :/home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/QSO_COSMOS(.doc & .bin)
# Z_STEP   :0.0100 0.0000 3.0000
# COSMOLOGY   :70.0000,0.3000,0.7000
# EXTINC_LAW   :SB_calzetti.dat
# MOD_EXTINC   :0 1000
# EB_V   :0.0000 0.1000 0.2000 0.3000 # LIB_ASCII   YES
# CREATION_DATE Mon May  4 12:44:03 2026
#############################################
Using user columns from input table assuming they are in the standard order.
Processing 100 objects with 30 bands
#######################################
# PHOTOMETRIC REDSHIFT with OPTIONS   #
# Config file            :
# CAT_IN                 : change_me_to_output_filename_required.ascii
# CAT_OUT                : zphot.out
# CAT_LINES              : 0 1000000000
# PARA_OUT               : /home/runner/.cache/lephare/data/examples/output.para
# INP_TYPE               : F
# CAT_FMT[0:MEME 1:MMEE] : 0
# CAT_MAG                : AB
# ZPHOTLIB               : CE_COSMOS STAR_COSMOS QSO_COSMOS
# FIR_LIB                :
# FIR_LMIN               : 7.000000
# FIR_CONT               : -1.000000
# FIR_SCALE              : -1.000000
# FIR_FREESCALE          : YES
# FIR_SUBSTELLAR         : NO
# ERR_SCALE              : 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.050000 0.050000 0.050000 0.050000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.050000 0.050000 0.050000 0.050000 0.100000 0.200000 0.300000
# ERR_FACTOR
          : 1.500000
# GLB_CONTEXT            : 0
# FORB_CONTEXT           : -1
# DZ_WIN                 : 1.000000
# MIN_THRES              : 0.020000
# MAG_ABS                : -24.000000 -5.000000
# MAG_ABS_AGN            : -30.000000 -10.000000
# MAG_REF                : 3
# NZ_PRIOR               : -1 -1
# Z_INTERP               : YES
# Z_METHOD               : BEST
# MABS_METHOD            : 1
# MABS_CONTEXT           : 33556478
# MABS_REF               : 11
# AUTO_ADAPT             : NO
# ADAPT_BAND             : 5
# ADAPT_LIM              : 1.500000 23.000000
# ADAPT_ZBIN             : 0.010000 6.000000
# ZFIX                   : NO
# SPEC_OUT               : NO
# CHI_OUT                : NO
# PDZ_OUT                : test
#######################################
Reading input librairies ...
Read lib
Number of keywords to be read in the doc: 13
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /home/runner/.cache/lephare/runs/inform_Offsets from auto-adapt: 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0

COSMOS/lib_mag/QSO_COSMOS.doc
Number of keywords read in the config file: 16
Keyword NUMBER_ROWS not provided
Keyword NUMBER_SED not provided
Keyword Z_FORM not provided
Reading library: /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/QSO_COSMOS.bin
 Done with the library reading with 36120 SED read.
Number of keywords to be read in the doc: 13
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/STAR_COSMOS.doc
Number of keywords read in the config file: 16
Keyword NUMBER_ROWS not provided
Keyword NUMBER_SED not provided
Keyword Z_FORM not provided
Reading library: /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/STAR_COSMOS.bin
 Done with the library reading with 36374 SED read.
Number of keywords to be read in the doc: 13
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/CE_COSMOS.doc
Number of keywords read in the config file: 16
Keyword NUMBER_ROWS not provided
Keyword NUMBER_SED not provided
Keyword Z_FORM not provided
Reading library: /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/CE_COSMOS.bin
 Done with the library reading with 448744 SED read.
Read lib out
Read filt
# NAME                        IDENT      Lbda_mean Lbeff(Vega)       FWHM     AB-cor      VEGA   CALIB    Fac_corr
u_cfht.lowres                 1             0.3844      0.3908      0.0538    0.3150  -20.6300       0      1.0000
u_new.pb                      2             0.3690      0.3750      0.0456    0.6195  -20.8500       0      1.0000
gHSC.pb                       3             0.4851      0.4760      0.1194   -0.0860  -20.7300       0      1.0000
rHSC.pb                       4             0.6241      0.6142      0.1539    0.1466  -21.5100       0      1.0000
iHSC.pb                       5             0.7716      0.7637      0.1476    0.3942  -22.2300       0      1.0000
zHSC.pb                       6             0.8915      0.8907      0.0768    0.5169  -22.6700       0      1.0000
yHSC.pb                       7             0.9801      0.9771      0.0797    0.5534  -22.9100       0      1.0000
Y.lowres                      8             1.0220      1.0200      0.0919    0.6043  -23.0600       0      1.0000
J.lowres                      9             1.2550      1.2480      0.1712    0.9228  -23.8200       0      1.0000
H.lowres                      10            1.6500      1.6350      0.2893    1.3700  -24.8600       0      1.0000
K.lowres                      11            2.1580      2.1430      0.2926    1.8330  -25.9100       0      1.0000
IB427.lowres                  12            0.4264      0.4256      0.0207   -0.1446  -20.4100       0      1.0000
IB464.lowres                  13            0.4636      0.4633      0.0218   -0.1520  -20.5900       0      1.0000
IB484.lowres                  14            0.4851      0.4846      0.0228   -0.0241  -20.8100       0      1.0000
IB505.lowres                  15            0.5064      0.5061      0.0231   -0.0656  -20.8600       0      1.0000
IB527.lowres                  16            0.5262      0.5259      0.0242   -0.0260  -20.9900       0      1.0000
IB574.lowres                  17            0.5766      0.5762      0.0272    0.0657  -21.2800       0      1.0000
IB624.lowres                  18            0.6234      0.6230      0.0301    0.1527  -21.5300       0      1.0000
IB679.lowres                  19            0.6783      0.6779      0.0336    0.2542  -21.8200       0      1.0000
IB709.lowres                  20            0.7075      0.7071      0.0316    0.2982  -21.9500       0      1.0000
IB738.lowres                  21            0.7363      0.7358      0.0323    0.3460  -22.0900       0      1.0000
IB767.lowres                  22            0.7687      0.7681      0.0364    0.3992  -22.2400       0      1.0000
IB827.lowres                  23            0.8246      0.8241      0.0344    0.4891  -22.4800       0      1.0000
NB711.lowres                  24            0.7120      0.7119      0.0073    0.3072  -21.9800       0      1.0000
NB816.lowres                  25            0.8150      0.8149      0.0120    0.4713  -22.4300       0      1.0000
NB118.lowres                  26            1.1910      1.1910      0.0112    0.8376  -23.6200       0      1.0000
irac_ch1.lowres               27            3.5760      3.5260      0.7411    2.7950  -27.9600       1      1.0040
irac_ch2.lowres               28            4.5290      4.4610      1.0100    3.2630  -28.9400       1      1.0040
irac_ch3.lowres               29            5.7870      5.6760      1.3510    3.7540  -29.9600       1      1.0050
irac_ch4.lowres               30            8.0440      7.7030      2.8390    4.3960  -31.3000       1      1.0110
Inserting handle into data store.  model_inform_COSMOS: inprogress_model_inform_COSMOS.pkl, inform_COSMOS

Now we take the sythetic test data, and find the best fits from the library. This results in a PDF, zmode, and zmean for each input test data.

lephare_estimated = ri.estimation.algos.lephare.lephare_estimator(
    input_data=data,
    name="test_Lephare_COSMOS",
    nondetect_val=np.nan,
    model=lephare_model,
    hdf5_groupname="",
    aliases=dict(input="test_data", output="lephare_estim"),
    bands=flux_cols,
    err_bands=flux_err_cols,
    ref_band=flux_cols[0],
)["output"]
Inserting handle into data store.  test_data: None, test_Lephare_COSMOS
Inserting handle into data store.  model: {'lephare_version': '0.3.1', 'lephare_config': {'ADAPT_BAND': '5', 'ADAPT_CONTEXT': '-1', 'ADAPT_LIM': '1.5,23.0', 'ADAPT_MODBIN': '1,1000', 'ADAPT_ZBIN': '0.01,6', 'ADDITIONAL_MAG': 'none', 'ADD_DUSTEM': 'NO', 'ADD_EMLINES': '0,10000', 'AGE_RANGE': '0.,15.e9', 'AUTO_ADAPT': 'NO', 'CAT_FMT': 'MEME', 'CAT_IN': 'change_me_to_output_filename_required.ascii', 'CAT_LINES': '0,1000000000', 'CAT_MAG': 'AB', 'CAT_OUT': 'zphot.out', 'CAT_TYPE': 'LONG', 'CHI2_OUT': 'NO', 'COSMOLOGY': '70,0.3,0.7', 'DZ_WIN': '1.0', 'EBV_RANGE': '0,9', 'EB_V': '0.,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.5', 'EM_DISPERSION': '0.5,0.75,1.,1.5,2.', 'EM_LINES': 'EMP_UV', 'ERR_FACTOR': '1.5', 'ERR_SCALE': '0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.05,0.05,0.05,0.05,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.05,0.05,0.05,0.05,0.1,0.2,0.3', 'EXTERNALZ_FILE': 'NONE', 'EXTINC_LAW': 'SMC_prevot.dat,SB_calzetti.dat,SB_calzetti_bump1.dat,SB_calzetti_bump2.dat', 'FILTER_CALIB': '0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1', 'FILTER_FILE': 'filter_cosmos', 'FILTER_LIST': 'cosmos/u_cfht.lowres,cosmos/u_new.pb,hsc/gHSC.pb,hsc/rHSC.pb,hsc/iHSC.pb,hsc/zHSC.pb,hsc/yHSC.pb,vista/Y.lowres,vista/J.lowres,vista/H.lowres,vista/K.lowres,cosmos/IB427.lowres,cosmos/IB464.lowres,cosmos/IB484.lowres,cosmos/IB505.lowres,cosmos/IB527.lowres,cosmos/IB574.lowres,cosmos/IB624.lowres,cosmos/IB679.lowres,cosmos/IB709.lowres,cosmos/IB738.lowres,cosmos/IB767.lowres,cosmos/IB827.lowres,cosmos/NB711.lowres,cosmos/NB816.lowres,vista/NB118.lowres,cosmos/irac_ch1.lowres,cosmos/irac_ch2.lowres,cosmos/irac_ch3.lowres,cosmos/irac_ch4.lowres', 'FILTER_REP': '/home/runner/.cache/lephare/data/filt', 'FIR_CONT': '-1', 'FIR_FREESCALE': 'YES', 'FIR_LIB': 'NONE', 'FIR_LMIN': '7.0', 'FIR_SCALE': '-1', 'FIR_SUBSTELLAR': 'NO', 'FORB_CONTEXT': '-1', 'GAL_FSCALE': '1.', 'GAL_LIB': 'LIB_CE', 'GAL_LIB_IN': 'LIB_CE', 'GAL_LIB_OUT': 'CE_COSMOS', 'GAL_SED': '/home/runner/.cache/lephare/data/sed/GAL/COSMOS_SED/COSMOS_MOD.list', 'GLB_CONTEXT': '0', 'INP_TYPE': 'F', 'LIB_ASCII': 'NO', 'LIMITS_MAPP_CUT': '90', 'LIMITS_MAPP_REF': '1', 'LIMITS_MAPP_SEL': '1', 'LIMITS_ZBIN': '0,99', 'MABS_CONTEXT': '33556478', 'MABS_FILT': '1,2,3,4', 'MABS_METHOD': '1', 'MABS_REF': '11', 'MABS_ZBIN': '0,0.5,2,4,6', 'MAGTYPE': 'AB', 'MAG_ABS': '-24,-5', 'MAG_ABS_QSO': '-30,-10', 'MAG_REF': '3', 'MIN_THRES': '0.02', 'MOD_EXTINC': '0,0', 'PARA_OUT': '/home/runner/.cache/lephare/data/examples/output.para', 'PDZ_OUT': 'test', 'PDZ_TYPE': 'BAY_ZG', 'QSO_FSCALE': '1.', 'QSO_LIB': 'LIB_QSO', 'QSO_LIB_IN': 'LIB_QSO', 'QSO_LIB_OUT': 'QSO_COSMOS', 'QSO_SED': '/home/runner/.cache/lephare/data/sed/QSO/SALVATO09/AGN_MOD.list', 'RF_COLORS': '32,4,4,13', 'RM_DISCREPANT_BD': '500', 'SPEC_OUT': 'NO', 'STAR_FSCALE': '3.432E-09', 'STAR_LIB': 'LIB_STAR', 'STAR_LIB_IN': 'LIB_STAR', 'STAR_LIB_OUT': 'STAR_COSMOS', 'STAR_SED': '/home/runner/.cache/lephare/data/sed/STAR/STAR_MOD_ALL.list', 'TRANS_TYPE': '1', 'VERBOSE': 'NO', 'ZFIX': 'NO', 'ZGRID_TYPE': '0', 'ZPHOTLIB': 'CE_COSMOS,STAR_COSMOS,QSO_COSMOS', 'Z_INTERP': 'YES', 'Z_METHOD': 'BEST', 'Z_RANGE': '0.,99.99', 'Z_STEP': '0.01,0.0,3.0'}, 'offsets': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'run_dir': '/home/runner/.cache/lephare/runs/inform_COSMOS', 'star_config': {'LIB_ASCII': 'YES'}, 'gal_config': {'LIB_ASCII': 'YES', 'MOD_EXTINC': '18,26,26,33,26,33,26,33', 'EXTINC_LAW': 'SMC_prevot.dat,SB_calzetti.dat,SB_calzetti_bump1.dat,SB_calzetti_bump2.dat', 'EM_LINES': 'EMP_UV', 'EM_DISPERSION': '0.5,0.75,1.,1.5,2.'}, 'qso_config': {'LIB_ASCII': 'YES', 'MOD_EXTINC': '0,1000', 'EB_V': '0.,0.1,0.2,0.3', 'EXTINC_LAW': 'SB_calzetti.dat'}}, test_Lephare_COSMOS
User defined LEPHAREDIR is set. Code runs depend on all required
auxiliary data being present at /home/runner/.cache/lephare/data.
User defined LEPHAREWORK is set. All intermediate files will be written to:
 /home/runner/.cache/lephare/runs/inform_COSMOS
Process 0 running estimator on chunk 0 - 100
Using user columns from input table assuming they are in the standard order.
Processing 100 objects with 30 bands
#######################################
# PHOTOMETRIC REDSHIFT with OPTIONS   #
# Config file            :
# CAT_IN                 : change_me_to_output_filename_required.ascii
# CAT_OUT                : zphot.out
# CAT_LINES              : 0 1000000000
# PARA_OUT               : /home/runner/.cache/lephare/data/examples/output.para
# INP_TYPE               : F
# CAT_FMT[0:MEME 1:MMEE] : 0
# CAT_MAG                : AB
# ZPHOTLIB               : CE_COSMOS STAR_COSMOS QSO_COSMOS
# FIR_LIB                :
# FIR_LMIN               : 7.000000
# FIR_CONT               : -1.000000
# FIR_SCALE              : -1.000000
# FIR_FREESCALE          : YES
# FIR_SUBSTELLAR         : NO
# ERR_SCALE              : 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.050000 0.050000 0.050000 0.050000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.020000 0.050000 0.050000 0.050000 0.050000 0.100000 0.200000 0.300000
# ERR_FACTOR
AUTO_ADAPT is set to YES. Computing offsets.          : 1.500000
# GLB_CONTEXT            : 0
# FORB_CONTEXT           : -1
# DZ_WIN                 : 1.000000
# MIN_THRES              : 0.020000
# MAG_ABS                : -24.000000 -5.000000
# MAG_ABS_AGN            : -30.000000 -10.000000
# MAG_REF                : 3
# NZ_PRIOR               : -1 -1
# Z_INTERP               : YES
# Z_METHOD               : BEST
# MABS_METHOD            : 1
# MABS_CONTEXT           : 33556478
# MABS_REF               : 11
# AUTO_ADAPT             : NO
# ADAPT_BAND             : 5
# ADAPT_LIM              : 1.500000 23.000000
# ADAPT_ZBIN             : 0.010000 6.000000
# ZFIX                   : NO
# SPEC_OUT               : NO
# CHI_OUT                : NO
# PDZ_OUT                : test
#######################################
Reading input librairies ...
Read lib
Number of keywords to be read in the doc: 13
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /home/runner/.cache/lephare/runs/inform_
# Offsets added to the modeled magnitudes (or substracted to the observed): 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0

COSMOS/lib_mag/QSO_COSMOS.doc
Number of keywords read in the config file: 16
Keyword NUMBER_ROWS not provided
Keyword NUMBER_SED not provided
Keyword Z_FORM not provided
Reading library: /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/QSO_COSMOS.bin
 Done with the library reading with 36120 SED read.
Number of keywords to be read in the doc: 13
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/STAR_COSMOS.doc
Number of keywords read in the config file: 16
Keyword NUMBER_ROWS not provided
Keyword NUMBER_SED not provided
Keyword Z_FORM not provided
Reading library: /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/STAR_COSMOS.bin
 Done with the library reading with 36374 SED read.
Number of keywords to be read in the doc: 13
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/CE_COSMOS.doc
Number of keywords read in the config file: 16
Keyword NUMBER_ROWS not provided
Keyword NUMBER_SED not provided
Keyword Z_FORM not provided
Reading library: /home/runner/.cache/lephare/runs/inform_COSMOS/lib_mag/CE_COSMOS.bin
 Done with the library reading with 448744 SED read.
Read lib out
Read filt
# NAME                        IDENT      Lbda_mean Lbeff(Vega)       FWHM     AB-cor      VEGA   CALIB    Fac_corr
u_cfht.lowres                 1             0.3844      0.3908      0.0538    0.3150  -20.6300       0      1.0000
u_new.pb                      2             0.3690      0.3750      0.0456    0.6195  -20.8500       0      1.0000
gHSC.pb                       3             0.4851      0.4760      0.1194   -0.0860  -20.7300       0      1.0000
rHSC.pb                       4             0.6241      0.6142      0.1539    0.1466  -21.5100       0      1.0000
iHSC.pb                       5             0.7716      0.7637      0.1476    0.3942  -22.2300       0
1.0000
zHSC.pb                       6             0.8915      0.8907      0.0768    0.5169  -22.6700       0      1.0000
yHSC.pb                       7             0.9801      0.9771      0.0797    0.5534  -22.9100       0      1.0000
Y.lowres                      8             1.0220      1.0200      0.0919    0.6043  -23.0600       0      1.0000
J.lowres                      9             1.2550      1.2480      0.1712    0.9228  -23.8200       0      1.0000
H.lowres                      10            1.6500      1.6350      0.2893    1.3700  -24.8600       0      1.0000
K.lowres                      11            2.1580      2.1430      0.2926    1.8330  -25.9100       0      1.0000
IB427.lowres                  12            0.4264      0.4256      0.0207   -0.1446  -20.4100       0      1.0000
IB464.lowres                  13            0.4636      0.4633      0.0218   -0.1520  -20.5900       0      1.0000
IB484.lowres                  14            0.4851      0.4846      0.0228   -0.0241  -20.8100       0      1.0000
IB505.lowres                  15            0.5064      0.5061      0.0231   -0.0656  -20.8600       0      1.0000
IB527.lowres                  16            0.5262      0.5259      0.0242   -0.0260  -20.9900       0      1.0000
IB574.lowres                  17            0.5766      0.5762      0.0272    0.0657  -21.2800       0      1.0000
IB624.lowres                  18            0.6234      0.6230      0.0301    0.1527  -21.5300       0      1.0000
IB679.lowres                  19            0.6783      0.6779      0.0336    0.2542  -21.8200       0      1.0000
IB709.lowres                  20            0.7075      0.7071      0.0316    0.2982  -21.9500       0      1.0000
IB738.lowres                  21            0.7363      0.7358      0.0323    0.3460  -22.0900       0      1.0000
IB767.lowres                  22            0.7687      0.7681      0.0364    0.3992  -22.2400       0      1.0000
IB827.lowres                  23            0.8246      0.8241      0.0344    0.4891  -22.4800       0      1.0000
NB711.lowres                  24            0.7120      0.7119      0.0073    0.3072  -21.9800       0      1.0000
NB816.lowres                  25            0.8150      0.8149      0.0120    0.4713  -22.4300       0      1.0000
NB118.lowres                  26            1.1910      1.1910      0.0112    0.8376  -23.6200       0      1.0000
irac_ch1.lowres               27            3.5760      3.5260      0.7411    2.7950  -27.9600       1      1.0040
irac_ch2.lowres               28            4.5290      4.4610      1.0100    3.2630  -28.9400       1      1.0040
irac_ch3.lowres               29            5.7870      5.6760      1.3510    3.7540  -29.9600       1      1.0050
irac_ch4.lowres               30            8.0440      7.7030      2.8390    4.3960  -31.3000       1      1.0110
Inserting handle into data store.  output_test_Lephare_COSMOS: inprogress_output_test_Lephare_COSMOS.hdf5, test_Lephare_COSMOS
lephare_config["AUTO_ADAPT"]
'NO'

An example lephare PDF and comparison to the true value

indx = 1
zgrid = np.linspace(0, 7, 1000)
plt.plot(zgrid, np.squeeze(lephare_estimated[indx].pdf(zgrid)), label="Estimated PDF")
plt.axvline(x=data["redshift"][indx], color="r", label="True redshift")
plt.legend()
plt.xlabel("z")
plt.show()
../../../_images/LePhare_COSMOS_15_0.png

More example fits

indxs = [8, 16, 32, 64, 65, 66, 68, 69]  # , 128, 256, 512, 1024]
zgrid = np.linspace(0, 7, 1000)
fig, axs = plt.subplots(2, 4, figsize=(20, 6))
for i, indx in enumerate(indxs):
    ax = axs[i // 4, i % 4]
    ax.plot(
        zgrid,
        np.squeeze(lephare_estimated[indx].pdf(zgrid)),
        label="Estimated PDF",
    )
    ax.axvline(x=data["redshift"][indx], color="r", label="True redshift")
    ax.set_xlabel("z")
../../../_images/LePhare_COSMOS_17_0.png

Histogram of the absolute difference between lephare estimate and true redshift

estimate_diff_from_truth = np.abs(lephare_estimated.ancil["zmode"] - data["redshift"])

plt.figure()
plt.hist(estimate_diff_from_truth, 100)
plt.xlabel("abs(z_estimated - z_true)")
plt.show()
../../../_images/LePhare_COSMOS_19_0.png
plt.scatter(data["redshift"], lephare_estimated.ancil["Z_BEST"])
plt.xlabel("$z_{spec}$")
plt.ylabel("$z_{LePHARE}$")
Text(0, 0.5, '$z_{LePHARE}$')
../../../_images/LePhare_COSMOS_20_1.png
plt.scatter(data["redshift"], lephare_estimated.ancil["zmean"])
plt.xlabel("$z_{spec}$")
plt.ylabel("$z_{LePHARE}$")
Text(0, 0.5, '$z_{LePHARE}$')
../../../_images/LePhare_COSMOS_21_1.png