BrownDwarf / gollum

A microservice for programmatic access to precomputed synthetic spectral model grids in astronomy
https://gollum-astro.readthedocs.io/
MIT License
20 stars 5 forks source link

Quickstart tutoirial - without jupyter notebook #106

Closed DanielAndreasen closed 3 months ago

DanielAndreasen commented 4 months ago

Hi again,

I've tried running the quickstart tutorial (https://gollum-astro.readthedocs.io/en/latest/quickstart.html) from ipython (not notebook), and I don't get a plot after running the commands:

ax = normalized_spectrum.plot()
ax.set_ylim(0, 2)

It might be my setup, but are you able to do so? Do I need to change something compared to the jupyter notebook code?

I am able to produce the plots without problems in the notebook though.

Review link: https://github.com/openjournals/joss-reviews/issues/6601

DanielAndreasen commented 4 months ago

I solved it myself. I had to install an extra dependency: pip install PyQt5, and then run the code like:

import matplotlib.pyplot as plt

from gollum.phoenix import PHOENIXSpectrum

spec = PHOENIXSpectrum(teff=5000, logg=4)
normalized_spectrum = spec.normalize()
ax = spec.normalize().plot()
ax.set_ylim(0)
plt.show()

This might just be my system, but maybe this issue can help others.

Sujay-Shankar commented 4 months ago

I agree with you, our documentation seems to be missing the actual show method for the chart. I think this relies on notebooks' behavior of rendering certain objects when expressed as a literal, but IPython not necessarily doing the same. I'll make this fix and close when complete.

Sujay-Shankar commented 4 months ago

Okay, I believe I've updated our quickstart tutorial. Regarding pyqt5, I'm trying to reproduce the error, but the code is running fine, both in notebook and in raw IPython, without a need for pyqt5 to be explicitly installed. Did you use one of the two recommended environment creation methods in the updated documentation?

DanielAndreasen commented 4 months ago

I'm no longer a fan of conda, so I installed it using pip in a virtual environment using the requirements.txt file. Technically I used uv which seems to become the standard, but that is just pip on steroids. It's fine if you close this issue, but it can be used for others if they have similar problems.

Sujay-Shankar commented 4 months ago

I see, I myself don't technically use conda either, but mamba, which is to conda as uv is to pip, I assume. Unfortunately, pyqt5 is the pip package name while pyqt is the conda package name, meaning if I put it in requirements.txt it would throw an error for one of the two platforms. When you got the error, did it itself tell you to install pyqt5? If so, I think we can just leave it be for the time being, users will most likely just follow the error's directions. If it didn't explicitly tell you to install it I can add a note to the docs saying pip/uv users need to also manually install pyqt5 so they don't have to comb through stackoverflow for the fix.

DanielAndreasen commented 3 months ago

I just searched for the error and found a stackoverflow answer, but I'm unable to find it now. It's fine for me to close this issue as is, or if you want, add a small footnote about the solution I found in the docs.