Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dimensionality of input #9

Open
zpace opened this issue Feb 18, 2019 · 2 comments
Open

dimensionality of input #9

zpace opened this issue Feb 18, 2019 · 2 comments

Comments

@zpace
Copy link

zpace commented Feb 18, 2019

It appears that extinction only works with 1-d wavelength inputs.

Example:

import extinction
import numpy as np
a = extinction.fitzpatrick99(
    wave=np.random.uniform(3800., 10000., (1000, 10, 10)), r_v=3.1, a_v=1.)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-d87da702ce4d> in <module>
----> 1 extinction.fitzpatrick99(wave=np.random.uniform(3800., 10000., (1000, 10, 10)), r_v=3.1, a_v=1.)

extinction.pyx in extinction.fitzpatrick99()

extinction.pyx in extinction.Fitzpatrick99.__call__()

ValueError: Buffer has wrong number of dimensions (expected 1, got 3)
@kbarbary
Copy link
Member

True! Quick fix: call wave.ravel() to get a 1-d array, then reshape the output array to match the input.

This limitation is because I used typed memory views. For example, see this function signature, which means the function only takes a 1-d array of doubles. While more complex, one could use the numpy C API to achieve the more flexible behavior you're looking for without much performance loss. Or there might be a better way.

Related issue about flexibility of inputs: #6 .

@zpace
Copy link
Author

zpace commented Feb 19, 2019

Yes, that is a solution I considered. It was better for my workflow to just sample the dust law densely and interpolate it using scipy.interpolate.interp1d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants