fermi-lat / Likelihood

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

unbinnedAnalysis() from fermitools-2.2.0 version seems not to be adapted to numpy.float becomes float #122

Closed landriu closed 3 months ago

landriu commented 3 months ago

Hello,

when trying to generate a like object using unbinnedAnalysis() from UnbinnedAnalysis.py from fermitools-2.2.0 installation on SLAC machine, I get the following error :

(fermitools-2.2.0) [landriu@sdfiana009 testLike]$ python Python 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 15:55:03) [GCC 10.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.

from UnbinnedAnalysis import unbinnedAnalysis like = unbinnedAnalysis( evfile="/sdf/group/fermi/u/landriu/runs/tH/like/Rois/MergedEVENTS_1_E5.fits", scfile="/sdf/group/fermi/u/landriu/runs/tH/input/ft2_july09_pass8.fits", expmap="/sdf/group/fermi/u/landriu/runs/tH/like/Rois/expMap_1_E5.fits", expcube="/sdf/group/fermi/u/landriu/runs/tH/input/ltCube_105.fits", irfs="CALDB", optimizer="Minuit", srcmdl="/sdf/home/l/landriu/dev/testLike/srcModel_1_E5.xml-initial")

Traceback (most recent call last): File "", line 1, in File "/sdf/group/fermi/sw/conda/envs/fermitools-2.2.0/lib/python3.9/site-packages/fermitools/UnbinnedAnalysis.py", line 278, in unbinnedAnalysis like = UnbinnedAnalysis(obs, pars['srcmdl'], pars['optimizer'], nee=nee) File "/sdf/group/fermi/sw/conda/envs/fermitools-2.2.0/lib/python3.9/site-packages/fermitools/UnbinnedAnalysis.py", line 159, in init self.energies = eMinnum.exp(estepnum.arange(nee, dtype=num.float)) File "/sdf/group/fermi/sw/conda/envs/fermitools-2.2.0/lib/python3.9/site-packages/numpy/init.py", line 284, in getattr raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'float'

And I have following settings :

(fermitools-2.2.0) [landriu@sdfiana009 testLike]$ conda env list

conda environments:

# base /sdf/group/fermi/sw/conda calibrator /sdf/group/fermi/sw/conda/envs/calibrator fermitools-2.2.0 * /sdf/group/fermi/sw/conda/envs/fermitools-2.2.0 flare-advocate /sdf/group/fermi/sw/conda/envs/flare-advocate threeML-2.4.0 /sdf/group/fermi/sw/conda/envs/threeML-2.4.0

(fermitools-2.2.0) [landriu@sdfiana009 testLike]$ conda list fermi

packages in environment at /sdf/group/fermi/sw/conda/envs/fermitools-2.2.0:

#

Name Version Build Channel

fermipy 1.2.0 pypi_0 pypi fermitools 2.2.0 py39h93a0a19_0 fermi fermitools-data 0.18 0 fermi (fermitools-2.2.0) [landriu@sdfiana009 testLike]$ conda list numpy

packages in environment at /sdf/group/fermi/sw/conda/envs/fermitools-2.2.0:

#

Name Version Build Channel

numpy 1.24.1 py39h223a676_0 conda-forge

Can you check please ? I guess this error can be easily reproduced with any other inputs, and if it is not the case: you should be allowed to use mine. Tell me if I forgot to mention anything .

David Landriu

nmirabal commented 3 months ago

Thanks for reporting it. The FSSC is aware of this and hopefully it will be fixed in the next release. A temporary fix is to include the following at the beginning of each session:

import numpy as np np.float=float

landriu commented 3 months ago

Hi, this is working indeed. I just want to give the following precision that in AnalysisBase.py, from which is derived UnbinnedAnalysis.py, it was written "import numpy as num"

Thank you for your help