fermi-lat / Fermitools-conda

Conda recipe files for the Fermi Sciencetools software analysis package: Fermitools
https://fermi.gsfc.nasa.gov/ssc/data/analysis/
BSD 3-Clause "New" or "Revised" License
34 stars 17 forks source link

IndexError when running gta.setup() #145

Closed TheCriticalSpan closed 1 year ago

TheCriticalSpan commented 1 year ago

Hey everyone! It's my first time opening an issue on github so I hope everything is in order.

I am currently learning how to use Fermipy and Fermitools but I can't seem to get gta.setup() to run all the way through. I've tried updating Fermipy and Fermitools with mamba to make sure I'm on the latest version. I'm frankly at a loss so any help would be greatly appreciated. I am pasting my code, gta.setup() log and error traceback as generated by Jupyter Notebook. I am also pasting my config file (I would attach it but it seems like the the file type isn't supported on this website).

Thanks to anyone who read this through! Edit: Fixed formatting

config.yaml data: evfile : Blazar.lst scfile : L190726155320A894EC7048_SC00.fits ltcube : null

binning: roiwidth : 10.0 binsz : 0.1 binsperdec : 8

selection : emin : 100 emax : 300000 zmax : 90 evclass : 128 evtype : 3 target : '3FGL J0509.4+0541' tmin : 494380804 tmax : 557452805

gtlike: edisp : True irfs : 'P8R2_SOURCE_V6' edisp_disable : ['isodiff','galdiff']

model: src_roiwidth : 15.0 galdiff : '/home/thecriticalspan/mambaforge/envs/fermi/share/fermitools/refdata/fermi/galdiffuse/gll_iem_v07.fits' isodiff : '/home/thecriticalspan/mambaforge/pkgs/fermitools-data-0.18-0/share/fermitools/refdata/fermi/galdiffuse/iso_P8R2_SOURCE_V6_v06.txt' catalogs : '/home/thecriticalspan/mambaforge/envs/fermi/share/fermitools/data/pyBurstAnalysisGUI/gll_psc_v16.xml'

Code: import os import matplotlib import numpy as np from fermipy.gtanalysis import GTAnalysis from fermipy.plotting import ROIPlotter, SEDPlotter import matplotlib.pyplot as plt

gta = GTAnalysis('config.yaml') matplotlib.interactive(True) gta.setup()

gta.setup() log: 2023-06-19 14:36:23 INFO GTAnalysis.__init__(): fermipy version v1.1 ScienceTools version 2.2.0 2023-06-19 14:36:26 INFO GTAnalysis.setup(): Running setup. 2023-06-19 14:36:26 INFO GTBinnedAnalysis.setup(): Running setup for component 00 2023-06-19 14:36:26 INFO GTBinnedAnalysis.run_gtapp(): Running gtselect. 2023-06-19 14:36:26 INFO GTBinnedAnalysis.run_gtapp(): time -p gtselect infile=/home/thecriticalspan/mambaforge/envs/fermi/fermipy-tutorial/evfile_00.txt outfile=/home/thecriticalspan/mambaforge/envs/fermi/fermipy-tutorial/ft1_00.fits ra=77.3639 dec=5.699 rad=7.5710678118654755 tmin=494380804.0 tmax=557452805.0 emin=100.0 emax=300000.0 zmin=0.0 zmax=90.0 evclass=128 evtype=3 convtype=-1 phasemin=0.0 phasemax=1.0 evtable="EVENTS" chatter=3 clobber=yes debug=no gui=no mode="ql" 2023-06-19 14:36:26 INFO GTBinnedAnalysis.run_gtapp(): This is gtselect version HEAD 2023-06-19 14:36:27 INFO GTBinnedAnalysis.run_gtapp(): Applying filter string: ((EVENT_CLASS&o200) != o0) && angsep(RA,DEC,77.3639,5.699) < 7.571067812 && ((EVENT_TYPE&o3) != o0) && 100 < ENERGY && ENERGY <= 300000 && 494380804 < TIME && TIME <= 557452805 && 0 < ZENITH_ANGLE && ZENITH_ANGLE <= 90 && gtifilter() 2023-06-19 14:36:28 INFO GTBinnedAnalysis.run_gtapp(): Done. 2023-06-19 14:36:28 INFO GTBinnedAnalysis.run_gtapp(): Finished gtselect. Execution time: 1.60 s 2023-06-19 14:36:28 INFO GTBinnedAnalysis.run_gtapp(): Running gtltcube. 2023-06-19 14:36:28 INFO GTBinnedAnalysis.run_gtapp(): time -p gtltcube evfile="/home/thecriticalspan/mambaforge/envs/fermi/fermipy-tutorial/ft1_00.fits" evtable="EVENTS" scfile=L190726155320A894EC7048_SC00.fits sctable="SC_DATA" outfile=/home/thecriticalspan/mambaforge/envs/fermi/fermipy-tutorial/ltcube_00.fits dcostheta=0.025 binsz=1.0 phibins=0 tmin=0.0 tmax=0.0 file_version="1" zmin=0.0 zmax=90.0 chatter=2 clobber=yes debug=no gui=no mode="ql" 2023-06-19 14:36:28 INFO GTBinnedAnalysis.run_gtapp(): Caught St13runtime_error at the top level: File not found: L190726155320A894EC7048_SC00.fits 2023-06-19 14:36:28 INFO GTBinnedAnalysis.run_gtapp(): Finished gtltcube. Execution time: 0.12 s

Error traceback: IndexError Traceback (most recent call last) Cell In[1], line 11 9 gta = GTAnalysis('config.yaml') 10 matplotlib.interactive(True) ---> 11 gta.setup()

File ~/mambaforge/envs/fermi/lib/python3.9/site-packages/fermipy/gtanalysis.py:1085, in GTAnalysis.setup(self, init_sources, overwrite, **kwargs) 1083 # Run setup for each component 1084 for i, c in enumerate(self.components): -> 1085 c.setup(overwrite=overwrite) 1087 # Create likelihood 1088 self._create_likelihood()

File ~/mambaforge/envs/fermi/lib/python3.9/site-packages/fermipy/gtanalysis.py:5124, in GTBinnedAnalysis.setup(self, overwrite, kwargs) 5121 self._create_ltcube(overwrite=overwrite, kwargs) 5123 self.logger.debug('Loading LT Cube %s', self.files['ltcube']) -> 5124 self._ltc = LTCube.create(self.files['ltcube']) 5126 # Extract tmin, tmax from LT cube 5127 self._tmin = self._ltc.tstart

File ~/mambaforge/envs/fermi/lib/python3.9/site-packages/fermipy/ltcube.py:192, in LTCube.create(cls, ltfile) 189 elif not isinstance(ltfile, list): 190 files = glob.glob(ltfile) --> 192 ltc = cls.create_from_fits(files[0]) 193 for f in files[1:]: 194 ltc.load_ltfile(f)

IndexError: list index out of range

TheCriticalSpan commented 1 year ago

Nevermind everyone, I just noticed the issue was I forgot to update the SC file name in the config file to the correct one from a previous faulty attempt with different data. It even said the SC file wasn't being found in the gta.setup() log but I guess I'm a little blind because I completely missed it. Sorry about the somewhat useless issue!