From 9f856e23fd87729e8dc9b7fd6b085303b563c5b2 Mon Sep 17 00:00:00 2001 From: sdickreuter Date: Thu, 22 Jan 2015 16:20:13 +0100 Subject: [PATCH 1/4] updated DarkPixels for QE65000 --- oceanoptics/defines.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/oceanoptics/defines.py b/oceanoptics/defines.py index da5e0f8..e3c1354 100644 --- a/oceanoptics/defines.py +++ b/oceanoptics/defines.py @@ -150,13 +150,30 @@ 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), 'HR4000' : (0.00001, 655.350), 'Maya' : (0.015, 1600.), 'Maya2000pro' : (0.0072, 65.), - 'QE65000' : (0.008, 1600.), + 'QE65000' : (0.0008, 1600.), 'QE65pro' : (0.010, 1600.), 'Torus' : (0.0, float('inf')), # TODO: don't know... 'USB2000+' : (0.001, 655.350), @@ -167,5 +184,6 @@ class OceanOpticsError(Exception): 'STS' : (0.00001, 85.) } -OceanOpticsSupportedModels = OceanOpticsSpectrumConfig.keys() + ['STS'] +OceanOpticsSupportedModels = list(OceanOpticsSpectrumConfig.keys()) + ['STS'] + From d74d8435fbf06d1e56e880135f73d4ebd523a15d Mon Sep 17 00:00:00 2001 From: sdickreuter Date: Thu, 22 Jan 2015 16:24:57 +0100 Subject: [PATCH 2/4] implemented dark current correction and nonlinearity correction --- oceanoptics/base.py | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/oceanoptics/base.py b/oceanoptics/base.py index 87ba45c..bdced50 100644 --- a/oceanoptics/base.py +++ b/oceanoptics/base.py @@ -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 @@ -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 @@ -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. @@ -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, @@ -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. From c05edc12615f9ee8583c6150935450d7ce264700 Mon Sep 17 00:00:00 2001 From: sdickreuter Date: Thu, 22 Jan 2015 16:27:16 +0100 Subject: [PATCH 3/4] Revert "updated DarkPixels for QE65000" This reverts commit 9f856e23fd87729e8dc9b7fd6b085303b563c5b2. --- oceanoptics/defines.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/oceanoptics/defines.py b/oceanoptics/defines.py index e3c1354..da5e0f8 100644 --- a/oceanoptics/defines.py +++ b/oceanoptics/defines.py @@ -150,30 +150,13 @@ 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), 'HR4000' : (0.00001, 655.350), 'Maya' : (0.015, 1600.), 'Maya2000pro' : (0.0072, 65.), - 'QE65000' : (0.0008, 1600.), + 'QE65000' : (0.008, 1600.), 'QE65pro' : (0.010, 1600.), 'Torus' : (0.0, float('inf')), # TODO: don't know... 'USB2000+' : (0.001, 655.350), @@ -184,6 +167,5 @@ class OceanOpticsError(Exception): 'STS' : (0.00001, 85.) } -OceanOpticsSupportedModels = list(OceanOpticsSpectrumConfig.keys()) + ['STS'] - +OceanOpticsSupportedModels = OceanOpticsSpectrumConfig.keys() + ['STS'] From 3a917cf564a2c214620a829cab10c85befbab72b Mon Sep 17 00:00:00 2001 From: sdickreuter Date: Thu, 22 Jan 2015 16:28:33 +0100 Subject: [PATCH 4/4] added Defintion of OceanOpticsDarkPixels --- oceanoptics/defines.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/oceanoptics/defines.py b/oceanoptics/defines.py index da5e0f8..a4e715b 100644 --- a/oceanoptics/defines.py +++ b/oceanoptics/defines.py @@ -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),