Ejemplo n.º 1
0
	def _storeData(self, s=None):
		"""
		stores the data. The strategy is to store it all, it has to be processed later.
		The purpose of this function is to standardize the column "design", so the numerous data files are easily
		accessed and generic scripts can be written for them.

		s has to be given if this is the first time the method is called and an output should  be created.
		"""
		e=self.excelOut
		if not e: #start a new instance.
			if not s:
				raise Exception('simulation instance has to be provided at first call for _storeData')
			e=ExcelOutput(template='sim/planting/template.xls', out=self.filename)
			self.excelOut=e
			e.changeSheet(0)
			#set all the parameters
			paramRow=3
			type=copy.copy(s.m.type) #we need to shift 2aXh because of new directions...
			e.modify(paramRow, 0, s.m.type) #machine type
			e.modify(paramRow, 1, s.G.terrain.ttype) #terrain type
			e.modify(paramRow, 2, s.G.terrain.stumpFile) #terrain type
			e.modify(paramRow, 3, s.G.terrain.stumpsPerH) #stumps/ha
			e.modify(paramRow, 4, s.G.terrain.groundModel)
			e.modify(paramRow, 5, s.G.terrain.blockQuota*100) #percent
			e.modify(paramRow, 6, s.G.terrain.boulderFreq)
			e.modify(paramRow, 7, s.G.terrain.meanBoulderV*1000)
			e.modify(paramRow, 9, s.m.craneMaxL)
			if s.m.type[0:2]=='2a':
				e.modify(paramRow, 10, s.m.craneIntersect)
				e.modify(paramRow, 11, s.m.angleLim[0]*180/pi)
				e.modify(paramRow, 12, s.m.angleLim[1]*180/pi)
			if len(s.m.pDevs[0].plantHeads)==2: e.modify(paramRow, 13, s.m.pDevs[0].plantSepDist*100)
			e.modify(paramRow, 14, s.m.pDevs[0].plantHeads[0].width*100)
			e.modify(paramRow, 15, s.m.stockingRate)
			e.modify(paramRow, 16, s.m.plantMinDist)
			e.modify(paramRow, 17, s.m.times['switchFocus'])
			e.modify(paramRow, 18, str(s.G.automatic['automove']))
			e.modify(paramRow, 19, str(s.G.automatic['mound']))
			e.modify(paramRow, 20, s.m.velocities['radial'])			
			e.modify(paramRow, 21, str(self.bestCase))
			e.modify(paramRow, 22, str(self.worstCase))
		e.changeSheet(1) #the time-data sheet
		tdrow=2+self.sims
		for col,val in enumerate(self.timeData):
			print tdrow, col, val
			e.modify(tdrow,col,round(val,2)) #writes the time data. Request from BTE to round off
		e.save()
		return e
Ejemplo n.º 2
0
	def __init__(self,it=1):
		self.G=globalVar()
		self.G.areaPoly=[(0,0), (25,0), (25,40), (0,40)]
		self.G.terrain=Terrain(G=self.G)
		self.folder='outputFiles/NewThinning_2012'
		today=datetime.date.today()
		self.filename=self.folder+'/'+'ThinningWawoBundler_'+'%s'%(string.join([string.strip(a) for a in string.split(time.ctime(time.time()))], "_"))+'.xls'
		e=ExcelOutput(template='sim/thinning/template.xls', out=self.filename)
		self.Paramrow=1
		for treeFile in self.G.terrain.thinningFiles:
			self.G.terrain.treeFile=treeFile
			self.G.terrain.readTrees()
			
			for head in ['BC','convAcc']:
				for nCranes in [1,2]:
					for bundler in [False, True]:
						for twigCrack in [False, True]:
							for simNumber in range(1,it+1):
								G=copy.deepcopy(self.G)
								self.s=ThinningSim(G=G, vis=False, anim=False, head=head, nCranes=nCranes, bundler=bundler, twigCrack=twigCrack, observer=True)
								self.s.stats['machineConfig']=self.getConfig(head,nCranes,twigCrack,bundler)
								self.s.stats['simNumber']=simNumber
								self.s.stats['treeFile']=treeFile
								self.s.stats['noHarvTrees']=sum([len(b.trees) for b in G.terrain.piles])
								self.s.stats['noCraneCycles']=sum([pb.craneCycles for pb in G.terrain.piles])
								self.s.stats['harvBiomass']=sum([b.weight for b in self.s.m.trees]) #total mass of the trees that were harvested, before tc?
								self.s.stats['harvStemMass']=sum([t.logWeight for t in self.s.m.trees])#total weight of the stems of the trees that are harvested. Not what's in the bundles or piles, but rather what was in terrain before chop.
								self.s.stats['harvStemVol']=sum([t.vol for t in self.s.m.trees])# total volume of the stems of the trees that are harvested. Not what's in the bundles or piles
								self.s.stats['noBundlesOrPiles']=len(G.terrain.piles)
								self.s.stats['minBunPileMass']=min([b.biomass for b in G.terrain.piles])
								self.s.stats['maxBunPileMass']=max([b.biomass for b in G.terrain.piles])
								self.s.stats['totBunPileMass']=sum([b.biomass for b in G.terrain.piles])
								self.s.stats['minBunPileVol']=min([self.getVol(b) for b in G.terrain.piles])
								self.s.stats['maxBunPileVol']=max([self.getVol(b) for b in G.terrain.piles])
								self.s.stats['totBunPileVol']=sum([self.getVol(b) for b in G.terrain.piles])
								self.s.stats['noMainStops']=len(self.s.m.positions)-1 #Here I assume what is meant is number of stops on the mainroad for harvesting. Not number of places with piles close by. Is this a good assumption. Gives seven all the time.. should be len(self.s.m.positions)-1 maybe?
								self.s.stats['totTimeConsumed']=self.s.now()
								if bundler==True:
									#self.s.stats['bundlingTime']=self.o.tstep*sum([c[1] for c in self.o.bundlerActiveMoni]) can be used instead, but does not give exact result as expected.see below
									self.s.stats['bundlingTime']=self.s.stats['noBundlesOrPiles']*self.s.m.bundler.timeBundle
								else: self.s.stats['bundlingTime']=0
								self.s.stats['work time']#operator active time
								print self.s.stats['noBundlesOrPiles'], 'piles or bundles'
								print self.s.stats['noCraneCycles'], 'was the number of crane cycles'
								print self.s.stats['bundlingTime'], self.s.stats['totTimeConsumed']
								print '---------------------------------------------------------------------'
								
								"""This part here writes the data to the excel file"""
								e.modify(self.Paramrow,0,self.s.stats['machineConfig'])
								e.modify(self.Paramrow,1,self.s.stats['treeFile'])
								e.modify(self.Paramrow,2,self.s.stats['simNumber'])
								e.modify(self.Paramrow,3,self.s.stats['noHarvTrees'])
								e.modify(self.Paramrow,4,self.s.stats['noCraneCycles'])
								e.modify(self.Paramrow,5,self.s.stats['harvBiomass'])
								e.modify(self.Paramrow,6,self.s.stats['harvStemMass'])
								e.modify(self.Paramrow,7,self.s.stats['harvStemVol'])
								e.modify(self.Paramrow,8,self.s.stats['noBundlesOrPiles'])
								e.modify(self.Paramrow,9,self.s.stats['minBunPileMass'])#
								e.modify(self.Paramrow,10,self.s.stats['maxBunPileMass'])
								e.modify(self.Paramrow,11,self.s.stats['totBunPileMass'])
								e.modify(self.Paramrow,12,self.s.stats['minBunPileVol'])
								e.modify(self.Paramrow,13,self.s.stats['maxBunPileVol'])
								e.modify(self.Paramrow,14,self.s.stats['totBunPileVol'])
								e.modify(self.Paramrow,15,self.s.stats['noMainStops'])
								e.modify(self.Paramrow,16,self.s.stats['totTimeConsumed'])
								e.modify(self.Paramrow,17,self.s.stats['bundlingTime'])
								e.modify(self.Paramrow,18,self.s.stats['work time'])
								e.modify(self.Paramrow,19,self.s.stats['oneCraneWorkTime'])
								e.modify(self.Paramrow,20,self.s.stats['twoCranesWorkTime'])
								e.modify(self.Paramrow,21,self.s.stats['oneCraneWaitDriverTime'])
								e.modify(self.Paramrow,22,self.s.stats['twoCranesWaitDriverTime'])
								e.modify(self.Paramrow,23,self.s.stats['oneCraneWaitBundlerTime'])
								e.modify(self.Paramrow,24,self.s.stats['twoCranesWaitBundlerTime'])
								e.modify(self.Paramrow,25,self.s.stats['noCraneWaitings'])
								e.modify(self.Paramrow,26,self.s.stats['noCraneWaitingsTwo'])
								self.Paramrow+=1
								e.save()#To be sure to save after each simulation, if something should go wrong
		print 'Congratulations, all your simulations has been run and the data has successfully been stored in the excel-file named ThinningWawoBundler_date and time.xls, to be found in tota/outputFiles/NewThinning_2012.'
Ejemplo n.º 3
0
	def __init__(self,it=1, head='BC', nCranes=1, bundler=False, twigCrack=False, simNumber=1, rowNumber=1, treeFile=210):
		if bundler==1: bundler=False
		elif bundler==2: bundler=True
		else: raise Exception('bundler should be 1 or 2 from bash')
		if twigCrack==1: twigCrack=False
		elif twigCrack==2: twigCrack=True
		else: raise Exception('twigCrack should be 1 or 2 from bash')
		self.G=globalVar()
		#self.G.plotDelay=500 #for debug only
		self.G.areaPoly=[(0,0), (25,0), (25,40), (0,40)]
		self.G.terrain=Terrain(G=self.G)
		self.folder='outputFiles/NewThinning_2012'
		today=datetime.date.today()
		self.filename=self.folder+'/'+'ThinningWawoBundler.xls'
		e=ExcelOutput(template='outputFiles/NewThinning_2012/ThinningWawoBundler.xls', out=self.filename)
		self.Paramrow=rowNumber

		self.G.terrain.treeFile=treeFile
		self.G.terrain.readTrees()
		G=copy.deepcopy(self.G)
		self.s=ThinningSim(G=G, vis=False, anim=False, head=head, nCranes=nCranes, bundler=bundler, twigCrack=twigCrack, observer=True)						
		self.s.stats['machineConfig']=self.getConfig(head,nCranes,twigCrack,bundler)
		self.s.stats['simNumber']=simNumber
		self.s.stats['treeFile']=treeFile
		self.s.stats['noHarvTrees']=sum([len(b.trees) for b in G.terrain.piles])
		self.s.stats['noCraneCycles']=sum([pb.craneCycles for pb in G.terrain.piles])
		self.s.stats['harvBiomass']=sum([b.weight for b in self.s.m.trees]) #total mass of the trees that were harvested, before tc?
		self.s.stats['harvStemMass']=sum([t.logWeight for t in self.s.m.trees])# total weight of the stems of the trees that are harvested. Not what's in the bundles or piles, but rather what was in terrain before chop.
		self.s.stats['harvStemVol']=sum([t.vol for t in self.s.m.trees])# total volume of the stems of the trees that are harvested. Not what's in the bundles or piles
		self.s.stats['noBundlesOrPiles']=len(G.terrain.piles)
		self.s.stats['minBunPileMass']=min([b.biomass for b in G.terrain.piles])
		self.s.stats['maxBunPileMass']=max([b.biomass for b in G.terrain.piles])
		self.s.stats['totBunPileMass']=sum([b.biomass for b in G.terrain.piles])
		self.s.stats['minBunPileVol']=min([self.getVol(b) for b in G.terrain.piles])
		self.s.stats['maxBunPileVol']=max([self.getVol(b) for b in G.terrain.piles])
		self.s.stats['totBunPileVol']=sum([self.getVol(b) for b in G.terrain.piles])
		self.s.stats['noMainStops']=len(self.s.m.positions)-1 #Here I assume what is meant is number of stops on the mainroad for harvesting.
		self.s.stats['totTimeConsumed']=self.s.now()
		if bundler==True:
			#self.s.stats['bundlingTime']=self.o.tstep*sum([c[1] for c in self.o.bundlerActiveMoni]) could be used instead, but does not give exact result as expected. Deviates by some 5%
			self.s.stats['bundlingTime']=self.s.stats['noBundlesOrPiles']*self.s.m.bundler.timeBundle
		else: self.s.stats['bundlingTime']=0
		self.s.stats['work time']#operator active time
		print self.s.stats['noBundlesOrPiles'], 'piles or bundles'
		print self.s.stats['noCraneCycles'], 'was the number of crane cycles'
		print self.s.stats['bundlingTime'], self.s.stats['totTimeConsumed']
		print '---------------------------------------------------------------------'
		
		"""This part here writes the data to the excel file"""
		e.modify(self.Paramrow,0,self.s.stats['machineConfig'])
		e.modify(self.Paramrow,1,self.s.stats['treeFile'])
		e.modify(self.Paramrow,2,self.s.stats['simNumber'])
		e.modify(self.Paramrow,3,self.s.stats['noHarvTrees'])
		e.modify(self.Paramrow,4,self.s.stats['noCraneCycles'])
		e.modify(self.Paramrow,5,self.s.stats['harvBiomass'])
		e.modify(self.Paramrow,6,self.s.stats['harvStemMass'])
		e.modify(self.Paramrow,7,self.s.stats['harvStemVol'])
		e.modify(self.Paramrow,8,self.s.stats['noBundlesOrPiles'])
		e.modify(self.Paramrow,9,self.s.stats['minBunPileMass'])#
		e.modify(self.Paramrow,10,self.s.stats['maxBunPileMass'])
		e.modify(self.Paramrow,11,self.s.stats['totBunPileMass'])
		e.modify(self.Paramrow,12,self.s.stats['minBunPileVol'])
		e.modify(self.Paramrow,13,self.s.stats['maxBunPileVol'])
		e.modify(self.Paramrow,14,self.s.stats['totBunPileVol'])
		e.modify(self.Paramrow,15,self.s.stats['noMainStops'])
		e.modify(self.Paramrow,16,self.s.stats['totTimeConsumed'])
		e.modify(self.Paramrow,17,self.s.stats['bundlingTime'])
		e.modify(self.Paramrow,18,self.s.stats['work time'])
		e.modify(self.Paramrow,19,self.s.stats['oneCraneWorkTime'])
		e.modify(self.Paramrow,20,self.s.stats['twoCranesWorkTime'])
		e.modify(self.Paramrow,21,self.s.stats['oneCraneWaitDriverTime'])
		e.modify(self.Paramrow,22,self.s.stats['twoCranesWaitDriverTime'])
		e.modify(self.Paramrow,23,self.s.stats['oneCraneWaitBundlerTime'])
		e.modify(self.Paramrow,24,self.s.stats['twoCranesWaitBundlerTime'])
		e.modify(self.Paramrow,25,self.s.stats['noCraneWaitings'])
		e.modify(self.Paramrow,26,self.s.stats['noCraneWaitingsTwo'])
		e.save()#To be sure to save after each simulation, if something should go wrong
Ejemplo n.º 4
0
	def _storeData(self, s=None):
		"""
		Stores the data. The strategy is to store it all, it has to be processed later.
		The purpose of this function is to standardize the column 'design', so the numerous data files are easily
		accessed and generic scripts can be written for them.

		s has to be given if this is the first time the method is called and an output should  be created.
		"""
		e=self.excelOut
		if not e: #start a new instance.
			if not s:
				raise Exception('simulation instance has to be provided at first call for _storeData')
			e=ExcelOutput(template='sim/planting/template_art3.xls', out=self.filename)
			self.excelOut=e
			e.changeSheet(0)
			#set all the parameters
			paramRow=3
			type=copy.copy(s.m.type) #we need to shift 2aXh because of new directions...
			e.modify(paramRow, 0, s.m.type) #machine type
			e.modify(paramRow, 1, s.G.terrain.ttype) #terrain type
			e.modify(paramRow, 2, s.G.terrain.stumpFile) #terrain type
			e.modify(paramRow, 3, s.G.terrain.stumpsPerH) #stumps/ha
			e.modify(paramRow, 4, s.G.terrain.groundModel)
			e.modify(paramRow, 5, s.G.terrain.blockQuota*100) #percent
			e.modify(paramRow, 6, s.G.terrain.boulderFreq)
			e.modify(paramRow, 7, s.G.terrain.meanBoulderV*1000)
			e.modify(paramRow, 8, s.G.terrain.humusType) #humustype
			e.modify(paramRow, 9, s.stats['noSurfBoulders'])#set in plantmsim
			e.modify(paramRow, 10, round(s.stats['meanSurfBoulderDiam']*10,1))#changed to dm, set in plantmsim
			e.modify(paramRow, 12, s.m.craneMaxL)
			e.modify(paramRow, 13, s.m.plantMinDist*100)
			e.modify(paramRow, 14, s.m.pDevs[0].plantHeads[0].width*100)
			e.modify(paramRow, 15, s.G.simParam['TSR'])
			if s.G.simParam['inverting']==True and s.G.simParam['ExcavatorInverting']==True:
				noManRemInv = 5
				cycleTimeInv = s.G.simParam['tInvExcavator']
			elif s.G.simParam['inverting']==True and s.G.simParam['KOInverting']==True:
				noManRemInv = 11
				cycleTimeInv = s.G.simParam['tCWhenInvKO']
			elif s.G.simParam['inverting']==False:
				noManRemInv = 5
				cycleTimeInv = 0
			e.modify(paramRow, 16, cycleTimeInv)
			e.modify(paramRow, 17, noManRemInv)
			if s.G.simParam['rectangular']==False: scoopshape='SemiCyl'
			elif s.G.simParam['rectangular']==True: scoopshape='Rect'
			e.modify(paramRow, 18, scoopshape)
			e.modify(paramRow, 19, s.G.simParam['multiplierFindMuSite'])
			e.modify(paramRow, 20, s.G.simParam['moundRadius'])
			if s.G.simParam['inverting']==True:
				e.modify(paramRow, 21, s.G.simParam['SBMinvert'])
			elif s.G.simParam['inverting']==False:
				e.modify(paramRow, 21, s.G.simParam['SBMmound'])
		e.changeSheet(1) #the time-data sheet
		tdrow=2+self.sims
		for col,val in enumerate(self.timeData):
			e.modify(tdrow,col,round(val,2)) #writes the time data. Request from BTE to round off
		e.save()
		return e