[Flow] COVID-19 country history charts based on total tests

I have found a cool github repository maintained by Our World in Data that is also reporting the total tests performed per day.

Based on this I have created a node-red flow that allows to compare percentage of confirmed cases (with respect to the tests performed) over time between 2 countries.

E.g. a comparison between the US and Italy.

Observations

  1. The first chart clearly shows that Italy is on the right track and is currently in a way better situation than the US.
  2. For the US the % of new cases is hardly decreasing since the last 3 weeks which is concerning.

Remind that in Hubei (China) they only gradually started reopening schools when no confirmed cases were being reported for a period of more than 2 weeks (in other words the top chart was 0% for 2 weeks). Most countries are months away from the 0%.

Here below the flow which you can also copy from janvda/node-red-covid-our-world-in-data:

[{"id":"3a9fb996.bbe926","type":"tab","label":"owid-covid-data","disabled":false,"info":""},{"id":"c3387945.6987c8","type":"inject","z":"3a9fb996.bbe926","name":"Run flow","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":140,"y":100,"wires":[["c010259.2cf98d8","bddf1478.9b09c8"]]},{"id":"c010259.2cf98d8","type":"http request","z":"3a9fb996.bbe926","name":"get owid-covid-data.csv","method":"GET","ret":"txt","paytoqs":false,"url":"https://github.com/owid/covid-19-data/raw/master/public/data/owid-covid-data.csv","tls":"","persist":false,"proxy":"","authType":"","x":390,"y":100,"wires":[["4c5e0107.81dd"]]},{"id":"4c5e0107.81dd","type":"csv","z":"3a9fb996.bbe926","name":"csv2array","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"x":580,"y":100,"wires":[["99fb2113.37e54","c8dbff0d.cef35"]]},{"id":"c826db11.2bca08","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":1,"width":13,"height":6,"label":"%new cases (with respect to new tests)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#942192","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":840,"y":660,"wires":[[]]},{"id":"99fb2113.37e54","type":"debug","z":"3a9fb996.bbe926","name":"owid-covid-data json","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":800,"y":100,"wires":[]},{"id":"c8dbff0d.cef35","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"covid_data","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":160,"wires":[["bc39bac.e135f48","9b88f1d0.e8c99","185638b4.45eab7"]]},{"id":"f211e551.667b68","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"location1","pt":"msg","to":"location1","tot":"flow"},{"t":"set","p":"location2","pt":"msg","to":"location2","tot":"flow"},{"t":"set","p":"covid_data","pt":"msg","to":"covid_data","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t   $location1 := location1;\t   $location2 := location2;\t   {\t       \"location1\" : \t        covid_data[location=$location1 and new_tests>0].{\t           \"date\" : date,\t           \"new_cases\" : new_cases,\t           \"new_tests\" : new_tests,\t           \"positive_test_percentage\" : $round(\t               new_cases / new_tests * 100 ,2),\t            \"total_cases\" : total_cases,\t            \"total_tests\" : total_tests,\t            \"population_in_thousand\": ($location1=\"United Kingdom\" ? 66573:\t                                       total_cases*1000/total_cases_per_million)\t      },\t     \"location2\":         covid_data[location=$location2 and new_tests>0].{    \t            \"date\" : date,     \t            \"new_cases\" : new_cases,     \t            \"new_tests\" : new_tests,     \t            \"positive_test_percentage\" : $round(new_cases / new_tests * 100 ,\t               2\t           ),\t           \"total_cases\" : total_cases,\t           \"total_tests\" : total_tests,\t           \"population_in_thousand\": ($location2=\"United Kingdom\" ? 66573:\t                                      total_cases*1000/total_cases_per_million)\t      }\t   }\t)\t/* see https://try.jsonata.org/WEDEzGOBb  */","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":460,"wires":[["d6412970.f37978","ce16a18e.14da5"]]},{"id":"d6412970.f37978","type":"debug","z":"3a9fb996.bbe926","name":"covid data for location1 and location2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":850,"y":460,"wires":[]},{"id":"d04b500a.baa45","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1, location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : positive_test_percentage \t               }\t           ],\t           [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : positive_test_percentage \t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":660,"wires":[["c826db11.2bca08","f19b43a3.24f15"]]},{"id":"f19b43a3.24f15","type":"debug","z":"3a9fb996.bbe926","name":"chart1 input","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":620,"wires":[]},{"id":"44dcda4e.51f944","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":2,"width":13,"height":5,"label":"new tests per thousand (population)","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#942192","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":830,"y":700,"wires":[[]]},{"id":"9476a458.94ece8","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1, location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_tests_per_thousand \t               }\t           ],\t           [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_tests_per_thousand\t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":700,"wires":[["44dcda4e.51f944"]]},{"id":"5819eb08.df1c14","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":3,"width":13,"height":"5","label":"new (confirmed) cases per thousand (population)","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#942192","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":870,"y":740,"wires":[[]]},{"id":"d308a880.137648","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1,location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_cases_per_thousand\t               }\t           ],\t                      [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_cases_per_thousand\t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":740,"wires":[["5819eb08.df1c14"]]},{"id":"cdd81598.25c3b8","type":"ui_dropdown","z":"3a9fb996.bbe926","name":"location1 dropdown","label":"location1","tooltip":"","place":"Select option","group":"7075490e.7cac28","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":540,"y":260,"wires":[["2203fb23.dd7704"]]},{"id":"bc39bac.e135f48","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload[new_tests>0].location ~> $distinct ~> $sort","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":120,"y":300,"wires":[["2753fa25.e238a6","6af92528.bf095c"]]},{"id":"2203fb23.dd7704","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"location1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":260,"wires":[["8ba29581.5d84f8"]]},{"id":"2753fa25.e238a6","type":"change","z":"3a9fb996.bbe926","name":"set to Belgium","rules":[{"t":"set","p":"payload","pt":"msg","to":"Belgium","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":260,"wires":[["cdd81598.25c3b8"]]},{"id":"6af92528.bf095c","type":"change","z":"3a9fb996.bbe926","name":"set to Italy","rules":[{"t":"set","p":"payload","pt":"msg","to":"Italy","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":320,"wires":[["efd55a63.c3a458"]]},{"id":"efd55a63.c3a458","type":"ui_dropdown","z":"3a9fb996.bbe926","name":"location1 dropdown","label":"location2","tooltip":"","place":"Select option","group":"7075490e.7cac28","order":2,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":540,"y":320,"wires":[["39013f83.273c5"]]},{"id":"39013f83.273c5","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"location2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":320,"wires":[["d35aba75.cd02f8"]]},{"id":"c5ba297f.3149a8","type":"ui_button","z":"3a9fb996.bbe926","name":"","group":"7bc90a44.ed8dd4","order":1,"width":0,"height":0,"passthru":false,"label":"retrieve owid-covid-data","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":60,"wires":[["c010259.2cf98d8"]]},{"id":"d35aba75.cd02f8","type":"switch","z":"3a9fb996.bbe926","name":"flow.location1 not null ?","property":"location1","propertyType":"flow","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":480,"wires":[["f211e551.667b68"]]},{"id":"8ba29581.5d84f8","type":"switch","z":"3a9fb996.bbe926","name":"flow.location2 not null ?","property":"location2","propertyType":"flow","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":440,"wires":[["f211e551.667b68"]]},{"id":"ce16a18e.14da5","type":"change","z":"3a9fb996.bbe926","name":"running average","rules":[{"t":"set","p":"running_average_days","pt":"msg","to":"running_average_days","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t  $x := running_average_days;\t{\t \"location1\" : payload.location1 ~> $map( function($v, $i, $a) \t     { \t        (\t          $v_min_x := $a[$i-$x]; /* take care this is circular !*/\t          $new_cases := ($v.total_cases - $v_min_x.total_cases)/$x;\t          $new_tests := ($v.total_tests - $v_min_x.total_tests)/$x;\t          \t          {\t            \"date\" : ($toMillis($v.date) + $toMillis($v_min_x.date))/2 ~> $fromMillis(),\t            \"new_cases_per_thousand\" : $new_cases/$v.population_in_thousand,\t            \"new_tests_per_thousand\" : $new_tests/$v.population_in_thousand,\t            \"positive_test_percentage\": $new_cases*100/$new_tests ~> $round(2)\t          }\t        )\t     }) ~> $filter (function($v, $i, $a) { $i>=$x}),\t  \"location2\": payload.location2 ~> $map( function($v, $i, $a) \t     { \t        (\t          $v_min_x := $a[$i-$x]; /* take care this is circular !*/\t          $new_cases := ($v.total_cases - $v_min_x.total_cases)/$x;\t          $new_tests := ($v.total_tests - $v_min_x.total_tests)/$x;\t          \t          {\t            \"date\" : ($toMillis($v.date) + $toMillis($v_min_x.date))/2 ~> $fromMillis(),\t            \"new_cases_per_thousand\" : $new_cases/$v.population_in_thousand,\t            \"new_tests_per_thousand\" : $new_tests/$v.population_in_thousand,\t            \"positive_test_percentage\": $new_cases*100/$new_tests ~> $round(2)\t          }\t        )\t     }) ~> $filter (function($v, $i, $a) { $i>=$x})\t     \t}\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":520,"wires":[["d04b500a.baa45","9476a458.94ece8","d308a880.137648","529b9278.947aac"]]},{"id":"529b9278.947aac","type":"debug","z":"3a9fb996.bbe926","name":"running average","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":760,"y":520,"wires":[]},{"id":"4b0da2ab.fc904c","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"running_average_days","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":40,"wires":[["f211e551.667b68"]]},{"id":"bddf1478.9b09c8","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"7","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":40,"wires":[["a3a09f70.89765"]]},{"id":"15636a9d.bbd545","type":"ui_text_input","z":"3a9fb996.bbe926","name":"","label":"max date in data set","tooltip":"","group":"7bc90a44.ed8dd4","order":3,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1060,"y":160,"wires":[[]]},{"id":"9b88f1d0.e8c99","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$max(payload.$toMillis(date))~>$fromMillis()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":160,"wires":[["15636a9d.bbd545"]]},{"id":"79b611ae.ae3ec","type":"ui_text_input","z":"3a9fb996.bbe926","name":"","label":"last time date retrieved","tooltip":"","group":"7bc90a44.ed8dd4","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1140,"y":220,"wires":[[]]},{"id":"185638b4.45eab7","type":"change","z":"3a9fb996.bbe926","name":"get timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"$now()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":220,"wires":[["79b611ae.ae3ec"]]},{"id":"a3a09f70.89765","type":"ui_slider","z":"3a9fb996.bbe926","name":"","label":"running average number of days:","tooltip":"","group":"7075490e.7cac28","order":3,"width":0,"height":0,"passthru":true,"outs":"end","topic":"","min":"1","max":"20","step":1,"x":700,"y":40,"wires":[["4b0da2ab.fc904c"]]},{"id":"828b3fe0.ce8ff","type":"ui_group","z":"","name":"charts","tab":"e3251669.740868","order":2,"disp":false,"width":"13","collapse":false},{"id":"7075490e.7cac28","type":"ui_group","z":"","name":"Filter","tab":"e3251669.740868","order":1,"disp":true,"width":"6","collapse":false},{"id":"7bc90a44.ed8dd4","type":"ui_group","z":"","name":"github","tab":"e3251669.740868","order":3,"disp":true,"width":"6","collapse":false},{"id":"e3251669.740868","type":"ui_tab","z":"","name":"owid-covid-data","icon":"dashboard","order":9,"disabled":false,"hidden":true}]

Any feedback, comments, improvements suggestions are more than welcome.
Jan.

4 Likes

I have updated the flow:

[{"id":"3a9fb996.bbe926","type":"tab","label":"owid-covid-data","disabled":false,"info":""},{"id":"c3387945.6987c8","type":"inject","z":"3a9fb996.bbe926","name":"Run flow","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":160,"y":120,"wires":[["c010259.2cf98d8","bddf1478.9b09c8"]]},{"id":"c010259.2cf98d8","type":"http request","z":"3a9fb996.bbe926","name":"get owid-covid-data.csv","method":"GET","ret":"txt","paytoqs":false,"url":"https://covid.ourworldindata.org/data/owid-covid-data.csv","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":120,"wires":[["164fca1a.bdcc36"]]},{"id":"4c5e0107.81dd","type":"csv","z":"3a9fb996.bbe926","name":"csv2array","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"x":600,"y":160,"wires":[["99fb2113.37e54","c8dbff0d.cef35"]]},{"id":"c826db11.2bca08","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":2,"width":"12","height":"7","label":"%new cases (with respect to new tests)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#009051","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":600,"y":900,"wires":[[]]},{"id":"99fb2113.37e54","type":"debug","z":"3a9fb996.bbe926","name":"owid-covid-data json","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":820,"y":160,"wires":[]},{"id":"c8dbff0d.cef35","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"covid_data","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":220,"wires":[["bc39bac.e135f48","9b88f1d0.e8c99","185638b4.45eab7"]]},{"id":"f211e551.667b68","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"location1","pt":"msg","to":"location1","tot":"flow"},{"t":"set","p":"location2","pt":"msg","to":"location2","tot":"flow"},{"t":"set","p":"covid_data","pt":"msg","to":"covid_data","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t   $location1 := location1;\t   $location2 := location2;\t   {\t       \"location1\" : \t        covid_data[location=$location1 and new_tests>0].{\t           \"date\" : date,\t           \"new_cases\" : new_cases,\t           \"new_tests\" : new_tests,\t           \"positive_test_percentage\" : $round(\t               new_cases / new_tests * 100 ,2),\t            \"total_cases\" : total_cases,\t            \"total_tests\" : total_tests,\t            \"population_in_thousand\": ($location1=\"United Kingdom\" ? 66573:\t                                       $location1=\"Israel\" ? 8884 :\t                                       $location1=\"Czech Republic\" ? 10650 :\t                                       $location1=\"Iceland\" ? 364 :\t                                       total_cases*1000/total_cases_per_million)\t      },\t     \"location2\":         covid_data[location=$location2 and new_tests>0].{    \t            \"date\" : date,     \t            \"new_cases\" : new_cases,     \t            \"new_tests\" : new_tests,     \t            \"positive_test_percentage\" : $round(new_cases / new_tests * 100 ,\t               2\t           ),\t           \"total_cases\" : total_cases,\t           \"total_tests\" : total_tests,\t           \"population_in_thousand\": ($location2=\"United Kingdom\" ? 66573:\t                                      $location2=\"Israel\" ? 8884 :\t                                      $location2=\"Czech Republic\" ? 10650 :\t                                      $location2=\"Iceland\" ? 364 :\t                                      total_cases*1000/total_cases_per_million)\t      }\t   }\t)\t/* see https://try.jsonata.org/WEDEzGOBb  */","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":520,"wires":[["d6412970.f37978","ce16a18e.14da5"]]},{"id":"d6412970.f37978","type":"debug","z":"3a9fb996.bbe926","name":"covid data for location1 and location2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":870,"y":520,"wires":[]},{"id":"d04b500a.baa45","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1, location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : positive_test_percentage \t               }\t           ],\t           [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : positive_test_percentage \t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":900,"wires":[["c826db11.2bca08"]]},{"id":"44dcda4e.51f944","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":1,"width":"12","height":4,"label":"new tests per thousand (population)","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#009051","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":590,"y":860,"wires":[[]]},{"id":"9476a458.94ece8","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1, location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_tests_per_thousand \t               }\t           ],\t           [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_tests_per_thousand\t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":860,"wires":[["44dcda4e.51f944"]]},{"id":"5819eb08.df1c14","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":3,"width":"12","height":"7","label":"new (confirmed) cases per thousand (population)","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#76d6ff","#00f900","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":630,"y":940,"wires":[[]]},{"id":"d308a880.137648","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1,location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_cases_per_thousand\t               }\t           ],\t                      [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_cases_per_thousand\t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":940,"wires":[["5819eb08.df1c14"]]},{"id":"cdd81598.25c3b8","type":"ui_dropdown","z":"3a9fb996.bbe926","name":"location1 dropdown","label":"location1","tooltip":"","place":"Select option","group":"7075490e.7cac28","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":560,"y":320,"wires":[["2203fb23.dd7704"]]},{"id":"bc39bac.e135f48","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload[new_tests>0].location ~> $distinct ~> $sort","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":360,"wires":[["2753fa25.e238a6","6af92528.bf095c"]]},{"id":"2203fb23.dd7704","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"location1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":320,"wires":[["8ba29581.5d84f8","21f6225a.3d4f3e"]]},{"id":"2753fa25.e238a6","type":"change","z":"3a9fb996.bbe926","name":"set to Belgium","rules":[{"t":"set","p":"payload","pt":"msg","to":"Belgium","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":320,"wires":[["cdd81598.25c3b8"]]},{"id":"6af92528.bf095c","type":"change","z":"3a9fb996.bbe926","name":"set to Italy","rules":[{"t":"set","p":"payload","pt":"msg","to":"Italy","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":380,"wires":[["efd55a63.c3a458"]]},{"id":"efd55a63.c3a458","type":"ui_dropdown","z":"3a9fb996.bbe926","name":"location1 dropdown","label":"location2","tooltip":"","place":"Select option","group":"7075490e.7cac28","order":2,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":560,"y":380,"wires":[["39013f83.273c5"]]},{"id":"39013f83.273c5","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"location2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":380,"wires":[["d35aba75.cd02f8","72a41a7c.2a5364"]]},{"id":"c5ba297f.3149a8","type":"ui_button","z":"3a9fb996.bbe926","name":"","group":"7bc90a44.ed8dd4","order":1,"width":0,"height":0,"passthru":false,"label":"retrieve owid-covid-data","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":60,"wires":[["c010259.2cf98d8"]]},{"id":"d35aba75.cd02f8","type":"switch","z":"3a9fb996.bbe926","name":"flow.location1 not null ?","property":"location1","propertyType":"flow","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":540,"wires":[["f211e551.667b68"]]},{"id":"8ba29581.5d84f8","type":"switch","z":"3a9fb996.bbe926","name":"flow.location2 not null ?","property":"location2","propertyType":"flow","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":500,"wires":[["f211e551.667b68"]]},{"id":"ce16a18e.14da5","type":"change","z":"3a9fb996.bbe926","name":"running average","rules":[{"t":"set","p":"running_average_days","pt":"msg","to":"running_average_days","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t  $x := running_average_days;\t{\t \"location1\" : payload.location1 ~> $map( function($v, $i, $a) \t     { \t        (\t          $v_min_x := $a[$i-$x]; /* take care this is circular !*/\t          $new_cases := ($v.total_cases - $v_min_x.total_cases)/$x;\t          $new_tests := ($v.total_tests - $v_min_x.total_tests)/$x;\t          \t          {\t            \"date\" : ($toMillis($v.date) + $toMillis($v_min_x.date))/2 ~> $fromMillis(),\t            \"new_cases_per_thousand\" : $new_cases/$v.population_in_thousand,\t            \"new_tests_per_thousand\" : $new_tests/$v.population_in_thousand,\t            \"positive_test_percentage\": $new_cases*100/$new_tests ~> $round(2)\t          }\t        )\t     }) ~> $filter (function($v, $i, $a) { $i>=$x}),\t  \"location2\": payload.location2 ~> $map( function($v, $i, $a) \t     { \t        (\t          $v_min_x := $a[$i-$x]; /* take care this is circular !*/\t          $new_cases := ($v.total_cases - $v_min_x.total_cases)/$x;\t          $new_tests := ($v.total_tests - $v_min_x.total_tests)/$x;\t          \t          {\t            \"date\" : ($toMillis($v.date) + $toMillis($v_min_x.date))/2 ~> $fromMillis(),\t            \"new_cases_per_thousand\" : $new_cases/$v.population_in_thousand,\t            \"new_tests_per_thousand\" : $new_tests/$v.population_in_thousand,\t            \"positive_test_percentage\": $new_cases*100/$new_tests ~> $round(2)\t          }\t        )\t     }) ~> $filter (function($v, $i, $a) { $i>=$x})\t     \t}\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":580,"wires":[["d04b500a.baa45","9476a458.94ece8","d308a880.137648","529b9278.947aac","e30083b3.51f12","43bc878f.cac668","23ef5b36.c85664"]]},{"id":"529b9278.947aac","type":"debug","z":"3a9fb996.bbe926","name":"running average","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":800,"y":580,"wires":[]},{"id":"4b0da2ab.fc904c","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"running_average_days","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":40,"wires":[["f211e551.667b68"]]},{"id":"bddf1478.9b09c8","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"7","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":40,"wires":[["a3a09f70.89765"]]},{"id":"15636a9d.bbd545","type":"ui_text_input","z":"3a9fb996.bbe926","name":"","label":"max date in data set","tooltip":"","group":"7bc90a44.ed8dd4","order":3,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1080,"y":220,"wires":[[]]},{"id":"9b88f1d0.e8c99","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$max(payload.$toMillis(date))~>$fromMillis()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":220,"wires":[["15636a9d.bbd545"]]},{"id":"79b611ae.ae3ec","type":"ui_text_input","z":"3a9fb996.bbe926","name":"","label":"last time date retrieved","tooltip":"","group":"7bc90a44.ed8dd4","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1160,"y":280,"wires":[[]]},{"id":"185638b4.45eab7","type":"change","z":"3a9fb996.bbe926","name":"get timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"$now()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":280,"wires":[["79b611ae.ae3ec"]]},{"id":"a3a09f70.89765","type":"ui_slider","z":"3a9fb996.bbe926","name":"","label":"running average number of days:","tooltip":"","group":"7075490e.7cac28","order":3,"width":0,"height":0,"passthru":true,"outs":"end","topic":"","min":"1","max":"20","step":1,"x":700,"y":40,"wires":[["4b0da2ab.fc904c"]]},{"id":"164fca1a.bdcc36","type":"switch","z":"3a9fb996.bbe926","name":"statusCode = 200 ?","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":650,"y":120,"wires":[["d29c622e.fe8b"],["4c5e0107.81dd"]]},{"id":"e1c555aa.70c088","type":"ui_toast","z":"3a9fb996.bbe926","position":"top right","displayTime":"10","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":1050,"y":80,"wires":[]},{"id":"d29c622e.fe8b","type":"change","z":"3a9fb996.bbe926","name":"set errormessage","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"Problem retrieving data (statusCode =\" & statusCode & \")\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":80,"wires":[["e1c555aa.70c088"]]},{"id":"e30083b3.51f12","type":"change","z":"3a9fb996.bbe926","name":"calculate reproduction factors","rules":[{"t":"set","p":"last_x_weeks","pt":"msg","to":"last_x_weeks","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t  $last_x_weeks          := last_x_weeks;\t  $location1_now         := payload.location1[-1];\t  $location1_x_weeks_ago := payload.location1[-1-(7*$last_x_weeks)];\t  $location2_now         := payload.location2[-1];\t  $location2_x_weeks_ago := payload.location2[-1-(7*$last_x_weeks)];\t  $location1_reproduction_rate := (($location1_now.positive_test_percentage/$location1_x_weeks_ago.positive_test_percentage) +\t                                   ($location1_now.new_cases_per_thousand/$location1_x_weeks_ago.new_cases_per_thousand))/2;\t  $location2_reproduction_rate := (($location2_now.positive_test_percentage/$location2_x_weeks_ago.positive_test_percentage) +\t                                   ($location2_now.new_cases_per_thousand/$location2_x_weeks_ago.new_cases_per_thousand))/2;\t  $location1_weekly_reproduction_rate := $power($location1_reproduction_rate, (1/$last_x_weeks));\t  $location2_weekly_reproduction_rate := $power($location2_reproduction_rate, (1/$last_x_weeks));\t  $location1_factor_to_1ppm := $location1_now.new_cases_per_thousand/0.001;\t  $location2_factor_to_1ppm := $location2_now.new_cases_per_thousand/0.001;  \t  {\t    \"location1\" : {\t          \"weekly_reproduction_rate\" :$location1_weekly_reproduction_rate~> $round(2),\t          \"reproduction_rate_for_period\" :   \t               $location1_reproduction_rate ~> $round(2),\t           \"factor_to_1ppm\": $location1_factor_to_1ppm~> $round(2)\t               },\t    \"location2\" : {\t          \"weekly_reproduction_rate\" :$location2_weekly_reproduction_rate~> $round(2),\t          \"reproduction_rate_for_period\" :   \t            $location2_reproduction_rate ~> $round(2),\t           \"factor_to_1ppm\": $location2_factor_to_1ppm~> $round(2)\t               }           \t  }\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":700,"wires":[["40ee0ab4.b257e4","9741f258.c7a","b3dd7050.4176c","bbf42cef.526c3","514dd192.00878","4516276d.16d788","aa2d19c7.809558","7eab409e.39896"]]},{"id":"40ee0ab4.b257e4","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":2,"width":0,"height":0,"name":"","label":"weekly reproduction rate","format":"{{msg.payload.location1.weekly_reproduction_rate}}","layout":"row-spread","x":1270,"y":640,"wires":[]},{"id":"9741f258.c7a","type":"debug","z":"3a9fb996.bbe926","name":"reproduction factors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1260,"y":600,"wires":[]},{"id":"b3dd7050.4176c","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":2,"width":0,"height":0,"name":"","label":"weekly reproduction rate","format":"{{msg.payload.location2.weekly_reproduction_rate}}","layout":"row-spread","x":1270,"y":680,"wires":[]},{"id":"43bc878f.cac668","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1 & \" (% new cases)\", location1 & \" (new cases)\",\t                  location2 & \" (% new cases)\", location2 & \" (new cases)\"\t       ],\t       \"data\": [\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   $a[$i+7].positive_test_percentage/$v.positive_test_percentage~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   $a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   $a[$i+7].positive_test_percentage/$v.positive_test_percentage~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   $a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":780,"wires":[["2aa1c807.351eb8"]]},{"id":"2ed1a7d.6aca758","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"e89c34cf.95af58","order":1,"width":13,"height":"7","label":"(averaged) reproduction number (assuming incubation period = 1 week)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"2","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#ff2600","#0433ff","#008f00","#00f900","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":700,"y":820,"wires":[[]]},{"id":"2aa1c807.351eb8","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"e89c34cf.95af58","order":2,"width":13,"height":"7","label":"reproduction number (assuming incubation period = 1 week)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#76d6ff","#008f00","#00f900","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":660,"y":780,"wires":[[]]},{"id":"23ef5b36.c85664","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [\"allowed max\", location1 , location2 ],\t       \"data\": [\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   1:\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   (($a[$i+7].positive_test_percentage/$v.positive_test_percentage)+\t                                    ($a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand))/2~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   (($a[$i+7].positive_test_percentage/$v.positive_test_percentage)+\t                                    ($a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand))/2~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":820,"wires":[["2ed1a7d.6aca758"]]},{"id":"1dfa56ae.c287a9","type":"ui_numeric","z":"3a9fb996.bbe926","name":"last x weeks","label":"period","tooltip":"","group":"c77dcaba.ebe128","order":1,"width":0,"height":0,"wrap":false,"passthru":true,"topic":"","format":"last {{value}} weeks","min":"1","max":10,"step":1,"x":1110,"y":440,"wires":[["ad9970be.06e94","f211e551.667b68"]]},{"id":"ad9970be.06e94","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"last_x_weeks","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":440,"wires":[[]]},{"id":"12b264a.814219b","type":"inject","z":"3a9fb996.bbe926","name":"","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":1050,"y":400,"wires":[["1dfa56ae.c287a9"]]},{"id":"bbf42cef.526c3","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":3,"width":0,"height":0,"name":"","label":"reproduction rate for period","format":"{{msg.payload.location1.reproduction_rate_for_period}}","layout":"row-spread","x":1340,"y":720,"wires":[]},{"id":"514dd192.00878","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":3,"width":0,"height":0,"name":"","label":"reproduction rate for period","format":"{{msg.payload.location2.reproduction_rate_for_period}}","layout":"row-spread","x":1340,"y":760,"wires":[]},{"id":"ae4060a7.47c75","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":540,"wires":[[]]},{"id":"21f6225a.3d4f3e","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":1,"width":0,"height":0,"name":"location1","label":"country","format":"{{msg.payload}}","layout":"row-spread","x":1340,"y":320,"wires":[]},{"id":"72a41a7c.2a5364","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":1,"width":0,"height":0,"name":"location2","label":"country","format":"{{msg.payload}}","layout":"row-spread","x":1340,"y":360,"wires":[]},{"id":"4516276d.16d788","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":4,"width":0,"height":0,"name":"","label":"factor to 1ppm","format":"{{msg.payload.location1.factor_to_1ppm}}","layout":"row-spread","x":1240,"y":800,"wires":[]},{"id":"aa2d19c7.809558","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":4,"width":0,"height":0,"name":"","label":"factor to 1 ppm","format":"{{msg.payload.location2.factor_to_1ppm}}","layout":"row-spread","x":1240,"y":840,"wires":[]},{"id":"7eab409e.39896","type":"function","z":"3a9fb996.bbe926","name":"calculate nr of weeks to 1ppm","func":"msg.location1_nr_of_weeks = -  Math.log(msg.payload.location1.factor_to_1ppm)/Math.log(msg.payload.location1.weekly_reproduction_rate);\nmsg.location2_nr_of_weeks = -  Math.log(msg.payload.location2.factor_to_1ppm)/Math.log(msg.payload.location2.weekly_reproduction_rate);\nreturn msg;","outputs":1,"noerr":0,"x":1050,"y":900,"wires":[["bb913191.10f88","326b4dad.53dc12"]]},{"id":"bb913191.10f88","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":4,"width":0,"height":0,"name":"","label":"nr of weeks to 1 ppm","format":"{{msg.location1_nr_of_weeks | number:2}}","layout":"row-spread","x":1380,"y":900,"wires":[]},{"id":"326b4dad.53dc12","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":4,"width":0,"height":0,"name":"","label":"nr of weeks to 1 ppm","format":"{{msg.location2_nr_of_weeks | number:2}}","layout":"row-spread","x":1380,"y":940,"wires":[]},{"id":"828b3fe0.ce8ff","type":"ui_group","z":"","name":"charts","tab":"e3251669.740868","order":3,"disp":false,"width":"12","collapse":false},{"id":"7075490e.7cac28","type":"ui_group","z":"","name":"Filter","tab":"e3251669.740868","order":1,"disp":true,"width":"7","collapse":false},{"id":"7bc90a44.ed8dd4","type":"ui_group","z":"","name":"github","tab":"e3251669.740868","order":2,"disp":true,"width":"6","collapse":false},{"id":"366031e1.19a67e","type":"ui_group","z":"","name":"location 1","tab":"e3251669.740868","order":6,"disp":true,"width":"6","collapse":false},{"id":"fdc57d76.7fafa","type":"ui_group","z":"","name":"location 2","tab":"e3251669.740868","order":7,"disp":true,"width":"6","collapse":false},{"id":"e89c34cf.95af58","type":"ui_group","z":"3a9fb996.bbe926","name":"Reproduction Chart","tab":"e3251669.740868","order":4,"disp":false,"width":"13","collapse":false},{"id":"c77dcaba.ebe128","type":"ui_group","z":"","name":"average reproduction rate","tab":"e3251669.740868","order":5,"disp":true,"width":"6","collapse":false},{"id":"e3251669.740868","type":"ui_tab","z":"","name":"owid-covid-data","icon":"dashboard","order":9,"disabled":false,"hidden":true}]

Here below todays output when comparing United States with Italy:

The main new feature is that I am calculating the reproduction number and putting the evolution of this number also in chart.

Definition Reproduction number (also referred as reproduction rate):

If the reproduction number is 2 at 2020-04-01 then this means if on that day X persons were infected by COVID-19 then one week later (day : 2020-04-08) there will be 2 times X persons infected.
Note that the reproduction number in these charts is calculated based on the new cases confirmed through tests.

Observations based on above chart

  1. Since 19/3 the reproduction number for Italy < 1. This is 12 days after lock down. As the reproduction number is based on confirmed cases there is indeed a delay when these charts effectively show the real decrease.
  2. Italy has currently (based on last 2 weeks) a reproduction number of 0.78. This means that within about 15.14 weeks the number of new cases drops to less than 1 per million people per day.
  3. US reproduction number is also below 1 since 5/4 and it currently has a reproduction rate of about 0.88. Based on a reproduction rate of 0.88 it would take the US 35 weeks before the number of new cases drops to less than 1 per million people per day.

Tried with Estonia and run into trouble
The change node "running average" gives an error
I think it may be don't like the NaN

1 Like

The fix for Estonia:

[{"id":"3a9fb996.bbe926","type":"tab","label":"owid-covid-data","disabled":false,"info":""},{"id":"c3387945.6987c8","type":"inject","z":"3a9fb996.bbe926","name":"Run flow","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":160,"y":120,"wires":[["c010259.2cf98d8","bddf1478.9b09c8"]]},{"id":"c010259.2cf98d8","type":"http request","z":"3a9fb996.bbe926","name":"get owid-covid-data.csv","method":"GET","ret":"txt","paytoqs":false,"url":"https://covid.ourworldindata.org/data/owid-covid-data.csv","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":120,"wires":[["164fca1a.bdcc36"]]},{"id":"4c5e0107.81dd","type":"csv","z":"3a9fb996.bbe926","name":"csv2array","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"x":600,"y":160,"wires":[["99fb2113.37e54","c8dbff0d.cef35"]]},{"id":"c826db11.2bca08","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":2,"width":"12","height":"7","label":"%new cases (with respect to new tests)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#009051","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":600,"y":900,"wires":[[]]},{"id":"99fb2113.37e54","type":"debug","z":"3a9fb996.bbe926","name":"owid-covid-data json","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":820,"y":160,"wires":[]},{"id":"c8dbff0d.cef35","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"covid_data","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":220,"wires":[["bc39bac.e135f48","9b88f1d0.e8c99","185638b4.45eab7"]]},{"id":"f211e551.667b68","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"location1","pt":"msg","to":"location1","tot":"flow"},{"t":"set","p":"location2","pt":"msg","to":"location2","tot":"flow"},{"t":"set","p":"covid_data","pt":"msg","to":"covid_data","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t   $location1 := location1;\t   $location2 := location2;\t   {\t       \"location1\" : \t        covid_data[location=$location1 and new_tests>0].{\t           \"date\" : date,\t           \"new_cases\" : new_cases,\t           \"new_tests\" : new_tests,\t           \"positive_test_percentage\" : $round(\t               new_cases / new_tests * 100 ,2),\t            \"total_cases\" : total_cases,\t            \"total_tests\" : total_tests,\t            \"population_in_thousand\": ($location1=\"United Kingdom\" ? 66573:\t                                       $location1=\"Israel\" ? 8884 :\t                                       $location1=\"Czech Republic\" ? 10650 :\t                                       $location1=\"Iceland\" ? 364 :\t                                       $location1=\"Estonia\" ? 1328:\t                                       total_cases*1000/total_cases_per_million)\t      },\t     \"location2\":         covid_data[location=$location2 and new_tests>0].{    \t            \"date\" : date,     \t            \"new_cases\" : new_cases,     \t            \"new_tests\" : new_tests,     \t            \"positive_test_percentage\" : $round(new_cases / new_tests * 100 ,\t               2\t           ),\t           \"total_cases\" : total_cases,\t           \"total_tests\" : total_tests,\t           \"population_in_thousand\": ($location2=\"United Kingdom\" ? 66573:\t                                      $location2=\"Israel\" ? 8884 :\t                                      $location2=\"Czech Republic\" ? 10650 :\t                                      $location2=\"Iceland\" ? 364 :\t                                      $location2=\"Estonia\" ? 1328:\t                                      total_cases*1000/total_cases_per_million)\t      }\t   }\t)\t/* see https://try.jsonata.org/WEDEzGOBb  */","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":520,"wires":[["d6412970.f37978","ce16a18e.14da5"]]},{"id":"d6412970.f37978","type":"debug","z":"3a9fb996.bbe926","name":"covid data for location1 and location2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":870,"y":520,"wires":[]},{"id":"d04b500a.baa45","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1, location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : positive_test_percentage \t               }\t           ],\t           [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : positive_test_percentage \t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":900,"wires":[["c826db11.2bca08"]]},{"id":"44dcda4e.51f944","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":1,"width":"12","height":4,"label":"new tests per thousand (population)","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#009051","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":590,"y":860,"wires":[[]]},{"id":"9476a458.94ece8","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1, location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_tests_per_thousand \t               }\t           ],\t           [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_tests_per_thousand\t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":860,"wires":[["44dcda4e.51f944"]]},{"id":"5819eb08.df1c14","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":3,"width":"12","height":"7","label":"new (confirmed) cases per thousand (population)","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#76d6ff","#00f900","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":630,"y":940,"wires":[[]]},{"id":"d308a880.137648","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1,location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_cases_per_thousand\t               }\t           ],\t                      [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_cases_per_thousand\t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":940,"wires":[["5819eb08.df1c14"]]},{"id":"cdd81598.25c3b8","type":"ui_dropdown","z":"3a9fb996.bbe926","name":"location1 dropdown","label":"location1","tooltip":"","place":"Select option","group":"7075490e.7cac28","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":560,"y":320,"wires":[["2203fb23.dd7704"]]},{"id":"bc39bac.e135f48","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload[new_tests>0].location ~> $distinct ~> $sort","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":360,"wires":[["2753fa25.e238a6","6af92528.bf095c"]]},{"id":"2203fb23.dd7704","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"location1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":320,"wires":[["8ba29581.5d84f8","21f6225a.3d4f3e"]]},{"id":"2753fa25.e238a6","type":"change","z":"3a9fb996.bbe926","name":"set to Belgium","rules":[{"t":"set","p":"payload","pt":"msg","to":"Belgium","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":320,"wires":[["cdd81598.25c3b8"]]},{"id":"6af92528.bf095c","type":"change","z":"3a9fb996.bbe926","name":"set to Italy","rules":[{"t":"set","p":"payload","pt":"msg","to":"Italy","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":380,"wires":[["efd55a63.c3a458"]]},{"id":"efd55a63.c3a458","type":"ui_dropdown","z":"3a9fb996.bbe926","name":"location1 dropdown","label":"location2","tooltip":"","place":"Select option","group":"7075490e.7cac28","order":2,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":560,"y":380,"wires":[["39013f83.273c5"]]},{"id":"39013f83.273c5","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"location2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":380,"wires":[["d35aba75.cd02f8","72a41a7c.2a5364"]]},{"id":"c5ba297f.3149a8","type":"ui_button","z":"3a9fb996.bbe926","name":"","group":"7bc90a44.ed8dd4","order":1,"width":0,"height":0,"passthru":false,"label":"retrieve owid-covid-data","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":60,"wires":[["c010259.2cf98d8"]]},{"id":"d35aba75.cd02f8","type":"switch","z":"3a9fb996.bbe926","name":"flow.location1 not null ?","property":"location1","propertyType":"flow","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":540,"wires":[["f211e551.667b68"]]},{"id":"8ba29581.5d84f8","type":"switch","z":"3a9fb996.bbe926","name":"flow.location2 not null ?","property":"location2","propertyType":"flow","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":500,"wires":[["f211e551.667b68"]]},{"id":"ce16a18e.14da5","type":"change","z":"3a9fb996.bbe926","name":"running average","rules":[{"t":"set","p":"running_average_days","pt":"msg","to":"running_average_days","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t  $x := running_average_days;\t{\t \"location1\" : payload.location1 ~> $map( function($v, $i, $a) \t     { \t        (\t          $v_min_x := $a[$i-$x]; /* take care this is circular !*/\t          $new_cases := ($v.total_cases - $v_min_x.total_cases)/$x;\t          $new_tests := ($v.total_tests - $v_min_x.total_tests)/$x;\t          \t          {\t            \"date\" : ($toMillis($v.date) + $toMillis($v_min_x.date))/2 ~> $fromMillis(),\t            \"new_cases_per_thousand\" : $new_cases/$v.population_in_thousand,\t            \"new_tests_per_thousand\" : $new_tests/$v.population_in_thousand,\t            \"positive_test_percentage\": $new_cases*100/$new_tests ~> $round(2)\t          }\t        )\t     }) ~> $filter (function($v, $i, $a) { $i>=$x}),\t  \"location2\": payload.location2 ~> $map( function($v, $i, $a) \t     { \t        (\t          $v_min_x := $a[$i-$x]; /* take care this is circular !*/\t          $new_cases := ($v.total_cases - $v_min_x.total_cases)/$x;\t          $new_tests := ($v.total_tests - $v_min_x.total_tests)/$x;\t          \t          {\t            \"date\" : ($toMillis($v.date) + $toMillis($v_min_x.date))/2 ~> $fromMillis(),\t            \"new_cases_per_thousand\" : $new_cases/$v.population_in_thousand,\t            \"new_tests_per_thousand\" : $new_tests/$v.population_in_thousand,\t            \"positive_test_percentage\": $new_cases*100/$new_tests ~> $round(2)\t          }\t        )\t     }) ~> $filter (function($v, $i, $a) { $i>=$x})\t     \t}\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":580,"wires":[["d04b500a.baa45","9476a458.94ece8","d308a880.137648","529b9278.947aac","e30083b3.51f12","43bc878f.cac668","23ef5b36.c85664"]]},{"id":"529b9278.947aac","type":"debug","z":"3a9fb996.bbe926","name":"running average","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":800,"y":580,"wires":[]},{"id":"4b0da2ab.fc904c","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"running_average_days","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":40,"wires":[["f211e551.667b68"]]},{"id":"bddf1478.9b09c8","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"7","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":40,"wires":[["a3a09f70.89765"]]},{"id":"15636a9d.bbd545","type":"ui_text_input","z":"3a9fb996.bbe926","name":"","label":"max date in data set","tooltip":"","group":"7bc90a44.ed8dd4","order":3,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1080,"y":220,"wires":[[]]},{"id":"9b88f1d0.e8c99","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$max(payload.$toMillis(date))~>$fromMillis()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":220,"wires":[["15636a9d.bbd545"]]},{"id":"79b611ae.ae3ec","type":"ui_text_input","z":"3a9fb996.bbe926","name":"","label":"last time date retrieved","tooltip":"","group":"7bc90a44.ed8dd4","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1160,"y":280,"wires":[[]]},{"id":"185638b4.45eab7","type":"change","z":"3a9fb996.bbe926","name":"get timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"$now()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":280,"wires":[["79b611ae.ae3ec"]]},{"id":"a3a09f70.89765","type":"ui_slider","z":"3a9fb996.bbe926","name":"","label":"running average number of days:","tooltip":"","group":"7075490e.7cac28","order":3,"width":0,"height":0,"passthru":true,"outs":"end","topic":"","min":"1","max":"20","step":1,"x":700,"y":40,"wires":[["4b0da2ab.fc904c"]]},{"id":"164fca1a.bdcc36","type":"switch","z":"3a9fb996.bbe926","name":"statusCode = 200 ?","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":650,"y":120,"wires":[["d29c622e.fe8b"],["4c5e0107.81dd"]]},{"id":"e1c555aa.70c088","type":"ui_toast","z":"3a9fb996.bbe926","position":"top right","displayTime":"10","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":1050,"y":80,"wires":[]},{"id":"d29c622e.fe8b","type":"change","z":"3a9fb996.bbe926","name":"set errormessage","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"Problem retrieving data (statusCode =\" & statusCode & \")\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":80,"wires":[["e1c555aa.70c088"]]},{"id":"e30083b3.51f12","type":"change","z":"3a9fb996.bbe926","name":"calculate reproduction factors","rules":[{"t":"set","p":"last_x_weeks","pt":"msg","to":"last_x_weeks","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t  $last_x_weeks          := last_x_weeks;\t  $location1_now         := payload.location1[-1];\t  $location1_x_weeks_ago := payload.location1[-1-(7*$last_x_weeks)];\t  $location2_now         := payload.location2[-1];\t  $location2_x_weeks_ago := payload.location2[-1-(7*$last_x_weeks)];\t  $location1_reproduction_rate := (($location1_now.positive_test_percentage/$location1_x_weeks_ago.positive_test_percentage) +\t                                   ($location1_now.new_cases_per_thousand/$location1_x_weeks_ago.new_cases_per_thousand))/2;\t  $location2_reproduction_rate := (($location2_now.positive_test_percentage/$location2_x_weeks_ago.positive_test_percentage) +\t                                   ($location2_now.new_cases_per_thousand/$location2_x_weeks_ago.new_cases_per_thousand))/2;\t  $location1_weekly_reproduction_rate := $power($location1_reproduction_rate, (1/$last_x_weeks));\t  $location2_weekly_reproduction_rate := $power($location2_reproduction_rate, (1/$last_x_weeks));\t  $location1_factor_to_1ppm := $location1_now.new_cases_per_thousand/0.001;\t  $location2_factor_to_1ppm := $location2_now.new_cases_per_thousand/0.001;  \t  {\t    \"location1\" : {\t          \"weekly_reproduction_rate\" :$location1_weekly_reproduction_rate~> $round(2),\t          \"reproduction_rate_for_period\" :   \t               $location1_reproduction_rate ~> $round(2),\t           \"factor_to_1ppm\": $location1_factor_to_1ppm~> $round(2)\t               },\t    \"location2\" : {\t          \"weekly_reproduction_rate\" :$location2_weekly_reproduction_rate~> $round(2),\t          \"reproduction_rate_for_period\" :   \t            $location2_reproduction_rate ~> $round(2),\t           \"factor_to_1ppm\": $location2_factor_to_1ppm~> $round(2)\t               }           \t  }\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":700,"wires":[["40ee0ab4.b257e4","9741f258.c7a","b3dd7050.4176c","bbf42cef.526c3","514dd192.00878","4516276d.16d788","aa2d19c7.809558","7eab409e.39896"]]},{"id":"40ee0ab4.b257e4","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":2,"width":0,"height":0,"name":"","label":"weekly reproduction rate","format":"{{msg.payload.location1.weekly_reproduction_rate}}","layout":"row-spread","x":1270,"y":640,"wires":[]},{"id":"9741f258.c7a","type":"debug","z":"3a9fb996.bbe926","name":"reproduction factors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1260,"y":600,"wires":[]},{"id":"b3dd7050.4176c","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":2,"width":0,"height":0,"name":"","label":"weekly reproduction rate","format":"{{msg.payload.location2.weekly_reproduction_rate}}","layout":"row-spread","x":1270,"y":680,"wires":[]},{"id":"43bc878f.cac668","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1 & \" (% new cases)\", location1 & \" (new cases)\",\t                  location2 & \" (% new cases)\", location2 & \" (new cases)\"\t       ],\t       \"data\": [\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   $a[$i+7].positive_test_percentage/$v.positive_test_percentage~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   $a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   $a[$i+7].positive_test_percentage/$v.positive_test_percentage~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   $a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":780,"wires":[["2aa1c807.351eb8"]]},{"id":"2ed1a7d.6aca758","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"e89c34cf.95af58","order":1,"width":13,"height":"7","label":"(averaged) reproduction number (assuming incubation period = 1 week)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"2","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#ff2600","#0433ff","#008f00","#00f900","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":700,"y":820,"wires":[[]]},{"id":"2aa1c807.351eb8","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"e89c34cf.95af58","order":2,"width":13,"height":"7","label":"reproduction number (assuming incubation period = 1 week)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#76d6ff","#008f00","#00f900","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":660,"y":780,"wires":[[]]},{"id":"23ef5b36.c85664","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [\"allowed max\", location1 , location2 ],\t       \"data\": [\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   1:\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   (($a[$i+7].positive_test_percentage/$v.positive_test_percentage)+\t                                    ($a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand))/2~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>0.001) and ($a[$i+7].new_cases_per_thousand>0.001) ?\t                                   (($a[$i+7].positive_test_percentage/$v.positive_test_percentage)+\t                                    ($a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand))/2~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":820,"wires":[["2ed1a7d.6aca758"]]},{"id":"1dfa56ae.c287a9","type":"ui_numeric","z":"3a9fb996.bbe926","name":"last x weeks","label":"period","tooltip":"","group":"c77dcaba.ebe128","order":1,"width":0,"height":0,"wrap":false,"passthru":true,"topic":"","format":"last {{value}} weeks","min":"1","max":10,"step":1,"x":1110,"y":440,"wires":[["ad9970be.06e94","f211e551.667b68"]]},{"id":"ad9970be.06e94","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"last_x_weeks","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":440,"wires":[[]]},{"id":"12b264a.814219b","type":"inject","z":"3a9fb996.bbe926","name":"","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":1050,"y":400,"wires":[["1dfa56ae.c287a9"]]},{"id":"bbf42cef.526c3","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":3,"width":0,"height":0,"name":"","label":"reproduction rate for period","format":"{{msg.payload.location1.reproduction_rate_for_period}}","layout":"row-spread","x":1340,"y":720,"wires":[]},{"id":"514dd192.00878","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":3,"width":0,"height":0,"name":"","label":"reproduction rate for period","format":"{{msg.payload.location2.reproduction_rate_for_period}}","layout":"row-spread","x":1340,"y":760,"wires":[]},{"id":"ae4060a7.47c75","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":540,"wires":[[]]},{"id":"21f6225a.3d4f3e","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":1,"width":0,"height":0,"name":"location1","label":"country","format":"{{msg.payload}}","layout":"row-spread","x":1340,"y":320,"wires":[]},{"id":"72a41a7c.2a5364","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":1,"width":0,"height":0,"name":"location2","label":"country","format":"{{msg.payload}}","layout":"row-spread","x":1340,"y":360,"wires":[]},{"id":"4516276d.16d788","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":4,"width":0,"height":0,"name":"","label":"factor to 1ppm","format":"{{msg.payload.location1.factor_to_1ppm}}","layout":"row-spread","x":1240,"y":800,"wires":[]},{"id":"aa2d19c7.809558","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":4,"width":0,"height":0,"name":"","label":"factor to 1 ppm","format":"{{msg.payload.location2.factor_to_1ppm}}","layout":"row-spread","x":1240,"y":840,"wires":[]},{"id":"7eab409e.39896","type":"function","z":"3a9fb996.bbe926","name":"calculate nr of weeks to 1ppm","func":"msg.location1_nr_of_weeks = -  Math.log(msg.payload.location1.factor_to_1ppm)/Math.log(msg.payload.location1.weekly_reproduction_rate);\nmsg.location2_nr_of_weeks = -  Math.log(msg.payload.location2.factor_to_1ppm)/Math.log(msg.payload.location2.weekly_reproduction_rate);\nreturn msg;","outputs":1,"noerr":0,"x":1050,"y":900,"wires":[["bb913191.10f88","326b4dad.53dc12"]]},{"id":"bb913191.10f88","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":4,"width":0,"height":0,"name":"","label":"nr of weeks to 1 ppm","format":"{{msg.location1_nr_of_weeks | number:2}}","layout":"row-spread","x":1380,"y":900,"wires":[]},{"id":"326b4dad.53dc12","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":4,"width":0,"height":0,"name":"","label":"nr of weeks to 1 ppm","format":"{{msg.location2_nr_of_weeks | number:2}}","layout":"row-spread","x":1380,"y":940,"wires":[]},{"id":"828b3fe0.ce8ff","type":"ui_group","z":"","name":"charts","tab":"e3251669.740868","order":3,"disp":false,"width":"12","collapse":false},{"id":"7075490e.7cac28","type":"ui_group","z":"","name":"Filter","tab":"e3251669.740868","order":1,"disp":true,"width":"7","collapse":false},{"id":"7bc90a44.ed8dd4","type":"ui_group","z":"","name":"github","tab":"e3251669.740868","order":2,"disp":true,"width":"6","collapse":false},{"id":"366031e1.19a67e","type":"ui_group","z":"","name":"location 1","tab":"e3251669.740868","order":6,"disp":true,"width":"6","collapse":false},{"id":"fdc57d76.7fafa","type":"ui_group","z":"","name":"location 2","tab":"e3251669.740868","order":7,"disp":true,"width":"6","collapse":false},{"id":"e89c34cf.95af58","type":"ui_group","z":"3a9fb996.bbe926","name":"Reproduction Chart","tab":"e3251669.740868","order":4,"disp":false,"width":"13","collapse":false},{"id":"c77dcaba.ebe128","type":"ui_group","z":"","name":"average reproduction rate","tab":"e3251669.740868","order":5,"disp":true,"width":"6","collapse":false},{"id":"e3251669.740868","type":"ui_tab","z":"","name":"owid-covid-data","icon":"dashboard","order":9,"disabled":false,"hidden":true}]

The problem is that for some of the countries the data set doesn't contain the information to derive the country population (in thousands) so I had to hard code it in the change: 5 rules node:

1 Like

As the success of New Zealand was in the news I have also compared them with Italy and ... indeed as you can see: the rate at which the reproduction number of New Zealand dropped (see chart "(average) reproduction number...") and stayed below 0.5 is really impressive.

I fixed the error for "India" so that it now also appears in the reproduction number charts:

[{"id":"3a9fb996.bbe926","type":"tab","label":"owid-covid-data","disabled":false,"info":""},{"id":"c3387945.6987c8","type":"inject","z":"3a9fb996.bbe926","name":"Run flow","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":160,"y":120,"wires":[["c010259.2cf98d8","bddf1478.9b09c8"]]},{"id":"c010259.2cf98d8","type":"http request","z":"3a9fb996.bbe926","name":"get owid-covid-data.csv","method":"GET","ret":"txt","paytoqs":false,"url":"https://covid.ourworldindata.org/data/owid-covid-data.csv","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":120,"wires":[["164fca1a.bdcc36"]]},{"id":"4c5e0107.81dd","type":"csv","z":"3a9fb996.bbe926","name":"csv2array","sep":",","hdrin":true,"hdrout":false,"multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"x":600,"y":160,"wires":[["99fb2113.37e54","c8dbff0d.cef35"]]},{"id":"c826db11.2bca08","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":2,"width":"12","height":"7","label":"%new cases (with respect to new tests)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#009051","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":600,"y":900,"wires":[[]]},{"id":"99fb2113.37e54","type":"debug","z":"3a9fb996.bbe926","name":"owid-covid-data json","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":820,"y":160,"wires":[]},{"id":"c8dbff0d.cef35","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"covid_data","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":220,"wires":[["bc39bac.e135f48","9b88f1d0.e8c99","185638b4.45eab7"]]},{"id":"f211e551.667b68","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"location1","pt":"msg","to":"location1","tot":"flow"},{"t":"set","p":"location2","pt":"msg","to":"location2","tot":"flow"},{"t":"set","p":"covid_data","pt":"msg","to":"covid_data","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t   $location1 := location1;\t   $location2 := location2;\t   {\t       \"location1\" : \t        covid_data[location=$location1 and new_tests>0].{\t           \"date\" : date,\t           \"new_cases\" : new_cases,\t           \"new_tests\" : new_tests,\t           \"positive_test_percentage\" : $round(\t               new_cases / new_tests * 100 ,2),\t            \"total_cases\" : total_cases,\t            \"total_tests\" : total_tests,\t            \"population_in_thousand\": ($location1=\"United Kingdom\" ? 66573:\t                                       $location1=\"Israel\" ? 8884 :\t                                       $location1=\"Czech Republic\" ? 10650 :\t                                       $location1=\"Iceland\" ? 364 :\t                                       $location1=\"Estonia\" ? 1328:\t                                       total_cases*1000/total_cases_per_million)\t      },\t     \"location2\":         covid_data[location=$location2 and new_tests>0].{    \t            \"date\" : date,     \t            \"new_cases\" : new_cases,     \t            \"new_tests\" : new_tests,     \t            \"positive_test_percentage\" : $round(new_cases / new_tests * 100 ,\t               2\t           ),\t           \"total_cases\" : total_cases,\t           \"total_tests\" : total_tests,\t           \"population_in_thousand\": ($location2=\"United Kingdom\" ? 66573:\t                                      $location2=\"Israel\" ? 8884 :\t                                      $location2=\"Czech Republic\" ? 10650 :\t                                      $location2=\"Iceland\" ? 364 :\t                                      $location2=\"Estonia\" ? 1328:\t                                      total_cases*1000/total_cases_per_million)\t      }\t   }\t)\t/* see https://try.jsonata.org/WEDEzGOBb  */","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":520,"wires":[["d6412970.f37978","ce16a18e.14da5"]]},{"id":"d6412970.f37978","type":"debug","z":"3a9fb996.bbe926","name":"covid data for location1 and location2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":870,"y":520,"wires":[]},{"id":"d04b500a.baa45","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1, location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : positive_test_percentage \t               }\t           ],\t           [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : positive_test_percentage \t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":900,"wires":[["c826db11.2bca08"]]},{"id":"44dcda4e.51f944","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":1,"width":"12","height":4,"label":"new tests per thousand (population)","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#009051","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":590,"y":860,"wires":[[]]},{"id":"9476a458.94ece8","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1, location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_tests_per_thousand \t               }\t           ],\t           [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_tests_per_thousand\t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":860,"wires":[["44dcda4e.51f944"]]},{"id":"5819eb08.df1c14","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"828b3fe0.ce8ff","order":3,"width":"12","height":"7","label":"new (confirmed) cases per thousand (population)","chartType":"line","legend":"false","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#76d6ff","#00f900","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":630,"y":940,"wires":[[]]},{"id":"d308a880.137648","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [location1,location2],\t       \"data\": [\t           [\t               payload.location1.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_cases_per_thousand\t               }\t           ],\t                      [\t               payload.location2.{\t                   \"x\" : $toMillis(date),\t                   \"y\" : new_cases_per_thousand\t               }\t           ]\t          ],\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":940,"wires":[["5819eb08.df1c14"]]},{"id":"cdd81598.25c3b8","type":"ui_dropdown","z":"3a9fb996.bbe926","name":"location1 dropdown","label":"location1","tooltip":"","place":"Select option","group":"7075490e.7cac28","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":560,"y":320,"wires":[["2203fb23.dd7704"]]},{"id":"bc39bac.e135f48","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload[new_tests>0].location ~> $distinct ~> $sort","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":360,"wires":[["2753fa25.e238a6","6af92528.bf095c"]]},{"id":"2203fb23.dd7704","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"location1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":320,"wires":[["8ba29581.5d84f8","21f6225a.3d4f3e"]]},{"id":"2753fa25.e238a6","type":"change","z":"3a9fb996.bbe926","name":"set to Belgium","rules":[{"t":"set","p":"payload","pt":"msg","to":"Belgium","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":320,"wires":[["cdd81598.25c3b8"]]},{"id":"6af92528.bf095c","type":"change","z":"3a9fb996.bbe926","name":"set to Italy","rules":[{"t":"set","p":"payload","pt":"msg","to":"Italy","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":380,"wires":[["efd55a63.c3a458"]]},{"id":"efd55a63.c3a458","type":"ui_dropdown","z":"3a9fb996.bbe926","name":"location1 dropdown","label":"location2","tooltip":"","place":"Select option","group":"7075490e.7cac28","order":2,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":560,"y":380,"wires":[["39013f83.273c5"]]},{"id":"39013f83.273c5","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"location2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":380,"wires":[["d35aba75.cd02f8","72a41a7c.2a5364"]]},{"id":"c5ba297f.3149a8","type":"ui_button","z":"3a9fb996.bbe926","name":"","group":"7bc90a44.ed8dd4","order":1,"width":0,"height":0,"passthru":false,"label":"retrieve owid-covid-data","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":60,"wires":[["c010259.2cf98d8"]]},{"id":"d35aba75.cd02f8","type":"switch","z":"3a9fb996.bbe926","name":"flow.location1 not null ?","property":"location1","propertyType":"flow","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":540,"wires":[["f211e551.667b68"]]},{"id":"8ba29581.5d84f8","type":"switch","z":"3a9fb996.bbe926","name":"flow.location2 not null ?","property":"location2","propertyType":"flow","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":500,"wires":[["f211e551.667b68"]]},{"id":"ce16a18e.14da5","type":"change","z":"3a9fb996.bbe926","name":"running average","rules":[{"t":"set","p":"running_average_days","pt":"msg","to":"running_average_days","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t  $x := running_average_days;\t{\t \"location1\" : payload.location1 ~> $map( function($v, $i, $a) \t     { \t        (\t          $v_min_x := $a[$i-$x]; /* take care this is circular !*/\t          $new_cases := ($v.total_cases - $v_min_x.total_cases)/$x;\t          $new_tests := ($v.total_tests - $v_min_x.total_tests)/$x;\t          \t          {\t            \"date\" : ($toMillis($v.date) + $toMillis($v_min_x.date))/2 ~> $fromMillis(),\t            \"new_cases_per_thousand\" : $new_cases/$v.population_in_thousand,\t            \"new_tests_per_thousand\" : $new_tests/$v.population_in_thousand,\t            \"positive_test_percentage\": $new_cases*100/$new_tests ~> $round(2)\t          }\t        )\t     }) ~> $filter (function($v, $i, $a) { $i>=$x}),\t  \"location2\": payload.location2 ~> $map( function($v, $i, $a) \t     { \t        (\t          $v_min_x := $a[$i-$x]; /* take care this is circular !*/\t          $new_cases := ($v.total_cases - $v_min_x.total_cases)/$x;\t          $new_tests := ($v.total_tests - $v_min_x.total_tests)/$x;\t          \t          {\t            \"date\" : ($toMillis($v.date) + $toMillis($v_min_x.date))/2 ~> $fromMillis(),\t            \"new_cases_per_thousand\" : $new_cases/$v.population_in_thousand,\t            \"new_tests_per_thousand\" : $new_tests/$v.population_in_thousand,\t            \"positive_test_percentage\": $new_cases*100/$new_tests ~> $round(2)\t          }\t        )\t     }) ~> $filter (function($v, $i, $a) { $i>=$x})\t     \t}\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":580,"wires":[["d04b500a.baa45","9476a458.94ece8","d308a880.137648","529b9278.947aac","e30083b3.51f12","43bc878f.cac668","23ef5b36.c85664"]]},{"id":"529b9278.947aac","type":"debug","z":"3a9fb996.bbe926","name":"running average","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":800,"y":580,"wires":[]},{"id":"4b0da2ab.fc904c","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"running_average_days","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":40,"wires":[["f211e551.667b68"]]},{"id":"bddf1478.9b09c8","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"7","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":40,"wires":[["a3a09f70.89765"]]},{"id":"15636a9d.bbd545","type":"ui_text_input","z":"3a9fb996.bbe926","name":"","label":"max date in data set","tooltip":"","group":"7bc90a44.ed8dd4","order":3,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1080,"y":220,"wires":[[]]},{"id":"9b88f1d0.e8c99","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$max(payload.$toMillis(date))~>$fromMillis()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":220,"wires":[["15636a9d.bbd545"]]},{"id":"79b611ae.ae3ec","type":"ui_text_input","z":"3a9fb996.bbe926","name":"","label":"last time date retrieved","tooltip":"","group":"7bc90a44.ed8dd4","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1160,"y":280,"wires":[[]]},{"id":"185638b4.45eab7","type":"change","z":"3a9fb996.bbe926","name":"get timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"$now()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":280,"wires":[["79b611ae.ae3ec"]]},{"id":"a3a09f70.89765","type":"ui_slider","z":"3a9fb996.bbe926","name":"","label":"running average number of days:","tooltip":"","group":"7075490e.7cac28","order":3,"width":0,"height":0,"passthru":true,"outs":"end","topic":"","min":"1","max":"20","step":1,"x":700,"y":40,"wires":[["4b0da2ab.fc904c"]]},{"id":"164fca1a.bdcc36","type":"switch","z":"3a9fb996.bbe926","name":"statusCode = 200 ?","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":650,"y":120,"wires":[["d29c622e.fe8b"],["4c5e0107.81dd"]]},{"id":"e1c555aa.70c088","type":"ui_toast","z":"3a9fb996.bbe926","position":"top right","displayTime":"10","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":1050,"y":80,"wires":[]},{"id":"d29c622e.fe8b","type":"change","z":"3a9fb996.bbe926","name":"set errormessage","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"Problem retrieving data (statusCode =\" & statusCode & \")\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":80,"wires":[["e1c555aa.70c088"]]},{"id":"e30083b3.51f12","type":"change","z":"3a9fb996.bbe926","name":"calculate reproduction factors","rules":[{"t":"set","p":"last_x_weeks","pt":"msg","to":"last_x_weeks","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"(\t  $last_x_weeks          := last_x_weeks;\t  $location1_now         := payload.location1[-1];\t  $location1_x_weeks_ago := payload.location1[-1-(7*$last_x_weeks)];\t  $location2_now         := payload.location2[-1];\t  $location2_x_weeks_ago := payload.location2[-1-(7*$last_x_weeks)];\t  $location1_reproduction_rate := (($location1_now.positive_test_percentage/$location1_x_weeks_ago.positive_test_percentage) +\t                                   ($location1_now.new_cases_per_thousand/$location1_x_weeks_ago.new_cases_per_thousand))/2;\t  $location2_reproduction_rate := (($location2_now.positive_test_percentage/$location2_x_weeks_ago.positive_test_percentage) +\t                                   ($location2_now.new_cases_per_thousand/$location2_x_weeks_ago.new_cases_per_thousand))/2;\t  $location1_weekly_reproduction_rate := $power($location1_reproduction_rate, (1/$last_x_weeks));\t  $location2_weekly_reproduction_rate := $power($location2_reproduction_rate, (1/$last_x_weeks));\t  $location1_factor_to_1ppm := $location1_now.new_cases_per_thousand/0.001;\t  $location2_factor_to_1ppm := $location2_now.new_cases_per_thousand/0.001;  \t  {\t    \"location1\" : {\t          \"weekly_reproduction_rate\" :$location1_weekly_reproduction_rate~> $round(2),\t          \"reproduction_rate_for_period\" :   \t               $location1_reproduction_rate ~> $round(2),\t           \"factor_to_1ppm\": $location1_factor_to_1ppm~> $round(2)\t               },\t    \"location2\" : {\t          \"weekly_reproduction_rate\" :$location2_weekly_reproduction_rate~> $round(2),\t          \"reproduction_rate_for_period\" :   \t            $location2_reproduction_rate ~> $round(2),\t           \"factor_to_1ppm\": $location2_factor_to_1ppm~> $round(2)\t               }           \t  }\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":700,"wires":[["40ee0ab4.b257e4","9741f258.c7a","b3dd7050.4176c","bbf42cef.526c3","514dd192.00878","4516276d.16d788","aa2d19c7.809558","7eab409e.39896"]]},{"id":"40ee0ab4.b257e4","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":2,"width":0,"height":0,"name":"","label":"weekly reproduction rate","format":"{{msg.payload.location1.weekly_reproduction_rate}}","layout":"row-spread","x":1270,"y":640,"wires":[]},{"id":"9741f258.c7a","type":"debug","z":"3a9fb996.bbe926","name":"reproduction factors","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1260,"y":600,"wires":[]},{"id":"b3dd7050.4176c","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":2,"width":0,"height":0,"name":"","label":"weekly reproduction rate","format":"{{msg.payload.location2.weekly_reproduction_rate}}","layout":"row-spread","x":1270,"y":680,"wires":[]},{"id":"43bc878f.cac668","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t\t   {\t       \"series\": [location1 & \" (% new cases)\", location1 & \" (new cases)\",\t                  location2 & \" (% new cases)\", location2 & \" (new cases)\"\t       ],\t       \"data\":\t       (\t         /* the threshold for India is lowered to 1 case per 10 million */\t         $threshold_loc1 :=  location1 = \"India\" ? 0.0001 : 0.001 ;\t         $threshold_loc2 :=  location2 = \"India\" ? 0.0001 : 0.001 ;\t       [\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>$threshold_loc1) and ($a[$i+7].new_cases_per_thousand>$threshold_loc1) ?\t                                   $a[$i+7].positive_test_percentage/$v.positive_test_percentage~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>$threshold_loc1) and ($a[$i+7].new_cases_per_thousand>$threshold_loc1) ?\t                                   $a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>$threshold_loc2) and ($a[$i+7].new_cases_per_thousand>$threshold_loc2) ?\t                                   $a[$i+7].positive_test_percentage/$v.positive_test_percentage~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>$threshold_loc2) and ($a[$i+7].new_cases_per_thousand>$threshold_loc2) ?\t                                   $a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0]\t          ]\t        ),\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":780,"wires":[["2aa1c807.351eb8"]]},{"id":"2ed1a7d.6aca758","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"e89c34cf.95af58","order":1,"width":13,"height":"7","label":"(averaged) reproduction number (assuming incubation period = 1 week)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"2","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#ff2600","#0433ff","#008f00","#00f900","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":700,"y":820,"wires":[[]]},{"id":"2aa1c807.351eb8","type":"ui_chart","z":"3a9fb996.bbe926","name":"","group":"e89c34cf.95af58","order":2,"width":13,"height":"7","label":"reproduction number (assuming incubation period = 1 week)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"","removeOlder":"8","removeOlderPoints":"1000","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#0433ff","#76d6ff","#008f00","#00f900","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":660,"y":780,"wires":[[]]},{"id":"23ef5b36.c85664","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\": [\"allowed max\", location1 , location2 ],\t       \"data\": \t         (\t         /* the threshold for India is lowered to 1 case per 10 million */\t         $threshold_loc1 :=  location1 = \"India\" ? 0.0001 : 0.001 ;\t         $threshold_loc2 :=  location2 = \"India\" ? 0.0001 : 0.001 ;\t         [\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>$threshold_loc1) and ($a[$i+7].new_cases_per_thousand>$threshold_loc1) ?\t                                   1:\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location1~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           /* y = -1 when there is less than 1 case in million */\t                           \"y\" : ( ($v.new_cases_per_thousand>$threshold_loc1) and ($a[$i+7].new_cases_per_thousand>$threshold_loc1) ?\t                                   (($a[$i+7].positive_test_percentage/$v.positive_test_percentage)+\t                                    ($a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand))/2~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0],\t           [\t               payload.location2~>$map(function($v,$i,$a){\t                         {\t                           \"x\" : $toMillis($v.date),\t                           \"y\" : ( ($v.new_cases_per_thousand>$threshold_loc2) and ($a[$i+7].new_cases_per_thousand>$threshold_loc2) ?\t                                   (($a[$i+7].positive_test_percentage/$v.positive_test_percentage)+\t                                    ($a[$i+7].new_cases_per_thousand/$v.new_cases_per_thousand))/2~>$round(2):\t                                   -1)\t                         }\t                     })\t           ][y>=0]\t          ] ),\t       \"labels\": [\"\"]\t}\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":820,"wires":[["2ed1a7d.6aca758"]]},{"id":"1dfa56ae.c287a9","type":"ui_numeric","z":"3a9fb996.bbe926","name":"last x weeks","label":"period","tooltip":"","group":"c77dcaba.ebe128","order":1,"width":0,"height":0,"wrap":false,"passthru":true,"topic":"","format":"last {{value}} weeks","min":"1","max":10,"step":1,"x":1110,"y":440,"wires":[["ad9970be.06e94","f211e551.667b68"]]},{"id":"ad9970be.06e94","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"last_x_weeks","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":440,"wires":[[]]},{"id":"12b264a.814219b","type":"inject","z":"3a9fb996.bbe926","name":"","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":1050,"y":400,"wires":[["1dfa56ae.c287a9"]]},{"id":"bbf42cef.526c3","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":3,"width":0,"height":0,"name":"","label":"reproduction rate for period","format":"{{msg.payload.location1.reproduction_rate_for_period}}","layout":"row-spread","x":1340,"y":720,"wires":[]},{"id":"514dd192.00878","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":3,"width":0,"height":0,"name":"","label":"reproduction rate for period","format":"{{msg.payload.location2.reproduction_rate_for_period}}","layout":"row-spread","x":1340,"y":760,"wires":[]},{"id":"ae4060a7.47c75","type":"change","z":"3a9fb996.bbe926","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":540,"wires":[[]]},{"id":"21f6225a.3d4f3e","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":1,"width":0,"height":0,"name":"location1","label":"country","format":"{{msg.payload}}","layout":"row-spread","x":1340,"y":320,"wires":[]},{"id":"72a41a7c.2a5364","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":1,"width":0,"height":0,"name":"location2","label":"country","format":"{{msg.payload}}","layout":"row-spread","x":1340,"y":360,"wires":[]},{"id":"4516276d.16d788","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":4,"width":0,"height":0,"name":"","label":"factor to 1ppm","format":"{{msg.payload.location1.factor_to_1ppm}}","layout":"row-spread","x":1240,"y":800,"wires":[]},{"id":"aa2d19c7.809558","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":4,"width":0,"height":0,"name":"","label":"factor to 1 ppm","format":"{{msg.payload.location2.factor_to_1ppm}}","layout":"row-spread","x":1240,"y":840,"wires":[]},{"id":"7eab409e.39896","type":"function","z":"3a9fb996.bbe926","name":"calculate nr of weeks to 1ppm","func":"msg.location1_nr_of_weeks = -  Math.log(msg.payload.location1.factor_to_1ppm)/Math.log(msg.payload.location1.weekly_reproduction_rate);\nmsg.location2_nr_of_weeks = -  Math.log(msg.payload.location2.factor_to_1ppm)/Math.log(msg.payload.location2.weekly_reproduction_rate);\nreturn msg;","outputs":1,"noerr":0,"x":1050,"y":900,"wires":[["bb913191.10f88","326b4dad.53dc12"]]},{"id":"bb913191.10f88","type":"ui_text","z":"3a9fb996.bbe926","group":"366031e1.19a67e","order":4,"width":0,"height":0,"name":"","label":"nr of weeks to 1 ppm","format":"{{msg.location1_nr_of_weeks | number:2}}","layout":"row-spread","x":1380,"y":900,"wires":[]},{"id":"326b4dad.53dc12","type":"ui_text","z":"3a9fb996.bbe926","group":"fdc57d76.7fafa","order":4,"width":0,"height":0,"name":"","label":"nr of weeks to 1 ppm","format":"{{msg.location2_nr_of_weeks | number:2}}","layout":"row-spread","x":1380,"y":940,"wires":[]},{"id":"828b3fe0.ce8ff","type":"ui_group","z":"","name":"charts","tab":"e3251669.740868","order":3,"disp":false,"width":"12","collapse":false},{"id":"7075490e.7cac28","type":"ui_group","z":"","name":"Filter","tab":"e3251669.740868","order":1,"disp":true,"width":"7","collapse":false},{"id":"7bc90a44.ed8dd4","type":"ui_group","z":"","name":"github","tab":"e3251669.740868","order":2,"disp":true,"width":"6","collapse":false},{"id":"366031e1.19a67e","type":"ui_group","z":"","name":"location 1","tab":"e3251669.740868","order":6,"disp":true,"width":"6","collapse":false},{"id":"fdc57d76.7fafa","type":"ui_group","z":"","name":"location 2","tab":"e3251669.740868","order":7,"disp":true,"width":"6","collapse":false},{"id":"e89c34cf.95af58","type":"ui_group","z":"3a9fb996.bbe926","name":"Reproduction Chart","tab":"e3251669.740868","order":4,"disp":false,"width":"13","collapse":false},{"id":"c77dcaba.ebe128","type":"ui_group","z":"","name":"average reproduction rate","tab":"e3251669.740868","order":5,"disp":true,"width":"6","collapse":false},{"id":"e3251669.740868","type":"ui_tab","z":"","name":"owid-covid-data","icon":"dashboard","order":9,"disabled":false,"hidden":true}]

Here below a comparison between India and US.

Observations

  1. Number of (new) confirmed cases in India is very low compared to US.
  2. ... but concerning for India is that despite the lock down the reproduction rate is well above 1.
  3. The reproduction rate for the US is a bit below 1 and is further decreasing. This is good news.
  4. ... of course this doesn't mean that the reproduction rate for all states in the US are below 1. It is well possible that some states in the US have a reproduction rate > 1 but that this is concealed thanks to New York and other states with many cases that are properly managing the COVID-19 spread.

Comparison of the United States with United Kingdom

Observations

  • Reproduction number in the US is rising and has jumped above 1. This is very concerning as this means that the problem is getting worse in the US.
  • The Reproduction number in the UK is around 0.75 which is not bad. Note that they have increased their test capacity recently so this might mean that there is a greater error on the reproduction number. We need to watch out if the increase in reproduction number that we see in the last 2 days reported is not continuing.
2 Likes

Comparison between Italy and Belgium

Observations

  1. Italy has a very stable production rate around 0.75. Which is good. So Mid july they might expect 1 new confirmed case per million per day (which is 34 times less than today).
  2. Reproduction rate in Belgium is gradually decreasing (it is 0.64 for the last 2 weeks of data). This is also due to the fact that Belgium is more and more testing. So the error margin on the reproduction rate might be bigger due to this. Anyway this is very good news. If things progress similarly as last 2 weeks then beginning of July they might expect 1 new confirmed case per million per day (which is 70 times less than today).

Some more interesting observations related to the 2 diagrams calculating the reproduction numbers:

Observations

Belgium went in a kind of (pseudo) lock down 13th of March ... but the effect of the measures on confirmed cases seems only to start at 20th of March. So that is 1 week delay. In order to calculate this we need to compare this with the 7days average of next week (so that is acually 7 + (7/2) days later). So basically if we take measures on day X then they only start to become visible in these charts on day X + 17.5 day (= 7 + 7 + (7/2)). The major effect of the measures is seen at 27th of March (then the calculated reproduction went to 1. So that it is another week later. But the full effect of the measures on the reproduction number is not yet seen as the reproduction number is still decreasing (last date in chart = 21th of April = almost 4 weeks later than the big decrease).

Conclusion
What is concerning is that this also means that we might follow the same pattern when reducing the measures. So the effect of reducing measures on the reproduction number might only start to become visible in the data after 18 days (the big effect after 24 days and its full effect might take more than 50 days).

Comparison UK with Italy

Observation

  • number of new confirmed cases per day is in Italy 18.6 per million compared to 69.7 per million for the UK and this for the same amount of tests. So at 8th of May a UK person had almost 4 times more chance to become infected than an Italian person.
  • Reproduction number in Italy stays low for several weeks. It is now 0.65 based on last 2 weeks => This means that before the 1st of July they will go below 1 new confirmed case per day per million people (which is 19 times less than today).
  • Reproduction number is again going up in the UK. It is now 0.85 based on last 2 weeks => This means that it will take until November before they go below 1 new confirmed case per day per million people (which is 70 times less than today).

Interesting (in a terrifying way). Perhaps now they burned the 5G masts down they think its ok to proceed as normal.

I fear here in the UK there are too many who do not think this situation is dangerous or they're invincible (which is bad for everyone else) or worse, think its a hoax :crazy_face:

Maybe it will take everyone to lose someone close to believe these are truly perilous times?

Its madness.

Is it time for enforced tracking and tracing (EDIT: coupled with testing)?

Not what I want but perhaps necessary because of those who flaunt the social distancing guidelines (if you've been to a UK supermarket or shop - you know who I mean)

Comparison US with Russia

Observations

  1. Both countries have same number of confirmed cases (74 per day per million). But as Russia does more testing the problem at 8th of May is a bit more severe in the US.
  2. Reproduction number in Russia is around 1.29 which indicates that every week it is getting 30% worse.
  3. Reproduction number in US is below 1 but still high (around 0.86). This means that it could take until the end of November before they go below 1 case per day per million which is still a long time. Note that Italy will most likely reach this milestone before the 1st July (5 months earlier)

Comparison Austria with Italy

Observations
After an impressive decline of the number of cases, Austria was the first country to relax the lock down measures. As you can see the reproduction rate is again going up (0.83 based on last 2 weeks). If we extrapolate this it means that Italy will reach the 1 case per day per million before Austria. If reproduction rate for Austria continues rising coming days they will have to reintroduce measures.

Unfortunately, "we" rejected existing tried and trusted tracing apps already deployed in other countries even though we were offered them. Instead the job was given to mates of BJ along with one of the worlds scariest private (US) companies. Here is a comment about them:

"bringing weaponized surveillance from Fallujah to the streets of LA."

Though slightly less worrying that I now have a little inside insight to how it works, it does look like some elements of privacy are being considered. Though if you've seen yesterday's Wired article on the accidentally leaked document from X, it is clear that we are far from being out of the woods on this. The app has the potential to be a very powerful weapon for excessive governments.

Also still not clear how effective it is anyway. It needs large-scale use to be effective and it won't even run on many devices. As is so often the case with these poorly thought through tech "answers" to problems, it will miss the people who most need tracking.

2 Likes

Comparison Austria with Italy:

New Observations compared to 4 days ago

  1. Italy is still doing perfect with a weekly reproduction rate of 0.67.
  2. Austria has for 4 days in a row a reproduction rate > 1 which means that they are getting a 2nd peak.

comparison US - Russia

New observations compared to 4 days ago

  1. The reproduction rate in Russia is for the first time diving below 1 which is good news.
  2. The reproduction rate for US is slowly further decreasing (at 4th of May = 0.77) which is also very good news.

comparison UK - India

Observations

  1. The increase in reproduction rate for the UK stopped and also went again down in the last 4 days which is very good news.
  2. The reproduction rate in India goes down but is still above 1 which is not good.

With so many states eager to 'open' up, it will be interesting to see what this looks like in 2-3 weeks.

2 Likes

With so many states eager to 'open' up, it will be interesting to see what this looks like in 2-3 weeks.

Yes, that is true. For the moment the downward trend is mainly thanks to New York which might be hiding the upward trend of several states that currently don't have that many confirmed cases as new york.

E.g. "scaled" comparison of states "Wisconsin" and "Arkansas".

Observations
Those 2 states are seeing an increased number of new cases recently. The estimated reproduction rate of Arkansas is already for 7 days in a row above 1 and that of Wisconsin just went above 1.

Comparison Sweden - Norway

Observations

  • The reproduction rate in Sweden hangs around 1 for quite some time (in other words number of confirmed cases is not decreasing).
  • Sweden has currently 15 times more deaths than Norway (3500 versus 230) while its population is only twice as big.
  • Fatality rate is much higher in Sweden (around 13%) than Norway (around 5%). This seems to indicate that in Sweden they are only testing the very ill people.
  • At this moment Sweden has also 25 times more confirmed cases per day than Norway (550 versus 20).

So far, Sweden is paying a high price for not going in lock down and is currently also in considerably worse situation than the neighbouring countries that went in lock down.