Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-linearity corrections lead to infinities #40

Closed
JuanCab opened this issue Mar 17, 2017 · 6 comments
Closed

non-linearity corrections lead to infinities #40

JuanCab opened this issue Mar 17, 2017 · 6 comments

Comments

@JuanCab
Copy link

JuanCab commented Mar 17, 2017

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.

@ap--
Copy link
Owner

ap-- commented Mar 19, 2017

The non-linearity correction uses coefficients stored on the spectrometer.
They are stored in the Spectrometer class in spec._nc
Can you report the contents of spec._nc?
Maybe we need to protect against nonsensical nonlinearity coefficients in pyseabreeze.

@JuanCab
Copy link
Author

JuanCab commented Mar 20, 2017

I tried it and got a back a zero...

In [1]: import seabreeze.spectrometers as sb
In [2]: devices = sb.list_devices()
   ...: spec = sb.Spectrometer(devices[0])
   ...:
In [3]: spec._nc
Out[3]: poly1d([ 0.])

So it looks non-sensical if you divide by this. I've tested this with both of our Ocean Optics USB2000's and they both produce the same results.

Is this something I should contact Ocean Optics about (the coefficients being missing) or is it maybe that those coefficients were not stored for USB2000's?

@ap--
Copy link
Owner

ap-- commented Mar 20, 2017

So it could be, that your spectrometer just doesn't have any coefficients stored or it could be a problem with pyseabreeze. Report back with the output of:

print "order: '%s'" % spec.eeprom_read_slot(14)
for i in range(6, 14):
    print "'%s'" % spec.eeprom_read_slot(i)

@ap--
Copy link
Owner

ap-- commented Mar 21, 2017

I think this is a bug in pyseabreeze. The order returned by your USB2000 spec.eeprom_read_slot(14) will be 0.

In this case cseabreeze will internally return a zero length vector and consequently raise an Exception, that the device does not support nonlinearity correction.

Pyseabreeze, currently just assumes that there are 8 coefficients stored, and will return a list with eight zeros.

@JuanCab
Copy link
Author

JuanCab commented Mar 21, 2017

Yep, it returns all zeros:

order: 'b'0\x00\x00\x000000e+000\x00\x00''
'b'0.000000e+000\x00\x00''
'b'0.000000e+000\x00\x00''
'b'0.000000e+000\x00\x00''
'b'0.000000e+000\x00\x00''
'b'0.000000e+000\x00\x00''
'b'0.000000e+000\x00\x00''
'b'0.000000e+000\x00\x00''
'b'0.000000e+000\x00\x00''

So I guess the USB2000 doesn't support nonlinearity corrections.

@ap--
Copy link
Owner

ap-- commented Mar 21, 2017

So I guess the USB2000 doesn't support nonlinearity corrections.

Well... to be nitpicky: you could still do nonlinearity correction, the device just doesn't store predetermined coefficients.

In a way if you are concerned about the linearity of your relative intensity measures, you should measure the nonlinearity coefficients PER PIXEL and not use the predetermined 7th order polynomial for the whole sensor that's (maybe) stored on the device.

But back to topic: pyseabreeze should raise an error when the polynomial order is 0.

ap-- added a commit that referenced this issue Mar 21, 2017
@ap-- ap-- closed this as completed Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants