Commits

iorodeo committed 7ce03e5

Add error dialog to measurement program for the case where the users is using a
nonlinear fit and the measurement falls outside of the calibration range -
basically disallow extrapolation.

  • Participants
  • Parent commits c4011e8

Comments (0)

Files changed (2)

File python/Colorimeter/colorimeter/gui/measure/measure.py

             conc = self.getConcentration(absorb) 
         else:
             freq, trans, absorb = self.dev.getMeasurement()
-            conc = self.getConcentration(absorb[ledNumber])
+            try:
+                conc = self.getConcentration(absorb[ledNumber])
+            except ValueError, err:
+                msgTitle = 'Range Error'
+                msgText = str(err)
+                QtGui.QMessageBox.warning(self,msgTitle, msgText)
+                return
+
         concStr = '{0:1.2f}'.format(conc)
         self.measurePushButton.setFlat(False)
         self.tableWidget.addData('',concStr,selectAndEdit=True)

File python/Colorimeter/colorimeter/nonlinear_fit.py

 def getValueFromFit(fitCoeff,inputValue,numPts=500):
     interpFunc, minVal, maxVal = fitCoeff
     if (inputValue < minVal) or (inputValue > maxVal):
-        raise ValueError, 'input Value outside of interpolator range'
+        raise ValueError, 'value outside of calibration range'
     outputValue = interpFunc(inputValue)
     return float(outputValue)