-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Note: This might be the same problem pointed out by @cylammarco here: #1 (comment), but unfortunately that issue is closed, and the issue is still present 4 years later.
The following minimal example:
old_flux = np.zeros(100)
old_wlen = np.linspace(1, 2, 101)
new_wlen = np.linspace(1, 2, 51)
new_flux = spectres(
new_wavs=new_wlen,
spec_wavs=old_wlen,
spec_fluxes=old_flux,
)gives me a warning:
Spectres: new_wavs contains values outside the range in spec_wavs, new_fluxes and new_errs will be filled with the value set in the 'fill' keyword argument.
This seems very counterintuitive because in this case, the new wavelengths are obviously just a subset of the old wavelengths.
It goes on, however. This minimal example also gives me the above warning:
old_flux = np.zeros(100)
old_wlen = np.linspace(1, 2, 100)
new_wlen = np.linspace(1.01, 1.99, 33)
new_flux = spectres(
new_wavs=new_wlen,
spec_wavs=old_wlen,
spec_fluxes=old_flux,
)If I set new_wlen = np.linspace(1.01, 1.99, 34), though, the warning disappears.
On a bit of a sidenote, I have also (accidentally) noticed that the spectres() method does not necessarily seem to expect spec_wavs and spec_fluxes to have the same length. For example, the following code runs without complaints:
old_flux = np.zeros(100)
old_wlen = np.linspace(1, 2, 165)
new_wlen = np.linspace(1.4, 1.6, 20)
new_flux = spectres(
new_wavs=new_wlen,
spec_wavs=old_wlen,
spec_fluxes=old_flux,
)How should one interpret this — 165 wavelengths, but only 100 flux values? Especially considering that increasing the number of wavelengths from 165 to 166 actually breaks the code with a ValueError: operands could not be broadcast together with shapes (3,) (2,).
Thank you in advance already — any help on this is very much appreciated! 🙂