# owner:@aviviguixiang
# createtime:2019/7/22
# 任务:芒市20190326—20190328、20190330—20190401气象场、监测数据逐时折线

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
zhfont1 = fm.FontProperties(fname=r'D:\pycharm_project\190325\taihexian\data\SIMKAI.TTF')


def draw(data,a,b,p1,p2,p3,p4,p5,p6):
fig,(ax00, ax10, ax20, ax30) = plt.subplots(4, 1, sharex=True,figsize=(10, 11))
# fig, ax = plt.subplots(4, 1, figsize=(10, 11))
ax00 .plot(data.loc[a:b,p1].values,'k-',linewidth=2)
ax00.set_ylabel(r'温度(℃)',fontproperties=zhfont1,size=12)
ax10 .plot(data.loc[a:b,p2].values,'k-',linewidth=2)
ax10.set_ylabel(r'十米风速(m/s)', fontproperties=zhfont1, size=12)
ax20 .plot(data.loc[a:b,p3].values,'k-',linewidth=2)
ax20.set_ylabel(r'气压(hPa)', fontproperties=zhfont1, size=12)
ax30 .plot(data.loc[a:b,p4].values,'k-',linewidth=2)
ax30.set_ylabel(r'相对湿度(%)', fontproperties=zhfont1, size=12)
x_lable=list(data.loc[a:b,p6].values[0:72:10])
print(x_lable)
# x_lable.append(data.loc[a:b,p6].values[0])
new_x=sorted(x_lable)
print(type(new_x))
plt.xlim(0,71)
ax30.set_xlabel('日期', fontproperties=zhfont1, size=12)
ax30.set_xticklabels(new_x, fontproperties=zhfont1, size=12)
print(new_x)
plt.savefig(r'D:\pycharm_project\1205\mangshi\png\qi_2.png')
plt.show()


def draw_1(data,a,b,p1,p2,p3,p4,p5,p6):
fig,(ax00, ax10, ax20, ax30,ax40) = plt.subplots(5, 1, sharex=True,figsize=(10, 11))
# fig, ax = plt.subplots(4, 1, figsize=(10, 11))
ax00 .plot(data.loc[a:b,p1].values,'k-',linewidth=2)
ax00.set_ylabel(r'$PM_{2.5}$'+r'($\mu{g/m}^{3}$)',fontproperties=zhfont1,size=12)
ax10 .plot(data.loc[a:b,p2].values,'k-',linewidth=2)
ax10.set_ylabel(r'$PM_{10}$'+r'($\mu{g/m}^{3}$)', fontproperties=zhfont1, size=12)
ax20 .plot(data.loc[a:b,p3].values,'k-',linewidth=2)
ax20.set_ylabel(r'CO'+r'($m{g/m}^{3}$)', fontproperties=zhfont1, size=12)
ax30 .plot(data.loc[a:b,p4].values,'k-',linewidth=2)
ax30.set_ylabel(r'$SO_{2}$'+r'($\mu{g/m}^{3}$)', fontproperties=zhfont1, size=12)
ax40.plot(data.loc[a:b, p5].values,'k-',linewidth=2)
ax40.set_ylabel(r'$NO_{2}$'+r'($\mu{g/m}^{3}$)', fontproperties=zhfont1, size=12)
x_lable = list(data.loc[a:b, p6].values[0:72:10])
print(x_lable)
new_x = sorted(x_lable)
print(type(new_x))
plt.xlim(0, 71)
ax40.set_xlabel('日期', fontproperties=zhfont1, size=12)
ax40.set_xticklabels(new_x, fontproperties=zhfont1, size=12)
print(new_x)
plt.savefig(r'D:\pycharm_project\1205\mangshi\png\qi_4.png')
plt.show()




if __name__ == '__main__':

file=r'D:\pycharm_project\1205\mangshi\data\1\ms_0722.xlsx'
data1=pd.read_excel(file,sheet_name='average')
data2=pd.read_excel(file,sheet_name='56844')
print(data1)
# draw(data2,0,72,'TEM','WIN_S_Avg_10mi','PRS','RHU','','TimeStamp')
# draw(data2,96,168,'TEM','WIN_S_Avg_10mi','PRS','RHU','','TimeStamp')
# draw_1(data1,0,72,'pm25','pm10','co','so2','no2','aqitime')
draw_1(data1,96,168,'pm25','pm10','co','so2','no2','aqitime')
# print(data2)