lephare-photoz / lephare

LePHARE is a code for calculating photometric redshifts.
MIT License
5 stars 1 forks source link

Running Getting Started example gives: TypeError: readsource(): incompatible function arguments #178

Closed hdante closed 2 months ago

hdante commented 2 months ago

Hello, when executing the following script, based on the example in the Getting Started docs:

import lephare as lp
from astropy.table import Table
# The following config is highly dependent on your input data and science goals
config=lp.all_types_to_keymap(lp.default_cosmos_config)
lp.data_retrieval.get_auxiliary_data(keymap=config, additional_files=['examples/COSMOS.in'])
lp.prepare(config)
# The following example table is in the lephare input format.
input_table=Table.read(f"{lp.LEPHAREDIR}/examples/COSMOS.in", format='ascii')
output, pdfs, zgrid = lp.process(config, input_table)

I get:

>>> output, pdfs, zgrid = lp.process(config, input_table)
Using user columns from input table assuming they are in the standard order.
Processing 18420 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               : /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/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                : 2
# NZ_PRIOR               : -2 -2
# Z_INTERP               : YES
# Z_METHOD               : BEST
# PROB_INTZ              : 0.000000 
# MABS_METHOD            : 1
# MABS_CONTEXT           : 33556478 
# MABS_REF               : 10 
# AUTO_ADAPT             : NO
# ADAPT_BAND             : 4
# 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: 14
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/cache/lephare/work/lib_mag/QSO_COSMOS.doc
Number of keywords read in the config file: 17
Keyword NUMBER_ROWS not provided 
Keyword NUMBER_SED not provided 
Keyword Z_FORM not provided 
Reading library: /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/cache/lephare/work/lib_mag/QSO_COSMOS.bin
 Done with the library reading with 9814 SED read. 
Number of keywords to be read in the doc: 14
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/cache/lephare/work/lib_mag/STAR_COSMOS.doc
Number of keywords read in the config file: 17
Keyword NUMBER_ROWS not provided 
Keyword NUMBER_SED not provided 
Keyword Z_FORM not provided 
Reading library: /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/cache/lephare/work/lib_mag/STAR_COSMOS.bin
 Done with the library reading with 10068 SED read. 
Number of keywords to be read in the doc: 14
Number of keywords read at the command line (excluding -c config): 0
Reading keywords from /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/cache/lephare/work/lib_mag/CE_COSMOS.doc
Number of keywords read in the config file: 17
Keyword NUMBER_ROWS not provided 
Keyword NUMBER_SED not provided 
Keyword Z_FORM not provided 
Reading library: /lustre/t1/cl/lsst/tmp/henrique.almeida/slurm-home/var/cache/lephare/work/lib_mag/CE_COSMOS.bin
 Done with the library reading with 118723 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
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lustre/t1/cl/lsst/tmp/henrique.almeida/miniconda3/lib/python3.11/site-packages/lephare/process.py", line 53, in process
    one_obj.readsource(str(i), flux[i], flux_err[i], context[i], zspec[i], string_data[i])
TypeError: readsource(): incompatible function arguments. The following argument types are supported:
    1. (self: lephare._lephare.onesource, arg0: str, arg1: list[float], arg2: list[float], arg3: int, arg4: float, arg5: str) -> None

Invoked with: <lephare._lephare.onesource object at 0x7fef6f758870>, '0', array([-6.41449459e-32,  1.31820607e-31,  1.69058563e-31,  4.45163049e-31,
        2.26642796e-30,  1.98339413e-30,  1.92216140e-30,  1.38086403e-30,
       -1.39870907e-30,  1.03999916e-30, -1.03022638e-30,  4.82959001e-31,
        8.16676393e-31, -3.80408633e-32, -2.43452262e-31,  1.86865951e-31,
        3.19485752e-31,  3.79711571e-31,  1.85745599e-30,  4.05331931e-30,
        1.02506258e-30, -3.18141269e-31, -1.08232430e-32,  1.51057577e-29,
        1.55559713e-30,  1.11706805e-30,  2.28701980e-30, -9.90000000e+01,
       -9.90000000e+01, -9.90000000e+01]), array([ 1.10222285e-31,  9.85797069e-32,  5.86654083e-32,  7.61001231e-32,
        1.02282244e-31,  1.50691440e-31,  3.00889737e-31,  7.62980704e-31,
        7.49928203e-31,  1.24825595e-30,  1.56785772e-30,  5.14269045e-31,
        8.44728014e-31,  3.22567946e-31,  4.07932416e-31,  4.52356839e-31,
        7.02463575e-31,  4.23712487e-31,  7.97403458e-31,  6.38778865e-31,
        5.73823445e-31,  8.99417748e-31,  6.89487528e-31,  8.97822649e-31,
        7.19746586e-31,  3.63894344e-30,  1.38081336e-31, -9.90000000e+01,
       -9.90000000e+01, -9.90000000e+01]), 0, 4.839, 3004.0

Versions:

raphaelshirley commented 2 months ago

Thanks very much for spotting all these issues!

You can fix it temporarily by running this prior to the lp.process command

input_table['col64']=input_table['col64'].astype(str)

I have fixed this issue in the code and the PR should be merged soon...

hdante commented 2 months ago

Hello, Raphael, tested with version 0.1.10 released today, but it didn't work. Tested with the latest main branch and it worked. Thanks,

hdante commented 2 months ago

Hello, can you release version 0.1.11 with this patch ? Thanks,