samuelyeewl / specmatch-emp

Empirical SpecMatch
9 stars 8 forks source link

Installation problem/ code not working #43

Closed mdredyanahmed closed 5 months ago

mdredyanahmed commented 5 months ago

I have tried to install with guideline mentioned in the website but am unable to use specmatch-emp. I am having problem when I tried to run these commands:

(GW) mdredyanahmed@Redyans-MacBook-Pro specmatch-emp % smemp specmatch -o ./ -p -s spectrum TIC0461591646S-ab20221009.fits /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:102: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:108: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:111: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:117: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:102: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:108: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:111: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:117: SyntaxWarning: "is" with a literal. Did you mean "=="? Traceback (most recent call last): File "/Users/mdredyanahmed/mambaforge/envs/GW/bin/smemp", line 33, in sys.exit(load_entry_point('SpecMatch-Emp==0.3', 'console_scripts', 'smemp')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/cli.py", line 147, in main File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/cli.py", line 29, in specmatch_spectrum File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/core.py", line 45, in specmatch_spectrum File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/spectrum.py", line 581, in read_hires_fits File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/astropy/io/fits/hdu/hdulist.py", line 385, in getitem raise e File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/astropy/io/fits/hdu/hdulist.py", line 379, in getitem return self._try_while_unread_hdus( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/astropy/io/fits/hdu/hdulist.py", line 1246, in _try_while_unread_hdus return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ IndexError: list index out of range

(GW) mdredyanahmed@Redyans-MacBook-Pro specmatch-emp % smemp shift -o ./ -f -p -s spectrum TIC0461591646S-ab20221009.fits /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:102: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:108: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:111: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:117: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:102: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:108: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:111: SyntaxWarning: "is" with a literal. Did you mean "=="? /Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/plots.py:117: SyntaxWarning: "is" with a literal. Did you mean "=="? Traceback (most recent call last): File "/Users/mdredyanahmed/mambaforge/envs/GW/bin/smemp", line 33, in sys.exit(load_entry_point('SpecMatch-Emp==0.3', 'console_scripts', 'smemp')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/cli.py", line 147, in main File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/cli.py", line 47, in shift_spectrum File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/core.py", line 482, in shift_spectrum File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/SpecMatch_Emp-0.3-py3.11.egg/specmatchemp/spectrum.py", line 581, in read_hires_fits File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/astropy/io/fits/hdu/hdulist.py", line 385, in getitem raise e File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/astropy/io/fits/hdu/hdulist.py", line 379, in getitem return self._try_while_unread_hdus( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/astropy/io/fits/hdu/hdulist.py", line 1246, in _try_while_unread_hdus return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ IndexError: list index out of range

from pylab import * import specmatchemp.library import specmatchemp.plots as smplot lib = specmatchemp.library.read_hdf(wavlim=[5140,5200]) Reading library from /Users/mdredyanahmed/.specmatchemp/library.h5 Traceback (most recent call last): File "", line 1, in File "/Users/mdredyanahmed/specmatch-emp/specmatchemp/library.py", line 778, in read_hdf return read_hdf(LIBPATH, wavlim, lib_index_subset) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mdredyanahmed/specmatch-emp/specmatchemp/library.py", line 800, in read_hdf for (col_name, dt) in library_params.dtypes.iteritems(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/mdredyanahmed/mambaforge/envs/GW/lib/python3.11/site-packages/pandas-2.2.2-py3.11-macosx-11.1-arm64.egg/pandas/core/generic.py", line 6299, in getattr return object.getattribute(self, name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Series' object has no attribute 'iteritems'

Screenshot 2024-05-27 at 4 16 54 AM

I have also attached the errrors as a screenshot. Can anyone help me to make specmatch-emp work?

Screenshot 2024-05-27 at 4 08 51 AM Screenshot 2024-05-27 at 4 06 39 AM
samuelyeewl commented 5 months ago

Hi,

It seems like you were able to successfully install the code and were able to run it.

I just updated the master branch to fix the SyntaxWarning code (which arose starting with Python 3.8), as well as the iteritems() compatibility issue (which arose starting with pandas 1.5). This addresses the issue in your second example.

In your other two examples, you're running SpecMatch-Emp from the command line. Unfortunately, that command-line interface only works out of the box with HIRES spectra.

Thanks for bringing my attention to those two compatibility issues. In the future, it would be really helpful if you could include the versions of the packages you're using (e.g. the output of conda list). Also, including the errors not as a screenshot or plaintext but as a markdown code block (enclosing it in triple backticks: ``` output ```) would help make it more readable.

Sam

mdredyanahmed commented 5 months ago

Thanks for the suggestions. Should I remove all of the previous installations directories and git clone again and reinstall it? Could you please tell me how can I run the command line code with spectrums to get the parameters as you mentioned it may not work without boxes?

Could you give me some examples?

samuelyeewl commented 5 months ago

You can simply run a git pull in the specmatch-emp folder and run the setup.py script again. The quickstart documentation page provides an example of running the code not through the command-line interface but through the python interface. You'll need to implement your own code to read your spectrum though.