Skip to content
This repository was archived by the owner on Aug 30, 2020. It is now read-only.
This repository was archived by the owner on Aug 30, 2020. It is now read-only.

Nonlinearity Correction #16

@sdickreuter

Description

@sdickreuter

I could'nt open a second pull request, so here is a patch for the implementation of the nonlinearity correction:

--- ../python-oceanoptics_upstream/oceanoptics/base.py  2015-01-14 10:22:10.573384769 +0100
+++ oceanoptics/base.py 2015-01-16 09:40:37.732968993 +0100
@@ -168,7 +170,7 @@
         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.
         correct_saturation : bool, optional
@@ -183,8 +185,14 @@
             data = np.array(self._request_spectrum()[self._valid_pixels], dtype=np.float64)
         else:
             data = np.array(self._request_spectrum(), dtype=np.float64)
+        if correct_nonlinearity:
+            data = data/self._calc_nonlinearity(data)
         return data

+    def _calc_nonlinearity(self, counts):
+        return sum( self._nl_factors[i] * counts**i for i in range(8) )
+
+
     def spectrum(self, raw=False, only_valid_pixels=True,
             correct_nonlinearity=True, correct_darkcounts=True,
             correct_saturation=True):
@@ -197,7 +205,7 @@
         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.
         correct_saturation : bool, optional

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions