Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs on the quickstart page #341

Open
steveschulze opened this issue Sep 8, 2024 · 2 comments
Open

Bugs on the quickstart page #341

steveschulze opened this issue Sep 8, 2024 · 2 comments

Comments

@steveschulze
Copy link

Hi,

While upgrading from Prospector 1.1 to 1.4, I realised some syntax has changed. To get an idea of how to update my script, I followed the demo on https://prospect.readthedocs.io/en/latest/quickstart.html. When I copy the different code blocks into a Jupyter Notebook, I encounter various errors, e.g.,

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[45], line 11
      7 magerr = np.hypot(magerr, 0.05)
      9 pdat = Photometry(filters=filters, flux=maggies, uncertainty=magerr*maggies[/1.086](http://localhost:8889/1.086),
     10                   name=f'sdss_phot_specobjID{cat[0]["specObjID"]}')
---> 11 sdat = Spectrum(wavelength=None, flux=None, uncertainty=None)
     12 observations = [pdat]
     13 for obs in observations:

File [~/prospector/prospector-1.4/prospect/observation/observation.py:334](http://localhost:8889/lab/tree/~/prospector/prospector-1.4/prospect/observation/observation.py#line=333), 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 [~/prospector/prospector-1.4/prospect/observation/observation.py:345](http://localhost:8889/lab/tree/~/prospector/prospector-1.4/prospect/observation/observation.py#line=344), 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 [~/prospector/prospector-1.4/prospect/observation/observation.py:354](http://localhost:8889/lab/tree/~/prospector/prospector-1.4/prospect/observation/observation.py#line=353), 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

Or the sampler is not defined.

Could you check all instructions on this page? (The demo Jupyter Notebook in the repo is also out of date.)

Cheers,

Steve

@bd-j
Copy link
Owner

bd-j commented Sep 9, 2024

Hi @steveschulze, I think there's been a mixup. I'm currently developing v2.0 (e.g. https://github.com/bd-j/prospector?tab=readme-ov-file#version-20-in-progress and https://github.com/bd-j/prospector?tab=readme-ov-file#migration-from--v20), but it has not been released, so installing the development version according to the documentation will get you something very different than v1.4 (e.g. the observation module does not exist in the released v1.4). If you really want v1.4 try python -m pip uninstall astro-prospector; python -m pip install astro-prospector or python -m pip install astro-prospector==1.4 to be extra sure. If you still encounter problems please let me know.

The prospector readthedocs page should default to the "stable" version, i.e. v1.4, but if it does not please let me know. I believe the jupyter notebook is still valid for that version.

All that said, the bug you noted in the v2.x quickstart should get fixed, thanks for noting it - I think there may be some more in the plotting section. If you want to continue with the v2.0development version, you can omit the spectroscopic data set from the list of observations (and omit spec from the tuple of predicted quantities in the outputs later in the quickstart).

Apologies for the confusing state of the code right now.

@bd-j
Copy link
Owner

bd-j commented Sep 9, 2024

If you have a clone of the repo, you can install v1.4 as follows:

git checkout main
git fetch
git checkout v1.4.0
python -m pip install .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants