A problem is that you're doing arithmetic before checking for a "None"
result. For example,
...
dp_F = dewpointF(t_F, rh)
dp_D = t_F - dp_F
return dp_D if dp_D is not None else None
If db_F is None, this will fail. Same problem with the other algorithms.
As for adding the results to the database, if you add the types
through the xtypes
system <https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types>,
they will become available throughout WeeWX. Follow the example
<https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types#a-comprehensive-example>
in the Wiki. The biggest challenge will be checking that the units are
right.
-tk
On Sun, Nov 1, 2020 at 12:58 PM rich T <[email protected]> wrote:
> I want to add Dewpoint Depression and Wetbulb Formulas to the
> wxformulas.py file. So far this is what I have
>
> Dewpoint Depression:
>
> def dewpointdepressF(t_F, rh):
>
> """Calculate dew point depression.
>
> https://www.theweatherprediction.com/habyhints3/904/
>
> t_f: Temperature in Fahrenheit
>
> rh: relative humidity [0-100]
>
> Returns: Dewpoint Depression
>
> """
>
> if t_f is None or rh is None:
> return None
>
> dp_F = dewpointF(t_F, rh)
> dp_D = t_F - dp_F
>
> return dp_D if dp_D is not None else None
>
> def dewpointdepressC(t_C, rh):
>
> """Calculate dew point depression.
>
> https://www.theweatherprediction.com/habyhints3/904/
>
> t_C: temperature in degree Celsius
>
> rh: relative humidity [0-100]
>
> Returns: Dewpoint Depression
>
> """
>
> if t_C is None or rh is None:
> return None
>
> dp_C = dewpointC(t_C, rh)
> dp_D = t_C - dp_C
>
> return dp_D if dp_D is not None else None
>
> Wetbulb:
>
> def wetbulbF(t_F, rh):
>
> """Estimate the wetbulb temperature (1/3 method).
>
> https://theweatherprediction.com/habyhints/170/
>
> t_f: Temperature in Fahrenheit
>
> rh: relative humidity [0-100]
>
> dp_DwB: Dewpoint Depression divided by 3
>
> t_WbF: Wetbulb Temperature in Fahrenheit
>
> Returns: Wetbulb Temperature Estimation
>
> """
>
> if t_f is None or rh is None:
> return None
>
> dp_F = dewpointF(t_F, rh)
> dp_DwB = (t_F - dp_F) / 3
> t_WbF = t_F - dp_DwB
>
> return t_WbF if t_WbF is not None else None
>
> def wetbulbC(t_C, rh):
>
> """Estimate the wetbulb temperature (1/3 method).
>
> https://theweatherprediction.com/habyhints/170/
>
> t_C: temperature in degree Celsius
>
> rh: relative humidity [0-100]
>
> dp_DwB: Dewpoint Depression divided by 3
>
> t_WbC: Wetbulb Temperature in Celsius
>
> Returns: Wetbulb Temperature Estimation
>
> """
>
> if t_C is None or rh is None:
> return None
>
> dp_C = dewpointC(t_C, rh)
> dp_DwB = (t_C - dp_C) / 3
> t_WbC = t_C - dp_DwB
>
> return t_WbC if t_WbC is not None else None
>
> Does the coding look okay? I know I need to add two columns to the
> database, but what else would need to be updated to get the results in the
> database?
>
> Rich
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-development/0e328c83-7614-4448-8dd9-743929495d9bo%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-development/0e328c83-7614-4448-8dd9-743929495d9bo%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-development/CAPq0zEAM_yTfqVqpWeft0VK7Y5bdfXM0DaghJVdQScJrx%2Bmo2Q%40mail.gmail.com.