Giter VIP home page Giter VIP logo

Comments (11)

ap-- avatar ap-- commented on August 25, 2024

Need more info:

  • which spectrometer model?
  • which backend are you using?

from python-seabreeze.

yakir12 avatar yakir12 commented on August 25, 2024

Sorry, of course:

  • USB2000
  • Since I got some errors when trying to install the cseabreeze backend, I think I'm using the pyseabreeze...

When running it (say from Python) I use:

>>> import seabreeze
>>> seabreeze.use('pyseabreeze')
>>> import seabreeze.spectrometers as sb

from python-seabreeze.

ap-- avatar ap-- commented on August 25, 2024

Okay.
In python-oceanoptics, the only keyword parameter that does anything is: only_valid_pixels

So if you want to compare the two, please do (I assume, that spec is an instance of the class for your spectrometer):

  • python-oceanoptics

    spec.intensities(only_valid_pixels=False) / 4095.
  • python-seabreeze

    spec.intensities(correct_dark_counts=False, correct_nonlinearity=False)

Let me know how it goes.

from python-seabreeze.

yakir12 avatar yakir12 commented on August 25, 2024

I'll report back (Australia) tomorrow, the spec is at work :|

from python-seabreeze.

yakir12 avatar yakir12 commented on August 25, 2024

It seems like I'm getting values larger than one with python-seabreeze.

  • python-oceanoptics:
>>> import oceanoptics
>>> spec = oceanoptics.get_a_random_spectrometer()
>>> y = spec.intensities(only_valid_pixels=False) / 4095
>>> y
array([ 0.        ,  0.04151404,  0.04126984, ...,  0.04249084,
        0.04249084,  0.04224664])
>>> sum(y > 1)
0
  • pyseabreeze backend in python-seabreeze:
>>> import seabreeze
>>> seabreeze.use('pyseabreeze')
>>> import seabreeze.spectrometers as sb
>>> devices = sb.list_devices()
>>> spec = sb.Spectrometer(devices[0])
>>> y = spec.intensities(correct_dark_counts=False, correct_nonlinearity=False)
>>> y
array([ 3072.,  3240.,  3493., ...,     0.,     0.,     0.])
>>> sum(y > 1)
1024

from python-seabreeze.

ap-- avatar ap-- commented on August 25, 2024

Hey, it seems i am wrong about pyseabreeze returning normalized spectra. (It's been a while since I worked on this and I have to double check why i made that decision).

And these two lines are wrong: https://github.com/ap--/python-seabreeze/blob/master/seabreeze/pyseabreeze/interfaces/spectrometer.py#L133L134 which is why your spectra don't make sense.

I'll push a patch soon.

from python-seabreeze.

yakir12 avatar yakir12 commented on August 25, 2024

Hmm... I'm getting this error now:

>>> import seabreeze
>>> seabreeze.use('pyseabreeze')
>>> import seabreeze.spectrometers as sb
>>> devices = sb.list_devices()
>>> spec = sb.Spectrometer(devices[0])
>>> y = spec.intensities(correct_dark_counts=False, correct_nonlinearity=False)
Traceback (most recent call last):
  File "seabreeze/pyseabreeze/interfaces/common.py", line 14, in decorated_func
    return func(*args, **kwargs)
  File "seabreeze/pyseabreeze/interfaces/spectrometer.py", line 134, in get_formatted_spectrum
    tsorted = tmp[idx] & np.array((0xFF, 0x0F)*(N/2))  # high nibble not guaranteed to be pulled low
IndexError: index 4097 is out of bounds for size 4097
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "seabreeze/spectrometers.py", line 148, in intensities
    out[transfered_N:])
  File "seabreeze/pyseabreeze/wrapper.py", line 123, in spectrometer_get_formatted_spectrum
    return device.interface.get_formatted_spectrum(out)
  File "seabreeze/pyseabreeze/interfaces/common.py", line 23, in decorated_func
    raise SeaBreezeError(msg)
seabreeze.pyseabreeze.interfaces.common.SeaBreezeError: Error while reading raw spectrum

or this:

>>> y = spec.intensities()
Traceback (most recent call last):
  File "seabreeze/pyseabreeze/interfaces/common.py", line 14, in decorated_func
    return func(*args, **kwargs)
  File "seabreeze/pyseabreeze/interfaces/spectrometer.py", line 134, in get_formatted_spectrum
    tsorted = tmp[idx] & np.array((0xFF, 0x0F)*(N/2))  # high nibble not guaranteed to be pulled low
IndexError: index 4097 is out of bounds for size 4097
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "seabreeze/spectrometers.py", line 148, in intensities
    out[transfered_N:])
  File "seabreeze/pyseabreeze/wrapper.py", line 123, in spectrometer_get_formatted_spectrum
    return device.interface.get_formatted_spectrum(out)
  File "seabreeze/pyseabreeze/interfaces/common.py", line 23, in decorated_func
    raise SeaBreezeError(msg)
seabreeze.pyseabreeze.interfaces.common.SeaBreezeError: Error while reading raw spectrum

from python-seabreeze.

ap-- avatar ap-- commented on August 25, 2024

Let me know if it's fixed now.

from python-seabreeze.

yakir12 avatar yakir12 commented on August 25, 2024

I pulled, and went through the installation for the pyseabreeze backend and got this error:

sudo ./misc/install_udev_rules.sh
# SEABREEZE: copying 10-oceanoptics.rules to /etc/udev/rules.d/
cp: cannot stat ‘10-oceanoptics.rules’: No such file or directory
# SEABREEZE: reloading udev rules

went on with the rest of it, and got similar errors when trying to fetch the intensities:

Traceback (most recent call last):
  File "seabreeze/pyseabreeze/interfaces/common.py", line 14, in decorated_func
    return func(*args, **kwargs)
  File "seabreeze/pyseabreeze/interfaces/spectrometer.py", line 135, in get_formatted_spectrum
    ret = numpy.array(struct.unpack("<" + "H"*self._PIXELS, tsorted), dtype=numpy.double)
error: unpack requires a string argument of length 4096
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "seabreeze/spectrometers.py", line 148, in intensities
    out[transfered_N:])
  File "seabreeze/pyseabreeze/wrapper.py", line 123, in spectrometer_get_formatted_spectrum
    return device.interface.get_formatted_spectrum(out)
  File "seabreeze/pyseabreeze/interfaces/common.py", line 23, in decorated_func
    raise SeaBreezeError(msg)
seabreeze.pyseabreeze.interfaces.common.SeaBreezeError: Error while reading raw spectrum

Maybe I'm doing something wrong somewhere else? Want me to run some other tests to make sure the problem isn't somewhere else? Let me know.

from python-seabreeze.

ap-- avatar ap-- commented on August 25, 2024

I missed a cast to int64. fixed now.

Maybe I'm doing something wrong somewhere else? Want me to run some other tests to make sure the problem isn't somewhere else? Let me know.

I hope it works now.

from python-seabreeze.

yakir12 avatar yakir12 commented on August 25, 2024

Yap, that looks good. I think you can close this issue (I'll continue my rant at #17). Thanks!

from python-seabreeze.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.