[Tutor] spectutils
Peter Otten
__peter__ at web.de
Wed Apr 8 11:51:35 EDT 2020
Rudolf Baer wrote:
> I am working on a macbook pro OS X Yosemite 10.10.5, python 2.7 , jupyter
> notebook. The first code given in the the manual
>
> import numpy as np
> import astropy.units as u
> import matplotlib.pyplot as plt
> from specutils import Spectrum1D
> flux = np.random.randn(200)*u.Jy
> wavelength = np.arange(5100, 5300)*u.AA
> spec1d = Spectrum1D(spectral_axis=wavelength, flux=flux)
> ax = plt.subplots()[1]
> ax.plot(spec1d.spectral_axis, spec1d.flux)
> ax.set_xlabel("Dispersion")
> ax.set_ylabel("Flux”)
>
> ends in
>
> TypeError Traceback (most recent call
> last) <ipython-input-1-2e15c1951be1> in <module>()
> 5 flux = np.random.randn(200)*u.Jy
> 6 wavelength = np.arange(5100, 5300)*u.AA
> ----> 7 spec1d = Spectrum1D(spectral_axis=wavelength, flux=flux)
> 8 ax = plt.subplots()[1]
> 9 ax.plot(spec1d.spectral_axis, spec1d.flux)
>
> TypeError: __init__() takes at least 3 arguments (2 given)
Judging by the code in
https://github.com/astropy/specutils/blame/master/specutils/spectra/spectrum1d.py#L51
the code you gave above will not fail with the current
Spectrum1D.__init__(). So you seem to be using the current documentation in
combination with an outdated implementation.
> How can this be fixed?
I suggest that you switch to Python 3 and a specutils version that is a bit
more up-to-date (specutils 1.0 requires Python 3.5):
https://pypi.org/project/specutils/
https://specutils.readthedocs.io/en/stable/installation.html
More information about the Tutor
mailing list