EnSpec / SpecDAL

Website landing page for SpecDAL project. https://specdal.github.io now redirects here.
MIT License
28 stars 17 forks source link

Problem loading .sig file #13

Open sparkvilla opened 4 years ago

sparkvilla commented 4 years ago

Hi there. I am following your tutorial on the jupyter notebook to open a .sig file. When trying

from specdal import Collection, Spectrum, read
from matplotlib import pyplot as plt

spectrum = Spectrum(filepath="/home/diego/work/dev/svc/diegoSphereRef18062020.060115.0004.sig")

I am getting this traceback:

UnboundLocalError                         Traceback (most recent call last)
<ipython-input-6-0d240d28a1dd> in <module>
----> 1 spectrum = Spectrum(filepath="/home/diego/work/dev/svc/diegoSphereRef18062020.060115.0004.sig")

~/venv_py3/lib/python3.6/site-packages/specdal/spectrum.py in __init__(self, name, filepath, measurement, measure_type, metadata, interpolated, stitched, jump_corrected, vector_normalized, derivative_order, verbose)
     53         self.derivative_order = derivative_order
     54         if filepath:
---> 55             self.read(filepath, measure_type, verbose=verbose)
     56     def __str__(self):
     57         string = "\nname:\t\t{!s},\n".format(self.name)

~/venv_py3/lib/python3.6/site-packages/specdal/spectrum.py in read(self, filepath, measure_type, verbose)
     77         Read measurement from a file.
     78         '''
---> 79         data, meta = read(filepath, verbose=verbose)
     80         self.metadata = meta
     81         if measure_type == 'pct_reflect' and 'pct_reflect' not in data:

~/venv_py3/lib/python3.6/site-packages/specdal/reader.py in read(filepath, read_data, read_metadata, verbose)
     16     reader = SUPPORTED_READERS[ext]
     17     return reader(abspath(expanduser(filepath)), read_data,
---> 18                   read_metadata, verbose)
     19 
     20 def read_sed(filepath, read_data=True, read_metadata=True, verbose=False):

~/venv_py3/lib/python3.6/site-packages/specdal/reader.py in read_sig(filepath, read_data, read_metadata, verbose)
     98         data = pd.read_table(filepath, skiprows=i+1,
     99                              sep="\s+", index_col=0,
--> 100                              header=None, names=colnames
    101         )
    102         if "pct_reflect" in data:

UnboundLocalError: local variable 'colnames' referenced before assignment

Any idea what can be wrong? Thank you for working on this tool!

sergiobellido commented 2 years ago

Hi @sparkvilla,

It is possible for you to send the file, so I can test it?