pad_spectrum does not fully obey axis argument
Closed this issue · 0 comments
zpace commented
The FilterResponse
object's pad_spectrum
method appears to not add elements along the correct axis. For example...
import numpy as np, astropy.units as u, speclite.filters as filters
# 1-dim wavelength array
lam0 = np.arange(3800., 5500., 1.) * u.AA
# compatible datacube shape
flam0 = np.tile(np.ones_like(lam0.value)[..., None, None], (1, 20, 20)) * \
u.Unit('1e-17 erg/s/cm2/AA')
sdss = filters.load_filters('sdss2010-*')
flam, lam = sdss.pad_spectrum(spectrum=flam0, wavelength=lam0, method='zero', axis=0)
print(flam0.shape, lam0.shape, flam.shape, lam.shape)
which outputs (1700, 20, 237) (1917,)
instead of (1917, 20, 20), (1917,)
my version is 0.5
The workaround seems to be to np.moveaxis
from 0 ==> -1 prior to calling pad_spectrum
, and then reversing that operation after.