element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Fighting Germs
  • Challenges & Projects
  • Project14
  • Fighting Germs
  • More
  • Cancel
Fighting Germs
Blog Corona Chart – Building an Information Display with the Pi
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Fighting Germs to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: shabaz
  • Date Created: 26 Mar 2020 4:22 PM Date Created
  • Views 4126 views
  • Likes 19 likes
  • Comments 24 comments
  • python
  • rpibeginner
  • fightinggermsch
  • covid-19
  • raspberrypi
  • rpi
  • coronavirus
  • corona virus
  • cvid-health
Related
Recommended

Corona Chart – Building an Information Display with the Pi

shabaz
shabaz
26 Mar 2020

Introduction

This project builds a coronavirus chart for the Pi. There is a 7-minute video to explain it:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Here in the UK, most of the newspaper organisations and journalists (if you can call them that) behave like sycophants toward the government. We don’t get the information we need to keep ourselves safe. Instead, we get told to keep mixing and attending public events until it’s too late. Here almost two months of advance notice was squandered while China and then Italy suffered. Our leader is an outright clown, there’s no two ways of seeing it. The government actions which were universally condemned worldwide, initially encouraged ‘herd immunity’ and will now result in massive quantities of deaths.

 

Looking at (say) charts in the Financial Times, it is easy to further fool oneself that the trend for your country is pretty much the same as any other country.

Image snippet: ft.com, fair use to explain the problem with their chart..image

 

Looking closer, it becomes clear that the chart vertical axis is actually logarithmic. Mathematically it may be understandable, but log charts are not understood by everyone. Is the chart deliberately intended to confuse? I think it is – it’s just a personal opinion of course. But what I do know, is when a non-log chart was shown to a sample of friends, they were astonished at what they saw.

 

You’d think that perhaps the official government websites could be helpful here, but that’s not true. The UK government website merely displays a few numbers presenting a static view. That’s extremely useless for anyone who wishes to see what trajectory the country is on. The 'number of cases' in no way represents the real situation either, since the quantity of testing is low.

Image snippet: UK government site, to explain the pointlessness of their informationimage

 

 

It’s very sad, but it is now down to individuals to chart the information they want or feel they need, at this important time.

Here’s what the situation really looks like, as of 24th March 2020, for a few countries. This is actual deaths over time, it is not some prediction based on a low volume of testing, and it is on an clear unambiguous scale. On the chart, the starting point per country, and precisely what countries are plotted, is down to us.

image

The result is frightening.

Zooming in closer, we can now see the exceptionally mediocre state certain countries are in, and the direct consequences of poor and deliberate government decisions and the squandered time. No wonder the newspapers and the government didn’t want it to be easily visible.

image

 

This project aims to chart the deaths from coronavirus independently from the newspaper charts, and allow navigation through pan and zoom. This project has been tested on a laptop running Linux, and on a Raspberry Pi. The reason to use the Pi is to convert it into a standard ‘kiosk-like’ device with a permanently attached touchscreen for all interactivity. At power-on the Pi will automatically fetch the latest data and chart it onto the screen, ready for navigation. No physical keyboard or mouse is used.

 

This project is suitable for use in any country, and the desired countries of interest can be modified in the code.

image

 

How it Works

This project takes the latest data set from John Hopkins Center for Systems Science and Engineering  (CSSE). Python code is used to parse it, pull out the countries of interest and then chart it using a library called MatPlotLib.

 

When the code is run, it will automatically download the dataset, process it and then generate the chart rendered onto the screen, ready for browsing or for grabbing a screenshot / saving to a file.

 

Installing and Running the Code

To get going, at a command prompt (from any Linux machine such as a Pi, or from Windows PowerShell) confirm that Python 3.x is installed (type python3 -h and confirm you get useful output; if you don’t then install Python as superuser by typing (on many Linux systems) apt-get update and then apt-get install python3 or go to the Microsoft Windows Store and search and install from there) and then type the following. If you get an error indicating that you do not have git installed then install that too! Type as superuser apt-get install git or on Windows click here to download git. 

 

pip3 install requests
pip3 install numpy
pip3 install matplotlib
mkdir -p ~/development/covid
cd development/covid
git clone https://github.com/shabaz123/coronachart1.git
cd coronachart1

 

That’s it, the software is now installed. It’s just a single file called app.py.

You can run it by typing:

 

python3 ./app.py

 

You should see a chart appear such as the example ones shown earlier.

 

Modifying the Code

The code relies on a CSV file that is automatically downloaded from the John Hopkins CSSE github page. CSV files can be examined in a text editor or Excel. You’ll see that there is a row per country, and the columns indicate number of deaths per day. You’ll have to scroll to the right to see the values rising.

 

If you open up app.py in a text editor, you’ll see lines with country names in them. They can be modified to add or remove countries. To add new countries, run the code at least once so that the CSV dataset gets downloaded to the folder you’re in. Then, open up the CSV file in Excel, and search it to find the line number. If you don’t have excel, you can use grep to search for a country name, for instance the following command reveals that Italy is in row 139 in the CSV file:

 

grep -ni "Italy" *.csv

 

Kiosk Mode

If you have a screen to attach to a Pi (either via the HDMI connector, or a plug-on display such as the Pi Capacitive Display or any of the various plug-on displays, then the Pi can be set up so that it automatically does just one task – display the chart. This is ideal if you wish to permanently dedicate a Pi and display for this purpose – perhaps as an information board with future enhancements.

 

To convert the Pi to work as a standalone kiosk-type appliance, follow the steps here: Home Automation in the UK Simplified, Part 2: Raspberry Pi and Touch Display

in the section titled Building a ‘kiosk mode’ for the Pi and Display. Ignore the initial steps related to Node-RED.

 

Incidentally, in the file called midori_start.sh, you can replace the text http://127.0.0.1:1880/ui with a news URL such as (say) http://www.bbc.co.uk/news if you wanted your kiosk mode device to permanently display the news. For this project, the Pi will display a chart instead.

 

Issue the following commands. The aim is to create a startup script that will run the Python code:

 

cd ~
cp midori_start.sh app_start.sh

 

Edit the app_start.sh file and replace the last line with the following two lines:

 

cd ~/development/covid/coronachart1
/usr/bin/python3 ./app.py

 

Next, edit your .bashrc file. Replace this line:

 

xinit ./midori_start.sh

 

with:

 

xinit ./app_start.sh

 

Now whenever the Pi is restarted (as superuser use the shutdown or reboot command!) the Pi will automatically display a progress bar as it waits for the network connectivity to become available, and then it will run the Python application which will download the latest data and chart it.

 

If you have a touchscreen, there are controls at the bottom of the display to be able to perform pan and zoom by then touching and dragging in the chart area.

 

Doing Useful Things with it

I hope people can make use of the kiosk chart or news facilities to present information in store windows. It would be great to hear if people manage to represent the news information in a readable manner, or translated into different languages for those who will be feeling lost in those countries where governments are not making the effort to assist them.

 

Also, please share any interesting code modifications, as well as any interesting charts you generate, here and to other friends so they can see useful information too.

 

Thanks for reading!

  • Sign in to reply

Top Comments

  • fmilburn
    fmilburn over 5 years ago +6
    Hi Shabaz, Very useful and I was able to get it going on my Pi in just minutes. It is also a great example of an application where Python shines. Thanks for posting.
  • shabaz
    shabaz over 5 years ago in reply to fmilburn +5
    Hi Frank, This is great! Thanks for testing out the code. It's certainly not data any of us would want to see visualised in an ideal world, but better to see it to be prepared. Incidentally, I tried it…
  • shabaz
    shabaz over 5 years ago in reply to cstanton +5
    Today's chart (the data source is refreshed at midnight, so this is as of 15 hours ago): Italy is still a straight line off the chart at about 11,000 deaths. It is the dark green line at the top. Light…
  • shabaz
    shabaz over 4 years ago

    Just as a small update, the code is currently broken due to a change in the source data format : ( It will need fixing but hopefully the change is minor.

     

    Also, there's another data set called VAERS, it reports adverse vaccine reactions and deaths. It requires experts to make real use of it, since it is easy to come up with incorrect assumptions based on just looking at a few numbers.

    Anyway, for what it's worth, there is some very simple Python code to begin looking at the data, here: https://github.com/shabaz123/vaers-insight

     

    Also this story is maybe relevant!

    (image source: unknown, popular via social media, will remove if anyone requests me to do so).image

    • Cancel
    • Vote Up +5 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 5 years ago in reply to cstanton

    That would be very cool : ) Even for other scenarios, having blog posts that can dynamically update an image could be interesting..

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • cstanton
    cstanton over 5 years ago in reply to shabaz

    I wouldn't be surprised if you could get it to automatically take a snapshot and update the post using the Jive API.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • aspork42
    aspork42 over 5 years ago in reply to genebren

    Yes, if you want to talk about wasting valuable time... Our president here in the US keeps talking about America First. Didn't realize that this is what he meant!

    Great project! I'll have to try it out image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 5 years ago in reply to shabaz

    And yet, somehow, this country (USA) is in a hurry to restart the economy!  I think that we should at least be flattening the curve on deaths, before we encourage people to put their lives on the line.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube