aburgasser / splat

SpeX Prism Spectral Analysis Toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: Syntax for function is Spectrum.filterMag(filter,magnitude)

daniellabardalezgagliuffi opened this issue · comments

I've had this issue multiple times when flux calibrating a batch of spectra (not when getting absolute magnitudes for a filter). The problem seems to happen when flux calibrate finds a corrupted spectrum file or no file with that filename. Currently, I can't find 10210_10024.fits on any version of SPLAT. The error message is not informative of the error either.

File "make_spl_singles.py", line 66, in
tmp = [specdf.loc[i,'interpsp'].fluxCalibrate('2MASS J', specdf.loc[i,'MJ']) for i in range(len(specdf))]
File "make_spl_singles.py", line 66, in
tmp = [specdf.loc[i,'interpsp'].fluxCalibrate('2MASS J', specdf.loc[i,'MJ']) for i in range(len(specdf))]
File "/Users/daniella/Python/splat/splat/core.py", line 1827, in fluxCalibrate
raise ValueError('\nSyntax for function is Spectrum.filterMag(filter,magnitude)')

Yes, there is no hook in .fluxCalibrate to test whether the spectrum object has a spectrum in it - this would be a major change since every function would have that. My suggestion is, when reading in your files to your array/pandas table, you check at that point if the spectrum is present. I think this spectrum is an unpublished one (although actually published since in Greco et al.) so wouldn't be in the currently released dataset.

My bad! It seems like the code was choking because the mag provided was NaN (some M5 outside of limits for spt to mag empirical relation) and there was no spectrum. The function works fine, but it would benefit from a more informative error message :) Thank you!