Skip to content

development version error when creating empty Spectrum object  #352

@kevinhainline

Description

@kevinhainline

When using the development version, running this:
% sdat = Spectrum(wavelength=None, flux=None, uncertainty=None)

results in an error:

File ~/miniconda3/envs/prospector/lib/python3.10/site-packages/prospect/observation/observation.py:334, in Spectrum.__init__(self, wavelength, resolution, response, name, lambda_pad, **kwargs)
    332 self.response = response
    333 self.instrument_smoothing_parameters = dict(smoothtype="vel", fftsmooth=True)
--> 334 self.wavelength = np.atleast_1d(wavelength)

File ~/miniconda3/envs/prospector/lib/python3.10/site-packages/prospect/observation/observation.py:345, in Spectrum.wavelength(self, wave)
    343 if self._wavelength is not None:
    344     assert np.all(np.diff(self._wavelength) > 0)
--> 345     self.pad_wavelength_array()

File ~/miniconda3/envs/prospector/lib/python3.10/site-packages/prospect/observation/observation.py:354, in Spectrum.pad_wavelength_array(self)
    351 if self.wavelength is None:
    352     return
--> 354 low_pad = np.arange(self.lambda_pad, 1, (self.wavelength[0]-self.wavelength[1]))
    355 hi_pad = np.arange(1, self.lambda_pad, (self.wavelength[-1]-self.wavelength[-2]))
    356 wave_min = self.wave_min - low_pad

IndexError: index 1 is out of bounds for axis 0 with size 1

This will also effect using from_oldstyle on observations that only have photometry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions