mfouesneau / pyphot

suite to deal with passband photometry
https://mfouesneau.github.io/pyphot/
MIT License
57 stars 18 forks source link

extractPhotometry method expects 2d array #39

Closed sundarjhu closed 2 years ago

sundarjhu commented 2 years ago

Even though extractPhotometry is supposed to compute synthetic photometry for a single spectrum (the dostring specifies that spec is a 1d array), the code expects a 2d array.

For example,

import pyphot
vega = pyphot.vega.Vega()
fL = pyphot.UnitHDF_Library().load_all_filters(lamb = vega.wavelength)
pyphot.extractPhotometry(vega.wavelength, vega.flux, fL)

results in the following message:

Photometry:|------------------------------------------------------------------------------------------| 0/271  0% [time: 00:00, eta: ?, ? iters/sec]Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/pyphot/helpers.py", line 62, in extractPhotometry
    s0  = spec[:, xl]
  File "/usr/local/lib/python3.9/site-packages/pyphot/ezunits/pint.py", line 1143, in __getitem__
    value = self._magnitude[key]
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

Line 62 in helpers.py could be changed from s0 = spec[:, xl] to either s0 = spec[xl] or s0 = np.atleast_2d(spec)[:, xl]

@pscicluna

mfouesneau commented 2 years ago

I will close as duplicated with #40. These function need to be deprecated and removed (#41)