Author Topic: Cloud Cover  (Read 3135 times)

0 Members and 1 Guest are viewing this topic.

Offline marshad

  • Member
  • *
  • Posts: 22
Cloud Cover
« on: July 18, 2019, 06:58:02 AM »
Measuring cloud cover seems to be an area neglected by most amateur weather enthusiasts (or am I wrong?)
 
The problem is how to measure it. If you are lucky enough to have a METAR close by (which I haven't), you could use this as a proxy. Or use an api such as darksky to get the current conditions, but my experience is that this can be highly inaccurate. Or you could look up every half hour and record the oktas manually - but life is too short.

Instead what if you could take the latest satellite image of your location and analyse the pixels directly over your station? I have written a program in Python to do just this (I am a totally amateur programmer btw). It takes an image every 15 mins from Sat24.com, converts it to grayscale and then looks at the values of the pixels in a 10x10 pixel box above my location and returns an average. The range is 0 for black to 255 white. It is then a case of calibrating it by looking at the values of a totally clear sky and a totally overcast sky.

I have had it running for about a month now and it is remarkably accurate with the visible satellite images, slightly less so for the infrared. I am storing the data in weewx - sample chart attached.

If anybody thinks this has any merit I would be happy to share the program and would welcome any improvements from more experienced programmers.
 [ You are not allowed to view attachments ]
http://moonappreciationsociety.com/Meteo/VillarPerosa/

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: Cloud Cover
« Reply #1 on: July 18, 2019, 08:45:03 AM »
Very nice Marshad!

It would also be interesting to compare that to a sunrecorder like the Blake-Larsen.  Unfortunately I have not yet been able to reconnect mine after our move to a new home.

Enjoy,
Paul

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Re: Cloud Cover
« Reply #2 on: July 18, 2019, 05:43:23 PM »
Quote
Instead what if you could take the latest satellite image of your location and analyse the pixels directly over your station
This has great potential for eg. 'latest obs' or various forecasting scripts or .....

Keep us informed  [tup]
Imagine what you will KNOW tomorrow !

Offline marshad

  • Member
  • *
  • Posts: 22
Re: Cloud Cover
« Reply #3 on: July 18, 2019, 06:22:16 PM »
Thanks Paul and beteljuice.

The script was surprisingly simple to put together and yes I agree it could be used for other things - thinking also about radar images.

David

http://moonappreciationsociety.com/Meteo/VillarPerosa/

Offline marshad

  • Member
  • *
  • Posts: 22
Re: Cloud Cover
« Reply #4 on: July 18, 2019, 07:07:23 PM »
Quote
Instead what if you could take the latest satellite image of your location and analyse the pixels directly over your station
This has great potential for eg. 'latest obs' or various forecasting scripts or .....

Keep us informed  [tup]

Perhaps I didn't make it clear enough that this is working now and happy to share it with anyone wanting to try it.

http://moonappreciationsociety.com/Meteo/VillarPerosa/

Offline Bushman

  • Forecaster
  • *****
  • Posts: 7549
    • Eagle Bay Weather
Re: Cloud Cover
« Reply #5 on: July 18, 2019, 07:52:22 PM »
Well done!  There was someone here who did the same thing only using their local webcam image.  Can you share your Python code?
Need low cost IP monitoring?  http://wirelesstag.net/wta.aspx?link=NisJxz6FhUa4V67/cwCRWA or PM me for 50% off Wirelesstags!!

Offline marshad

  • Member
  • *
  • Posts: 22
Re: Cloud Cover
« Reply #6 on: July 19, 2019, 08:44:43 AM »
Ok for brevity I am assuming that people know how to get a image from a url at regular intervals.

You can create a url with the satellite image centred on your location here: https://en.sat24.com/en/freeimages

Use the 300x300px option.

Here is the python code (with apologies to real python programmers)

# Important the python PIL library needs to be installed

import os, sys
import Image
import json

# This gets a value for the altitude of the Sun to decide which image to use
# You could use time instead if you haven't got access to a similar value
almanac = open('/var/www/html/VillarPerosa/jsondata/almanac.txt')
data = json.load(almanac)
sun = data["sunalt"]
almanac.close()

pixarray = []

# change the filepaths to the location of the images
if sun > 8:
    im = Image.open("/var/www/html/VillarPerosa/sat1.png")
 
else:
    im = Image.open("/var/www/html/VillarPerosa/sat2.png")
   
# this converts the image to grayscale   
im = im.convert('L')

# coordinates for the box at the centre of the image
xpos1 = 145
xpos2 = 155
ypos1 = 145
ypos2 = 155


pix = im.load()

# creates an array with the individual pixel values in the box
for y in range(ypos1,ypos2):
    for x in range(xpos1,xpos2):

        pixarray.append(pix[x,y])
      
# takes the average
pixavg = sum(pixarray) / float(len(pixarray))

# calibration, min = totally clear, max = totally overcast
min = 50
max = 250

# an adjustment to align the infrared sat with the visible       
adj =  60 * (255 - pixavg)/255
s = pixavg + adj

if sun > 8:
    s = pixavg

# cloud cover %   
s = (s - min)*100/(max - min)

# result written to a txt file for import into the weewx database.
text_file = open("cloud.txt", "w")
text_file.write(str(s))
text_file.close()   

im.close()

Good luck with it!

http://moonappreciationsociety.com/Meteo/VillarPerosa/

Offline noctilucent

  • Senior Member
  • **
  • Posts: 88
Re: Cloud Cover
« Reply #7 on: January 14, 2021, 05:03:17 AM »
What dashboard software are you using to display all that?  It looks pretty impressive.

 

anything