Skip to content

Discontinuous temperature correction in O3 #13

Description

@theGOTOguy

In the field we noticed a dramatic shift in measured O3 PPM and realized it was due to the temperature correction being discontinuous at 0C. For instance, consider your code:

    elif self.gastype == DFRobot_GasType.O3:
      if (self.temp > -20) and (self.temp <= 0):
        Con = Con / (0.015 * self.temp + 1.1) - 0.05
      elif (self.temp > 0) and (self.temp <= 20):
        Con = Con/1.1 - (0.01 * self.temp)
      elif (self.temp > 20) and (self.temp <= 40):
        Con = Con/1.1 - (-0.005 * self.temp + 0.3)
      else:
         Con = 0.0

We expect Con / (0.015 * self.temp + 1.1) - 0.05 to equal Con/1.1 - (0.01 * self.temp) at self.temp == 0.

However, let's try letting Con = 1 and see what we get:

ben@anteater:~$ ipython3
Python 3.12.3 (main, Feb  4 2025, 14:48:35) [GCC 13.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.20.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: 1 / (0.015 * 0  + 1.1) - 0.05
Out[1]: 0.859090909090909

In [2]: 1 / 1.1 - (0.01 * 0)
Out[2]: 0.9090909090909091

There is clearly an issue in the concentration calculations if they are not continuous at the temperature boundaries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions