-
Notifications
You must be signed in to change notification settings - Fork 2
/
graphgenerator.koi
1 lines (1 loc) · 137 KB
/
graphgenerator.koi
1
{"nodes":[{"nid":4,"version":"0.0.1","uid":5,"category":"logical","type":"Data2Terminal","x":69,"y":490,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"@on_start\ndef data2Terminal|||(*args,**kwargs):\n global {userinput}\n skwargs=kwargs.copy()\n print('kwargs from this node available as global variable {userinput}')\n return kwargs","python_import":"","python_exec":"data2Terminal|||","settings":[{"key":"userinput","label":"Global Variable Name"}],"icon":"./static/media/blankNode.38260d5b.svg","data":{"undefined":"","userinput":"skwargs"},"kwargs":{},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\nDumps kwargs in a node to a user specified global variable\n\n_Allows you to introspect within nodes after your algorithm completes_\n\n[YOUR GITHUB PAGE FOR THE NODE SOURCE](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links)\n\n## This Node Changes\n\n![TRANSITION](http://go.pluricorp.com/websitemedia/gitlab/templatetransition.svg)\n\nThis node takes a Pandas Dataframe in outputs and excel file and returns kwargs unchanged to the next node.\n\n## Getting This Node to Work\n\nThis node will work if it provided with a Dataframe in kwargs{Data} and Pandas is installed\n\n### Installing Dependencies\n\nThis node requires Pandas. Pandas can be installed using pip in your terminal \n\n```bash\npip install pandas\n```\n\nif you have python2 and python3 installed\n\n```bash\npip3 install pandas\n```\n\nIf you are using Anaconda (Pandas is already installed in the default setup):\n\n```bash\nconda install pandas\n```\n\n### Input State Requirements\n\nThis node requires that kwargs{Data} be a [Pandas Dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)\n\n```python\nkwargs={\n Start: True,\n Settings: Any,\n Data: Any Pandas Dataframe,\n Status: Any,\n }\n```\n\n### Output State\n\n```python\nkwargs={\n Start: No Change,\n Settings: No Change,\n Data: No Change,\n Status: No Change\n }\n```\n\n## Example Usage\n\nCheck out this simple demo of this node working : [Download Koi](https://mykoilocation.com)\n\n![STREMEExample](http://go.pluricorp.com/websitemedia/gitlab/example.gif)\n\n## Todo\n\n- Something\n\n- Another Thing\n\n- Something Else\n\n## Known Issues\n\n- We coded it poorly\n\n- Works only on the first of every month that is also within 5 days of the summer solstice \n\n## License\n\nUsage of this node is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"userinput\",\"label\":\"Global Variable Name\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#15ad60"}},{"nid":0,"version":"1.0.0","uid":1,"category":"function","type":"Start","x":10,"y":10,"headerStyle":{"background":""},"fields":{"in":[],"out":[{"name":"start"}]},"python":"def start():\n return {'Start':True,'Settings':{'Verbose':True},'Status':{},'Threads':[]}\n","python_import":"","python_exec":"start","settings":[],"icon":"./static/media/start.c59e7ea6.svg","data":{},"kwargs":{},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\nThe Start Node \n\n_This node is required to run a standard nodegraph that use the onstart decorator_\n\n\n## This Node Changes\n\nThis node initializes all standard kwargs\n\n## Getting This Node to Work\n\nThis node takes no inputs and only one can be connected in any given nodegraph. It sets Verbose to True by default, this setting outputs nodes run in the terminal when they are running and other debugging information. \n\n\n### Input State Requirements\n\nNone\n\n### Output State\n\n```python\nkwargs={\n Start: {},\n Settings: {Verbose:True},\n Data:{},\n Status: {}\n }\n```\n\n## Example Usage\n\n![STREMEExample](http://go.pluricorp.com/websitemedia/gitlab/example.gif)\n\n## Todo\n\n## Known Issues\n\nNo known Issues\n\n## License\n\nUsage of this node is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n\nThis node signifies the beginning of your node graph by the streme server. The start node passes true from the start output pin initiating the nodes it is connected to.","showExecution":false,"showDescription":false,"showImports":false,"showFunction":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[]","stringPins":"{\"in\":[],\"out\":[{\"name\":\"start\"}]}","togglePins":false},{"nid":1,"version":"1.0.0","uid":10,"category":"function","type":"Stop","x":1037,"y":118,"headerStyle":{"background":"#ad1562"},"fields":{"in":[{"name":"start"}],"out":[]},"python":"@on_start\ndef stop(*args,**kwargs):\n print('exiting')\n sys.exit()\n ","python_import":"import sys","python_exec":"stop","settings":[],"icon":"./static/media/stop.a2171794.svg","data":{},"kwargs":{},"description":"This node ends the existing node experiment. It will not stop processes that have started in parallel using split nodes.","showExecution":false,"showDescription":false,"showImports":false,"showFunction":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[]}","togglePins":false},{"nid":3,"version":"0.0.1","uid":5,"category":"logical","type":"Generate nodeGraph","x":91,"y":113,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"@on_start\ndef nodeGraph(*args,**kwargs):\n nodes = {nodes}\n k = {k}\n prob = {prob}\n G = nx.newman_watts_strogatz_graph(nodes, k, prob)\n kwargs['Settings']['NetworkX']={{\"nodes\":nodes, \"k\":k,\"prob\":prob}}\n pos = nx.spring_layout(G)\n kwargs['Settings']['NetworkX']['Pos']= pos\n #nx.draw(G, with_labels=True, font_weight='bold',pos=pos)\n #plt.show()\n \n kwargs['Data'] = G\n return kwargs","python_import":"import networkx as nx\nimport matplotlib.pyplot as plt","python_exec":"nodeGraph","settings":[{"key":"nodes","label":"Number of Nodes (Integer)"},{"key":"k","label":"Mean number of edges per node (Integer)"},{"key":"prob","label":"Probability nodes will have an extra edge (0-1)"}],"icon":"./static/media/blankNode.38260d5b.svg","data":{"Filename6kl5hte":"","nodes":"8000","k":"20","prob":"0.1","anodes":"10"},"kwargs":{},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"nodes\",\"label\":\"Number of Nodes (Integer)\"},{\"key\":\"k\",\"label\":\"Mean number of edges per node (Integer)\"},{\"key\":\"prob\",\"label\":\"Probability nodes will have an extra edge (0-1)\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#15ad60"},"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":7,"uid":"custom","category":"function","type":"Simulation Loop (Ebola)","x":912,"y":584,"fields":{"in":[{"name":"start"},{"name":"action1"},{"name":"action2"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[15,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n pos = kwargs['Settings']['NetworkX']['Pos']\n G = kwargs['Data']\n screensize = (1000,900)\n inflength = 16\n mortality = 0.7\n rnaught = 2.0\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n G.graph['colors'] = {\"Naive\":(52, 101, 164),\"Infected\":(78, 154, 6),\"Immune\":(237, 212, 0),\"Dead\":(204, 0, 0)}\n G.graph['disease'] = {\"Infection Probability\" : infprob, \"Infection Length\" : inflength, \"Mortality\": mortality}\n # Add Parameters to Nodegraph\n for nid in G:\n G.node[nid]['Status'] = 'Naive'\n G.node[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n G.node[0]['Status'] = 'Infected'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pygame.image.load(\"logo32x32.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"Pygame Simulation\")\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((250, 250, 250))\n green = (0, 255, 0) \n blue = (0, 0, 128) \n deaths = 0\n infected = 1\n font = pg.font.Font('freesansbold.ttf', 32)\n text = font.render('R0:{}'.format(rnaught), True, green, blue)\n textinfected = font.render('Infected:{}'.format(infected), True, green, blue)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n infected = 0\n screen.blit(background, (0, 0))\n screen.blit(text, (0,0))\n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(85, 87, 83))\n for nid in pos:\n color = G.graph['colors'][G.node[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n if G.node[nid]['Status'] == \"Infected\":\n infected = infected+1\n if G.node[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.node[nid]['Status'] = \"Immune\"\n if roll < G.graph['disease']['Mortality']:\n G.node[nid]['Status'] = \"Dead\"\n deaths=deaths+1\n G.node[nid]['Day'] = G.node[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.node[cnode]['Status'] != \"Dead\": \n if G.node[cnode]['Status'] != \"Immune\":\n roll = random.random()\n if roll < G.graph['disease']['Infection Probability']:\n G.node[cnode]['Status'] = 'Infected'\n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n textdeath = font.render('Deaths:{}'.format(deaths), True, green, blue)\n screen.blit(textdeath, (0,30))\n pg.display.flip()\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport numpy as np\nimport random","python_exec":"simLoop|||","settings":[],"icon":"./static/media/for.e1841ce0.svg","data":{},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[]","stringPins":"{\"in\":[{\"name\":\"start\"},{\"name\":\"action1\"},{\"name\":\"action2\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false},{"nid":11,"uid":"custom","category":"function","type":"Simulation Loop (Meningococcal Disease)","x":731,"y":79,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n pos = kwargs['Settings']['NetworkX']['Pos']\n G = kwargs['Data']\n screensize = (1000,900)\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected\":(145, 238, 7),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob, \"Infection Length\" : inflength, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.node[nid]['Status'] = 'Naive'\n G.node[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n G.node[0]['Status'] = 'Infected'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = 1\n infday = 0 \n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n infected = 0\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],80),0)\n screen.blit(text, (10,10))\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,40))\n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.node[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n if G.node[nid]['Status'] == \"Infected\":\n infected = infected+1\n if G.node[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.node[nid]['Status'] = \"Immune\"\n if roll < G.graph['disease']['Mortality']:\n G.node[nid]['Status'] = \"Dead\"\n deaths=deaths+1\n G.node[nid]['Day'] = G.node[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.node[cnode]['Status'] != \"Dead\": \n roll = random.random()\n if roll < G.graph['disease']['Infection Probability']:\n G.node[cnode]['Status'] = 'Infected'\n G.node[cnode]['Day'] = 0\n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n screen.blit(legend,(825,20))\n pg.display.flip()\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport numpy as np\nimport random","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Bacterial Meningitis","rnaught":"2.5","infprob":"0","inflength":"21","mortality":"0.1"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#adac15"},"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":12,"uid":"custom","category":"logical","type":"data2Pickle","x":97,"y":385,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"@on_start\ndef data2Pickle|||(*args,**kwargs):\n pickle.dump(kwargs,open(\"{userinput}\",\"wb\"))\n return kwargs","python_import":"import pickle","python_exec":"data2Pickle|||","settings":[{"key":"userinput","label":"Save Path including Filename"}],"icon":"./static/media/blankNode.38260d5b.svg","data":{"undefined":"","userinput":"nodegraph8000.pkl"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\nDumps kwargs in a node to a user specified global variable\n\n_Allows you to introspect within nodes after your algorithm completes_\n\n[YOUR GITHUB PAGE FOR THE NODE SOURCE](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links)\n\n## This Node Changes\n\n![TRANSITION](http://go.pluricorp.com/websitemedia/gitlab/templatetransition.svg)\n\nThis node takes a Pandas Dataframe in outputs and excel file and returns kwargs unchanged to the next node.\n\n## Getting This Node to Work\n\nThis node will work if it provided with a Dataframe in kwargs{Data} and Pandas is installed\n\n### Installing Dependencies\n\nThis node requires Pandas. Pandas can be installed using pip in your terminal \n\n```bash\npip install pandas\n```\n\nif you have python2 and python3 installed\n\n```bash\npip3 install pandas\n```\n\nIf you are using Anaconda (Pandas is already installed in the default setup):\n\n```bash\nconda install pandas\n```\n\n### Input State Requirements\n\nThis node requires that kwargs{Data} be a [Pandas Dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)\n\n```python\nkwargs={\n Start: True,\n Settings: Any,\n Data: Any Pandas Dataframe,\n Status: Any,\n }\n```\n\n### Output State\n\n```python\nkwargs={\n Start: No Change,\n Settings: No Change,\n Data: No Change,\n Status: No Change\n }\n```\n\n## Example Usage\n\nCheck out this simple demo of this node working : [Download Koi](https://mykoilocation.com)\n\n![STREMEExample](http://go.pluricorp.com/websitemedia/gitlab/example.gif)\n\n## Todo\n\n- Something\n\n- Another Thing\n\n- Something Else\n\n## Known Issues\n\n- We coded it poorly\n\n- Works only on the first of every month that is also within 5 days of the summer solstice \n\n## License\n\nUsage of this node is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"userinput\",\"label\":\"Save Path including Filename\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#15ad60"},"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":14,"uid":"custom","category":"logical","type":"loadPickle","x":83,"y":566,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"@on_start\ndef loadPickle|||(*args,**kwargs):\n kwargs = pickle.load(open(\"{userinput}\",\"rb\"))\n return kwargs","python_import":"import pickle","python_exec":"loadPickle|||","settings":[{"key":"userinput","label":"Load Path including Filename"}],"icon":"./static/media/blankNode.38260d5b.svg","data":{"undefined":"","userinput":"nodegraph.pkl"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\nDumps kwargs in a node to a user specified global variable\n\n_Allows you to introspect within nodes after your algorithm completes_\n\n[YOUR GITHUB PAGE FOR THE NODE SOURCE](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links)\n\n## This Node Changes\n\n![TRANSITION](http://go.pluricorp.com/websitemedia/gitlab/templatetransition.svg)\n\nThis node takes a Pandas Dataframe in outputs and excel file and returns kwargs unchanged to the next node.\n\n## Getting This Node to Work\n\nThis node will work if it provided with a Dataframe in kwargs{Data} and Pandas is installed\n\n### Installing Dependencies\n\nThis node requires Pandas. Pandas can be installed using pip in your terminal \n\n```bash\npip install pandas\n```\n\nif you have python2 and python3 installed\n\n```bash\npip3 install pandas\n```\n\nIf you are using Anaconda (Pandas is already installed in the default setup):\n\n```bash\nconda install pandas\n```\n\n### Input State Requirements\n\nThis node requires that kwargs{Data} be a [Pandas Dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)\n\n```python\nkwargs={\n Start: True,\n Settings: Any,\n Data: Any Pandas Dataframe,\n Status: Any,\n }\n```\n\n### Output State\n\n```python\nkwargs={\n Start: No Change,\n Settings: No Change,\n Data: No Change,\n Status: No Change\n }\n```\n\n## Example Usage\n\nCheck out this simple demo of this node working : [Download Koi](https://mykoilocation.com)\n\n![STREMEExample](http://go.pluricorp.com/websitemedia/gitlab/example.gif)\n\n## Todo\n\n- Something\n\n- Another Thing\n\n- Something Else\n\n## Known Issues\n\n- We coded it poorly\n\n- Works only on the first of every month that is also within 5 days of the summer solstice \n\n## License\n\nUsage of this node is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"userinput\",\"label\":\"Load Path including Filename\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#15ad60"},"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":15,"uid":"custom","category":"logical","type":"Load NodeGraph 1200 People","x":93,"y":174,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"@on_start\ndef loadPickle|||(*args,**kwargs):\n kwargs = pickle.load(open(\"{userinput}\",\"rb\"))\n kwargs['Threads'] = []\n\n return kwargs","python_import":"import pickle","python_exec":"loadPickle|||","settings":[{"key":"userinput","label":"Load Path including Filename"}],"icon":"./static/media/blankNode.38260d5b.svg","data":{"undefined":"","userinput":"nodegraph.pkl"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\nDumps kwargs in a node to a user specified global variable\n\n_Allows you to introspect within nodes after your algorithm completes_\n\n[YOUR GITHUB PAGE FOR THE NODE SOURCE](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links)\n\n## This Node Changes\n\n![TRANSITION](http://go.pluricorp.com/websitemedia/gitlab/templatetransition.svg)\n\nThis node takes a Pandas Dataframe in outputs and excel file and returns kwargs unchanged to the next node.\n\n## Getting This Node to Work\n\nThis node will work if it provided with a Dataframe in kwargs{Data} and Pandas is installed\n\n### Installing Dependencies\n\nThis node requires Pandas. Pandas can be installed using pip in your terminal \n\n```bash\npip install pandas\n```\n\nif you have python2 and python3 installed\n\n```bash\npip3 install pandas\n```\n\nIf you are using Anaconda (Pandas is already installed in the default setup):\n\n```bash\nconda install pandas\n```\n\n### Input State Requirements\n\nThis node requires that kwargs{Data} be a [Pandas Dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)\n\n```python\nkwargs={\n Start: True,\n Settings: Any,\n Data: Any Pandas Dataframe,\n Status: Any,\n }\n```\n\n### Output State\n\n```python\nkwargs={\n Start: No Change,\n Settings: No Change,\n Data: No Change,\n Status: No Change\n }\n```\n\n## Example Usage\n\nCheck out this simple demo of this node working : [Download Koi](https://mykoilocation.com)\n\n![STREMEExample](http://go.pluricorp.com/websitemedia/gitlab/example.gif)\n\n## Todo\n\n- Something\n\n- Another Thing\n\n- Something Else\n\n## Known Issues\n\n- We coded it poorly\n\n- Works only on the first of every month that is also within 5 days of the summer solstice \n\n## License\n\nUsage of this node is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"userinput\",\"label\":\"Load Path including Filename\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":17,"uid":"custom","category":"function","type":"Simulation Loop (Polio)","x":736,"y":228,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n pos = kwargs['Settings']['NetworkX']['Pos']\n G = kwargs['Data']\n screensize = (1000,900)\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected\":(145, 238, 7),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob, \"Infection Length\" : inflength, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.node[nid]['Status'] = 'Naive'\n G.node[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n G.node[0]['Status'] = 'Infected'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = 1\n infday = 0 \n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n infected = 0\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],80),0)\n screen.blit(text, (10,10))\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,40))\n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.node[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n if G.node[nid]['Status'] == \"Infected\":\n infected = infected+1\n if G.node[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.node[nid]['Status'] = \"Immune\"\n if roll < G.graph['disease']['Mortality']:\n G.node[nid]['Status'] = \"Dead\"\n deaths=deaths+1\n G.node[nid]['Day'] = G.node[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.node[cnode]['Status'] != \"Dead\":\n if G.node[cnode]['Status'] != \"Immune\":\n roll = random.random()\n if roll < G.graph['disease']['Infection Probability']:\n G.node[cnode]['Status'] = 'Infected'\n G.node[cnode]['Day'] = 0\n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n screen.blit(legend,(825,20))\n pg.display.flip()\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport numpy as np\nimport random","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Polio","rnaught":"2.5","infprob":"0","inflength":"42","mortality":"0.001"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#adac15"},"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":18,"uid":"custom","category":"function","type":"Simulation Loop (Measles UnVaccinated)","x":745,"y":300,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n#############################################################################\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n pos = kwargs['Settings']['NetworkX']['Pos']\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected\":(145, 238, 7),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob, \"Infection Length\" : inflength, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n G.nodes[0]['Status'] = 'Infected'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = 1\n infday = 0 \n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n infected = 0\n if infday == 366:\n running = False\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],80),0)\n screen.blit(text, (10,10))\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,40))\n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n if G.nodes[nid]['Status'] == \"Infected\":\n infected = infected+1\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n roll = random.random()\n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected'\n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n screen.blit(legend,(625,-15))\n pg.display.flip()\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport numpy as np\nimport random\n","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Measles","rnaught":"15","infprob":"0","inflength":"8","mortality":"0.002"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showDescription":false,"showImports":false,"showFunction":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#adac15"}},{"nid":19,"uid":"custom","category":"function","type":"Simulation Loop (Ebola)","x":865,"y":438,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n pos = kwargs['Settings']['NetworkX']['Pos']\n G = kwargs['Data']\n screensize = (1000,900)\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected\":(145, 238, 7),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob, \"Infection Length\" : inflength, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.node[nid]['Status'] = 'Naive'\n G.node[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n G.node[0]['Status'] = 'Infected'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = 1\n infday = 0 \n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n infected = 0\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],80),0)\n screen.blit(text, (10,10))\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,40))\n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.node[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n if G.node[nid]['Status'] == \"Infected\":\n infected = infected+1\n if G.node[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.node[nid]['Status'] = \"Immune\"\n if roll < G.graph['disease']['Mortality']:\n G.node[nid]['Status'] = \"Dead\"\n deaths=deaths+1\n G.node[nid]['Day'] = G.node[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.node[cnode]['Status'] != \"Dead\":\n if G.node[cnode]['Status'] != \"Immune\":\n roll = random.random()\n if roll < G.graph['disease']['Infection Probability']:\n G.node[cnode]['Status'] = 'Infected'\n G.node[cnode]['Day'] = 0\n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n screen.blit(legend,(825,20))\n pg.display.flip()\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport numpy as np\nimport random","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Ebola","rnaught":"2","infprob":"0","inflength":"16","mortality":"0.8"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showDescription":false,"showImports":false,"showFunction":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#adac15"}},{"nid":23,"uid":"custom","category":"function","type":"Simulation Loop (Ebola PreVaccine)","x":954,"y":198,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n#############################################################################\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n pos = kwargs['Settings']['NetworkX']['Pos']\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected\":(145, 238, 7),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob, \"Infection Length\" : inflength, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n G.nodes[0]['Status'] = 'Infected'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = 1\n infday = 0 \n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n infected = 0\n if infday == 366:\n running = False\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],80),0)\n screen.blit(text, (10,10))\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,40))\n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n if G.nodes[nid]['Status'] == \"Infected\":\n infected = infected+1\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n roll = random.random()\n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected'\n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n screen.blit(legend,(625,-15))\n pg.display.flip()\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport numpy as np\nimport random\n","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Ebola","rnaught":"2","infprob":"0","inflength":"16","mortality":"0.8"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showDescription":true,"showImports":false,"showFunction":false,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#adac15"},"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":24,"uid":"custom","category":"function","type":"Simulation Loop (Normal Flu)","x":943,"y":320,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n#############################################################################\n\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n pos = kwargs['Settings']['NetworkX']['Pos']\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected\":(145, 238, 7),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob, \"Infection Length\" : inflength, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n G.nodes[0]['Status'] = 'Infected'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = 1\n infday = 0 \n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n infected = 0\n if infday == 366:\n running = False\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],80),0)\n screen.blit(text, (10,10))\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,40))\n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n if G.nodes[nid]['Status'] == \"Infected\":\n infected = infected+1\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n roll = random.random()\n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected'\n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n screen.blit(legend,(625,-15))\n pg.display.flip()\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport random\nimport numpy as np\n","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Normal Flu","rnaught":"2","infprob":"0","inflength":"8","mortality":"0.0015"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showDescription":false,"showImports":false,"showFunction":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"headerStyle":{"background":"#adac15"}},{"nid":26,"uid":"custom","category":"logical","type":"Load NodeGraph 6000 People","x":87,"y":256,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"@on_start\ndef loadPickle|||(*args,**kwargs):\n kwargs = pickle.load(open(\"{userinput}\",\"rb\"))\n kwargs['Threads'] = []\n\n return kwargs","python_import":"import pickle","python_exec":"loadPickle|||","settings":[{"key":"userinput","label":"Load Path including Filename"}],"icon":"./static/media/blankNode.38260d5b.svg","data":{"undefined":"","userinput":"nodegraph6000.pkl"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\nDumps kwargs in a node to a user specified global variable\n\n_Allows you to introspect within nodes after your algorithm completes_\n\n[YOUR GITHUB PAGE FOR THE NODE SOURCE](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links)\n\n## This Node Changes\n\n![TRANSITION](http://go.pluricorp.com/websitemedia/gitlab/templatetransition.svg)\n\nThis node takes a Pandas Dataframe in outputs and excel file and returns kwargs unchanged to the next node.\n\n## Getting This Node to Work\n\nThis node will work if it provided with a Dataframe in kwargs{Data} and Pandas is installed\n\n### Installing Dependencies\n\nThis node requires Pandas. Pandas can be installed using pip in your terminal \n\n```bash\npip install pandas\n```\n\nif you have python2 and python3 installed\n\n```bash\npip3 install pandas\n```\n\nIf you are using Anaconda (Pandas is already installed in the default setup):\n\n```bash\nconda install pandas\n```\n\n### Input State Requirements\n\nThis node requires that kwargs{Data} be a [Pandas Dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)\n\n```python\nkwargs={\n Start: True,\n Settings: Any,\n Data: Any Pandas Dataframe,\n Status: Any,\n }\n```\n\n### Output State\n\n```python\nkwargs={\n Start: No Change,\n Settings: No Change,\n Data: No Change,\n Status: No Change\n }\n```\n\n## Example Usage\n\nCheck out this simple demo of this node working : [Download Koi](https://mykoilocation.com)\n\n![STREMEExample](http://go.pluricorp.com/websitemedia/gitlab/example.gif)\n\n## Todo\n\n- Something\n\n- Another Thing\n\n- Something Else\n\n## Known Issues\n\n- We coded it poorly\n\n- Works only on the first of every month that is also within 5 days of the summer solstice \n\n## License\n\nUsage of this node is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n","showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"userinput\",\"label\":\"Load Path including Filename\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":27,"uid":"custom","category":"logical","type":"Load NodeGraph Los Angeles","x":1200,"y":262,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"@on_start\ndef loadPickle|||(*args,**kwargs):\n kwargs = pickle.load(open(\"{userinput}\",\"rb\"))\n kwargs['Threads'] = []\n\n return kwargs","python_import":"import pickle","python_exec":"loadPickle|||","settings":[{"key":"userinput","label":"Load Path including Filename"}],"icon":"./static/media/blankNode.38260d5b.svg","data":{"undefined":"","userinput":"nodegraph40000.pkl"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\nDumps kwargs in a node to a user specified global variable\n\n_Allows you to introspect within nodes after your algorithm completes_\n\n[YOUR GITHUB PAGE FOR THE NODE SOURCE](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links)\n\n## This Node Changes\n\n![TRANSITION](http://go.pluricorp.com/websitemedia/gitlab/templatetransition.svg)\n\nThis node takes a Pandas Dataframe in outputs and excel file and returns kwargs unchanged to the next node.\n\n## Getting This Node to Work\n\nThis node will work if it provided with a Dataframe in kwargs{Data} and Pandas is installed\n\n### Installing Dependencies\n\nThis node requires Pandas. Pandas can be installed using pip in your terminal \n\n```bash\npip install pandas\n```\n\nif you have python2 and python3 installed\n\n```bash\npip3 install pandas\n```\n\nIf you are using Anaconda (Pandas is already installed in the default setup):\n\n```bash\nconda install pandas\n```\n\n### Input State Requirements\n\nThis node requires that kwargs{Data} be a [Pandas Dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)\n\n```python\nkwargs={\n Start: True,\n Settings: Any,\n Data: Any Pandas Dataframe,\n Status: Any,\n }\n```\n\n### Output State\n\n```python\nkwargs={\n Start: No Change,\n Settings: No Change,\n Data: No Change,\n Status: No Change\n }\n```\n\n## Example Usage\n\nCheck out this simple demo of this node working : [Download Koi](https://mykoilocation.com)\n\n![STREMEExample](http://go.pluricorp.com/websitemedia/gitlab/example.gif)\n\n## Todo\n\n- Something\n\n- Another Thing\n\n- Something Else\n\n## Known Issues\n\n- We coded it poorly\n\n- Works only on the first of every month that is also within 5 days of the summer solstice \n\n## License\n\nUsage of this node is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n","showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"userinput\",\"label\":\"Load Path including Filename\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false},{"nid":28,"uid":"custom","category":"function","type":"Simulation Loop (Wuhan Corona Virus) China","x":419,"y":422,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n infincubation={infincubation}\n infdetected = {infdetected}\n#############################################################################\n\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n pos = kwargs['Settings']['NetworkX']['Pos']\n #rng = default_rng()\n #initialinf = rng.choice({startinf}*2, size={startinf}, replace=False)\n initialinf = random.sample(range({startinf}*2),{startinf})\n\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected Symptomatic\":(145, 238, 7),\"Infected Asymptomatic\":(159, 190, 126),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob,\"Infection Detection\":infdetected, \"Infection Length\" : inflength, \"Incubation Length\":infincubation, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n for nid in initialinf:\n G.nodes[nid]['Status'] = 'Infected Asymptomatic'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = {startinf}\n asymptomatic={startinf}\n symptomatic=0 \n willdie=0\n infday = 0 \n detected = 0\n immune = 0 \n datacontainer={{\"Day\":[],\"Deaths\":[],\"Cumulative Infections\":[],\"Detected Infections\":[],\"Current Asymptomatic Infections\":[],\"Current Infectious Carriers\":[]}}\n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n #infected = 0\n############################### STOP CRITERIA ########################################################\n# if infday >= 6:\n# running = False\n# totaldetected = infected - (asymptomatic+immune+deaths)\n# if detected >= 2:\n# running = False\n if deaths >=106:\n running = False\n \n#######################################################################################################\n\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],120),0)\n\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,10))\n textinfected = font.render('Cumulative Infections: {{}}'.format(infected), True, green)\n screen.blit(textinfected, (10,25))\n \n textinfected = font.render('Recoveries: {{}}'.format(immune), True, green)\n screen.blit(textinfected, (10,55))\n textinfected = font.render('Naive: {{}}'.format(kwargs['Settings']['NetworkX']['nodes']-infected), True, green)\n screen.blit(textinfected, (10,40))\n #totaldetected = infected - (asymptomatic+immune+deaths)\n textsymptomatic = font.render('Cumulative Detected Infections: {{}}'.format(detected), True, green)\n screen.blit(textsymptomatic, (10,70))\n \n textasymptomatic = font.render('Current Asymptomatic Infections: {{}}'.format(asymptomatic), True, green)\n screen.blit(textasymptomatic, (10,85))\n carriers = infected-asymptomatic-detected\n textcarriers = font.render('Current Infectious Carriers: {{}}'.format(carriers), True, green)\n screen.blit(textcarriers, (10,100))\n \n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n textrnaught = font.render('R0: {{}}'.format(rnaught), True, green)\n screen.blit(textrnaught, ((screensize[0]/2)-40,25))\n \n textmortality = font.render('Mortality Rate: {{}} %'.format(mortality*100), True, green)\n screen.blit(textmortality, ((screensize[0]/2)+40,25))\n datacontainer['Day'].append(infday)\n datacontainer['Deaths'].append(deaths)\n datacontainer['Cumulative Infections'].append(infected)\n datacontainer['Detected Infections'].append(detected)\n datacontainer['Current Asymptomatic Infections'].append(asymptomatic)\n datacontainer['Current Infectious Carriers'].append(carriers)\n \n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n \n if G.nodes[nid]['Day'] == G.graph['disease']['Infection Detection']:\n detected = detected + 1 \n if G.nodes[nid]['Status'] == \"Infected Symptomatic\":\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n immune = immune+1\n symptomatic = symptomatic-1\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n symptomatic = symptomatic-1\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n if G.nodes[cnode]['Status'] != \"Infected Asymptomatic\":\n if G.nodes[cnode]['Status'] != \"Infected Symptomatic\":\n roll = random.random()\n \n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected Asymptomatic'\n infected = infected+1\n asymptomatic = asymptomatic+1\n \n \n if G.nodes[nid]['Status'] == \"Infected Asymptomatic\":\n if G.nodes[nid]['Day'] >= G.graph['disease'][\"Incubation Length\"]:\n asymptomatic = asymptomatic-1\n symptomatic = symptomatic+1\n G.nodes[nid]['Status'] = \"Infected Symptomatic\"\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1 \n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n \n screen.blit(legend,(625,-15))\n pg.display.flip()\n time.sleep(10)\n df=pd.DataFrame(datacontainer)\n print(df)\n df = df[['Deaths','Detected Infections','Cumulative Infections','Current Asymptomatic Infections','Current Infectious Carriers']].rolling(1).sum()\n #sns.barplot(x = 'Day', y = 'Cumulative Infections', data = df)\n #sns.barplot(x = 'Day', y = 'Detected Infections', palette = 'magma', data = df)\n sns.lineplot(data=df, linewidth=2)\n\n\n plt.show()\n df.to_excel('summarydataChina.xlsx')\n kwargs['Data'] = df\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport random\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\n\nimport time","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"infincubation","label":"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day "},{"key":"infdetected","label":"Number of Simulation Cycles before illness Detection"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"},{"key":"startinf","label":"Number of Initial Seed infections"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Novel coronavirus (2019-nCoV) Wuhan Virus China","rnaught":"0","infprob":"0.049","inflength":"20","mortality":"0.0815","infincubation":"5","infdetected":"10","startinf":"21"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"infincubation\",\"label\":\"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day \"},{\"key\":\"infdetected\",\"label\":\"Number of Simulation Cycles before illness Detection\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"},{\"key\":\"startinf\",\"label\":\"Number of Initial Seed infections\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false,"showImports":false,"headerStyle":{"background":"#1562ad"}},{"nid":32,"uid":"custom","category":"function","type":"Simulation Loop (Wuhan Corona Virus) Los Angeles Possible Case","x":416,"y":113,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n infincubation={infincubation}\n infdetected = {infdetected}\n#############################################################################\n\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n pos = kwargs['Settings']['NetworkX']['Pos']\n #initialinf = rng.choice({startinf}*2, size={startinf}, replace=False)\n initialinf = random.sample(range({startinf}*2),{startinf})\n\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected Symptomatic\":(145, 238, 7),\"Infected Asymptomatic\":(159, 190, 126),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob,\"Infection Detection\":infdetected, \"Infection Length\" : inflength, \"Incubation Length\":infincubation, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n for nid in initialinf:\n G.nodes[nid]['Status'] = 'Infected Asymptomatic'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = {startinf}\n asymptomatic={startinf}\n symptomatic=0 \n willdie=0\n infday = 0 \n detected = 0\n immune = 0 \n datacontainer={{\"Day\":[],\"Deaths\":[],\"Cumulative Infections\":[],\"Detected Infections\":[],\"Current Asymptomatic Infections\":[],\"Current Infectious Carriers\":[]}}\n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n #infected = 0\n############################### STOP CRITERIA ########################################################\n# if infday >= 6:\n# running = False\n# totaldetected = infected - (asymptomatic+immune+deaths)\n if detected >= 2:\n running = False\n# if deaths >=56:\n# running = False\n \n#######################################################################################################\n\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],120),0)\n\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,10))\n textinfected = font.render('Cumulative Infections: {{}}'.format(infected), True, green)\n screen.blit(textinfected, (10,25))\n \n textinfected = font.render('Recoveries: {{}}'.format(immune), True, green)\n screen.blit(textinfected, (10,55))\n textinfected = font.render('Naive: {{}}'.format(kwargs['Settings']['NetworkX']['nodes']-infected), True, green)\n screen.blit(textinfected, (10,40))\n #totaldetected = infected - (asymptomatic+immune+deaths)\n textsymptomatic = font.render('Cumulative Detected Infections: {{}}'.format(detected), True, green)\n screen.blit(textsymptomatic, (10,70))\n \n textasymptomatic = font.render('Current Asymptomatic Infections: {{}}'.format(asymptomatic), True, green)\n screen.blit(textasymptomatic, (10,85))\n carriers = infected-asymptomatic-detected\n textcarriers = font.render('Current Infectious Carriers: {{}}'.format(carriers), True, green)\n screen.blit(textcarriers, (10,100))\n \n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n textrnaught = font.render('R0: {{}}'.format(rnaught), True, green)\n screen.blit(textrnaught, ((screensize[0]/2)-40,25))\n \n textmortality = font.render('Mortality Rate: {{}} %'.format(mortality*100), True, green)\n screen.blit(textmortality, ((screensize[0]/2)+40,25))\n datacontainer['Day'].append(infday)\n datacontainer['Deaths'].append(deaths)\n datacontainer['Cumulative Infections'].append(infected)\n datacontainer['Detected Infections'].append(detected)\n datacontainer['Current Asymptomatic Infections'].append(asymptomatic)\n datacontainer['Current Infectious Carriers'].append(carriers)\n \n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n \n if G.nodes[nid]['Day'] == G.graph['disease']['Infection Detection']:\n detected = detected + 1 \n if G.nodes[nid]['Status'] == \"Infected Symptomatic\":\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n immune = immune+1\n symptomatic = symptomatic-1\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n symptomatic = symptomatic-1\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n if G.nodes[cnode]['Status'] != \"Infected Asymptomatic\":\n if G.nodes[cnode]['Status'] != \"Infected Symptomatic\":\n roll = random.random()\n \n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected Asymptomatic'\n infected = infected+1\n asymptomatic = asymptomatic+1\n \n \n if G.nodes[nid]['Status'] == \"Infected Asymptomatic\":\n if G.nodes[nid]['Day'] >= G.graph['disease'][\"Incubation Length\"]:\n asymptomatic = asymptomatic-1\n symptomatic = symptomatic+1\n G.nodes[nid]['Status'] = \"Infected Symptomatic\"\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1 \n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n \n screen.blit(legend,(625,-15))\n pg.display.flip()\n time.sleep(10)\n df=pd.DataFrame(datacontainer)\n print(df)\n df = df[['Deaths','Detected Infections','Cumulative Infections','Current Asymptomatic Infections','Current Infectious Carriers']].rolling(1).sum()\n #sns.barplot(x = 'Day', y = 'Cumulative Infections', data = df)\n #sns.barplot(x = 'Day', y = 'Detected Infections', palette = 'magma', data = df)\n sns.lineplot(data=df, linewidth=2)\n\n\n plt.show()\n df.to_excel('summarydataLosAngelesPossibleCase.xlsx')\n kwargs['Data'] = df\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport random\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport datetime\n\n\nimport time","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"infincubation","label":"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day "},{"key":"infdetected","label":"Number of Simulation Cycles before illness Detection"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"},{"key":"startinf","label":"Number of Initial Seed infections"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Novel coronavirus (2019-nCoV) Wuhan Virus Los Angeles","rnaught":"0","infprob":"0.049","inflength":"20","mortality":"0.0815","infincubation":"5","infdetected":"10","startinf":"18"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"infincubation\",\"label\":\"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day \"},{\"key\":\"infdetected\",\"label\":\"Number of Simulation Cycles before illness Detection\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"},{\"key\":\"startinf\",\"label\":\"Number of Initial Seed infections\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false,"showImports":false,"headerStyle":{"background":"#15ad60"}},{"nid":33,"uid":"custom","category":"function","type":"Simulation Loop (Wuhan Corona Virus) Los Angeles Best Case","x":417,"y":5,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n infincubation={infincubation}\n infdetected = {infdetected}\n#############################################################################\n\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n pos = kwargs['Settings']['NetworkX']['Pos']\n #initialinf = rng.choice({startinf}*2, size={startinf}, replace=False)\n initialinf = random.sample(range({startinf}*2),{startinf})\n\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected Symptomatic\":(145, 238, 7),\"Infected Asymptomatic\":(159, 190, 126),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob,\"Infection Detection\":infdetected, \"Infection Length\" : inflength, \"Incubation Length\":infincubation, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n for nid in initialinf:\n G.nodes[nid]['Status'] = 'Infected Asymptomatic'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = {startinf}\n asymptomatic={startinf}\n symptomatic=0 \n willdie=0\n infday = 0 \n detected = 0\n immune = 0 \n datacontainer={{\"Day\":[],\"Deaths\":[],\"Cumulative Infections\":[],\"Detected Infections\":[],\"Current Asymptomatic Infections\":[],\"Current Infectious Carriers\":[]}}\n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n d0 = datetime.date(2020, 1, 16)\n d1 = datetime.datetime.now().date()\n delta = d1 - d0\n delta = delta.days\n # main loop\n while running:\n #infected = 0\n############################### STOP CRITERIA ########################################################\n if infday >= delta:\n running = False\n# totaldetected = infected - (asymptomatic+immune+deaths)\n# if detected >= 2:\n# running = False\n# if deaths >=56:\n# running = False\n \n#######################################################################################################\n\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],120),0)\n\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,10))\n textinfected = font.render('Cumulative Infections: {{}}'.format(infected), True, green)\n screen.blit(textinfected, (10,25))\n \n textinfected = font.render('Recoveries: {{}}'.format(immune), True, green)\n screen.blit(textinfected, (10,55))\n textinfected = font.render('Naive: {{}}'.format(kwargs['Settings']['NetworkX']['nodes']-infected), True, green)\n screen.blit(textinfected, (10,40))\n #totaldetected = infected - (asymptomatic+immune+deaths)\n textsymptomatic = font.render('Cumulative Detected Infections: {{}}'.format(detected), True, green)\n screen.blit(textsymptomatic, (10,70))\n \n textasymptomatic = font.render('Current Asymptomatic Infections: {{}}'.format(asymptomatic), True, green)\n screen.blit(textasymptomatic, (10,85))\n carriers = infected-asymptomatic-detected\n textcarriers = font.render('Current Infectious Carriers: {{}}'.format(carriers), True, green)\n screen.blit(textcarriers, (10,100))\n \n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n textrnaught = font.render('R0: {{}}'.format(rnaught), True, green)\n screen.blit(textrnaught, ((screensize[0]/2)-40,25))\n \n textmortality = font.render('Mortality Rate: {{}} %'.format(mortality*100), True, green)\n screen.blit(textmortality, ((screensize[0]/2)+40,25))\n datacontainer['Day'].append(infday)\n datacontainer['Deaths'].append(deaths)\n datacontainer['Cumulative Infections'].append(infected)\n datacontainer['Detected Infections'].append(detected)\n datacontainer['Current Asymptomatic Infections'].append(asymptomatic)\n datacontainer['Current Infectious Carriers'].append(carriers)\n \n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n \n if G.nodes[nid]['Day'] == G.graph['disease']['Infection Detection']:\n detected = detected + 1 \n if G.nodes[nid]['Status'] == \"Infected Symptomatic\":\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n immune = immune+1\n symptomatic = symptomatic-1\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n symptomatic = symptomatic-1\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n if G.nodes[cnode]['Status'] != \"Infected Asymptomatic\":\n if G.nodes[cnode]['Status'] != \"Infected Symptomatic\":\n roll = random.random()\n \n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected Asymptomatic'\n infected = infected+1\n asymptomatic = asymptomatic+1\n \n \n if G.nodes[nid]['Status'] == \"Infected Asymptomatic\":\n if G.nodes[nid]['Day'] >= G.graph['disease'][\"Incubation Length\"]:\n asymptomatic = asymptomatic-1\n symptomatic = symptomatic+1\n G.nodes[nid]['Status'] = \"Infected Symptomatic\"\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1 \n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n \n screen.blit(legend,(625,-15))\n pg.display.flip()\n time.sleep(10)\n df=pd.DataFrame(datacontainer)\n print(df)\n df = df[['Deaths','Detected Infections','Cumulative Infections','Current Asymptomatic Infections','Current Infectious Carriers']].rolling(1).sum()\n #sns.barplot(x = 'Day', y = 'Cumulative Infections', data = df)\n #sns.barplot(x = 'Day', y = 'Detected Infections', palette = 'magma', data = df)\n sns.lineplot(data=df, linewidth=2)\n\n\n plt.show()\n df.to_excel('summarydataLosAngelesBestCase.xlsx')\n kwargs['Data'] = df\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport random\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport datetime\n\nimport time","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"infincubation","label":"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day "},{"key":"infdetected","label":"Number of Simulation Cycles before illness Detection"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"},{"key":"startinf","label":"Number of Initial Seed infections"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Novel coronavirus (2019-nCoV) Wuhan Virus Los Angeles","rnaught":"0","infprob":"0.049","inflength":"20","mortality":"0.0815","infincubation":"5","infdetected":"10","startinf":"2"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"infincubation\",\"label\":\"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day \"},{\"key\":\"infdetected\",\"label\":\"Number of Simulation Cycles before illness Detection\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"},{\"key\":\"startinf\",\"label\":\"Number of Initial Seed infections\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false,"showImports":false,"headerStyle":{"background":"#15ad60"}},{"nid":34,"uid":"custom","category":"function","type":"Simulation Loop (Wuhan Corona Virus) Los Angeles Worst Case","x":416,"y":222,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n infincubation={infincubation}\n infdetected = {infdetected}\n#############################################################################\n\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n pos = kwargs['Settings']['NetworkX']['Pos']\n #rng = default_rng()\n #initialinf = rng.choice({startinf}*2, size={startinf}, replace=False)\n initialinf = random.sample(range({startinf}*2),{startinf})\n\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected Symptomatic\":(145, 238, 7),\"Infected Asymptomatic\":(159, 190, 126),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob,\"Infection Detection\":infdetected, \"Infection Length\" : inflength, \"Incubation Length\":infincubation, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n for nid in initialinf:\n G.nodes[nid]['Status'] = 'Infected Asymptomatic'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = {startinf}\n asymptomatic={startinf}\n symptomatic=0 \n willdie=0\n infday = 0 \n detected = 0\n immune = 0 \n datacontainer={{\"Day\":[],\"Deaths\":[],\"Cumulative Infections\":[],\"Detected Infections\":[],\"Current Asymptomatic Infections\":[],\"Current Infectious Carriers\":[]}}\n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n d0 = datetime.date(2020, 1, 3)\n d1 = datetime.datetime.now().date()\n delta = d1 - d0\n delta = delta.days\n \n # main loop\n while running:\n #infected = 0\n############################### STOP CRITERIA ########################################################\n if infday >= delta:\n running = False\n# totaldetected = infected - (asymptomatic+immune+deaths)\n# if detected >= 2:\n# running = False\n# if deaths >=56:\n# running = False\n \n#######################################################################################################\n\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],120),0)\n\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,10))\n textinfected = font.render('Cumulative Infections: {{}}'.format(infected), True, green)\n screen.blit(textinfected, (10,25))\n \n textinfected = font.render('Recoveries: {{}}'.format(immune), True, green)\n screen.blit(textinfected, (10,55))\n textinfected = font.render('Naive: {{}}'.format(kwargs['Settings']['NetworkX']['nodes']-infected), True, green)\n screen.blit(textinfected, (10,40))\n #totaldetected = infected - (asymptomatic+immune+deaths)\n textsymptomatic = font.render('Cumulative Detected Infections: {{}}'.format(detected), True, green)\n screen.blit(textsymptomatic, (10,70))\n \n textasymptomatic = font.render('Current Asymptomatic Infections: {{}}'.format(asymptomatic), True, green)\n screen.blit(textasymptomatic, (10,85))\n carriers = infected-asymptomatic-detected\n textcarriers = font.render('Current Infectious Carriers: {{}}'.format(carriers), True, green)\n screen.blit(textcarriers, (10,100))\n \n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n textrnaught = font.render('R0: {{}}'.format(rnaught), True, green)\n screen.blit(textrnaught, ((screensize[0]/2)-40,25))\n \n textmortality = font.render('Mortality Rate: {{}} %'.format(mortality*100), True, green)\n screen.blit(textmortality, ((screensize[0]/2)+40,25))\n datacontainer['Day'].append(infday)\n datacontainer['Deaths'].append(deaths)\n datacontainer['Cumulative Infections'].append(infected)\n datacontainer['Detected Infections'].append(detected)\n datacontainer['Current Asymptomatic Infections'].append(asymptomatic)\n datacontainer['Current Infectious Carriers'].append(carriers)\n \n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n \n if G.nodes[nid]['Day'] == G.graph['disease']['Infection Detection']:\n detected = detected + 1 \n if G.nodes[nid]['Status'] == \"Infected Symptomatic\":\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n immune = immune+1\n symptomatic = symptomatic-1\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n symptomatic = symptomatic-1\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n if G.nodes[cnode]['Status'] != \"Infected Asymptomatic\":\n if G.nodes[cnode]['Status'] != \"Infected Symptomatic\":\n roll = random.random()\n \n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected Asymptomatic'\n infected = infected+1\n asymptomatic = asymptomatic+1\n \n \n if G.nodes[nid]['Status'] == \"Infected Asymptomatic\":\n if G.nodes[nid]['Day'] >= G.graph['disease'][\"Incubation Length\"]:\n asymptomatic = asymptomatic-1\n symptomatic = symptomatic+1\n G.nodes[nid]['Status'] = \"Infected Symptomatic\"\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1 \n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n \n screen.blit(legend,(625,-15))\n pg.display.flip()\n time.sleep(10)\n df=pd.DataFrame(datacontainer)\n print(df)\n df = df[['Deaths','Detected Infections','Cumulative Infections','Current Asymptomatic Infections','Current Infectious Carriers']].rolling(1).sum()\n #sns.barplot(x = 'Day', y = 'Cumulative Infections', data = df)\n #sns.barplot(x = 'Day', y = 'Detected Infections', palette = 'magma', data = df)\n sns.lineplot(data=df, linewidth=2)\n\n\n plt.show()\n df.to_excel('summarydataLosAngelesUndetectedCase.xlsx')\n kwargs['Data'] = df\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport random\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport datetime\n\n\nimport time","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"infincubation","label":"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day "},{"key":"infdetected","label":"Number of Simulation Cycles before illness Detection"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"},{"key":"startinf","label":"Number of Initial Seed infections"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Novel coronavirus (2019-nCoV) Wuhan Virus Los Angeles","rnaught":"0","infprob":"0.049","inflength":"20","mortality":"0.0815","infincubation":"5","infdetected":"10","startinf":"1"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"infincubation\",\"label\":\"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day \"},{\"key\":\"infdetected\",\"label\":\"Number of Simulation Cycles before illness Detection\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"},{\"key\":\"startinf\",\"label\":\"Number of Initial Seed infections\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false,"showImports":false,"headerStyle":{"background":"#15ad60"}},{"nid":35,"uid":"custom","category":"function","type":"Simulation Loop (Wuhan Corona Virus) Los Angeles Complete Run","x":415,"y":319,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n infincubation={infincubation}\n infdetected = {infdetected}\n#############################################################################\n\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n pos = kwargs['Settings']['NetworkX']['Pos']\n initialinf = random.sample(range({startinf}*2),{startinf})\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected Symptomatic\":(145, 238, 7),\"Infected Asymptomatic\":(159, 190, 126),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob,\"Infection Detection\":infdetected, \"Infection Length\" : inflength, \"Incubation Length\":infincubation, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n for nid in initialinf:\n G.nodes[nid]['Status'] = 'Infected Asymptomatic'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = {startinf}\n asymptomatic={startinf}\n symptomatic=0 \n willdie=0\n infday = 0 \n detected = 0\n immune = 0 \n datacontainer={{\"Day\":[],\"Deaths\":[],\"Cumulative Infections\":[],\"Detected Infections\":[],\"Current Asymptomatic Infections\":[],\"Current Infectious Carriers\":[]}}\n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n # main loop\n while running:\n #infected = 0\n############################### STOP CRITERIA ########################################################\n if infday >= 200:\n running = False\n# totaldetected = infected - (asymptomatic+immune+deaths)\n# if detected >= 2:\n# running = False\n# if deaths >=56:\n# running = False\n \n#######################################################################################################\n\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],120),0)\n\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,10))\n textinfected = font.render('Cumulative Infections: {{}}'.format(infected), True, green)\n screen.blit(textinfected, (10,25))\n \n textinfected = font.render('Recoveries: {{}}'.format(immune), True, green)\n screen.blit(textinfected, (10,55))\n textinfected = font.render('Naive: {{}}'.format(kwargs['Settings']['NetworkX']['nodes']-infected), True, green)\n screen.blit(textinfected, (10,40))\n #totaldetected = infected - (asymptomatic+immune+deaths)\n textsymptomatic = font.render('Cumulative Detected Infections: {{}}'.format(detected), True, green)\n screen.blit(textsymptomatic, (10,70))\n \n textasymptomatic = font.render('Current Asymptomatic Infections: {{}}'.format(asymptomatic), True, green)\n screen.blit(textasymptomatic, (10,85))\n carriers = infected-asymptomatic-detected\n textcarriers = font.render('Current Infectious Carriers: {{}}'.format(carriers), True, green)\n screen.blit(textcarriers, (10,100))\n \n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n textrnaught = font.render('R0: {{}}'.format(rnaught), True, green)\n screen.blit(textrnaught, ((screensize[0]/2)-40,25))\n \n textmortality = font.render('Mortality Rate: {{}} %'.format(mortality*100), True, green)\n screen.blit(textmortality, ((screensize[0]/2)+40,25))\n datacontainer['Day'].append(infday)\n datacontainer['Deaths'].append(deaths)\n datacontainer['Cumulative Infections'].append(infected)\n datacontainer['Detected Infections'].append(detected)\n datacontainer['Current Asymptomatic Infections'].append(asymptomatic)\n datacontainer['Current Infectious Carriers'].append(carriers)\n \n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n \n if G.nodes[nid]['Day'] == G.graph['disease']['Infection Detection']:\n detected = detected + 1 \n if G.nodes[nid]['Status'] == \"Infected Symptomatic\":\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n immune = immune+1\n symptomatic = symptomatic-1\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n symptomatic = symptomatic-1\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n if G.nodes[cnode]['Status'] != \"Infected Asymptomatic\":\n if G.nodes[cnode]['Status'] != \"Infected Symptomatic\":\n roll = random.random()\n \n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected Asymptomatic'\n infected = infected+1\n asymptomatic = asymptomatic+1\n \n \n if G.nodes[nid]['Status'] == \"Infected Asymptomatic\":\n if G.nodes[nid]['Day'] >= G.graph['disease'][\"Incubation Length\"]:\n asymptomatic = asymptomatic-1\n symptomatic = symptomatic+1\n G.nodes[nid]['Status'] = \"Infected Symptomatic\"\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1 \n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n \n screen.blit(legend,(625,-15))\n pg.display.flip()\n time.sleep(10)\n df=pd.DataFrame(datacontainer)\n print(df)\n df = df[['Deaths','Detected Infections','Cumulative Infections','Current Asymptomatic Infections','Current Infectious Carriers']].rolling(1).sum()\n #sns.barplot(x = 'Day', y = 'Cumulative Infections', data = df)\n #sns.barplot(x = 'Day', y = 'Detected Infections', palette = 'magma', data = df)\n sns.lineplot(data=df, linewidth=2)\n\n\n plt.show()\n df.to_excel('summarydataLosAngelesFullRun.xlsx')\n kwargs['Data'] = df\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport random\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nimport time","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"infincubation","label":"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day "},{"key":"infdetected","label":"Number of Simulation Cycles before illness Detection"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"},{"key":"startinf","label":"Number of Initial Seed infections"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Novel coronavirus (2019-nCoV) Wuhan Virus Los Angeles","rnaught":"0","infprob":"0.049","inflength":"20","mortality":"0.0815","infincubation":"5","infdetected":"10","startinf":"2"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"infincubation\",\"label\":\"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day \"},{\"key\":\"infdetected\",\"label\":\"Number of Simulation Cycles before illness Detection\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"},{\"key\":\"startinf\",\"label\":\"Number of Initial Seed infections\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false,"showImports":false,"headerStyle":{"background":"#15ad60"}},{"nid":36,"uid":"custom","category":"function","type":"Simulation Loop Predictor (Wuhan Corona Virus) China","x":417,"y":509,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"def remap(narray,resolution):\n x = np.interp(narray[0],[-1,1],[15,resolution[0]-15])\n y = np.interp(narray[1],[-1,1],[50,resolution[1]- 15])\n return np.array([int(x),int(y)])\n\n\n@on_start\ndef simLoop|||(*args, **kwargs):\n############################## EDIT THESE PARAMETERS ########################\n inflength = {inflength}\n mortality = {mortality}\n rnaught = {rnaught}\n infprob = {infprob}\n infincubation={infincubation}\n infdetected = {infdetected}\n#############################################################################\n\n if infprob == 0:\n infprob = rnaught/(kwargs['Settings']['NetworkX']['k']*inflength)\n if rnaught == 0:\n rnaught = infprob*kwargs['Settings']['NetworkX']['k']*inflength\n \n pos = kwargs['Settings']['NetworkX']['Pos']\n #rng = default_rng()\n #initialinf = rng.choice({startinf}*2, size={startinf}, replace=False)\n initialinf = random.sample(range({startinf}*2),{startinf})\n\n G = kwargs['Data']\n screensize = (800,800)\n G.graph['colors'] = {{\"Naive\":(99, 7, 238),\"Infected Symptomatic\":(145, 238, 7),\"Infected Asymptomatic\":(159, 190, 126),\"Immune\":(255, 235, 59),\"Dead\":(239, 99, 7)}}\n G.graph['disease'] = {{\"Infection Probability\" : infprob,\"Infection Detection\":infdetected, \"Infection Length\" : inflength, \"Incubation Length\":infincubation, \"Mortality\": mortality}}\n # Add Parameters to Nodegraph\n for nid in G:\n G.nodes[nid]['Status'] = 'Naive'\n G.nodes[nid]['Day'] = 0\n # Remap -1 1 square to pygame resolution\n for nid in pos:\n pos[nid] = remap(pos[nid],screensize) \n for nid in initialinf:\n G.nodes[nid]['Status'] = 'Infected Asymptomatic'\n # initialize the pygame module\n pg.init()\n # load and set the logo\n #logo = pg.image.load(\"logo.png\")\n #pg.display.set_icon(logo)\n pg.display.set_caption(\"{diseasename}\")\n legend = pg.image.load('legend.png')\n \n # create a surface on screen that has the size of 240 x 180\n screen = pg.display.set_mode(screensize)\n background = pg.Surface(screen.get_size())\n background = background.convert()\n background.fill((236, 239, 241))\n \n green = (255, 255, 255) \n deaths = 0\n infected = {startinf}\n asymptomatic={startinf}\n symptomatic=0 \n willdie=0\n infday = 0 \n detected = 0\n immune = 0 \n datacontainer={{\"Day\":[],\"Deaths\":[],\"Cumulative Infections\":[],\"Detected Infections\":[],\"Current Asymptomatic Infections\":[],\"Current Infectious Carriers\":[]}}\n font = pg.font.Font(pg.font.match_font('lato'), 20)\n text = font.render('R0: {{0}}'.format(rnaught), True, green)\n textinfected = font.render('Infected: {{0}}'.format(infected), True, green)\n # define a variable to control the main loop\n running = True\n \n \n \n \n \n d0 = datetime.date(2019, 12, 3)\n d1 = datetime.datetime.now().date()\n delta = d1 - d0\n delta = delta.days\n # main loop\n while running:\n #infected = 0\n############################### STOP CRITERIA ########################################################\n if infday >= delta:\n running = False\n# totaldetected = infected - (asymptomatic+immune+deaths)\n# if detected >= 2:\n# running = False\n# if deaths >=106:\n# running = False\n \n#######################################################################################################\n\n screen.blit(background, (0, 0))\n pg.draw.rect(background,(74,20,140),(0,0,screensize[0],120),0)\n\n textdeath = font.render('Deaths: {{}}'.format(deaths), True, green)\n screen.blit(textdeath, (10,10))\n textinfected = font.render('Cumulative Infections: {{}}'.format(infected), True, green)\n screen.blit(textinfected, (10,25))\n \n textinfected = font.render('Recoveries: {{}}'.format(immune), True, green)\n screen.blit(textinfected, (10,55))\n textinfected = font.render('Naive: {{}}'.format(kwargs['Settings']['NetworkX']['nodes']-infected), True, green)\n screen.blit(textinfected, (10,40))\n #totaldetected = infected - (asymptomatic+immune+deaths)\n textsymptomatic = font.render('Cumulative Detected Infections: {{}}'.format(detected), True, green)\n screen.blit(textsymptomatic, (10,70))\n \n textasymptomatic = font.render('Current Asymptomatic Infections: {{}}'.format(asymptomatic), True, green)\n screen.blit(textasymptomatic, (10,85))\n carriers = infected-asymptomatic-detected\n textcarriers = font.render('Current Infectious Carriers: {{}}'.format(carriers), True, green)\n screen.blit(textcarriers, (10,100))\n \n textdays = font.render('Epidemic Day: {{}}'.format(infday), True, green)\n screen.blit(textdays, ((screensize[0]/2)-40,10))\n textrnaught = font.render('R0: {{}}'.format(round(rnaught,2)), True, green)\n screen.blit(textrnaught, ((screensize[0]/2)-40,25))\n \n textmortality = font.render('Mortality Rate: {{}} %'.format(mortality*100), True, green)\n screen.blit(textmortality, ((screensize[0]/2)+40,25))\n datacontainer['Day'].append(infday)\n datacontainer['Deaths'].append(deaths)\n datacontainer['Cumulative Infections'].append(infected)\n datacontainer['Detected Infections'].append(detected)\n datacontainer['Current Asymptomatic Infections'].append(asymptomatic)\n datacontainer['Current Infectious Carriers'].append(carriers)\n \n for nid in pos:\n for e in G.edges(nid):\n cnode= e[1]\n gfx.line(screen,pos[nid][0],pos[nid][1],pos[cnode][0],pos[cnode][1],(120,144,156))\n for nid in pos:\n color = G.graph['colors'][G.nodes[nid]['Status']]\n gfx.aacircle(screen, pos[nid][0],pos[nid][1], 6, color)\n gfx.filled_circle(screen, pos[nid][0],pos[nid][1], 6, color)\n \n if G.nodes[nid]['Day'] == G.graph['disease']['Infection Detection']:\n detected = detected + 1 \n if G.nodes[nid]['Status'] == \"Infected Symptomatic\":\n if G.nodes[nid]['Day'] == G.graph['disease'][\"Infection Length\"]:\n roll = random.random()\n if roll >= G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Immune\"\n immune = immune+1\n symptomatic = symptomatic-1\n if roll < G.graph['disease']['Mortality']:\n G.nodes[nid]['Status'] = \"Dead\"\n symptomatic = symptomatic-1\n deaths=deaths+1\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1\n for e in G.edges(nid):\n cnode = e[1]\n if G.nodes[cnode]['Status'] != \"Dead\": \n if G.nodes[cnode]['Status'] != \"Immune\":\n if G.nodes[cnode]['Status'] != \"Infected Asymptomatic\":\n if G.nodes[cnode]['Status'] != \"Infected Symptomatic\":\n roll = random.random()\n \n if roll < G.graph['disease']['Infection Probability']:\n G.nodes[cnode]['Status'] = 'Infected Asymptomatic'\n infected = infected+1\n asymptomatic = asymptomatic+1\n \n \n if G.nodes[nid]['Status'] == \"Infected Asymptomatic\":\n if G.nodes[nid]['Day'] >= G.graph['disease'][\"Incubation Length\"]:\n asymptomatic = asymptomatic-1\n symptomatic = symptomatic+1\n G.nodes[nid]['Status'] = \"Infected Symptomatic\"\n G.nodes[nid]['Day'] = G.nodes[nid]['Day'] + 1 \n \n # event handling, gets all event from the event queue\n for event in pg.event.get():\n # only do something if the event is of type QUIT\n if event.type == pg.QUIT:\n # change the value to False, to exit the main loop\n running = False\n infday = infday + 1\n \n screen.blit(legend,(625,-15))\n pg.display.flip()\n time.sleep(10)\n df=pd.DataFrame(datacontainer)\n print(df)\n df = df[['Deaths','Detected Infections','Cumulative Infections','Current Asymptomatic Infections','Current Infectious Carriers']].rolling(1).sum()\n #sns.barplot(x = 'Day', y = 'Cumulative Infections', data = df)\n #sns.barplot(x = 'Day', y = 'Detected Infections', palette = 'magma', data = df)\n sns.lineplot(data=df, linewidth=2)\n\n\n plt.show()\n df.to_excel('summarydataChina.xlsx')\n kwargs['Data'] = df\n return kwargs\n ","python_import":"import pygame as pg\nimport pygame.gfxdraw as gfx \nimport random\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport datetime\n\n\nimport time","python_exec":"simLoop|||","settings":[{"key":"diseasename","label":"Disease Name For Pygame Caption"},{"key":"rnaught","label":"R0 for disease (Set to zero to calculate from infection probablility)"},{"key":"infprob","label":"Contact Infection Probability (Set this value to 0 to have it calculated from R0)"},{"key":"infincubation","label":"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day "},{"key":"infdetected","label":"Number of Simulation Cycles before illness Detection"},{"key":"inflength","label":"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day "},{"key":"mortality","label":"What is the Mortality Rate of this disease 1 is equivalent to 100%"},{"key":"startinf","label":"Number of Initial Seed infections"}],"icon":"./static/media/for.e1841ce0.svg","data":{"diseasename":"Novel coronavirus (2019-nCoV) Wuhan Virus China","rnaught":"0","infprob":"0.049","inflength":"20","mortality":"0.0815","infincubation":"5","infdetected":"10","startinf":"21"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\n","headerStyle":{"background":"#ad1562"},"showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"diseasename\",\"label\":\"Disease Name For Pygame Caption\"},{\"key\":\"rnaught\",\"label\":\"R0 for disease (Set to zero to calculate from infection probablility)\"},{\"key\":\"infprob\",\"label\":\"Contact Infection Probability (Set this value to 0 to have it calculated from R0)\"},{\"key\":\"infincubation\",\"label\":\"Number of Simulation Cycles a Person Remains Incubated. One cycle for example could represent a day \"},{\"key\":\"infdetected\",\"label\":\"Number of Simulation Cycles before illness Detection\"},{\"key\":\"inflength\",\"label\":\"Number of Simulation Cycles a Person Remains infectious after cycle zero, incubation is excluded. One cycle for example could represent a day \"},{\"key\":\"mortality\",\"label\":\"What is the Mortality Rate of this disease 1 is equivalent to 100%\"},{\"key\":\"startinf\",\"label\":\"Number of Initial Seed infections\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false,"showImports":false},{"nid":37,"uid":"custom","category":"logical","type":"Load NodeGraph 8 Million","x":662,"y":419,"fields":{"in":[{"name":"start"}],"out":[{"name":"pass"}]},"python":"@on_start\ndef loadPickle|||(*args,**kwargs):\n kwargs = pickle.load(open(\"{userinput}\",\"rb\"))\n kwargs['Threads'] = []\n\n return kwargs","python_import":"import pickle","python_exec":"loadPickle|||","settings":[{"key":"userinput","label":"Load Path including Filename"}],"icon":"./static/media/blankNode.38260d5b.svg","data":{"undefined":"","userinput":"nodegraph80000.pkl"},"description":"![STREMECOVER](http://go.pluricorp.com/websitemedia/gitlab/templatetop.svg)\n\nDumps kwargs in a node to a user specified global variable\n\n_Allows you to introspect within nodes after your algorithm completes_\n\n[YOUR GITHUB PAGE FOR THE NODE SOURCE](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links)\n\n## This Node Changes\n\n![TRANSITION](http://go.pluricorp.com/websitemedia/gitlab/templatetransition.svg)\n\nThis node takes a Pandas Dataframe in outputs and excel file and returns kwargs unchanged to the next node.\n\n## Getting This Node to Work\n\nThis node will work if it provided with a Dataframe in kwargs{Data} and Pandas is installed\n\n### Installing Dependencies\n\nThis node requires Pandas. Pandas can be installed using pip in your terminal \n\n```bash\npip install pandas\n```\n\nif you have python2 and python3 installed\n\n```bash\npip3 install pandas\n```\n\nIf you are using Anaconda (Pandas is already installed in the default setup):\n\n```bash\nconda install pandas\n```\n\n### Input State Requirements\n\nThis node requires that kwargs{Data} be a [Pandas Dataframe](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)\n\n```python\nkwargs={\n Start: True,\n Settings: Any,\n Data: Any Pandas Dataframe,\n Status: Any,\n }\n```\n\n### Output State\n\n```python\nkwargs={\n Start: No Change,\n Settings: No Change,\n Data: No Change,\n Status: No Change\n }\n```\n\n## Example Usage\n\nCheck out this simple demo of this node working : [Download Koi](https://mykoilocation.com)\n\n![STREMEExample](http://go.pluricorp.com/websitemedia/gitlab/example.gif)\n\n## Todo\n\n- Something\n\n- Another Thing\n\n- Something Else\n\n## Known Issues\n\n- We coded it poorly\n\n- Works only on the first of every month that is also within 5 days of the summer solstice \n\n## License\n\nUsage of this node is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n","showExecution":false,"showFunction":false,"executionClass":"","descriptionClass":"uk-active","importsClass":"","functionClass":"","showDescription":true,"toggleMarkdown":false,"toggleUserDialog":false,"stringDialog":"[{\"key\":\"userinput\",\"label\":\"Load Path including Filename\"}]","stringPins":"{\"in\":[{\"name\":\"start\"}],\"out\":[{\"name\":\"pass\"}]}","togglePins":false,"pintracker":false,"dialogtracker":false,"descriptiontracker":false,"showImports":false}],"connections":[{"from_node":0,"from":"start","to_node":3,"to":"start"},{"from_node":3,"from":"pass","to_node":12,"to":"start"}],"title":"graphgenerator","showPopup":false,"current":-1,"count":37,"servers":{},"serverselection":null}