aburgasser / splat

SpeX Prism Spectral Analysis Toolkit
MIT License
28 stars 46 forks source link

Unable to getSpectrum, due to missing noise row #176

Open Tianxing-Sky-Zhou opened 1 year ago

Tianxing-Sky-Zhou commented 1 year ago
IndexError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 splat.getSpectrum(name='2MASS J04442713+2512164')[0]

File ~\Desktop\splat\splat\core.py:4322, in getSpectrum(output, limit, verbose, key_name, *args, **kwargs)
   4320     for i,k in enumerate(search[key_name]):
   4321         skwargs = search.iloc[i].to_dict()
-> 4322         result.append(Spectrum(k))
   4323 #         if len(files) == 1:
   4324 #             if kwargs.get('lucky',False) == True:
   4325 #                 print('\nRetrieving 1 lucky file\n')
   (...)
   4348     #     else:
   4349     #         sys.stderr.write('\nNo files match search criteria\n\n')
   4351     return result

File ~\Desktop\splat\splat\core.py:396, in Spectrum.__init__(self, *args, **kwargs)
    388                 sdb = searchLibrary(file=self.filename)
    390 # return prior spectrum - THIS IS NOT WORKING SO COMMENTED OUT
    391 #            if self.filename in list(SPECTRA_READIN.keys()) and self.runfast == True:
    392 #                self = SPECTRA_READIN[self.filename]
    393 #                return
    394 
    395 # read in spectrum, being careful not to overwrite specifically assigned quantities
--> 396             rs = readSpectrum(self.filename,**mkwargs)
    397             if 'wave' in rs.keys():
    398                 for k in list(rs.keys()): 

File ~\Desktop\splat\splat\core.py:5548, in readSpectrum(file, folder, file_type, wave_unit, flux_unit, dimensionless, comment, delimiter, crval1, cdelt1, catch_sn, remove_nans, no_zero_noise, use_instrument_reader, instrument, instrument_param, verbose)
   5546                 wave = d[0,:]
   5547                 flux = d[1,:]
-> 5548             if len(d[:,0]) > 1: noise = d[2,:]
   5549             else: noise = [numpy.nan]*len(wave)
   5551 # ascii - can be done with pandas as local or online and w/ or w/o gzip/bzip2/pkzip
   5552         else:

IndexError: index 2 is out of bounds for axis 0 with size 2

The noise information is missing in d, causing the spectrum to be unable to load. This happens for multiple sources, here are all the names that I found with this error: LRL 405, KPNO 1, KPNO 2, KPNO 12, KPNO 4, KPNO 5, KPNO 6, KPNO 7, MHO 4, KPNO 9, CFHT 3, ITG 2, CFHT 6, CFHT 4, 2MASS J04414825+2534304, 2MASS J04442713+2512164, 2MASS J04574903+3015195.

aburgasser commented 1 year ago

yes, unfortunately some of the spectra passed to us had no noise vectors. I'll see if I can do a bypass, but please be patient

aburgasser commented 3 months ago

hmmm, I am unable to replicate this error; make sure SPLAT is pointing to the write data directory