This file is indexed.

/usr/share/pyshared/Epigrass/epiRTplay.py is in epigrass 2.0.4-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python

#program to animate simulations in Real Time using Pyglet
import cPickle, glob, os, epigdal
from math import *
from pyglet import font
from pyglet import clock
from pyglet import window
from pyglet import image
from pyglet.gl import *
from pyglet.window import mouse
from pyglet.window import event
from pyglet.window import key
from numpy import *
from matplotlib import cm
from matplotlib.colors import rgb2hex
import primitives
import gdal,locale, ogr

class Viewer:
    """
    Pyglet OpenGL cotext to display epidemic dynamics
    """
    def __init__(self,graph, shpfname, geocfield, var="incidence"):
        self .graph  = graph
        self.var = var
        if graph:
            self.nodes = dict([(n.geocode, n) for n in graph.site_list])
        self.win = window.Window(visible=False)
        self.win.set_caption('Model Dynamics')
        self.polygons = self.drawMap(shpfname, geocfield)
        self.colmap  = cm.get_cmap("jet",100)
        
    def Show(self, timestep):
        """
        Shows the window and runs an update cycle.
        """
        if not self.win.visible:
            self.win.set_visible(True)
        self.win.dispatch_events()
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        for pol in self.polygons.items():
            color = self.colmap(self.nodes[pol[0]].__getattribute__(self.var)[timestep])
            pol[1].color = color
            pol[1].render()
            
        
        self.win.flip()
 

        
    def drawMap(self, fname, geocfield):
        """
        Draws the polygons of the model
        fname: shapefile with the polygons
        """
    
        #Get the polygons
        g = ogr.Open (fname)
        L = g.GetLayer(0)
        N = 0
        pl = {}#polygon patch dictionary (by geocode)
        feat = L.GetNextFeature()
        while feat is not None:
            try:
                gc = feat.GetFieldAsInteger(geocfield)
            except:
                gc = 0
            field_count = L.GetLayerDefn().GetFieldCount()
            geo = feat.GetGeometryRef()
            if geo.GetGeometryCount()<2:
                g1 = geo.GetGeometryRef( 0 )
                x =[g1.GetX(i) for i in xrange(g1.GetPointCount()) ]
                y =[g1.GetY(i) for i in xrange(g1.GetPointCount()) ]
                polv=zip(x, y) #Vertices do poligono
                poligono = primitives.Polygon(polv) #Definimos o poligono
                pl[gc]=poligono
            for c in range( geo.GetGeometryCount()):
                ring = geo.GetGeometryRef ( c )
                for cnt in range( ring.GetGeometryCount()):
                    g1 = ring.GetGeometryRef( cnt )
                    x =[g1.GetX(i) for i in range(g1.GetPointCount()) ]
                    y =[g1.GetY(i) for i in range(g1.GetPointCount()) ]
                    polv=zip(x, y) #Vertices do poligono
                    poligono = primitives.Polygon(polv, color=(.3,0.2,0.5,.7)) #Definimos o poligono
                    pl[gc]=poligono
                    
            feat = L.GetNextFeature()
        return pl
            
    def animReplay(self,var):
        """
        replays the animation for the given graph
        - data: time series from database
        - pos: column number of variable to animate
        - ax: is the axis containing the polygons
        - pl is the polygon dictionary
        """
        for step in xrange(0, self.graph.maxstep):
            self.show(step)
        
if __name__ == "__main__":
    Display=Viewer(None,'riozonas_LatLong.shp', 'geocode' )
    Display.win.set_visible(True)
    while not Display.win.has_exit:
        Display.win.dispatch_events()
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        [pol[1].render() for pol in Display.polygons.items()]
        print "show"
        Display.win.flip()