File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -414,11 +414,12 @@ def dew_point(self):
414414 """Return dew point temperature in degrees Celsius.
415415
416416 Uses the Magnus formula (Alduchov & Eskridge, 1996) with the
417- current temperature and relative humidity readings.
417+ current temperature and relative humidity readings. Both values
418+ come from a single ``read()`` call to ensure consistency.
418419 """
419420 from math import log
420421
421- t = self .temperature ()
422- rh = self . humidity ( )
422+ t , _ , rh = self .read ()
423+ rh = max ( rh , 0.01 )
423424 gamma = log (rh / 100.0 ) + 17.625 * t / (243.04 + t )
424425 return 243.04 * gamma / (17.625 - gamma )
Original file line number Diff line number Diff line change @@ -642,15 +642,12 @@ tests:
642642 expect_true : true
643643 mode : [mock]
644644
645- - name : " dew_point() equals temperature at 100% humidity "
645+ - name : " dew_point() matches Magnus formula for mock readings "
646646 action : script
647647 script : |
648- # Override humidity compensation to return ~100%RH
649- # At 100% RH, dew point should equal temperature
650648 from math import log
651- t = dev.temperature()
652- rh = dev.humidity()
653- # Compute expected dew point from actual mock values
649+ t, _, rh = dev.read()
650+ # Compute expected dew point from Magnus formula
654651 gamma = log(rh / 100.0) + 17.625 * t / (243.04 + t)
655652 expected = 243.04 * gamma / (17.625 - gamma)
656653 dp = dev.dew_point()
You can’t perform that action at this time.
0 commit comments