def main(): record = SimulationRecord(100, False) record.loadHDF5('../data/anazasi.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('estimates')) agentResults.applyTo(record,'households.csv', 'Household') rasterResults = GlobalRasterStats(';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.applyTo(record, 'water.csv', 'yield x100')
def main(): record = SimulationRecord(100, False) record.loadHDF5('../data/anazasi.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('estimates')) agentResults.applyTo(record, 'households.csv', 'Household') rasterResults = GlobalRasterStats(';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.applyTo(record, 'water.csv', 'yield x100')
def main(): """ this file provides a template that can be used to analyze any Pandora model """ record = SimulationRecord(1, False) record.loadHDF5('data/results.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('x')) agentResults.addAnalysis(AgentMean('y')) agentResults.addAnalysis(AgentMean('value')) agentResults.addAnalysis(AgentSum('value')) agentResults.applyTo(record, 'agents.csv', 'HelloAgent') rasterResults = GlobalRasterStats(';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.applyTo(record, 'values.csv', 'values')
def main(): record = SimulationRecord(1, False) record.loadHDF5('../data/results.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('strength x100')) agentResults.addAnalysis(AgentMean('aggressiveness x100')) agentResults.addAnalysis(AgentStdDev('strength x100')) agentResults.addAnalysis(AgentStdDev('aggressiveness x100')) agentResults.addAnalysis(AgentSum('strength x100')) agentResults.addAnalysis(AgentSum('aggressiveness x100')) agentResults.applyTo(record,'farmers.csv', 'Farmer') agentResults.applyTo(record,'herders.csv', 'Herder') rasterResults = GlobalRasterStats(';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.applyTo(record, 'conflicts.csv', 'conflicts')
def main(): record = SimulationRecord(1, False) record.loadHDF5('../data/results.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('strength x100')) agentResults.addAnalysis(AgentMean('aggressiveness x100')) agentResults.addAnalysis(AgentStdDev('strength x100')) agentResults.addAnalysis(AgentStdDev('aggressiveness x100')) agentResults.addAnalysis(AgentSum('strength x100')) agentResults.addAnalysis(AgentSum('aggressiveness x100')) agentResults.applyTo(record, 'farmers.csv', 'Farmer') agentResults.applyTo(record, 'herders.csv', 'Herder') rasterResults = GlobalRasterStats(';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.applyTo(record, 'conflicts.csv', 'conflicts')
#!/usr/bin/python import sys, random sys.path.append('../../../pyPandora/') sys.path.append('../../../') from pyPandora import SimulationRecord, GlobalAgentStats, AgentNum, AgentMean, AgentSum, AgentStdDev, GlobalRasterStats, RasterMean, RasterSum record = SimulationRecord(1, False) record.loadHDF5('../data/results.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('strength x100')) agentResults.addAnalysis(AgentMean('aggressiveness x100')) agentResults.addAnalysis(AgentStdDev('strength x100')) agentResults.addAnalysis(AgentStdDev('aggressiveness x100')) agentResults.addAnalysis(AgentSum('strength x100')) agentResults.addAnalysis(AgentSum('aggressiveness x100')) agentResults.applyTo(record,'farmers.csv', 'Farmer') agentResults.applyTo(record,'herders.csv', 'Herder') rasterResults = GlobalRasterStats(';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.applyTo(record, 'conflicts.csv', 'conflicts')
def createAgents(self): for i in range(0, 10): newAgent = MyAgent('id_' + str(i)) 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())
def createAgents(self): for i in range (0, 10): newAgent = MyAgent('id_'+str(i)) 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())
#!/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()
def createAgents(self): for i in range(0, 10): newAgent = MyAgent('id_' + str(i)) self.addAgent(newAgent) newAgent.setRandomPosition() newAgent._value = random.randint(0, 10) myConfig = Config(SizeInt(32, 32), 10) myWorld = MyWorld(myConfig) myWorld.initialize() myWorld.run() # analysis record = SimulationRecord(1, False) record.loadHDF5('data/results.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('x')) agentResults.addAnalysis(AgentMean('y')) agentResults.addAnalysis(AgentMean('value')) agentResults.addAnalysis(AgentSum('value')) agentResults.applyTo(record, 'agents.csv', 'id') #agentResults.addAnalysis(AgentHDFtoSHP('shp/agents.shp', -1)) rasterResults = GlobalRasterStats(';') rasterResults.addAnalysis(RasterMean()) rasterResults.addAnalysis(RasterSum()) rasterResults.applyTo(record, 'resources.csv', 'test')
#!/usr/bin/python3.3 import sys, random sys.path.append('/home/xrubio/workspace/pandora/pandora/pyPandora/') sys.path.append('/home/xrubio/workspace/pandora/pandora/') from pyPandora import Simulation, Agent, World, Point2DInt, SimulationRecord, GlobalAgentStats, AgentNum, AgentMean, AgentSum, AgentStdDev, GlobalRasterStats, RasterMean, RasterSum record = SimulationRecord(1, False) record.loadHDF5('../data/anazasi.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) #agentResults.addAnalysis(AgentMean('estimates')) #agentResults.addAnalysis(AgentStdDev('strength x100')) #agentResults.addAnalysis(AgentSum('strength x100')) agentResults.applyTo(record,'households.csv', 'Household') #rasterResults = GlobalRasterStats(';') #rasterResults.addAnalysis(RasterMean()) #rasterResults.addAnalysis(RasterSum()) #rasterResults.applyTo(record, 'water.csv', 'yield x100')
#!/usr/bin/python3 import sys, random pandoraDir = '/home/xrubio/workspace/pandoraMaster/' sys.path.append(pandoraDir+'/pandora/') sys.path.append(pandoraDir+'/pandora/pyPandora/') from pyPandora import Simulation, Point2DInt, SimulationRecord, GlobalAgentStats, AgentNum, AgentMean, AgentSum, AgentStdDev, GlobalRasterStats, RasterMean, RasterSum, SizeInt record = SimulationRecord(1, False) record.loadHDF5('data/ap.h5', True, True) agentResults = GlobalAgentStats(';') agentResults.addAnalysis(AgentNum()) agentResults.addAnalysis(AgentMean('population')) agentResults.addAnalysis(AgentSum('population')) """ agentResults.addAnalysis(AgentMean('starvation rate %')) agentResults.addAnalysis(AgentMean('number of plots')) agentResults.addAnalysis(AgentSum('number of animals')) """ agentResults.applyTo(record, 'agents.csv', 'ap')