self.addAgent(newAgent) newAgent.setRandomPosition() newAgent._value = random.randint(0, 10) mySimulation = Simulation(32, 10) myWorld = MyWorld(mySimulation) myWorld.initialize() myWorld.run() # analysis record = SimulationRecord() record.loadHDF5('data/results.h5', 1, 1) agentResults = AgentResults(record, 'agents.csv', 'id', ';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('x')) agentResults.addAnalysis(AgentMean('y')) agentResults.addAnalysis(AgentMean('value')) agentResults.addAnalysis(AgentSum('value')) agentResults.addAnalysis(AgentHDFtoSHP('shp/agents.shp', -1)) agentResults.apply() rasterResults = RasterResults(record, 'resources.csv', 'test', ';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.apply()
self.addAgent(newAgent) newAgent.setRandomPosition() newAgent._value = random.randint(0,10) mySimulation = Simulation(32, 10) myWorld = MyWorld(mySimulation) myWorld.initialize() myWorld.run() # analysis record = SimulationRecord() record.loadHDF5('data/results.h5', 1, 1) agentResults = AgentResults(record, 'agents.csv', 'id', ';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('x')) agentResults.addAnalysis(AgentMean('y')) agentResults.addAnalysis(AgentMean('value')) agentResults.addAnalysis(AgentSum('value')) agentResults.addAnalysis(AgentHDFtoSHP('shp/agents.shp', -1)) agentResults.compute() rasterResults = RasterResults(record, 'resources.csv', 'test', ';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.compute()
self.addAgent(newAgent) newAgent.setRandomPosition() newAgent._value = random.randint(0,10) mySimulation = Simulation(32, 10) myWorld = MyWorld(mySimulation) myWorld.initialize() myWorld.run() # analysis record = SimulationRecord() record.loadHDF5('data/results.h5', 1, 1) agentResults = AgentResults(record, 'agents.csv', 'id', ';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('x')) agentResults.addAnalysis(AgentMean('y')) agentResults.addAnalysis(AgentMean('value')) agentResults.addAnalysis(AgentSum('value')) agentResults.addAnalysis(AgentHDFtoSHP('shp/agents.shp', -1)) agentResults.apply() rasterResults = RasterResults(record, 'resources.csv', 'test', ';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.apply()
#!/usr/bin/python import sys sys.path.append('..') sys.path.append('../../') from pyPandora import SimulationRecord, AgentResults, AgentMean, AgentSum, AgentNum, AgentHDFtoSHP, RasterMean, RasterSum, RasterResults record = SimulationRecord() record.loadHDF5('data_test/gujarat.h5', 1, 1) agentResults = AgentResults(record, 'agents.csv', 'HunterGatherer', ';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('children')) agentResults.addAnalysis(AgentSum('children')) agentResults.addAnalysis(AgentMean('collected resources')) agentResults.addAnalysis(AgentHDFtoSHP('shp/agents.shp', -1)) agentResults.compute() rasterResults = RasterResults(record, 'resources.csv', 'resources', ';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.compute()