Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in Funktion weewx_wdc.py/get_calendar_data #77

Closed
Daveiano opened this issue Oct 14, 2022 Discussed in #76 · 0 comments
Closed

Problem in Funktion weewx_wdc.py/get_calendar_data #77

Daveiano opened this issue Oct 14, 2022 Discussed in #76 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@Daveiano
Copy link
Owner

Discussed in #76

Originally posted by hoetzgit October 14, 2022
Hallo David,

aus bestimmten Gründen habe ich in einigen WeeWX Datenbanktabellen Zeilen mit dateTime belegt, aber den Rest der Spalten mit NULL Werten. Das ist beabsichtigt und macht bei mir für bestimmte Situationen Sinn. Es führt jedoch bei weewx-wdc zu folgendem Problem (siehe unten). Da ich von Python nicht so viel Ahnung habe, schreibe ich hier wie ich es gelöst habe und würde Dich bitten, Dir das mal anzusehen und zu bewerten, ggf. in irgendeiner Form bei Dir einzubauen.

Vielen Dank und Grüße Henry

Fehlermeldung:

Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: Evaluation of template /home/weewx/skins/weewx-wdc/statistics.html.tmpl failed with exception '<class 'TypeError'>'
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/weewx-wdc/statistics.html.tmpl
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: **** Reason: '>' not supported between instances of 'NoneType' and 'float'
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/cheetahgenerator.py", line 348, in generate
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_weewx_wdc_statistics_html_tmpl.py", line 192, in respond
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1708, in _handleCheetahInclude
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****      self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_weewx_wdc_includes_climatological_days_inc.py", line 330, in respond
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_weewx_wdc_includes_climatological_days_inc.py", line 127, in __errorCatcher9
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****    File "<string>", line 1, in <module>
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/user/weewx_wdc.py", line 1030, in get_calendar_data
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****      for day in days:
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/user/weewx_wdc.py", line 1026, in <lambda>
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****      lambda x: x[1].raw > 0.0, list(zip(day_series.start, day_series.data))
Oct 14 08:55:47 weewx weewx[303151] ERROR weewx.cheetahgenerator: ****  TypeError: '>' not supported between instances of 'NoneType' and 'float'

Korrektur (Filter angepasst)

    def get_calendar_data(self, obs, aggrgate_type, period):
        """
        Returns array of calendar data for use in diagram.

        Args:
            observation (string): The observation
            aggrgate_type (string): Min, max, avg.
            period (obj): Period to use, eg. $year, month, $span

        Returns:
            list: Calendar data.
        """
        if obs == "rain":
            day_series = period.rain.series(
                aggregate_type=aggrgate_type,
                aggregate_interval="day",
                time_series="start",
                time_unit="unix_epoch",
            ).round(self.diagram_util.get_rounding("rain"))

            days = filter(
                lambda x: (x[1].raw > 0.0) if x[1].raw is not None else False, list(zip(day_series.start, day_series.data))
            )
            rainDays = []

            for day in days:
                rainDays.append({"value": day[1].raw, "day": day[0].format("%Y-%m-%d")})

            return rainDays

        if obs == "outTemp":
            day_series = period.outTemp.series(
                aggregate_type=aggrgate_type,
                aggregate_interval="day",
                time_series="start",
                time_unit="unix_epoch",
            ).round(self.diagram_util.get_rounding("outTemp"))

            days = list(zip(day_series.start, day_series.data))
            tempDays = []

            for day in days:
                if day[1].raw is not None:
                    tempDays.append(
                        {"value": day[1].raw, "day": day[0].format("%Y-%m-%d")}
                    )
            return tempDays
```</div>
@Daveiano Daveiano added the bug Something isn't working label Oct 14, 2022
@Daveiano Daveiano added this to the 2.3.0 milestone Oct 14, 2022
Daveiano added a commit that referenced this issue Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant