Quasars / orange-spectroscopy

Other
51 stars 58 forks source link

Impossible to open ENVI spectral library #696

Closed AntanisMJR closed 10 months ago

AntanisMJR commented 10 months ago

Hi, I'm trying to use Spectral to open an ENVI spectral library.

As a consequence of some prior processing, I have two formats for the header file:

Screenshot 2023-10-27 160115

Other header for same file Screenshot 2023-10-27 160248

The code that I am using:

`import matplotlib matplotlib.use('WX') import spectral as sp1 import pandas as pd

SpecLib = sp1.envi.open("C:/mypath/file_name.hdr") SpecLib = pd.DataFrame(index=SpecLib.names, data=SpecLib.spectra, columns=SpecLib.bands.centers)

print(index) print(data) print(columns)`

The errors I get: Traceback (most recent call last): File "C:\Users\Utente\anaconda3\envs\library_converter\lib\site-packages\IPython\core\interactiveshell.py", line 3526, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in runfile('C:\\Correlograms\Envi_bsq_numpy_to_csv.py', wdir='C:\*\SPECTRAL_Process\Correlograms') File "C:\Program Files\JetBrains\PyCharm 2023.2.3\plugins\python\helpers\pydev_pydev_bundle\pydev_umd.py", line 197, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "C:\Program Files\JetBrains\PyCharm 2023.2.3\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:\Users\\Envi_bsq_numpy_to_csv.py", line 7, in SpecLib = pd.DataFrame(index=SpecLib.names, data=SpecLib.spectra, columns=SpecLib.bands.centers) AttributeError: 'BsqFile' object has no attribute 'names'

Thanks a lot for the help!

markotoplak commented 10 months ago

Hi, I think you mistakenly posted this issue in the wrong repository. This is not the repository of spectral, even though that we use it as a dependency.

AntanisMJR commented 10 months ago

Super sorry!