mfouesneau / ezmist

Interface to MIST/MESA Isochrones
MIT License
5 stars 5 forks source link

Photometry download examples #1

Closed adrn closed 6 years ago

adrn commented 6 years ago

Request: could you add some example of how to download photometry to the README?

I tried this:

iso = get_one_isochrone(1e8, -1., output_option='photometry', output='GALEX')

but get:

ERROR: ValueError: could not convert string to float: 'Yinit' [ezmist.ezmist]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-31-7f8bdf8ec97e> in <module>()
----> 1 test = get_one_isochrone(1e8, -1., output_option='photometry', output='GALEX')

~/anaconda/lib/python3.6/site-packages/ezmist/ezmist.py in get_one_isochrone(age, FeH, age_scale, ret_table, **kwargs)
    340     r = _query_website(d)
    341     if ret_table is True:
--> 342         return _read_mist_iso_filecontent(r)
    343     else:
    344         return r

~/anaconda/lib/python3.6/site-packages/ezmist/ezmist.py in _read_mist_iso_filecontent(data)
    208     content = [line.split() for line in f]
    209     hdr = {'MIST': content[0][-1], 'MESA': content[1][-1]}
--> 210     abun = {content[3][i]:float(content[4][i]) for i in range(1,5)}
    211     hdr.update(**abun)
    212     hdr['ROT'] = float(content[4][-1])

~/anaconda/lib/python3.6/site-packages/ezmist/ezmist.py in <dictcomp>(.0)
    208     content = [line.split() for line in f]
    209     hdr = {'MIST': content[0][-1], 'MESA': content[1][-1]}
--> 210     abun = {content[3][i]:float(content[4][i]) for i in range(1,5)}
    211     hdr.update(**abun)
    212     hdr['ROT'] = float(content[4][-1])

ValueError: could not convert string to float: 'Yinit'
adrn commented 6 years ago

Ah, it's because of a difference in the number of lines returned if you use 'photometric' instead of 'theory'. Quick hack to fix:

added to L210 in ezmist.py

if content[2][1] == 'photometric':
    del content[2]
    del content[7]
mfouesneau commented 6 years ago

Check new version -- reopen is needed