当前位置: 首页>>代码示例>>Python>>正文


Python Utils.isOverbooked方法代码示例

本文整理汇总了Python中Utils.Utils.isOverbooked方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.isOverbooked方法的具体用法?Python Utils.isOverbooked怎么用?Python Utils.isOverbooked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils.Utils的用法示例。


在下文中一共展示了Utils.isOverbooked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: overbookingCurves

# 需要导入模块: from Utils import Utils [as 别名]
# 或者: from Utils.Utils import isOverbooked [as 别名]
	def overbookingCurves(self, network, orgs=None, dests=None, flights=None, 
						cabins=None, bcs=None, date_ranges=None, normalized=True):
		""" Plots overbooking curves for some subset of the data.
		
		Overbooking is defined where AUTH > CAP.  We plot overbooking as a 
		ratio between AUTH and CAP.  Overbooking varies with time.
	
		"""
		df = network.f.getDrillDown(orgs=orgs, dests=dests, flights=flights,
							cabins=cabins, bcs=bcs, date_ranges=date_ranges)

		fltbk = network.f.getUniqueFlightsAndBookings(df)

		plt.figure()
		
		if normalized:
			for g, d in fltbk:
				# normalized AUTH == OVERBOOKED
				AUTH = np.array(d.sort(columns='KEYDAY', ascending=False)['AUTH'])
				
				# ignore time series that are not overbooked
				if not Utils.isOverbooked(AUTH):
					continue

				KEYDAY = np.array(-d.sort(columns='KEYDAY', ascending=False)['KEYDAY'])
				
				plt.plot(KEYDAY, AUTH)
		else:
			for g, d in fltbk:
				AUTH = np.array(d.sort(columns='KEYDAY', ascending=False)['AUTH'])
				CAP = float(d.iloc[0]['CAP'])
				OVRBKD = AUTH/CAP

				# ignore time series that are not overbooked
				if not Utils.isOverbooked(OVRBKD):
					continue

				KEYDAY = np.array(-d.sort(columns='KEYDAY', ascending=False)['KEYDAY'])
				
				plt.plot(KEYDAY, OVRBKD)

		title = Utils.createTitleForFeatures(orgs,dests,flights,cabins,bcs,date_ranges)
		plt.title(title)
		plt.xlabel('-KEYDAY')
		plt.ylabel('Percentage Overbooked: AUTH / CAP')
		plt.show()
开发者ID:kmcconnaughay,项目名称:ICF-Project,代码行数:48,代码来源:Visualizer.py

示例2: overbookingVsCabinLoadFactor

# 需要导入模块: from Utils import Utils [as 别名]
# 或者: from Utils.Utils import isOverbooked [as 别名]
	def overbookingVsCabinLoadFactor(self, network, orgs=None, dests=None, flights=None, 
									cabins=None, bcs=None, date_ranges=None, 
									normalized=True, subplots=True):
		""" Plots how overbooking varies with Cabin load factor.  Final Cabin Load Factor
		for a particular flight booking class is binned into three separate categories:
		
		Overbooked: CLF > 1
		Underbooked: CLF < .8
		Optimumly booked: .8 < CLF < 1
		
		"""
		df = network.f.getDrillDown(orgs=orgs, dests=dests, flights=flights,
							cabins=cabins, bcs=bcs, date_ranges=date_ranges)

		fltbk = network.f.getUniqueFlightsAndBookings(df)
		# TODO: allow for countFinalCabinLoadFactor to use normalized data		
		CLF_dict = network.countFinalCabinLoadFactor()

		fig = plt.figure()
		# preparing to capture the legend handles
		legend_over = None
		legend_under = None
		legend_optimum = None
		n_over = 0
		n_under = 0
		n_optimum = 0

		if normalized:
			for g, d in fltbk:
				# normalized AUTH == OVERBOOKED
				AUTH = np.array(d.sort(columns='KEYDAY', ascending=False)['AUTH'])
				
				# ignore time series that are not overbooked
				if not Utils.isOverbooked(AUTH):
					continue

				KEYDAY = np.array(-d.sort(columns='KEYDAY', ascending=False)['KEYDAY'])
				DATE = d.iloc[0]['DATE']
				FLT = d.iloc[0]['FLT']
				ORG = d.iloc[0]['ORG']
				DES = d.iloc[0]['DES']
				
				#TODO: See CLF_dict (above)
				CABIN_LOAD_FACTOR = CLF_dict[(DATE, FLT, ORG, DES)]

				if CABIN_LOAD_FACTOR > 1:
					plt.plot(KEYDAY, AUTH, 'r')
				elif CABIN_LOAD_FACTOR < .95: 
					plt.plot(KEYDAY, AUTH, 'y')
				else:
					plt.plot(KEYDAY, AUTH, 'g')
		else:
			for g, d in fltbk:
				
				AUTH = np.array(d.sort(columns='KEYDAY', ascending=False)['AUTH'])
				CAP = float(d.iloc[0]['CAP'])
				OVRBKD = AUTH/CAP

				# ignore time series that are not overbooked
				if not Utils.isOverbooked(OVRBKD):
					continue

				KEYDAY = np.array(-d.sort(columns='KEYDAY', ascending=False)['KEYDAY'])
				DATE = d.iloc[0]['DATE']
				FLT = d.iloc[0]['FLT']
				ORG = d.iloc[0]['ORG']
				DES = d.iloc[0]['DES']

				CABIN_LOAD_FACTOR = CLF_dict[(DATE, FLT, ORG, DES)]

				


				if CABIN_LOAD_FACTOR > 1:
					plt.subplot(311) if subplots else None
					if not legend_over:
						legend_over, = plt.plot(KEYDAY, OVRBKD , 'r')
					else:
						plt.plot(KEYDAY, OVRBKD , 'r')
					n_over += 1

				elif CABIN_LOAD_FACTOR < .95: 
					plt.subplot(313) if subplots else None
					if not legend_under:
						legend_under, = plt.plot(KEYDAY, OVRBKD, 'y')
					else:
						plt.plot(KEYDAY, OVRBKD, 'y')
					n_under += 1

				else:
					plt.subplot(312) if subplots else None
					if not legend_optimum:
						legend_optimum, = plt.plot(KEYDAY, OVRBKD, 'g')
					else:
						plt.plot(KEYDAY, OVRBKD, 'g')
					n_optimum += 1

		title = Utils.createTitleForFeatures(orgs,dests,flights,cabins,bcs,date_ranges)
		plt.subplot(311) if subplots else None
		plt.suptitle(title)
#.........这里部分代码省略.........
开发者ID:kmcconnaughay,项目名称:ICF-Project,代码行数:103,代码来源:Visualizer.py


注:本文中的Utils.Utils.isOverbooked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。