Perfect, done! Nice documentation! And, the brultech example was very
useful since it wasn't completely clear from the regular docs how to
implement get_series.

In case you're up for some feedback:

   - Xtype needs a capital 'T' in the "Pressure" example: "class
   Pressure(weewx.xtypes.XType):"
   - It'd be nice if there were a bit more clarity in how to "register"
      - the documentation doesn't clearly stay to edit user/extensions.py
      - it'd be nice to give an example of how to import the user module
      ("import user.indewpoint" in my case")
   - It'd be nice to give a simple example of querying the database. I used
   the brultech example.
   - Type documentation could be a bit more precise, e.g. "obs_type is the
   type to be computed." Technically obs_type is a string name, not an actual
   type. I know this sounds picky, but it confused me at first. If there's a
   link to a list of normal values for obs_type, that would be helpful.

My code is below in case any of it would be useful for documentation.

Thanks!

Jason

P.S. The yearly plots started working overnight, but thanks for the
reminder re: deleting---I forgot that weewx will automatically recreate.

----- user/extensions.py
import user.indewpoint
import weewx.xtypes

weewx.xtypes.xtypes.append(user.indewpoint.InsideDewpoint())


----- user/indewpoint.py
import weewx.units
import weewx.xtypes
import weewx.wxformulas
from weewx.units import ValueTuple

class InsideDewpoint(weewx.xtypes.XType):

  def get_scalar(self, obs_type, record, dbmanager):
    """Calculate indoor dewpoint from temperature and humidity."""
    if obs_type != 'inDewpoint':
      raise weewx.UnknownType
    try:
      record_us = weewx.units.to_US(record)
      inDewpoint = weewx.wxformulas.dewpointF(record_us['inTemp'],
                                              record_us['inHumidity'])
      return ValueTuple(inDewpoint, "degree_F", "group_temperature")
    except KeyError:
      # Don't have everything we need. Raise an exception.
      raise weewx.CannotCalculate(obs_type)

  def get_series(self, obs_type, timespan, db_manager, aggregate_type,
aggregate_interval):
    if obs_type != 'inDewpoint':
      raise weewx.UnknownType
    start_vec = list()
    stop_vec = list()
    data_vec = list()
    if aggregate_type:
      raise weewx.UnknownAggregation(aggregate_type)
    for record in db_manager.genSql("select dateTime, interval, usUnits,
inTemp, inHumidity from archive where dateTime > %(start)s and dateTime <=
%(stop)s" % {'start': timespan[0], 'stop': timespan[1]}):
      if (record[2] != 1):
        raise weewx.CannotCalculate("units are not US")
      start_vec.append(record[0] - record[1] * 60)
      stop_vec.append(record[0])
      # Calculation takes inTemp and inHumidity
      data_vec.append(weewx.wxformulas.dewpointF(record[3], record[4]))
    return (ValueTuple(start_vec, 'unix_epoch', 'group_time'),
            ValueTuple(stop_vec, 'unix_epoch', 'group_time'),
            ValueTuple(data_vec, "degree_F", "group_temperature"))


On Sat, Jul 18, 2020 at 9:50 PM Tom Keffer <[email protected]> wrote:

> Just delete all the plots. WeeWX will regenerate them all at the next
> reporting cycle.
>
> Yes, the archive data is used for plots, unless the aggregation interval
> is one day, in which case the daily summaries are used.
>
> Yes, inDewpoint is a derived value. Write an xtypes extension
> <https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types> for it
> and StdWXCalculate can calculate it.
>
> -tk
>
>
>
> On Sat, Jul 18, 2020 at 6:36 PM Jason Rennie <[email protected]> wrote:
>
>> I know! I guess weewx worked so well that I almost never needed to spend
>> any time on it!
>>
>> I was seeing month and year plots that only had a ~week of data, but now
>> that I look at the archive_day_outTemp table, I see data going back at
>> least a year. And, now the month plots are fully populated and I realize
>> the plots are probably based on the raw data rather than the daily stats.
>> The year plots still only have a ~week of data, but I know those are
>> regenerated much less often, so I'm guessing I'll see new plots tomorrow.
>> So, I suspect this was a false alarm and nothing is wrong. I should have
>> investigated a bit more :)
>>
>> But, while I've got your attention, you might remember that I like to
>> keep track of indoor dewpoint. I've got it working for including values in
>> html (using "inDewpoint" in the templates). But, plot generation when I try
>> to use "inDewpoint" in skin.conf for the daytempin plot. It looks
>> like inDewpoint is a generated value. Can plots use inDewpoint?
>>
>> Thanks,
>>
>> Jason
>>
>> On Saturday, July 18, 2020 at 9:00:58 PM UTC-4 [email protected] wrote:
>>
>>> Hello, Jason! Have not heard from you in years!
>>>
>>> The "backfill" process should do the entire database, not just a year.
>>> What symptoms are you seeing?
>>>
>>> On Sat, Jul 18, 2020 at 5:48 PM Jason Rennie <[email protected]> wrote:
>>>
>>>> I'm amazed that the upgrade mostly worked flawlessly. I installed 4.1.1
>>>> via the Deb/Ubuntu package after realizing that Ubuntu 20.04 no longer
>>>> supports v2 python libraries. Tom, I'm impressed! Just had to copy
>>>> weewx.sdb to /var/lib/weewx and make some minor config tweaks. Plots look
>>>> great for day and week, but month/year appear to be missing data. I see
>>>> that the stats tables are now part of weewx.sdb. During startup, it spent a
>>>> few minutes "generating stats" and I see the new tables in weewx.sdb. Is
>>>> there a way to tell it to go back further and generate, say, a year of
>>>> stats?
>>>>
>>>> Thanks,
>>>>
>>>> Jason
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "weewx-user" 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-user/CA%2BPf4UBs5k4bkugsewv3_LTc%3Dd74YRhX0ANpmab-4CEBnPp5Ug%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/weewx-user/CA%2BPf4UBs5k4bkugsewv3_LTc%3Dd74YRhX0ANpmab-4CEBnPp5Ug%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "weewx-user" 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-user/7bf1e090-c097-47c0-a3aa-95e136aaaacen%40googlegroups.com
>> <https://groups.google.com/d/msgid/weewx-user/7bf1e090-c097-47c0-a3aa-95e136aaaacen%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "weewx-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/weewx-user/hp6ZvSOPM5s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/CAPq0zEDncM5RpR8A99e7WQExjJGr7Md5voks2HJKqx6RCg5vtQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/weewx-user/CAPq0zEDncM5RpR8A99e7WQExjJGr7Md5voks2HJKqx6RCg5vtQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Jason Rennie
Software Engineer
Google

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" 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-user/CA%2BPf4UB1OJfqndc7csXcwuYgX%3DtU11RNQyVUoTQux9GRSkm0jA%40mail.gmail.com.

Reply via email to