引言
AGS中可以導(dǎo)出每次飛行的快照數(shù)據(jù),這些數(shù)據(jù)對(duì)于飛行品質(zhì)的分析非常有幫助监婶。目前上航每月737航班約產(chǎn)生9000-10000行快照信息,每行信息包含200個(gè)字段
分析字段
現(xiàn)階段僅針對(duì)以下字段進(jìn)行監(jiān)控和分析,分別對(duì)應(yīng)100英尺以下最大坡度葫哗、接地最大垂直載荷匈辱,油門慢車高度振湾、接地姿態(tài)
event_name_landing=['`ROLL_MAX_BL100 (deg)`','`VRTG_MAX_LD (g)`','`RETARD_ALT (FT)`','`PITCH_LANDING (deg)`']
分析方法一
使用經(jīng)典的mysql導(dǎo)出數(shù)據(jù)列表,將字段信息寫(xiě)入list列表亡脸,再通過(guò)對(duì)list進(jìn)行統(tǒng)計(jì)學(xué)分析得到結(jié)果
print("機(jī)隊(duì),字段,月份,航班快照量,Q1值,中位數(shù),Q3值,Q90,標(biāo)準(zhǔn)差,變異系數(shù),平均值")
for column in columnlist:
for month in monthlist:
sql="select ags.ags_id,flnk.`航班日期`,ags.`From`,ags.`To`,ags.%s as 數(shù)據(jù) from ags_snapshot ags,flight_link_chn flnk where flnk.key_id=ags.key_id and date_format(flnk.航班日期,'%%Y-%%m')='%s' and flnk.機(jī)型 IN (%s)" % (column,month,ac_type)
#print(sql)
a=query(sql)
if a.rowcount>0:
result=a.fetchall()
list=[]
for row in result:
#data=row['數(shù)據(jù)']
#數(shù)據(jù)庫(kù)里是字符串押搪,這里必須轉(zhuǎn)換成浮點(diǎn)數(shù)
list.append(float(row['數(shù)據(jù)']))
#輸出結(jié)果
print(len(list))
Q1=np.percentile(list,25)
Q2=np.percentile(list,50)
Q3=np.percentile(list,75)
#注:Q90在個(gè)人數(shù)據(jù)中沒(méi)有意義,不做統(tǒng)計(jì)
Q90=np.percentile(list,90)
m_std=std(list,ddof=1)
m_mean=mean(list)
m_cv=std(list,ddof=1)/m_mean
#print(name,month,Q2,Q3,m_std,m_cv)
#清空l(shuí)ist列表
list=[]
print("%s,%s,%s,%d,%f,%f,%f,%f,%f,%f,%f" % ("B737機(jī)隊(duì)",column,month,len(list),Q1,Q2,Q3,Q90,m_std,m_cv,m_mean))
else:
pass
pass
分析方法二
使用pandas做為數(shù)據(jù)輸入源浅碾,理論上速度更快
print("機(jī)隊(duì),字段,月份,航班快照量,Q1值,中位數(shù),Q3值,Q90,標(biāo)準(zhǔn)差,變異系數(shù),平均值")
for column in columnlist:
for month in monthlist:
sql="select ags.ags_id,flnk.`航班日期`,ags.`From`,ags.`To`,ags.%s as 數(shù)據(jù) from ags_snapshot ags,flight_link_chn flnk where flnk.key_id=ags.key_id and date_format(flnk.航班日期,'%%Y-%%m')='%s' and flnk.機(jī)型 IN (%s)" % (column,month,ac_type)
df=query_df(sql)
#數(shù)據(jù)類型轉(zhuǎn)換 text->float
df_float=df['數(shù)據(jù)'].astype('float')
count=df_float.count()
Q1=df_float.quantile(0.25)
Q2=df_float.quantile(0.50)
Q3=df_float.quantile(0.75)
#注:Q90在個(gè)人數(shù)據(jù)中沒(méi)有意義大州,不做統(tǒng)計(jì)
Q90=df_float.quantile(0.9)
m_std=df_float.std()
#m_std=std(list,ddof=1)
m_mean=df_float.mean()
m_cv=m_std/m_mean
print("%s,%s,%s,%d,%f,%f,%f,%f,%f,%f,%f" % ("B737機(jī)隊(duì)",column,month,count,Q1,Q2,Q3,Q90,m_std,m_cv,m_mean))
#print(stats1(df_float))
分析結(jié)果:
image.png