Giter VIP home page Giter VIP logo

python-seabreeze's Introduction

Python module for Ocean Optics spectrometers

Conda (channel only) PyPI test build deploy Github All Releases PyPI - Downloads MIT license GitHub issues DOI Github Sponsors

Python-seabreeze is the easy way to access your Ocean Optics spectrometers from python. It wraps the SeaBreeze library provided by Ocean Optics to communicate with the spectrometer. It also provides a pyUSB based reimplementation of SeaBreeze for easy extension. This software is not associated with Ocean Optics. Use it at your own risk.

DOCUMENTATION ON RTD

You'll find the documentation and more detailed information here https://python-seabreeze.readthedocs.io/en/latest/

Changes

The changelog can be found here CHANGELOG.md

Install

# via pypi
pip install seabreeze
seabreeze_os_setup

or

# via conda
conda install -c conda-forge seabreeze
seabreeze_os_setup

Using the backend pyseabreeze in Windows

The backend pyseabreeze requires the libraries pyusb and libusb

# via pypi
pip install seabreeze[pyseabreeze]  # this ensures installation of pyusb

Additionally, you might need to manually install libusb1. Go here https://libusb.info/, Downloads -> Latest Windows Binaries. In the zip file, enter either the folder MinGW64/dll or MinGW32/dll (depending on your OS). Copy the file libusb-1.0.dll into C:\Windows\System32.

Usage

The following example shows how simple it is to acquire a spectrum with python-seabreeze through the model independent Spectrometer class. For a more detailed description read the documentation:

>>> from seabreeze.spectrometers import Spectrometer
>>> spec = Spectrometer.from_first_available()
>>> spec.integration_time_micros(20000)
>>> spec.wavelengths()
array([  340.32581   ,   340.70321186,   341.08058305, ...,  1024.84940994,
        1025.1300678 ,  1025.4106617 ])
>>> spec.intensities()
array([  1.58187931e+01,   2.66704852e+04,   6.80208103e+02, ...,
         6.53090172e+02,   6.35011552e+02,   6.71168793e+02])

To use the pyseabreeze backend (requires pyusb) simply run this before importing seabreeze.spectrometers.

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

Supported Devices

Spectrometer cseabreeze pyseabreeze
HR2000 x x
HR2000PLUS x x
HR4000 x x
JAZ x x
MAYA2000 x x
MAYA2000PRO x x
MAYALSL x x
NIRQUEST256 x x
NIRQUEST512 x x
QE65000 x x
QE-PRO x x
STS x x
TORUS x x
USB2000 x x
USB2000PLUS x x
USB4000 x x
USB650 ap--/python-seabreeze#47
SPARK x x
ADC1000 x
SR2 x
SR4 x
SR6 x
HR2 x
HR4 x
ST-VIS x

Known Issues

  • USB2000 spectrometers cause Data transfer error due to old firmware Issue #48
  • USB650 not supported Issue #47
  • No conda packages for armv6 (RPI version 1) Issue #46

Contributing Guidelines

If you run into any problems, file an issue and be sure to include the following in your report:

  • Operating system (Linux distribution, Windows version, OSX version) and archictecture (32bit, 64bit, arm)
  • Python version and arch (i.e. Python 2.7.10 64bit)
  • python-seabreeze version

If you want a feature implemented, please file an issue, or create a pull request when you implement it yourself. And if you would like to support me via paypal, click on the paypal donate button on top of this README.

License

Files in this repository are released under the MIT license.

Related Repositories

If you want me to add your project here, let me know. Happy to add it.

python-seabreeze's People

Contributors

ap-- avatar asenchristov avatar brandoncurtis avatar ericmorelle avatar ffy00 avatar fi156 avatar gabrielbenedikt avatar greyltc avatar knaugh avatar ksunden avatar lavikjo avatar magnium avatar michelecotrufo avatar moritzj29 avatar padalev avatar pre-commit-ci[bot] avatar sdickreuter avatar tyrannican avatar vxgmichel avatar weiqiang-li avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-seabreeze's Issues

How to extract the saturation value?

Moved from ap--/python-oceanoptics#23 asked by @yakir12:

Fantastic. I'm assuming the variable I want is _MAX_PIXEL_VALUE.
I'm a total noob with Python, and I'm doing all of this from Julia with PyCall. Everything works great, but > how do I actually access _MAX_PIXEL_VALUE?

>>> spec._MAX_PIXEL_VALUE()
  Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  AttributeError: 'Spectrometer' object has no attribute '_MAX_PIXEL_VALUE'

Excuse the noobness...

Installation failure

Thank you for all the effort putting this stuff together, but I am running into a problem with installation of python SeaBreeze. I have tried to install with anaconda (and by hand) on a windows 7 64bit computer, python 3.6. I have also tried anaconda install on Linux CentOS 7 64bit, python 2.7.

In all cases I get warnings that the backend driver can not be found, or that a lib could not be found. Anaconda said all requirements have been meet. Do I need to compile/install the Ocean Optics C/C++ SeaBreeze driver separately?

I have tried to follow all instructions on the GitHub project site, but no joy. Any suggestions on other resources I should review?

Thanks for your time.

Clark


python setup.py install not working on linux or os.x

Followed instructions in readme to install on raspberrian (armv7l). Everything seemed to compile, but coudln't successefully import the seabreeze package in python.

I was unable to install any of the precompiled wheel packages on os.x, pip install seabreeze-0.5.1-cp27-none-macosx_10_5_x86_64.whl would report an error like seabreeze-0.5.1-cp27-none-macosx_10_5_x86_64.whl is not a supported wheel on this platform, but I was able to compile from source. Had the same problem though as on rpi.

pi@opentrons1 ~/spec $ git clone https://github.com/ap--/python-seabreeze.git
Cloning into 'python-seabreeze'...
remote: Counting objects: 374, done.
remote: Total 374 (delta 0), reused 0 (delta 0), pack-reused 374
Receiving objects: 100% (374/374), 168.01 KiB | 0 bytes/s, done.
Resolving deltas: 100% (216/216), done.
Checking connectivity... done.
pi@opentrons1 ~/spec $ cd python-seabreeze
pi@opentrons1 ~/spec/python-seabreeze $ ls
appveyor  appveyor.yml  LICENSE.md  misc  README.md  scripts  seabreeze  setup.py  travis
pi@opentrons1 ~/spec/python-seabreeze $ sudo python setup.py install
running install
running bdist_egg
running egg_info
creating seabreeze.egg-info
writing pbr to seabreeze.egg-info/pbr.json
writing seabreeze.egg-info/PKG-INFO
writing top-level names to seabreeze.egg-info/top_level.txt
writing dependency_links to seabreeze.egg-info/dependency_links.txt
writing manifest file 'seabreeze.egg-info/SOURCES.txt'
reading manifest file 'seabreeze.egg-info/SOURCES.txt'
writing manifest file 'seabreeze.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
running build_ext
creating build/bdist.linux-armv7l
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/seabreeze
creating build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/__init__.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/wrapper.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze
creating build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/nonlinearity.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/common.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/__init__.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/communication.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/defines.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/thermoelectric.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/wavelength.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/spectrometer.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces/eeprom.py -> build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces
copying build/lib.linux-armv7l-2.7/seabreeze/spectrometers.pyc -> build/bdist.linux-armv7l/egg/seabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/__init__.py -> build/bdist.linux-armv7l/egg/seabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/backends.py -> build/bdist.linux-armv7l/egg/seabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/__init__.pyc -> build/bdist.linux-armv7l/egg/seabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/backends.pyc -> build/bdist.linux-armv7l/egg/seabreeze
creating build/bdist.linux-armv7l/egg/seabreeze/cseabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/cseabreeze/__init__.py -> build/bdist.linux-armv7l/egg/seabreeze/cseabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/cseabreeze/__init__.pyc -> build/bdist.linux-armv7l/egg/seabreeze/cseabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/cseabreeze/wrapper.so -> build/bdist.linux-armv7l/egg/seabreeze/cseabreeze
copying build/lib.linux-armv7l-2.7/seabreeze/spectrometers.py -> build/bdist.linux-armv7l/egg/seabreeze
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/wrapper.py to wrapper.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/nonlinearity.py to nonlinearity.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/common.py to common.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/communication.py to communication.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/defines.py to defines.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/thermoelectric.py to thermoelectric.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/wavelength.py to wavelength.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/spectrometer.py to spectrometer.pyc
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/eeprom.py to eeprom.pyc
creating stub loader for seabreeze/cseabreeze/wrapper.so
byte-compiling build/bdist.linux-armv7l/egg/seabreeze/cseabreeze/wrapper.py to wrapper.pyc
creating build/bdist.linux-armv7l/egg/EGG-INFO
installing scripts to build/bdist.linux-armv7l/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/bdist.linux-armv7l/egg/EGG-INFO/scripts
copying build/scripts-2.7/seabreeze-compare -> build/bdist.linux-armv7l/egg/EGG-INFO/scripts
changing mode of build/bdist.linux-armv7l/egg/EGG-INFO/scripts/seabreeze-compare to 755
copying seabreeze.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying seabreeze.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying seabreeze.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying seabreeze.egg-info/pbr.json -> build/bdist.linux-armv7l/egg/EGG-INFO
copying seabreeze.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
writing build/bdist.linux-armv7l/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/seabreeze-0.5.1-py2.7-linux-armv7l.egg' and adding 'build/bdist.linux-armv7l/egg' to it
removing 'build/bdist.linux-armv7l/egg' (and everything under it)
Processing seabreeze-0.5.1-py2.7-linux-armv7l.egg
Copying seabreeze-0.5.1-py2.7-linux-armv7l.egg to /usr/local/lib/python2.7/dist-packages
Adding seabreeze 0.5.1 to easy-install.pth file
Installing seabreeze-compare script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/seabreeze-0.5.1-py2.7-linux-armv7l.egg
Processing dependencies for seabreeze==0.5.1
Finished processing dependencies for seabreeze==0.5.1
pi@opentrons1 ~/spec/python-seabreeze $ python
Python 2.7.9 (default, Mar  8 2015, 00:52:26) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.7/dist-packages/seabreeze-0.5.1-py2.7-linux-armv7l.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-arm-linux-gnueabihf', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']
>>> import seabreeze.spectrometers as sb
seabreeze/backends.py:32: UserWarning: Can't load seabreeze c library wrapper, because:
'No module named wrapper'

  warnings.warn("Can't load seabreeze c library wrapper, because:\n'%s'\n" % err.message )
seabreeze/backends.py:17: UserWarning: Falling back to 'pyseabreeze'.
  warnings.warn("Falling back to 'pyseabreeze'.")
seabreeze/backends.py:42: UserWarning: Can't load pyusb wrapper, because:
'No module named usb.core'

  warnings.warn("Can't load pyusb wrapper, because:\n'%s'\n" % err.message )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "seabreeze/spectrometers.py", line 4, in <module>
    lib = seabreeze.backends.get_backend()
  File "seabreeze/backends.py", line 26, in get_backend
    raise ImportError('Could not import any backends. Wanted "%s"' % __SEABREEZE_BACKEND)
ImportError: Could not import any backends. Wanted "cseabreeze"
>>> 

However, I was able to import and use the module manually by adding the build directory to python's sys.path. This indicates the problem is related to how setup.py install packages up the the compiled files and rules out compilation problems from setup.py build.

pi@opentrons1 ~/spec/python-seabreeze $ sudo rm -rf build/
pi@opentrons1 ~/spec/python-seabreeze $ sudo rm -rf dist
pi@opentrons1 ~/spec/python-seabreeze $ sudo python setup.py build
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/seabreeze
copying seabreeze/__init__.py -> build/lib.linux-armv7l-2.7/seabreeze
copying seabreeze/backends.py -> build/lib.linux-armv7l-2.7/seabreeze
copying seabreeze/spectrometers.py -> build/lib.linux-armv7l-2.7/seabreeze
creating build/lib.linux-armv7l-2.7/seabreeze/cseabreeze
copying seabreeze/cseabreeze/__init__.py -> build/lib.linux-armv7l-2.7/seabreeze/cseabreeze
creating build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze
copying seabreeze/pyseabreeze/__init__.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze
copying seabreeze/pyseabreeze/wrapper.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze
creating build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/nonlinearity.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/common.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/__init__.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/communication.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/defines.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/thermoelectric.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/wavelength.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/spectrometer.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
copying seabreeze/pyseabreeze/interfaces/eeprom.py -> build/lib.linux-armv7l-2.7/seabreeze/pyseabreeze/interfaces
running build_ext
building 'seabreeze.cseabreeze.wrapper' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/seabreeze
creating build/temp.linux-armv7l-2.7/seabreeze/cseabreeze
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/lib -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c seabreeze/cseabreeze/wrapper.c -o build/temp.linux-armv7l-2.7/seabreeze/cseabreeze/wrapper.o
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1761:0,
                 from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from seabreeze/cseabreeze/wrapper.c:239:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ufuncobject.h:327:0,
                 from seabreeze/cseabreeze/wrapper.c:240:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/__ufunc_api.h:241:1: warning: โ€˜_import_umathโ€™ defined but not used [-Wunused-function]
 _import_umath(void)
 ^
arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/seabreeze/cseabreeze/wrapper.o -lseabreeze -lusb -o build/lib.linux-armv7l-2.7/seabreeze/cseabreeze/wrapper.so
running build_scripts
creating build/scripts-2.7
copying and adjusting scripts/seabreeze-compare -> build/scripts-2.7
changing mode of build/scripts-2.7/seabreeze-compare from 644 to 755
pi@opentrons1 ~/spec/python-seabreeze $ ls
appveyor  appveyor.yml  build  LICENSE.md  misc  README.md  scripts  seabreeze  setup.py  travis
pi@opentrons1 ~/spec/python-seabreeze $ ls build/
lib.linux-armv7l-2.7  scripts-2.7  temp.linux-armv7l-2.7
pi@opentrons1 ~/spec/python-seabreeze $ python
Python 2.7.9 (default, Mar  8 2015, 00:52:26) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.insert(0,'/home/pi/spec/python-seabreeze/build/lib.linux-armv7l-2.7')
>>> import seabreeze.spectrometers as sb
>>> sb
<module 'seabreeze.spectrometers' from '/home/pi/spec/python-seabreeze/build/lib.linux-armv7l-2.7/seabreeze/spectrometers.py'>
>>> sb.list_devices()[0]
<SeaBreezeDevice USB2000PLUS:USB2K10109>
>>> spec = sb.Spectrometer(sb.list_devices()[0])
>>> spec
<Spectrometer USB2000PLUS:USB2K10109>
>>> 

python module build/install cython error on raspberry pi / raspbian

Not sure what the issue here is ... cython seems unhappy

root@raspberrypi:~/python-seabreeze-python-seabreeze-v0.3.4# python setup.py install
Compiling ./seabreeze/cseabreeze/wrapper.pyx because it changed.
Cythonizing ./seabreeze/cseabreeze/wrapper.pyx

Error compiling Cython file:
------------------------------------------------------------
...
DEF SBMAXDBUFLEN = 256

class SeaBreezeError(Exception):

    def __init__(self, message=None, error_code=None):
        cdef const char *cmessage
                       ^
------------------------------------------------------------

seabreeze/cseabreeze/wrapper.pyx:23:24: Syntax error in C variable declaration
Traceback (most recent call last):
  File "setup.py", line 35, in <module>
    ext_modules=cythonize(extensions),
  File "/usr/lib/pymodules/python2.7/Cython/Build/Dependencies.py", line 517, in cythonize
    cythonize_one(pyx_file, c_file, quiet, options)
  File "/usr/lib/pymodules/python2.7/Cython/Build/Dependencies.py", line 540, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: ./seabreeze/cseabreeze/wrapper.pyx

STS Sensors and multiprocessing

Hey Guys,

I am trying to get a measurement from two STS Devices simultaneously.

This does not work due to an error:

Traceback (most recent call last): File "StsSensorTestMultiprocessing.py", line 43, in decorated a = func(*args, **kwargs) File "build/bdist.linux-armv7l/egg/seabreeze/spectrometers.py", line 149, in intensities out[transfered_N:]) File "build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/wrapper.py", line 123, in spectrometer_get_formatted_spectrum return device.interface.get_formatted_spectrum(out) File "build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/common.py", line 14, in decorated_func return func(*args, **kwargs) File "build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/spectrometer.py", line 316, in get_formatted_spectrum self.get_unformatted_spectrum(tmp) File "build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/common.py", line 14, in decorated_func return func(*args, **kwargs) File "build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/spectrometer.py", line 309, in get_unformatted_spectrum timeout=int(self._INTEGRATION_TIME_MAX * 1e-3 + self.usbtimeout_ms)) File "build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/communication.py", line 211, in query return self.receive_query(timeout) File "build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/communication.py", line 187, in receive_query remaining_bytes, checksumtype = self._check_incoming_message_header(ret[:44]) File "build/bdist.linux-armv7l/egg/seabreeze/pyseabreeze/interfaces/communication.py", line 267, in _check_incoming_message_header raise SeaBreezeError('Header start_bytes wrong: "%d"' % data[0]) SeaBreezeError: Header start_bytes wrong: "1552"

I have uploaded the code to Pastebin:
http://pastebin.com/Txeirz1N

Line 108: The sleep value is above the Integration Intervall for the first run. (Big for loop at Line 90.) >> Everything works fine and of course the second sensor will capture, when the first one finished already.

When the sleep value is below the integration time, the script fails with the afore mentioned error message.

Thanks!

seabreeze 3.0.11

I'm using the new Ocean Optics flameNIR spectrometer and I have seen that this Python module does not support this device yet. However, there is a new version of the official SeaBreeze Embedded Open-Source Device Driver that allows the use of this spectrometer. I have substituted the old .zip file, changing the organization of it, and I have been able to connect and use the flameNIR spectrometer using Python under a Raspberry Pi 2 and 3. It would be nice to update the installation files, so the installation process could be easier for general users.

Thank you for developing this awesome project.

Implementation for the NIR256 2.5

Hello !

spectrometer and system information

  • model: NIR256 2.5
  • operating system: Windows 8.1 64bits
  • python version: 2.7
  • python-seabreeze version: 0.6.0
  • installed-via: anaconda

current problem

I have a python program which uses the data transmitted by a spectrometer. Everything is working well with the HR4000 but I would like to make my program work with the NIR256 2.5 (which is older). It is also a device from Ocean Optics so it should work easily...

steps to reproduce

When I execute the simple code found out here :

import seabreeze
seabreeze.use("pyseabreeze")
#seabreeze.use("cseabreeze")
import seabreeze.spectrometers as sb
devices = sb.list_devices()
print(devices)

With the Hr4000 no problem, it is detected and everything is good but with the nir256 it just print [ ] : so nothing indeed...

So I found out that it didn't work because this spectrometer wasn't defined in the files so I tried to add it myself where I could find the other spectros mentionned, so in C:\ProgramData\Anaconda2\Lib\site-packages\seabreeze\pyseabreeze\interfaces I changed these files :

  • init.py , where I tried to create a class using the datasheet such as :
class NIR256(SpectrometerFeatureNIR256,
             WavelengthCoefficientsEEPromFeature,
             NonlinearityCoefficientsEEPromFeature,
             EEPromFeature,
             NoShutterFeature,
             NoTecFeature,
             NotImplementedWrapper):
    _ENDPOINT_MAP = EndPoints['NIR256']
    _PIXELS = 256  # FIXME
    _RAW_SPECTRUM_LEN = (256 * 2) + 1
    _INTEGRATION_TIME_MIN = 1000
    _INTEGRATION_TIME_MAX = 655350000
    _INTEGRATION_TIME_BASE = 1000
    _MAX_PIXEL_VALUE = 16383

but I am not sure for the values...

  • defines.py , with the productID 0x1010 but I didn't know the list range so I put [ ]. I also chose endpoints : _EML2K and TriggerModes :
'NIR256'	   : { 
       'FREE_RUNNING' : 0,
       'SOFTWARE'     : 1,
        },
  • spectrometer.py , I put
class SpectrometerFeatureNIR256(SpectrometerFeatureOOI2K):
    pass

I also found out about this driver thing and with the same method I created an .inf file in the folder C:\Program Files\Ocean Optics\SeaBreeze\Drivers by copying on the other .inf of the spectrometers.
In the Ocean Optics folder I have seabreeze and OmniDriverr

I tried to use both pyseabreeze and cseabreeze but nothing works ! (in the cseabreeze folder there is not much beside a init.py file) I am a bit confused between OmniDriver, pyseabreeze, cseabreeze, pyusb or usb.core...

I hope I was clear enough and that you will be able to help me...
I an very new to python and seabreeze and this driver/usb-connection is driving me crazy trying to make it work for the nir256...
I don't really know what to do now... The device is detected by my PC because there is the icon in the notification area and it is in the device manager...

If you have any questions do not hesitate, thanks !!

PS : for the values I used this datasheet : https://oceanoptics.com/wp-content/uploads/OEM-Data-Sheet-NIR.pdf

non-linearity corrections lead to infinities

Running

intens = spec.intensities(correct_dark_counts=True)

returns dark corrected counts, but running

intens = spec.intensities(correct_dark_counts=True, correct_nonlinearity=True)

returns infinities, as if the correction involved dividing by zero. Is there a possibility that to get nonlinearity corrections I have to do some particular exposures first? Sorry, looked in the limited documentation and didn't see anything obvious.

Workaround Fedora 24 for non-existing plugdev group

As the plugdev group should not exist in Fedora (see https://bugzilla.redhat.com/show_bug.cgi?id=859244), the udev rules provided in "10-oceanoptics.rules" have to be adjusted to give users without root permission access to the spectrometers:

Replace SUBSYSTEM=="usb_device", in the header with
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664" ,
according to the default 50-udev-default.rules in /lib/udev/rules.d and delete all the GROUP="plugdev".

I attach a modified 10-oceanoptics.rules and install_udev_rules.sh which work with my recent Fedora 24 installation

fedora udev rules.tar.gz

Integer intensity array instead of float

Is there a way to obtain the spectrum as an array of integers instead of floats?

I am not sure that I can obtain it just changing spectrometers.py line 148 from
lib.spectrometer_get_formatted_spectrum
to
lib.spectrometer_get_unformatted_spectrum

High speed acquisition mode

I am using HR2000+ spectrometers and for my setup I will need the high speed acquisition mode as provided by the OmniDriver. Means: preallocating internal buffer, recording spectra until this buffer is filled and then read out the data from the spectrometer. Is this possible?
Thanks.

Unable to reload udev rules on Raspberry Pi 3

spectrometer and system information

  • model: USB2000+
  • operating system: Raspbian 'jessie'
  • python version: 3.6.1
  • python-seabreeze version: current master
  • installed-via: conda (Berryconda)

current problem

Installation of python-seabreeze is fine, but when I try to reset the rules in /etc/udev/rules.d/ by running:

sudo udevadm --reload-rules

it returns

udevadm: unrecognized option '--reload-rules'

After googling I haven't found much to help, I am new to the Raspberry Pi. I have tried

sudo udevadm control --reload-rules

which executes with no error but doesn't allow the spectrometer to be detected.

I have tried several reboots and unplugs/replugs of the spectrometer.

steps to reproduce

Step by step instructions to reproduce the error. The more detailed the better, but please use some common sense:

  1. Download 10-oceanoptics.rules and copy to /etc/udev/rules.d/
  2. Run
sudo udevadm --reload-rules
  1. Returns message:
udevadm: unrecognized option '--reload-rules'

In python, running

import seabreeze.spectrometers as sb
sb.list_devices()

returns

[]

with no spectrometers attached (as expected) and

usb_claim_interface() returned -1 - did you copy os-support/linux/10-oceanoptics.rules to /etc/udev/rules.d?
Could not open device with ID 0. error=-1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "seabreeze/cseabreeze/wrapper.pyx", line 84, in seabreeze.cseabreeze.wrapper.device_list_devices (./seabreeze/cseabreeze/wrapper.c:3750)
  File "seabreeze/cseabreeze/wrapper.pyx", line 133, in seabreeze.cseabreeze.wrapper.device_get_serial_number (./seabreeze/cseabreeze/wrapper.c:4711)
seabreeze.cseabreeze.wrapper.SeaBreezeError: This should not have happened. Apparently this device has 0 serial number features. The code expects it to have 1 and only 1. Please file a bug report including a description of your device.

with the USB2000+ connected.

Any light you can shed would be gratefully received.

Many thanks!

Windows XP (32 bits): cseabreeze does not load and pyseabreeze does not find devices

Hi,

I have followed the instructions of the main page about installing python-seabreeze on Windows ( I am trying to do so in Windows XP (32 bits) ). However, when I run the simple example programs, it systematically says that cseabreeze can not be loaded and that pyseabreeze will be used instead. However, this does not work because the spectrometer is configured using WinUSB and not libusb (if configured with libusb, the proprietary OceanView does not find the spectrometer, which is not convenient; additionally, libusb only gets incomplete information from the spectrometer and python-seabreeze does not work, either!).

This configuration with WinUSB and using cseabreeze works perfect in another PC with Windows 7 (32 bits), so I think there must be an issue with the versions of the libraries or the way seabreeze has been compiled with cython.

I am using:

  • Python 3.4
  • SeaBreezeSetup-x86bit-v3.0.6.msi
  • seabreeze-0.4.3-cp34-none-win32.whl

Any suggestion on where the problem might be will be very welcome.

Best wishes

Issue Recognizing Spark Using Raspberry Pi and Python

Hi. First, thanks for this software. I have a Flame (USB2000+) and Spark spectrometer. They both work properly - confirmed using Ocean Optic's OceanView software for the Mac. I need an embedded application, however, using the Spark. I updated all of the software on the Raspberry Pi 3 (Raspian, Python 2.7.10 and PIP 8.1.2). I installed the Python software on the Raspberry Pi 3, and it works fine with my Flame (USB2000+) spectrometer; but I receive the following error message when I attach the Spark spectrometer to the Raspberry Pi 3 and run the script:
2016-07-25-131925_1824x984_scrot

Using the OceanView software on the Mac, I confirm that the Spark spectrometer is identified and working:
Spark Notification.pdf

Any assistance to resolve this issue would be greatly appreciated.
Thanks!
Brian

Calibration mode

How can I calibrate STS-NIR ??.

  • At "full light source"
  • At "no light"

The same process you do in the software called OceanView. I need to understand the intensities returned from the devices when using Spectrometer.intensities().

Support for flameNIR

Will there be any support for the flameNIR?

Where would i start if i would like to implement support for it?

Raspberry PI 1 (armv6l) conda modules missing

I tried to install pyseabreeze using Miniconda (full Anaconda is not available for Raspberry Pi) but I can never get past conda install -c poehlmann python-seabreeze - it says theres no such package.

I'm running Raspbian on Raspberry Pi B+, Python 2.7.

Strange Effect when using python-seabreeze in combination with gtk

I'm not sure if this would better fit to the bugtracker of gtk, but maybe someone else using python-seabreeze can check if the problem exist on other computers too, and it's not a problem of my configuration.
When calling the following code with python 3.4, wrong values for the wavelength are returned:

from gi.repository import Gtk
import seabreeze.spectrometers as sb

devices = sb.list_devices()
s = sb.Spectrometer(devices[0])
print(s.intensities())
print(s.wavelengths())

When commenting out from gi.repository import Gtk, the right values are reported.
In both cases the intensities are correct.
I can't get my head around why gtk might interfere with seabreeze ...

Setting up

Is there something else to do to set this up besides installing SeaBreeze and the given .msi? Where am I supposed to put the module? Because when I try to test it in Idle or in a python file I get errors

intensities() returns all pixels for QE65000, not only valid ones

When checking the length of the returned wavelengths I get 1024 and for the returned intensities I get 1044.
So I guess that seabreeze returns all pixels. This is a problem when one wants to relate the wavelengths with the intensities.
This might be fixed by using the same strategy as in python-oceanoptics, by using a dictionary of the models and a corresponding slice which only returns valid pixels, I haven't found a way to do this within the seabreeze library.
Does anyone else experience this problem ?

cseabreeze: Setting integration time below min integration time returns "Undefined error"

I had successfully used this to access my spectrometer immediately after installing seabreeze, but now, a few hours later, I am having problems. Here is a capture of the iPython session:

In [1]: import matplotlib.pyplot as plt
   ...: import seabreeze.spectrometers as sb
   ...:

In [2]: devices = sb.list_devices()
   ...: spec = sb.Spectrometer(devices[0])
   ...:

In [3]: print("Attaching ", spec.model, " serial number ", spec.serial_number)
Attaching  USB2000  serial number  XXXXXXXX

In [4]: spec.integration_time_micros(1000)
---------------------------------------------------------------------------
SeaBreezeError                            Traceback (most recent call last)
<ipython-input-4-28900482d9af> in <module>()
----> 1 spec.integration_time_micros(1000)

/Users/XXXX/anaconda3/lib/python3.5/site-packages/seabreeze/spectrometers.py in integration_time_micros(self, integration_time_micros)
    166     def integration_time_micros(self, integration_time_micros):
    167         lib.spectrometer_set_integration_time_micros(self._dev,
--> 168                                                      self._fidsp, integration_time_micros)
    169
    170     def trigger_mode(self, mode):

seabreeze/cseabreeze/wrapper.pyx in seabreeze.cseabreeze.wrapper.spectrometer_set_integration_time_micros (./seabreeze/cseabreeze/wrapper.c:5102)()

SeaBreezeError: b'Error: Undefined error'

Any ideas why setting the integration time is failing?

Missing import struct in pyseabreeze/interfaces/nonlinearity.py

import struct # <<----- IMPORT REQUIRED
from .common import SeaBreezeError, get_pyseabreeze_decorator
from .eeprom import EEPromFeature
from .communication import USBCommOBP

convert_exceptions = get_pyseabreeze_decorator('interfaces.nonlinearity')

class NonlinearityCoefficientsEEPromFeature(EEPromFeature):

def has_nonlinearity_coeffs_feature(self):
    return [True]

@convert_exceptions("Error when reading nonlinearity coeffs.")
def get_nonlinearity_coeffs(self):
    # The spectrometers store the wavelength calibration in slots 6..13
    coeff = []
    for i in range(6, 14):
        coeff.append(float(self.read_eeprom_slot(i)))
    return coeff

class NonlinearityCoefficientsOBPFeature(USBCommOBP):

def has_nonlinearity_coeffs_feature(self):
    return [True]

@convert_exceptions("Error when reading nonlinearity coeffs.")
def get_nonlinearity_coeffs(self):
    # get number of nonlinearity coefficients
    data = self.query(0x00181100, "")
    N = struct.unpack("<B", data)[0]
    # now query the coefficients
    coeffs = []
    for i in range(N):
        data = self.query(0x00181101, struct.pack("<B", i))
        coeffs.append(struct.unpack("<f", data)[0])
    return coeff

Read temperature feature

Hello,

Is it possible to read the temperature sensor using this library? In the Version History of the Seabreeze API documentation there is a brief note saying: "added read temperature feature" (version 3.0.8).

https://oceanoptics.com/api/seabreeze/

Thank you for your time, this library is awesome.

Windows install instructions don't work.

Getting the cseabreeze backend running under windows can fail, because:

  • libseabreeze installers are faulty, see: ap--/libseabreeze#1
  • instructions are not detailed enough (need to explain where to find driver files, etc...)

Getting the libusb backend running is complicated because:

  • Windows. (try to link a good pyusb windows tutorial)

how to use python-seabreeze with anaconda python

Operating system (Linux distribution, Windows version, OSX version) and archictecture (32bit, 64bit, arm) : window 7 64bit
Python version and arch (i.e. Python 2.7.10 64bit): Anadonda python 3.5 64bit
python-seabreeze version: seabreeze-0.5.3-cp35-cp35m-win_amd64.whl

when I run import seabreeze.spectrometers, it shows the error as bellow:

warnings.warn("Can't load seabreeze c library wrapper, because:\n'%s'\n" % err.message )
AttributeError: 'ImportError' object has no attribute 'message'

in the same computer, if I run the python-seabreeze with python2.7 32bit, it works fine.

Thank you very much!

Arch linux install

Arch linux doesn't use have libusb-devel as they don't separate their packages into binary and development. Also, libusb in pacman is libusb-1.0 rather than libusb-0.1. If libusb-compat is installed, the build proceeds fine on arch linux.

Replace the following...
pacman -S base-devel libusb libusb-devel
with...
pacman -S base-devel libusb-compat make gcc

Same result with different integration time

Hi, I am new to spectrometer and Seabreeze. I am trying to use STS spectrometer on a raspberry Pi for daylight studies. I followed the documentation and example code. The intensities returned always has similar values does not matter what integration time I set or whether sensor is covered or not. Output is saved here

####################################
import seabreeze.spectrometers as sb
import scipy.io as sio
import time
import numpy as np

devices = sb.list_devices()
spec = sb.Spectrometer(devices[0])

spec.trigger_mode(0)
spec.integration_time_micros(100)
spec.wavelengths()
WaveLengths = spec.wavelengths()
Intensities = spec.intensities(correct_dark_counts=False, correct_nonlinearity=True)

f_handle = file('Output.txt', 'w')
for index, val in enumerate(Intensities):
f_handle.write(str(WaveLengths[index])+" "+str(Intensities[index])+"\n")
f_handle.close()
#######################################

Can't detect serial number.

I am not sure where I should report this bug. Maybe it is juste the seabreeze API being faulty but I can't detect my spectrometer, reportedly because it has no serial number. The spectrometer does work fine with spectrasuite on windows.

It fails with both backends.

I'm on ubuntu 14.04 using python 2.7.

You can see the full trace (in ipython) in the attached files.

cseabreeze_trace.txt
pyseabreeze_trace.txt

bug with tec

in pyseabreaze/thermoelectric.py

class ThermoElectricFeatureOBP(USBCommOBP):

def has_tec_feature(self):
    return [True]  # <<--- must return a LIST !!!!!!!!!!!!!!!!!!!!

@convert_exceptions("Error tec temperature read.")

Limited functionality for context manager

spectrometer and system information

  • model: all
  • operating system: Debian
  • python version: 3.5
  • python-seabreeze version: current master
  • installed-via: instructions in this repo for ARM

current problem

The context manager for the Spectrometer object (included below) will close the connection on __exit__ but it doesn't re-open it on __enter__. Ideally, I would like to use this in a manner like this:

class MyInstrumentClass:
    def __init__(*a, *kw):
        self.spec =  sb.Spectrometer.from_serial_number('xyz')
        with self.spec as spec:
            spec.integration_time_micros(30000)

    def some_method(self):
        with self.spec as s:
            intensities = s.intensities()
            wavelengths = s.wavelengths()

And these are the context managers now:

    def __enter__(self):
        return self

    def __exit__(self, type, value, traceback):
        self.close()

And, for comparison, this is what pyserial does for a Serial object (see SerialBase at https://github.com/pyserial/pyserial/blob/master/serial/serialutil.py):

    def __enter__(self):
        if not self.is_open:
            self.open()
        return self

    def __exit__(self, *args, **kwargs):
        self.close()

Of course, I could create a new Spectrometer instance each time I use it, but that seems annoying and it also wastes the effort to find the Device object. I think it would be nice to have a simple Spectrometer.open method that doesn't take any arguments, and use it in the __enter__ method.

So, do others agree that it would be useful to have the feature of allowing the context manager to open and close the connection?

Happy to take a stab at it if others agree.

Add install instructions for raspbian

If libseabreeze.so is installed to /usr/local/lib on raspian jessie then the default installation of python does not pick up the shared object and so you can't use cseabreeze.
I'm sure you could also add /usr/local/lib to one of the dynamic linker variables as indicated here: http://stackoverflow.com/questions/9542357/how-do-so-files-work-and-where-do-they-go-in-unix

Pretty new to python so sorry if I've completely missed something obvious. Manually moving libseabreeze.so to /usr/lib was the easiest way I found to get my pi to see an STS.

win7 64 bit NotImplementedError: is_kernel_driver_active in v0.4.2 but not v0.4.0

I'm running Win7 Pro 64 bit, with python 2.7.6 32bit. Using the latest pyusb (1.0.0b2) or 1.0.0b1, and python-seabreeze-v0.4.2, i get the error in the bottom screenshot (NotImplementedError: is_kernel_driver_active)

I was able to fix the problem by downgrading to python-seabreeze-v0.4.0. Not a big deal but hopefully can save someone else some time. Love the work BTW.

image

image

Boxcar width

Hi,
I can't find in the documentation any reference to boxcar width, which basically helps smoothing the signal, along with the integration time.

Discrepancy between python-seabreeze and python-oceanoptics

I'm sure I'm doing something wrong but intensities does not result in the same spectrum when I use python-seabreeze and python-oceanoptics. While the spectrum from python-oceanoptics looks like what I expect, the spectrum from python-seabreeze looks like weird saturated noise (tons of high values when the spectrum is in complete darkness).

I'm sure it has to do with differences in the default settings between the two forks: raw=False, only_valid_pixels=True, correct_nonlinearity=True, correct_darkcounts=True, correct_saturation=True, etc.

How can I get python-seabreeze's intensities to output something similar to what it does in python-oceanoptics? And maybe more importantly, why...?

Full wavelenghts/intensities

When I do
w = [spec.wavelengths()] print w i = [spec.intensities()] print i
or write the array to a Textfile, it always just says

[array([ 334.97958374, 335.43344214, 335.88734493, ..., 819.75723328, 820.25133371, 820.74546857])] [array([ 1352., 1351., 1350., ..., 1314., 1317., 1305.])]

How can I get all values (not just "...")?

Can't load c library wrapper

Hi,

I followed all the steps to install cseabreeze (and checked at the end that WinUSB was added to my spectrometer name in device manager).
The wheel corresponding to my python version (i.e win64, python 2.7) would not install however, I had to install the one for win32. But the install seemed to work fine.

I installed seabreeze from an .msi file, so did not go through the steps for building Seabreeze, as specified in http://oceanoptics.com/api/seabreeze/

When running the command in the iPython console "import seabreeze.spectrometers as sb", I get the following error:
image.

I tried running the "CSharpDemo.csproj", but nothing happens when I double-click on it.

I also tried running the "api_test.c" in Sublime Text 2 and got the following error:
image

Oh and I also tried copying the dll into the folder from which I'm running the console, but that still doesn't do it ! When running the command "import seabreeze.cseabreeze", I get:
image

Any idea what I'm doing wrong?

Best regards,
Teratora

absolute irradiance calibration

It would be great to add basic routines to generate absolute irradiance calibration arrays using the LAMP files.
Do you have any sample code?

installation instructions missing dependency for Debian

On a fresh Debian install (wheezy, raspbian 2015-05-05) the addition of the following was need to complete the installation.

sudo apt-get install libusb-dev

The ./misc/install_libseabreeze.sh compilation would otherwise halt on a missing usb.h.

Error listing the devices

Hi,

I installed the precompiled seabreeze Windows 7 library from here:

https://github.com/ap--/libseabreeze/releases

and the precompileled windows wheel from here:

https://github.com/ap--/python-seabreeze/releases

Everything installs fine and the hardware seems to be configured correctly by Windows. However, when I try to list the devices connected this is what I get:

import seabreeze.spectrometers as sb
devices = sb.list_devices()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-722e25f61c75> in <module>()
      1 import seabreeze.spectrometers as sb
----> 2 devices = sb.list_devices()

seabreeze\cseabreeze\wrapper.pyx in seabreeze.cseabreeze.wrapper.device_list_devices     (./seabreeze/cseabreeze/wrapper.c:3035)()

seabreeze\cseabreeze\wrapper.pyx in seabreeze.cseabreeze.wrapper.device_get_serial_number   (./seabreeze/cseabreeze/wrapper.c:4002)()

TypeError: Type str doesn't support the buffer API

I have no idea what this means. I am using Windows 7 (32 bits) with Python 3.4.

Best wishes,
Diego

USB2000: spec.intensities causes infinite loop (due to old FW)

Hey ap--

im new to python (experienced C and arduino user here).

anyways, im currently trying to get the intensity values from a USB2000 ocean optics device.

currently, it seems like everything is working. USB 2000 is detected, wavelengths seem correct and printed.

The problem is when i call spec.intensities, my command line goes into an infinite loop.

heres my code...

import seabreeze.spectrometers as sb
devices = sb.list_devices()
print(devices)
spec = sb.Spectrometer(devices[0])
spec.integration_time_micros(10000)
Wavelengths = spec.wavelengths()
print(Wavelengths)
value = spec.intensities()
print(value)

the command line just remains blank after it runs

im running Spyder from anaconda

image of command line

screen shot 2017-06-05 at 11 12 47 pm

isready()

It would be an awesome feature to have an isready functionality for testing if the spectrometer is ready for input (e.g. via spec.integration_time_micros(12000)) and/or output (e.g. spec.intensities()).

Support for Pixel Binning

I would love to play with the pixel binning factors to see how that would affect integration time and granularity.

How difficult would it be to add support for these functions in the Seabreeze API:

Response GetPixelBinningFactor(const std::string &arguments);
Response SetPixelBinningFactor(const std::string &arguments);
Response GetDefaultPixelBinningFactor(const std::string &arguments);
Response SetDefaultPixelBinningFactor(const std::string &arguments);
Response GetMaxPixelBinningFactor(const std::string &arguments);

I thought about trying to implement it myself, but I worry about running into trouble with the _pixels field in spectrometers.py

install_libseabreeze.sh build failure with Log.cpp

spectrometer and system information

  • model: STS-VIS
  • operating system: 2017-08-16-raspbian-stretch-lite on a Raspberry Pi Zero
  • python version: 2.7.13
  • python-seabreeze version: v0.6.0
  • installed-via: install_libseabreeze.sh

current problem

The Linux build fails on the install_libseabreeze.sh step. The cause is the Seabreeze file Log.cpp that mixes tabs and spaces. Because of this, the compiler throws this warning, which is treated like an error:

building Log.o
Log.cpp: In member function 'void Log::formatAndSend(int, const char*, const char*, const char*, va_list)':
Log.cpp:163:5: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
     if (logFile == NULL)
     ^~   
Log.cpp:166:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' 
  unsigned indent = (unsigned int) (callstack->size() - 1) * 4; 
  ^~~~~~~~
Log.cpp:180:5: error: this 'if' clause does not guard... [-Werror=misleading-indentation]
     if (fmt[strlen(fmt)] != '\n')
     ^~   
Log.cpp:182:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' 
  fflush(logFile);
  ^~~~~~
cc1plus: all warnings being treated as errors
../../common.mk:158: recipe for target 'Log.o' failed
make[2]: *** [Log.o] Error 1
make[2]: Leaving directory '/home/pi/python-seabreeze-python-seabreeze-v0.6.0/misc/libseabreeze/SeaBreeze/src/common'
../common.mk:169: recipe for target 'subdirs' failed
make[1]: *** [subdirs] Error 2
make[1]: Leaving directory '/home/pi/python-seabreeze-python-seabreeze-v0.6.0/misc/libseabreeze/SeaBreeze/src'
Makefile:29: recipe for target 'lib/libseabreeze.so' failed
make: *** [lib/libseabreeze.so] Error 2

steps to reproduce

With a fresh install of Raspbian:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git-all build-essential libusb-dev python-pip

wget https://github.com/ap--/python-seabreeze/archive/python-seabreeze-v0.6.0.tar.gz
tar xzvf python-seabreeze-v0.6.0.tar.gz
cd python-seabreeze-python-seabreeze-v0.6.0/misc
./install_libseabreeze.sh

minimal code example and error (very helpful if available)

I did manage to find two possible workarounds:

  1. I used export CFLAGS="-Wno-error=misleading-indentation" to not trigger that compiler error. This worked on one of my Raspbian installs, but not another.
  2. After I got the failure, I edited Log.cpp, replaced all tab characters (\t) with four spaces, then commented out the code that would re-fetch the source:
> #curl -L -o libseabreeze.zip ${SB_URL}
> #unzip libseabreeze.zip
> #mv libseabreeze-libseabreeze-${SB_VER} libseabreeze
---
< curl -L -o libseabreeze.zip ${SB_URL}
< unzip libseabreeze.zip
< mv libseabreeze-libseabreeze-${SB_VER} libseabreeze

Then a rebuild will work.

RedTide 650 support not working

spectrometer and system information

  • model: RedTide 650
  • operating system: macOS 10.12.5
  • python version:3.5.1
  • python-seabreeze version: 0.6.0
  • installed-via: _conda

current problem

In a nutshell, the same code I have that works with an Ocean Optics USB2000 when applied to a RedTide 650 (which appears to be listed on the list of compatible devices) doesn't work due to a failure to connect to the spectrometer. The specific steps are below:

steps to reproduce

Specifically, although Apple's System Profiler clearly shows the RedTide connected (and I can access it via Vernier's Logger Pro software), when I do

import seabreeze.spectrometers as sb
devices = sb.list_devices()
print(devices)

I get a blank list.

get_electric_dark_pixel_indeces must return a numpy.array

in class SpectrometerFeatureOBP

@convert_exceptions("Is the spectrometer initialized?")
def get_electric_dark_pixel_indices(self):
    # return model name with lookuptable
    return numpy.array(DarkPixels[self.get_model()])   # <<--- need numpy.array casting as in the SpectrometerFeatureOOI class

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.