gammapy / enrico

Enrico helps you with your Fermi data analysis
http://enrico.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
22 stars 26 forks source link

error while doing unbinned likelihood analysis #174

Open ajaykhoj opened 1 year ago

ajaykhoj commented 1 year ago

Hello,

I am doing unbinned likelihood analysis to produce SED, but I am getting error--

*** 12 Results --- Print results of the fit

****

(4FGL J1809.8-2332 Spectrum: PLSuperExpCutoff4 0 Prefactor: 2.711e+00 4.090e-01 1.000e-05 1.000e+03 ( 1.000e-11) 1 IndexS: -2.304e+00 0.000e+00 -5.000e+00 0.000e+00 ( 1.000e+00) fixed 2 Scale: 2.109e+03 0.000e+00 3.000e+01 3.000e+05 ( 1.000e+00) fixed 3 ExpfactorS: 6.265e-01 0.000e+00 0.000e+00 5.000e+00 ( 1.000e+00) fixed 4 Index2: 3.376e-01 0.000e+00 -5.000e-01 2.000e+00 ( 1.000e+00) fixed

4FGL J1824.6-2452 Spectrum: PLSuperExpCutoff4 5 Prefactor: 2.631e-01 4.900e-02 1.000e-05 1.000e+03 ( 1.000e-11) 6 IndexS: -2.403e+00 1.438e-01 -5.000e+00 0.000e+00 ( 1.000e+00) 7 Scale: 1.354e+03 0.000e+00 3.000e+01 3.000e+05 ( 1.000e+00) fixed 8 ExpfactorS: 6.566e-02 1.349e-01 0.000e+00 5.000e+00 ( 1.000e+00) 9 Index2: 6.667e-01 0.000e+00 -5.000e-01 2.000e+00 ( 1.000e+00) fixed

4FGL J1826.2-1450 Spectrum: LogParabola 10 norm: 1.143e+00 1.558e-01 0.000e+00 1.000e+04 ( 1.000e-11) 11 alpha: 2.759e+00 0.000e+00 5.000e-01 3.000e+00 ( 1.000e+00) fixed 12 beta: 1.219e-01 0.000e+00 0.000e+00 1.000e+00 ( 1.000e+00) fixed 13 Eb: 1.939e+03 0.000e+00 3.000e+01 3.000e+05 ( 1.000e+00) fixed

GalDiffModel Spectrum: ConstantValue 14 Value: 9.833e-01 1.231e-02 1.000e-02 1.000e+01 ( 1.000e+00)

IsoDiffModel Spectrum: FileFunction 15 Normalization: 1.586e+00 2.354e-01 1.000e-03 1.000e+03 ( 1.000e+00)

PKS1830-211 Spectrum: LogParabola 16 norm: 3.099e+00 6.957e-02 0.000e+00 1.000e+04 ( 1.000e-10) 17 alpha: 2.516e+00 1.865e-02 5.000e-01 3.000e+00 ( 1.000e+00) 18 beta: 8.273e-02 1.408e-02 0.000e+00 1.000e+00 ( 1.000e+00) 19 Eb: 6.299e+02 0.000e+00 3.000e+01 3.000e+05 ( 1.000e+00) fixed , '\n') [FitMaker]: Results for the Fit Source Name Npred TS Values and (MINOS) errors for PKS1830-211 TS : 9090.781902033137 Minos error encountered for parameter 7 norm : 3.10 +/- 0.07 1e-10 Minos error encountered for parameter 8 alpha : 2.52 +/- 0.02 1e+00 Minos error encountered for parameter 9 beta : 0.08 +/- 0.01 1e+00 Eb : 629.90 1e+00 ('The covariance matrix is :\n', array([[ 4.84054568e-03, -3.15143592e-04, 5.20308437e-04], [-3.15143592e-04, 3.47699524e-04, 7.11694197e-05], [ 5.20308437e-04, 7.11694197e-05, 1.98241961e-04]]))

Source Flux [1.00e+02 MeV, 3.00e+05 MeV] : 4FGL J1809.8-2332 Integral Flux : 7.05e-07 +/- 1.06e-07 ph/cm2/s 4FGL J1824.6-2452 Integral Flux : 9.01e-08 +/- 2.56e-08 ph/cm2/s 4FGL J1826.2-1450 Integral Flux : 1.15e-06 +/- 1.57e-07 ph/cm2/s GalDiffModel Integral Flux : 5.12e-04 +/- 6.41e-06 ph/cm2/s IsoDiffModel Integral Flux : 1.95e-04 +/- 2.89e-05 ph/cm2/s PKS1830-211 Integral Flux : 1.81e-06 +/- 3.86e-08 ph/cm2/s

time -p gtmodel srcmaps=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits srcmdl=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_LogParabola_testofpks_out.xml outfile=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_ModelMap.fits irfs="P8R3_SOURCE_V3" evtype="INDEF" expcube=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_ltCube.fits bexpmap=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_BinnedMap.fits convol=yes resample=yes rfactor=2 outtype="CMAP" psfcorr=yes phased_expmap=none edisp_bins=0 chatter=2 clobber=yes debug=no gui=no mode="ql" Parameter srcmaps: file "/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits" is not accessible in mode r. Caught N5hoops12ApeExceptionE at the top level: Exception while querying for file name parameter srcmaps for component gtmodel; Ape exception code 43 (at /usr/local/miniconda/conda-bld/fermitools_1611158369806/work/hoops/build/Unknown-x86_64-64bit-gcc110-Optimized/src/hoops_ape.cxx: 565) [Message] Warning: An error ocurred, retrying ... time -p gtmodel srcmaps=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits srcmdl=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_LogParabola_testofpks_out.xml outfile=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_ModelMap.fits irfs="P8R3_SOURCE_V3" evtype="INDEF" expcube=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_ltCube.fits bexpmap=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_BinnedMap.fits convol=yes resample=yes rfactor=2 outtype="CMAP" psfcorr=yes phased_expmap=none edisp_bins=0 chatter=2 clobber=yes debug=no gui=no mode="ql" Parameter srcmaps: file "/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits" is not accessible in mode r. Caught N5hoops12ApeExceptionE at the top level: Exception while querying for file name parameter srcmaps for component gtmodel; Ape exception code 43 (at /usr/local/miniconda/conda-bld/fermitools_1611158369806/work/hoops/build/Unknown-x86_64-64bit-gcc110-Optimized/src/hoops_ape.cxx: 565) [Message] Warning: An error ocurred, retrying ... time -p gtmodel srcmaps=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits srcmdl=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_LogParabola_testofpks_out.xml outfile=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_ModelMap.fits irfs="P8R3_SOURCE_V3" evtype="INDEF" expcube=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_ltCube.fits bexpmap=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_BinnedMap.fits convol=yes resample=yes rfactor=2 outtype="CMAP" psfcorr=yes phased_expmap=none edisp_bins=0 chatter=2 clobber=yes debug=no gui=no mode="ql" Parameter srcmaps: file "/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits" is not accessible in mode r. Caught N5hoops12ApeExceptionE at the top level: Exception while querying for file name parameter srcmaps for component gtmodel; Ape exception code 43 (at /usr/local/miniconda/conda-bld/fermitools_1611158369806/work/hoops/build/Unknown-x86_64-64bit-gcc110-Optimized/src/hoops_ape.cxx: 565) [Message] Warning: An error ocurred, retrying ... time -p gtmodel srcmaps=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits srcmdl=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_LogParabola_testofpks_out.xml outfile=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_ModelMap.fits irfs="P8R3_SOURCE_V3" evtype="INDEF" expcube=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_ltCube.fits bexpmap=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_BinnedMap.fits convol=yes resample=yes rfactor=2 outtype="CMAP" psfcorr=yes phased_expmap=none edisp_bins=0 chatter=2 clobber=yes debug=no gui=no mode="ql" Parameter srcmaps: file "/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits" is not accessible in mode r. Caught N5hoops12ApeExceptionE at the top level: Exception while querying for file name parameter srcmaps for component gtmodel; Ape exception code 43 (at /usr/local/miniconda/conda-bld/fermitools_1611158369806/work/hoops/build/Unknown-x86_64-64bit-gcc110-Optimized/src/hoops_ape.cxx: 565) [Message] Warning: An error ocurred, retrying ... time -p gtmodel srcmaps=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits srcmdl=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_LogParabola_testofpks_out.xml outfile=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_ModelMap.fits irfs="P8R3_SOURCE_V3" evtype="INDEF" expcube=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_ltCube.fits bexpmap=/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_BinnedMap.fits convol=yes resample=yes rfactor=2 outtype="CMAP" psfcorr=yes phased_expmap=none edisp_bins=0 chatter=2 clobber=yes debug=no gui=no mode="ql" Parameter srcmaps: file "/Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits" is not accessible in mode r. Caught N5hoops12ApeExceptionE at the top level: Exception while querying for file name parameter srcmaps for component gtmodel; Ape exception code 43 (at /usr/local/miniconda/conda-bld/fermitools_1611158369806/work/hoops/build/Unknown-x86_64-64bit-gcc110-Optimized/src/hoops_ape.cxx: 565) [Message] Warning: An error ocurred, retrying ...

Error [Message]: An error ocurred and could not be recovered. Exiting!

mireianievas commented 1 year ago

Does /Users/ajaysharma/Downloads/PhD_Work/Sources_study/Enrico_analysis/PKS1830-211/PKS1830-211_testofpks_FRONTBACK_LogParabola_srcMap.fits exist?

abhradeep-1996 commented 1 year ago

Hi @ajaykhoj , I think in unbinned likelihood analysis the gtmodel step should not appear, as it does not make srcmap files in earlier steps.

You can find the "RunGTlike.py" file within enrico/enrico/ directory and edit it following way to overcome the problem. In line 268, 269 of "RunGTlike.py", the lines are probably- for AnalysisComponent in ListOfAnalysisObjects: AnalysisComponent.obs.ModelMap(outXml)

Just put these two lines inside an 'if' statement in the following way (be careful about the proper indentations)- if config['analysis']['likelihood'] == 'binned' : for AnalysisComponent in ListOfAnalysisObjects: AnalysisComponent.obs.ModelMap(outXml)

Save the edited file, and try to run enrico_sed and see whether the problem persists or not.

mireianievas commented 1 year ago

would you mind doing a pull request with this @abhradeep-1996 ?

abhradeep-1996 commented 1 year ago

@mireianievas Okay, I will put a pull request. But before that I need to be sure whether this solves @ajaykhoj's issue.

ajaykhoj commented 1 year ago

@abhradeep-1996, still facing same problem, couldn't resolve that issue.