Novel coronavirus charts and numbers

Hi all,

here a small definition that uses Python and GH to query public databases for coronavirus cases and provides that data for further analysis. It’s inspired by this video by Luciano Ambrosini.

The data of some countries actually starts to look quite good.

There’s also a part that uses JSON to query the Italian more-up-to-date repository. It will prove useful for a sample in case your local data is provided in that format.
Finally, this definition purposely does not use any add-ons. However, your charts will look more beautiful with some third-party library, for example Human UI.

Note: any responsibility on decisions taken based on this data or definition is disclaimed.

coronavirus-data.gh (15.8 KB)

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

19 Likes

If you find it useful and edit this, please feel free to post your improvements here.

Hi Giulio,

Thanks for sharing!

I added a list to easily scroll through to find the index of each country
And I put the max values for each graph to get some reference.

coronavirus-data_WD.gh (19.8 KB)

Take care everyone!
-Willem

5 Likes
4 Likes

@piac @Willem what are the lower two graphs representing?

First and second derivative.

It’s the (here daily) increment of the number of the first graph (1st derivative) and the rate by which the increment is modifying (2nd derivative). These show the trends, basically. They suffer of statistical error.

1 Like

The derivative tells you how a function (in this case a sampled distribution) change at any position. If A and B are points, the change from A to B is (A-B) / dt, where dt is the change in time. So in case of the change of a position, the derivative is its velocity. And the derivative of the derivative, or second derivative, is how its velocity changes, ie, its acceleration.

2 Likes

Thanks @piac! Here’s an update that combines combines US counties into state summaries when join_regions is false, and rolls up by country when join_regions is true. Early data in the US was by county, and is now aggregated by state, so the overall time-period graphs for either didn’t make sense.

coronavirus-data_WD.gh (17.7 KB)

Thanks @piac
Here is a small Gh contribution to make fancy graphs…
I used Log scaling for heights.

Cheers

coronavirus-data_AMA.gh (32.5 KB)


9 Likes

small update !!

It now also works for death cases and recoveries ! Also displays the selection in tiltle !

coronavirus-data_AMA.gh (30.5 KB)

1 Like

I wonder why these numbers are higher, while the source is the same?
https://localfocus2.appspot.com/5e6f877460e13

update rate

Last update :

you can highlight your or any country super easily.

You will need Human plugin

coronavirus-data_AMA.gh (37.0 KB)

2 Likes

the c# component isnt working, line 22 error.
pls help
@antoinemaes

thanks
triptonicart

Ok so these (python) components are from Giulio Piacentino… I’m not on the same python level :upside_down_face:

But as I understand it, there is a mistake in the data, where information is missing (empty spot in one list that does not convert to integer). That maybe could be fixed by some python magicians (any idea @piac ?)

While waiting for that, as a python noob, when there are errors, I simply pass them :sweat_smile:
Here is a working version… This should be ok, but I don’t really know what is being thrown by my “try/except” combo. (if anyone could enlighten me, please do !)
coronavirus-data_AMA.gh (39.1 KB)

from io import StringIO as s
import csv
import ghpythonlib.treehelpers as th

f = s(x)
reader = csv.reader(f, delimiter=',')

results = dict()

count = -1
for row in reader:
    count += 1
    if count == 0: continue
    Province_State_Country = row[1] if join_regions else row[0]
    if not Province_State_Country: Province_State_Country = row[1]
    if not join_regions and Province_State_Country != row[1]: Province_State_Country = row[1] + ", " + Province_State_Country
    
    raw_vals = row[4:]
    
    if Province_State_Country in results:
        prevs = results[Province_State_Country]
        #print(raw_vals)
        
        try:
            extra = [(int(c) + prevs[i]) for (i,c) in enumerate(raw_vals)]
        except (ValueError):
            pass
        values = extra
        #
    else:
        try:
            values = [int(c) for c in raw_vals]
        except(ValueError):
            pass
    results[Province_State_Country] = values

results = sorted(results.items(), key = lambda kv: kv[0])
a = [n[0] for n in results]
b = th.list_to_tree([n[1] for n in results])

Just updated AMA’s file with the new modified source in the CSSEGISandData repository.

coronavirus-data_AMA_2.gh (38.3 KB)

1 Like

Guys! is there any way to updated the source files?
thanks in advance!