ValueError: y1 must be greater than or equal to y0 in fresh installed weewx 4.10.2

1,434 views
Skip to first unread message

c s (224)

unread,
Apr 3, 2023, 7:18:39 AM4/3/23
to weewx-user
Hello,

I have just installed weewx as described here: https://weisser-zwerg.dev/posts/ecowitt-gw2000-weewx-docker

And I run into an error that prevents the images from being drawn:

weewx-weewx-1      | Apr  3 13:11:03 weewx[20] ERROR weewx.reportengine:         ****  Generator terminated
weewx-weewx-1      | Traceback (most recent call last):
weewx-weewx-1      |   File "/home/weewx/bin/weewx/reportengine.py", line 197, in run
weewx-weewx-1      |     obj.start()
weewx-weewx-1      |   File "/home/weewx/bin/weewx/reportengine.py", line 385, in start
weewx-weewx-1      |     self.run()
weewx-weewx-1      |   File "/home/weewx/bin/weewx/imagegenerator.py", line 42, in run
weewx-weewx-1      |     self.gen_images(self.gen_ts)
weewx-weewx-1      |   File "/home/weewx/bin/weewx/imagegenerator.py", line 114, in gen_images
weewx-weewx-1      |     image = plot.render()
weewx-weewx-1      |             ^^^^^^^^^^^^^
weewx-weewx-1      |   File "/home/weewx/bin/weeplot/genplot.py", line 222, in render
weewx-weewx-1      |     self._renderDayNight(sdraw)
weewx-weewx-1      |   File "/home/weewx/bin/weeplot/genplot.py", line 266, in _renderDayNight
weewx-weewx-1      |     sdraw.rectangle(((xleft,self.yscale[0]),
weewx-weewx-1      |   File "/home/weewx/bin/weeplot/utilities.py", line 442, in rectangle
weewx-weewx-1      |     self.draw.rectangle(box_scaled, **options)
weewx-weewx-1      |   File "/opt/venv/lib/python3.11/site-packages/PIL/ImageDraw.py", line 294, in rectangle
weewx-weewx-1      |     self.draw.draw_rectangle(xy, fill, 1)
weewx-weewx-1      | ValueError: y1 must be greater than or equal to y0

I have followed the complete set-up process as described in "WeeWX: Installation using setup.py", except that I do use a conda environment and pip packages rather than the OS packages:

> mamba create -n weewx python=3.9
> conda activate weewx
> pip3 install configobj paho-mqtt pyserial pyusb Cheetah3 Pillow ephem
> wget https://weewx.com/downloads/weewx-4.10.2.tar.gz
> tar -xzvf weewx-4.10.2.tar.gz
> cd weewx-4.10.2
> python3 ./setup.py build
> python3 ./setup.py install
> # create the weewx.conf.patch from here: https://weisser-zwerg.dev/posts/ecowitt-gw2000-weewx-docker/
> patch -p1 weewx.conf < weewx.conf.patch
> wget -O weewx-mqtt.zip https://github.com/matthewwall/weewx-mqtt/archive/master.zip
> ./bin/wee_extension --install ./weewx-mqtt.zip
> wget -O weewx-interceptor.zip https://github.com/matthewwall/weewx-interceptor/archive/master.zip
> ./bin/wee_extension --install ./weewx-interceptor.zip
> # -------------------
> ./bin/weewxd

I still run into the exact same problem. I've tried several modifications to the config file, but cannot figure out what causes this problem. I've also added some print statement to tell me more about the issue around the drawing of the rectangle:
def rectangle(self, box, **options):
"""Draw a scaled rectangle.
box: A pair of 2-way tuples, containing coordinates of opposing corners
of the box.
options: passed on to draw.rectangle. Usually contains 'fill' (the color)
"""
box_scaled = [(coord[0] * self.xscale + self.xoffset + 0.5,
coord[1] * self.yscale + self.yoffset + 0.5) for coord in box]
try:
self.draw.rectangle(box_scaled, **options)
print("Draw rectangle succeeded.")
except:
print("Draw rectangle failed:")
print(box)
print(box_scaled)
print(f"self.xscale: {self.xscale}, self.xoffset: {self.xoffset}, self.yscale: {self.yscale}, self.yoffset: {self.yoffset}\n")
pass

And I get results as follows:
# ((1680429600, 1029.6000000000001), (1680457455, 1030.1000000000001))
# [(44.01851851865649, 144.4999999999709), (216.61388888955116, 24.499999999970896)]
# self.xscale: 0.004465020576131688, self.xoffset: -7503109, self.yscale: -240.0, self.yoffset: 247248

Do you have any clues on how to resolve this?


Thanks!

Tom Keffer

unread,
Apr 3, 2023, 12:07:14 PM4/3/23
to weewx...@googlegroups.com
Thanks for your exceptionally detailed query! Unfortunately, I can't diagnose anything related to Docker, or your unusual configuration. I assume you are using the Seasons skin. Some thoughts:

Any particular reason why you're trying to use the interceptor driver, rather than the native GW1000 driver?

Did you change anything in skin.conf?

The problem seems to be around the drawing of the day/night transition bands. Does it work if you set option "show_daynight" in skin.conf to False?

It would be useful to see some values in _renderDayNight in genplot.py. The following should do it:

===================================================================
diff --git a/bin/weeplot/genplot.py b/bin/weeplot/genplot.py
--- a/bin/weeplot/genplot.py (revision b5a79042fb5017c8c0d342e957ae1fa98040bd94)
+++ b/bin/weeplot/genplot.py (date 1680537716331)
@@ -259,6 +259,9 @@
         """Draw vertical bands for day/night."""
         (first, transitions) = weeutil.weeutil.getDayNightTransitions(
             self.xscale[0], self.xscale[1], self.latitude, self.longitude)
+        print(f"In _renderDayNight(), self.yscale = {self.yscale}")
+        print(f"latitude={self.latitude}, longitude={self.longitude}")
+        print(f"first={first}, transitions={transitions}")
         color = self.daynight_day_color \
             if first == 'day' else self.daynight_night_color
         xleft = self.xscale[0]
===================================================================

-tk


--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/cf100b38-68c2-47de-ae9d-0b1d91a2da96n%40googlegroups.com.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

c s (224)

unread,
Apr 3, 2023, 3:47:04 PM4/3/23
to weewx-user
Thank you very much! You are right! Setting the "show_daynight" in skin.conf to False resolves the problem. I did not touch skin.conf before and used the version as it is delivered in weewx-4.10.2.tar.gz.

When I turn "show_daynight" on again and add your additional print messages (and keep the ones I had already added before) I get the following:

In _renderDayNight(), self.yscale = (0.0, 5.0, 0.5)
latitude=48.14, longitude=11.57
first=night, transitions=[1680497278, 1680543969]
Draw rectangle failed:
((1680462000, 0.0), (1680497278, 5.0))
[(44.90740740764886, 144.5), (202.42440329305828, 24.5)]
self.xscale: 0.004465020576131688, self.xoffset: -7503253, self.yscale: -24.0, self.yoffset: 144

Draw rectangle failed:
((1680497278, 0.0), (1680543969, 5.0))
[(202.42440329305828, 144.5), (410.9006790127605, 24.5)]
self.xscale: 0.004465020576131688, self.xoffset: -7503253, self.yscale: -24.0, self.yoffset: 144


Does this tell you anything? What can I do to resolve this problem (without switching this feature off)?

As a side remark: in my installation of "WeeWX: Installation using setup.py" I use the native GW1000 driver. Only in the docker image I left everything as it was and continue to use the interceptor driver.

Thank you very much!

Tom Keffer

unread,
Apr 3, 2023, 7:04:27 PM4/3/23
to weewx...@googlegroups.com
The error seems to be peculiar to the most recent version of Pillow. If I hardwire in your values and use any version prior to 9.5.0, it runs without errors. If I use Pillow 9.5.0, I get the same error as you. I see nothing in the 9.5.0 release notes that mentions anything related to draws.

Pillow 9.5.0 was just posted 1 April. Maybe it's an April Fool's joke? 

More likely, it's being stricter about the ordering of the box coordinates, but they didn't mention that in the release notes.

What version of Pillow are you using? I assume 9.5.0

python3 -c "import PIL;print(PIL.__version__)"

and

python3 -m pip list | grep Pillow

I've created issue 862 to track.

In the meantime, I'd suggest using Pillow 9.4.0.

-tk

--
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 weewx-user+...@googlegroups.com.

Tom Keffer

unread,
Apr 3, 2023, 7:12:25 PM4/3/23
to weewx...@googlegroups.com

I'm sure they broke a lot of code with this change.

Tom Keffer

unread,
Apr 3, 2023, 10:01:54 PM4/3/23
to weewx...@googlegroups.com
Fixed in commit 48f6053

-tk

c s (224)

unread,
Apr 4, 2023, 3:33:53 AM4/4/23
to weewx-user
Thank you very much for digging deeper! My solution will then be to simply install an older version of the Pillow library. Thanks a lot!

c s (224) schrieb am Montag, 3. April 2023 um 13:18:39 UTC+2:

Marius Schamschula

unread,
Apr 11, 2023, 5:01:59 PM4/11/23
to weewx-user
I ran into the same error after a routine update to FreeBSD 13.1 packages.

I applied the patch and reinstalled weewx 4.10.2, and all is again working as expected!

seano...@gmail.com

unread,
May 21, 2023, 3:35:00 AM5/21/23
to weewx-user
Hi,

I seem to be having this same error but I don't understand exactly how to rectify it. Please can you explain in a simple way how to apply the patch?

Appreciate it, thank you.

c s (224)

unread,
May 22, 2023, 2:05:05 AM5/22/23
to weewx-user
Which installation method are you using? If you install the python package then "pip3 install Pillow==9.4.0" will help to install the previous Pillow library that is working. Or you upgrade to the newest version of weewx, where the issue was fixed. I hope that helps ...

gjr80

unread,
May 23, 2023, 9:52:57 PM5/23/23
to weewx-user
If you are running the current WeeWX release you should be fairly safe in downloading the patched utilities.py in place of your current version. To do this:

1. move aside your current utilities.py so your can revert to it if you run into catastrophic problems, for a WeeWX package install:

$ sudo mv /usr/share/weewx/weeplot/utilities.py /usr/share/weewx/weeplot/utilities_orig.py 

if you have a setup.py install use /home/weewx/bin in place of /usr/share/weewx

2. download the patched utilities.py from GitHub, for a WeeWX package install:


again, if you have a setup.py install use /home/weewx/bin in place of /usr/share/weewx

3. restart WeeWX

If you mess up the process simply copy utilities_orig.py back as utilities.py and restart WeeWX.

Gary

Joseph Verreau

unread,
Jan 10, 2024, 6:49:37 PM1/10/24
to weewx-user
thanks to all for their help on this one.  I see it didn't present on my installation until Nov 25th and I didn't notice it right away to boot but all is humming again.
Reply all
Reply to author
Forward
0 new messages