Skip to content
This repository was archived by the owner on Aug 30, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions oceanoptics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def __init__(self, model):
self._wl = sum( self._wl_factors[i] *
np.arange(self._pixels, dtype=np.float64)**i for i in range(4) )
self._valid_pixels = _OOValidPixels[model]
self._dark_pixels = _OODarkPixels[model]


#---------------------
# High level functions
Expand All @@ -161,9 +163,9 @@ def wavelengths(self, only_valid_pixels=True):
else:
return self._wl

def intensities(self, raw=False, only_valid_pixels=True,
correct_nonlinearity=True, correct_darkcounts=True,
correct_saturation=True ):
def intensities(self, raw=False, only_valid_pixels=True,
correct_nonlinearity=True, correct_darkcounts=True,
correct_saturation=True):
"""returns array of intensities

Parameters
Expand All @@ -173,9 +175,9 @@ def intensities(self, raw=False, only_valid_pixels=True,
only_valid_pixels : bool, optional
only optical active pixels are returned.
correct_nonlinearity : bool, optional
does nothing yet.
corrects for nonlinearity of CCD-Chip
correct_darkcounts : bool, optional
does nothing yet.
substracts mean value of dark pixels from spectrum
correct_saturation : bool, optional
does nothing yet.

Expand All @@ -184,10 +186,28 @@ def intensities(self, raw=False, only_valid_pixels=True,
intensities : ndarray
intensities of spectrometer.
"""
def calc_nonlinearity(counts):
return sum( self._nl_factors[i] * counts**i for i in range(8) )

data = np.array(self._request_spectrum(), dtype=np.float64)
dark = np.mean(data[self._dark_pixels])
# uncomment to check if the definition of self._dark_pixels is correct
#print(data[self._dark_pixels])

if correct_darkcounts:
data = data - dark

if correct_nonlinearity and correct_darkcounts:
data = data/calc_nonlinearity(data)

if correct_nonlinearity and not correct_darkcounts:
data = data - dark
data = data/calc_nonlinearity(data)
data = data + dark

if only_valid_pixels:
data = np.array(self._request_spectrum()[self._valid_pixels], dtype=np.float64)
else:
data = np.array(self._request_spectrum(), dtype=np.float64)
data = data[self._valid_pixels]

return data

def spectrum(self, raw=False, only_valid_pixels=True,
Expand All @@ -202,9 +222,9 @@ def spectrum(self, raw=False, only_valid_pixels=True,
only_valid_pixels : bool, optional
only optical active pixels are returned.
correct_nonlinearity : bool, optional
does nothing yet.
corrects for nonlinearity of CCD-Chip
correct_darkcounts : bool, optional
does nothing yet.
substracts mean value of dark pixels from spectrum
correct_saturation : bool, optional
does nothing yet.

Expand Down
17 changes: 17 additions & 0 deletions oceanoptics/defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ class OceanOpticsError(Exception):
'HR2000' : slice(26, 2048),
}

# TODO: For QE6500 the values in the datasheet were not correct ! (is also wrong in Spectra Suite) -> Please checkfor your model individually
OceanOpticsDarkPixels = {
'Apex' : [1,2,3,2064,2065,2066,2067],
'HR2000+' : [12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29],
'HR4000' : [6,7,8,9,10,11,12,13,14,15,16,17,18],
'Maya' : [1,2,3,2064,2065,2066,2067],
'Maya2000pro' : [1,2,3,2064,2065,2066,2067],
'QE65000' : [1,2,3,1038,1039,1040,1041],
'QE65pro' : [0,1,2,3,1038,1039,1040,1041,1042,1043],
'Torus' : [12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29],
'USB2000+' : [12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29],
'USB4000' : [6,7,8,9,10,11,12,13,14,15,16,17,18],
'USB2000' : [], #TODO: Add dark pixels
'USB650' : [], #TODO: Add dark pixels
'HR2000' : [], #TODO: Add dark pixels
}

OceanOpticsMinMaxIntegrationTime = {
'Apex' : (0.015, 1600.),
'HR2000+' : (0.001, 655.350),
Expand Down