nhmc / Barak

A set of astronomy-related routines for generating Voigt profiles from atomic data, reading and writing data, working with SEDs and passbands.
Other
19 stars 7 forks source link

Calzetti extinction curve does not work at 2850<lambda<3700 #4

Closed monodera closed 9 years ago

monodera commented 9 years ago

Hi,

I've got an error message when using barak.extinction.starburst_Calzetti00. Apparently, the function does not work properly between 2850<lambda<3700. In the following example, the first and last lines work properly, while the other two lines return error. This happens both 0.3.2 and the current master.

from barak.extinction import starburst_Calzetti00
starburst_Calzetti00(2850)  # work
starburst_Calzetti00(2851)  # does not work
starburst_Calzetti00(3699)  # does not work
starburst_Calzetti00(3700)  # work

The error message I got is the following:

In [53]: starburst_Calzetti00(3669)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-53-660921431fc5> in <module>()
----> 1 starburst_Calzetti00(3669)

/usr/local/lib/python2.7/site-packages/barak/extinction.pyc in starburst_Calzetti00(wa, Rv, EBmV)
    218         if c1.any():
    219             AlamAv[c0] = MW_Cardelli89(wa[c0], 3.1).AlamAv
--> 220             AlamAv[c1] = interp_Akima(wa[c1], wa[~c1], AlamAv[~c1])
    221
    222     if len(wa) == 1:

/usr/local/lib/python2.7/site-packages/barak/interp.pyc in interp_Akima(x_new, x, y)
    344     >>> plt.show()
    345     """
--> 346     interpolator = AkimaSpline(x, y)
    347     return interpolator(x_new)
    348

/usr/local/lib/python2.7/site-packages/barak/interp.pyc in __init__(self, xvals, yvals)
    173         n = len(x)
    174         if n < 3:
--> 175             raise ValueError("Array too small")
    176         if n != len(y):
    177             raise ValueError("Size of x-array must match data shape")

ValueError: Array too small

Maybe it's not only for the Calzetti extinction curve, but I've not tested other extinction curves.

Best, Masato Onodera

nhmc commented 9 years ago

Thanks for finding this! It's fixed by commit 8d1ae19c10dcd8380ff72294003b1fb6c3983451.