Exemple #1
0
	def analyze_building_stock_per_run(self, run, result_dir_run):
		"""
		Compares the distribution of the synthetic building stock generated per run
		with the statistics.
		"""
			
		# RESIDENTIAL
		# total buildings
		count_res  = len(self.my_city.energy_per_building[self.my_city.energy_per_building[:, 1] == 3])
		
		for year_class in range(10):
			for btype in range(4):
		
				# extract all buildings B with specific year_class, btype and use
				c0  = self.my_city.energy_per_building[:, 1] == 3  # RESIDENTIAL
				c1  = self.my_city.energy_per_building[:, 2] == year_class
				c2  = self.my_city.energy_per_building[:, 3] == btype
				B   = self.my_city.energy_per_building[c0 * c1 * c2]
			
				# add building distribution to category
				self.bstock_res[run][year_class][btype]   = len(B)/float(count_res)
		
		# NON-RESIDENTIAL
		count_nres = len(self.my_city.energy_per_building[self.my_city.energy_per_building[:, 1] != 3])
		
		for year_class in range(5):
			
			# extract all buildings B with specific year_class, btype and use
			c0  = self.my_city.energy_per_building[:, 1] != 3  # NON-RESIDENTIAL
			c1  = self.my_city.energy_per_building[:, 2] == year_class
			B   = self.my_city.energy_per_building[c0 * c1]
			
			# add building distribution to category
			self.bstock_nres[run][year_class] 			  = len(B)/float(count_nres)
			count_nres += 1
					
		# Plots
		# Building distribution per category from statistics [%]
		stat_res   = self.building_stock_stats[8]
		stat_nres  = self.building_stock_stats[9]
		
		# plot imshow to compare with statistics
		fig_name    = '{}/BuildingStock_res_{}.png'.format(result_dir_run, run)
		UrbanHeatPro.plot_imshow_comparison(3, self.bstock_res[run], stat_res, fig_name, cmap = 'RdBu')
		#
		fig_name    = '{}/BuildingStock_nres_{}.png'.format(result_dir_run, run)
		UrbanHeatPro.plot_imshow_comparison(0, self.bstock_nres[run], stat_nres, fig_name, cmap = 'RdBu')
Exemple #2
0
	def analyze_building_stock_per_sim(self):
		"""
		Compares the MEAN distribution of the synthetic building stock generated per run
		with the statistics.
		"""
		
		# Building distribution per category from statistics [%]
		stat_res   = self.building_stock_stats[8]
		stat_nres  = self.building_stock_stats[9]
		
		# Simulation building stock results
		mean_res   = self.bstock_res.mean(axis = 0)
		mean_nres  = self.bstock_nres.mean(axis = 0)
		
		# plot imshow to compare with statistics
		fig_name    = '{}/BuildingStock_res.png'.format(self.result_dir)
		UrbanHeatPro.plot_imshow_comparison(3, mean_res, stat_res, fig_name, cmap = 'RdBu')
		#
		fig_name    = '{}/BuildingStock_nres.png'.format(self.result_dir)
		UrbanHeatPro.plot_imshow_comparison(0, mean_nres, stat_nres, fig_name, cmap = 'RdBu')