threeML / hawc_hal

HAWC Accelerated Likelihood - python-only framework for HAWC data analysis
BSD 3-Clause "New" or "Revised" License
12 stars 22 forks source link

Deleting all the `old_div` appearances in hawc_hal #36

Closed hayalaso closed 4 years ago

hayalaso commented 4 years ago

I deleted all the appearances of old_div inside hawc_hal. I know @ndilalla run some tests and was able to pinpoint the problem when running HAL with the public HAWC data. So if this PR is not necessary let me know.

I tested this repo and I was able to get the same results as @ndilalla. However, I was not able to get the figures with the environment that I was using. It is the environment that we use to install 3ML in HAWC (@cbrisboi might have more info). After talking with @cbrisboi it seems there are other py2-py3 non-trivial issues so not getting the figures might be related to that.

ndilalla commented 4 years ago

Thank you @hayalaso, this is certainly very useful! Could you please briefly explain which problems you encountered with figures? And which other py2/py3 non-trivial issues? I think the best thing to do is to open an appropriate issue here on github, so that we can work on it and keep track of everything.

hayalaso commented 4 years ago

Yeah, I got this after the fit results when trying to call the method fig = hawc.display_spectrum()

  File "crab_fit_logparabola.py", line 73, in <module>
    fig = hawc.display_spectrum()
  File "build/bdist.linux-x86_64/egg/hawc_hal/HAL.py", line 406, in display_spectrum
  File "build/bdist.linux-x86_64/egg/hawc_hal/HAL.py", line 414, in _plot_spectrum
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/matplotlib/__init__.py", line 1717, in inner
    return func(ax, *args, **kwargs)
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 3024, in errorbar
    barcols.append(self.vlines(xo, lo, uo, **eb_lines_style))
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/matplotlib/__init__.py", line 1717, in inner
    return func(ax, *args, **kwargs)
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 1002, in vlines
    minx = x.min()
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/numpy/core/_methods.py", line 32, in _amin
    return umr_minimum(a, axis, None, out, keepdims, initial)
TypeError: cannot perform reduce with flexible type

At least my understanding from this environment is that it installs 3ml using python3 but some of the libraries, like matplotlib from seeing this traceback, show that it is linked to some py2 libraries. I know @cbrisboi wrote the installation of this environment, so he might have more insight about it.

Also just for completeness, here are the fit results I got, since I forgot to add them before

Best fit values:
                                                            result  \
parameter                                                            
crab.spectrum.main.Log_parabola.K      (2.54 -0.06 +0.07) x 10^-22   
crab.spectrum.main.Log_parabola.alpha             -2.646 +/- 0.019   
crab.spectrum.main.Log_parabola.beta       (1.04 +/- 0.15) x 10^-1   
                                                  unit  
parameter                                               
crab.spectrum.main.Log_parabola.K      1 / (cm2 keV s)  
crab.spectrum.main.Log_parabola.alpha                   
crab.spectrum.main.Log_parabola.beta                    
Correlation matrix:
 col0  col1  col2
----- ----- -----
 1.00 -0.11  0.83
-0.11  1.00 -0.43
 0.83 -0.43  1.00
ndilalla commented 4 years ago

Yeah, I got this after the fit results when trying to call the method fig = hawc.display_spectrum()

  File "crab_fit_logparabola.py", line 73, in <module>
    fig = hawc.display_spectrum()
  File "build/bdist.linux-x86_64/egg/hawc_hal/HAL.py", line 406, in display_spectrum
  File "build/bdist.linux-x86_64/egg/hawc_hal/HAL.py", line 414, in _plot_spectrum
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/matplotlib/__init__.py", line 1717, in inner
    return func(ax, *args, **kwargs)
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 3024, in errorbar
    barcols.append(self.vlines(xo, lo, uo, **eb_lines_style))
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/matplotlib/__init__.py", line 1717, in inner
    return func(ax, *args, **kwargs)
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 1002, in vlines
    minx = x.min()
  File "/home/hayalaso/hawc_software/miniconda3/envs/hal_analysis/lib/python2.7/site-packages/numpy/core/_methods.py", line 32, in _amin
    return umr_minimum(a, axis, None, out, keepdims, initial)
TypeError: cannot perform reduce with flexible type

At least my understanding from this environment is that it installs 3ml using python3 but some of the libraries, like matplotlib from seeing this traceback, show that it is linked to some py2 libraries. I know @cbrisboi wrote the installation of this environment, so he might have more insight about it.

Also just for completeness, here are the fit results I got, since I forgot to add them before

Best fit values:
                                                            result  \
parameter                                                            
crab.spectrum.main.Log_parabola.K      (2.54 -0.06 +0.07) x 10^-22   
crab.spectrum.main.Log_parabola.alpha             -2.646 +/- 0.019   
crab.spectrum.main.Log_parabola.beta       (1.04 +/- 0.15) x 10^-1   
                                                  unit  
parameter                                               
crab.spectrum.main.Log_parabola.K      1 / (cm2 keV s)  
crab.spectrum.main.Log_parabola.alpha                   
crab.spectrum.main.Log_parabola.beta                    
Correlation matrix:
 col0  col1  col2
----- ----- -----
 1.00 -0.11  0.83
-0.11  1.00 -0.43
 0.83 -0.43  1.00

Oh I actually solved this issue in the pull request #35

hayalaso commented 4 years ago

Oh ok, I'll check it then.

henrikef commented 4 years ago

Is this still needed @hayalaso ?

hayalaso commented 4 years ago

Mmm, probably not? I actually thought this was fixed already.

El vie., 30 de oct. de 2020 a la(s) 16:48, Henrike F ( notifications@github.com) escribió:

Is this still needed @hayalaso https://github.com/hayalaso ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/threeML/hawc_hal/pull/36#issuecomment-719791745, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCUZ627YXMBPIZODHRK2DLSNMRATANCNFSM4OIRGNDA .

-- Saludos, Hugo

henrikef commented 4 years ago

Ok, should I go ahead and close this pull request then?

hayalaso commented 4 years ago

Sure

El vie., 30 de oct. de 2020 a la(s) 16:57, Henrike F ( notifications@github.com) escribió:

Ok, should I go ahead and close this pull request then?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/threeML/hawc_hal/pull/36#issuecomment-719795868, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCUZ654TB622H5BXRXDIF3SNMSFNANCNFSM4OIRGNDA .

-- Saludos, Hugo