Recent

Author Topic: Corona outbreak  (Read 9480 times)

wp

  • Hero Member
  • *****
  • Posts: 11853
Corona outbreak
« on: March 19, 2020, 06:04:53 pm »
The Johns Hopkins University, Baltimore, publishes current counts of confirmed and recovered cases as well as deaths in the Corona outbreak for many countries. I wrote a little program which downloads the time-series values and displays them graphically in a TChart. I know that such programs can be found in the web at many places now, but having the data immediately available makes the program very agile. And there is an option to use a logarithmic scale for cumulative data which allows to detect when the currently exponential increase of cases begins to level out hopefully. And holding the CTRL key and left mouse button down, and dragging the mouse across data points allows to fit an exponential curve to the data points; the time for doubling the case counts as well as an estimage of the case count in 1 and 2 weeks are displayed in the status bar.

The attached screenshot compares the growth of confirmed cases for China/Hubei, South Korea, Iran, Italy and Germany. The line fitted to the exponential plot of Germany, extrapolated two weeks into the future, tells that there will be 400.000 confirmed cases then if the current measures fail (and if testing capacity will be sufficient to handle this).

The sources can be found on my github at https://github.com/wp-xyz/corona.git and can be compiled with Laz trunk or 2.0.6 and FPC trunk or 3.0.4 (others combinations not tested). I am developing on Windows, but I checked the program to run on Linux (Mint) and Mac (Mojave), too. For access to the Johns Hopkins server, the OpenSSL library must be available on the system; for Windows users, the libeay32.dll and ssleay32.dll must be available in the exe folder with the correct bitness.

Otto

  • Full Member
  • ***
  • Posts: 226
Re: Corona outbreak
« Reply #1 on: March 19, 2020, 06:45:25 pm »
Hello wp, thank you for sharing your work.

I wanted to ask whether the data on deaths also include age of previous diseases or additional parameters to better understand Covid-19's behaviour.

Otto.
Kind regards.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Corona outbreak
« Reply #2 on: March 19, 2020, 07:08:33 pm »
I am not a specialist here, but I am pretty sure that it is the total of persons who died due to Covid-19, no matter how old they were and which previous diseases they had. There are other documents on that site (https://github.com/CSSEGISandData/COVID-19) which you can study to get more detail, but probably you will also have to look at the main site of JHU or that of WHO. I only used this site because data are nicely accessible and can be downloaded easily.

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Corona outbreak
« Reply #3 on: March 19, 2020, 07:39:30 pm »
Hi wp thanks for sharing

I've got some sigsev

Those lines are the problems:

Code: Pascal  [Select][+][-]
  1. sa[0] := AnsiDequotedStr(sa[0], '"');
  2. sa[1] := AnsiDequotedStr(sa[1], '"');

Solved by just comment

My configuration is W10 64 bits and Lazarus 2.0.6 SVN 62129 and FPC 3.0.4

Best regards


wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Corona outbreak
« Reply #4 on: March 19, 2020, 07:43:07 pm »
Which country did you select?

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Corona outbreak
« Reply #5 on: March 19, 2020, 07:52:00 pm »
Which country did you select?

None. The exception is thrown at the begining in TMainForm.LoadLocations and in TMainForm.GetDataString when selecting any country

After comment those line all work very well

[EDIT] I've checked the csv all are unquoted except some but not many
« Last Edit: March 19, 2020, 07:53:47 pm by BeanzMaster »

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Corona outbreak
« Reply #6 on: March 19, 2020, 08:03:55 pm »
Cannot reproduce... Your Laz/FPC versions? OS/Widgetset? 32/64 bit?

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Corona outbreak
« Reply #7 on: March 19, 2020, 08:04:20 pm »
When the exception is raised i'm only see ASM windows, and point to  function AnsiDequotedStr(const S: string; AQuote: Char): string; 

By replacing with this quick function


Code: Pascal  [Select][+][-]
  1. Function MyDequotedStr(s: string) : String;
  2. var
  3.   i: integer;
  4. begin
  5.   Result :='';
  6.   for i:= 0 to length(s)-1 do
  7.   begin
  8.     if s[i]<>'"' then result := result + s[i];
  9.   end;
  10. end;  

All is fine
« Last Edit: March 19, 2020, 08:11:16 pm by BeanzMaster »

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Corona outbreak
« Reply #8 on: March 19, 2020, 08:05:35 pm »
My OS Win10 64
Lazarus 2.0.6 SVN 62129
FPC 3.0.4

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Corona outbreak
« Reply #9 on: March 19, 2020, 08:29:15 pm »
The program compiles and runs well, even on the Mac, on both Carbon and Cocoa widgetsets.

This is a very interesting initiative that helps understanding the dynamics of COVID-19. Is it possible to display cumulative data for the whole planet? This would be especially instructive by revealing a more or less clear exponential relationship.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: Corona outbreak
« Reply #10 on: March 19, 2020, 08:43:33 pm »
Sorry, I couldn't deny myself, so just ignore me, but there is no immune system (yeah, it's just a lie!). Free your mind and relax! Yes, this is an one post only ... (Truth is important, at least for me!) ... and now I'm calm again... enjoy the show...  :).
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Corona outbreak
« Reply #11 on: March 19, 2020, 08:56:12 pm »
Another good, well-researched site with reliable information is
https://healthmap.org/en/
Although it seems at first to be restricted to the UK, it also has up-to-date information from across the globe (see COVID-19 outbreak news).
The "Animate spread" button on the page
https://healthmap.org/covid-19/

is particularly illuminating, showing the worldwide spread of the virus since its first appearance in China.
« Last Edit: March 19, 2020, 09:03:30 pm by howardpc »

Otto

  • Full Member
  • ***
  • Posts: 226
Re: Corona outbreak
« Reply #12 on: March 19, 2020, 09:28:32 pm »
I am not a specialist here, but I am pretty sure that it is the total of persons who died due to Covid-19, no matter how old they were and which previous diseases they had. There are other documents on that site (https://github.com/CSSEGISandData/COVID-19) which you can study to get more detail, but probably you will also have to look at the main site of JHU or that of WHO. I only used this site because data are nicely accessible and can be downloaded easily.

Thank you wp for the answer.

I compiled the program and everything works regularly (Windows 10 64bit; FPC 3.0.4; Laz 2.0.6).
However, I've had problems with OpenSSL. Which version would you advise me to use?

Otto.
Kind regards.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Corona outbreak
« Reply #13 on: March 19, 2020, 10:20:16 pm »
The exception is thrown at the begining in TMainForm.LoadLocations and in TMainForm.GetDataString when selecting any country
OK, it happens on 64-bit Windows. Fixed.

I compiled the program and everything works regularly (Windows 10 64bit; FPC 3.0.4; Laz 2.0.6).
However, I've had problems with OpenSSL. Which version would you advise me to use?

https://forum.lazarus.freepascal.org/index.php/topic,46560.msg332387.html#msg332387 points to 32bit and 64 bit versions of the openssl dlls. You need the version which matches the bitness of your IDE (unless you are cross-compiling).

Is it possible to display cumulative data for the whole planet? This would be especially instructive by revealing a more or less clear exponential relationship.
It looks to me that the dataset used seems to contain both areas and sub-areas, I saw that US cities are contained together with their states which would count these cities twice. These cities are filtered out in my program, but I cannot guarantee that duplicates do not occur anywhere else.

I doubt that the global total sum is an exponential because the outbreaks sets in at different times and with different intensities, and in some countries (China, South Korea) the case count does not grow any more noticably.

See for example https://www.worldometers.info/coronavirus/ which can be switched to logarithmic scale.
« Last Edit: March 19, 2020, 10:43:44 pm by wp »

Otto

  • Full Member
  • ***
  • Posts: 226
Re: Corona outbreak
« Reply #14 on: March 19, 2020, 10:48:40 pm »
https://forum.lazarus.freepascal.org/index.php/topic,46560.msg332387.html#msg332387 points to 32bit and 64 bit versions of the openssl dlls. You need the version which matches the bitness of your IDE (unless you are cross-compiling).

Perfect, It all works properly now.

I would suggest adding the link to the openssl dlls on your project's GitHub web page.

Thank you again for sharing your work.

Otto.
Kind regards.

 

TinyPortal © 2005-2018