Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # IMPORTANT! This Python script has one dependancy, simply paste this line into the terminal to install it!
- # sudo apt-get install imagemagick -y
- #
- # Next, make a folder on your Raspberry pi: /home/pi/pyscripts/wxgif/ (you probably have /home/pi/ already!)
- # Save this script into that folder.
- #
- # WXGIF python3 script by Scott Hather - Run this every hour (using Crontab) and it will download the latest
- # Weather satellite image of europe, then it grabs the latest 12 captured images and compiles them into
- # an animated GIF for your viewing pleasure!
- from subprocess import call
- from subprocess import check_output
- import datetime
- import os.path
- import shutil
- # first get the hour as an integer
- hr=datetime.datetime.now().time().hour
- mn=0
- fn=str(hr).zfill(2)+str(mn).zfill(2) # the time in format 1300 1400 etc.
- # grab this hour's Infra-red satellite image
- call("wget --no-cache -O /home/pi/pyscripts/wxgif/wx"+fn+".jpg http://oiswww.eumetsat.org/IPPS/html/latestImages/EUMETSAT_MSG_IR039E-westernEurope.jpg",shell=True)
- # also, during daylight hours, grab the Visual image too
- if hr>=8 and hr <=16:
- call("wget --no-cache -O /home/pi/pyscripts/wxgif/wxv"+fn+".jpg http://oiswww.eumetsat.org/IPPS/html/latestImages/EUMETSAT_MSG_VIS006E-westernEurope.jpg",shell=True)
- # fiddle with the hours and set things up a bit
- xhr=hr-12
- if xhr<0:
- xhr=xhr+24
- jpgfiles=""
- jpgfilesv=""
- got=""
- # Compile the last 12 images IR and VIS into animated GIFs
- for i in range(0,12):
- xhr=xhr+1
- if xhr >23:
- xhr=xhr-24
- # IR
- ff="wx"+str(xhr).zfill(2)+"00.jpg"
- fn="/home/pi/pyscripts/wxgif/"+ff
- print("Checking for "+fn)
- if os.path.isfile(fn):
- print("Got "+fn)
- jpgfiles=jpgfiles+fn+" "
- else:
- print(fn+" DOES NOT EXIST, but that's ok")
- # VISUAL
- ffv="wxv"+str(xhr).zfill(2)+"00.jpg"
- fnv="/home/pi/pyscripts/wxgif/"+ffv
- print("Checking for "+fnv)
- if os.path.isfile(fnv):
- print("Got "+fnv)
- got=fnv
- jpgfilesv=jpgfilesv+fnv+" "
- #IR Hold last image for 10 frames
- for j in range(0,10):
- jpgfiles=jpgfiles+fn+" "
- #VISUAL Hold last image for 10 frames
- for j in range(0,10):
- jpgfilesv=jpgfilesv+got+" "
- print("Converting to animated gif...")
- call("convert -delay 1 -loop 0 "+jpgfiles+"/home/pi/pyscripts/wxgif/latest-anim.gif",shell=True)
- if hr>=8 and hr <=17:
- call("convert -delay 1 -loop 0 "+jpgfilesv+"/home/pi/pyscripts/wxgif/latest-animv.gif", shell=True)
- # All done!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement