bd-j / prospector

Python code for Stellar Population Inference from Spectra and SEDs
http://prospect.readthedocs.io
MIT License
158 stars 74 forks source link

development version error when creating empty Spectrum object #352

Open kevinhainline opened 1 week ago

kevinhainline commented 1 week ago

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.

bd-j commented 1 week ago

I think this is related to #341 and tests needs to be added/improved for a likelihood calculation, prediction, and .rectify() in the case of no data.