jpierel14 / snsed

3 stars 3 forks source link

Reference to 'B' band not in data #5

Closed Zeklandia closed 5 years ago

Zeklandia commented 5 years ago

Line 395 of colorCalc.py appears to statically call upon the 'B' band, but that band does not always appear in the data.

Traceback (most recent call last):
  File "…/model_fitting_routines.py", line 378, in <module>
    color_tables_all = get_all_color_tables(data_photometry_all_formatted_snsedextend, dict_models_fit_best)
  File "…/model_fitting_routines.py", line 331, in get_all_color_tables
    effect_names=["host", "mw"]))
  File "…/anaconda3/envs/astro3/lib/python3.7/site-packages/snsedextend/colorCalc.py", line 395, in curveToColor
    t0=_getBandMaxTime(bestFit,fitted,bandDict,'B',zpMag.band_flux_to_mag(1,bandDict['B']),zpsys)
KeyError: 'B'
jpierel14 commented 5 years ago

The time of peak is usually defined based on the B band magnitude, which is why it's hard-coded in. I'll make a small change that should fix this though, right now it looks like it depends on you sending the right banddict.

Zeklandia commented 5 years ago

Is there documentation on how to use the bandDict argument?

jpierel14 commented 5 years ago

The documentation just says "sncosmo bandpass for each band used in the fitting/table generation", which is about right. It has the names of bands that are in your light curve as keys, and the corresponding name for that band in sncosmo as values. This is just in case you have strange band names and don't want to change them.

I think in this case it would mean your bandDict would just have the same keys and values, which is sort of dumb. I just made an update to version 3.6, which should fix the original issue you had, plus you should be able to set bandDict=None, which should then assume that your light curve contains sncosmo bands.